/* ---------- Tokens (Vasari paper) ---------- */
:root {
  --display: 'Newsreader', Georgia, serif;
  --body: 'Newsreader', Georgia, serif;
  --mono: 'Inter Tight', system-ui, sans-serif;
  --sans: 'Inter Tight', system-ui, sans-serif;
  --ease: cubic-bezier(.2,.8,.2,1);
  --bg: #F0E8D4;
  --paper: #F0E8D4;
  --sheet: #F7F0DD;
  --card: #F7F0DD;
  --ink: #2b2418;
  --ink-soft: #4a3f2e;
  --muted: #8a7e64;
  --border: #d8cdb1;
  --border-strong: #2b2418;
  --rule: rgba(43,36,24,.9);
  --cobalt: #B5472B;
  --accent: #B5472B;
  --accent-soft: #F3DDD0;
  --accent-fg: #ffffff;
  --shelf-wood: #a98758;
  --shelf-wood-dark: #6a4a28;
  --shadow: 0 1px 0 rgba(40,28,14,0.04), 0 2px 12px rgba(40,28,14,0.06);
  --shadow-lg: 0 4px 24px rgba(40,28,14,0.14), 0 1px 2px rgba(40,28,14,0.08);
}

/* grain + labels */
.grain { position: fixed; inset: 0; z-index: 40; pointer-events: none; mix-blend-mode: multiply; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27220%27%20height%3D%27220%27%3E%3Cfilter%20id%3D%27n%27%20x%3D%270%27%20y%3D%270%27%20width%3D%27100%25%27%20height%3D%27100%25%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.85%27%20numOctaves%3D%273%27%20stitchTiles%3D%27stitch%27/%3E%3CfeColorMatrix%20values%3D%270%200%200%200%20.45%200%200%200%200%20.42%200%200%200%200%20.38%200%200%200%20.44%200%27/%3E%3C/filter%3E%3Crect%20width%3D%27100%25%27%20height%3D%27100%25%27%20filter%3D%27url%28%23n%29%27/%3E%3C/svg%3E");
  background-size: 220px 220px; }
.lbl { font-family: var(--sans); font-weight: 600; font-size: 10.5px; line-height: 1; letter-spacing: .09em; text-transform: uppercase; }
.box { display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border: 1px solid var(--rule); }

/* custom cursor (fine pointers) */
.cur { display: none; position: fixed; left: 0; top: 0; width: 58px; height: 58px; margin: -29px 0 0 -29px; z-index: 100; pointer-events: none; will-change: transform; }
@media (pointer: fine) {
  .cur { display: block; }
  html, body, button, a, .shelf-item, .book-cover { cursor: none; }
}
.cur .ring { position: absolute; inset: 0; border: 1.5px solid var(--ink); border-radius: 50%; background: transparent; transition: transform .5s var(--ease), background-color .4s var(--ease), border-color .4s var(--ease); }
.cur .dot { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--ink); transition: transform .4s var(--ease); }
.cur .lab { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-family: var(--sans); font-weight: 600; font-size: 10px; line-height: 1.25; letter-spacing: .1em; color: #fff; transform: scale(0); transition: transform .45s var(--ease); }
.cur.spine .ring { transform: scale(.72); }
.cur.btn .ring { transform: scale(.55); }
.cur.btn .dot { transform: scale(0); }
.cur.open .ring { transform: scale(1.75); background: var(--cobalt); border-color: var(--cobalt); }
.cur.open .dot { transform: scale(0); }
.cur.open .lab { transform: scale(1); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
#root { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; color: inherit; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.muted { color: var(--muted); }

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}

[data-density="compact"] .app { padding: 24px 32px 60px; }

/* ---------- Typography ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.library-title, .detail-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--ink);
  text-wrap: balance;
}
[data-density="compact"] .library-title { font-size: 44px; }

.library-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.section-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 16px;
  font-weight: 500;
}

.section-body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 64ch;
  text-wrap: pretty;
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-shop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  transition: all 150ms ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-soft); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--card); border-color: var(--border-strong); color: var(--ink); }
.btn-copied, .btn-copied:hover { background: #1e7a4a; border-color: #1e7a4a; color: #fff; }

.btn-icon { padding: 6px; width: 32px; justify-content: center; }


.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-add-link {
  font-style: italic;
  color: var(--muted);
  border-style: dashed;
}

/* ---------- Library header ---------- */
.library-header { margin-bottom: 40px; }
.library-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.library-actions { display: flex; gap: 10px; }

.library-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 240px;
  color: var(--muted);
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--ink);
  flex: 1;
}
.search-box input::placeholder { color: var(--muted); font-style: italic; }

.genre-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  transition: all 120ms ease;
}
.chip:hover { border-color: var(--border-strong); }
.chip-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- Shelves ---------- */
.shelves { display: flex; flex-direction: column; gap: 56px; }

.shelf-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.shelf-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink);
}
.shelf-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.shelf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 28px;
  align-items: flex-start;
}
.shelf-row-compact { gap: 24px 18px; }

.shelf-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 124px;
  cursor: pointer;
}
.shelf-row-compact .shelf-item { width: 64px; }

