:root {
  /* AniBasa brand — фіксована тема, не Telegram theme */
  --bg: #070b14;
  --bg-elev: #0f1524;
  --bg-soft: #171e30;
  --line: rgba(122, 180, 255, 0.12);
  --text: #eef3fb;
  --muted: #8b97ad;
  --accent: #4aa3ef;
  --accent-2: #7ec4ff;
  --accent-glow: rgba(74, 163, 239, 0.35);
  --danger: #e25b5b;
  --ok: #3dbf8a;
  --radius: 16px;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --font: "Outfit", system-ui, sans-serif;
  --display: "Syne", "Outfit", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --top: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body.theme-anibasa {
  background-color: var(--bg) !important;
  background-image:
    radial-gradient(900px 420px at 50% -8%, rgba(74, 163, 239, 0.22), transparent 55%),
    radial-gradient(700px 380px at 100% 12%, rgba(36, 90, 160, 0.18), transparent 50%),
    radial-gradient(600px 320px at 0% 40%, rgba(20, 50, 90, 0.2), transparent 55%),
    linear-gradient(180deg, #070b14 0%, #0a1020 45%, #070b14 100%);
  background-attachment: fixed;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

#app {
  max-width: 920px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(28px + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(7, 11, 20, 0.78);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.brand-logo {
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-logo-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(126, 196, 255, 0.2), 0 4px 16px rgba(0, 0, 0, 0.35);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #5b95ff, #3a6fd6);
  font-weight: 700;
  font-size: 14px;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.topbar-actions { margin-left: auto; }

.icon-btn, .text-btn, .btn, .tab {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.text-btn {
  color: var(--accent-2);
  font-weight: 600;
  padding: 8px 10px;
}

.view { padding: 12px 14px 0; }
.view-home { padding-top: 8px; }
.hidden { display: none !important; }

/* ——— Home hero (logo) ——— */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 8px 20px;
  animation: heroIn 0.55s ease both;
}

.home-hero-logo {
  width: min(52vw, 200px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 12px 36px rgba(74, 163, 239, 0.28));
  animation: logoFloat 5.5s ease-in-out infinite;
}

.home-hero-tagline {
  margin: 14px 0 0;
  max-width: 28em;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 500;
}

@keyframes heroIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.catalog-tools {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(15, 21, 36, 0.72);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

.search-row { margin: 0; }

.search-row input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.65);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-row input:focus {
  border-color: rgba(74, 163, 239, 0.55);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-block { display: grid; gap: 8px; }
.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gchip {
  border: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.45);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.gchip:hover { border-color: rgba(74, 163, 239, 0.4); }
.gchip.active {
  background: linear-gradient(135deg, rgba(74, 163, 239, 0.28), rgba(74, 163, 239, 0.12));
  border-color: rgba(74, 163, 239, 0.55);
  color: #d7ecff;
}

.year-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.year-range-label {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-2);
}
.year-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ypill {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.ypill.active {
  color: var(--text);
  border-color: rgba(74, 163, 239, 0.45);
  background: rgba(74, 163, 239, 0.12);
}

.dual-range {
  position: relative;
  height: 28px;
  margin-top: 4px;
}
.dual-range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.dual-range-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 100%;
}
.dual-range input[type="range"] {
  position: absolute;
  left: 0;
  width: 100%;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  appearance: none;
  background: transparent;
  pointer-events: none;
  height: 28px;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (min-width: 640px) {
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .home-hero-logo { width: min(40vw, 220px); }
}

.card-title {
  display: block;
  text-align: left;
  border: 0;
  padding: 0;
  background: var(--bg-elev);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: cardIn 0.4s ease both;
}

.card-title:active { transform: scale(0.985); }
.card-title:hover {
  border-color: rgba(74, 163, 239, 0.4);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(74, 163, 239, 0.12);
  transform: translateY(-2px);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  background:
    linear-gradient(160deg, #1a2438, #0c1220 70%),
    var(--bg-soft);
  overflow: hidden;
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.card-cover-fade {
  position: absolute;
  inset: auto 0 0 0;
  height: 42%;
  background: linear-gradient(to top, rgba(7, 11, 20, 0.92), transparent);
  pointer-events: none;
}
.card-cover-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.card-body { padding: 11px 12px 13px; }
.card-body h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  line-height: 1.3;
  font-weight: 650;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty, .hint, .muted { color: var(--muted); }
.empty { text-align: center; padding: 40px 10px; }

/* ——— Title page ——— */
.view-title { padding-top: 10px; }

.title-page { display: grid; gap: 0; }

.title-hero {
  position: relative;
  min-height: 280px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(145deg, #152038, #0a1020);
  margin-bottom: 0;
  box-shadow: var(--shadow);
}

.title-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.title-hero-shade {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 18px 18px;
  background:
    linear-gradient(to top, rgba(7, 11, 20, 0.96) 0%, rgba(7, 11, 20, 0.55) 42%, rgba(7, 11, 20, 0.15) 70%, transparent 100%);
}

.title-genre-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.title-genre-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(74, 163, 239, 0.18);
  border: 1px solid rgba(74, 163, 239, 0.35);
  color: #cfe8ff;
}

.title-hero h1 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.55rem, 5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.title-meta {
  margin: 0;
  color: rgba(238, 243, 251, 0.78);
  font-size: 0.88rem;
  font-weight: 500;
}

.title-body {
  padding: 16px 4px 0;
}

.title-orig {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-style: italic;
}

.title-desc {
  line-height: 1.6;
  color: #c2cad8;
  margin: 0 0 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.section-label {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.episode-list { display: grid; gap: 8px; }

.ep-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 21, 36, 0.95), rgba(12, 18, 32, 0.95));
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ep-item:hover:not(:disabled) {
  border-color: rgba(74, 163, 239, 0.4);
  transform: translateX(2px);
}

.ep-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ep-num {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(74, 163, 239, 0.12);
  border: 1px solid rgba(74, 163, 239, 0.22);
  font-weight: 700;
  color: var(--accent-2);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.ep-item strong { display: block; font-size: 0.95rem; }
.ep-item span { font-size: 0.8rem; color: var(--muted); }
.ep-item .go {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(74, 163, 239, 0.16);
  color: var(--accent-2);
  font-weight: 700;
  font-size: 0.75rem;
}

/* ——— Cinema player ——— */
.player-view {
  padding: 0 !important;
  margin: 0;
}

body.cinema-mode .topbar { display: none; }
body.cinema-mode #app {
  max-width: none;
  padding-bottom: 0;
}

.cinema {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  background: #000;
}

.cinema-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  touch-action: manipulation;
}

.cinema-stage:fullscreen,
.cinema-stage:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #000;
}

#player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

.cinema-ui {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,.72) 0%, transparent 28%, transparent 62%, rgba(0,0,0,.78) 100%);
  opacity: 1;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.cinema-ui.is-hidden { opacity: 0; }
.cinema-ui > * { pointer-events: auto; }

.cinema-top, .cinema-bottom {
  padding: 12px 14px;
}

.cinema-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.cinema-head { flex: 1; min-width: 0; }
.cinema-head h2 {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cinema-head p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255,255,255,.72);
}

.cinema-icon, .cinema-playbtn, .cinema-bigplay {
  border: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(255,255,255,.12);
}

.cinema-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.cinema-playbtn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: var(--accent);
}

.cinema-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 22px;
  z-index: 3;
  pointer-events: none;
}

.cinema-center.hidden { display: none; }

.cinema-center > * { pointer-events: auto; }

.cinema-bigplay {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 1.4rem;
  background: rgba(79, 140, 255, 0.92);
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}

.cinema-seekbtn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(255,255,255,.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, transform 0.12s ease;
}

.cinema-seekbtn:active {
  transform: scale(0.94);
  background: rgba(255,255,255,.28);
}

.cinema-seek-ico {
  font-size: 1.15rem;
  font-weight: 700;
}

.cinema-seek-sec {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.9;
  margin-top: -2px;
}

/* помилка поверх центральних кнопок */
.cinema-error {
  z-index: 5;
}
.cinema-error:not(.hidden) ~ .cinema-center {
  display: none !important;
}

.cinema-progress {
  position: relative;
  height: 28px; /* зона кліку ширша за видиму смужку */
  margin-bottom: 4px;
  cursor: pointer;
  touch-action: none;
}

.cinema-progress::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  border-radius: 99px;
  background: rgba(255,255,255,.22);
  pointer-events: none;
}

.cinema-progress-bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  pointer-events: none;
  z-index: 1;
}

