:root {
  --bg: #08090b;
  --panel: #121419;
  --panel-raised: #1a1d23;
  --text: #f7f7f5;
  --muted: #b9bbc2;
  --faint: #747780;
  --accent: #e50914;
  --focus: #ffffff;
  --safe-x: clamp(1.5rem, 3.8vw, 4.8rem);
  --safe-y: clamp(1.25rem, 3.2vh, 3rem);
  --card-radius: .55rem;
  color-scheme: dark;
  font-size: clamp(16px, 1.03vw, 24px);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.boot {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  background: var(--bg);
}
.boot-mark, .brand-mark {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 900;
  line-height: 1;
}
.boot-mark { width: 4.5rem; height: 4.5rem; font-size: 2.4rem; box-shadow: 0 0 3rem rgba(229, 9, 20, .24); }
.boot-copy { display: flex; flex-direction: column; gap: .3rem; }
.boot-copy strong { font-size: 1.2rem; letter-spacing: .22em; }
.boot-copy span { color: var(--muted); font-size: .78rem; }
.boot.is-leaving { opacity: 0; transition: opacity 180ms linear; }

.app { min-height: 100vh; background: var(--bg); }
.masthead {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 5.4rem;
  padding: var(--safe-y) var(--safe-x) 2rem;
  background: linear-gradient(180deg, rgba(8, 9, 11, .9), rgba(8, 9, 11, .34) 64%, transparent);
  pointer-events: none;
}
.masthead > * { pointer-events: auto; }
.brand { display: inline-flex; width: max-content; align-items: center; gap: .75rem; color: white; text-decoration: none; }
.brand-mark { width: 2.35rem; height: 2.35rem; font-size: 1.25rem; }
.brand-name { font-size: .88rem; font-weight: 900; letter-spacing: .18em; }
.nav { display: flex; align-items: center; gap: .35rem; padding: .25rem; border: 1px solid rgba(255, 255, 255, .08); border-radius: 2rem; background: rgba(12, 13, 16, .45); backdrop-filter: blur(12px); }
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 2.7rem;
  padding: .55rem 1.05rem;
  border: 0;
  border-radius: 1.6rem;
  background: transparent;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms linear, color 120ms linear, transform 120ms ease;
}
.nav-item.is-active { background: rgba(255, 255, 255, .15); color: white; }
.nav-icon { font-size: 1.05rem; line-height: 1; }
.status-cluster { justify-self: end; display: flex; align-items: center; gap: 1rem; color: var(--muted); }
.signal { display: flex; align-items: center; gap: .45rem; font-size: .7rem; font-weight: 700; }
.signal-dot { width: .48rem; height: .48rem; border-radius: 50%; background: #6c7078; }
.signal-dot.is-live { background: #46d369; box-shadow: 0 0 .7rem rgba(70, 211, 105, .48); }
.clock { min-width: 3.2rem; color: #d7d8db; font-size: .82rem; font-variant-numeric: tabular-nums; text-align: right; }

.hero { position: relative; height: min(86vh, 61rem); min-height: 38rem; overflow: hidden; background: #111318; contain: layout paint; }
.hero-artwork, .detail-artwork, .hero-shade, .detail-shade { position: absolute; inset: 0; }
.hero-image, .detail-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.015); transition: opacity 320ms linear, transform 7s ease-out; }
.hero-image.is-loaded, .detail-image.is-loaded { opacity: 1; transform: scale(1); }
.artwork-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #151820;
  color: rgba(255, 255, 255, .06);
}
.artwork-fallback span { font-size: min(38vw, 28rem); font-weight: 900; }
.hero-shade {
  background:
    linear-gradient(90deg, rgba(8, 9, 11, .98) 0%, rgba(8, 9, 11, .74) 38%, rgba(8, 9, 11, .12) 72%),
    linear-gradient(0deg, var(--bg) 0%, rgba(8, 9, 11, .16) 38%, rgba(8, 9, 11, .22) 100%);
}
.hero-content { position: absolute; z-index: 2; left: var(--safe-x); bottom: clamp(8rem, 19vh, 13rem); width: min(43rem, 54vw); }
.hero-kicker, .eyebrow { margin: 0 0 .8rem; color: #e8e8e8; font-size: .72rem; font-weight: 850; letter-spacing: .17em; text-transform: uppercase; }
.hero-kicker::before, .eyebrow::before { display: inline-block; width: .32rem; height: .9rem; margin-right: .55rem; background: var(--accent); content: ""; vertical-align: -.1rem; }
.hero-title { max-width: 100%; margin: 0; font-size: clamp(2.9rem, 4.8vw, 5.4rem); font-weight: 900; line-height: .94; letter-spacing: -.055em; text-wrap: balance; text-shadow: 0 .15rem 1.3rem rgba(0, 0, 0, .38); }
.hero-meta { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: center; min-height: 1.4rem; margin-top: 1.25rem; color: #ececee; font-size: .88rem; font-weight: 650; }
.hero-meta span + span::before { margin-right: 1rem; color: #81848b; content: "•"; }
.hero-meta .rating { display: inline-flex; align-items: center; gap: .35rem; }
.hero-meta .rating::after { padding: .08rem .32rem; border-radius: .16rem; background: #f5c518; color: #111; content: "IMDb"; font-size: .52rem; font-weight: 900; order: -1; }
.hero-overview { display: -webkit-box; max-width: 39rem; margin: 1rem 0 0; overflow: hidden; color: #d1d2d6; font-size: 1rem; line-height: 1.48; text-wrap: pretty; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.hero-actions, .detail-actions { display: flex; gap: .75rem; margin-top: 1.55rem; }
.button, .control-button, .icon-button { border: 0; cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .65rem; min-width: 7.8rem; min-height: 3.2rem; padding: .75rem 1.25rem; border-radius: .4rem; font-size: .9rem; font-weight: 850; transition: transform 120ms ease, background-color 120ms linear, color 120ms linear; }
.button:disabled { cursor: default; opacity: .38; }
.button-primary { background: white; color: #08090b; }
.button-secondary { background: rgba(109, 109, 110, .72); color: white; backdrop-filter: blur(8px); }
.button-icon { font-size: 1rem; line-height: 1; }
.button-info { display: grid; width: 1.12rem; height: 1.12rem; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-family: Georgia, serif; font-size: .72rem; }
.hero-count { position: absolute; z-index: 2; right: var(--safe-x); bottom: clamp(8rem, 19vh, 13rem); display: flex; align-items: center; gap: .6rem; color: rgba(255, 255, 255, .72); font-size: .72rem; font-variant-numeric: tabular-nums; }
.hero-count i { width: 2.6rem; height: 2px; background: rgba(255, 255, 255, .28); }

.shelves { position: relative; z-index: 4; min-height: 30vh; margin-top: clamp(-8rem, -11vh, -5rem); padding: 0 0 6rem; }
.media-shelf { position: relative; margin-bottom: 2.1rem; padding-left: var(--safe-x); }
.shelf-heading { display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 2.2rem; padding-right: var(--safe-x); }
.shelf-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; letter-spacing: -.025em; }
.freshness { margin: 0; color: var(--muted); font-size: .68rem; }
.media-row { display: flex; gap: .72rem; overflow-x: auto; overflow-y: visible; padding: .75rem var(--safe-x) 1.1rem 0; scrollbar-width: none; scroll-snap-type: x proximity; contain: layout; }
.media-row::-webkit-scrollbar { display: none; }
.movie-card {
  position: relative;
  flex: 0 0 clamp(14.4rem, 20.5vw, 24rem);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 0;
  border-radius: var(--card-radius);
  outline: 0 solid transparent;
  background: var(--panel-raised);
  color: white;
  text-align: left;
  scroll-snap-align: start;
  transform: translateZ(0);
  transition: transform 140ms ease, outline-color 100ms linear, box-shadow 140ms ease;
  contain: layout paint;
}
.movie-card-art { position: absolute; inset: 0; background: #20232a; }
.movie-card-art::after { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(5, 6, 8, .95), transparent 58%); content: ""; }
.movie-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 180ms linear; }
.movie-card img.is-loaded { opacity: 1; }
.movie-card-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .08); font-size: 5rem; font-weight: 900; }
.movie-card-copy { position: absolute; z-index: 1; right: .8rem; bottom: .68rem; left: .8rem; display: flex; align-items: end; justify-content: space-between; gap: .7rem; }
.movie-card-title { min-width: 0; }
.movie-card h3 { max-width: 100%; margin: 0; overflow: hidden; font-size: .9rem; font-weight: 780; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.movie-card p { margin: .23rem 0 0; overflow: hidden; color: #c5c7cc; font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
.movie-card-badge { flex: none; padding: .18rem .38rem; border-radius: .22rem; background: rgba(8, 9, 11, .78); color: #f5c518; font-size: .58rem; font-weight: 850; }
.genre-rows:empty { display: none; }

.empty-state { display: flex; align-items: center; gap: 1.5rem; margin: 2rem var(--safe-x); padding: 2rem; border: 1px solid rgba(255, 255, 255, .09); border-radius: .6rem; background: var(--panel); }
.empty-mark { display: grid; flex: none; width: 4rem; height: 4rem; place-items: center; border-radius: 50%; background: var(--accent); font-size: 2rem; font-weight: 900; }
.empty-state h2 { margin: 0; font-size: 1.35rem; }
.empty-state p { max-width: 40rem; margin: .45rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }

.remote-hints { position: fixed; z-index: 15; right: 0; bottom: 0; left: 0; display: flex; gap: 1.5rem; align-items: center; padding: .55rem var(--safe-x); background: rgba(8, 9, 11, .84); color: var(--faint); font-size: .6rem; backdrop-filter: blur(10px); }
.remote-hints span:last-child { margin-left: auto; }
kbd { padding: .12rem .28rem; border: 1px solid rgba(255, 255, 255, .2); border-radius: .18rem; color: #d7d8dc; font-family: inherit; }

.focusable:focus { outline: none; }
.focusable.is-focused, .focusable:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.nav-item.is-focused, .nav-item:focus-visible { background: white; color: #08090b; transform: scale(1.035); }
.button.is-focused, .button:focus-visible, .control-button.is-focused, .control-button:focus-visible { transform: scale(1.055); }
.movie-card.is-focused, .movie-card:focus-visible { z-index: 5; outline-color: var(--focus); box-shadow: 0 .7rem 2rem rgba(0, 0, 0, .58); transform: scale(1.065) translateZ(0); }

.overlay { position: fixed; z-index: 40; inset: 0; overflow: auto; padding: var(--safe-y) var(--safe-x) 5rem; background: var(--bg); }
.overlay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; }
.overlay-head h2 { max-width: 55rem; margin: 0; font-size: clamp(2rem, 3.4vw, 3.7rem); line-height: 1.04; letter-spacing: -.045em; }
.icon-button { display: grid; flex: none; width: 3rem; height: 3rem; place-items: center; border: 1px solid rgba(255, 255, 255, .3); border-radius: 50%; background: rgba(12, 13, 16, .72); color: white; font-size: 1.65rem; line-height: 1; backdrop-filter: blur(8px); }
.search-box { display: flex; align-items: center; gap: 1rem; max-width: 62rem; margin-top: 2.5rem; border: 2px solid rgba(255, 255, 255, .2); border-radius: .55rem; background: var(--panel); padding: 0 1.15rem; }
.search-box:focus-within { border-color: white; }
.search-symbol { color: var(--muted); font-size: 1.7rem; }
.search-box input { width: 100%; border: 0; background: transparent; padding: 1rem 0; color: white; font-size: 1.25rem; outline: 0; }
.search-box input::placeholder { color: #777a82; }
.search-summary { min-height: 1rem; margin: 1rem 0 0; color: var(--muted); font-size: .72rem; }
.search-results { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; padding-bottom: 3rem; }
.search-results .movie-card { width: 100%; min-width: 0; }

.detail-overlay { overflow: hidden; padding: 0; background: var(--bg); }
.detail-shade { background: linear-gradient(90deg, rgba(8, 9, 11, .99) 0%, rgba(8, 9, 11, .84) 42%, rgba(8, 9, 11, .16) 80%), linear-gradient(0deg, rgba(8, 9, 11, .86), transparent 52%); }
.detail-close { position: absolute; z-index: 3; top: var(--safe-y); right: var(--safe-x); }
.detail-content { position: absolute; z-index: 2; left: var(--safe-x); bottom: 8vh; width: min(44rem, 55vw); }
.detail-content h2 { margin: 0; font-size: clamp(3rem, 5.3vw, 6.2rem); font-weight: 900; line-height: .92; letter-spacing: -.055em; text-wrap: balance; }
.detail-overview { display: -webkit-box; max-width: 39rem; margin: 1rem 0 0; overflow: hidden; color: #d4d5d8; font-size: .96rem; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.detail-credits { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; max-width: 38rem; margin: 1.15rem 0 0; font-size: .72rem; line-height: 1.4; }
.detail-credits dt { color: #92959d; }
.detail-credits dd { margin: 0; color: #d3d4d7; }

.player { position: fixed; z-index: 60; inset: 0; overflow: hidden; background: #000; }
.player-topbar { position: absolute; z-index: 3; top: 0; right: 0; left: 0; display: flex; align-items: center; justify-content: space-between; padding: 1.5rem var(--safe-x) 4rem; background: linear-gradient(180deg, rgba(0, 0, 0, .92), transparent); }
.player-topbar h2 { margin: 0; font-size: 1.35rem; }
.player-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.player-stage iframe, .player-stage video { width: 100%; height: 100%; border: 0; background: #000; }
.player-controls { position: absolute; z-index: 3; right: 0; bottom: 0; left: 0; display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: 4.5rem var(--safe-x) 1.7rem; background: linear-gradient(0deg, rgba(0, 0, 0, .96), transparent); }
.player-topbar, .player-controls { transition: opacity 260ms linear; }
.player.is-idle .player-topbar, .player.is-idle .player-controls { opacity: 0; }
.control-hint { align-self: center; max-width: 26rem; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.source-buttons, .media-buttons { display: flex; flex-wrap: wrap; gap: .55rem; }
.control-button { min-width: 5.5rem; padding: .65rem .9rem; border: 1px solid rgba(255, 255, 255, .45); border-radius: .35rem; background: rgba(0, 0, 0, .75); font-size: .72rem; font-weight: 800; }
.control-button.is-active { border-color: white; background: white; color: #08090b; }
.player-message { position: absolute; z-index: 4; top: 50%; left: 50%; margin: 0; transform: translate(-50%, -50%); color: white; font-size: .9rem; }
.toast { position: fixed; z-index: 80; right: var(--safe-x); bottom: 3.5rem; max-width: 32rem; padding: .85rem 1rem; border-left: 4px solid var(--accent); border-radius: .25rem; background: #24262c; color: white; font-size: .78rem; box-shadow: 0 .8rem 2rem rgba(0, 0, 0, .45); }

@media (max-width: 1100px) {
  :root { --safe-x: 1.4rem; --safe-y: 1.15rem; }
  .masthead { grid-template-columns: auto 1fr auto; }
  .brand-name, .signal span:last-child { display: none; }
  .nav { justify-self: center; }
  .hero-content { width: 64vw; }
  .movie-card { flex-basis: 27vw; }
  .search-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  :root { font-size: 16px; }
  .masthead { display: flex; justify-content: space-between; }
  .status-cluster { display: none; }
  .nav-item { min-width: 2.7rem; padding: .55rem .8rem; }
  .nav-item > span:last-child { display: none; }
  .hero { height: 82vh; min-height: 37rem; }
  .hero-shade { background: linear-gradient(0deg, var(--bg) 0%, rgba(8, 9, 11, .5) 52%, rgba(8, 9, 11, .22) 100%); }
  .hero-content { bottom: 7rem; width: calc(100% - 3rem); }
  .hero-title { font-size: 2.8rem; }
  .hero-overview { font-size: .9rem; -webkit-line-clamp: 3; }
  .hero-count { display: none; }
  .shelves { margin-top: -4rem; }
  .movie-card { flex-basis: 76vw; }
  .freshness { display: none; }
  .remote-hints { display: none; }
  .search-results { grid-template-columns: 1fr; }
  .detail-shade { background: linear-gradient(0deg, rgba(8, 9, 11, .98) 0%, rgba(8, 9, 11, .65) 72%, rgba(8, 9, 11, .18)); }
  .detail-content { bottom: 3rem; width: calc(100% - 3rem); }
  .detail-content h2 { font-size: 3rem; }
}

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