/* Plex Canvas Player — dark, remote-friendly UI with large targets. */

:root {
  /* Marquee: dark and cinematic, one amber accent. */
  --bg: #0E0F13;
  --bg-2: #16171C;
  --bg-3: #212329;
  --bg-4: #2B2D36;
  --line: #2A2C34;
  --text: #F2F2F4;
  --text-2: #A3A7B3;
  --text-3: #7A7E89;
  --accent: #F2B23A;
  --accent-text: #1A1405;
  --ok: #4cc38a;
  --warn: #f0b429;
  --err: #ff6b6b;
  --focus: #7cc4ff;
  --radius: 12px;
  --tap: 44px;
  --topbar-h: 64px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/archivo.woff2') format('woff2');
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
a { color: var(--accent); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--text-2); }
.small { font-size: 0.875rem; }
.block { display: block; }
.error { color: var(--err); }
.offscreen { position: fixed; left: -9999px; top: 0; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-3); color: var(--text);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-4); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 52px; padding: 0 22px; font-size: 1.05rem; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 0.875rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 0; background: transparent; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.iconbtn:hover { background: var(--bg-3); }
.iconbtn svg { width: 24px; height: 24px; fill: currentColor; }
.sel {
  min-height: 40px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-3); max-width: 100%;
}

/* ----------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h); padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  background: rgba(16, 17, 20, 0.96); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; }
.logo { width: 30px; height: 30px; }
.logo rect { fill: var(--accent); }
.logo path { fill: var(--bg); }
.topbar-spacer { flex: 1; }
.toplink { color: var(--text-2); text-decoration: none; padding: 10px 8px; }
.toplink:hover { color: var(--text); }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-text { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }

.mode-badge {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: var(--tap); max-width: 46vw; padding: 4px 12px;
  border: 1px solid var(--line); border-left: 4px solid var(--text-3); border-radius: 8px;
  background: var(--bg-2); cursor: pointer; text-align: left; line-height: 1.2;
}
.mode-badge-text { font-weight: 650; white-space: nowrap; }
.mode-badge-reason { font-size: 0.75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mode-badge.mode-html5 { border-left-color: #6cb6ff; }
.mode-badge.mode-webcodecs { border-left-color: #b28cff; }
.mode-badge.mode-jsmpeg { border-left-color: var(--accent); }
.mode-badge.mode-mjpeg { border-left-color: #ff8f6b; }
.mode-badge.mode-external { border-left-color: var(--ok); }
.mode-badge.active { background: var(--bg-3); }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 44px; height: 26px; border-radius: 13px; background: var(--bg-4); position: relative; transition: background 0.15s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.6; }
.switch-text { font-size: 0.9rem; white-space: nowrap; }

/* ------------------------------------------------------------------ main */
.main { padding: 16px max(16px, env(safe-area-inset-left)); max-width: 1500px; margin: 0 auto; }
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.panel.narrow { max-width: 560px; margin: 40px auto; }
.panel h3 { margin-top: 0; }
.boot { text-align: center; margin-top: 20vh; }

.signin h2 { margin-top: 0; }
.signin-status { margin-top: 14px; }
.signin-status.error p { color: var(--err); }
.pin-code { font: 700 2.6rem/1.2 var(--mono); letter-spacing: 0.2em; color: var(--accent); margin: 8px 0; }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.tab {
  flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px;
  border-radius: 22px; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text-2); text-decoration: none; white-space: nowrap;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.toolbar { margin: 6px 0 14px; }
.search { width: min(420px, 100%); min-height: var(--tap); padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg-2); }

