/* ------------------------------------------------------------------
   Robinson Cinemas theme.
   Every colour and metric is a variable, so restyling the whole app is
   a matter of editing this block.
   ------------------------------------------------------------------ */
:root {
  --bg:            #0c0d10;
  --bg-elevated:   #15171c;
  --bg-hover:      #1e2128;
  --border:        #262a33;
  --text:          #e9ecf1;
  --text-dim:      #9aa3b2;
  --text-faint:    #656d7d;
  --accent:        #f5c518;
  --accent-text:   #17181c;
  --danger:        #ff6b6b;

  --radius:        10px;
  --radius-lg:     16px;
  --gap:           18px;
  --card-min:      210px;
  --topbar-h:      64px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { padding-top: var(--topbar-h); }

a { color: inherit; }

/* ------------------------------ top bar ------------------------------ */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  /*
   * More transparent and more blurred than before, so the library scrolling
   * underneath is suggested rather than hidden behind a solid strip. The hard
   * 1px border is replaced by a soft fade: a visible line across the top is the
   * single most dated thing about a dark interface.
   */
  background: rgba(12, 13, 16, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

/* Backdrop blur is not universal; without it the bar would be see-through and
   the text unreadable over a scrolling grid. */
@supports not (backdrop-filter: blur(1px)) {
  .topbar { background: rgba(12, 13, 16, 0.97); }
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { color: var(--accent); }

.search-wrap { flex: 1; max-width: 520px; position: relative; }

.search {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search:focus { border-color: var(--accent); background: var(--bg-hover); }
.search::placeholder { color: var(--text-faint); }

.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  line-height: 0;
}

/*
 * type="search" renders a clear button on desktop browsers but not on Android,
 * where emptying the field otherwise means holding backspace. Drawn here so it
 * exists everywhere, and the native one is suppressed to avoid two of them.
 */
.search::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.search-clear:hover { background: var(--bg-hover); color: var(--text); }
.search-clear[hidden] { display: none; }
.search-wrap:has(.search-clear:not([hidden])) .search { padding-right: 40px; }

.spacer { flex: 1; }

select.control, button.control {
  height: 40px;
  padding: 0 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
select.control:hover, button.control:hover { background: var(--bg-hover); }

/* --------------------------- update button --------------------------- */

.update-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.update-btn:hover { background: rgba(245, 197, 24, 0.12); }
.update-btn[hidden] { display: none; }

/* Small pulsing dot so the button reads as "something is waiting for you". */
.update-btn::after {
  content: "";
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.update-btn.busy::after { display: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.8); }
}

/* ----------------------------- changelog ----------------------------- */

.version-pill {
  display: inline-block;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
}
.version-pill.new { background: rgba(245, 197, 24, 0.14); border-color: var(--accent); color: var(--accent); }

.version-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.version-row .arrow { color: var(--text-faint); }

.changelog {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}
.changelog h3 { font-size: 14px; margin: 14px 0 6px; }
.changelog h3:first-child { margin-top: 0; }
.changelog ul { margin: 6px 0; padding-left: 20px; }
.changelog li { margin-bottom: 4px; }
.changelog p { margin: 0 0 10px; }
.changelog p:last-child { margin-bottom: 0; }
.changelog code {
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}
.changelog .muted { color: var(--text-faint); font-style: italic; }

.update-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ settings ----------------------------- */

.settings-group {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 26px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-group:first-of-type { margin-top: 20px; }

.field .hint {
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 6px 0 0;
}

.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.field select { height: 44px; }
.field textarea { resize: vertical; min-height: 88px; line-height: 1.5; }

.field select,
.field textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.14);
}

/*
 * Switches rather than checkboxes.
 *
 * row-reverse with space-between puts the control on the right and lets the
 * label fill the space to its left, which is how a settings list reads: the
 * thing you are looking for on the left, its state on the right, all the states
 * in one scannable column. It does that without touching any markup - the input
 * stays first in the DOM, so the label still wraps it and clicking the text
 * still toggles it.
 */
/*
 * .field.checkbox-field, not .checkbox-field: `.field label { display: block }`
 * lives further down this file with identical specificity, so source order
 * decided the winner and the switches silently laid out as blocks. Raising the
 * specificity settles it wherever either rule moves to.
 */
.field.checkbox-field label {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--text);
  font-size: 14.5px;
  cursor: pointer;
  min-height: 28px;
  margin-bottom: 0;
}

.checkbox-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 40px;
  height: 23px;
  margin: 0;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.checkbox-field input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-faint);
  transform: translateY(-50%);
  transition: transform 0.16s ease, background 0.16s ease;
}
.checkbox-field input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-field input[type="checkbox"]:checked::after {
  transform: translateY(-50%) translateX(17px);
  background: var(--accent-text);
}
.checkbox-field input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.3);
}
.checkbox-field input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* The explanation belongs under the whole row, not indented beneath the text,
   so the switches stay in one unbroken column down the right. */
