/* Remote: each family member is a colored key, like the red/green/yellow/blue buttons on a TV remote. */

:root {
  --bg: #EDEFF3;
  --surface: #FFFFFF;
  --sunk: #E2E5EC;
  --ink: #1A1D2B;
  --muted: #5B6176;
  --line: #D3D7E0;
  --danger: #C62F3A;
  --star: #D99A00;
  --me: #3E7BFA;
  --on-me: #FFFFFF;
  --r-sm: 6px;
  --r: 14px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141C;
    --surface: #1B1E29;
    --sunk: #252938;
    --ink: #ECEEF4;
    --muted: #989EB1;
    --line: #2D3243;
    --danger: #FF6B73;
    --star: #F2C230;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
p { margin: 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 30vh 24px; text-align: center; color: var(--muted); }

/* ---------- keys ---------- */
.key {
  --k: var(--me);
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 26px;
  border-radius: 999px;
  background: var(--k);
  font: 700 13px/1 var(--font);
  font-stretch: 112%;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .22), inset 0 1px 0 rgb(255 255 255 / .35);
}
.key.sm { width: 24px; height: 18px; font-size: 10px; box-shadow: inset 0 -2px 0 rgb(0 0 0 / .22); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--k); flex: none; }

.logo { display: grid; grid-template-columns: repeat(2, 30px); gap: 6px; }
.logo span {
  height: 22px;
  border-radius: 999px;
  background: var(--k);
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .22), inset 0 1px 0 rgb(255 255 255 / .35);
  animation: press .5s ease both;
}
.logo span:nth-child(2) { animation-delay: .12s; }
.logo span:nth-child(3) { animation-delay: .24s; }
.logo span:nth-child(4) { animation-delay: .36s; }
@keyframes press {
  0%, 100% { transform: none; }
  45% { transform: translateY(3px); box-shadow: inset 0 -1px 0 rgb(0 0 0 / .22); }
}
.logo.mini { grid-template-columns: repeat(2, 11px); gap: 3px; }
.logo.mini span { height: 8px; animation: none; box-shadow: none; }

/* ---------- shell ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
}
.top-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 20px/1 var(--font); font-stretch: 125%; }
.keys { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.keys a { text-decoration: none; border-radius: 999px; }

.main { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom, 0px)); }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs-in { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 760px; margin: 0 auto; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] svg { color: var(--me); }

/* ---------- type ---------- */
.h { font: 800 clamp(30px, 8vw, 42px)/1.02 var(--font); font-stretch: 125%; letter-spacing: -.01em; margin: 18px 0 18px; }
.h2 { font: 700 15px/1.3 var(--font); font-stretch: 110%; color: var(--muted); margin: 30px 0 10px; }
.note { color: var(--muted); font-size: 15px; margin: 8px 0; }
.headrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.headrow .h { margin-right: auto; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 15px/1 var(--font); font-stretch: 105%;
  padding: 13px 20px;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: progress; }