/* poster grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
.card { color: var(--text); text-decoration: none; display: block; border-radius: var(--radius); }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.poster { position: relative; aspect-ratio: 2 / 3; background: var(--bg-3); border-radius: 8px; overflow: hidden; transition: transform .12s; }
.poster img, .still img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noposter { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.4rem; color: var(--text-3); }
.card-title { margin-top: 6px; font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 0.82rem; color: var(--text-2); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0,0,0,.6); }
.progress-fill { height: 100%; background: var(--accent); width: 0; }
.watched { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: .8rem; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.more { display: flex; margin: 18px auto; }

/* item page */
.item-head { display: flex; gap: 24px; align-items: flex-start; }
.item-poster { width: 220px; flex: none; border-radius: 10px; aspect-ratio: 2 / 3; object-fit: cover; background: var(--bg-3); }
.item-info { flex: 1; min-width: 0; }
.item-info h2 { margin: 0 0 4px; font-size: 1.8rem; line-height: 1.15; }
.item-sub { font-size: 1.1rem; margin-bottom: 4px; }
.tagline { font-style: italic; color: var(--text-2); }
.summary { max-width: 70ch; }
.play-controls { margin-top: 14px; }
.field { display: inline-flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--text-2); margin-right: 6px; }
.mode-hint { margin-top: 4px; }
.ext-box { margin-top: 10px; }
.episode-list { display: flex; flex-direction: column; gap: 8px; }
.episode { display: flex; gap: 14px; align-items: center; padding: 8px; border-radius: var(--radius); color: var(--text); text-decoration: none; background: var(--bg-2); border: 1px solid var(--line); }
.episode:hover { background: var(--bg-3); }
.still { position: relative; width: 160px; aspect-ratio: 16 / 9; flex: none; background: var(--bg-3); border-radius: 6px; overflow: hidden; }