.checkbox-field .hint { margin-top: 6px; }

/* Marks a setting that only takes effect after a restart, so the difference
   is visible while editing rather than a surprise afterwards. */
.restart-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.settings-detail {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-dim);
}
.settings-detail summary { cursor: pointer; color: var(--text-dim); }
.settings-detail ul { margin: 12px 0 0; padding-left: 20px; }
.settings-detail code {
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* The QR sits on white regardless of theme; scanners want the quiet zone light. */
.qr-box {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.qr-box svg {
  width: min(260px, 70vw);
  height: auto;
  border-radius: 6px;
}
.setup-key {
  display: inline-block;
  background: var(--bg-hover);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 15px;
  letter-spacing: 1.5px;
  word-break: break-all;
}

.backup-codes {
  list-style: none;
  margin: 14px 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.backup-codes code {
  display: block;
  background: var(--bg-hover);
  padding: 8px 10px;
  border-radius: 4px;
  text-align: center;
  letter-spacing: 1px;
}

.person-list { list-style: none; margin: 0 0 18px; padding: 0; }
.person-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.person { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.person-list .btn { padding: 5px 12px; font-size: 13px; }

/* Wraps rather than squeezing: three actions plus a long username does not fit
   on a phone, and shrinking them would put Delete under a fingertip. */
.person-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Upload progress. Deliberately chunky: this is the one thing on the screen
   that can run for an hour, and it has to be readable from across a room. */
.upload-bar {
  height: 10px;
  margin: 14px 0 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.upload-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s linear;
}
#upload-status .sub { font-variant-numeric: tabular-nums; }
#upload-file { width: 100%; font-family: inherit; font-size: 14px; }

.invite-list { list-style: none; margin: 0; padding: 0; }
.invite-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.invite-list li:last-child { border-bottom: 0; }
.invite-list .btn { padding: 5px 12px; font-size: 13px; }
.person-list .sub { margin: 0; font-size: 12.5px; }

.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag.ok { color: #7fd18b; }
.tag.warn { color: #e6b45e; }

/* Controls that only exist on a television. */
.tv-only { display: none !important; }
body.tv-mode .tv-only { display: inline-flex !important; align-items: center; gap: 8px; }

/* ---------------------------- on-screen keyboard ---------------------------- */

.osk-overlay {
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4vh;
}

.osk {
  width: min(1100px, 92vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* What has been typed so far, large enough to read from a sofa. */
.osk-preview {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 54px;
  margin-bottom: 18px;
  padding: 0 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 26px;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}
.osk-caret {
  width: 2px;
  height: 30px;
  background: var(--accent);
  animation: osk-blink 1.1s step-end infinite;
}
@keyframes osk-blink { 50% { opacity: 0; } }

.osk-keys {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 10px;
}

.osk-key {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.osk-key.wide { grid-column: span 2; font-size: 18px; font-weight: 500; }
.osk-key.action { font-size: 17px; font-weight: 500; color: var(--text-dim); }

/* The focus ring has to be unmistakable from across a room. */
.osk-key:focus,
.osk-key:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.28);
}

.ban-list { list-style: none; margin: 0 0 18px; padding: 0; }
.ban-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ban-list code {
  background: var(--bg-hover);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12.5px;
}
/* The address and its button stay together; the explanation gives way first. */
.ban-list .sub { flex: 1 1 200px; margin: 0; font-size: 12.5px; }
.ban-list .btn { padding: 5px 12px; font-size: 13px; }

/* ------------------------------- footer ------------------------------ */

.footer {
  position: fixed;
  inset: auto 0 0 auto;
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-faint);
  pointer-events: none;
}

/* ------------------------------ layout ------------------------------ */

main { padding: 26px 20px 80px; max-width: 1800px; margin: 0 auto; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
}
.section-head h2 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
.section-head .count { color: var(--text-faint); font-size: 14px; }

section { margin-bottom: 40px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: var(--gap);
}

/* A single horizontally-scrolling row, used for "Continue watching". */
.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 260px);
  gap: var(--gap);
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

/* ------------------------------- cards ------------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  /* Cubic rather than ease: the lift settles rather than stopping dead, which
     is most of the difference between "animated" and "responsive". */
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1),
              border-color 0.22s ease,
              box-shadow 0.22s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  border-color: #3a4050;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  outline: none;
}
/* The picture drifts in slightly while the card lifts, so the tile feels like
   an object with depth rather than a rectangle that moved. */
.card .thumb img { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1); }
.card:hover .thumb img, .card:focus-visible .thumb img { transform: scale(1.045); }

/* Keeps white subtitles and bright frames from washing out the badge sitting
   on top of them, without darkening the whole picture. */
.card .thumb::after {
  content: "";
  position: absolute;
  inset: 55% 0 0 0;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .card, .card .thumb img { transition: none; }
  .card:hover, .card:focus-visible { transform: none; }
  .card:hover .thumb img, .card:focus-visible .thumb img { transform: none; }
}
.card:focus-visible { border-color: var(--accent); }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0b0e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .placeholder { color: var(--text-faint); font-size: 30px; }

.badge {
  position: absolute;
  bottom: 8px; right: 8px;
  z-index: 1;
  /* Frosted rather than a solid black box: it sits over a photograph, and
     letting a little of the frame through stops it reading as a sticker. */
  background: rgba(10, 11, 14, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge.warn { background: rgba(255, 107, 107, 0.85); border-color: transparent; }
.badge.convert { color: var(--accent); border-color: rgba(245, 197, 24, 0.4); }

.progress-track {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.progress-track i {
  display: block;
  height: 100%;
  background: var(--accent);
  /* Rounded on the leading edge only, so a part-watched bar reads as a position
     along the film rather than as a floating pill. */
  border-radius: 0 2px 2px 0;
}

.card .meta { padding: 10px 12px 12px; }
.card .meta h3 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  /* Two-line clamp keeps every card the same height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta .sub { font-size: 12px; color: var(--text-dim); }

/* ------------------------------ overlays ----------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 9, 0.88);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay[hidden] { display: none; }

.sheet {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(720px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px 30px 30px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.sheet h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.sheet .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }

.tech {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 18px 0 22px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tech div span { display: block; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.tech div strong { font-size: 14px; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  /* Movement on press, so a click feels answered on a slow connection where
     the result may be a second away. */
  transition: filter 0.15s ease, transform 0.06s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.35);
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }

/*
 * Destructive actions. Outlined rather than filled: a solid red button next to
 * a solid amber one reads as the primary action on the row, and deleting an
 * account should never look like the thing you came here to do.
 */
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn.danger:hover { background: rgba(229, 72, 77, 0.12); filter: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.notice {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffc9c9;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

/* Informational rather than a warning: conversion is expected, not a fault. */
.notice.info {
  background: rgba(245, 197, 24, 0.1);
  border-color: rgba(245, 197, 24, 0.32);
  color: #f2dfa4;
}

/* ------------------------------- player ------------------------------ */

#player-overlay { background: #000; padding: 0; flex-direction: column; }
#player-overlay video { width: 100%; height: 100%; background: #000; }

.player-bar {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 34px;
  /*
   * A three-stop gradient rather than two. A straight fade to transparent has a
   * visible edge where it ends - a faint band across the picture - because the
   * eye finds the discontinuity in the rate of change, not in the colour. The
   * middle stop softens the falloff enough to hide it.
   */
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.45) 45%,
    transparent 100%);
  z-index: 2;
  /*
   * Fades out with the cursor. A title bar sitting over the film for the whole
   * two hours is the thing that makes a web player feel like a web page.
   */
  transition: opacity 0.3s ease;
}
.player-bar h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Set by app.js while a film is playing and the pointer has gone quiet, and by
   TV mode's own idle timer. Either way the chrome gets out of the way. */
body.player-idle #player-overlay .player-bar,
body.cursor-hidden #player-overlay .player-bar {
  opacity: 0;
  pointer-events: none;
}
body.player-idle #player-overlay { cursor: none; }
.icon-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* ------------------------------- states ------------------------------ */

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-dim);
}
.empty h2 { color: var(--text); margin-bottom: 8px; font-size: 20px; }
.empty code {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated), var(--bg-hover), var(--bg-elevated));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------ auth pages --------------------------- */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  padding-top: 24px;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.02em; }
.auth-card p.lede { color: var(--text-dim); font-size: 14px; margin: 0 0 24px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  /* A ring on focus rather than only a colour change: it reads at a glance and
     survives being looked at by somebody who cannot distinguish the two greys. */
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field input:hover:not(:focus) { border-color: var(--text-faint); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.14);
}

