:root {
  color-scheme: dark;
  --bg: #0b0b0e;
  --surface: #17171d;
  --line: #303039;
  --muted: #bbb8c3;
  --ink: #faf8fc;
  --accent: #ff4557;
  --gutter: clamp(1rem, 5vw, 5rem);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.6 system-ui, sans-serif; }
main { max-width: 1600px; min-height: 76vh; margin: auto; }
header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(.65rem, env(safe-area-inset-top)) var(--gutter) .65rem;
  border-bottom: 1px solid var(--line);
  background: #0b0b0ef5;
}
.brand { color: var(--ink); font-weight: 900; letter-spacing: .08em; white-space: nowrap; text-decoration: none; }
.brand b { color: var(--accent); }
.mark {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  margin-inline-end: .3rem;
  place-items: center;
  border-radius: .5rem;
  background: var(--accent) url('/icon.png') center / cover;
  vertical-align: middle;
}
nav, .actions, .detail-actions, .detail-header, .toolbar, .hero-actions, #search-form {
  display: flex;
  align-items: center;
  gap: .6rem;
}
button, input, select {
  min-height: 44px;
  padding: .45rem .85rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
  color: inherit;
  font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .6; }
nav button, .actions button { background: transparent; border-color: transparent; font-size: .925rem; white-space: nowrap; }
nav button[aria-current] { background: #ff455720; color: #ff97a1; border-color: #ff45574d; }
.primary { background: var(--accent); border-color: var(--accent); color: #16090b; font-weight: 800; }
.hero {
  --hero-side: to right;
  display: flex;
  align-items: end;
  min-height: clamp(390px, 52vw, 655px);
  padding: clamp(2.2rem, 7vw, 7rem) var(--gutter);
  background:
    linear-gradient(0deg, var(--bg), #0b0b0e15 75%),
    linear-gradient(var(--hero-side), #0b0b0ef0, #0b0b0e20 78%),
    url('/hero.jpg') center 44% / cover #34272f;
}
[dir=rtl] .hero { --hero-side: to left; }
.hero h1 {
  margin: .15em 0;
  font-size: clamp(3.2rem, 9vw, 8rem);
  line-height: .84;
  font-weight: 900;
  letter-spacing: -.078em;
  text-align: start;
}
[dir=rtl] .hero h1 { text-align: right; }
.hero p { max-width: 32rem; color: #e2dde6; }
.hero .eyebrow { color: #ff9ea7; font-weight: 800; }
.hero-actions { flex-wrap: wrap; margin-top: 1.25rem; }
.catalog, .system, footer { padding: 1.2rem var(--gutter); }
.toolbar, .detail-header { justify-content: space-between; }
.toolbar { padding-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.toolbar h2, .licensed h2, #history h2 { margin: 0; line-height: 1.2; }
#query { min-width: 0; }
#status:empty, #system:empty { display: none; }
#status { margin-block: 1.2rem; }
#tmdb-title { margin: 1.5rem 0 .65rem; }
#cards { margin-block-start: 1rem; }
.licensed, #history { margin-block: 1.7rem; }
.licensed h2, #history h2 { margin-block-end: .85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr)); gap: clamp(.65rem, 2vw, 1.2rem); }
#licensed-cards, .licensed-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0;
  overflow: hidden;
  text-align: start;
  transition: border-color 160ms ease, background 160ms ease;
}
.card img, .placeholder {
  display: grid;
  width: 100%;
  aspect-ratio: 2 / 3;
  align-items: center;
  justify-items: center;
  object-fit: cover;
  background: linear-gradient(145deg, #44292f, #171722);
}
.card-licensed img, .card-licensed .placeholder { aspect-ratio: 16 / 9; }
.card strong { display: block; padding: .65rem .8rem; overflow-wrap: anywhere; }
.card small { display: block; color: var(--muted); font-weight: 400; }
#more { margin-top: 1rem; }
.panel, dialog {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  color: inherit;
}
.login { width: min(90%, 28rem); margin: clamp(3rem, 12vh, 8rem) auto; }
.login form { display: grid; gap: .65rem; }
dialog { width: min(calc(100% - 2rem), 56rem); max-height: 90dvh; overflow: auto; }
dialog::backdrop { background: #08080bdd; }
.detail-header h2 { margin-block: .35rem; }
.detail-header { position: relative; isolation: isolate; gap: 1rem; }
.detail-header.has-art {
  min-height: clamp(8rem, 28vw, 14rem);
  align-items: end;
  overflow: hidden;
  padding: 1rem;
  border-radius: .75rem;
  background: #101016;
}
.detail-header.has-art::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, #0b0b0ef5, #0b0b0e00 85%);
  content: '';
}
.detail-art { position: absolute; z-index: -2; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.detail-header h2 { overflow-wrap: anywhere; }
.detail-header h2:focus { outline: none; }
#close { flex: 0 0 44px; line-height: 1; font-size: 1.35rem; }
.detail-header.has-art #close { align-self: start; background: #0b0b0edb; }
.detail-meta { margin-block: .75rem 0; color: var(--muted); }
.detail-actions { flex-wrap: wrap; }
.detail-section { margin-top: 1.2rem; }
.detail-section h3 { margin-block: 0 .5rem; }
.episode-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(8.5rem, 30%, 11.5rem);
  gap: .55rem;
  overflow-x: auto;
  padding: .25rem .25rem .6rem;
}
.episode-card { overflow: hidden; padding: 0 0 .5rem; text-align: start; }
.episode-card[aria-pressed="true"] { border-color: var(--accent); background: #2b1920; }
.episode-card img, .episode-card .placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #282431;
}
.episode-card small, .episode-card strong { display: block; margin-inline: .5rem; overflow-wrap: anywhere; }
.episode-card small { margin-block-start: .25rem; color: var(--muted); font-size: .875rem; }
#episode-overview { margin-block: .5rem 0; color: var(--muted); }
#player-status:empty, .player-controls:empty { display: none; }
video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 54dvh; margin-block: 1rem .5rem; background: #000; }
.player-controls { display: flex; flex-wrap: wrap; gap: .6rem 1rem; margin-block: .7rem; }
.player-controls label { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
#related-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 125px), 1fr)); }
a { color: #ff9aa5; }
footer, #status, #overview, #player-status { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 960px) {
  header { flex-wrap: wrap; }
  nav { order: 3; width: 100%; overflow: auto; padding: .1rem .15rem .25rem; }
  #licensed-cards, .licensed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  header { gap: .4rem; }
  nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .2rem; padding: 0; }
  nav button { padding-inline: .15rem; font-size: .875rem; line-height: 1.25; white-space: normal; }
  .toolbar { align-items: stretch; flex-direction: column; }
  #query { flex: 1; }
  .hero { background-position: center, center, 54% center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 138px), 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
