/* ==========================================================================
   AniBublik — style.css
   Спільні стилі для index.html, anime.html, profile.html

   Структура:
   1. Токени (кольори, шрифти, радіуси)
   2. База та утиліти
   3. Кнопки, чіпи, теги, бейджі, аватар
   4. Хедер, меню, пошук, випадаючі списки
   5. Постери та картки
   6. Головна: hero, секції, сітки
   7. Сторінка тайтлу: шапка, сайдбар, плеєр, серії, коментарі
   8. Профіль: шапка, статистика, вкладки, таблиця безпеки
   9. Футер, модалка входу, тости
   ========================================================================== */

/* 1. ТОКЕНИ ---------------------------------------------------------------- */
:root {
  /* Північна синява замість «чорного» — тло з відтінком */
  --ink: #0a0e22;
  --ink-2: #0e1331;
  --surface: #131a3a;
  --surface-2: #1b2450;
  --surface-3: #263168;
  --line: rgba(160, 175, 255, 0.12);
  --line-strong: rgba(160, 175, 255, 0.24);

  --text: #eef1ff;
  --muted: #a3acd4;
  --faint: #8791bd;

  /* Сонячно-жовтий — головна дія; рожевий — «рідкісний» акцент */
  --sun: #ffd23f;
  --sun-hover: #ffdd68;
  --sun-ink: #1d1600;
  --pink: #ff4f9a;
  --cyan: #5cd5ff;
  --mint: #5ee6a8;
  --danger: #ff6b81;

  /* Кольори статусів списків */
  --c-watch: #5cd5ff;
  --c-plan: #a99bff;
  --c-done: #5ee6a8;
  --c-hold: #ffd23f;
  --c-drop: #ff6b81;

  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-jp: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", "Microsoft YaHei", sans-serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 24px;

  --wrap: 1280px;
  --gutter: clamp(16px, 3vw, 32px);
  --header-h: 72px;
}

/* 2. БАЗА ------------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection { background: var(--pink); color: #fff; }

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 200;
  padding: 10px 16px; border-radius: 10px;
  background: var(--sun); color: var(--sun-ink); font-weight: 700;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--fill { fill: currentColor; stroke: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* 3. КНОПКИ, ЧІПИ, ТЕГИ ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
  height: 44px; padding: 0 20px;
  border-radius: 12px;
  font-weight: 600; font-size: 0.95rem; white-space: nowrap;
  transition: transform 0.15s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn .icon { width: 1.15em; height: 1.15em; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--sun); color: var(--sun-ink);
  box-shadow: 0 10px 26px -12px rgba(255, 210, 63, 0.75);
}
.btn--primary:hover { background: var(--sun-hover); }

.btn--ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line-strong);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.13); }

.btn--block { width: 100%; }
.btn--lg { height: 54px; padding: 0 28px; font-size: 1.02rem; border-radius: 14px; }
.btn--sm { height: 38px; padding: 0 16px; font-size: 0.9rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  color: var(--muted);
  transition: background-color 0.2s, color 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-size: 0.85rem; font-weight: 500;
}
a.chip:hover { background: rgba(255, 255, 255, 0.15); }
.chip--sun { background: var(--sun); color: var(--sun-ink); border-color: transparent; font-weight: 700; }

.tags { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--muted);
}
.tag::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c, var(--muted));
}
.tag--dub { --c: var(--sun); }
.tag--sub { --c: var(--cyan); }

.badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 8px; font-size: 0.8rem; font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
}
.badge--ok { background: rgba(94, 230, 168, 0.14); color: var(--mint); }
.badge--warn { background: rgba(255, 107, 129, 0.16); color: var(--danger); }
.badge--info { background: rgba(92, 213, 255, 0.14); color: var(--cyan); }

.avatar {
  --h: 260;
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  font: 700 1rem var(--font-display);
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 80% 55%), hsl(calc(var(--h) + 50) 80% 40%));
}
.avatar--sm { width: 38px; height: 38px; font-size: 0.85rem; }
.avatar--xl { width: 128px; height: 128px; font-size: 2.6rem; border: 4px solid var(--ink); }
.avatar.has-image { background-position: center; background-repeat: no-repeat; background-size: cover; }

/* 4. ХЕДЕР ----------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--line);
}
/* blur винесено в псевдоелемент: backdrop-filter на самому хедері
   зламав би position:fixed для мобільного меню */
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: rgba(10, 14, 34, 0.78);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  transition: background-color 0.25s;
}
.site-header.is-scrolled::before { background: rgba(10, 14, 34, 0.94); }

.site-header__row { display: flex; align-items: center; gap: 18px; height: var(--header-h); }

.logo { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.logo__mark { width: 34px; height: 34px; }
.logo__text { font: 700 1.2rem var(--font-display); letter-spacing: -0.02em; }
.logo__text b { color: var(--sun); font-weight: 700; }

.burger { display: none; }

.nav__list { display: flex; align-items: center; gap: 2px; }
.nav__link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500; font-size: 0.95rem;
  transition: color 0.2s, background-color 0.2s;
}
.nav__link:hover, .has-dropdown.is-open > .nav__link { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.nav__link[aria-current="page"] { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.nav__link .icon { width: 16px; height: 16px; transition: transform 0.2s; }
.has-dropdown.is-open > .nav__link > .icon:last-child { transform: rotate(180deg); }

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pink); box-shadow: 0 0 0 3px rgba(255, 79, 154, 0.22);
}

