/* Layout: one airy column for a phone held in one hand — a quiet title, two actions, results, then the shelf; a book opens as a bottom sheet. */
:root {
  --bg: #ede7df;
  --surface: #f7f3ee;
  --ink: #2f2a26;
  --taupe: #8b7f74;
  --line: #ddd4ca;
  --accent: #6b5d52;
  --accent-ink: #f7f3ee;
  --soft: #e4dbd0;
  --sage: #5f6b52;  --sage-soft: #e1e3d6;
  --ochre: #8d6a3a; --ochre-soft: #efe2cc;
  --brick: #96503f; --brick-soft: #f0dcd4;
  --scrim: rgba(47, 42, 38, 0.38);
  --f-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --f-body: "Manrope", -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a17; --surface: #27231f; --ink: #ede6dc; --taupe: #a99e92; --line: #3a342e;
    --accent: #cdbda9; --accent-ink: #1d1a17; --soft: #332d27;
    --sage: #b3c09f; --sage-soft: #2e3328; --ochre: #d9b27a; --ochre-soft: #3a2f20; --brick: #e39a87; --brick-soft: #3c2622;
    --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1a17; --surface: #27231f; --ink: #ede6dc; --taupe: #a99e92; --line: #3a342e;
  --accent: #cdbda9; --accent-ink: #1d1a17; --soft: #332d27;
  --sage: #b3c09f; --sage-soft: #2e3328; --ochre: #d9b27a; --ochre-soft: #3a2f20; --brick: #e39a87; --brick-soft: #3c2622;
  --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 600px; margin: 0 auto; padding-block: 36px 56px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 32px; }
