/* Ink and paper: near-black blue background, cream text, sage green for the
   main action, serif for book titles. Measured for the iPhone 15
   (393 × 852, insets 59 top / 34 bottom). */
:root {
  --bg: #101318;
  --panel: #1a1e25;
  --panel-2: #252a33;
  --line: #2f3540;
  --text: #efe8da;
  --muted: #9aa0a8;
  --accent: #8fcfae;
  --accent-ink: #0f2219;
  --warm: #e8a85c;
  --danger: #ff7a6b;
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --dock: 58px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: calc(var(--top) + 4px) 16px calc(var(--bottom) + var(--dock) + 28px);
  -webkit-text-size-adjust: 100%;
}

/* Double-tap zoom off on things you tap; never on text fields (global CLAUDE.md). */
button, a, select, label, .row, .list, .dock, .segmented, .shops, .swipe-buttons, .filters, .answers { touch-action: manipulation; }
input, textarea { touch-action: auto; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 28px; margin: 0; letter-spacing: -0.01em; font-family: var(--serif); font-weight: 600; }
h2 { font-size: 20px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 56px 12px 20px; line-height: 1.6; }
.center { display: block; margin: 20px auto 0; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.top h1 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 40px; line-height: 1; width: 40px; height: 44px; margin-left: -8px; color: var(--accent); }
.summary { color: var(--muted); font-size: 14px; margin: 0 0 12px; min-height: 1px; }

.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 12px; padding: 13px 18px; }
.ghost { padding: 13px 18px; border-radius: 12px; background: var(--panel-2); font-weight: 600; }
.link-button { color: var(--accent); padding: 10px 0; font-size: 15px; }
.link-button.danger { color: var(--danger); }

/* ---------- bottom bar ---------- */
/* Opaque, no backdrop-filter: Safari strands a blurred fixed bar mid-page
   (global CLAUDE.md). translateZ(0) keeps it on its own layer. */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; padding: 0 6px var(--bottom);
  background: #0c0f13; border-top: 1px solid var(--line);
  transform: translateZ(0);
}
/* `hidden` alone loses to display:flex above — the bar stayed on the
   sign-in screen in the first e2e run (2026-11-01). */
.dock[hidden] { display: none; }
.dock a {
  flex: 1; height: var(--dock); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600;
}
.dock-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dock a.on { color: var(--accent); }

/* ---------- rows (lists and search) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--panel); border-radius: 14px; padding: 10px; position: relative;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.row-cover { width: 56px; height: 84px; border-radius: 6px; object-fit: cover; flex: none; background: var(--panel-2); }
.cover-empty {
  display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden;
  padding: 6px; font: 600 10px/1.2 var(--serif); color: var(--muted);
  background: linear-gradient(160deg, #2c3340, #1d222b); border: 1px solid var(--line);
}
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 1px; }
.row-title {
  font: 600 17px/1.25 var(--serif);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-author { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.row-score { font-size: 13px; color: var(--warm); }
.row-note {
  color: var(--muted); font-size: 14px; font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rank {
  position: absolute; top: 4px; left: 4px; z-index: 1; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800;
  display: grid; place-items: center;
}
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--muted);
}
.chip-own { background: #1f3a2d; color: var(--accent); }
.chip-buy { background: #3d2c17; color: var(--warm); }
.chip-status { align-self: center; flex: none; }
.lang { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }

/* The only place a drag can start, so the rest of the list scrolls normally. */
.drag-handle {
  align-self: stretch; flex: none; width: 44px; margin: -10px -10px -10px 0;
  display: grid; place-items: center; font-size: 24px; color: var(--muted);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.sorting .row:not(.dragging) { transition: transform 0.15s ease; }
.row.dragging { z-index: 5; box-shadow: 0 10px 30px #000c; background: var(--panel-2); }

.quick-add {
  align-self: center; flex: none; width: 44px; height: 44px; border-radius: 22px;
  background: var(--panel-2); color: var(--accent); font-size: 26px; font-weight: 500; line-height: 1;
}

/* ---------- search ---------- */
.search-form { margin: 4px 0 14px; }
input, textarea, select {
  font: inherit; font-size: 17px; /* 16px+ or iOS zooms the page on focus */
  color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 120px; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; font-size: 16px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239aa0a8' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; }

/* ---------- book page ---------- */
.hero { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 20px; }
.hero-cover { width: 128px; height: 192px; border-radius: 8px; object-fit: cover; flex: none; background: var(--panel-2); box-shadow: 0 8px 24px #0008; font-size: 13px; }
.hero-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.book-title { font-size: 24px; line-height: 1.15; }
.book-author { margin: 0; font-size: 16px; }
.book-score { margin: 4px 0 0; color: var(--warm); font-size: 15px; line-height: 1.35; }

.segmented { display: flex; background: var(--panel); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; padding: 10px 6px; border-radius: 9px; font-size: 15px; color: var(--muted); font-weight: 600; }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }
.segmented .count { font-weight: 500; opacity: 0.75; font-size: 13px; }
.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border-radius: 12px; padding: 12px 14px; margin-top: 10px; cursor: pointer;
}
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.switch-row input {
  appearance: none; -webkit-appearance: none; width: 51px; height: 31px; padding: 0; flex: none;
  border-radius: 16px; border: 0; background: #3a404b; position: relative; transition: background 0.2s;
}
.switch-row input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(20px); }
.switch-row input:focus { outline: none; }

.label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }
.section { margin-top: 4px; }
.saved { color: var(--accent); margin-top: 6px; }