.shelf-meta { font-size: 13px; line-height: 1.3; }
.shelf-row-compact .shelf-meta { display: none; }
.shelf-meta-title {
  font-family: var(--body);
  color: var(--ink);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shelf-meta-author {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  margin-top: 1px;
}

.shelf-board {
  position: relative;
  height: 16px;
  margin-top: 24px;
  background: linear-gradient(
    to bottom,
    var(--shelf-wood) 0%,
    var(--shelf-wood-dark) 100%
  );
  border-radius: 3px 3px 6px 6px;
  box-shadow: 
    /* Top edge highlights for a 3D bevel effect */
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    /* Shadow under the top lip */
    inset 0 2px 2px rgba(255, 255, 255, 0.1),
    /* Shadow at the bottom rim to give depth */
    inset 0 -1.5px 0 rgba(0, 0, 0, 0.45),
    /* Heavy drop shadow to give distance from the back wall */
    0 5px 8px rgba(0, 0, 0, 0.16),
    /* Soft ambient shadow below */
    0 12px 24px rgba(0, 0, 0, 0.12);
}

/* 3D top plane of the shelf */
.shelf-board::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 2px;
  right: 2px;
  height: 4px;
  background: var(--shelf-wood);
  opacity: 0.9;
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

/* Subtle wood texture pattern overlay */
.shelf-board::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.03) 25%,
    rgba(0, 0, 0, 0) 50%,
    rgba(0, 0, 0, 0.03) 75%,
    rgba(0, 0, 0, 0) 100%
  );
  pointer-events: none;
  border-radius: 4px;
}

.shelf-empty {
  font-style: italic;
  color: var(--muted);
  padding: 24px 0;
  font-size: 14px;
}

.borrow-tag {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 4px;
}

.shelf-expand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 150ms ease;
}
.shelf-expand:hover { background: var(--card); border-style: solid; color: var(--ink); }
.shelf-expand-arrow { font-size: 13px; }

/* progress + stars (in shelf cards) */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
}
.stars { font-size: 11px; letter-spacing: 1px; color: var(--border-strong); margin-top: 4px; }
.star-on { color: var(--accent); }

/* ---------- Book detail ---------- */
.detail-topbar { margin-bottom: 24px; }

.detail-hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 56px;
  align-items: flex-start;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.detail-cover-wrap { position: relative; }
.detail-cover-shadow {
  position: absolute;
  bottom: -16px;
  left: 8%;
  right: 8%;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.18), transparent 70%);
  filter: blur(4px);
  z-index: -1;
}

.detail-meta { padding-top: 8px; }

.detail-title {
  font-size: 52px;
  letter-spacing: -0.012em;
  margin-bottom: 6px;
}
.detail-author {
  font-family: var(--body);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 28px;
}

.status-pills { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.status-pill {
  font-family: var(--body);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  transition: all 120ms ease;
}
.status-pill:hover { border-color: var(--border-strong); }
.status-pill-on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.detail-progress {
  margin-bottom: 24px;
  max-width: 480px;
}
.detail-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.detail-progress-fill { height: 100%; background: var(--accent); transition: width 200ms ease; }
.detail-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}
.rating-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.stars-large { display: flex; gap: 4px; }
.star-btn {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 22px;
  color: var(--border-strong);
  transition: color 100ms ease;
  cursor: pointer;
}
.star-btn:hover { color: var(--accent); }
.star-btn.star-on { color: var(--accent); }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0 0 32px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.meta-grid > div { display: flex; flex-direction: column; gap: 4px; }
.meta-grid dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.meta-grid dd { margin: 0; font-family: var(--body); font-size: 15px; color: var(--ink); }

.shop-row { margin-top: 0; }

.borrow-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-radius: 16px;
  padding: 5px 12px;
  margin-bottom: 24px;
}
.borrow-note svg { color: var(--accent); }

.category-editor {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.category-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 7px;
  flex-shrink: 0;
  width: 88px;
}
.category-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--body);
  font-size: 13px;
  padding: 5px 10px 5px 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.cat-chip-x {
  background: transparent;
  border: none;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  color: var(--accent);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 100ms ease;
}
.cat-chip-x:hover { opacity: 1; }
.cat-chip-add {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  font-style: italic;
  cursor: pointer;
  padding: 4px 12px;
}
.cat-chip-add:hover { color: var(--ink); border-color: var(--ink-soft); }
.cat-chip-input {
  font-family: var(--body);
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--paper);
  outline: none;
  color: var(--ink);
  min-width: 140px;
}

/* ── Shop links ───────────────────────────────────────────── */
.shop-links {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.shop-links-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  align-items: center;
}
.shop-link-row {
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  transition: all 150ms ease;
}
.shop-link-row:hover { border-color: var(--border-strong); }
.shop-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
}
.shop-btn-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.shop-btn-label {
  font-weight: 500;
}
.affiliate-tag-sm {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg);
}
.shop-btn-ext { color: var(--muted); }
.shop-btn-x {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  font-size: 16px;
  line-height: 1;
  padding: 0 10px;
  color: var(--muted);
  cursor: pointer;
  transition: all 100ms ease;
}
.shop-btn-x:hover { background: var(--bg); color: #b14a3a; }

.shop-add-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.shop-add-form input[type="url"] {
  flex: 1;
  min-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-size: 13px;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
}
.shop-add-form input[type="url"]:focus { border-color: var(--accent); }
.shop-add-label {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-size: 13px;
  font-family: var(--body);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.reading-since {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 24px;
  font-style: italic;
}
.shop-link { display: flex; align-items: center; gap: 12px; }
.btn-shop {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: background 150ms ease;
}
.btn-shop:hover { background: var(--ink-soft); }
.affiliate-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.12);
  margin-left: 6px;
}

.shop-edit {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 520px;
}
.shop-edit input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  font-size: 14px;
  outline: none;
}
.shop-edit input:focus { border-color: var(--accent); }

/* ---------- Detail tabs ---------- */
.detail-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.detail-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--body);
  font-size: 14px;
  padding: 10px 16px;
  color: var(--muted);
  transition: all 120ms ease;
  margin-bottom: -1px;
}
.detail-tab:hover { color: var(--ink-soft); }
.detail-tab-on {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.detail-body { padding-bottom: 60px; }
.detail-section { max-width: 720px; }

.ai-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ai-header .section-title { margin: 0; }
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: auto;
}
.ai-badge-saved {
  background: oklch(0.92 0.05 145);
  color: oklch(0.40 0.13 145);
}

.ai-generating {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 15px;
}