.nav__dice .icon { width: 18px; height: 18px; color: var(--sun); }
.nav__dice.is-rolling .icon { animation: dice-roll 0.6s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes dice-roll {
  from { transform: rotate(-200deg) scale(0.7); }
  to { transform: none; }
}

/* Пошук */
.search { flex: 1 1 220px; min-width: 0; max-width: 440px; margin-left: auto; }
.search__field {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 12px 0 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color 0.2s, background-color 0.2s;
}
.search__field:focus-within {
  border-color: var(--sun); background: rgba(255, 255, 255, 0.09); color: var(--text);
}
.search__input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; outline: 0;
  color: var(--text); font: inherit; font-size: 0.93rem;
  text-overflow: ellipsis;
}
.search__input::placeholder { color: var(--faint); text-overflow: ellipsis; }
.search__hint {
  flex: none; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px;
  border: 1px solid var(--line-strong);
  font: 600 0.75rem var(--font-body); color: var(--faint);
}
.search-toggle { display: none; margin-left: auto; }

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* Стан авторизації керується атрибутом <html data-auth="guest|user"> */
html[data-auth="user"] .auth__login { display: none; }
html[data-auth="guest"] .auth__user { display: none; }
.avatar-btn { display: inline-grid; border-radius: 50%; transition: box-shadow 0.2s; }
.avatar-btn:hover, .auth__user.is-open .avatar-btn { box-shadow: 0 0 0 3px var(--line-strong); }

/* Випадаючі списки (каталог, меню профілю, «додати в список») */
.has-dropdown { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 60;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: 0 34px 60px -24px rgba(0, 0, 0, 0.8);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
}
/* «місток», щоб hover не губився в проміжку під кнопкою */
.dropdown::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.has-dropdown.is-open > .dropdown { opacity: 1; visibility: visible; transform: none; }
.dropdown--mega {
  display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 28px;
  width: min(660px, 92vw);
}
.dropdown__title { font: 600 0.95rem var(--font-display); margin-bottom: 10px; }
.dropdown__col a {
  display: block; padding: 6px 0; color: var(--muted); font-size: 0.93rem;
  transition: color 0.15s, transform 0.15s;
}
.dropdown__col a:hover { color: var(--sun); transform: translateX(3px); }
.dropdown__all { margin-top: 6px; color: var(--text) !important; font-weight: 600; }

.dropdown--catalog {
  display: block;
  width: min(680px, calc(100vw - 32px));
  padding: 0 22px 18px;
  overflow: hidden;
  border: 1px solid #c8d9f02e;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 2% 0, #6b78bb1e, transparent 46%),
    linear-gradient(145deg, #1a2a46, #121e33 82%);
  box-shadow: 0 28px 72px -30px #000e, 0 8px 26px #050b1880;
}
.catalog-menu__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 15px;
  border-bottom: 1px solid #d5e2f21c;
}
.catalog-menu__top > div {
  display: grid;
  gap: 3px;
}
.catalog-menu__eyebrow,
.catalog-menu__label {
  color: #b7c8e2a8;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.catalog-menu__top strong {
  color: #f5f7ff;
  font: 700 1rem/1.35 var(--font-display);
  letter-spacing: -0.035em;
}
.catalog-menu__top > a,
.catalog-menu__all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--sun);
  font-size: 0.8rem;
  font-weight: 750;
  white-space: nowrap;
}
.catalog-menu__top > a span,
.catalog-menu__all span {
  transition: transform 0.18s ease;
}
.catalog-menu__top > a:hover span,
.catalog-menu__all:hover span {
  transform: translate(2px, -2px);
}
.catalog-menu__body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 22px;
  padding-top: 17px;
}
.catalog-menu__section h3 {
  margin: 5px 0 13px;
  color: #f4f6fd;
  font: 650 0.94rem/1.4 var(--font-display);
  letter-spacing: -0.035em;
}
.catalog-menu__section--years {
  padding-left: 20px;
  border-left: 1px solid #d5e2f21c;
}
.catalog-menu__genres,
.catalog-menu__years {
  display: grid;
  gap: 7px;
}
.catalog-menu__genres {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.catalog-menu__years {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.catalog-menu__genres a,
.catalog-menu__years a {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #c4d6ef12;
  border-radius: 10px;
  background: #eaf1ff08;
  color: #c1cde0;
  font-size: 0.79rem;
  font-weight: 600;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}
.catalog-menu__years a {
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.catalog-menu__genres a::before {
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: #8fb4d5;
  content: "";
  flex: none;
}
.catalog-menu__genres a:hover,
.catalog-menu__years a:hover {
  transform: translateY(-1px);
  border-color: #ffe07860;
  background: #ffe07812;
  color: #fff0bf;
}
.catalog-menu__genres a:hover::before {
  background: var(--sun);
}
.catalog-menu__all {
  margin-top: 13px;
}
.dropdown--catalog a:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 2px;
}

.dropdown--user, .dropdown--list { padding: 8px; min-width: 220px; }
.dropdown--user { left: auto; right: 0; }
.dropdown__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text); font-size: 0.94rem; text-align: left;
  transition: background-color 0.15s;
}
.dropdown__item:hover { background: rgba(255, 255, 255, 0.08); }
.dropdown__item .icon { width: 18px; height: 18px; color: var(--muted); }
.dropdown__item[aria-checked="true"] { color: var(--sun); }
.dropdown__item[aria-checked="true"]::after { content: "✓"; margin-left: auto; font-weight: 700; }
.dropdown__sep { height: 1px; margin: 6px 4px; background: var(--line); }
.dropdown__who { padding: 10px 12px 8px; }
.dropdown__who strong { display: block; font-size: 0.95rem; }
.dropdown__who span { color: var(--faint); font-size: 0.82rem; }

