/* Layout: one-screen app. Phone = poster card stacked over the vote buttons;
   desktop = horizontal card plus a sidebar showing the two people's overlap. */
:root {
  --bg: #f1eff5;
  --surface: #ffffff;
  --sunk: #e7e3ee;
  --ink: #1d1a24;
  --muted: #696377;
  --line: #dbd6e3;
  --a: #2f68e0;
  --b: #e04f7b;
  --both: #8a4cd8;
  --a-soft: #2f68e01f;
  --b-soft: #e04f7b1f;
  --both-soft: #8a4cd81f;
  --shadow: 0 1px 2px #1d1a2414, 0 12px 32px -12px #1d1a2440;
  --scrim: #1d1a248c;

  --f-title: "Noto Serif SC", "Songti SC", "STSong", serif;
  --f-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --f-en: "Newsreader", Georgia, "Times New Roman", serif;
  --f-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121a; --surface: #1f1c27; --sunk: #2a2634; --ink: #f0edf5; --muted: #a59eb4; --line: #353040;
    --a: #6d9bff; --b: #ff7ca1; --both: #b48cff;
    --a-soft: #6d9bff26; --b-soft: #ff7ca126; --both-soft: #b48cff26;
    --shadow: 0 1px 2px #00000040, 0 16px 40px -12px #000000a0; --scrim: #000000a6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14121a; --surface: #1f1c27; --sunk: #2a2634; --ink: #f0edf5; --muted: #a59eb4; --line: #353040;
  --a: #6d9bff; --b: #ff7ca1; --both: #b48cff;
  --a-soft: #6d9bff26; --b-soft: #ff7ca126; --both-soft: #b48cff26;
  --shadow: 0 1px 2px #00000040, 0 16px 40px -12px #000000a0; --scrim: #000000a6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--both); outline-offset: 2px; border-radius: 8px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); max-width: 1200px; margin: 0 auto; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding-block: 12px 4px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand svg { flex: none; }
.brand b { font-family: var(--f-title); font-weight: 900; font-size: 19px; letter-spacing: .02em; white-space: nowrap; }
.brand small { font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 3px; }
.seg button { padding: 4px 12px; border-radius: 999px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"][data-p="a"] { background: var(--a); color: #fff; }
.seg button[aria-pressed="true"][data-p="b"] { background: var(--b); color: #fff; }
.results-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--both-soft); color: var(--both); font-weight: 700; font-size: 13px; white-space: nowrap; }
.results-btn .mono { font-weight: 500; }

/* ---------- main ---------- */
.main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; min-height: 0; }
.stage { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding-block: 8px 12px; }
.ticket { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); gap: 12px; }
.ticket .bar { flex: 1; height: 4px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.ticket .bar i { display: block; height: 100%; background: var(--active); border-radius: 4px; transition: width .3s; }

.card-slot { flex: 1; min-height: 0; position: relative; }
.card {
  position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--surface);
  border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); touch-action: none; user-select: none;
  -webkit-user-select: none; transform-origin: 50% 90%; animation: enter .28s ease-out;
}
@keyframes enter { from { transform: scale(.96); opacity: .4; } }
.card.fly { transition: transform .32s ease-in, opacity .32s ease-in; }
.card.dragging { cursor: grabbing; }

.poster-wrap { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; container-type: size; display: grid; place-items: center; background: var(--sunk); }
.poster-wrap .blur { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(1.3); opacity: .55; }
.poster {
  position: relative; display: block; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; box-shadow: 0 10px 30px -8px #00000080;
  width: min(calc(100cqw - 32px), calc((100cqh - 32px) * 2 / 3)); max-width: 100%; height: auto; pointer-events: none;
}
.reason { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; background: var(--surface); font-size: 12px; font-weight: 500; box-shadow: 0 2px 8px #0000002a; max-width: calc(100% - 24px); }
.reason i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; }
.stamp { position: absolute; top: 28%; padding: 6px 14px; border: 3px solid currentColor; border-radius: 10px; font-weight: 700; font-size: 24px; letter-spacing: .08em; opacity: 0; pointer-events: none; background: var(--surface); }
.stamp.love { left: 20px; transform: rotate(-12deg); color: var(--active); }
.stamp.no { right: 20px; transform: rotate(12deg); color: var(--muted); }
.stamp.meh { left: 50%; top: 14%; transform: translateX(-50%); color: var(--muted); }