.ai-empty {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  margin-right: 8px;
}
.spinner-lg { width: 24px; height: 24px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.review-body {
  font-size: 17px;
  line-height: 1.7;
  font-family: var(--body);
}
.review-textarea {
  width: 100%;
  padding: 16px;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  resize: vertical;
  outline: none;
  color: var(--ink);
}
.review-textarea:focus { border-color: var(--accent); }

.highlight {
  margin: 0 0 20px;
  padding: 18px 20px;
  border-left: 3px solid var(--accent);
  background: var(--card);
  border-radius: 0 6px 6px 0;
}
.highlight p {
  margin: 0;
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink);
}
.highlight cite {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  font-style: normal;
  color: var(--muted);
}
.highlight-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.link-danger {
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
}
.link-danger:hover { color: #b14a3a; }

.highlight-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}
.highlight-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--display);
  font-size: 16px;
  font-style: italic;
  resize: vertical;
  outline: none;
  color: var(--ink);
}
.highlight-form-row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.highlight-form-row input {
  width: 80px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}

/* ── Comments ───────────────────────────────────────────── */
.comments-count {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 10px;
  margin-left: auto;
}

.comment-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 28px;
}
.comment-form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.comment-name {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  font-family: var(--body);
  font-size: 14px;
  outline: none;
  color: var(--ink);
}
.comment-name:focus { border-color: var(--accent); }
.comment-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  color: var(--ink);
}
.comment-textarea:focus { border-color: var(--accent); }
.comment-form-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 12px;
}
.comment-help {
  font-size: 12px;
  font-style: italic;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.comment-empty {
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}
.comment {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.comment-body { min-width: 0; position: relative; }
.comment-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}
.comment-author {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}
.comment-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.comment-text {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.comment-remove {
  margin-top: 8px;
  opacity: 0;
  transition: opacity 120ms ease;
}
.comment:hover .comment-remove { opacity: 0.7; }
.comment-remove:hover { opacity: 1 !important; }
@media (hover: none) {
  .comment-remove { opacity: 0.5; }
}

/* ---------- Comment foot / reply toggle ---------- */
.comment-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.reply-toggle {
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 120ms;
}
.reply-toggle:hover { color: var(--ink); }

/* ---------- Comment replies (public) ---------- */
.comment-reply {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
}
.comment-reply-admin {
  background: var(--paper);
  border-left: 2px solid var(--accent);
}
.comment-reply-visitor {
  background: var(--paper);
  border-left: 2px solid var(--border);
}
.comment-reply-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.comment-reply-name {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.comment-reply-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
}
.comment-reply-time {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Reply form (inline) ---------- */
.reply-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reply-name {
  font-size: 13px !important;
  padding: 6px 10px !important;
}
.reply-textarea {
  font-size: 13px !important;
  padding: 8px 10px !important;
}
.reply-form-foot {
  display: flex;
  justify-content: flex-end;
}
.reply-error {
  font-size: 12px;
  color: var(--danger, #c0392b);
}

/* ---------- Admin comments tab ---------- */
.admin-comments {
  padding: 8px 0 40px;
  max-width: 720px;
}
.admin-comments-book {
  margin-bottom: 40px;
}
.admin-comments-book-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.admin-comments-book-title {
  font-weight: 600;
  font-size: 15px;
}
.ac-list { display: flex; flex-direction: column; gap: 0; }
.ac-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.ac-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ac-meta { display: flex; align-items: center; gap: 6px; }
.ac-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.ac-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--ink);
}
.ac-reply {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--paper);
  border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.ac-reply-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ac-reply-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ac-reply-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-reply-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
.btn-xs {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  border: none;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 4, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 180ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--paper);
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalIn 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  color: var(--ink);
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--card); color: var(--ink); }

.add-options { padding: 16px; }
.add-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 150ms ease;
}
.add-option:hover {
  background: var(--card);
  border-color: var(--border-strong);
  transform: translateX(2px);
}
.add-option:last-child { margin-bottom: 0; }
.add-option-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.add-option-text { flex: 1; }
.add-option-title {
  font-family: var(--body);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.add-option-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
}
.add-option-arrow {
  font-size: 18px;
  color: var(--muted);
  transition: transform 150ms ease;
}
.add-option:hover .add-option-arrow { transform: translateX(4px); color: var(--ink); }

.add-flow { padding: 16px 28px 28px; }
.flow-back {
  background: transparent;
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
  margin-bottom: 16px;
  cursor: pointer;
}
.flow-back:hover { color: var(--ink); }
.flow-title {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 20px;
  color: var(--ink);
}
.flow-empty { padding: 24px 0; }
.flow-illustration {
  width: 72px; height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  background: var(--card);
  color: var(--ink-soft);
}
.notion-illu { background: #2f2f2f; color: #fff; }
.flow-loading {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
}
.flow-loading p { margin-top: 16px; font-style: italic; }

.notion-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: oklch(0.55 0.13 145);
  background: oklch(0.95 0.04 145);
  padding: 6px 12px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.notion-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.notion-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms ease;
}
.notion-row:last-child { border-bottom: none; }
.notion-row:hover { background: var(--card); }
.notion-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  cursor: pointer;
}
.notion-row-meta { flex: 1; }
.notion-row-title { font-weight: 500; font-size: 14px; color: var(--ink); }
.notion-row-author { font-size: 12px; color: var(--muted); font-style: italic; }
.notion-row-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.flow-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.flow-success {
  text-align: center;
  padding: 48px 0;
}
.success-mark {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: oklch(0.55 0.13 145);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

/* ISBN scan */
.isbn-camera {
  text-align: center;
  margin-bottom: 20px;
}
.isbn-camera-viewport {
  height: 160px;
  background: #1a1410;
  border-radius: 10px;
  position: relative;
  margin-bottom: 12px;
  overflow: hidden;
  background-image:
    radial-gradient(at 30% 40%, rgba(255,255,255,0.04) 0%, transparent 40%),
    repeating-linear-gradient(90deg, transparent 0, transparent 18px, rgba(255,255,255,0.05) 18px, rgba(255,255,255,0.05) 19px);
}
.isbn-camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.isbn-target {
  width: 180px;
  height: 80px;
  border: 1.5px solid rgba(255,255,255,0.6);
  border-radius: 4px;
  margin-bottom: 14px;
  position: relative;
  box-shadow: 0 0 0 1000px rgba(0,0,0,0.25);
}
.isbn-target::before, .isbn-target::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 1.5px;
  background: oklch(0.7 0.13 38);
}
.isbn-target::before { top: 50%; box-shadow: 0 0 8px oklch(0.7 0.13 38); animation: scan 1.6s ease-in-out infinite; }
.isbn-target::after { display: none; }
@keyframes scan {
  0%, 100% { top: 10%; opacity: 0.4; }
  50% { top: 90%; opacity: 1; }
}