.auth-card .btn { width: 100%; }

.error {
  color: var(--danger);
  font-size: 13.5px;
  margin: 0 0 16px;
  line-height: 1.45;
  min-height: 1em;
}

/* ------------------------------ responsive --------------------------- */

/* The overflow menu button: only ever visible on narrow screens. */
.menu-btn { padding: 0 12px; }
.menu-btn svg { display: block; }

/*
 * The panel the top bar's controls move into on narrow screens. It hangs
 * below the bar rather than overlaying the page, so nothing is hidden behind
 * it and it cannot cover the film someone is trying to reach.
 */
.topbar-menu {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  z-index: 49;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(12, 13, 16, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.topbar-menu[hidden] { display: none; }

/* Full width and comfortably tappable once stacked. */
.topbar-menu > .control {
  width: 100%;
  height: 46px;
  justify-content: flex-start;
  font-size: 15px;
}

@media (max-width: 720px) {
  :root { --card-min: 150px; --gap: 12px; }

  /*
   * Nine controls needed 671px on a 390px screen, so everything from the
   * quality selector rightwards - including Settings, and with it the only
   * route to invite links - was clipped off the edge and unreachable. The
   * controls now live in the menu panel, leaving the bar with just the brand,
   * the search field and the menu button.
   */
  .topbar {
    padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
    gap: 10px;
  }
  .brand span.name { display: none; }
  .menu-btn { flex: 0 0 auto; }

  /* Search gets the room the controls were taking. */
  .search-wrap { flex: 1 1 auto; min-width: 0; max-width: none; }

  /*
   * While the field has focus it takes the whole bar: the brand mark and the
   * menu button step aside, which is worth roughly another 60px on a 390px
   * screen. Neither is any use mid-search, and being able to see what you are
   * typing is.
   *
   * Driven by a class rather than :focus-within so it also stays expanded
   * while a search is active but the keyboard has been dismissed - otherwise
   * the field shrinks the moment you look at the results.
   */
  .topbar.searching .brand,
  .topbar.searching .menu-btn { display: none; }

  main { padding: 18px 12px 60px; }
  .sheet { padding: 22px 20px 24px; }

  /* Sheets are full-height on a phone; a centred dialog wastes the screen. */
  .sheet { max-height: 92vh; }
}

/* Wide enough for everything to fit: the menu is never needed. */
@media (min-width: 721px) {
  .menu-btn { display: none !important; }
  .topbar-menu { display: none !important; }
}

/* Living-room screens: bigger tap/focus targets and larger type. */
@media (min-width: 1600px) {
  :root { --card-min: 260px; }
  .card .meta h3 { font-size: 15px; }
}

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

/* ------------------------------ TV mode ------------------------------
   Viewed from a sofa, not a desk: bigger everything, and a focus ring that
   is unmistakable, because on a TV the focus indicator IS the cursor.
   -------------------------------------------------------------------- */

body.tv-mode {
  --card-min: 300px;
  --gap: 26px;
  --topbar-h: 84px;
  font-size: 18px;
  /* TVs frequently overscan; keep content away from the bezel. */
  --safe: 3vmin;
}

body.cursor-hidden { cursor: none; }

body.tv-mode main { padding: calc(26px + var(--safe)) calc(20px + var(--safe)) 90px; }
body.tv-mode .topbar { padding: 0 calc(20px + var(--safe)); gap: 20px; }
body.tv-mode .brand { font-size: 22px; }
body.tv-mode .search { height: 52px; font-size: 18px; }
body.tv-mode select.control,
body.tv-mode button.control { height: 52px; font-size: 17px; padding: 0 18px; }
body.tv-mode .section-head h2 { font-size: 26px; }
body.tv-mode .card .meta h3 { font-size: 18px; }
body.tv-mode .card .meta .sub { font-size: 15px; }
body.tv-mode .row { grid-auto-columns: minmax(340px, 340px); }

/* The focus ring has to read across a room, so it is deliberately loud. */
body.tv-mode .card:focus,
body.tv-mode .card:focus-visible,
body.tv-mode .control:focus,
body.tv-mode .control:focus-visible,
body.tv-mode .btn:focus,
body.tv-mode .btn:focus-visible,
body.tv-mode .icon-btn:focus,
body.tv-mode .icon-btn:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--accent);
}
body.tv-mode .card:focus,
body.tv-mode .card:focus-visible {
  transform: scale(1.04);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  z-index: 1;
}