.link {
  background: none; border: none; padding: 0;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  text-align: left;
}
.link.danger { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input, textarea {
  width: 100%;
  font: 400 16px/1.4 var(--font);
  padding: 11px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, textarea:focus { outline: none; border-color: var(--me); }
textarea { resize: vertical; }

.pill {
  font: 600 14px/1 var(--font);
  padding: 10px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.pill.on { background: var(--me); border-color: var(--me); color: var(--on-me); }
.pill.ghost { background: transparent; color: var(--muted); }

.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 3px; }
.seg a { padding: 7px 15px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); }

/* the watched check */
.check {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  color: transparent;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background-color .18s, border-color .18s, transform .18s;
}
.check svg { width: 20px; height: 20px; }
.check:hover:not(:disabled) { border-color: var(--me); }
.check.done { background: var(--me); border-color: var(--me); color: var(--on-me); transform: scale(1.05); }
.check:disabled:not(.done) { opacity: .3; cursor: not-allowed; }
.check.sm { width: 34px; height: 34px; }
.check.sm svg { width: 15px; height: 15px; }

/* ---------- lists ---------- */
.list { background: var(--surface); border-radius: var(--r); }
.row { display: flex; gap: 14px; align-items: center; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.thumb { flex: none; width: 58px; aspect-ratio: 2 / 3; border-radius: var(--r-sm); overflow: hidden; background: var(--sunk); display: block; }
.thumb.sm { width: 42px; }
.thumb img, .pcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { width: 100%; height: 100%; background: var(--sunk); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-stretch: 108%; text-decoration: none; }
.row-ep { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 4px; }
.row-meta { color: var(--muted); font-size: 14px; }
.fam { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 7px; font-size: 13px; color: var(--muted); }
.who { display: inline-flex; align-items: center; gap: 6px; }
.who.ahead { color: var(--ink); font-weight: 600; }

.empty { padding: 36px 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 46ch; }
.empty h2 { font: 800 24px/1.15 var(--font); font-stretch: 118%; margin: 0; }
.empty p { color: var(--muted); }

.error-block { background: var(--surface); border-left: 4px solid var(--danger); padding: 14px 16px; border-radius: var(--r-sm); margin: 20px 0; }

/* ---------- search ---------- */
.searchbox input {
  width: 100%;
  font: 500 18px/1 var(--font);
  padding: 15px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.searchbox input:focus { outline: none; border-color: var(--me); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 20px 12px; margin-top: 8px; }
.card { text-decoration: none; display: flex; flex-direction: column; gap: 3px; }
.pcard { position: relative; aspect-ratio: 2 / 3; border-radius: var(--r-sm); overflow: hidden; background: var(--sunk); margin-bottom: 4px; }
.badge { position: absolute; left: 6px; bottom: 6px; background: var(--me); color: var(--on-me); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.card-title { font-weight: 600; font-size: 14px; line-height: 1.25; }
.card-meta { font-size: 12px; color: var(--muted); }

/* ---------- title page ---------- */
.hero { margin: 0 -16px; }
.backdrop { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; display: block; -webkit-mask-image: linear-gradient(#000 35%, transparent); mask-image: linear-gradient(#000 35%, transparent); }
.hero-in { display: flex; gap: 16px; align-items: flex-end; padding: 0 16px; margin-top: -72px; position: relative; }
.hero.plain .hero-in { margin-top: 18px; }
.hero-poster { flex: none; width: 104px; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--sunk); box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.hero-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.title { font: 800 clamp(26px, 6.5vw, 40px)/1.03 var(--font); font-stretch: 118%; margin: 0; letter-spacing: -.01em; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 14px; margin-top: 8px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 18px; }
.providers { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.providers img { width: 34px; height: 34px; border-radius: 8px; display: block; }
.overview { max-width: 64ch; line-height: 1.6; }

.prog-list { background: var(--surface); border-radius: var(--r); padding: 4px 14px; }
.prog { display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.prog + .prog { border-top: 1px solid var(--line); }
.prog-main { flex: 1; min-width: 0; }
.prog-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.prog-top span { color: var(--muted); }
.bar { height: 6px; background: var(--sunk); border-radius: 999px; margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--k); border-radius: 999px; }

.seasons { margin-top: 8px; }
.season { border-top: 1px solid var(--line); }
.season:last-child { border-bottom: 1px solid var(--line); }
.season-head {
  width: 100%;
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 16px 2px; background: none; border: none; cursor: pointer; text-align: left;
}
.season-name { font-weight: 700; font-stretch: 110%; font-size: 17px; }
.season-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.minibar { grid-column: 1 / -1; height: 4px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.minibar i { display: block; height: 100%; background: var(--me); }
.season-actions { display: flex; justify-content: flex-end; padding: 0 2px 6px; font-size: 14px; }
.eps { list-style: none; margin: 0; padding: 0 0 14px; }
.ep-line { display: flex; align-items: center; gap: 10px; }
.ep-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 0; background: none; border: none; cursor: pointer; text-align: left; }
.ep-num { width: 22px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.ep-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-side { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; flex: none; }
.ep-date { margin-left: 4px; white-space: nowrap; }
.is-watched .ep-name { color: var(--muted); }
.ep-detail { margin: 2px 0 14px 44px; padding: 14px; background: var(--surface); border-radius: var(--r); display: flex; flex-direction: column; gap: 12px; }
.still { width: 100%; max-width: 420px; border-radius: var(--r-sm); display: block; }

/* reactions */
.rx { display: flex; flex-direction: column; gap: 10px; }
.rx-item { display: flex; gap: 10px; align-items: flex-start; }
.rx-item p { line-height: 1.45; }
.rx-head { display: flex; gap: 8px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.rx-stars { color: var(--star); letter-spacing: 1px; }
.rx-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; }
.emo { font-size: 22px; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: transparent; cursor: pointer; }
.emo.on { border-color: var(--me); background: var(--sunk); }
.stars { display: flex; }
.star { font-size: 26px; line-height: 1; background: none; border: none; color: var(--line); cursor: pointer; padding: 4px; }
.star.on { color: var(--star); }
.rx-actions { display: flex; gap: 16px; align-items: center; }

/* ---------- calendar / family ---------- */
.day + .day { margin-top: 4px; }
.members .row { align-items: center; }
.invite { background: var(--surface); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.code-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.code-big { font: 800 26px/1 var(--font); font-stretch: 125%; letter-spacing: .08em; padding: 10px 14px; border-radius: 10px; background: var(--sunk); user-select: all; }
.activity .row { font-size: 15px; }
.activity time { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- auth / onboarding / settings ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 56px) 20px 48px; display: flex; flex-direction: column; gap: 26px; }
.auth h1 { font: 800 48px/1 var(--font); font-stretch: 125%; margin: 18px 0 8px; letter-spacing: -.01em; }
.auth .lede { color: var(--muted); font-size: 17px; }
.panel { background: var(--surface); padding: 20px; border-radius: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 0; font: 800 20px/1.2 var(--font); font-stretch: 115%; }
.form-msg { font-size: 14px; color: var(--danger); min-height: 1em; }
.form-msg.ok { color: var(--muted); }
.switch { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); font-size: 15px; }

.settings { display: flex; flex-direction: column; gap: 18px; max-width: 460px; }
.colors { border: none; padding: 0; margin: 0; display: flex; gap: 12px; flex-wrap: wrap; }
.colors legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch .face { display: block; width: 50px; height: 34px; border-radius: 999px; background: var(--k); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .22), inset 0 1px 0 rgb(255 255 255 / .35); }
.swatch input:checked + .face { outline: 3px solid var(--ink); outline-offset: 3px; }
.swatch input:focus-visible + .face { outline: 3px solid var(--me); outline-offset: 3px; }
hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; width: 100%; }
.credit { font-size: 13px; color: var(--muted); max-width: 60ch; }

/* ---------- skeleton & toast ---------- */
.sk { background: var(--sunk); border-radius: 8px; }
.sk-row { display: flex; gap: 14px; padding: 12px 14px; align-items: center; }
.sk-row .sk:first-child { width: 58px; aspect-ratio: 2 / 3; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-lines .sk { height: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px);
  opacity: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 20;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* focus last so it wins */
:focus-visible { outline: 2.5px solid var(--me); outline-offset: 2px; }
.searchbox input:focus-visible, .field input:focus-visible, textarea:focus-visible { outline: none; }

@media (min-width: 640px) {
  .hero-poster { width: 140px; }
  .hero-in { margin-top: -100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