/* Мобільна версія хедера */
@media (max-width: 1099px) {
  .burger { display: inline-grid; margin-left: -8px; }
  .nav {
    position: fixed; inset: var(--header-h) 0 0 0; z-index: 40;
    padding: 12px var(--gutter) 40px;
    background: var(--ink); overflow-y: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform 0.28s ease, visibility 0.28s;
  }
  .nav.is-open { transform: none; visibility: visible; }
  .nav-open { overflow: hidden; }
  .nav__list { flex-direction: column; align-items: stretch; gap: 2px; }
  .nav__link { width: 100%; padding: 14px 12px; font-size: 1.08rem; justify-content: flex-start; }
  .nav__link .icon:last-child:not(:first-child) { margin-left: auto; }
  .nav .dropdown {
    position: static; display: none; width: auto;
    margin: 4px 0 8px 12px; padding: 12px 16px;
    opacity: 1; visibility: visible; transform: none; box-shadow: none;
    background: var(--ink-2);
  }
  .nav .dropdown--catalog {
    max-width: 100%;
    padding: 0 14px 14px;
    border-radius: 15px;
  }
  .nav .catalog-menu__top { padding-top: 14px; }
  .nav .catalog-menu__top strong { font-size: 0.88rem; }
  .nav .catalog-menu__top > a { font-size: 0.72rem; }
  .nav .catalog-menu__body { gap: 14px; padding-top: 14px; }
  .nav .catalog-menu__section h3 { font-size: 0.8rem; }
  .nav .catalog-menu__genres,
  .nav .catalog-menu__years { gap: 5px; }
  .nav .catalog-menu__genres a,
  .nav .catalog-menu__years a {
    min-height: 34px;
    padding: 6px 7px;
    font-size: 0.72rem;
  }
  .nav .catalog-menu__section--years { padding-left: 12px; }
  .nav .dropdown::before { display: none; }
  .nav .has-dropdown.is-open > .dropdown { display: grid; }
  .dropdown--mega { grid-template-columns: 1fr 1fr; gap: 16px 24px; }
}

@media (max-width: 759px) {
  .search-toggle { display: inline-grid; }
  .search {
    position: absolute; left: 0; right: 0; top: 100%;
    max-width: none; padding: 10px var(--gutter);
    background: var(--ink-2); border-bottom: 1px solid var(--line);
    display: none;
  }
  .search-open .search { display: block; }
  .search__hint { display: none; }
  .dropdown--mega { grid-template-columns: 1fr; }
  .nav .catalog-menu__body { grid-template-columns: 1fr; gap: 13px; }
  .nav .catalog-menu__section--years {
    padding: 12px 0 0;
    border-top: 1px solid #d5e2f21c;
    border-left: 0;
  }
}
@media (min-width: 760px) and (max-width: 1399px) { .search__hint { display: none; } }

/* 5. ПОСТЕРИ ТА КАРТКИ ----------------------------------------------------- */
/* Постер згенеровано CSS-ом з двох відтінків (--h1, --h2) і ієрогліфа (data-k).
   Реальна картинка: додайте <img> усередину .poster — вона перекриє градієнт. */
.poster {
  --h1: 260; --h2: 320; --k: 64cqw;
  position: relative; isolation: isolate; overflow: hidden;
  container-type: inline-size;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-md);
  background:
    radial-gradient(90% 60% at 85% 8%, hsl(var(--h2) 95% 65% / 0.55), transparent 62%),
    radial-gradient(80% 60% at 8% 100%, hsl(var(--h1) 85% 45% / 0.75), transparent 66%),
    linear-gradient(165deg, hsl(var(--h1) 50% 24%), hsl(var(--h2) 55% 11%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.poster::before {
  content: attr(data-k);
  position: absolute; z-index: 0; right: -2%; top: 4%;
  font: 900 var(--k) / 1 var(--font-jp);
  writing-mode: vertical-rl; text-orientation: upright;
  color: hsl(var(--h2) 100% 90% / 0.2);
  user-select: none; pointer-events: none;
}
.poster::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(8, 11, 28, 0.78), transparent 48%);
  pointer-events: none;
}
.poster > img { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; }
.poster > * { z-index: 2; }
.poster--wide { aspect-ratio: 16 / 9; --k: 44cqw; }
.poster--fill { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none; --k: 38cqw; }
.poster--long::before { --k: 26cqw; right: 4%; top: 6%; }

.rating {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px 4px 7px; border-radius: 999px;
  background: rgba(8, 11, 28, 0.74);
  backdrop-filter: blur(6px);
  font-size: 0.82rem; font-weight: 700;
}
.rating .icon { width: 14px; height: 14px; color: var(--sun); }
.rating small { color: var(--muted); font-weight: 500; font-size: 0.72rem; margin-left: -1px; }