/* ------------------------------- episodes -------------------------------- */

.overview { color: var(--text-dim); line-height: 1.55; margin: 14px 0 4px; }

.season { margin-top: 22px; }
.season h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.episode-list { display: flex; flex-direction: column; gap: 6px; }

.episode {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.episode:hover { background: var(--bg-hover); }

/* Dimmed rather than hidden: a watched episode is still one you might replay,
   and a season that greys out as you go is how you find your place. */
.episode.watched .ep-text strong { color: var(--text-dim); }

.ep-num {
  flex: none;
  min-width: 30px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ep-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ep-text strong { font-weight: 600; font-size: 15px; }
.ep-text .sub { color: var(--text-dim); font-size: 13px; }
.ep-tick { margin-left: auto; color: var(--accent); font-size: 16px; }

.episode:focus,
.episode:focus-visible { outline: none; border-color: var(--accent); }

body.tv-mode .season h3 { font-size: 19px; }
body.tv-mode .episode { padding: 16px 20px; gap: 20px; }
body.tv-mode .ep-num { font-size: 22px; min-width: 44px; }
body.tv-mode .ep-text strong { font-size: 20px; }
body.tv-mode .ep-text .sub { font-size: 16px; }
body.tv-mode .episode:focus,
body.tv-mode .episode:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.28);
}

