:root {
  --bg: #0e1013;
  --panel: #171a1f;
  --panel-2: #1f242b;
  --line: #2a3038;
  --ink: #e8eaed;
  --muted: #9aa3ae;
  --accent: #e0a44c;
  --danger: #e2706a;
  --radius: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f2; --panel: #fff; --panel-2: #efeeea; --line: #dfddd6;
    --ink: #1c1d1f; --muted: #6b7280; --accent: #b3701a;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 8px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; max-width: 60ch; }

button, input, select {
  font: inherit; color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}
button { cursor: pointer; }
button.ghost { background: transparent; border-color: transparent; font-size: 17px; padding: 6px 10px; }
button.ghost.on, button.ghost:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- gate ------ */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(380px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.gate-card h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.gate-card p { margin: 0; }
.gate-card input { width: 100%; }
.gate-card button[type=submit] { background: var(--accent); color: #12140f; border-color: transparent; font-weight: 600; }

/* ----------------------------------------------------------- topbar ------ */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0); z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.tabs button { background: transparent; border-color: transparent; white-space: nowrap; }
.tabs button.active { background: var(--panel-2); border-color: var(--line); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip {
  font-size: 13px; padding: 6px 11px; white-space: nowrap;
  border-radius: 999px; color: var(--muted);
}
.chip.on { color: var(--accent); border-color: var(--accent); }
.topbar-right input { width: min(220px, 40vw); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 0; }

/* -------------------------------------------------------- home shelves --- */
.home { padding: 18px 0 8px; }
.shelf { margin: 0 0 26px; }
.shelf-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 16px 9px;
}
.shelf-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.shelf-note { color: var(--muted); font-size: 13px; }
.shelf-more {
  margin-left: auto; background: transparent; border-color: transparent;
  color: var(--muted); font-size: 13px; padding: 4px 8px;
}
.shelf-more:hover { color: var(--accent); }
#shelf-favorites .hint { padding: 0 16px; }

/* Horizontal shelf. Cards keep a fixed width so the row scrolls rather than
   squashing, and snap so it never rests mid-tile. */
.rail {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  padding: 2px 16px 6px; scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.rail .card { flex: 0 0 168px; scroll-snap-align: start; }

/* ------------------------------------------------------------- grid ------ */
.grid {
  display: grid; gap: 12px; padding: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

/* -------------------------------------------------------------- card ----- */
.card {
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: left; transition: border-color .12s, transform .12s;
}
.card:hover, .card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.art {
  position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center;
  background: var(--panel-2); color: var(--muted);
  font-size: 22px; font-weight: 700; letter-spacing: .04em;
}
.art img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.meta { display: flex; flex-direction: column; gap: 2px; padding: 9px 11px 11px; min-width: 0; }
.meta .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* One-tap star, always reachable without opening the player. Sits above the
   art, sized for thumbs (36px) rather than mouse pointers. */
.star {
  position: absolute; top: 5px; right: 5px;
  width: 36px; height: 36px; padding: 0; line-height: 1;
  display: grid; place-items: center;
  font-size: 17px; border: none; border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  color: var(--muted);
  backdrop-filter: blur(3px);
  opacity: .75; transition: opacity .12s, color .12s, transform .12s;
}
.card:hover .star, .card:focus-within .star { opacity: 1; }
.star:hover { transform: scale(1.12); color: var(--accent); }
.star.on { color: var(--accent); opacity: 1; }
@media (hover: none) { .star { opacity: 1; } }

/* How far into a film you got, drawn along the bottom of its tile. */
.progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.progress i { display: block; height: 100%; background: var(--accent); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ----------------------------------------------------------- player ------ */
.player {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.player-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px 16px; }
.player-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.player-head h2 { margin: 0; font-size: 17px; }
.player-head p { margin: 2px 0 0; font-size: 13px; }
.player-actions { display: flex; gap: 2px; flex-shrink: 0; }
/* Capped so the player never swallows the page — a sticky bottom player is
   only useful if you can still see and browse the shelves above it. */
#video {
  width: 100%; aspect-ratio: 16 / 9; max-height: 38vh; margin-top: 10px;
  background: #000; border-radius: var(--radius); object-fit: contain;
}
/* Audio-only sources don't need a big black rectangle. */
.player.audio #video { max-height: 88px; }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; padding: 12px; }
  .rail .card { flex-basis: 136px; }
  .rail, .shelf-head { padding-left: 12px; padding-right: 12px; }
  .topbar-right input { width: 130px; }
}