/* external panel */
.external-panel h3 { margin: 0 0 6px; }
.external-panel h4 { margin: 16px 0 4px; font-size: .95rem; color: var(--text-2); }
.url-box { width: 100%; min-height: var(--tap); padding: 0 10px; font: 0.85rem var(--mono); border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: .82rem var(--mono); background: var(--bg); padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------------------------------------------------------------- player */
body.playing .main, body.playing .topbar { display: none; }
.player-view { padding: 0; }
/* While playing, the player owns the whole window. */
.player { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: #000; }
.player-loading { padding: 40px; text-align: center; color: var(--text-2); }
.stage { position: relative; flex: 1; min-height: 200px; overflow: hidden; background: #000; outline: none; }
.stage .surface {
  position: absolute; inset: 0; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: contain; display: block; background: #000;
}
.stage .surface.pending { visibility: hidden; }
.stage video.surface::-webkit-media-controls { display: none !important; }

.subs {
  position: absolute; left: 5%; right: 5%; bottom: 7%; z-index: 3; text-align: center; pointer-events: none;
  transition: bottom .2s;
}
.stage.show-controls .subs, .stage.paused .subs { bottom: 120px; }
.stage.show-controls .sound-btn, .stage.paused .sound-btn { top: 110px; }
.subs .cue {
  display: inline-block; margin: 2px auto; padding: 3px 10px; border-radius: 4px;
  background: rgba(0,0,0,.72); color: #fff; font-size: clamp(16px, 3.2vmin, 34px); line-height: 1.3;
  text-shadow: 0 1px 2px #000;
}
.subs .cue + .cue { display: table; }

.spinner {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; z-index: 4;
  border: 5px solid rgba(255,255,255,.25); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .9s linear infinite; pointer-events: none;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-msg {
  position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92%); max-height: 86%; overflow: auto;
  background: rgba(23,24,28,.96); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
  text-align: center;
}
.center-msg.wide { width: min(760px, 94%); text-align: left; }
.center-msg.hidden { display: none; }
.err-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.err-text { color: var(--text-2); margin-bottom: 8px; word-break: break-word; }

.top-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; flex-direction: column; gap: 4px;
  padding: max(8px, env(safe-area-inset-top, 0px)) 12px 30px; background: linear-gradient(rgba(0,0,0,.8) 60%, transparent);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.top-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 28px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.stage.show-controls .controls, .stage.paused .controls,
.stage.show-controls .top-bar, .stage.paused .top-bar { opacity: 1; pointer-events: auto; }
.stage:not(.show-controls):not(.paused) { cursor: none; }
.ctl-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctl {
  min-width: var(--tap); height: var(--tap); padding: 0 10px; border: 0; border-radius: 8px;
  background: rgba(255,255,255,.08); color: #fff; cursor: pointer; font-size: 1rem;
}
.ctl:hover { background: rgba(255,255,255,.18); }
.ctl.play { min-width: 56px; font-size: 1.2rem; }
.time { font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.spacer { flex: 1; }
.ctl-label { display: inline-flex; align-items: center; gap: 4px; }
.ctl-label-text { font-size: .75rem; color: var(--text-2); }
.ctl-label .sel { min-height: 38px; max-width: 170px; background: rgba(0,0,0,.55); }
input[type=range] { accent-color: var(--accent); cursor: pointer; }
.seek { width: 100%; height: 26px; margin: 0 0 4px; }
.volume { width: 90px; }

.status-bar { font-size: .82rem; padding-left: 2px; color: var(--text-2); }
.status-line { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.status-mode { font-weight: 700; padding: 1px 8px; border-radius: 6px; background: var(--bg-4); }
.status-mode.mode-html5 { background: #1d3550; }
.status-mode.mode-webcodecs { background: #33265a; }
.status-mode.mode-jsmpeg { background: #4a3608; }
.status-mode.mode-mjpeg { background: #50291b; }
.status-mode.mode-external { background: #173d2b; }
.status-reason { color: var(--text-2); }
.status-stats { color: var(--text-2); font-variant-numeric: tabular-nums; }
.status-msg { color: var(--text-2); }
.status-msg.error { color: var(--err); font-weight: 600; }
.status-msg:empty { display: none; }

.player:fullscreen { height: 100vh; }
.player:-webkit-full-screen { height: 100vh; }
.player[data-mode="external"] .controls { display: none; }
.fake-fullscreen .player { position: fixed; inset: 0; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 50; }

/* --------------------------------------------------------------- drawer */
.drawer-backdrop { position: fixed; inset: 0; top: 0; left: 0; right: 0; bottom: 0; z-index: 60; background: rgba(0,0,0,.55); }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.2rem; }
.drawer-body { overflow-y: auto; padding: 8px 16px 24px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; padding: 8px 12px 12px; }
legend { padding: 0 6px; color: var(--text-2); font-weight: 600; }
.mode-opt {
  display: grid; grid-template-columns: 28px 1fr; gap: 0 6px; padding: 10px 6px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.mode-opt:hover { background: var(--bg-3); }
.mode-opt.selected { border-color: var(--accent); background: var(--bg-3); }
.mode-opt input { grid-row: span 3; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.mode-name { font-weight: 650; }
.mode-desc { font-size: .85rem; color: var(--text-2); }
.mode-sup { font-size: .8rem; }
.mode-sup.ok { color: var(--ok); }
.mode-sup.no { color: var(--err); }
.mode-opt.unavailable .mode-name { color: var(--text-2); }
.toggle-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 4px; cursor: pointer; }
.toggle-row input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- probe */
.probe h2 { margin-top: 4px; }
.probe-result { font-size: 1.3rem; }
.probe-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.probe-table th { text-align: left; font-weight: 500; padding: 7px 10px; width: 40%; }
.probe-table td { padding: 7px 10px; color: var(--text-2); word-break: break-word; }
.probe-table tr { border-top: 1px solid var(--line); }
.probe-table td.mark { width: 28px; font-weight: 700; text-align: center; }
.probe-table tr.ok td.mark { color: var(--ok); }
.probe-table tr.no td.mark { color: var(--err); }
.probe-table tr.na td.mark { color: var(--text-3); }
.tests { margin-top: 10px; font-family: var(--mono); font-size: .9rem; }
.report { width: 100%; min-height: 220px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: .8rem var(--mono); }
.ua { word-break: break-all; }
.probe-video { position: fixed; width: 2px; height: 2px; left: -10px; top: -10px; opacity: 0.01; pointer-events: none; }
.mjpeg-source { position: fixed; width: 1px; height: 1px; left: -10px; top: -10px; opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 12px); transform: translate(-50%, -20px); z-index: 80;
  background: var(--bg-4); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ----------------------------------------------------------- responsive */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 3s !important; }
}

/* ------------------------------------------------- streams + server picker */
.server-sel { background: transparent; border: 0; color: var(--text-2); font-size: .8rem; padding: 0; max-width: 180px; cursor: pointer; }
.stream-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.stream-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; background: var(--bg-3); }
.stream-row.this-tab { outline: 1px solid var(--accent); }
.stream-info { flex: 1; min-width: 0; }
.stream-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upnext-label { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.upnext-still { width: min(320px, 80%); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; margin: 8px auto; display: block; background: var(--bg-3); }
.countdown { display: block; color: var(--accent); margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.sound-btn {
  position: absolute; z-index: 7; right: 16px; top: 64px;
  min-height: var(--tap); padding: 0 16px; border-radius: 22px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}

/* ------------------------------------------------ simple vs. advanced UI */
/* Technical controls (playback engine, probe, codec details) only show when
   "Show technical details" is on in Settings. */
body:not(.advanced) .adv { display: none !important; }

.main-nav { display: flex; align-items: center; gap: 2px; }
.navlink {
  color: var(--text-2); text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 600;
}
.navlink:hover { color: var(--text); background: var(--bg-3); }
.navlink.active { color: var(--text); background: var(--bg-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-4); color: var(--text); font-weight: 700; font-size: .9rem; text-transform: uppercase;
}

/* sign-in */
.signin-card { max-width: 440px; margin: 8vh auto 0; text-align: center; padding: 32px 28px; }
.signin-card h2 { margin: 6px 0 8px; font-size: 1.6rem; }
.signin-card .logo { width: 56px; height: 56px; }
.signin-card .btn.big { width: 100%; }
.signin-card .signin-status { text-align: left; }
.google-btn { background: #fff; color: #1f1f1f; border-color: #fff; font-weight: 600; }
.google-btn:hover { background: #f1f1f1; }
.google-btn svg { width: 20px; height: 20px; }
.linkbtn { background: none; border: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; padding: 8px; }
.linkbtn:hover { color: var(--text); }
.signin-alt { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.notice { border-radius: 8px; padding: 10px 12px; background: var(--bg-3); text-align: left; margin: 12px 0; }
.notice.error { color: var(--text); background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .35); }

/* home */
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.page-head h2 { margin: 0; font-size: 1.5rem; }

/* settings (simple part) */
.set-group { border: 0; padding: 0; margin: 0 0 18px; }
.set-group legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.advanced-box { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }

/* setup page */
.setup { max-width: 760px; margin: 0 auto; }
.setup h2 { margin: 6px 0 4px; }
.setup .panel h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.step-no {
  width: 26px; height: 26px; border-radius: 50%; flex: none; font-size: .85rem;
  display: inline-flex; align-items: center; justify-content: center; background: var(--bg-4);
}
.step-no.done { background: var(--ok); color: #0b2a1b; }
.setup ol { padding-left: 20px; margin: 8px 0; }
.setup ol li { margin: 4px 0; }
.setup input[type=text], .setup input[type=email], .setup input[type=password] {
  min-height: 48px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-3); width: 100%; font-size: 16px;
}
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: var(--bg-3); padding: 8px 10px; border-radius: 8px; font-family: var(--mono); font-size: .85rem; }
.people { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-3); }
.person .who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 10px; background: var(--bg-4); color: var(--text-2); }
.form-grid { display: grid; gap: 10px; }
.form-grid label span { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 4px; }
.err-detail { font-size: .8rem; color: var(--text-3); margin-top: 4px; }

/* ================================================================ Marquee */

.main { max-width: 1440px; padding: 20px max(40px, env(safe-area-inset-left)) 56px; }
.loading { padding: 24px 0; }

/* top bar */
.topbar { gap: 8px 22px; background: rgba(14, 15, 19, 0.92); border-bottom: 0; padding-left: max(40px, env(safe-area-inset-left)); padding-right: max(40px, env(safe-area-inset-right)); }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; gap: 10px; }
.logo rect { fill: var(--accent); }
.main-nav { gap: 2px; }
.navlink { color: var(--text-2); font-weight: 600; padding: 10px 14px; border-radius: 0; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); box-sizing: border-box; }
.navlink:hover { background: none; color: var(--text); }
.navlink.active { background: none; color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.nav-ico { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn svg.stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.user-box { gap: 6px; }
.menu-wrap { position: relative; }
.avatar-btn { border: 0; background: none; padding: 2px; border-radius: 50%; cursor: pointer; display: inline-flex; }
.avatar { width: 38px; height: 38px; background: var(--bg-4); font-size: 16px; }
.avatar-btn:hover .avatar, .avatar-btn[aria-expanded="true"] .avatar { background: #3A3D48; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 230px;
  background: #1B1C22; border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.menu-who { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; overflow-wrap: anywhere; }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: var(--tap); padding: 0 12px; box-sizing: border-box;
  border: 0; background: none; color: var(--text); border-radius: 8px; text-align: left; text-decoration: none; cursor: pointer; font: inherit;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-3); }

/* buttons */
.btn { border-radius: 12px; font-weight: 600; }
.btn.big { min-height: 54px; padding: 0 24px; font-size: 1.05rem; font-weight: 700; }
.btn.primary { font-weight: 800; }
.btn.soft { background: var(--bg-4); border-color: transparent; }
.btn.soft:hover { background: #363946; }
.ico { display: inline-flex; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; fill: currentColor; }
.back-link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0; border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.back-link:hover { color: var(--text); }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); text-decoration: none; }
a.eyebrow:hover { text-decoration: underline; }

/* meta line: 1990 · 2h 26m · R */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: #C9CCD4; font-size: 15px; font-weight: 500; }
.meta .rating { border: 1px solid #5B5F6B; border-radius: 4px; padding: 0 6px; font-size: 13px; }
.meta .dot { color: var(--text-3); }

/* hero */
.hero { position: relative; border-radius: 18px; overflow: hidden; background: #1D1713; min-height: 440px; display: flex; align-items: flex-end; margin: 4px 0 40px; }
.hero-art, .item-art { position: absolute; inset: 0; }
.hero-pic, .item-art-pic { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.hero-art .noimg, .item-art .noimg { width: 100%; height: 100%; }
.hero::after, .item-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(14,15,19,.96) 0%, rgba(14,15,19,.82) 38%, rgba(14,15,19,.2) 72%, rgba(14,15,19,.05) 100%), linear-gradient(0deg, rgba(14,15,19,.75) 0%, transparent 45%);
}
.hero-body { position: relative; z-index: 1; padding: 56px; max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.hero-title { margin: 0; font-size: clamp(40px, 6vw, 76px); line-height: 0.95; font-weight: 900; letter-spacing: -0.03em; }
.hero-sub { font-size: 18px; font-weight: 600; }
.hero-summary { margin: 0; font-size: 17px; line-height: 1.5; color: #D8DAE0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.hero-body .progress, .item-info .progress { position: relative; width: min(320px, 100%); height: 4px; border-radius: 2px; background: #3A3B44; }
.hero-body .progress-fill, .item-info .progress-fill { border-radius: 2px; }

/* shelves */
.shelf { margin: 0 0 36px; }
.shelf-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.shelf-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.see-all { margin-left: auto; font-weight: 700; font-size: 15px; text-decoration: none; }
.see-all:hover { text-decoration: underline; }
.shelf-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 5 * 18px) / 6); gap: 18px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding-bottom: 8px; scrollbar-width: thin;
}
.shelf-row > * { scroll-snap-align: start; min-width: 0; }
.shelf-row.wide { grid-auto-columns: calc((100% - 3 * 18px) / 4); }
.shelf-row > p { white-space: nowrap; }
.panel.tip { margin: 0 0 32px; }

/* cards */
.grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 28px 18px; }
.poster { border-radius: 10px; }
.poster-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .noimg, .wide-img .noimg, .pl-img .noimg, .still .noimg { width: 100%; height: 100%; background: var(--bg-3); }
.card-title { margin-top: 8px; font-size: 15px; }
.card-sub { font-size: 13px; margin-top: 1px; }
.card:hover .poster, .card:focus-visible .poster { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.55); }
.progress { height: 4px; background: rgba(0,0,0,.55); }
.watched { top: 8px; right: 8px; width: 26px; height: 26px; background: var(--bg); }
.watched svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.wide-card { display: block; color: var(--text); text-decoration: none; min-width: 0; }
.wide-img { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--bg-3); transition: transform .12s; }
.wide-pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.wide-play {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: var(--accent); opacity: 0; transition: opacity .15s;
}
.wide-play::after { content: ''; position: absolute; left: 20px; top: 16px; border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent var(--accent-text); }
.wide-card:hover .wide-play, .wide-card:focus-visible .wide-play { opacity: 1; }
.wide-card:hover .wide-img { transform: translateY(-3px); }
.wide-img .progress { height: 4px; }

/* pages */
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 18px; }
.page-head h1 { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: -0.02em; }
.page-head h2 { font-size: 30px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 22px; }
.search { background: var(--bg-3); border-color: transparent; border-radius: 12px; }
.search:focus { border-color: var(--accent); outline: none; }
.search.big { width: 100%; max-width: 680px; min-height: 54px; font-size: 18px; padding: 0 18px; margin-bottom: 28px; }
.toolbar .sel { min-height: var(--tap); border-radius: 12px; background: var(--bg-3); border-color: transparent; padding: 0 12px; }
.grid-status { margin: 18px 0 0; }
.sentinel { height: 1px; }
.results { margin-bottom: 32px; }

/* playlists */
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 28px 18px; }
.pl-card { display: block; color: var(--text); text-decoration: none; }
.pl-img { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--bg-3); transition: transform .12s; }
.pl-pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-card:hover .pl-img { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.55); }
.pl-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.pl-empty svg { width: 44px; height: 44px; fill: none; stroke: var(--text-3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pl-badge { position: absolute; top: 10px; left: 10px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 10px; }

/* title page */
.item-hero { position: relative; border-radius: 18px; overflow: hidden; background: #17181D; margin: 4px 0 32px; }
.item-hero-inner { position: relative; z-index: 1; padding: 16px 48px 44px; min-height: 420px; display: flex; flex-direction: column; box-sizing: border-box; }
.item-body { display: flex; gap: 36px; align-items: flex-end; margin-top: auto; padding-top: 48px; }
.item-poster-wrap { width: 210px; flex: none; }
.item-poster { width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; object-fit: cover; display: block; box-shadow: 0 14px 40px rgba(0,0,0,.6); }
.item-poster-wrap .noimg { aspect-ratio: 2 / 3; border-radius: 12px; background: var(--bg-3); }
.item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.item-title { margin: 0; font-size: clamp(32px, 5vw, 64px); line-height: 0.98; font-weight: 900; letter-spacing: -0.03em; }
.item-info .summary { margin: 0; max-width: 68ch; color: #D8DAE0; font-size: 16px; line-height: 1.55; }
.item-info .tagline { margin: 0; }
.play-controls { margin-top: 6px; }
.play-controls .row { margin: 8px 0; }
.play-controls .selects { gap: 8px 12px; }
.field { font-size: 13px; }
.field .sel, .play-controls .sel { min-height: var(--tap); border-radius: 12px; background: rgba(43,45,54,.92); border-color: transparent; padding: 0 12px; }
.item-children h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; }
.episode-list { gap: 4px; }
.episode { background: none; border: 0; border-radius: 12px; padding: 10px; gap: 18px; align-items: flex-start; }
.episode:hover { background: var(--bg-2); }
.still { width: 220px; border-radius: 8px; }
.still-pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.episode-text { min-width: 0; padding-top: 2px; }
.episode .card-title { margin-top: 0; font-size: 16px; }
.episode-summary { margin-top: 6px; font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 80ch; }

/* sign-in */
.signin-card { background: var(--bg-2); border-color: var(--line); border-radius: 18px; }
.signin-card h2 { font-weight: 900; letter-spacing: -0.02em; font-size: 2rem; }
.google-btn { color: #1F1F1F; border-radius: 12px; }
.gicon { display: inline-flex; width: 20px; height: 20px; }
.gicon svg { width: 100%; height: 100%; }
.server-checks { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }


/* ================================================= in-car touch screen */
/* Target: a ~1150×800 browser pane (fluid from 750×600 to 1220 wide), a
   touch screen whose browser still reports hover and a fine pointer, no
   zoom. So: 48px targets 8px apart, nothing that only shows on hover,
   16px+ text, main actions within ~780px of height, light effects, and an
   in-app size setting (Settings → Text and button size). */

:root { --tap: 48px; }
html { overflow-x: hidden; }
.main, .drawer, .toast { zoom: var(--ui-zoom, 1); }
.topbar { min-height: 56px; padding-top: 4px; padding-bottom: 4px; background: rgba(14, 15, 19, 0.97); padding-left: 32px; padding-right: 32px; gap: 8px 16px; }
.main { padding: 16px 32px 48px; }

/* every control at least 48×48, with 8px between neighbours */
.btn, .btn.small, .btn.big, .sel, .search, .menu-item, .navlink, .back-link, .linkbtn, .see-all, .toggle-row { min-height: 48px; }
.btn.small { font-size: 15px; padding: 0 16px; }
.iconbtn { width: 48px; height: 48px; }
.avatar-btn { min-width: 48px; min-height: 48px; align-items: center; justify-content: center; }
.avatar { width: 40px; height: 40px; }
.main-nav, .user-box { gap: 8px; }
.navlink { padding: 0 14px; }
.see-all, .linkbtn { display: inline-flex; align-items: center; padding: 0 12px; }
.see-all { margin-right: -12px; }
.row { gap: 12px; }
.toggle-row { align-items: center; padding: 4px; }
.toggle-row input { width: 26px; height: 26px; margin-top: 0; }
.user-menu { display: flex; flex-direction: column; gap: 8px; }
.menu-who { margin-bottom: 0; }
.people, .stream-list, .episode-list, .server-checks { gap: 8px; }
.mode-opt { min-height: 48px; }
.mode-opt input { width: 24px; height: 24px; }

/* legible type (no browser zoom) */
.small { font-size: 15px; }
.card-title { font-size: 16px; }
.card-sub { font-size: 15px; }
.meta { font-size: 16px; }
.eyebrow { font-size: 14px; }
.field { font-size: 15px; }
.mode-desc, .mode-sup, .err-detail { font-size: 15px; }
.pl-badge { font-size: 13px; }

/* touch: show the play badge always; press feedback instead of hover lifts */
.wide-play { opacity: 0.92; }
.card:hover .poster, .wide-card:hover .wide-img, .pl-card:hover .pl-img { transform: none; box-shadow: none; }
.card:active .poster, .wide-card:active .wide-img, .pl-card:active .pl-img, .episode:active { transform: scale(0.97); }
.btn:active, .navlink:active, .menu-item:active, .ctl:active { transform: scale(0.97); }
.episode:hover { background: none; }
.episode:active { background: var(--bg-2); }

/* sized for a ~1150×800 pane: main actions and the first row of posters
   fit in the first ~780px */
.hero { min-height: 340px; margin-bottom: 32px; }
.hero-body { padding: 40px 44px; max-width: 600px; gap: 12px; }
.hero-title { font-size: clamp(36px, 5vw, 60px); }
.hero-summary { -webkit-line-clamp: 2; }
.item-hero-inner { min-height: 360px; padding: 8px 40px 36px; }
.item-body { padding-top: 24px; gap: 32px; }
.item-poster-wrap { width: 180px; }
.item-title { font-size: clamp(32px, 4.6vw, 56px); }
.shelf { margin-bottom: 32px; }

/* the player's controls are fingers-first too */
.ctl { min-width: 48px; height: 48px; }
.ctl.play { min-width: 60px; }
.ctl-row { gap: 8px; }
.ctl-label .sel { min-height: 48px; max-width: 180px; }
.ctl-label-text { font-size: 14px; }
.status-bar { font-size: 14px; }
.seek, .volume { -webkit-appearance: none; appearance: none; background: transparent; height: 32px; }
.seek { height: 36px; margin-bottom: 6px; }
.seek::-webkit-slider-runnable-track, .volume::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }
.seek::-webkit-slider-thumb, .volume::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--accent); border: 0; }
.seek::-moz-range-track, .volume::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }
.seek::-moz-range-thumb, .volume::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); border: 0; }

