:root {
  color-scheme: light;
  --canvas: #111;
  --page: #fff;
  --surface: #f5f8fa;
  --line: #e2e6e8;
  --text: #17191a;
  --muted: #575f63;
  --accent: #78cb9c;
  --accent-text: #236a51;
  --accent-wash: #edf4f0;
  --accent-wash: color-mix(in srgb, var(--accent) 13%, var(--page));
  --player: #11191f;
  --mobile-banner-height: 152px;
  --desktop-backdrop-max-width: 860px;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141c24;
  --surface: #1c262f;
  --line: #34404a;
  --text: #f4f6f7;
  --muted: #c3cbd1;
  --accent-text: #a9d5c0;
  --accent-wash: #23382e;
  --accent-wash: color-mix(in srgb, var(--accent) 22%, var(--page));
  --player: #0f151b;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  padding: clamp(112px, 19.5vw, 270px) 12px 28px;
  color: var(--text);
  background: var(--canvas);
}

a { color: var(--accent-text); text-underline-offset: .18em; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; }

.backdrop {
  position: absolute;
  z-index: -1;
  inset: 0 0 auto;
  height: clamp(190px, 35vw, 670px);
}

.backdrop img {
  display: block;
  width: min(1920px, 100%);
  height: 100%;
  margin: 0 auto;
  object-fit: cover;
  object-position: center top;
}

.backdrop::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #111 0%, transparent 23%, transparent 77%, #111 100%),
    linear-gradient(0deg, #111, transparent 58%);
  content: "";
}