/*
 * Signing in from a sofa. The card is read at the same distance as everything
 * else in TV mode, and the focus ring has to be visible on a field as well as
 * on a button - it is the only thing telling you what Enter will open.
 */
body.tv-mode .auth-card { width: min(620px, 100%); padding: 44px 44px 48px; }
body.tv-mode .auth-card h1 { font-size: 34px; }
body.tv-mode .auth-card p.lede { font-size: 18px; margin-bottom: 30px; }
body.tv-mode .auth-card .sub,
body.tv-mode .auth-card .hint { font-size: 15px; }
body.tv-mode .field { margin-bottom: 22px; }
body.tv-mode .field label { font-size: 17px; margin-bottom: 9px; }
/* Text fields only. Without the exclusion this also stretched checkboxes into
   60px slabs, because a checkbox row carries both .field and .checkbox-field. */
body.tv-mode .field input:not([type="checkbox"]) {
  height: 60px;
  font-size: 21px;
  padding: 0 18px;
}
/* Proportionate to the larger type around it, not to a fingertip. */
body.tv-mode .checkbox-field input[type="checkbox"] { width: 54px; height: 31px; }
body.tv-mode .checkbox-field input[type="checkbox"]::after { width: 25px; height: 25px; }
body.tv-mode .checkbox-field input[type="checkbox"]:checked::after {
  transform: translateY(-50%) translateX(23px);
}
body.tv-mode .checkbox-field label { font-size: 19px; }
body.tv-mode .field input:focus,
body.tv-mode .field input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.28);
}
body.tv-mode .error { font-size: 17px; }