/* -------------------------------------------------------------- tiers
   lg  >= 1024px  Profile A (~1150x800): inline nav, full hero.
   md  750-1023px Profile B (~775x600): menu in a drawer, compact hero,
                  core content within 600px of height.
   sm  < 750px    windows narrowed further (down to 480x580): small-screen
                  layout. */

.nav-toggle { flex: none; }
/* below the sticky header (z-index 20), which holds the drawer */
.nav-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(0, 0, 0, 0.55); }
@media (min-width: 1024px) {
  .nav-toggle, .nav-backdrop { display: none !important; }
}

@media (max-width: 1023px) {
  .topbar { padding-left: 16px; padding-right: 24px; gap: 8px; flex-wrap: nowrap; }
  .topbar .adv { display: none !important; }
  .main { padding: 14px 24px 40px; }
  /* navigation slides in from the left */
  .main-nav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 70; width: min(300px, 86vw); box-sizing: border-box;
    display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 16px 12px;
    background: #17181D; border-right: 1px solid var(--line); box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    transform: translateX(-105%); transition: transform 0.2s ease, visibility 0s linear 0.2s; visibility: hidden;
  }
  body.nav-open .main-nav { transform: none; visibility: visible; transition: transform 0.2s ease, visibility 0s; }
  .main-nav .navlink { min-height: 56px; padding: 0 16px; border-bottom: 0; border-radius: 12px; font-size: 18px; gap: 14px; justify-content: flex-start; }
  .main-nav .navlink.active { background: var(--bg-3); color: var(--accent); }
  .nav-ico { display: block; }
  /* compact hero: title, facts and buttons only */
  .hero { min-height: 220px; margin-bottom: 24px; }
  .hero-body { padding: 24px 28px; max-width: 560px; gap: 10px; }
  .hero-title { font-size: clamp(30px, 4.6vw, 44px); }
  .hero-summary { display: none; }
  .item-hero-inner { min-height: 0; padding: 4px 28px 24px; }
  .item-body { padding-top: 12px; gap: 24px; }
  .item-poster-wrap { width: 140px; }
  .item-title { font-size: clamp(28px, 4.4vw, 42px); }
  .shelf { margin-bottom: 28px; }
  .shelf-row { grid-auto-columns: calc((100% - 4 * 16px) / 5); gap: 16px; }
  .shelf-row.wide { grid-auto-columns: calc((100% - 2 * 16px) / 3); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 24px 16px; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .page-head h1 { font-size: 30px; }
  .still { width: 180px; }
}
@media (max-width: 860px) {
  .shelf-row { grid-auto-columns: calc((100% - 3 * 14px) / 4); gap: 14px; }
  .shelf-row.wide { grid-auto-columns: calc((100% - 14px) / 2); }
  .item-poster-wrap { display: none; }
  .ctl-label-text { display: none; }
  .volume { display: none; }
  .ctl-label .sel { max-width: 140px; }
  .still { width: 150px; }
}

