/* ───────────── Fonts (self-hosted so the app works offline) ───────────── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-ext-opsz-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-opsz-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-ext-opsz-italic.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/fraunces-latin-opsz-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ───────────── Tokens ───────────── */
:root {
  --bg: #131210;
  --surface: #1c1a17;
  --surface-2: #26231f;
  --border: #302c26;
  --text: #ede8df;
  --muted: #a0988c;
  --faint: #756e63;
  --accent: #e0a458;
  --accent-hover: #ebb46d;
  --on-accent: #1d1508;
  --danger: #ea7a66;
  --ok: #9cc594;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px;
  --radius-sm: 10px;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #efe9df;
  --border: #e2dace;
  --text: #201d18;
  --muted: #6c655a;
  --faint: #968e81;
  --accent: #a34d1c;
  --accent-hover: #8c4016;
  --on-accent: #fff9f2;
  --danger: #b4392a;
  --ok: #3f7a3a;
  --shadow: 0 10px 30px rgba(60, 40, 20, .16);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s ease, color .2s ease;
}
body.locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; touch-action: manipulation; }
img { display: block; max-width: 100%; }
.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ───────────── Notice at the app's old address ───────────── */
.moved {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px;
  padding: calc(var(--safe-t) + 14px) 20px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.moved p { flex: 1 1 280px; max-width: 620px; }
.moved .btn { min-height: 42px; text-decoration: none; }

/* ───────────── Library ───────────── */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 120px);
  animation: fadeUp .4s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 0 20px; }
.wordmark {
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 460;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -.025em;
  line-height: 1.05;
}
.wordmark em { font-style: italic; color: var(--accent); font-weight: 400; }
.count { color: var(--muted); font-size: .9rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; gap: 2px; margin-right: -10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-light { display: none; }
[data-theme="light"] .icon-light { display: block; }
[data-theme="light"] .icon-dark { display: none; }

.search {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 46px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--faint);
  transition: border-color .15s ease;
}
.search:focus-within { border-color: var(--accent); }
.search .icon { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 1rem; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .6; }