.cinema-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.cinema-time {
  margin-left: 4px;
  font-size: 0.8rem;
  color: rgba(255,255,255,.78);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.cinema-volume {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
  min-width: 0;
}

.cinema-vol-btn {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.cinema-volume-range {
  width: 72px;
  max-width: 18vw;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  appearance: none;
  background: rgba(255,255,255,.22);
  border-radius: 99px;
  outline: none;
}

.cinema-volume-range::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.cinema-volume-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

@media (max-width: 420px) {
  .cinema-volume-range { width: 52px; }
  .cinema-autoplay-label { display: none; }
}

.cinema-autoplay {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.88);
  cursor: pointer;
  padding: 4px 0;
  flex-shrink: 0;
}

.cinema-controls #cinema-autoplay { margin-left: auto; }
.cinema-controls #cinema-autoskip { flex-shrink: 0; }
@media (max-width: 520px) {
  .cinema-autoplay-label { max-width: 6.5em; }
}

.cinema-skip {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(20, 24, 32, 0.72);
  border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(8px);
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
}

.cinema-skip:active { transform: translateY(-50%) scale(0.98); }
.cinema-skip.hidden { display: none; }

.cinema-autoplay-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  max-width: 9.5em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cinema-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.22);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.cinema-switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  display: block;
}