.info { flex: none; padding: 14px 18px 16px; display: grid; gap: 8px; }
.title-row { display: flex; align-items: flex-start; gap: 12px; }
.title-row > div { min-width: 0; flex: 1; }
.zh { font-family: var(--f-title); font-weight: 900; font-size: clamp(21px, 5.6vw, 28px); line-height: 1.2; text-wrap: balance; margin: 0; }
.en { font-family: var(--f-en); font-style: italic; font-size: 16px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.en .mono { font-style: normal; font-size: 12px; margin-left: 6px; letter-spacing: .02em; }
.genres { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.genres span + span::before { content: "·"; margin-right: 6px; }
.seen { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 9px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.seen .box { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid currentColor; display: grid; place-items: center; }
.seen[aria-pressed="true"] { border-color: var(--active); color: var(--active); background: var(--active-soft); }
.seen[aria-pressed="true"] .box { background: var(--active); border-color: var(--active); }
.seen[aria-pressed="true"] .box::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--surface); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

.people { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding-top: 2px; }
.people::-webkit-scrollbar { display: none; }
.person { display: grid; justify-items: center; gap: 3px; width: 58px; flex: none; text-align: center; }
.person + .person.lead { margin-left: 4px; }
.ava { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--sunk); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.person.director .ava { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--muted); }
.person span { font-size: 11px; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.person em { font-style: normal; font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.divider { width: 1px; background: var(--line); flex: none; margin-block: 4px 18px; }

.controls { display: grid; gap: 6px; justify-items: center; }
.votes { display: flex; align-items: flex-end; justify-content: center; gap: clamp(18px, 7vw, 40px); }
.vote { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.vote .ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); transition: transform .12s; }
.vote:active .ring { transform: scale(.92); }
.vote.love .ring { width: 66px; height: 66px; background: var(--active); color: #fff; }
.vote.love { color: var(--ink); }
.vote svg { width: 24px; height: 24px; }
.vote.love svg { width: 28px; height: 28px; }
.minor { display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.minor button { padding: 4px 2px; }
.minor button:hover { color: var(--ink); }
kbd { display: none; font-family: var(--f-mono); font-size: 10px; padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); margin-left: 4px; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; background: var(--surface); border-radius: 22px; padding: 24px; }
.empty h2 { font-family: var(--f-title); margin: 0; font-size: 22px; }
.empty p { margin: 0; color: var(--muted); }

/* ---------- sidebar (desktop) ---------- */
.side { display: none; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; justify-items: center; background: var(--scrim); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: 100%; max-width: 760px; max-height: calc(100% - 24px - env(safe-area-inset-top, 0px)); overflow-y: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  animation: rise .26s ease-out; display: grid; gap: 22px;
}
@keyframes rise { from { transform: translateY(40px); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; font-family: var(--f-title); font-size: 22px; }
.close { width: 34px; height: 34px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; flex: none; }
.panel h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .12em; color: var(--muted); font-weight: 500; }

.score { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center; background: var(--surface); border-radius: 18px; padding: 18px; }
.score .big { font-family: var(--f-mono); font-size: 46px; line-height: 1; color: var(--both); grid-row: span 2; }
.score .big small { font-size: 20px; }
.score p { margin: 0; color: var(--muted); font-size: 13px; }
.score .stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--sunk); font-size: 13px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 5px; min-width: 0; }
.tile img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--sunk); }
.tile b { font-size: 13px; font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { justify-self: start; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--both-soft); color: var(--both); font-weight: 500; }
.tag.rewatch { background: var(--both-soft); color: var(--both); }
.tag.new { background: var(--sunk); color: var(--ink); }
.tag.rec-a { background: var(--a-soft); color: var(--a); }
.tag.rec-b { background: var(--b-soft); color: var(--b); }
.none { color: var(--muted); font-size: 14px; background: var(--surface); border-radius: 14px; padding: 16px; margin: 0; }

.genre-rows { display: grid; gap: 10px; background: var(--surface); border-radius: 18px; padding: 16px 18px; }
.g-row { display: grid; grid-template-columns: 3.5em 1fr; gap: 4px 12px; align-items: center; font-size: 13px; }
.g-row b { grid-row: span 2; font-weight: 500; }
.g-bar { height: 7px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.g-bar i { display: block; height: 100%; border-radius: 4px; }
.g-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }

.split { display: grid; gap: 8px; }
.split-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; padding: 8px 12px 8px 8px; }
.split-row img { width: 40px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 5px; }
.split-row div { min-width: 0; }
.split-row b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-row small { color: var(--muted); font-size: 12px; }
.verdicts { display: flex; gap: 6px; font-size: 12px; white-space: nowrap; }
.verdicts span { padding: 2px 8px; border-radius: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.btn.primary { background: var(--active); color: #fff; }
.btn.ghost { background: var(--sunk); }
.btn.danger { color: var(--muted); font-weight: 500; }
.btn.danger.armed { color: #fff; background: #c43d3d; }
.note { font-size: 12px; color: var(--muted); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); white-space: nowrap; max-width: calc(100vw - 32px);
}
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } }

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  body { font-size: 15px; }
  .top { padding-block: 18px 6px; }
  .main { grid-template-columns: minmax(0, 1fr) 320px; }
  .stage { padding-block: 10px 22px; gap: 14px; }
  .card { flex-direction: row; }
  .poster-wrap { flex: 0 0 54%; }
  .info { flex: 1; min-width: 0; padding: 32px 30px; align-content: start; gap: 14px; overflow-y: auto; }
  .zh { font-size: 34px; }
  .en { font-size: 19px; }
  .genres { font-size: 13px; }
  .people { flex-wrap: wrap; overflow: visible; row-gap: 14px; }
  .ava { width: 52px; height: 52px; }
  .person { width: 70px; }
  .person span { font-size: 12px; }
  .results-btn.phone { display: none; }
  .side { display: flex; flex-direction: column; gap: 16px; padding-block: 10px 22px; min-height: 0; overflow-y: auto; }
  .side-card { background: var(--surface); border-radius: 18px; padding: 16px 18px; display: grid; gap: 12px; }
  .side-card h3 { margin: 0; font-size: 12px; letter-spacing: .12em; color: var(--muted); font-weight: 500; }
  .prog { display: grid; gap: 8px; font-size: 13px; }
  .prog div { display: grid; grid-template-columns: 5em 1fr auto; gap: 10px; align-items: center; }
  .prog div > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mini-matches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .mini-matches img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; display: block; }
  .sheet { align-items: center; }
  .panel { border-radius: 22px; max-height: calc(100% - 64px); padding: 28px 30px; }
  .toast { bottom: 40px; }
}
@media (hover: hover) and (pointer: fine) { kbd { display: inline-block; } }
@media (max-height: 640px) and (max-width: 959px) {
  .people { display: none; }
  .vote .ring { width: 46px; height: 46px; }
  .vote.love .ring { width: 54px; height: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- landing & seat picker ---------- */
/* body never scrolls (the card app is one screen), so the landing page scrolls itself */
.landing { height: 100%; overflow-y: auto; display: flex; padding-block: 32px; }
.landing-card { width: 100%; max-width: 440px; display: grid; gap: 22px; margin: auto; }
.landing-card .mark { width: 72px; height: 50px; }
.landing-card h1 { font-family: var(--f-title); font-weight: 900; font-size: 34px; margin: 0; line-height: 1.15; }
.landing-card .lede { margin: 0; color: var(--muted); font-size: 15px; }
.form { display: grid; gap: 14px; background: var(--surface); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 12px; width: 100%;
}
.field input:focus { outline: none; border-color: var(--both); }
.field .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1.5px dashed var(--line); border-radius: 12px; padding: 8px 8px 8px 12px; }
.linkbox code { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: 13px; overflow-x: auto; white-space: nowrap; user-select: all; }
.linkbox button { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seat-btn { padding: 18px 12px; border-radius: 18px; color: #fff; font-weight: 700; font-size: 18px; display: grid; gap: 2px; justify-items: center; }
.seat-btn small { font-weight: 500; font-size: 12px; opacity: .85; }
.seat-btn[data-seat="a"] { background: var(--a); }
.seat-btn[data-seat="b"] { background: var(--b); }
.err { color: #c43d3d; font-size: 13px; margin: 0; }
.btn.block { width: 100%; padding: 13px 18px; font-size: 15px; background: var(--ink); color: var(--bg); }
.loading { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---------- identity, recent rooms, room code ---------- */
.me-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--sunk); font-size: 13px; font-weight: 500; white-space: nowrap; }
.me-chip .dot { margin-right: 0; }
.recent { display: grid; gap: 8px; }
.recent h3 { margin: 0; font-size: 13px; letter-spacing: .12em; color: var(--muted); font-weight: 500; }
.recent-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.recent-row span:nth-child(2) { flex: 1; min-width: 0; display: grid; }
.recent-row b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row small { color: var(--muted); font-size: 12px; }
.recent-row .go { color: var(--both); font-weight: 700; font-size: 13px; flex: none; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; }
.join-row .btn { flex: none; }
.room-code { font-size: 20px; letter-spacing: .08em; margin: 0 0 4px; user-select: all; word-break: break-all; }
.tile { position: relative; }
.badge-new { position: absolute; top: 6px; left: 6px; z-index: 1; padding: 1px 7px; border-radius: 6px; background: var(--both); color: #fff; font-size: 11px; font-weight: 700; }

/* ---------- 我的表态 ---------- */
.vote-list { display: grid; gap: 8px; }
.vote-row { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: start; background: var(--surface); border-radius: 14px; padding: 10px 12px 10px 10px; }
.vote-row img { width: 48px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; background: var(--sunk); }
.v-main { min-width: 0; display: grid; gap: 4px; }
.v-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-main small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-status { color: var(--ink); font-weight: 500; }
.v-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.v-seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 2px; }
.v-seg button { padding: 3px 10px; border-radius: 999px; font-size: 12px; color: var(--muted); }
.v-seg button[aria-pressed="true"] { background: var(--active); color: #fff; }
.v-seen { padding: 3px 10px; border-radius: 999px; font-size: 12px; border: 1.5px solid var(--line); color: var(--muted); }
.v-seen[aria-pressed="true"] { border-color: var(--active); color: var(--active); background: var(--active-soft); }
.v-back { padding: 3px 4px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