/* Картка постера */
.anime-card { position: relative; min-width: 0; }
.anime-card__link { display: block; }
.anime-card .poster { transition: transform 0.25s ease, box-shadow 0.25s ease; }
.anime-card__link:hover .poster {
  transform: translateY(-4px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 22px 34px -20px hsl(var(--h2) 90% 60% / 0.7);
}
.anime-card__rank {
  position: absolute; left: 10px; bottom: 4px;
  font: 800 2.7rem/1 var(--font-display);
  color: transparent; -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.9);
}
.anime-card__title {
  margin-top: 12px; font-size: 0.98rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color 0.2s;
}
.anime-card__link:hover .anime-card__title { color: var(--sun); }
.anime-card__type { margin-top: 2px; color: var(--muted); font-size: 0.85rem; }

.progress { height: 5px; margin-top: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--cyan)); }

/* Картка нової серії */
.ep-card__link { display: grid; gap: 14px; }
.ep-card .poster { transition: transform 0.25s ease; }
.ep-card__link:hover .poster { transform: translateY(-3px); }
.ep-card__num {
  position: absolute; left: 12px; bottom: 12px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--pink); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.ep-card__play {
  position: absolute; right: 12px; bottom: 12px;
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--sun); color: var(--sun-ink);
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.2s, transform 0.2s;
}
.ep-card__link:hover .ep-card__play, .ep-card__link:focus-visible .ep-card__play { opacity: 1; transform: none; }
.ep-card__title { font-size: 1.05rem; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.ep-card__link:hover .ep-card__title { color: var(--sun); }

/* 6. ГОЛОВНА --------------------------------------------------------------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: clamp(540px, 80vh, 740px);
  display: flex; align-items: center;
  background:
    radial-gradient(55% 70% at 78% 42%, rgba(92, 213, 255, 0.34), transparent 65%),
    radial-gradient(40% 50% at 96% 100%, rgba(255, 79, 154, 0.2), transparent 70%),
    linear-gradient(110deg, #050c24 0%, #08244a 52%, #0f4d78 100%);
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(90deg, rgba(5, 10, 30, 0.88) 0%, rgba(5, 10, 30, 0.55) 46%, transparent 78%);
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0; height: 34%; z-index: 0;
  background: linear-gradient(to bottom, transparent, var(--ink));
}
.hero__art { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

/* Кола на воді — відсилання до Міста Водоспаду Прістелли.
   Єдина «постановочна» анімація сторінки: хвилі розходяться один раз при завантаженні. */
.hero__ripples {
  position: absolute; right: -6%; top: 50%;
  width: min(112vh, 920px); aspect-ratio: 1; transform: translateY(-50%);
}
.hero__ripples circle {
  fill: none; stroke: rgba(150, 225, 255, var(--o, 0.3)); stroke-width: 1.5;
  transform-box: fill-box; transform-origin: center;
  animation: ripple 2.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 0.2s);
}
@keyframes ripple {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: none; }
}
.hero__kanji {
  position: absolute; right: calc(var(--gutter) + 5%); top: 50%; transform: translateY(-52%);
  font: 900 clamp(15rem, 34vw, 32rem) / 1 var(--font-jp);
  color: transparent; -webkit-text-stroke: 2px rgba(170, 230, 255, 0.3);
  user-select: none;
}