.isbn-divider {
  text-align: center;
  position: relative;
  margin: 24px 0;
}
.isbn-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  border-top: 1px solid var(--border);
}
.isbn-divider span {
  background: var(--paper);
  padding: 0 12px;
  position: relative;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.isbn-manual, .url-input-row {
  display: flex;
  gap: 8px;
}
.isbn-manual input, .url-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  font-size: 14px;
  font-family: var(--mono);
  outline: none;
  color: var(--ink);
}
.isbn-manual input:focus, .url-input-row input:focus { border-color: var(--accent); }

.lookup-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
}
.lookup-meta { padding-top: 4px; }
.lookup-title {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 4px;
}
.lookup-author {
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.lookup-detail {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.lookup-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Stats ---------- */
.stats-header { margin-bottom: 36px; }
.stats-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.year-picker {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.year-pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  transition: all 120ms ease;
  letter-spacing: 0.04em;
}
.year-pill:hover { color: var(--ink); }
.year-pill-on { background: var(--ink); color: var(--paper); }

.author-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.author-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.author-row:last-child { border-bottom: none; }
.author-rank {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  min-width: 24px;
}
.author-name {
  flex: 1;
  font-family: var(--display);
  font-size: 17px;
  color: var(--ink);
  font-weight: 500;
}
.author-count {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.stat-value {
  font-family: var(--display);
  font-size: 52px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat-suffix { font-size: 28px; color: var(--muted); }
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
}
.stat-foot {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stats-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}
.stats-card-wide { grid-column: 1 / -1; }

.pace-track {
  position: relative;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  margin: 24px 0 12px;
  overflow: visible;
  border: 1px solid var(--border);
}
.pace-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 300ms ease;
}
.pace-target {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
}
.pace-marker {
  width: 2px;
  height: 22px;
  background: var(--ink);
}
.pace-marker-label {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.pace-row {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
}
.pace-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 10px;
}
.pace-good { background: oklch(0.92 0.05 145); color: oklch(0.40 0.13 145); }
.pace-bad { background: oklch(0.92 0.05 30); color: oklch(0.45 0.13 30); }

.genre-chart {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-top: 8px;
}
.genre-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.genre-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-label { color: var(--ink); flex: 1; }
.legend-count { color: var(--muted); font-size: 12px; }

.months-chart {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
  margin-top: 16px;
  align-items: end;
}
.month-bar { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.month-bar-track {
  width: 100%;
  height: 100px;
  background: var(--bg);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  border: 1px solid var(--border);
}
.month-bar-fill {
  width: 100%;
  background: var(--accent);
  transition: height 300ms ease;
  min-height: 0;
}
.month-bar-count {
  font-size: 10px;
  color: var(--ink);
  height: 12px;
}
.month-bar-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.top-rated {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.top-rated-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.top-rated-meta { flex: 1; min-width: 0; }
.top-rated-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-rated-author {
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* responsive */
@media (max-width: 880px) {
  .app { padding: 24px 24px 60px; }
  .detail-hero { grid-template-columns: 1fr; gap: 32px; }
  .detail-hero .detail-cover-wrap { margin: 0 auto; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .library-title { font-size: 40px; }
  .detail-title { font-size: 36px; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); gap: 12px 0; }
  .months-chart { gap: 4px; }
}

@media (max-width: 640px) {
  .app { padding: 18px 16px 56px; }
  [data-density="compact"] .app { padding: 14px 12px 48px; }

  /* Header: stack title and actions */
  .library-header { margin-bottom: 28px; }
  .library-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    margin-bottom: 20px;
  }
  .library-title { font-size: 34px; }
  [data-density="compact"] .library-title { font-size: 28px; }
  .library-sub { font-size: 13px; }
  .library-actions {
    width: 100%;
    gap: 8px;
  }
  .library-actions button { flex: 1; justify-content: center; }

  .library-controls {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 0;
    gap: 12px;
  }
  .search-box { min-width: 0; }
  .genre-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    margin: 0 -16px;
    padding: 0 16px 4px;
    scrollbar-width: none;
  }
  .genre-chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }

  .shelves { gap: 40px; }
  .shelf-header { margin-bottom: 18px; }
  .shelf-title { font-size: 22px; }
  .shelf-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: 20px 12px;
  }
  .shelf-row-compact {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 14px 10px;
  }
  .shelf-item { width: auto; }
  .shelf-row-compact .shelf-item { width: auto; }
  /* Covers fill their grid cell on mobile */
  .shelf-item .book-cover {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 2 / 3 !important;
  }
  .shelf-item .shelf-meta-title { font-size: 12px; }
  .shelf-item .shelf-meta-author { font-size: 11px; }

  /* Detail */
  .detail-topbar { margin-bottom: 16px; }
  .detail-hero { padding-bottom: 24px; margin-bottom: 24px; gap: 24px; }
  .detail-cover-wrap { transform: scale(0.85); transform-origin: top center; }
  .detail-title { font-size: 28px; }
  .detail-author { font-size: 16px; margin-bottom: 20px; }
  .status-pills { gap: 6px; margin-bottom: 18px; }
  .status-pill { font-size: 12px; padding: 6px 12px; }
  .meta-grid { padding: 12px 0; gap: 12px 12px; }
  .meta-grid dd { font-size: 14px; }
  .rating-row { margin-bottom: 22px; }
  .star-btn { font-size: 26px; padding: 4px; }
  .category-editor, .shop-links {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 20px;
  }
  .category-label { width: auto; padding-top: 0; }

  /* Tabs fixed equal-width across full container */
  .detail-tabs {
    overflow-x: visible;
    margin: 0 0 24px;
    padding: 0;
    flex-wrap: nowrap;
  }
  .detail-tab { flex: 1; text-align: center; white-space: nowrap; font-size: 12px; padding: 9px 4px; }
  .detail-body { padding-bottom: 40px; }
  .section-body { font-size: 15px; }
  .highlight p { font-size: 17px; }
  .review-textarea { padding: 12px; font-size: 15px; }

  /* Shop add form wraps */
  .shop-add-form { flex-wrap: wrap; }
  .shop-add-form input[type="url"] { min-width: 0; width: 100%; flex: 1 1 100%; order: 2; }
  .shop-add-form .shop-add-label { order: 1; }
  .shop-add-form > button { order: 3; flex: 1; }

  /* Stats */
  .stats-header { margin-bottom: 28px; }
  .stats-header-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .year-picker { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .year-picker::-webkit-scrollbar { display: none; }
  .year-pill { flex-shrink: 0; }
  .stat-tile { padding: 16px; }
  .stat-value { font-size: 40px; }
  .stat-label { font-size: 9px; margin-top: 8px; }
  .stat-foot { font-size: 11px; }
  .stats-card { padding: 18px; }
  .months-chart { gap: 3px; }
  .month-bar-track { height: 70px; }
  .month-bar-label { font-size: 7px; }
  .pace-marker-label { font-size: 9px; }
  .genre-chart { flex-direction: column; gap: 16px; align-items: stretch; }
  .genre-chart svg { margin: 0 auto; }
  .top-rated { grid-template-columns: 1fr; }

  /* Modal */
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal {
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
    animation: modalInMobile 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
  }
  .modal-header { padding: 18px 20px 14px; }
  .modal-header h2 { font-size: 22px; }
  .add-options { padding: 12px; }
  .add-option { padding: 12px; gap: 12px; }
  .add-option-title { font-size: 15px; }
  .add-option-sub { font-size: 12px; }
  .add-flow { padding: 12px 20px 20px; }
  .flow-title { font-size: 20px; }
  .isbn-manual, .url-input-row { flex-direction: column; }
  .isbn-manual input, .url-input-row input { width: 100%; }
  .isbn-manual button, .url-input-row button { width: 100%; }
  .lookup-result { grid-template-columns: auto 1fr; gap: 14px; }
  .lookup-title { font-size: 20px; }
  .lookup-actions { flex-direction: column-reverse; gap: 8px; }
  .lookup-actions > * { width: 100%; justify-content: center; }

  /* Reading room thicker shelf board feels right on mobile too */
  .shelf-board { height: 12px; margin-top: 16px; }
}

@keyframes modalInMobile {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Loading bar */
.library-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: 2px;
  background: transparent;
}
.library-loading-bar {
  height: 100%;
  background: var(--accent, #8a5a3a);
  animation: loading-slide 1.4s ease-in-out infinite;
  transform-origin: left;
}
@keyframes loading-slide {
  0%   { transform: scaleX(0) translateX(0); }
  50%  { transform: scaleX(0.7) translateX(60%); }
  100% { transform: scaleX(0) translateX(200%); }
}

/* ---------- Admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.admin-header h1 { font-family: var(--display); font-size: 26px; margin: 0; font-weight: 600; }
.admin-header-left { display: flex; align-items: center; gap: 20px; }
.admin-view-tabs { display: flex; gap: 2px; background: var(--paper); border-radius: 8px; padding: 3px; border: 1px solid var(--border); }
.admin-view-tab { height: 28px; padding: 0 14px; border-radius: 6px; border: none; background: transparent; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.admin-view-tab:hover { color: var(--ink); }
.admin-view-tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.admin-toolbar { display: flex; gap: 10px; margin-bottom: 10px; }
.admin-filters { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-tab { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--border); background: transparent; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s; white-space: nowrap; }
.admin-tab:hover { background: var(--paper); color: var(--ink); }
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin-tab-count { font-size: 11px; background: rgba(0,0,0,.1); border-radius: 20px; padding: 0 5px; line-height: 18px; }
.admin-tab.active .admin-tab-count { background: rgba(255,255,255,.25); }
.admin-filter-controls { display: flex; gap: 8px; }
.admin-select { height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--paper); font: inherit; font-size: 13px; color: var(--ink); outline: none; cursor: pointer; }
.admin-select:focus { border-color: var(--accent); }
.admin-search { flex: 1; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--paper); font: inherit; font-size: 14px; outline: none; color: var(--ink); }
.admin-search:focus { border-color: var(--accent); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.admin-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover td { background: var(--paper); }
.admin-title-cell { font-weight: 500; max-width: 260px; }
.admin-actions-row { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.admin-confirm-row { display: flex; gap: 8px; align-items: center; font-size: 13px; white-space: nowrap; }
.admin-loading { padding: 60px; text-align: center; color: var(--muted); }
.admin-layout-toggle { display: flex; gap: 2px; background: var(--paper); border-radius: 8px; padding: 2px; border: 1px solid var(--border); }
.admin-layout-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 26px; border-radius: 6px; border: none; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.admin-layout-btn:hover { color: var(--ink); }
.admin-layout-btn.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.admin-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.admin-card-cover { display: flex; justify-content: center; padding: 12px 12px 8px; background: var(--paper); }
.admin-card-meta { padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-card-title { font-size: 13px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.admin-card-author { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-card-info { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.admin-card-status { font-size: 11px; background: var(--paper); border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px; color: var(--muted); white-space: nowrap; }
.admin-card-stars { font-size: 11px; color: var(--accent); letter-spacing: -.5px; }
.admin-card-actions { display: flex; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--border); flex-wrap: wrap; align-items: center; }

.admin-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.admin-login-box { background: var(--paper); border-radius: 14px; padding: 32px 36px; width: 100%; max-width: 320px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.admin-login-box h2 { margin: 0; font-size: 18px; font-weight: 600; }
.admin-login-error { color: #e53e3e; font-size: 13px; }

.book-form-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.book-form { background: var(--paper); border-radius: 14px; width: 100%; max-width: 580px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.25); }
.book-form-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.book-form-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.book-form-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.book-form-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form-input { height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font: inherit; font-size: 14px; outline: none; color: var(--ink); }
.form-input:focus { border-color: var(--accent); }
.form-textarea { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font: inherit; font-size: 14px; outline: none; resize: vertical; color: var(--ink); }
.form-textarea:focus { border-color: var(--accent); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.author-suggestions { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; max-height: 220px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; border-radius: 8px; border: 1px solid var(--border); background: var(--card); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.author-suggestions li { padding: 7px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--ink); }
.author-suggestions li:hover, .author-suggestions li.active { background: var(--accent); color: #fff; }

/* ---------- Shelf hero (Vasari) ---------- */
body { overflow-x: clip; }
.hs { --H: min(46vh, 31vw); position: relative; height: 100vh; height: 100svh; min-height: 560px; margin: -32px calc(50% - 50vw) 40px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.hs-bar { position: absolute; top: 0; left: 0; right: 0; height: 84px; padding: 0 32px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; z-index: 20; }
.hs-bar > :last-child { justify-self: end; }
.hs-logo { display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--cobalt); }
.hs-logo b { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: -.01em; line-height: 1; }
.hs-logo i { font-style: normal; font-family: var(--sans); font-weight: 600; font-size: 9px; letter-spacing: .34em; padding-left: .34em; text-transform: uppercase; line-height: 1; }
.hs-tabs { position: absolute; left: 50%; top: calc(50% - var(--H)/2 - 86px); transform: translateX(-50%); display: flex; z-index: 20; }
.hs-ind { position: absolute; left: 0; top: 0; height: 23px; width: 0; background: var(--cobalt); transition: width .6s var(--ease), transform .6s var(--ease); pointer-events: none; }
.hs-tabs button { position: relative; height: 23px; padding: 0 11px; border: 1px solid var(--rule); margin-left: -1px; white-space: nowrap; transition: color .45s; display: inline-flex; align-items: center; background: none; color: var(--ink); }
.hs-tabs button:first-of-type { margin-left: 0; }
.hs-tabs button.on { color: #fff; }

.hs-shelf { position: absolute; left: 0; right: 0; top: calc(50% - var(--H)/2 - 40px); height: calc(var(--H) + 80px); perspective: 2200px; perspective-origin: 50% 50%; touch-action: pan-y; z-index: 10; }
.hs-stage { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.hs-tape { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; will-change: transform; }
.hs-face { position: absolute; top: calc(var(--H) / -2); height: var(--H); backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 7px; overflow: hidden; }
.hs-face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: #000; opacity: var(--shade, 0); pointer-events: none; }
.hs-sp { width: var(--ws); border-radius: 7px 0 0 7px; left: calc(var(--ws) / -2); transform: translateZ(calc(var(--d) / 2)); display: flex; flex-direction: column; align-items: center; padding: calc(var(--ws) * .22) 0; gap: calc(var(--ws) * .16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 2px 0 5px rgba(0,0,0,.18); }
.hs-sp-dot { width: calc(var(--ws) * .3); height: calc(var(--ws) * .3); border-radius: 50%; opacity: .85; flex: none; }
.hs-sp-title { flex: 1; min-height: 0; writing-mode: vertical-rl; transform: rotate(180deg); font-family: var(--display); font-weight: 400; line-height: 1.05; text-transform: uppercase; letter-spacing: .02em; text-align: center; overflow: hidden; white-space: nowrap; }
.hs-sp-txt { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: calc(var(--ws) * .12); }
.hs-sp-auth { font-size: calc(var(--ws) * .12); max-width: 92%; text-align: center; line-height: 1.25; overflow-wrap: anywhere; letter-spacing: .06em; opacity: .9; flex: none; }
.hs-cv { border-radius: 0 7px 7px 0; width: var(--d); left: calc(var(--d) / -2); transform: rotateY(90deg) translateZ(calc(var(--ws) / 2)); box-shadow: 0 30px 60px -28px rgba(40,28,14,.55); }
.hs-cv { overflow: visible; }
.hs-cv img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 0 7px 7px 0; }
.hs-cv-fb { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 16% 10%; text-align: center; font-family: var(--display); font-size: calc(var(--d) * .1); line-height: 1.1; text-transform: uppercase; }
.hs-cv-fb i { font-style: normal; font-size: 9px; }


.hs-cap { position: absolute; left: 50%; top: calc(50% + var(--H)/2 + 30px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 9px; pointer-events: none; z-index: 15; }
.hs-cap .m { position: relative; overflow: hidden; text-align: center; width: min(92vw, 760px); }
.hs-cap .m > span { display: block; position: absolute; left: 0; right: 0; top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-cap .t { font-family: var(--display); font-size: 31px; line-height: 1.12; letter-spacing: -.01em; height: 1.12em; }
.hs-cap .s { color: var(--cobalt); font-weight: 500; height: 12px; }
.hs-cap .y { font-weight: 500; height: 12px; }
.hs-empty { font-family: var(--display); font-size: 22px; color: var(--muted); margin-bottom: 8px; }

.hs-arrow { position: absolute; top: calc(50% + var(--H)/2 + 40px); width: 44px; height: 44px; display: grid; place-items: center; z-index: 25; background: none; border: 0; color: var(--ink); }
.hs-arrow svg { width: 18px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.hs-arrow.l { left: 20px; } .hs-arrow.r { right: 20px; }
.hs-foot { position: absolute; left: 32px; right: 32px; bottom: 26px; display: flex; justify-content: space-between; align-items: center; z-index: 20; }
.hs-foot .box { background: none; color: var(--ink); }

@media (max-width: 767px) {
  .hs { --H: min(60vw, 40svh); }
  .hs-bar { height: 64px; padding: 0 16px; grid-template-columns: auto 1fr; }
  .hs-bar > :first-child { display: none; }
  .hs-logo { align-items: flex-start; }
  .hs-logo b { font-size: 19px; }
  .hs-tabs { top: calc(50% - var(--H)/2 - 70px); }
  .hs-tabs button { padding: 0 7px; font-size: 9px; }
  .hs-cap .t { font-size: 24px; }
  .hs-arrow.l { left: 6px; } .hs-arrow.r { right: 6px; }
  .hs-foot { left: 16px; right: 16px; bottom: 18px; }
}

/* ---------- Sheet transition + book detail (Vasari) ---------- */
.sheet-grow { position: fixed; inset: 0; z-index: 39; background: var(--sheet); pointer-events: none; }
[data-view="detail"] body { background: var(--sheet); }
.rise-m { overflow: hidden; }
.rise-m.rise-done { overflow: visible; }
.detail-back { background: none; color: var(--ink); height: 23px; padding: 0 11px; }
.detail-topbar { margin-bottom: 40px; }
.detail-hero { grid-template-columns: 340px 1fr; gap: 64px; border-bottom: 1px solid var(--rule); }
.ink-poster { display: block; width: 100%; height: auto; }
.ink-poster-wait { background: transparent; }
.detail-title { font-weight: 400; font-size: clamp(44px, 5.4vw, 76px); line-height: 1; letter-spacing: -.025em; margin-bottom: 14px; }
.library-title { font-weight: 400; letter-spacing: -.025em; }
.detail-author { font-size: 20px; color: var(--muted); }
.detail .eyebrow { font-family: var(--sans); font-weight: 600; letter-spacing: .09em; color: var(--cobalt); font-size: 10.5px; }
.rating-label, .meta-grid dt, .category-label { font-family: var(--sans); font-weight: 600; letter-spacing: .09em; font-size: 10.5px; }
.meta-grid { border-color: var(--rule); }
.star-btn, .star-btn:hover, .star-btn.star-on { color: var(--cobalt); }
.star-btn { color: var(--border); }
.cat-chip { border-radius: 0; border: 1px solid var(--rule); background: none; font-family: var(--sans); font-weight: 600; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; }
@media (max-width: 767px) {
  .detail-hero { grid-template-columns: 1fr; gap: 28px; }
  .ink-poster, .detail-cover-wrap { max-width: 300px; }
}

/* ---------- Vasari restyle: buttons, forms, cards, modals, stats, comments, admin ---------- */
.btn-primary, .btn-ghost, .btn-shop, .btn-xs, .btn-sm, .modal-close, .shelf-expand,
.admin-tab, .admin-view-tab, .admin-layout-btn, .year-pill, .status-pill, .chip, .reply-toggle {
  border-radius: 0;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.btn-primary, .btn-ghost, .btn-shop { font-size: 10.5px; padding: 0 14px; min-height: 28px; border: 1px solid var(--rule); }
.btn-sm { font-size: 10px; padding: 0 11px; min-height: 24px; }
.btn-xs { font-size: 9.5px; padding: 0 8px; min-height: 21px; }
.btn-primary, .btn-shop { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-primary:hover, .btn-shop:hover { background: #8f3720; border-color: #8f3720; }
.btn-ghost { background: none; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-copied, .btn-copied:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.link-danger { color: #b3261e; font-family: var(--sans); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; font-size: 10px; }

/* pills / chips / tabs: boxed labels with cobalt active state */
.chip, .status-pill, .admin-tab, .admin-view-tab, .year-pill, .admin-layout-btn {
  font-size: 10.5px; height: 23px; padding: 0 11px; display: inline-flex; align-items: center;
  border: 1px solid var(--rule); background: none; color: var(--ink);
}
.chip-on, .status-pill-on, .admin-tab-on, .admin-view-tab-on, .year-pill-on, .admin-layout-btn-on, .admin-tab.on, .admin-view-tab.on, .year-pill.on, .admin-tab.active, .admin-view-tab.active, .admin-layout-btn.active {
  background: var(--cobalt) !important; border-color: var(--cobalt) !important; color: #fff !important;
}
.admin-view-tabs, .admin-layout-toggle, .year-picker { border-radius: 0; border-color: var(--rule); }
.admin-tab-count { border-radius: 0; }
.status-pill, .admin-card-status { border-radius: 0; font-family: var(--sans); letter-spacing: .09em; text-transform: uppercase; font-weight: 600; font-size: 9.5px; }

/* inputs */
.search-box, .admin-search, .admin-select, .form-input, .form-textarea, .comment-name, .comment-textarea,
.review-textarea, .isbn-manual input, .url-input-row input, .highlight-form textarea, .highlight-form-row input,
.shop-edit input, .shop-add-form input[type="url"], .author-suggestions, .author-suggestions li {
  border-radius: 0; border-color: var(--rule); background: var(--sheet); font-family: var(--body);
}
.form-input:focus, .form-textarea:focus, .comment-name:focus, .comment-textarea:focus, .admin-select:focus, .search-box:focus-within {
  outline: 2px solid var(--cobalt); outline-offset: -1px; border-color: var(--cobalt);
}
.form-row label, .form-row-2 label, .form-row-3 label, .form-label, .category-label, .stat-label, .legend-label, .month-bar-label, .pace-marker-label {
  font-family: var(--sans); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; font-size: 10.5px; color: var(--muted);
}

/* cards, tiles, modals */
.stat-tile, .stats-card, .admin-card, .admin-login-box, .modal, .book-form, .add-option, .flow-illustration,
.top-rated-item, .comment-form, .comment-reply, .ac-reply, .highlight, .highlight-form, .notion-list, .ai-badge, .ai-empty, .ai-generating,
.shop-link-row, .shop-add-form, .notion-status, .pace-status, .borrow-note, .borrow-tag, .isbn-camera-viewport {
  border-radius: 0;
}
.stat-tile, .stats-card, .admin-card, .top-rated-item, .add-option { background: var(--sheet); border: 1px solid var(--rule); box-shadow: none; }
.modal, .book-form, .admin-login-box { background: var(--sheet); border: 1px solid var(--ink); box-shadow: 0 30px 60px -28px rgba(40,28,14,.55); }
.modal-backdrop, .book-form-backdrop { background: rgba(240,232,212,.78); }
.modal-header, .book-form-header { border-bottom: 1px solid var(--rule); }
.book-form-footer { border-top: 1px solid var(--rule); }
.add-option:hover { border-color: var(--cobalt); }
.add-option-icon { border-radius: 0; background: var(--cobalt) !important; color: #fff !important; }
.add-option-title, .flow-title, .lookup-title, .admin-card-title, .admin-comments-book-title { font-family: var(--display); font-weight: 400; letter-spacing: -.01em; }
.stat-value { font-family: var(--display); font-weight: 400; letter-spacing: -.025em; color: var(--cobalt); }
.comment-avatar { background: var(--ink) !important; color: var(--paper) !important; }
.comment-reply, .ac-reply, .highlight { border-left: 2px solid var(--cobalt); background: var(--sheet); }
.comment-reply-badge, .admin-reply-badge, .affiliate-tag, .affiliate-tag-sm, .comments-count, .notion-row-tag {
  border-radius: 0; font-family: var(--sans); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; font-size: 9px;
}
.comments-count { border: 1px solid var(--rule); background: none; color: var(--ink); }

/* progress / bars */
.progress-bar, .detail-progress-bar, .pace-track, .month-bar-track { border-radius: 0; }
.progress-fill, .detail-progress-fill, .pace-fill, .month-bar-fill { border-radius: 0; background: var(--cobalt); }
.legend-dot { border-radius: 0; }

/* admin table */
.admin-table th { font-family: var(--sans); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; font-size: 10px; color: var(--muted); }
.admin-table th, .admin-table td { border-color: var(--border); }
.admin-header h1, .admin-login-box h2 { font-family: var(--display); font-weight: 400; letter-spacing: -.025em; }

/* admin auth modal (app.jsx) */
.auth-backdrop { position: fixed; inset: 0; z-index: 9999; background: rgba(240,232,212,.78); display: flex; align-items: center; justify-content: center; }
.auth-form { background: var(--sheet); border: 1px solid var(--ink); padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; min-width: 300px; box-shadow: 0 30px 60px -28px rgba(40,28,14,.55); }
.auth-form .auth-title { font-family: var(--display); font-size: 26px; letter-spacing: -.025em; line-height: 1; }
.auth-form .auth-error { color: #b3261e; font-size: 10.5px; }
.auth-form input { height: 34px; padding: 0 12px; border: 1px solid var(--rule); background: var(--paper); font-family: var(--body); font-size: 15px; outline: none; border-radius: 0; }
.auth-form input:focus { outline: 2px solid var(--cobalt); outline-offset: -1px; border-color: var(--cobalt); }
.auth-form button { height: 30px; background: var(--cobalt); color: #fff; border: 1px solid var(--cobalt); border-radius: 0; font-family: var(--sans); font-weight: 600; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; }

.admin-layout-btn { border: 1px solid var(--rule); width: 28px; height: 25px; }
.admin-view-tab, .admin-layout-btn { margin-left: -1px; }
.admin-view-tab:first-child, .admin-layout-btn:first-child { margin-left: 0; }
.admin-view-tabs, .admin-layout-toggle { gap: 0; padding: 0; background: none; border: 0; }
.admin-view-tab.active, .admin-layout-btn.active { box-shadow: none; }

.author-input-wrap { width: 100%; }
.author-input-wrap input { width: 100%; }
.book-form-header h2, .modal-header h2 { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: -.025em; }
.year-picker { border: 0; padding: 0; background: none; gap: 0; }
.year-pill { margin-left: -1px; }
.year-pill:first-child { margin-left: 0; }

.hs { margin-top: calc(var(--app-pt, 32px) * -1); }
@media (max-width: 880px) { .app { --app-pt: 24px; } }
@media (max-width: 640px) { .app { --app-pt: 18px; } }

/* ---------- mobile fixes (<=640px) ---------- */
.detail-cover-wrap { justify-self: start; width: 100%; max-width: 300px; }
.btn-primary, .btn-ghost, .btn-shop, .admin-tab, .admin-view-tab { white-space: nowrap; }
.year-picker { overflow-x: auto; max-width: 100%; }
@media (max-width: 640px) {
  .admin-header { flex-wrap: wrap; gap: 12px; }
  .admin-header-left { flex-wrap: wrap; gap: 12px; min-width: 0; max-width: 100%; }
  .admin-view-tabs { max-width: 100%; overflow-x: auto; }
  .admin-view-tab { flex: none; }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .admin-table td { white-space: normal; min-width: 120px; }
  .admin-toolbar, .admin-filters { flex-wrap: wrap; }
}