.edition { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.edition-cover { width: 48px; height: 72px; border-radius: 5px; object-fit: cover; flex: none; background: var(--panel-2); }
.edition-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.edition-text { margin: 0; font-size: 15px; }
.shops { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.shop {
  display: flex; flex-direction: column; gap: 2px; padding: 11px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
}
.shop-name { font-weight: 700; color: var(--accent); }
.shop-where { font-size: 12px; color: var(--muted); }

.about { margin: 0; line-height: 1.5; white-space: pre-line; }
.about.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.subjects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ---------- stars (from rate-it) ---------- */
.stars { display: inline-block; font-size: 18px; line-height: 1; letter-spacing: 0; white-space: nowrap; }
.stars::before {
  content: "★★★★★";
  background: linear-gradient(90deg, var(--warm) calc(var(--v) / 5 * 100%), #3a404b 0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stars-small { font-size: 14px; }
.stars-big { font-size: 44px; touch-action: none; user-select: none; -webkit-user-select: none; padding: 4px 0; }
.picker-row { display: flex; align-items: center; gap: 12px; }
.picker-value { font-size: 17px; font-weight: 600; color: var(--warm); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--bottom) + var(--dock) + 14px); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 8px 24px #000a; transform: translateZ(0);
}

/* ---------- score marks (card + book page) ---------- */
.mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  height: 16px; min-width: 18px; padding: 0 4px; border-radius: 4px;
  font: 800 9px/1 -apple-system, system-ui, sans-serif; font-style: normal; letter-spacing: 0.02em;
}
.mark.ol { background: #e8dcc2; color: #3a2a12; }
.mark.hc { background: #6c5ce7; color: #fff; }
.mark.gb { background: #4c8bf5; color: #fff; }

.score-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.score-row:last-of-type { border-bottom: 0; }
.score-value { font-weight: 700; color: var(--warm); min-width: 46px; }
.score-source { flex: 1; }
.awards-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-award { background: #3a3117; color: #f0d58c; }
.key-hint { margin-top: 10px; }
/* One unbreakable piece with real padding: wrapped across two lines, the
   "›" sat alone and a tap between the lines hit nothing (e2e, 2026-10-30). */
.key-hint a { color: var(--accent); white-space: nowrap; display: inline-block; padding: 8px 0; font-weight: 600; }
.source-note { margin-top: 6px; font-size: 12px; }

/* ---------- swipe ---------- */
/* Height-locked: the view is fixed between the Dynamic Island and the bottom
   bar, so the page has nothing to scroll. A scrollable page is a pan target
   iOS steals mid-swipe; in cinequeue the first thing it did was scroll the
   Skip/Undo row out from under the finger. */
body.locked { overflow: hidden; overscroll-behavior: none; }
.swipe-view {
  position: fixed; left: 16px; right: 16px;
  top: calc(var(--top) + 6px); bottom: calc(var(--bottom) + var(--dock) + 10px);
  display: flex; flex-direction: column;
}
.swipe-view .empty { margin: auto 0; }
.swipe-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.swipe-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: auto; padding: 6px 0; }
.swipe-pill {
  font-size: 13px; color: var(--muted); padding: 7px 13px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); white-space: nowrap; touch-action: manipulation;
}
.swipe-stack {
  position: relative; flex: 1; min-height: 220px;
  /* The whole point is dragging in all four directions. */
  touch-action: none;
}
.swipe-card {
  position: absolute; inset: 0; border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(160deg, #2c3340, #1d222b); overflow: hidden;
  will-change: transform; user-select: none; -webkit-user-select: none;
  /* On the card too, and on every child below: touch-action does not
     inherit, and iOS resolves it from the touched element up (cinequeue). */
  touch-action: none;
}
.swipe-card * { touch-action: none; }
.swipe-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.swipe-card[data-idx="0"] { z-index: 3; }
.swipe-card[data-idx="1"] { z-index: 2; transform: scale(.96) translateY(10px); }
.swipe-card[data-idx="2"] { z-index: 1; transform: scale(.92) translateY(20px); }

.swipe-text {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 56px 14px 14px;
  background: linear-gradient(transparent, rgba(8, 10, 14, .93) 58%);
}
.swipe-text h3 { margin: 0; font: 600 21px/1.2 var(--serif); }
.swipe-text .sub { font-size: 13px; color: #c9c3b6; margin-top: 3px; }
.swipe-text .genres { font-size: 12.5px; color: var(--accent); margin-top: 3px; }
.swipe-text .desc {
  margin: 7px 0 0; font-size: 13.5px; line-height: 1.42; color: #e3ddd0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Open: the panel grows upward only as far as its text needs and stays a
   gradient, so the cover still shows and the title barely moves. Never give
   anything inside a card its own scroller: an overflow:auto box computes
   touch-action: auto and swallows up/down swipes (cinequeue's "stuck card"). */
.swipe-card.open .swipe-text {
  padding-top: 64px; max-height: 92%; overflow: hidden;
  background: linear-gradient(transparent, rgba(8, 10, 14, .78) 12%, rgba(8, 10, 14, .95) 30%);
}
.swipe-card.open .desc { display: block; -webkit-line-clamp: unset; }
.swipe-text .open-only { display: none; }
.swipe-card.open .swipe-text .open-only { display: block; }
/* Same specificity trap as cinequeue: the rule above sets block, so the
   score row needs one more class to be a flex row again. */
.swipe-text .cardscores {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 16px; margin-bottom: 8px;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cardscores .cs { display: inline-flex; align-items: center; gap: 5px; height: 16px; line-height: 16px; }
.swipe-text .awards { margin-top: 5px; font-size: 12px; color: #f0d58c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.swipe-overlay {
  position: absolute; top: 20px; z-index: 2; padding: 6px 12px; border: 2.5px solid; border-radius: 9px;
  font-weight: 800; font-size: 16px; letter-spacing: .02em; background: rgba(8, 10, 14, .6);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.swipe-overlay.like { left: 14px; color: var(--accent); border-color: var(--accent); rotate: -10deg; }
.swipe-overlay.nope { right: 14px; color: var(--danger); border-color: var(--danger); rotate: 10deg; }
.swipe-overlay.want, .swipe-overlay.pass { left: 50%; transform: translateX(-50%); width: max-content; top: 34%; }
.swipe-overlay.want { color: #7db8ff; border-color: #7db8ff; }
.swipe-overlay.pass { color: #c3ccd8; border-color: #c3ccd8; }
.swipe-love {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-size: 96px; color: #ff5b8d;
  text-shadow: 0 6px 34px rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .12s, scale .28s;
}
.swipe-love.show { opacity: 1; scale: 1.2; }

.swipe-buttons { display: flex; justify-content: center; align-items: flex-end; gap: 18px; margin-top: 10px; }
.sb-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sb-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sb-row { display: flex; gap: 8px; align-items: center; }
.sb {
  width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.sb span { font-size: 20px; line-height: 1; }
.sb b { font-size: 8.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sb.nope span { color: var(--danger); }
.sb.like span { color: var(--accent); }
.sb.want span { color: #7db8ff; }
.sb.pass span { color: var(--muted); }
.sb.love { border-color: rgba(255, 91, 141, .45); }
.sb.love span { color: #ff5b8d; font-size: 24px; }
.swipe-legend { text-align: center; font-size: 11.5px; line-height: 1.6; color: var(--muted); margin-top: 10px; }

/* ---------- keys ---------- */
.intro { margin: 0 0 14px; line-height: 1.5; }
.key-card { background: var(--panel); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.key-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.key-head h2 { margin: 0; font-size: 18px; }
.key-status { font-size: 13px; font-weight: 700; text-align: right; }
.key-status.ok { color: var(--accent); }
.key-status.bad { color: var(--danger); }
.key-status.warn { color: var(--warm); }
.key-status.off { color: var(--muted); }
.key-steps { margin: 10px 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.key-steps a { color: var(--accent); }
.key-form { display: flex; gap: 8px; }
.key-form input { flex: 1; min-width: 0; }

/* ---------- sign in / invite ---------- */
.signin { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 0 8px; }
.signin-logo { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 8px 24px #0008; }
.signin h1 { font-size: 30px; }
.signin .muted { max-width: 300px; line-height: 1.5; }
.signin .small { font-size: 13px; }
.signin-form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.primary.wide { width: 100%; max-width: 320px; padding: 15px; font-size: 17px; }
.account {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--panel-2); color: var(--accent); font-weight: 800; font-size: 15px;
}

.search-note { margin: 0 0 4px; line-height: 1.45; }

.swipe-text .because { font-size: 12.5px; color: #f0d58c; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Want to read / My books ---------- */
.reading-list { margin-bottom: 10px; }
.row-reading { border: 1px solid #2f5a46; }
.chip-reading { background: #1f3a2d; color: var(--accent); }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.filter.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filter .count { font-weight: 500; opacity: 0.75; font-size: 12px; }
.chip-answer.answer-loved { background: #3d1d29; color: #ff8db0; }
.chip-answer.answer-liked { background: #1f3a2d; color: var(--accent); }
.chip-answer.answer-disliked { background: #3b2220; color: var(--danger); }
.chip-answer.answer-interested { background: #1d2c40; color: #7db8ff; }

.answers { display: flex; flex-wrap: wrap; gap: 8px; }
.answer { padding: 9px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: 15px; color: var(--muted); }
.answer.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.reading-note { margin: 0 0 8px; color: var(--accent); }
.small { font-size: 13px; }

.taste { background: var(--panel); border-radius: 14px; padding: 2px 14px 12px; margin-bottom: 14px; }
.taste .label { margin-top: 14px; }
.taste-row { display: flex; gap: 10px; align-items: baseline; margin-top: 10px; }
.taste-label { flex: none; width: 76px; font-size: 13px; color: var(--muted); font-weight: 600; }
.taste-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-no { background: #3b2220; color: var(--danger); }

.author-link { display: inline-block; color: var(--accent); padding: 4px 0; font-weight: 600; }
/* On the card: a pill, big enough to hit with a thumb. */
.swipe-card.open .swipe-text .more-by { display: inline-block; margin-top: 8px; padding: 7px 12px; border-radius: 999px; background: #1f3a2d; color: var(--accent); font-size: 13px; font-weight: 700; touch-action: manipulation; }

.cardscores .cs-main { font-size: 15px; color: var(--warm); gap: 6px; }
.cardscores .cs-main small { font-size: 11.5px; color: #c9c3b6; font-weight: 600; }
.swipe-card.open .swipe-text .cs-each { display: inline-flex; gap: 10px; }
.cs-each .mark { margin-right: 4px; }
.score-main { display: flex; align-items: center; gap: 12px; padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.score-main-value { font-size: 26px; font-weight: 800; color: var(--warm); }
.score-main > span:last-child { display: flex; flex-direction: column; gap: 2px; }