@media (min-width: 481px) {
  .backdrop[data-desktop-backdrop-contained] {
    overflow: hidden;
    background: linear-gradient(120deg, #111 10%, #1e292b 55%, #111 90%);
  }

  .backdrop[data-desktop-backdrop-contained] img {
    width: min(61vw, var(--desktop-backdrop-max-width));
    height: auto;
    mask-image: linear-gradient(90deg, transparent, #000 9%, #000 98%, transparent),
      linear-gradient(0deg, transparent, #000 35%);
    mask-composite: intersect;
  }

  .backdrop[data-desktop-backdrop-contained]::after {
    background: linear-gradient(0deg, #111, transparent 30%);
  }
}

.site {
  width: min(1240px, 100%);
  margin: 0 auto;
  background: var(--page);
  border-radius: 5px;
  overflow: clip;
}

.site-header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 20px;
  font-weight: 760;
  line-height: 1.12;
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
}
.brand-name { min-width: 0; overflow-wrap: anywhere; }

.header-controls, .top-links { display: flex; align-items: center; }
.header-controls { max-width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.top-links { flex-wrap: wrap; gap: 0 15px; }
.top-links a { display: inline-flex; min-height: 44px; align-items: center; font-size: 14px; font-weight: 590; text-decoration: none; }
.top-links a:hover { text-decoration: underline; }

.watch-continue {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: #102820;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}
.watch-continue:hover { filter: brightness(1.06); }
.watch-continue small { font-size: 11px; font-weight: 550; white-space: nowrap; }
.watch-icon { width: 0; height: 0; border-block: 5px solid transparent; border-left: 7px solid currentColor; }

.theme-switch {
  position: relative;
  display: flex;
  min-width: 77px;
  min-height: 39px;
  align-items: center;
  justify-content: space-between;
  padding: 3px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  cursor: pointer;
}

.theme-switch[hidden] { display: none; }
.theme-switch::before {
  position: absolute;
  inset: 50% auto auto 3px;
  width: calc((100% - 6px) / 2);
  height: 29px;
  background: var(--accent);
  border-radius: 24px;
  content: "";
  transform: translate(0, -50%);
  transition: transform 230ms cubic-bezier(.2, .7, .25, 1);
}
.theme-switch[aria-pressed="true"]::before { transform: translate(100%, -50%); }
.theme-switch span { position: relative; display: grid; width: 33px; height: 29px; place-items: center; font-size: 19px; line-height: 1; transition: color 180ms ease; }
.theme-switch[aria-pressed="false"] .theme-day,
.theme-switch[aria-pressed="true"] .theme-night { color: #102820; }
@media (prefers-reduced-motion: reduce) {
  .theme-switch::before, .theme-switch span { transition: none; }
}

.site-header .brand { gap: 5px; font-size: 17px; }
.site-header .brand-mark { width: 26px; height: 26px; }
.site-header .header-controls { flex: none; }
.site-header :is(.top-links, .watch-continue) { display: none; }
.site-header .theme-switch { min-width: 82px; min-height: 44px; }
.site-header .theme-switch span { flex: 1; }

@media (min-width: 721px) {
  html:where(:not([data-device="phone"])) .site-header { flex-wrap: wrap; gap: 6px 20px; padding-inline: 24px; }
  html:where(:not([data-device="phone"])) .site-header .brand { gap: 10px; font-size: 20px; }
  html:where(:not([data-device="phone"])) .site-header .brand-mark { width: 32px; height: 32px; }
  html:where(:not([data-device="phone"])) .site-header .header-controls { flex: 0 1 auto; }
  html:where(:not([data-device="phone"])) .site-header .top-links { display: flex; }
  html:where(:not([data-device="phone"])) .site-header .watch-continue { display: inline-flex; }
  html:where(:not([data-device="phone"])) .site-header .theme-switch { min-width: 77px; min-height: 39px; }
  html:where(:not([data-device="phone"])) .site-header .theme-switch span { flex: 0 1 auto; }
}

h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: 21px; line-height: 1.3; }
h2 { font-size: 18px; line-height: 1.35; }

.title-card {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  padding: 18px 20px 22px;
}

.poster {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 590;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 5px;
}

picture.poster {
  display: block;
  border: 0;
}

.poster > img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 590;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: inherit;
}

.title-summary { max-width: 94ch; margin-top: 14px; color: var(--muted); }
.title-description-more summary {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  color: var(--accent-text);
  font-weight: 650;
  cursor: pointer;
}
.title-description-more summary::-webkit-details-marker { display: none; }
.title-description-more summary::after {
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  content: "";
  transform: translateY(-2px) rotate(45deg);
}
.title-description-more[open] summary::after { transform: translateY(2px) rotate(225deg); }
.description-hide, .title-description-more[open] .description-show { display: none; }
.title-description-more[open] .description-hide { display: inline; }
.title-description-more p + p { margin-top: 10px; }

.title-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px 24px;
  margin-top: 15px;
  font-size: 14px;
}

.fact-list { display: grid; gap: 4px; }
.fact-list div { display: flex; align-items: baseline; gap: 0 6px; }
.fact-list dt, .title-cast strong { flex: 0 0 auto; }
.fact-list dt::after, .title-cast strong::after { content: ":"; }
.title-facts dt, .title-cast strong { font-weight: 650; }
.title-facts dd { color: var(--muted); }
.fact-list-main dd, .title-cast span { color: var(--accent-text); }
.title-cast { display: flex; align-items: baseline; gap: 6px; margin-top: 12px; font-size: 14px; }

.title-ratings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.rating {
  display: grid;
  min-height: 35px;
  place-items: center;
  padding: 2px 5px;
  color: var(--text);
  background: var(--page);
  border: 2px solid;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 680;
  white-space: nowrap;
}
.rating-imdb { border-color: #e9bd36; }
.rating-kinopoisk { border-color: #f35f2a; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 13px;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

.button:hover { background: var(--surface); }
.button-primary { color: #102820; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: var(--accent); filter: brightness(1.06); }

.section { padding: 16px 20px 20px; border-top: 1px solid var(--line); }
.section h2 + .season-tabs, .section h2 + .season-groups { margin-top: 10px; }

.season-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.season-tab {
  display: flex;
  min-height: 55px;
  flex-direction: column;
  justify-content: center;
  padding: 6px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.35;
  text-decoration: none;
}

.season-tab strong, .episode-list strong { font-weight: 650; }
.season-tab span { color: var(--muted); font-size: 12px; }
.season-tab:hover, .season-tab[aria-current="page"] { background: var(--accent-wash); border-color: var(--accent); }
.season-tab[aria-current="page"] strong { color: var(--accent-text); }

.season-groups { border: 1px solid var(--line); border-radius: 4px; }
.season-group + .season-group { border-top: 1px solid var(--line); }
.season-group summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 5px 12px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}
.season-group summary::-webkit-details-marker { display: none; }
.season-group summary::after { margin-left: auto; color: var(--accent-text); content: "▾"; }
.season-group[open] summary::after { transform: rotate(180deg); }
.season-group small, .episode-list small { color: var(--muted); font-size: 12px; }
.season-group .episode-list { padding: 8px 10px 10px; }

.episode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.episode-list a {
  display: grid;
  min-height: 48px;
  grid-template-columns: 31px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  text-decoration: none;
}
.episode-list a:hover { background: var(--accent-wash); border-color: var(--accent); }
.episode-number {
  display: grid;
  min-height: 31px;
  place-items: center;
  color: var(--accent-text);
  background: var(--accent-wash);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.row-arrow { grid-column: -2; color: var(--accent-text); font-size: 19px; line-height: 1; }

.season-page, .episode-page { border-top: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 7px; margin: -4px 0 5px; color: var(--muted); font-size: 13px; }
.breadcrumbs a { display: inline-flex; min-height: 35px; align-items: center; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.page-meta { margin-top: 5px; color: var(--muted); font-size: 14px; }
.season-page .season-tabs { margin-top: 14px; }
.episode-list-heading { margin: 18px 0 8px; }

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 235px;
  align-items: start;
  gap: 13px;
  margin-top: 14px;
}
.player {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  color: #f5f7f8;
  background: var(--player);
  border-radius: 5px;
}
.player iframe, .player video { display: block; width: 100%; height: 100%; border: 0; }
.episode-player-source { padding: 8px; background: #1e1e1e; border-radius: 5px 5px 0 0; }
.episode-player-source:not([hidden]) + .player { border-radius: 0 0 5px 5px; }
.episode-player-source select, .episode-voiceovers select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--page);
  font: inherit;
  font-weight: 650;
}
.episode-player-source select {
  color: #fff;
  background: #464646;
  border-color: #555;
  color-scheme: dark;
}
.episode-voiceovers {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}
.episode-voiceovers label { color: var(--muted); }
.episode-voiceovers span { overflow-wrap: anywhere; }
.episode-player-source[hidden], .episode-voiceovers[hidden], .episode-voiceovers select[hidden] { display: none; }
.player-placeholder { display: grid; justify-items: center; gap: 4px; padding: 10px; text-align: center; }
.player-placeholder small { color: #b9c1c8; }
.play-symbol { width: 0; height: 0; margin: 0 0 5px 4px; border-block: 9px solid transparent; border-left: 14px solid #b9c1c8; }

.home-player h2 {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  text-align: center;
}
.player-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px; background: #1e1e1e; }
.player-source {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 5px 14px;
  color: #d9d9d9;
  background: #464646;
  border: 0;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.2;
  text-transform: uppercase;
  transition: background-color 160ms ease, color 160ms ease, filter 160ms ease,
    box-shadow 160ms ease, transform 160ms ease;
}
.player-source-current { color: #102820; background: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .player-source:not(:disabled):hover {
    filter: brightness(1.12);
    box-shadow: 0 4px 10px #0006;
    transform: translateY(-2px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .player-source { transition: none; }
  .player-source:not(:disabled):hover { transform: none; }
}
.player-home { position: relative; max-height: 70vh; background: #050505; }
.player-stage { display: grid; width: 100%; height: 100%; place-items: center; }
.player-selectors { position: absolute; inset: 9px 9px auto; display: flex; flex-wrap: wrap; gap: 7px; z-index: 1; }
.player-selectors[hidden], .remember-episode[hidden] { display: none; }
.player-selectors select {
  min-height: 44px;
  padding: 4px 9px;
  color: #f5f7f8;
  background: #22282d;
  border: 1px solid #30383e;
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color-scheme: dark;
}
.player-open {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  background: #079bd1;
  border-radius: 50%;
  text-decoration: none;
}
.player-open .play-symbol { margin-bottom: 0; border-left-color: currentColor; }
.player-open:hover { background: #0783b0; }
.player-home .player-placeholder { gap: 8px; }

.episode-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 8px;
}
.neighbor-links { display: flex; flex: 2 1 376px; min-width: 0; gap: 8px; }
.neighbor-links-single { flex: 1 1 184px; }
.neighbor-links .button { flex: 1 1 0; min-width: 0; }
.neighbor-links .button:hover { background: var(--accent-wash); }
.neighbor-links [aria-hidden="true"] { flex: none; color: var(--accent-text); }
.remember-episode { display: grid; flex: 1 1 184px; min-width: 0; gap: 4px; }
.remember-button { cursor: pointer; }
.remember-button .ui-icon { flex: none; width: 16px; height: 16px; fill: none; }
.watch-status { color: var(--muted); font-size: 12px; text-align: center; }
.watch-status:empty { display: none; }

.episode-queue { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.episode-queue h2 { font-size: 16px; }
.episode-queue p { color: var(--muted); font-size: 13px; }
.queue-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 9px; }
.queue-grid a {
  display: grid;
  min-height: 44px;
  place-items: center;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}
.queue-grid a:hover { background: var(--accent-wash); }
.queue-grid a[aria-current="page"] { color: #102820; background: var(--accent); border-color: var(--accent); }
.back-to-season { display: inline-flex; min-height: 44px; align-items: center; gap: 5px; margin-top: 3px; font-size: 13px; font-weight: 630; text-decoration: none; }
.back-to-season:hover { text-decoration: underline; }
.episode-about {
  margin-top: 16px;
  padding: clamp(14px, 2vw, 22px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 3px #172b240d, 0 6px 18px #172b2410;
}
:root[data-theme="dark"] .episode-about { box-shadow: 0 4px 14px #080d1366; }
.episode-about h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.episode-about h2::before {
  flex: 0 0 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  content: "";
}
.episode-about p {
  max-width: 80ch;
  margin-top: 8px;
  color: var(--text);
  overflow-wrap: break-word;
}

.site-footer {
  display: grid;
  grid-template-columns: clamp(150px, 24%, 270px) minmax(0, 1fr);
  align-items: center;
  gap: 12px 30px;
  padding: 20px;
  color: #d7dce0;
  background: #141c24;
}
.site-footer .footer-brand { min-height: 0; gap: 9px; color: #fff; font-size: 17px; }
.footer-brand .brand-mark { width: 28px; height: 28px; }
.footer-copy { max-width: 660px; font-size: 14px; line-height: 1.43; }
.footer-copy a { color: inherit; overflow-wrap: anywhere; }
.footer-copy-with-counter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  max-width: none;
}
.footer-copy-with-counter p { max-width: 660px; }
.footer-counter { display: block; }
.site-footer a:focus-visible { outline-color: #b9ddcd; }

@media (max-width: 720px) {
  .title-card { grid-template-columns: 150px minmax(0, 1fr); }
  .season-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .watch-layout { grid-template-columns: minmax(0, 1fr); }
  .queue-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .title-facts { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .site-footer { grid-template-columns: minmax(0, 1fr); gap: 10px; padding-block: 16px; }
}

@media (max-width: 480px) {
  body {
    padding-top: clamp(112px, var(--mobile-banner-height), 168px);
    padding-inline: 7px;
  }
  .title-card { grid-template-columns: 92px minmax(0, 1fr); gap: 9px 11px; padding: 12px; }
  .title-copy { display: contents; }
  .title-copy h1 { align-self: center; }
  .title-summary, .title-facts, .title-cast, .title-copy .actions { grid-column: 1 / -1; margin-top: 0; }
  .title-cast { display: block; }
  h1 { font-size: 19px; }
  .section, .site-footer { padding-inline: 12px; }
  .season-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .episode-list { grid-template-columns: minmax(0, 1fr); }
  .episode-page .player { min-height: 180px; }
  .queue-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (pointer: coarse) {
  html .site-header .theme-switch, html .site-header .watch-continue, .breadcrumbs a { min-height: 44px; }
}

@media (max-width: 900px) {
  .season-about { padding-inline-end: 40px; }
}