.hero__inner { position: relative; z-index: 1; padding-block: 56px 72px; }
.hero__body { max-width: 640px; }
.hero__title {
  margin: 18px 0 18px;
  font: 800 clamp(2.3rem, 5vw, 4rem) / 1.06 var(--font-display);
  letter-spacing: -0.03em;
}
.hero__title span {
  display: block; margin-top: 10px;
  font: 600 clamp(1.1rem, 2vw, 1.55rem) / 1.3 var(--font-display);
  letter-spacing: -0.01em; color: #cfe6ff;
}
.hero__desc { max-width: 58ch; color: #c5d1ee; font-size: 1.02rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

@media (max-width: 759px) {
  .hero__kanji { opacity: 0.55; right: -4%; }
  .hero::before { background: linear-gradient(90deg, rgba(5, 10, 30, 0.92), rgba(5, 10, 30, 0.6)); }
  .hero__inner { padding-block: 40px 56px; }
}

.section { padding-block: clamp(28px, 4vw, 48px); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section__title { font: 700 clamp(1.3rem, 2.4vw, 1.75rem) / 1.2 var(--font-display); letter-spacing: -0.02em; }
.section__note { color: var(--muted); font-size: 0.9rem; margin-top: 6px; font-family: var(--font-body); font-weight: 400; letter-spacing: 0; display: block; }
.section__more { color: var(--muted); font-size: 0.92rem; font-weight: 500; white-space: nowrap; transition: color 0.2s; }
.section__more:hover { color: var(--sun); }

.grid-eps { display: grid; gap: 28px 24px; grid-template-columns: 1fr; }
@media (min-width: 560px) and (max-width: 899px) {
  .ep-card__link { grid-template-columns: minmax(220px, 42%) 1fr; align-items: center; gap: 20px; }
}
@media (min-width: 900px) { .grid-eps { grid-template-columns: repeat(3, 1fr); } }

.grid-posters { display: grid; gap: 28px 18px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .grid-posters { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .grid-posters { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1180px) { .grid-posters { grid-template-columns: repeat(6, 1fr); column-gap: 20px; } }

/* 7. СТОРІНКА ТАЙТЛУ ------------------------------------------------------- */
/* overflow не обрізаємо: випадаючий список «Додати в список» виходить за межі шапки */
.title-hero {
  position: relative; z-index: 2; isolation: isolate;
  padding: clamp(24px, 3.5vw, 44px) 0 clamp(32px, 4vw, 52px);
}
.title-hero__bg { z-index: -1; }
.title-hero__bg.poster { container-type: size; --k: 140cqh; }
.title-hero__bg::after { background: linear-gradient(to bottom, rgba(10, 14, 34, 0.55), var(--ink) 98%); }
.title-hero__bg::before { right: 6%; top: -8%; color: hsl(var(--h2) 100% 90% / 0.1); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 28px; color: var(--muted); font-size: 0.88rem; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--faint); }
.crumbs a:hover { color: var(--sun); }

.title-hero__inner { display: grid; grid-template-columns: 250px 1fr; gap: clamp(24px, 4vw, 48px); align-items: end; }
.title-hero__poster { box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.14); border-radius: var(--r-lg); }
.title-hero h1 { font: 800 clamp(2rem, 4.4vw, 3.4rem) / 1.08 var(--font-display); letter-spacing: -0.03em; }

.names { display: grid; gap: 6px; margin-top: 18px; color: var(--muted); font-size: 0.95rem; }
.names div { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.names dt { color: var(--faint); }
.names dd { color: var(--text); }

.score-row { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 32px; margin-top: 26px; }
.score { display: flex; align-items: center; gap: 14px; }
.score__star { color: var(--sun); width: 38px; height: 38px; }
.score__value { font: 800 2.3rem / 1 var(--font-display); letter-spacing: -0.03em; }
.score__votes { color: var(--muted); font-size: 0.88rem; line-height: 1.3; max-width: 14ch; }

/* Оцінка 1–10: радіо-кнопки, зірки підсвічуються CSS-ом */
.rate { border: 0; margin: 0; padding: 0; min-width: 0; }
.rate__label { padding: 0; font-size: 0.85rem; color: var(--muted); margin-bottom: 2px; }
.rate__stars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.rate input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.rate label {
  cursor: pointer; padding: 0 1px; font-size: 1.45rem; line-height: 1.2;
  color: rgba(255, 255, 255, 0.2); transition: color 0.12s, transform 0.12s;
}
.rate label::before { content: "★"; }
.rate label:hover, .rate label:hover ~ label, .rate input:checked ~ label { color: var(--sun); }
.rate label:hover { transform: scale(1.2); }
.rate input:focus-visible + label { outline: 2px solid var(--sun); border-radius: 4px; }
.rate__out { font-size: 0.85rem; color: var(--muted); margin-left: 10px; align-self: center; }

.title-hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

@media (max-width: 759px) {
  .title-hero__inner { grid-template-columns: 1fr; }
  .title-hero__poster { width: 170px; }
}

/* Десктоп: контент ліворуч, липкий сайдбар праворуч (на дві «поверхи»).
   Мобайл: контент → деталі → відгуки. */
.detail {
  display: grid; align-items: start; padding-bottom: 72px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main" "aside" "comments";
  gap: 48px;
}
.detail__main { grid-area: main; display: grid; gap: 48px; min-width: 0; }
.detail__aside { grid-area: aside; }
.comments { grid-area: comments; min-width: 0; }
@media (min-width: 1020px) {
  .detail {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "main aside" "comments aside";
    column-gap: 40px;
  }
  .detail__aside { position: sticky; top: calc(var(--header-h) + 20px); }
}

.block-title { font: 700 1.3rem / 1.2 var(--font-display); letter-spacing: -0.02em; margin-bottom: 16px; display: flex; align-items: baseline; gap: 12px; }
.block-title small { font: 500 0.9rem var(--font-body); color: var(--muted); letter-spacing: 0; }

.synopsis p { max-width: 70ch; color: #cbd2ee; font-size: 1.04rem; line-height: 1.75; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.info-list > div {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.info-list > div:first-child { border-top: 0; padding-top: 0; }
.info-list > div:last-child { padding-bottom: 0; }
.info-list dt { color: var(--muted); font-size: 0.9rem; }
.info-list dd { font-weight: 500; }
.info-list dd a:hover { color: var(--sun); }
.info-note { display: block; margin-top: 6px; color: var(--muted); font-size: 0.85rem; font-weight: 400; }

/* Плеєр */
.player-module { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.player { position: relative; isolation: isolate; aspect-ratio: 16 / 9; display: grid; place-items: center; background: #05071a; overflow: hidden; }
.player__now { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 3; }
.player__now .chip { background: rgba(8, 11, 28, 0.7); backdrop-filter: blur(6px); }

.player__big {
  z-index: 3; display: grid; place-items: center;
  width: 86px; height: 86px; border-radius: 50%;
  background: var(--sun); color: var(--sun-ink);
  box-shadow: 0 0 0 12px rgba(255, 210, 63, 0.18), 0 24px 44px -12px rgba(255, 210, 63, 0.55);
  transition: transform 0.2s, opacity 0.2s;
}
.player__big .icon { width: 34px; height: 34px; margin-left: 4px; }
.player__big:hover { transform: scale(1.06); }
.player.is-playing .player__big { opacity: 0; pointer-events: none; transform: scale(0.8); }

.player__ui {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 36px 16px 12px;
  background: linear-gradient(to top, rgba(5, 7, 26, 0.92), transparent);
}
.player__track { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); overflow: hidden; margin-bottom: 8px; }
.player__fill { display: block; height: 100%; width: 0; background: var(--sun); border-radius: inherit; }
.player__row { display: flex; align-items: center; gap: 4px; }
.player__row .icon-btn { width: 38px; height: 38px; color: #fff; }
.player__time { margin-left: 6px; font-size: 0.85rem; color: #d7defa; font-variant-numeric: tabular-nums; }
.player__spacer { flex: 1; }
.player__toggle .i-pause { display: none; }
.player.is-playing .player__toggle .i-pause { display: block; }
.player.is-playing .player__toggle .i-play { display: none; }

.player-module__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--line); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); }
.seg__btn { padding: 8px 16px; border-radius: 10px; color: var(--muted); font-size: 0.92rem; font-weight: 600; transition: background-color 0.2s, color 0.2s; }
.seg__btn:hover { color: var(--text); }
.seg__btn[aria-selected="true"] { background: var(--sun); color: var(--sun-ink); }
.player-module__nav { display: flex; gap: 6px; }
.player-module__nav .icon-btn { background: rgba(255, 255, 255, 0.06); }
.player-module__nav .icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.episodes-wrap { padding: 4px 20px 22px; }
.episodes-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 20px; margin-bottom: 14px; }
.episodes-head h3 { font-size: 1rem; font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 0.82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

.episodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.ep-btn {
  position: relative; aspect-ratio: 1; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background-color 0.15s, transform 0.15s, color 0.15s;
}
.ep-btn:hover { background: var(--surface-3); transform: translateY(-2px); }
.ep-btn.is-viewed { background: transparent; color: var(--faint); }
.ep-btn.is-viewed::after {
  content: ""; position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--mint);
}
.ep-btn.is-current { background: var(--sun); border-color: var(--sun); color: var(--sun-ink); }
.ep-btn.is-current::after { background: var(--sun-ink); }

/* Пов'язане */
.related { display: grid; gap: 14px; }
@media (min-width: 640px) { .related { grid-template-columns: 1fr 1fr; } }
.rel-card {
  display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: center;
  padding: 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color 0.2s, background-color 0.2s;
}
.rel-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.rel-card .poster { border-radius: 10px; --k: 70cqw; }
.rel-card h3 { font-size: 1rem; font-weight: 600; line-height: 1.3; margin-bottom: 8px; }
.rel-card .tags { margin-top: 8px; }

/* Коментарі */
.comment-form { padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); transition: border-color 0.2s; }
.comment-form:focus-within { border-color: var(--sun); }
.comment-form textarea {
  display: block; width: 100%; min-height: 96px; resize: vertical;
  background: none; border: 0; outline: 0; color: var(--text); font: inherit; line-height: 1.6;
}
.comment-form textarea::placeholder { color: var(--faint); }
.comment-form__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.comment-form__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.comment-form__hint { color: var(--faint); font-size: 0.82rem; }

.comments__list { margin-top: 12px; }
.comment { display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); }
.comment__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 4px; }
.comment__head strong { font-weight: 600; }
.comment__head time { color: var(--faint); font-size: 0.82rem; }
.comment__text { color: #d3d9f2; overflow-wrap: anywhere; }
.comment__foot { display: flex; gap: 8px; margin-top: 10px; }
.comment__foot button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; color: var(--muted); font-size: 0.85rem; transition: background-color 0.15s, color 0.15s; }
.comment__foot button:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.comment__foot .icon { width: 16px; height: 16px; }

