:root {
  --bg: #0B0F17;
  --card: #151B27;
  --line: rgba(255, 255, 255, 0.08);
  --text: #FFFFFF;
  --dim: rgba(255, 255, 255, 0.6);
  --faint: rgba(255, 255, 255, 0.35);
  --accent: #34C759;
  --warn: #FFB4A8;
  /* Chart series (the data-viz palette's dark steps, validated against --card) and status colours. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --good: #0ca30c;
  --bad: #d03b3b;
  --busy: #fab219;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  min-height: 100dvh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Linking */
.link-box { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.logo { width: 72px; height: 72px; margin: 0 auto 16px; display: block; }
.link-box h1 { margin: 0 0 8px; font-size: 28px; }
.lead { margin: 0 0 6px; font-size: 18px; }
.hint { margin: 0 0 24px; color: var(--dim); font-size: 15px; }
#link-form { display: flex; gap: 10px; }
#code { flex: 1; min-width: 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  font-size: 26px; letter-spacing: 6px; text-align: center; }
.primary { padding: 0 20px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; }
.primary:disabled { opacity: 0.5; }
.error { color: var(--warn); min-height: 1.4em; }

/* Main */
header { display: flex; align-items: center; gap: 10px; padding: 14px 0 12px; }
header h1 { flex: 1 0 auto; margin: 0; font-size: 22px; white-space: nowrap; }
/* The TV's name gives way first on a narrow phone. */
header .chip { flex: 0 1 auto; min-width: 0; }
.chip { padding: 6px 12px; border-radius: 16px; background: var(--card); color: var(--dim); font-size: 14px; max-width: 40vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 50%; font-weight: 700; display: grid; place-items: center; flex: none; }
.round { width: 36px; height: 36px; border-radius: 50%; background: var(--card); color: var(--dim); display: grid; place-items: center; flex: none; }
.volume { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.volume button { height: 76px; border-radius: 16px; background: rgba(255,255,255,0.08); font-size: 34px; font-weight: 300;
  display: grid; place-items: center; touch-action: manipulation; }
.volume button:active { background: rgba(255,255,255,0.22); }
/* The remote: a round pad (arrows around OK), then Back, Home and Play/Pause, then the volume. */
.dpad { position: relative; width: 248px; height: 248px; margin: 6px auto 18px; border-radius: 50%; background: rgba(255,255,255,0.06); }
.dpad button { position: absolute; display: grid; place-items: center; touch-action: manipulation; border-radius: 50%; }
.dpad button:active { background: rgba(255,255,255,0.18); }
.dpad .up, .dpad .down { left: 84px; width: 80px; height: 80px; }
.dpad .up { top: 2px; } .dpad .down { bottom: 2px; }
.dpad .left, .dpad .right { top: 84px; width: 80px; height: 80px; }
.dpad .left { left: 2px; } .dpad .right { right: 2px; }
.dpad .ok { left: 79px; top: 79px; width: 90px; height: 90px; background: rgba(255,255,255,0.14); font-size: 20px; font-weight: 700; }
.dpad .ok:active { background: rgba(255,255,255,0.3); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.keys button { height: 56px; border-radius: 16px; background: rgba(255,255,255,0.08); display: grid; place-items: center; touch-action: manipulation; }
.keys button:active { background: rgba(255,255,255,0.22); }
.avatar.emoji { font-size: 21px; font-weight: 400; }
#search-form { display: flex; gap: 8px; position: sticky; top: 0; padding: 4px 0 10px; background: var(--bg); z-index: 2; }
#q { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); font-size: 17px; }
.mic { width: 46px; height: 46px; border-radius: 50%; background: var(--card); display: grid; place-items: center; flex: none; }
.lang { width: 46px; height: 46px; border-radius: 50%; background: var(--card); font-size: 14px; font-weight: 700; flex: none; }
.mic.on { background: #E5484D; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.status { color: var(--dim); font-size: 14px; margin: 2px 0 10px; min-height: 1.2em; }

h2.row { font-size: 17px; margin: 18px 0 8px; }
.item { display: flex; gap: 12px; align-items: center; width: 100%; padding: 8px 0; text-align: left; border-bottom: 1px solid var(--line); }
.item img, .item .noimg { width: 56px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--card); flex: none; }
.item .meta { min-width: 0; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { color: var(--dim); font-size: 14px; }
.dots { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.dot { font-size: 12px; color: var(--dim); display: inline-flex; align-items: center; gap: 4px; }
.dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tile { flex: none; width: 104px; text-align: left; scroll-snap-align: start; }
.tile img, .tile .noimg { width: 104px; height: 156px; border-radius: 8px; object-fit: cover; background: var(--card); display: block; }
.tile span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--dim); margin-top: 5px; }
.hint { color: var(--faint); font-size: 13px; margin: 10px 2px; }
h4.similar { margin: 20px 0 8px; font-size: 15px; }
/* Every state of the similar strip is the same height (see similarHtml): the sheet must not grow under the finger. */
#similar .strip { height: 214px; box-sizing: border-box; }
#similar .tile span { height: 2.6em; }
#similar .strip.none { align-items: center; }
.tile.ghost .noimg { animation: ghost 1.2s ease-in-out infinite alternate; }
@keyframes ghost { from { opacity: 0.5; } to { opacity: 1; } }
.why { color: #F5C26B !important; font-weight: 600; }
.rate { display: flex; gap: 8px; margin: 0 0 12px; }
.thumb { flex: 1; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.07); font-weight: 600; }
.thumb.on { background: var(--text); color: var(--bg); }
.empty { color: var(--dim); padding: 24px 0; text-align: center; }

/* Sheets */
.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--card);
  border-radius: 20px 20px 0 0; padding: 0 0 calc(20px + env(safe-area-inset-bottom)); }
.sheet-card.small { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-card h2 { margin: 0 0 12px; font-size: 18px; }
.close { position: absolute; top: 10px; right: 10px; z-index: 1; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,0.5); }
.hero { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--bg); }
.sheet-inner { padding: 14px 16px 0; }
.sheet-inner h3 { margin: 0 0 4px; font-size: 22px; }
.sheet-inner .sub { color: var(--dim); font-size: 14px; margin-bottom: 10px; }
.sheet-inner p { margin: 0 0 14px; color: rgba(255,255,255,0.85); font-size: 15px; }
.actions { display: grid; gap: 8px; }
.act { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 12px; background: rgba(255,255,255,0.07); font-weight: 600; text-align: left; }
.act .bar { width: 4px; align-self: stretch; border-radius: 2px; }
.act small { margin-left: auto; color: var(--dim); font-weight: 400; }
.act.light { background: var(--text); color: var(--bg); }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px; border-radius: 10px; text-align: left; }
.choice.on { background: rgba(255,255,255,0.08); }
.choice small { color: var(--dim); margin-left: auto; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-weight: 600; transition: 0.2s; z-index: 20;
  max-width: calc(100vw - 32px); text-align: center; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.why { color: rgba(255,255,255,0.85); font-size: 14px; margin-top: 2px; }
.tip { color: var(--faint); font-size: 14px; margin: 22px 4px; text-align: center; }
.spinner { width: 34px; height: 34px; margin: 40px auto; border-radius: 50%; border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* "Quitte bientôt": a warm band, on list items and on posters. */
.leave { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px; background: #C2410C; color: #fff; font-size: 12px; font-weight: 700; }
.tile .pic { position: relative; }
.leave.on { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0 0 8px 8px; text-align: center; font-size: 11px; padding: 3px 2px; }
.leave-note { display: block; color: #FDBA74; font-weight: 700; font-size: 12px; }

/* The cast: one line of names that scrolls sideways. */
.cast { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; height: 54px; box-sizing: border-box; -webkit-overflow-scrolling: touch; }
.person-chip { flex: none; display: flex; flex-direction: column; justify-content: center; padding: 6px 12px; border-radius: 12px; background: rgba(255,255,255,0.08); font-weight: 600; font-size: 14px; text-align: left; white-space: nowrap; }
.person-chip small { color: var(--dim); font-weight: 400; font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.person-chip.ghost { width: 96px; animation: ghost 1.2s ease-in-out infinite alternate; }

/* A person's page. */
.person { padding-top: 18px; padding-bottom: 20px; }
.person-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.portrait { width: 96px; height: 136px; border-radius: 12px; object-fit: cover; flex: none; background: var(--card); }
.portrait.none { display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; background: rgba(255,255,255,0.08); }
.person .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; }
/* The bio: four lines, the rest (and its source) when opened. */
.bio { margin: -4px 0 16px; }
.bio-text { font-size: 15px; line-height: 1.5; color: rgba(255,255,255,0.88); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.bio-text p { margin: 0 0 10px; }
.bio.open .bio-text { display: block; }
.bio-source { display: none; margin: 4px 0 0; font-size: 12px; color: var(--dim); }
.bio.open .bio-source { display: block; }
.bio-more { margin-top: 6px; padding: 0; font-size: 14px; font-weight: 600; color: var(--dim); background: none; }
/* Movies or shows, and the order, over the posters. */
.view-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.view-chip { padding: 6px 12px; border-radius: 16px; background: var(--card); color: var(--dim); font-size: 14px; font-weight: 600; border: 1px solid transparent; }
.view-chip.on { color: #fff; border-color: rgba(255,255,255,0.6); }
.view-gap { width: 6px; }
.person .grid .tile { width: auto; }
.person .grid .tile img, .person .grid .tile .noimg { width: 100%; height: auto; aspect-ratio: 2 / 3; }

/* Trailers: two buttons side by side; playing, the video takes the picture's place. */
.trailer-row { display: flex; gap: 8px; margin: 0 0 12px; }
.trailer-row .act { flex: 1; justify-content: center; }
.hero.video { position: relative; }
.hero.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Alerts: a followed title became included or cheaper. */
.alert-why, .alert-line { color: #86EFAC !important; font-weight: 600; font-size: 14px; margin-top: 2px; }
.follow-note { margin: 6px 2px 0; min-height: 2.6em; }

/* Recovery email */
.email-state { color: var(--dim); font-size: 15px; margin: 4px 2px 14px; }
.email-state strong { color: var(--text); font-weight: 600; }
#email-form { display: flex; flex-direction: column; gap: 10px; }
#email { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
#email-send { min-height: 48px; }
.plain { background: none; border: 0; color: var(--dim); font: inherit; font-size: 14px; padding: 8px 2px; text-decoration: underline; }

/* A person's photos: a wall over their page, then one over the whole screen. */
.pill { margin-top: 2px; padding: 8px 14px; border-radius: 18px; background: rgba(255,255,255,0.1); font-weight: 600; font-size: 14px; }
.photos { position: fixed; inset: 0; z-index: 12; overflow-y: auto; background: var(--bg); padding: 0 12px calc(20px + env(safe-area-inset-bottom)); }
.photos header { display: block; position: sticky; top: 0; z-index: 1; background: var(--bg); padding: calc(16px + env(safe-area-inset-top)) 44px 10px 4px; }
.photos header h2 { margin: 0; font-size: 20px; }
.photos header .sub { margin: 4px 0 0; color: var(--dim); font-size: 13px; }
.photos header .close { top: calc(12px + env(safe-area-inset-top)); right: 0; }
.wall { display: flex; flex-wrap: wrap; gap: 6px; }
.wall button { height: 120px; padding: 0; border-radius: 8px; overflow: hidden; background: var(--card); }
.wall img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Keeps the last row from stretching its few photos across the whole width. */
.wall i { flex-grow: 10; }
.viewer { position: fixed; inset: 0; z-index: 14; background: #000; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 64px; font-size: 32px; color: rgba(255,255,255,0.8); background: rgba(0,0,0,0.3); border-radius: 10px; }
.viewer .prev { left: 6px; } .viewer .next { right: 6px; }
.viewer p { position: absolute; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); margin: 0; text-align: center;
  font-size: 12px; color: rgba(255,255,255,0.7); text-shadow: 0 0 6px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Server status */
.server .st-ranges { display: inline-flex; gap: 4px; margin-top: 10px; padding: 3px; border-radius: 12px; background: var(--card); }
.st-ranges button { padding: 6px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--dim); }
.st-ranges button.on { background: rgba(255,255,255,0.12); color: var(--text); }
.server .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.server .dot.good { background: var(--good); } .server .dot.bad { background: var(--bad); }
.st-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 12px; }
.st-tile { padding: 12px; border-radius: 14px; background: var(--card); min-width: 0; }
.st-label { font-size: 12px; color: var(--dim); }
.st-value { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-sub { font-size: 12px; color: var(--dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); margin-top: 8px; overflow: hidden; }
.st-bar i { display: block; height: 100%; border-radius: 2px; background: var(--series-1); }
.st-card { position: relative; padding: 12px 12px 6px; border-radius: 14px; background: var(--card); margin-bottom: 8px; }
.st-card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.st-chart { position: relative; }
.st-chart svg { display: block; touch-action: pan-y; overflow: visible; }
.st-grid { stroke: rgba(255,255,255,0.08); stroke-width: 1; }
.st-axis { fill: var(--faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.st-cross line { stroke: rgba(255,255,255,0.4); stroke-width: 1; }
.st-cross circle { stroke: var(--card); stroke-width: 2; }
.st-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.st-legend i, .st-tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
.st-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.st-tip { position: absolute; top: -6px; padding: 6px 9px; border-radius: 9px; background: #222a3a; font-size: 12px; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4); white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-tip-t { color: var(--dim); margin-bottom: 2px; }
.st-h { font-size: 16px; margin: 20px 0 8px; }
.st-list { display: grid; gap: 6px; }
.st-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--card); }
.st-main { display: flex; flex-direction: column; min-width: 0; }
.st-main b { font-size: 14px; }
.st-main small { font-size: 12px; color: var(--dim); }
.st-main small.err { color: var(--warn); overflow-wrap: anywhere; }
.st-badge { flex: none; width: 92px; font-size: 12px; font-weight: 600; padding-top: 1px; }
.st-badge.good { color: var(--good); } .st-badge.bad { color: var(--bad); } .st-badge.run { color: var(--busy); } .st-badge.idle { color: var(--faint); }
.st-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.st-counts div { display: flex; flex-direction: column; padding: 9px 12px; border-radius: 12px; background: var(--card); min-width: 0; }
.st-counts span { font-size: 12px; color: var(--dim); }
.st-counts b { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.st-counts.host { grid-template-columns: 1fr; }
.st-counts.host div { flex-direction: row; justify-content: space-between; gap: 12px; }
.st-counts.host b { text-align: right; font-size: 13px; font-weight: 500; }
.st-paths { display: grid; gap: 4px; }
.st-path { position: relative; display: flex; align-items: baseline; gap: 10px; padding: 7px 10px; border-radius: 9px; background: var(--card); overflow: hidden; font-size: 13px; }
.st-path span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-path b { font-variant-numeric: tabular-nums; }
.st-path small { width: 56px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.st-path i { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--series-1); opacity: 0.7; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