@media (max-width: 749px) {
  .topbar { padding-left: 8px; padding-right: 12px; }
  .main { padding: 12px 16px 32px; }
  .hero { min-height: 0; margin-bottom: 22px; }
  .hero-body { padding: 20px; max-width: none; }
  .hero-title { font-size: 30px; }
  .hero-actions .btn { flex: 1 1 auto; }
  .item-hero-inner { padding: 4px 20px 20px; }
  .item-title { font-size: 30px; }
  .play-controls .btn.big { flex: 1 1 auto; }
  .shelf-row { grid-auto-columns: calc((100% - 2 * 12px) / 3); gap: 12px; }
  .shelf-row.wide { grid-auto-columns: calc((100% - 12px) / 1.6); }
  .shelf-head h2 { font-size: 21px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 20px 12px; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px 14px; }
  .page-head h1 { font-size: 28px; }
  .still { width: 128px; }
  .episode { gap: 12px; }
  .episode-summary { display: none; }
  .setup .panel { padding: 14px; }
  /* player: transport on the first row, everything else on the second */
  .ctl-row .spacer { flex: 1 0 100%; height: 0; }
}
@media (max-width: 599px) {
  .brand-text { display: none; }
}

/* short panes (Profile B is 600-650px tall) */
@media (max-height: 700px) {
  .hero { min-height: 200px; }
  .hero-body { padding-top: 20px; padding-bottom: 20px; }
  .hero-summary { display: none; }
  .item-hero-inner { min-height: 0; }
}
/* technical controls can wrap onto a second header row on wide panes */
@media (min-width: 1024px) {
  body.advanced .topbar { flex-wrap: wrap; }
}