.spoiler {
  display: inline; padding: 1px 8px; border-radius: 6px;
  background: var(--surface-3); color: transparent;
  cursor: pointer; user-select: none;
  transition: background-color 0.2s, color 0.2s;
}
.spoiler:hover { background: #33407f; }
.spoiler.is-revealed { background: rgba(255, 79, 154, 0.15); color: inherit; cursor: default; user-select: auto; }

/* 8. ПРОФІЛЬ --------------------------------------------------------------- */
.profile-banner { height: clamp(130px, 18vw, 200px); border-radius: 0 0 var(--r-lg) var(--r-lg); aspect-ratio: auto; --k: clamp(260px, 32vw, 460px); }
.profile-banner::before { top: -40%; right: 6%; }
.profile-banner.has-background { background-position: center; background-size: cover; }
.profile-banner.has-background::before { content: none; }
.profile-banner.has-background::after { background: linear-gradient(to top, rgba(8, 11, 28, 0.78), transparent 68%); }
.profile-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 28px; margin-top: -64px; position: relative; z-index: 3; }
.profile-head__info { flex: 1 1 280px; padding-bottom: 8px; }
.profile-head h1 { font: 800 clamp(1.7rem, 3vw, 2.4rem) / 1.1 var(--font-display); letter-spacing: -0.03em; }
.profile-head p { color: var(--muted); margin-top: 6px; }
.profile-head__actions { display: flex; gap: 10px; padding-bottom: 8px; }