/* Lists: one scrolling row of tabs on a phone, a sidebar on a wide screen */
.lists {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  margin: 0 -20px 10px; padding: 2px 20px;
  overflow-x: auto; scrollbar-width: none;
}
.lists::-webkit-scrollbar { display: none; }
.nav-group { display: contents; }
.nav-group + .nav-group::before { content: ''; flex: none; width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.nav-label { display: none; }
.nav-item {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nav-item:hover { color: var(--text); }
.nav-item b { font-weight: 500; font-size: .84rem; opacity: .7; font-variant-numeric: tabular-nums; }
.nav-item[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.nav-edit { border-style: dashed; background: none; }
.nav-edit .icon { width: 16px; height: 16px; }

.day {
  font-size: .72rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--faint);
  padding: 22px 0 6px;
}
.book {
  display: grid; grid-template-columns: 52px 1fr; gap: 16px; align-items: center;
  width: 100%; text-align: left;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  content-visibility: auto; contain-intrinsic-size: auto 106px;
  transition: opacity .15s ease;
}
.book:active { opacity: .6; }
.book:last-child { border-bottom: none; }
.book-text { min-width: 0; }
.book-title {
  font-family: var(--serif); font-size: 1.09rem; font-weight: 500; line-height: 1.25; letter-spacing: -.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-author { color: var(--muted); font-size: .92rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { color: var(--faint); font-size: .8rem; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta.flag { color: var(--accent); display: flex; align-items: center; gap: 6px; }
.book-meta.flag .icon { width: 14px; height: 14px; }
.book-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
}
.no-results { color: var(--muted); text-align: center; padding: 48px 12px; text-wrap: balance; }

/* Cover thumbnails, with a typographic placeholder underneath */
.cover {
  position: relative; overflow: hidden;
  width: 52px; aspect-ratio: 2 / 3; border-radius: 4px;
  background: hsl(var(--h, 30) 22% 26%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3), inset 0 0 0 1px rgba(255, 255, 255, .06);
  display: grid; place-items: center; flex: none;
}
[data-theme="light"] .cover { background: hsl(var(--h, 30) 30% 80%); box-shadow: 0 1px 3px rgba(60, 40, 20, .25); }
.cover::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 8%; background: rgba(0, 0, 0, .14); }
.cover span { font-family: var(--serif); font-style: italic; font-size: 1.5rem; color: hsl(var(--h, 30) 40% 78%); }
[data-theme="light"] .cover span { color: hsl(var(--h, 30) 35% 32%); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.cover.lg { width: 72px; }
.cover.lg span { font-size: 2rem; }

/* Empty state */
.empty { text-align: center; padding: 9dvh 12px 0; max-width: 360px; margin: 0 auto; }
.empty-art { width: 168px; margin: 0 auto 26px; }
.art-muted { stroke: var(--faint); }
.art-accent { stroke: var(--accent); }
.empty h2 { font-family: var(--serif); font-weight: 460; font-size: 1.55rem; letter-spacing: -.015em; }
.empty p { color: var(--muted); margin-top: 10px; }

/* Floating scan button */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 36px 20px calc(var(--safe-b) + 22px);
  display: flex; justify-content: center;
  background: linear-gradient(to top, var(--bg) 45%, transparent);
  pointer-events: none;
}
.fab {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 30px 0 26px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; font-size: 1.04rem; letter-spacing: .005em;
  box-shadow: var(--shadow);
  transition: background .15s ease, transform .15s ease;
}
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: scale(.97); }

/* ───────────── Buttons & form bits ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 999px;
  font-weight: 600; font-size: 1rem;
  transition: background .15s ease, opacity .15s ease, border-color .15s ease;
}
.btn .icon { width: 19px; height: 19px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover, .btn-outline:active { background: var(--surface-2); }
.btn-quiet { color: var(--muted); padding: 0 12px; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.btn-row > .btn-quiet { flex: none; }
.btn { white-space: nowrap; }
.card-actions .btn-narrow { flex: 0 1 auto; padding: 0 20px; }
.sheet-actions {
  position: sticky; bottom: 0; z-index: 1;
  padding: 18px 0 calc(var(--safe-b) + 22px); margin: 4px 0 calc(-1 * (var(--safe-b) + 22px));
  background: linear-gradient(to top, var(--surface) 78%, transparent);
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .76rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1.02rem; outline: none; resize: none;
  transition: border-color .15s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field .serif { font-family: var(--serif); font-size: 1.14rem; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { color: var(--danger); font-size: .88rem; margin: -6px 0 12px; }

/* ───────────── Bottom sheet ───────────── */
.backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, .55);
  opacity: 0; transition: opacity .22s ease;
}
.backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 680px; margin: 0 auto;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(102%);
  transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 10px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 20px calc(var(--safe-b) + 22px); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-title { font-family: var(--serif); font-size: 1.5rem; font-weight: 460; letter-spacing: -.015em; line-height: 1.15; }
