/* Screenshelf app. Tokens match marketing/public/index.html. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Light, warm paper. Text colors checked for >= 4.5:1 on --bg and --surface. */
  --bg: #FAF7F2; --surface: #FFFFFF; --surface-2: #F2ECE3; --border: #E6DED2; --border-strong: #D3C7B6;
  --accent: #D62249; --accent-soft: #FDF1F3;
  --gold: #9A6200; --gold-soft: #FFF3D6; --gold-line: #EDCB84;
  --yes: #0B7A50; --yes-fill: #34D399; --on-yes: #06301F; --no: #D62249;
  --text: #1C1917; --muted: #6E655A;
  --on-accent: #FFFFFF; --accent-line: #F3B5C2; --yes-soft: #DDF5EA; --bar-bg: rgba(250, 247, 242, .92);
  --backdrop: rgba(28, 25, 23, .35);
  color-scheme: light dark;
  --font-d: 'Fraunces', Georgia, serif; --font-b: 'DM Sans', sans-serif;
  --r: 10px;
}

/* Dark: warm charcoal, not blue-black. Follows the device setting. Text colors >= 4.5:1 on --bg and --surface. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1B17; --surface: #2A251F; --surface-2: #352F28; --border: #41392F; --border-strong: #5A4E41;
    --accent: #FF7A91; --accent-soft: #3D2429; --accent-line: #6E3440; --on-accent: #2B0B12;
    --gold: #F2BD5C; --gold-soft: #3A2F19; --gold-line: #6E5526;
    --yes: #6FD8AD; --yes-fill: #34D399; --on-yes: #06301F; --yes-soft: #1D3A2D; --no: #FF7A91;
    --text: #F3EDE4; --muted: #B5A997;
    --bar-bg: rgba(31, 27, 23, .92); --backdrop: rgba(0, 0, 0, .5);
  }
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-b); font-size: 1rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }
header.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--bar-bg); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.logo { font-family: var(--font-d); font-weight: 700; font-size: 1.3rem; letter-spacing: -.01em; text-decoration: none; }
.logo span { color: var(--accent); }
h1 { font-family: var(--font-d); font-weight: 600; font-size: clamp(1.7rem, 6.5vw, 2.3rem); letter-spacing: -.01em; line-height: 1.1; }
h2 { font-family: var(--font-d); font-weight: 600; font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn-danger { color: var(--no); }

input[type=text], input[type=email], input[type=password], input[type=search], textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); outline: none; font-size: 16px;
}
input:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.list-card { display: block; text-decoration: none; }
.list-card:hover { border-color: var(--border-strong); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); font-size: .78rem; color: var(--muted); }
.pill.match { background: var(--yes-soft); color: var(--yes); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }

.err { color: var(--no); font-size: .9rem; min-height: 1.2em; }
.toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem; z-index: 50; max-width: calc(100% - 32px);
}

/* tabs */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--surface-2); color: var(--text); }
.tabs .count { font-size: .75rem; margin-left: 4px; opacity: .8; }

/* title rows */
.title-row { display: flex; gap: 12px; align-items: flex-start; }
.poster { width: 64px; aspect-ratio: 2/3; border-radius: 6px; background: var(--surface-2); object-fit: cover; flex: none; }
.poster.lg { width: min(190px, 48vw); max-height: 34dvh; margin: 0 auto; border-radius: 12px; }
div.poster.lg { display: grid; place-items: center; font-family: var(--font-d); font-weight: 600; font-size: 2.6rem; color: var(--muted); }
.meta { font-size: .82rem; color: var(--muted); }
.ratings { display: flex; gap: 10px; font-size: .82rem; margin-top: 4px; }
.ratings b { color: var(--gold); font-weight: 600; }
.tally { font-size: .8rem; color: var(--muted); }
.tally .y { color: var(--yes); }
.tally .n { color: var(--no); }
.vote-toggle { display: flex; gap: 6px; margin-top: 8px; }
.vote-toggle button { min-height: 34px; min-width: 64px; border-radius: 8px; border: 1px solid var(--border); background: transparent; cursor: pointer; font-weight: 600; font-size: .85rem; }
.vote-toggle button[aria-pressed=true].y { background: var(--yes-fill); border-color: var(--yes-fill); color: var(--on-yes); }
.vote-toggle button[aria-pressed=true].n { background: var(--no); border-color: var(--no); color: var(--on-accent); }