header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
h1 { font: 400 clamp(1.9rem, 8vw, 2.75rem)/1 var(--f-display); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.count { font: 500 0.78rem var(--f-body); color: var(--taupe); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; padding-bottom: 6px; }
h2 { font: 600 0.7rem var(--f-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--taupe); margin: 0; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 18px; border-radius: 20px; border: 0; cursor: pointer; font: inherit; color: inherit; min-height: 128px; transition: transform 0.15s ease; }
.big:active { transform: scale(0.98); }
.big strong { font: 400 1.4rem/1.1 var(--f-display); }
.big span { font-size: 0.8rem; color: var(--taupe); }
.big svg { width: 22px; height: 22px; margin-bottom: auto; opacity: 0.85; }
.big.check { background: var(--accent); color: var(--accent-ink); }
.big.check span { color: var(--accent-ink); opacity: 0.72; }
.big.add { background: var(--surface); }
.big:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .shelf li:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.big:disabled { opacity: 0.55; cursor: progress; }
@media (prefers-reduced-motion: reduce) { .big { transition: none; } }

.panel { background: var(--surface); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.status { display: flex; gap: 14px; align-items: center; }
.thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 12px; flex: none; background: var(--soft); }
.spinner { width: 16px; height: 16px; border: 1.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.muted { color: var(--taupe); font-size: 0.85rem; }

.verdict { border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.verdict.owned { background: var(--sage-soft); }
.verdict.new { background: var(--soft); }
.verdict .tag { font: 600 0.68rem var(--f-body); letter-spacing: 0.14em; text-transform: uppercase; }
.verdict.owned .tag { color: var(--sage); }
.verdict.new .tag { color: var(--accent); }
.verdict .t { font: 400 1.6rem/1.15 var(--f-display); overflow-wrap: anywhere; }
.verdict .a { font-size: 0.88rem; color: var(--taupe); }
.verdict .why { font-size: 0.82rem; color: var(--taupe); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.compare img, .compare .ph { width: 100%; max-width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: var(--soft); }
.compare figcaption { font-size: 0.78rem; color: var(--taupe); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }

.found { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.found li { display: grid; grid-template-columns: auto 44px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.found li:first-child { border-top: 0; }
.found input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.found .crop { width: 44px; height: 60px; object-fit: cover; border-radius: 6px; background: var(--soft); }
.found .meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.found .t { font-weight: 600; overflow-wrap: anywhere; }
.found .a { font-size: 0.82rem; color: var(--taupe); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font: 600 0.66rem var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.owned { background: var(--sage-soft); color: var(--sage); }
.pill.new { background: var(--soft); color: var(--accent); }
.cond { font: 500 0.72rem var(--f-body); padding: 2px 9px; border-radius: 99px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.cond::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cond.c5, .cond.c4 { background: var(--sage-soft); color: var(--sage); }
.cond.c3 { background: var(--soft); color: var(--accent); }
.cond.c2 { background: var(--ochre-soft); color: var(--ochre); }
.cond.c1 { background: var(--brick-soft); color: var(--brick); }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: 600 0.88rem var(--f-body); padding: 12px 18px; border-radius: 99px; border: 0; background: var(--soft); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--taupe); }
.btn.danger { background: transparent; color: var(--brick); padding-inline: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.search { display: flex; flex-direction: column; gap: 12px; }
.field { width: 100%; font: 400 1rem var(--f-body); padding: 14px 18px; border-radius: 99px; border: 1px solid transparent; background: var(--surface); color: var(--ink); }
.field::placeholder { color: var(--taupe); }
.field:focus { border-color: var(--line); outline: none; }
select.field { border-radius: 14px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--taupe) 50%), linear-gradient(135deg, var(--taupe) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 17px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.hint { font-size: 0.85rem; color: var(--taupe); padding-inline: 6px; }
.hint b { color: var(--ink); font-weight: 600; }
.manual { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.manual .full { grid-column: 1 / -1; }

.shelf { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.shelf li { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 14px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.shelf li:first-child { border-top: 0; }
.shelf li.empty { display: block; cursor: default; }
.spine, .shelf .pic { width: 44px; height: 62px; border-radius: 4px; }
.shelf .pic { object-fit: cover; background: var(--soft); }
.spine { display: grid; place-items: center; font: 400 1.1rem var(--f-display); color: var(--accent-ink); }
.shelf .meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.shelf .t { font: 400 1.2rem/1.2 var(--f-display); overflow-wrap: anywhere; }
.shelf .a { font-size: 0.82rem; color: var(--taupe); }
.chev { color: var(--line); font-size: 1.3rem; }
.empty { padding: 40px 18px; text-align: center; color: var(--taupe); background: var(--surface); border-radius: 20px; }
.empty strong { display: block; font: 400 1.5rem var(--f-display); color: var(--ink); margin-bottom: 6px; }
.note { font-size: 0.75rem; color: var(--taupe); text-align: center; letter-spacing: 0.02em; }
.err { color: var(--brick); font-size: 0.88rem; }

/* book sheet */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 10; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet { background: var(--bg); width: 100%; max-width: 600px; max-height: 92%; overflow-y: auto; border-radius: 26px 26px 0 0; padding-top: 22px; padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: var(--line); align-self: center; margin-top: -8px; }
.sheet .cover { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 16px; background: var(--surface); }
.sheet .nocover { aspect-ratio: 4 / 3; max-width: 100%; border-radius: 16px; background: var(--surface); display: grid; place-items: center; color: var(--taupe); font-size: 0.88rem; text-align: center; padding: 20px; }
.sheet h3 { font: 400 2rem/1.1 var(--f-display); margin: 4px 0 0; overflow-wrap: anywhere; text-wrap: balance; }
.sheet .a { color: var(--taupe); }
.sheet .isbn { font-size: 0.78rem; color: var(--taupe); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.sheet label { font: 600 0.7rem var(--f-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--taupe); margin-top: 6px; }
.sheet .condnote { font-size: 0.86rem; color: var(--taupe); }

/* standalone page additions */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; padding-top: env(safe-area-inset-top, 0px); }
.head-right { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-bottom: 4px; }
.head-right .count { padding-bottom: 0; }
.linkish { border: 0; background: none; color: var(--taupe); font: 500 0.75rem var(--f-body); cursor: pointer; padding: 2px 0; text-decoration: underline; text-underline-offset: 3px; }
.quota { font-size: 0.72rem; color: var(--taupe); font-variant-numeric: tabular-nums; }

.auth { max-width: 420px; margin: 0 auto; min-height: 100vh; padding-block: 48px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; justify-content: center; gap: 28px; }
.auth h1 { font-size: 3rem; }
.auth .lede { color: var(--taupe); margin: 10px 0 0; max-width: 32ch; }
.auth form { display: flex; flex-direction: column; gap: 10px; }
.auth .tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 99px; }
.auth .tabs button { flex: 1; border: 0; background: transparent; color: var(--taupe); font: 600 0.88rem var(--f-body); padding: 10px; border-radius: 99px; cursor: pointer; }
.auth .tabs button[aria-pressed="true"] { background: var(--bg); color: var(--ink); }
.auth .btn.primary { padding-block: 14px; font-size: 0.95rem; }

[hidden] { display: none !important; }
img { max-width: 100%; }