body.tv-mode .sheet { width: min(880px, 100%); padding: 36px 40px 40px; }
body.tv-mode .sheet h2 { font-size: 32px; }
body.tv-mode .btn { height: 56px; font-size: 18px; padding: 0 30px; }
body.tv-mode .footer { font-size: 14px; padding: 12px calc(14px + var(--safe)); }

/* Native controls are hard to hit with a D-pad; the arrow keys drive
   playback in TV mode, so the bar is only a status readout. */
body.tv-mode #player-overlay video { cursor: none; }

/* -------------------------------- genres -------------------------------- */

.genre-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 4px; }
.genre-tag {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
}

.genre-edit { margin: 18px 0 6px; }
.genre-edit label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
/* The field takes the space and the button stays its own size, so a long list
   of genres does not squeeze Save down to an unhittable sliver. */
.genre-edit-row { display: flex; gap: 10px; align-items: stretch; }
.genre-edit-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.genre-edit-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.14);
}
.genre-edit-row .btn { flex: none; height: 40px; }
.genre-edit .hint { margin-top: 7px; }

body.tv-mode .genre-edit-row input { height: 52px; font-size: 18px; }
body.tv-mode .genre-tag { font-size: 15px; padding: 4px 14px; }

/* --------------------------- watching together --------------------------- */

/*
 * Sits over the film, bottom left, clear of the transport controls on the right
 * and of the title bar at the top. Frosted rather than solid for the same
 * reason as the badges: it is on top of a picture.
 */
.room-panel {
  position: absolute;
  left: 20px;
  bottom: 84px;
  z-index: 3;
  max-width: min(360px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: rgba(12, 13, 16, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}
@supports not (backdrop-filter: blur(1px)) {
  .room-panel { background: rgba(12, 13, 16, 0.95); }
}

.room-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-label { font-size: 13px; color: var(--text-dim); }

/* The code is read aloud, so it is the largest thing here and spaced to be
   dictated a character at a time. */
.room-code {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.room-head .btn { margin-left: auto; padding: 4px 12px; font-size: 13px; }

.room-panel .sub { font-size: 12.5px; color: var(--text-faint); margin: 6px 0 0; }

.room-members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.room-member {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  font-size: 12.5px;
}

/* The panel fades with the rest of the chrome once the pointer goes quiet, so
   a film is not watched from behind it. */
body.player-idle .room-panel,
body.cursor-hidden .room-panel { opacity: 0; pointer-events: none; }
.room-panel { transition: opacity 0.3s ease; }

body.tv-mode .room-code { font-size: 26px; }
body.tv-mode .room-panel { padding: 18px 22px; bottom: 110px; }

/* The tap that satisfies a phone's autoplay policy. Given real size because it
   is the only way back into the film when a browser refuses to start one. */
.room-blocked { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.room-blocked .btn { width: 100%; }