.sheet-sub { color: var(--muted); font-size: .93rem; margin-top: 4px; }
.sheet-head .icon-btn { margin: -8px -10px 0 0; flex: none; }
.sheet-head .cover { margin-top: 2px; }
.sheet-section { margin-top: 26px; }
.sheet-section > h3 { font-size: .76rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.sheet-note { color: var(--muted); font-size: .88rem; margin-top: 8px; }
.sheet-note a { color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Choosing and managing lists */
.pick-row + .pick-row { margin-top: 12px; }
.pick-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.list-picker .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.list-picker .field { margin: 16px 0 0; }
.form-lists { margin: 6px 0 18px; }
.sheet-done { margin-top: 22px; }
.list-rows { margin: -6px 0 18px; }
.list-row { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); }
.list-name { flex: 1; min-width: 0; padding: 13px 0; text-align: left; }
.list-name span { display: block; font-family: var(--serif); font-size: 1.09rem; font-weight: 500; }
.list-name small { display: block; color: var(--faint); font-size: .8rem; }
.list-name small:empty { display: none; }
.list-row .icon-btn:disabled { opacity: .3; }

/* Account (optional sync) */
.account-line { font-size: 1rem; }
.account-line strong { font-weight: 600; }
.account-status { margin: 4px 0 14px; }
.account-status.is-error { color: var(--danger); }
.account-form .field-error { margin-top: -2px; }

/* Candidate list */
.cand-list { margin: -6px 0 16px; }
.cand .book-title { -webkit-line-clamp: 3; }
.badge {
  display: inline-block; vertical-align: 2px; margin-right: 8px;
  font-family: var(--sans); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px;
}

/* Cover-text chips */
.ocr { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 18px; }
.ocr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ocr-head > span { font-size: .84rem; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { padding: 5px 14px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--muted); transition: background .15s ease, color .15s ease; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: .92rem; text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.chip:active { border-color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.swap { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .86rem; font-weight: 600; margin: -4px 0 12px; padding: 6px 0; }
.swap .icon { width: 15px; height: 15px; }

/* ───────────── Scanner ───────────── */
.scanner {
  position: fixed; inset: 0; z-index: 20;
  background: #0b0a09; color: #f3efe8;
  overflow: hidden;
  animation: scannerIn .22s ease both;
  --finder-w: min(78vw, 340px);
  --finder-h: calc(var(--finder-w) * .56);
  --finder-y: 38%;
}
.scanner[data-mode="cover"] {
  --finder-w: min(70vw, 44dvh, 340px);
  --finder-h: calc(var(--finder-w) * 1.5);
  --finder-y: 41%;
}
@keyframes scannerIn { from { opacity: 0; } to { opacity: 1; } }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.finder {
  position: absolute; left: 50%; top: var(--finder-y);
  width: var(--finder-w); height: var(--finder-h);
  transform: translate(-50%, -50%);
  border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgba(8, 7, 6, .58);
  transition: width .3s cubic-bezier(.2, .8, .2, 1), height .3s cubic-bezier(.2, .8, .2, 1), top .3s ease;
}
.scanner.no-camera .finder { display: none; }
.corner { position: absolute; width: 26px; height: 26px; border: 3px solid #e0a458; }
.corner.tl { left: -2px; top: -2px; border-right: none; border-bottom: none; border-radius: 18px 0 0 0; }
.corner.tr { right: -2px; top: -2px; border-left: none; border-bottom: none; border-radius: 0 18px 0 0; }
.corner.bl { left: -2px; bottom: -2px; border-right: none; border-top: none; border-radius: 0 0 0 18px; }
.corner.br { right: -2px; bottom: -2px; border-left: none; border-top: none; border-radius: 0 0 18px 0; }
.laser {
  position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #e0a458, transparent);
  animation: laser 2.2s ease-in-out infinite;
}
@keyframes laser { 0%, 100% { transform: translateY(-34px); opacity: .25; } 50% { transform: translateY(34px); opacity: .9; } }
.scanner[data-mode="cover"] .laser, .scanner.busy .laser { display: none; }
.scanner.hit .corner { border-color: #9cc594; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.scan-msg {
  position: absolute; left: 0; right: 0; top: 22%;
  padding: 0 36px; text-align: center;
}
.scan-msg .icon { width: 34px; height: 34px; color: #e0a458; margin: 0 auto 14px; }
.scan-msg h2 { font-family: var(--serif); font-weight: 460; font-size: 1.4rem; }
.scan-msg p { color: #b5ada1; margin-top: 8px; font-size: .96rem; }

.scan-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 14px) 16px 0;
}
.glass-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(20, 18, 16, .55); color: #f3efe8;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: background .15s ease, color .15s ease;
}
.glass-btn[aria-pressed="true"] { background: #e0a458; color: #1d1508; }
#torchBtn { grid-column: 3; }
.scan-target {
  justify-self: center; min-width: 0; max-width: 100%;
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 8px 0 14px; border-radius: 999px;
  background: rgba(20, 18, 16, .55); color: #f3efe8;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: .9rem; font-weight: 600;
}
.scan-target .icon { width: 16px; height: 16px; }
.scan-target span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }
.scan-count {
  flex: none; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center;
  background: #e0a458; color: #1d1508;
  font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

.scan-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 48px 16px calc(var(--safe-b) + 22px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(to top, rgba(8, 7, 6, .82) 30%, transparent);
}
.scan-hint { font-size: .95rem; color: #d9d2c6; text-align: center; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); min-height: 1.5em; }
.scan-controls { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; max-width: 420px; }
.scanner[data-mode="barcode"] .for-cover, .scanner[data-mode="cover"] .for-barcode { display: none; }
.for-cover { justify-content: space-between; }
.for-cover .glass-pill { flex: 1; max-width: 124px; }
.glass-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px; border-radius: 999px;
  background: rgba(20, 18, 16, .55); color: #f3efe8;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-weight: 600; font-size: .93rem; white-space: nowrap;
  transition: background .15s ease;
}
.glass-pill .icon { width: 18px; height: 18px; }
.glass-pill:active, .glass-btn:active { background: rgba(60, 54, 46, .7); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 3px solid #f3efe8; display: grid; place-items: center; flex: none; transition: transform .12s ease, opacity .15s ease; }
.shutter span { width: 60px; height: 60px; border-radius: 50%; background: #f3efe8; transition: transform .12s ease; }
.shutter:active span { transform: scale(.9); }
.shutter:disabled { opacity: .4; }

/* Result card inside the scanner */
.scan-card { width: 100%; max-width: 460px; }
.scan-card:empty { display: none; }
.card {
  position: relative;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  animation: cardIn .26s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.card-main { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.card-main.solo { grid-template-columns: 1fr; }
.card-status { display: flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.card-status .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.card-status.ok { color: var(--ok); }
.card-status.warn { color: var(--accent); }
.card-title { font-family: var(--serif); font-size: 1.14rem; font-weight: 500; line-height: 1.22; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 26px; }
.card-sub { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.card-meta { color: var(--faint); font-size: .8rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions .btn { flex: 1; min-height: 46px; font-size: .95rem; padding: 0 14px; }
.card-x { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); }
.card-x .icon { width: 18px; height: 18px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-busy { display: flex; align-items: center; gap: 12px; }
.card-busy .card-title { font-family: var(--sans); font-size: 1rem; padding: 0; }
.progress { height: 3px; border-radius: 2px; background: var(--border); margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

/* ───────────── Toast ───────────── */
.toast {
  position: fixed; z-index: 50; left: 50%; top: calc(var(--safe-t) + 18px);
  transform: translate(-50%, -16px); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 22px;
  background: var(--text); color: var(--bg);
  font-size: .93rem; font-weight: 500;
  box-shadow: var(--shadow);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 640px) {
  .app { padding-left: 28px; padding-right: 28px; padding-top: calc(var(--safe-t) + 44px); }
  .sheet { border-radius: 24px 24px 0 0; }
  .lists { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; }
}
/* Wide screens: the lists become a sidebar beside the books. */
@media (min-width: 900px) {
  .app {
    max-width: 1020px;
    display: grid; grid-template-columns: 216px minmax(0, 1fr); column-gap: 56px; align-content: start;
    grid-template-rows: auto auto auto 1fr;   /* the last row takes up whatever the sidebar is taller by */
  }
  .top { grid-column: 1 / -1; grid-row: 1; }
  .search { grid-column: 2; grid-row: 2; }
  .library { grid-column: 2; grid-row: 3; }
  .empty { grid-column: 2; grid-row: 4; }
  .lists {
    grid-column: 1; grid-row: 2 / span 3; align-self: start;
    position: sticky; top: 28px;
    flex-direction: column; align-items: stretch; gap: 2px;
    margin: 0; padding: 0; overflow: visible;
  }
  .nav-group { display: flex; flex-direction: column; gap: 2px; }
  .nav-group + .nav-group { margin-top: 18px; }
  .nav-group + .nav-group::before { content: none; }
  .nav-label {
    display: block; padding: 0 12px 6px;
    font-size: .72rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--faint);
  }
  .nav-item {
    justify-content: space-between; height: 40px; padding: 0 12px;
    border: none; border-radius: var(--radius-sm); background: none; font-size: .98rem;
  }
  .nav-item:hover { background: var(--surface); }
  .nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); }
  .nav-item[aria-current="page"] b { color: var(--accent); opacity: 1; }
  .nav-edit { justify-content: flex-start; color: var(--faint); font-size: .9rem; }
  .day:first-child { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