.cinema-autoplay[aria-pressed="true"] .cinema-switch {
  background: var(--accent);
}

.cinema-autoplay[aria-pressed="true"] .cinema-switch i {
  transform: translateX(16px);
}

.cinema-loading, .cinema-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: rgba(0,0,0,.45);
  z-index: 2;
  color: rgba(255,255,255,.85);
}

.cinema-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.cinema-error p {
  margin: 0 16px 8px;
  max-width: 320px;
  line-height: 1.4;
}

.cinema-icon:disabled, .cinema-playbtn:disabled {
  opacity: 0.35;
  cursor: default;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ——— Admin ——— */
.admin-shell { padding-bottom: 8px; }

.admin-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}

.admin-nav-btn {
  padding: 11px 12px;
  border-radius: 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.admin-nav-btn.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.admin-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-toolbar .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.btn.is-busy {
  opacity: 0.7;
  pointer-events: none;
}

.admin-heading {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.45rem;
}

.admin-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.admin-title-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .admin-title-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.admin-title-card {
  display: block;
  text-align: left;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.admin-title-card:active { transform: scale(0.98); }
.admin-title-card:hover { border-color: rgba(79, 140, 255, 0.4); }

.admin-title-cover {
  aspect-ratio: 16 / 10;
  background: linear-gradient(145deg, #2b3446, #171c26);
  background-size: cover;
  background-position: center;
}

.admin-title-body { padding: 10px 11px 12px; }
.admin-title-body h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  line-height: 1.25;
}
.admin-title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: 0.78rem;
}

.chip-soft {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.14);
  color: var(--accent-2);
  font-weight: 600;
}

.media-controls { display: grid; gap: 10px; margin-bottom: 14px; }
.media-controls input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  outline: none;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip.active {
  color: var(--text);
  border-color: rgba(79, 140, 255, 0.45);
  background: rgba(79, 140, 255, 0.14);
}

.attach-banner-text { min-width: 0; flex: 1; }
.attach-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.attach-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  border: 1px solid rgba(79, 140, 255, 0.35);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.16), rgba(79, 140, 255, 0.05));
}