.stats { display: flex; flex-wrap: wrap; gap: 20px 0; margin-top: 36px; }
.stat { padding: 4px 48px 4px 48px; border-left: 1px solid var(--line-strong); }
.stat:first-child { padding-left: 0; border-left: 0; }
.stat__label { color: var(--muted); font-size: 0.9rem; }
.stat__value { margin-top: 4px; font: 800 clamp(1.8rem, 3.4vw, 2.6rem) / 1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat__value small { font: 500 0.9rem var(--font-body); color: var(--muted); letter-spacing: 0; margin-left: 6px; }

.status-bar { display: flex; gap: 3px; height: 12px; margin-top: 32px; border-radius: 999px; overflow: hidden; }
.status-bar span { background: var(--c); min-width: 6px; }

.lists { padding-top: 24px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; margin-bottom: 28px; }
.tab {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 0.93rem;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.tab::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.tab__count { font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab__count { color: var(--muted); }

.empty { padding: 40px 0; color: var(--muted); }

.security { padding-bottom: 72px; }
.security__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.security__head p { color: var(--muted); max-width: 60ch; margin-top: 6px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; background: var(--surface); }
.sessions { width: 100%; border-collapse: collapse; min-width: 680px; }
.sessions th { text-align: left; padding: 16px 20px; color: var(--muted); font-size: 0.85rem; font-weight: 500; border-bottom: 1px solid var(--line); }
.sessions td { padding: 16px 20px; border-top: 1px solid var(--line); font-size: 0.93rem; vertical-align: middle; }
.sessions tbody tr:first-child td { border-top: 0; }
.sessions td:nth-child(2) { font-variant-numeric: tabular-nums; }
.sessions tr.is-alert { background: rgba(255, 107, 129, 0.07); }
.sessions small { display: block; color: var(--faint); font-size: 0.8rem; }

@media (max-width: 759px) {
  .table-wrap { overflow: visible; background: none; border: 0; }
  .sessions { min-width: 0; }
  .sessions thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sessions, .sessions tbody, .sessions tr, .sessions td { display: block; }
  .sessions tr { margin-bottom: 12px; padding: 8px 18px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
  .sessions tr.is-alert { border-color: rgba(255, 107, 129, 0.4); }
  .sessions td, .sessions tbody tr:first-child td { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); text-align: right; }
  .sessions tr td:first-child { border-top: 0; }
  .sessions td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  .stats { gap: 16px; }
  .stat { padding-left: 16px; }
}

/* 9. ФУТЕР, МОДАЛКА, ТОСТИ ------------------------------------------------- */
.site-footer { margin-top: 24px; border-top: 1px solid var(--line); background: var(--ink-2); }
.footer__grid { display: grid; gap: 36px 48px; padding-block: 56px 40px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .footer__grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .footer__grid { grid-template-columns: 1.6fr 1fr; } }
.footer__about { color: var(--muted); font-size: 0.93rem; max-width: 34ch; margin-top: 16px; }
.footer__title { font: 600 0.95rem var(--font-display); margin-bottom: 14px; }
.footer__links a, .footer__links button { display: block; padding: 5px 0; color: var(--muted); font-size: 0.93rem; transition: color 0.15s; text-align: left; }
.footer__links a:hover, .footer__links button:hover { color: var(--sun); }

.socials { display: flex; flex-wrap: wrap; gap: 10px; }
.social {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); color: var(--text); font-size: 0.9rem; font-weight: 500;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.social:hover { background: var(--sun); border-color: var(--sun); color: var(--sun-ink); }
.social .icon { width: 18px; height: 18px; }

.footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 22px; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.85rem; }

.modal {
  width: min(420px, calc(100% - 32px)); padding: 28px; margin: auto;
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: 0 50px 90px -30px rgba(0, 0, 0, 0.9);
}
.modal::backdrop { background: rgba(5, 8, 24, 0.72); backdrop-filter: blur(6px); }
.modal[open] { animation: modal-in 0.22s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.modal__head h2 { font: 700 1.35rem var(--font-display); letter-spacing: -0.02em; }
.modal__head p { color: var(--muted); font-size: 0.92rem; margin-top: 6px; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.88rem; font-weight: 500; color: var(--muted); }
.input {
  height: 48px; padding: 0 14px; border-radius: 12px;
  background: var(--ink-2); border: 1px solid var(--line-strong);
  color: var(--text); font: inherit; outline: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { border-color: var(--sun); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.18); }
.input:user-invalid { border-color: var(--danger); }
.modal__foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.modal__foot a { color: var(--sun); font-weight: 600; }
.modal--profile-editor { width: min(560px, calc(100% - 32px)); max-height: min(90vh, 820px); overflow-y: auto; }
.profile-editor__file { height: auto; padding: 10px; }
.profile-editor__preview { display: block; max-width: 100%; object-fit: cover; border: 1px solid var(--line-strong); }
.profile-editor__preview--avatar { width: 88px; height: 88px; border-radius: 50%; }
.profile-editor__preview--background { width: 100%; height: 112px; border-radius: 12px; }
.profile-editor__actions { display: flex; justify-content: flex-end; gap: 10px; }
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 300; display: grid; gap: 10px; transform: translateX(-50%); width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; border-radius: 14px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.7);
  font-size: 0.93rem; pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }
.toast a { color: var(--sun); font-weight: 700; white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.player__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
  opacity: 0;
}

.player.is-started .player__video {
  opacity: 1;
}
.player__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 4;
}
/* AniBublik: actions for catalog and official video previews */
.watch-preview { background: #080e23; border-radius:14px; overflow:hidden; position:relative; aspect-ratio:16/9; border:1px solid var(--line); display:grid; place-items:center; }
.watch-preview iframe { width:100%;height:100%;border:0;display:block;position:absolute;inset:0; }
.watch-empty { text-align:center; color:var(--muted);padding:24px;display:grid;gap:12px;justify-items:center; }
.watch-empty svg { width:44px;height:44px;stroke:var(--sun);fill:none;stroke-width:1.5; }
.watch-guide { display:grid;gap:14px; }
.watch-guide__links { display:flex;align-items:center;gap:12px;flex-wrap:wrap; }
.watch-note { color:var(--muted);font-size:.9rem;line-height:1.5; }
.player.is-embedded .player__big, .player.is-embedded .player__ui, .player.is-embedded .player__now { display:none!important; }
.player__iframe:not([hidden]) { position:absolute;inset:0;width:100%;height:100%;border:0;z-index:5; }
.catalog-head {padding:34px 0 10px;}
.catalog-form {display:flex;flex-wrap:wrap;gap:12px;margin:18px 0 24px;}
.catalog-form input {flex:1 1 250px;max-width:500px;background:var(--surface);border:1px solid var(--line-strong);border-radius:12px;padding:12px 16px;color:var(--text);font:inherit;}
.catalog-form input:focus-visible {outline:2px solid var(--sun);}
.catalog-count {color:var(--muted);font-size:.9rem;margin-bottom:12px;}

.player-module > .player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.player .player__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 5;
}