/* vote deck */
.deck { position: relative; touch-action: pan-y; user-select: none; }
.deck .vcard { text-align: center; transition: transform .18s ease, opacity .18s ease; }
.deck .vcard.gone-l { transform: translateX(-120%) rotate(-12deg); opacity: 0; }
.deck .vcard.gone-r { transform: translateX(120%) rotate(12deg); opacity: 0; }
.deck .ratings { justify-content: center; }
.deck .plot { font-size: .9rem; color: var(--muted); margin-top: 8px; }
.vote-big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.vote-big button { min-height: 60px; border-radius: 14px; font-size: 1.1rem; font-weight: 700; cursor: pointer; border: 0; }
.vote-big .n { background: var(--accent-soft); color: var(--no); border: 1px solid var(--accent-line); }
.vote-big .y { background: var(--yes-fill); color: var(--on-yes); }

/* search */
.results { max-height: 60vh; overflow: auto; }
.results button { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--border); padding: 10px 0; cursor: pointer; }
.results button:last-child { border-bottom: 0; }

/* sheet */
dialog { margin: auto auto 0; width: 100%; max-width: 640px; max-height: 88dvh; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 18px 18px 0 0; background: var(--bg); color: var(--text); padding: 20px 16px 28px; }
dialog::backdrop { background: var(--backdrop); }
@media (min-width: 700px) { dialog { margin: auto; border-radius: 18px; border-bottom: 1px solid var(--border); } }

.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.mt8 { margin-top: 8px; }

/* quiz */
.progress { height: 3px; background: var(--border); position: sticky; top: 57px; z-index: 9; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.rank { display: inline-block; font-weight: 700; letter-spacing: .02em; color: var(--gold); font-size: .95rem; margin-bottom: 8px; }
.quiz-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.qbtn { min-height: 58px; border-radius: 14px; font-size: 1.02rem; font-weight: 700; cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.qbtn.seen { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.qbtn.want { background: var(--yes-fill); border-color: var(--yes-fill); color: var(--on-yes); }
.qbtn.skip { grid-column: 1 / -1; min-height: 44px; font-size: .92rem; color: var(--muted); background: transparent; }
.qbtn[aria-pressed=true] { outline: 2px solid var(--text); outline-offset: 2px; }
.qchip { display: inline-block; flex: none; white-space: nowrap; min-width: 150px; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); font-weight: 600; }
.qchip.seen { color: var(--gold); }
.qchip.want { color: var(--yes); }
.score { font-family: var(--font-d); font-weight: 700; line-height: 1; }
.score #score-n { font-size: 4.2rem; color: var(--gold); }
.score .score-of { font-size: 1.4rem; color: var(--muted); margin-left: 6px; }
.gbar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.gbar > div { height: 100%; background: var(--gold); }
.banner { display: flex; gap: 12px; align-items: center; }
.banner .big { font-size: 1.8rem; }
.seen-by { font-size: .8rem; color: var(--gold); margin-top: 2px; }

/* up next (T21) */
.upnext-row { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 10px 0 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.upnext { flex: 0 0 min(300px, 82vw); scroll-snap-align: start; display: flex; gap: 12px; align-items: stretch; }
.upnext .poster { width: 56px; }
.upnext .ep { font-weight: 600; margin-top: 2px; }
.upnext .epname { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upnext .by { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.upnext .info { flex: 1; min-width: 0; cursor: pointer; background: none; border: 0; text-align: left; padding: 0; }
.upnext .info h3 { font-family: var(--font-d); font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-watched { background: var(--yes-fill); border-color: var(--yes-fill); color: var(--on-yes); min-height: 38px; font-size: .9rem; margin-top: 8px; }
.pill.watching { background: var(--gold-soft); color: var(--gold); }
select { min-height: 40px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; }
.ep-list { max-height: 50dvh; overflow: auto; border: 1px solid var(--border); border-radius: var(--r); }
.ep-list button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; background: var(--surface); border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.ep-list button:last-child { border-bottom: 0; }
.ep-list button[aria-current=true] { background: var(--gold-soft); }
.ep-list .n { color: var(--muted); min-width: 2.2em; }
.toast button { margin-left: 10px; background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
