/* Watch Tracker styles. Mobile first (390px), also fine on a laptop. */

:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #eeeef2;
  --text: #17171c;
  --muted: #6b6b76;
  --line: #e1e1e7;
  --accent: #5b4bdb;
  --accent-text: #ffffff;
  --accent-soft: #ebe8ff;
  --danger: #d0342c;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --radius: 14px;
  --s-active: #2f7de1;
  --s-plan: #7a7a86;
  --s-hold: #c98a0b;
  --s-completed: #1f9d55;
  --s-dropped: #d0342c;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216;
    --surface: #1d1d23;
    --surface-2: #2a2a32;
    --text: #f1f1f4;
    --muted: #a0a0ab;
    --line: #33333c;
    --accent: #8b7dff;
    --accent-text: #120f2b;
    --accent-soft: #2c2752;
    --danger: #ff6b62;
    --shadow: none;
    --s-active: #6aa8ff;
    --s-plan: #a0a0ab;
    --s-hold: #f0b542;
    --s-completed: #4ccf83;
    --s-dropped: #ff6b62;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }

.wrap, .topbar { max-width: 760px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: 8px;
}
.topbar h1 { font-size: 24px; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 8px; }

.pill-btn {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 500;
}
.pill-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.link-btn { background: none; border: 0; color: var(--accent); font-size: 16px; padding: 10px 4px; min-height: 44px; }
.link-btn.strong { font-weight: 600; }

/* ---------- Search and filters ---------- */
.searchbar { display: flex; gap: 8px; margin: 4px 0 8px; }
.searchbar input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
.searchbar .pill-btn { height: 44px; }