/* Однаковий вибір серій для ВСІХ тайтлів, які мають episodes в app.ts */

/* AniBublik — Premium Episode Selector */

.watch-series {
  padding: 24px;
  border: 1px solid #30395b;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 90% 0%, #50428830, transparent 60%),
    linear-gradient(145deg, #171d3d, #0e132b);
  box-shadow: 0 18px 45px #0004, inset 0 1px #ffffff12;
}

.watch-series .episodes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #ffffff14;
}

.watch-series .episodes-head h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.watch-series .episodes-head h3::before {
  content: "";
  width: 4px;
  height: 22px;
  border-radius: 8px;
  background: #ffd23f;
  box-shadow: 0 0 14px #ffd23f80;
}

.watch-series .episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 10px;
  overflow: visible;
}

.watch-series .ep-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 48px;
  aspect-ratio: auto;
  border: 1px solid #ffffff17;
  border-radius: 12px;
  background: linear-gradient(145deg, #28325d, #1a2247);
  color: #dce2ff;
  font: 700 14px "Onest", sans-serif;
  box-shadow: inset 0 1px #ffffff12;
  transition: transform .2s, background .2s, border-color .2s, box-shadow .2s;
}

.watch-series .ep-btn:hover:not(.is-current) {
  transform: translateY(-3px);
  background: #374477;
  border-color: #9186ff;
  box-shadow: 0 8px 20px #0004, 0 0 14px #8975ff30;
}

.watch-series .ep-btn.is-current {
  color: #211800;
  border-color: #ffe780;
  background: linear-gradient(135deg, #ffe878, #ffc52e);
  box-shadow: 0 5px 20px #ffd23f55, inset 0 1px #fff8;
}

.watch-series .ep-btn.is-viewed:not(.is-current) {
  color: #aff3d3;
  border-color: #5ee6a844;
  background: #193a3c88;
}

.watch-series .ep-btn.is-viewed:not(.is-current)::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5ee6a8;
  box-shadow: 0 0 8px #5ee6a8;
}

.watch-series .ep-btn:focus-visible {
  outline: 2px solid #ffd23f;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .watch-series { padding: 18px 14px; border-radius: 16px; }
  .watch-series .episodes { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
  .watch-series .ep-btn { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .watch-series .ep-btn { transition: none; }
}


/* ===== Real community controls (Supabase) ===== */
.auth-message { min-height:1.5rem; margin:8px 0; color:var(--mint); font-size:.9rem; }
.auth-message.is-error { color:var(--danger); }
.auth-link { color:var(--sun); text-decoration:underline; text-underline-offset:3px; }
.auth-link:hover { color:var(--sun-hover); }
.community-toast { position:fixed; bottom:22px; right:22px; z-index:300; max-width:min(440px,calc(100vw - 32px)); padding:12px 16px; border-radius:12px; background:#183d35; color:#d8fff0; border:1px solid #5ee6a844; box-shadow:0 12px 38px #0008; }
.community-toast--error { background:#432333; color:#ffe1e6; border-color:#ff6b8155; }
.community-empty { padding:18px; border:1px dashed var(--line-strong); border-radius:12px; color:var(--muted); font-size:.9rem; }
.community-reply-reference { color:var(--mint); font-size:.82rem; margin:4px 0; text-align:left; }
.community-viewed-controls { display:flex; flex-wrap:wrap; gap:12px; align-items:center; padding:8px 0; }
.community-viewed-controls span { color:var(--faint); font-size:.8rem; }
.community-history { margin:36px 0; }
.community-history ul { display:grid; gap:8px; }
.community-history li { display:flex; justify-content:space-between; gap:12px; padding:10px 14px; border:1px solid var(--line); border-radius:10px; background:var(--surface); }
.community-history li a:hover { color:var(--sun); }
.community-history li time { color:var(--muted); font-size:.85rem; }
.watch-series .ep-btn.is-viewed:not(.is-current) { border-color:#5ee6a866; color:#b6f1d4; background:#193d3a; }


/* Перекриваємо стару сторінку під час переходу — не миготить головна. */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  background: #101730;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
html.is-page-leaving::after {
  opacity: 1;
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  html::after { transition: none; }
}

html[data-auth="loading"] .auth__login,
html[data-auth="loading"] .auth__user {
  display: none !important;
}