.attach-banner strong { display: block; margin-bottom: 2px; }
.attach-banner span { font-size: 0.85rem; }

.media-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 560px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.media-card {
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.media-card:hover { border-color: rgba(79, 140, 255, 0.35); }
.media-card.is-pickable {
  border-color: rgba(61, 191, 138, 0.35);
  background: linear-gradient(180deg, rgba(61, 191, 138, 0.08), var(--bg-elev));
}
.media-card.is-used { opacity: 0.72; }
.media-card:active { transform: scale(0.985); }

.admin-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.media-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.media-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.media-del {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 90, 90, 0.14);
  color: #ff8e8e;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

.media-del:hover { background: rgba(255, 90, 90, 0.28); }

.file-icon {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3a4a66, #243044);
  color: #d7e4ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.file-icon.lg {
  min-width: 52px;
  height: 52px;
  font-size: 0.8rem;
}

.media-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.media-fname {
  margin: 2px 0 0;
  font-size: 0.92rem;
  line-height: 1.3;
  word-break: break-word;
  font-weight: 650;
}

.media-meta, .media-status {
  margin: 0;
  font-size: 0.78rem;
}

.media-status { color: var(--accent-2); min-height: 1.1em; }

.row-2 {
  display: grid;
  gap: 10px;
}

@media (min-width: 520px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  padding: 10px 14px;
  border-radius: 11px;
  font-weight: 650;
  border: 0;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: var(--bg-soft);
  color: var(--text);
}

.btn.danger {
  background: rgba(226, 91, 91, 0.18);
  color: #ffb0b0;
}

.btn.grow { width: 100%; }

/* Sheets */
body.sheet-open { overflow: hidden; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.62);
  backdrop-filter: blur(4px);
}

.sheet-card {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 8px 16px calc(18px + var(--safe-b));
  border-radius: 22px 22px 0 0;
  background: #1a1f29;
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  animation: sheetUp 0.22s ease;
}

.sheet-card-sm { max-height: 70dvh; }
.sheet-card-wide {
  max-height: 92dvh;
  width: min(100%, 720px);
}

.ep-editor { display: grid; gap: 14px; }
#sheet-episode {
  z-index: 46; /* вище workspace sheet, щоб превʼю не ховалось */
}
.ep-preview-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  min-height: 180px;
}
.ep-preview-wrap video {
  display: block;
  width: 100%;
  min-height: 180px;
  max-height: 42dvh;
  background: #000;
  object-fit: contain;
}
.ep-preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-elev);
}
.ep-preview-bar #ep-preview-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin-right: 4px;
  min-width: 3.2em;
}
.btn.sm {
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 10px;
}
.ep-timecode-hint { margin: 0 0 4px; font-size: 0.82rem; }

.ws-ep-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  margin: 4px auto 12px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-family: var(--display);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.sheet-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.sheet-form input,
.sheet-form textarea,
.sheet-form select,
.sheet-card label input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  outline: none;
  color: var(--text);
}

.sheet-form textarea.desc-input {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
  white-space: pre-wrap;
  field-sizing: content;
}

.sheet-form .check,
.sheet-card .check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.sheet-form .check input { width: auto; }

.sheet-card label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.ws-episodes { display: grid; gap: 8px; }

.ws-ep {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.ws-ep-body { flex: 1; min-width: 0; }
.ws-ep-body strong { display: block; font-size: 0.92rem; }
.ws-ep-body .file-name {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.ep-num.sm {
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
}

.danger-soft {
  background: rgba(226, 91, 91, 0.14) !important;
  color: #ffb0b0;
}

.pin-preview {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.pin-preview strong {
  display: block;
  word-break: break-word;
  margin-bottom: 4px;
}

.pin-target { margin: 0 0 12px; }

.empty.soft { padding: 18px 8px; }

@keyframes sheetUp {
  from { transform: translateY(18px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #10141b;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.boot-card { text-align: center; color: var(--muted); }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view:not(.hidden) { animation: fadein 0.22s ease; }
.card-title { animation: fadein 0.28s ease; }