.filters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.filters[hidden] { display: none; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters select { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 10px; font-size: 16px; color: var(--text); }
.filters .link-btn { grid-column: 1 / -1; justify-self: start; }

/* ---------- Continue row ---------- */
.continue { margin: 6px 0 10px; }
.continue h2 { font-size: 18px; margin-bottom: 8px; }
.hscroll {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }
.ccard {
  flex: 0 0 148px; scroll-snap-align: start; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden;
}
.ccard-main { background: none; border: 0; padding: 0; text-align: left; flex: 1; display: flex; flex-direction: column; }
.ccard h3 { font-size: 14px; padding: 8px 10px 0; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ccard .prog { font-size: 13px; color: var(--muted); padding: 2px 10px 0; }
.ccard .bar { margin: 6px 10px 0; }
.ccard .plus { margin: 8px; width: auto; height: 48px; }

.ccover {
  position: relative; height: 96px; width: 100%;
  background: var(--surface-2); overflow: hidden;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; margin: 4px -16px 10px; padding: 2px 16px;
  scrollbar-width: none; position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding-top: 8px; padding-bottom: 8px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; min-height: 38px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; white-space: nowrap;
}
.tab .count { color: var(--muted); font-size: 12px; margin-left: 2px; }
.tab.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab.on .count { color: inherit; opacity: .7; }

/* ---------- Cards ---------- */
.list { display: grid; gap: 10px; }
@media (min-width: 700px) { .list { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; align-items: stretch; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden;
}
.card-main {
  flex: 1; min-width: 0; display: flex; gap: 12px; padding: 10px; text-align: left;
  background: none; border: 0;
}
.cover {
  position: relative; flex: 0 0 64px; height: 90px; border-radius: 8px; overflow: hidden; background: var(--surface-2);
}
.cover img, .ccover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.cover-letter {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 28px; font-weight: 700; color: var(--muted);
}
.info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.info h3 { font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--muted); align-items: center; }
.status { font-weight: 600; }
.s-active { color: var(--s-active); }
.s-plan { color: var(--s-plan); }
.s-hold { color: var(--s-hold); }
.s-completed { color: var(--s-completed); }
.s-dropped { color: var(--s-dropped); }
.rating { color: var(--text); font-weight: 600; }
.prog { font-size: 14px; }
.reason { font-size: 13px; color: var(--muted); font-style: italic; }
.bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 0;
}

.plus {
  flex: 0 0 68px; border: 0; background: var(--accent); color: var(--accent-text);
  font-size: 22px; font-weight: 700; border-radius: 12px; margin: 10px 10px 10px 0;
}
.plus.wide { flex-basis: 84px; font-size: 15px; }
.ccard .plus { font-size: 20px; }
.plus:active { transform: scale(.96); filter: brightness(.95); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty strong { color: var(--text); }

/* ---------- Add button ---------- */
.fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%; border: 0; z-index: 10;
  background: var(--accent); color: var(--accent-text); font-size: 36px; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
@media (min-width: 800px) { .fab { right: calc(50% - 380px + 16px); } }

/* ---------- Dialogs ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(0,0,0,.45); }

.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0;
  border-radius: 18px 18px 0 0; display: none; flex-direction: column;
}
.sheet[open] { display: flex; }
.sheet > form { display: flex; flex-direction: column; min-height: 0; max-height: 92dvh; }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 18px; } }

.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 4px 12px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 17px; text-align: center; }
.sheet-head > :last-child { justify-self: end; }
.sheet-head > :first-child { justify-self: start; }
.sheet-body {
  overflow-y: auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch;
}

.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.field[hidden], .row2[hidden], .switch[hidden] { display: none; }
.field small, .switch small { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; font-weight: 400;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .searchbar input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.field-error { color: var(--danger); margin: -6px 0 0; font-size: 14px; }

.row2 { display: flex; gap: 10px; }
.row2 > .field { flex: 1; min-width: 0; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span {
  display: grid; place-items: center; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 500; font-size: 15px;
}
.seg-item input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.seg-item input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; font-size: 15px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui {
  flex: 0 0 50px; height: 30px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); position: relative; transition: background .15s;
}
.switch-ui::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s;
}
.switch input:checked + .switch-ui { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.tag-suggest:empty { display: none; }
.tag.add { min-height: 34px; padding: 4px 12px; font-size: 14px; }

.danger-btn {
  margin-top: 8px; min-height: 48px; border-radius: 12px; border: 1px solid var(--danger);
  background: none; color: var(--danger); font-weight: 600;
}
.danger-btn[hidden] { display: none; }

.big-btn {
  min-height: 52px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 17px;
}
.big-btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.muted { color: var(--muted); margin: -4px 0 0; font-size: 14px; }
.small { font-size: 12px; }

.small-dlg { width: calc(100% - 40px); max-width: 360px; border-radius: 16px; padding: 20px; margin: auto; }
.small-dlg h2 { font-size: 18px; margin-bottom: 8px; }
.small-dlg p { margin: 0 0 16px; color: var(--muted); white-space: pre-line; }
.dlg-buttons { display: flex; flex-direction: column; gap: 8px; }
.dlg-buttons button {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600;
}
.dlg-buttons .danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.dlg-buttons .primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Stats ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; }
.tile b { font-size: 24px; }
.tile span { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats th, .stats td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.stats tbody th { text-align: left; font-weight: 500; }
.stats thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.stats tr.total th, .stats tr.total td { font-weight: 700; border-bottom: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 10px 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 15px;
}
.toast[hidden] { display: none; }
#toast-text { flex: 1; }
.toast-action {
  flex: 0 0 auto; min-height: 40px; padding: 0 12px; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.toast-action[hidden] { display: none; }

/* ---------- Step 2: lookup and settings ---------- */
.pill-btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pill-btn:disabled { opacity: .6; }
.topbar h1 { font-size: 22px; }

.lookup-row { display: flex; gap: 8px; }
.lookup-row input { flex: 1; min-width: 0; }
.lookup-row .pill-btn { min-height: 46px; flex: 0 0 auto; }
#lookup-hint { margin-top: -6px; }

.lookup-results {
  display: flex; flex-direction: column; gap: 6px; margin-top: -4px;
  background: var(--surface-2); border-radius: 12px; padding: 8px;
}
.lookup-results[hidden] { display: none; }
.lookup-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; font-size: 14px; font-weight: 600; }
.lookup-head .link-btn { min-height: 36px; padding: 4px; font-size: 15px; }
.lookup-msg { padding: 8px; font-size: 15px; color: var(--muted); }
.result {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-height: 64px;
}
.result:active { border-color: var(--accent); }
.rcover { position: relative; flex: 0 0 42px; height: 58px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.rcover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.rcover .cover-letter { font-size: 18px; }
.rinfo { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.rinfo b { font-size: 15px; overflow-wrap: anywhere; }
.rinfo small { font-size: 12px; color: var(--muted); }

.sheet-body h3 { font-size: 17px; margin-top: 6px; }
.sheet-body p { margin: 0; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.sheet-body a { color: var(--accent); }
.credits { font-size: 14px; }
.tmdb-credit img { vertical-align: middle; margin-right: 4px; }

/* ---------- Step 3: what next ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; flex: 0 0 auto; }
.chips::-webkit-scrollbar { display: none; }
.panel { background: var(--surface-2); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel h3 { margin: 0; }
.panel .muted { margin: -6px 0 0; }
.panel .big-btn.secondary { background: var(--surface); }

.pick { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: 12px; padding: 10px; }
.pick .cover { flex-basis: 70px; height: 98px; }
.pick-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pick-info b { font-size: 17px; overflow-wrap: anywhere; }
.pick-info .pill-btn { align-self: flex-start; }

.rec-group { display: flex; flex-direction: column; gap: 6px; }
.rec-group h4 { margin: 4px 0 0; font-size: 14px; font-weight: 600; }
.rec-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px; padding: 2px 14px 6px; scrollbar-width: none; }
.rec-row::-webkit-scrollbar { display: none; }
.rec {
  flex: 0 0 122px; display: flex; flex-direction: column; background: var(--surface);
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
}
.rec .ccover { height: 150px; }
.rec b { font-size: 13px; line-height: 1.25; padding: 6px 8px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rec small { font-size: 11px; color: var(--muted); padding: 2px 8px 0; }
.rec button {
  margin: auto 8px 8px; min-height: 40px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 13px; margin-top: 8px;
}
.rec button:disabled { background: var(--surface-2); color: var(--muted); }
.rec-note { font-size: 14px; color: var(--muted); }

/* ---------- Swipe deck ---------- */
.swipe-cta {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin: 2px 0 12px; min-height: 60px;
}
.swipe-cta-icon {
  flex: 0 0 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-size: 22px;
}
.swipe-cta b { display: block; font-size: 16px; }
.swipe-cta small { display: block; font-size: 13px; color: var(--muted); }

.sheet.full { height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; max-width: none; }
@media (min-width: 600px) { .sheet.full { height: min(860px, 94dvh); max-height: 94dvh; max-width: 480px; border-radius: 18px; margin: auto; } }
.sheet.full .sheet-head { padding-top: calc(4px + env(safe-area-inset-top)); }

.swipe-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); overflow: hidden;
}
.swipe-help { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 2px; }

.deck { position: relative; flex: 1; min-height: 260px; }
.scard {
  position: absolute; inset: 0; margin: 0 auto; max-width: 360px; border-radius: 18px; overflow: hidden;
  background: var(--surface-2); box-shadow: 0 6px 20px rgba(0,0,0,.25);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.scard.under { transform: scale(.94) translateY(10px); opacity: .7; pointer-events: none; }
.scover { position: absolute; inset: 0; }
.scover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; -webkit-user-drag: none; pointer-events: none; }
.scover .cover-letter { font-size: 72px; }
.sinfo {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 40px 16px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); color: #fff; display: flex; flex-direction: column; gap: 2px;
}
.sinfo b { font-size: 20px; line-height: 1.2; }
.sinfo small { font-size: 13px; opacity: .85; }
.stamp {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%) rotate(-8deg); z-index: 3;
  font-size: 26px; font-weight: 800; letter-spacing: .04em; padding: 4px 12px; border: 4px solid; border-radius: 10px;
  background: rgba(0,0,0,.35); opacity: 0; transition: opacity .1s; white-space: nowrap;
}
.scard[data-dir="right"] .stamp { opacity: 1; color: #4ccf83; }
.scard[data-dir="left"] .stamp { opacity: 1; color: #e4e4ea; }
.scard[data-dir="up"] .stamp { opacity: 1; color: #ff6b62; }
.scard[data-dir="down"] .stamp { opacity: 1; color: #f0b542; }

.deck-msg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 20px; }
.deck-msg p { margin: 0; }
.swipe-status { margin: 0; min-height: 20px; text-align: center; font-size: 14px; color: var(--muted); }
.swipe-note { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

.swipe-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sb {
  min-height: 64px; border-radius: 14px; border: 2px solid; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600;
}
.sb span { font-size: 22px; line-height: 1; }
.sb:disabled { opacity: .4; }
.sb.skip { border-color: var(--line); color: var(--muted); }
.sb.drop { border-color: var(--s-dropped); color: var(--s-dropped); }
.sb.hold { border-color: var(--s-hold); color: var(--s-hold); }
.sb.seen { border-color: var(--s-completed); color: var(--s-completed); }
.sb:active { transform: scale(.95); }

/* ---------- Notes on cards ---------- */
.card-note {
  font-size: 13px; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 8px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}

/* ---------- Rate + note after a swipe ---------- */
.rate-panel { background: var(--surface-2); border-radius: 14px; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.rate-panel[hidden] { display: none; }
.rate-panel:not([hidden]) ~ .swipe-note { display: none; }
.rate-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; gap: 8px; }
.rate-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-head .link-btn { min-height: 32px; padding: 2px 4px; font-size: 15px; }
.rate-row { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rate-btn {
  min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 15px; padding: 0;
}
.rate-btn.on { background: var(--s-hold); border-color: var(--s-hold); color: #1a1205; }
.note-row { display: flex; gap: 8px; }
.note-row input {
  flex: 1; min-width: 0; min-height: 42px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
.note-row .pill-btn { min-height: 42px; }

/* ---------- Shelves ---------- */
.shelves-cta { background: var(--surface); border-color: var(--line); }
.shelves-cta .swipe-cta-icon { background: var(--surface-2); color: var(--text); }
.swipe-cta + .shelves-cta { margin-top: -4px; }

.seg.two { grid-template-columns: 1fr 1fr; }
.seg-btn {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 15px;
}
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

#shelves { display: flex; flex-direction: column; gap: 8px; }
.shelf { background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.shelf summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 14px; cursor: pointer; font-weight: 600;
}
.shelf summary::-webkit-details-marker { display: none; }
.shelf summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.shelf[open] summary::before { transform: rotate(90deg); }
.shelf-name { flex: 1; }
.shelf-meta { font-size: 13px; color: var(--muted); font-weight: 500; }
.shelf-meta b { color: var(--text); font-size: 15px; }
.shelf-items { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px; }
.shelf-row {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-height: 64px;
}
.shelf-row .rating { color: var(--text); font-weight: 600; }
.shelf-note { font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf-hint { margin: 0 4px; }
.shelf-items > .pill-btn { align-self: flex-start; margin: 0 4px 4px; }

/* ---------- Seasons / chapters info ---------- */
.about { font-size: 12px; color: var(--muted); }
.about-box {
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px;
  display: flex; flex-direction: column; gap: 4px; margin-top: -4px;
}
.about-box[hidden] { display: none; }
.about-box .link-btn { align-self: flex-start; min-height: 36px; padding: 4px 0; font-size: 15px; }
.about-box .link-btn[hidden] { display: none; }

/* ---------- Backup reminder ---------- */
.banner {
  display: flex; flex-direction: column; gap: 8px; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; margin: 4px 0 10px; font-size: 15px;
}
.banner[hidden] { display: none; }
.banner-buttons { display: flex; gap: 8px; align-items: center; }

/* ---------- Home tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 2px 0 12px; }
.tile-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px; min-height: 92px;
}
.tile-btn b { font-size: 15px; }
.tile-btn small { font-size: 11px; color: var(--muted); line-height: 1.2; }
.tile-icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 2px;
  background: var(--accent-soft); color: var(--accent); font-size: 20px;
}
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
}
.badge[hidden] { display: none; }
.tile-badge { position: absolute; top: 6px; right: 6px; }

/* ---------- Friends ---------- */
.flist { display: flex; flex-direction: column; gap: 6px; }
.frow-wrap { display: flex; align-items: center; gap: 4px; }
.frow-wrap .frow { flex: 1; }
.frow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; min-height: 58px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.frow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.frow-main b { font-size: 16px; overflow-wrap: anywhere; }
.frow-main small { font-size: 13px; color: var(--muted); }
.chev { font-size: 22px; color: var(--muted); }
.danger-link { color: var(--danger); font-size: 14px; }
.fsub { margin: 8px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.ccount { color: var(--accent) !important; font-weight: 600; }
.fmsg { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; color: var(--text); }

.invite-code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: var(--surface);
  border: 1px dashed var(--accent); border-radius: 10px; padding: 10px; overflow-wrap: anywhere;
  user-select: all; -webkit-user-select: all;
}

.comment-row {
  display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%;
  background: var(--surface-2); border: 0; border-radius: 10px; padding: 8px 12px;
}
.comment-row small { color: var(--muted); font-size: 12px; }
.thread { display: flex; flex-direction: column; gap: 8px; }
.comment { align-self: flex-start; max-width: 88%; background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.comment.mine { align-self: flex-end; background: var(--accent-soft); border-radius: 14px 14px 4px 14px; }
.comment small { color: var(--muted); font-size: 12px; }
.comment span { overflow-wrap: anywhere; }
.small-link { align-self: flex-start; min-height: 28px; padding: 0; font-size: 13px; }

/* ---------- For you ---------- */
.taste { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fy-list { display: flex; flex-direction: column; gap: 8px; }
.fy-row { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.fy-row .rcover { flex-basis: 56px; height: 78px; }
.fy-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fy-info b { font-size: 15px; overflow-wrap: anywhere; }
.fy-info small { font-size: 12px; color: var(--muted); }
.fy-info .fy-why { color: var(--accent); font-weight: 600; }
.fy-buttons { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.fy-buttons .pill-btn { min-height: 38px; font-size: 14px; }
.fy-buttons .pill-btn:disabled { background: var(--surface-2); border-color: var(--line); color: var(--muted); opacity: 1; }
.fy-buttons .link-btn { min-height: 38px; font-size: 14px; color: var(--muted); }

/* ---------- Popular in a group ---------- */
.pop-list { display: flex; flex-direction: column; gap: 8px; }
.pop-row { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: 12px; padding: 8px; }
.pop-row .rcover { flex-basis: 52px; height: 72px; }
.pop-rank { flex: 0 0 22px; font-weight: 800; font-size: 18px; color: var(--accent); text-align: center; padding-top: 22px; }
.pop-stats { font-size: 13px; font-weight: 600; }
.pop-people { font-size: 12px; color: var(--muted); }
.pop-mine { color: var(--s-completed) !important; font-weight: 600; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg.three .seg-btn { font-size: 14px; padding: 0 4px; }

/* ---------- Poster polish ---------- */
/* Posters are portrait (about 2:3). Crop from the top so faces/titles aren't cut off,
   and give every empty box a soft gradient instead of a flat grey. */
.cover, .ccover, .rcover, .scover, .dcover {
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
}
.cover img, .ccover img, .rcover img, .scover img, .dcover img,
.rec .ccover img, .pick .cover img {
  object-fit: cover;
  object-position: center 18%;
}
.cover { flex-basis: 62px; height: 93px; }           /* exact 2:3 in the list */
.rcover { flex: 0 0 44px; height: 66px; }
.cover-letter {
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
}

/* ---------- Title detail view ---------- */
.detail-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 4px; }
.dcover {
  position: relative; flex: 0 0 120px; width: 120px; aspect-ratio: 2 / 3;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
}
.dcover img { position: absolute; inset: 0; width: 100%; height: 100%; }
.dcover .cover-letter { font-size: 44px; }
.detail-top-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; padding-top: 2px; }
.detail-top-info h3 { font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.detail-top-info .meta { gap: 4px 6px; }
.detail-top-info .meta .dot { color: var(--muted); }
.detail-rating { font-weight: 700; color: var(--accent); }
.detail-actions { margin: 14px 0 4px; }
.detail-h {
  font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 18px 0 7px;
}
.detail-summary { line-height: 1.55; white-space: pre-line; }
.detail-journal {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 92px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; line-height: 1.5;
}
.detail-src { margin-top: 16px; }
.detail-src a { color: var(--accent); }
