:root {
  /* Base */
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #8a8a8a;
  --line: #ececec;
  --line-warm: #d8d4c8;
  --hover: #f7f6f3;
  --accent: #1a1a1a;

  /* Surfaces */
  --surface: #fafaf7;
  --surface-warm: #f3f1ec;
  --surface-gold: #faf6ed;

  /* Danger */
  --danger: #b04444;
  --danger-hover: #8e3333;

  /* Gold / favorite */
  --gold: #c9a25c;
  --gold-bg: #faf6ed;
  --gold-text: #6a4a14;

  /* Muted shades */
  --muted-mid: #b8b3a8;
  --muted-light: #c8c2b5;

  /* Dropdown menu (shared) */
  --menu-shadow: 0 14px 36px rgba(0,0,0,0.14);
  --menu-padding-v: 6px;
  --menu-item-padding: 12px 18px;
  --menu-font-size: 12px;
  --menu-letter-spacing: 0.14em;

  /* Trigger control (shared — cat, status, loan) */
  --trigger-bg: #ffffff;
  --trigger-radius: 4px;
  --trigger-font-size: 10px;
  --trigger-letter-spacing: 0.24em;
  --trigger-padding: 7px 12px;

  /* Eyebrow labels */
  --eyebrow-size: 10px;
  --eyebrow-spacing: 0.24em;

  /* Typography tokens */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Special Elite', 'Courier New', monospace;
  --weight-display: 300;
  --weight-title: 400;
  --label-spacing: 0.18em;
  --line-height-reading: 1.65;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ---------- Masthead ---------- */
.masthead {
  text-align: center;
  padding: 120px 48px 64px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.32em;
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 28px;
}

.title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 72px;
  letter-spacing: -0.02em;
  line-height: 1;
}

.title-meta {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 22px;
  color: var(--muted);
  margin-top: 18px;
  letter-spacing: 0.01em;
}
.title-meta:empty { display: none; }

/* ---------- Controls ---------- */
.controls {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 64px 80px;
}

.search-wrap {
  position: relative;
  max-width: 480px;
  margin: 0 auto 56px;
}

.search-icon {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 0 14px 28px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s ease;
}

#search::placeholder {
  color: var(--muted);
  font-weight: 300;
}

#search:focus { border-bottom-color: var(--ink); }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 400;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--ink);
}

.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.chip--add {
  padding: 10px 14px;
  color: var(--muted);
  border-style: dashed;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  letter-spacing: 0;
}
.chip--add:hover {
  color: var(--ink);
  border-color: var(--ink);
  border-style: solid;
}

/* ---------- New category modal ---------- */
.new-cat-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}
.new-cat-modal[hidden] { display: none; }

.new-cat-card {
  background: var(--paper);
  border-radius: 16px;
  padding: 28px 28px 24px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.new-cat-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.new-cat-input {
  font-family: var(--font-display);
  font-size: 26px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 4px 0 8px;
  width: 100%;
  outline: none;
}
.new-cat-input:focus {
  border-bottom-color: var(--ink);
}

.new-cat-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.new-cat-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}
.new-cat-btn--cancel {
  background: transparent;
  color: var(--muted);
}
.new-cat-btn--cancel:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.new-cat-btn--save {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.new-cat-btn--save:hover {
  opacity: 0.85;
}
.new-cat-btn--save:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- Filter trigger + panel ---------- */
.filter-area {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 14px;
}
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 400;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.filter-trigger:hover { border-color: var(--ink); }
.filter-trigger.has-filters { border-color: var(--ink); background: var(--ink); color: #fff; }
.filter-trigger .filter-caret { transition: transform 0.2s; }
.filter-trigger[aria-expanded="true"] .filter-caret { transform: rotate(180deg); }
.filter-trigger .filter-icon { color: inherit; flex-shrink: 0; }
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.filter-count[hidden] { display: none; }

.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  max-width: 92vw;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.04);
  z-index: 30;
  padding: 24px 28px 20px;
  animation: rise 0.22s ease;
}
.filter-panel[hidden] { display: none; }
.filter-group { margin-bottom: 22px; }
.filter-group:last-of-type { margin-bottom: 16px; }
.filter-eyebrow {
  font-size: var(--eyebrow-size);
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pills button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 400;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.filter-pills button:hover { border-color: var(--ink); }
.filter-pills button.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.filter-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}
.filter-footer button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.filter-footer button:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Shelf ---------- */
.shelf {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 64px 120px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 72px 56px;
}

.book {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.book:hover { transform: translateY(-4px); }

.cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--surface-warm);
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 12px 28px rgba(0,0,0,0.06);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease;
}

.book:hover .cover {
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 20px 40px rgba(0,0,0,0.10);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface-warm) 0%, #e8e5de 50%, var(--surface-warm) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.cover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px dashed var(--line-warm);
  color: var(--muted);
  text-align: center;
}

.cover-empty .plus {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
}

.cover-empty .label {
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

/* ---------- Minimal sketch cover ---------- */
.sketch-cover {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8% 10%;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease;
}
.sketch-cover::before {
  content: "";
  position: absolute;
  inset: 6% 8%;
  border: 0.5px solid currentColor;
  opacity: 0.4;
  pointer-events: none;
}
.sketch-cover::after {
  content: "";
  position: absolute;
  inset: 10% 12%;
  border-top: 0.5px solid currentColor;
  border-bottom: 0.5px solid currentColor;
  opacity: 0.25;
  pointer-events: none;
}
.sketch-cover .sketch-text {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sketch-cover .sketch-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
}
.sketch-cover .sketch-rule {
  width: 24px;
  height: 0.5px;
  background: currentColor;
  opacity: 0.5;
}
.sketch-cover .sketch-author {
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  opacity: 0.65;
  word-break: break-word;
}
/* Always-visible action strip pinned to the bottom of the sketch (modal only) */
.sketch-cover .sketch-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 2;
  border-top: 1px solid var(--line);
}
.sketch-cover .sketch-actions button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: 8px 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.sketch-cover .sketch-actions button + button {
  border-top: 1px solid var(--line);
}
.sketch-cover .sketch-actions button:hover { background: var(--hover); }

/* Leave room so the title isn't covered by the action strip */
.book-head-cover .sketch-cover:has(.sketch-actions) .sketch-text { transform: translateY(-22px); }

/* Bigger title in modal cover */
.book-head-cover .sketch-cover .sketch-title { font-size: 18px; }
.book-modal.expanded .book-head-cover .sketch-cover .sketch-title { font-size: 22px; }

.book-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 6px;
  padding: 0 4px;
}

.book-author {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  padding: 48px 24px 64px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 36px;
  align-items: center;
}
.foot-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.foot-link:hover { color: var(--ink); border-bottom-color: var(--ink); }
.foot-link.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Archive view banner */
.archive-banner {
  text-align: center;
  padding: 24px;
  margin: 0 auto 48px;
  max-width: 1280px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* ---------- Book detail modal ---------- */
.book-modal[hidden] { display: none; }
.book-card {
  background: #fff;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.2);
  animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 0 56px 56px;
  transition: max-width 0.3s ease, max-height 0.3s ease, padding 0.3s ease;
}

/* Expanded full-page mode */
.book-modal.expanded { padding: 0; align-items: stretch; }
.book-modal.expanded .book-card {
  max-width: 100%;
  max-height: 100vh;
  height: 100vh;
  box-shadow: none;
  padding: 32px 14% 80px;
}
.book-modal.expanded .notes-editor { min-height: 360px; }
.book-modal.expanded .book-head-cover { width: 160px; }
.book-modal.expanded .book-head-cover .cover { width: 160px; height: 240px; }
.book-modal.expanded .book-head-title { font-size: 42px; }
.book-modal.expanded .book-head-meta { max-width: 560px; }

.book-card-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  margin: 0 -8px 20px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 6;
  padding: 14px 8px 12px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
/* "Save" close button — appears only when the modal opened from a fresh add */
/* Also shared by .edit-save-btn */
.fresh-save-btn,
.edit-save-btn {
  padding: 9px 22px;
  font-size: 11px;
  letter-spacing: var(--label-spacing);
}

.book-card-bar.scrolled {
  border-bottom-color: var(--line);
}

/* Mini info nested inside the bar, fades in when scrolled */
.bar-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
  min-width: 0;
  flex: 1;
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.book-card-bar.scrolled .bar-mini {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.mini-cover {
  width: 32px;
  height: 48px;
  background: var(--surface-warm);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  flex-shrink: 0;
  overflow: hidden;
}
.mini-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-text { min-width: 0; }
.mini-title {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}
.mini-author {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  max-width: 360px;
}

.more-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1px solid var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.more-link:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* When more-link is the menu trigger, anchor dropdown under it */
.kebab-wrap .kebab-menu { left: 0; right: auto; top: calc(100% + 8px); }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.icon-btn:hover { color: var(--ink); background: var(--hover); }

.kebab-wrap { position: relative; }
.kebab-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  box-shadow: var(--menu-shadow);
  min-width: 180px;
  padding: var(--menu-padding-v) 0;
  z-index: 5;
  animation: rise 0.18s ease;
}
.kebab-menu[hidden] { display: none; }
.kebab-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--menu-font-size);
  letter-spacing: var(--menu-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: var(--menu-item-padding);
  cursor: pointer;
  transition: background 0.15s;
}
.kebab-menu button:hover { background: var(--hover); }
.kebab-menu button.danger { color: var(--danger); }

.book-head {
  display: flex;
  gap: 36px;
  align-items: flex-start;
  padding-bottom: 32px;
  transform-origin: top;
  transition:
    max-height 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.65s cubic-bezier(0.16, 1, 0.3, 1),
    margin 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 800px;
  overflow: hidden;
}
.book-head.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  opacity: 0;
  transform: translateY(-14px);
  pointer-events: none;
}

.bar-mini {
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.book-head-meta {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
  max-width: 420px;
}
.book-head-cat {
  display: inline-block;
  font-size: 10px;
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-warm);
  border-radius: 999px;
  padding: 4px 12px;
  margin-top: 18px;
  margin-bottom: 0;
}
.book-head-cat:empty { display: none; }
.book-head-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.book-head-author {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0;
}
.book-head-star {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}
.book-head-star[hidden] { display: none; }

/* ---------- Status + Loan side-by-side card ---------- */
.book-meta-cols {
  display: flex;
  gap: 0;
  margin-top: 24px;
  align-items: stretch;
  flex-wrap: wrap;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
}
.book-meta-col {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* Shared eyebrow label style */
.status-eyebrow,
.loan-eyebrow {
  display: block;
  font-size: var(--eyebrow-size);
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---------- Unified trigger — one definition used by status, loan, and cat ---------- */
.field-trigger,
.status-pill,
.loan-kind-trigger,
.cat-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  background: var(--trigger-bg);
  border: none;
  border-radius: var(--trigger-radius);
  padding: var(--trigger-padding);
  font-family: inherit;
  font-size: var(--trigger-font-size);
  letter-spacing: var(--trigger-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-appearance: none;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}
.field-trigger:hover,
.status-pill:hover,
.loan-kind-trigger:hover,
.cat-trigger:hover { box-shadow: inset 0 0 0 1px var(--line); }

.field-trigger.open,
.status-pill.open,
.loan-kind-trigger.open,
.cat-trigger.open,
.cat-trigger:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--ink); }

/* Cat trigger keeps a min-width in edit mode context */
.cat-trigger { min-width: 180px; }

/* ---------- Status ---------- */
.status-row { }
.status-pill-label { display: inline-flex; align-items: center; gap: 6px; }
.status-caret { transition: transform 0.2s; flex-shrink: 0; }
.status-pill.open .status-caret { transform: rotate(180deg); }

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted-mid);
  flex-shrink: 0;
}
.status-pill.reading .status-dot { background: var(--gold); }
.status-pill.read    .status-dot { background: #4f7a4f; }
.status-pill.paused  .status-dot { background: #b8b8b8; }
.status-pill.unset .status-dot {
  background: transparent;
  border: 1px solid var(--muted-mid);
}

/* Status menu — identical style to .cat-menu */
.status-menu {
  position: fixed;
  background: #fff;
  box-shadow: var(--menu-shadow);
  min-width: 0;
  padding: var(--menu-padding-v) 0;
  z-index: 100;
  animation: rise 0.18s ease;
}
.status-menu[hidden] { display: none; }
.status-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--menu-font-size);
  letter-spacing: var(--menu-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: var(--menu-item-padding);
  cursor: pointer;
  transition: background 0.15s;
}
.status-menu button:hover { background: var(--hover); }
.status-menu button.selected { background: var(--ink); color: #fff; }
.status-menu .status-clear {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.04em;
}
.status-menu .status-clear:hover { color: var(--ink); background: var(--hover); }

/* ---------- Loan row ---------- */
.loan-row { }
.loan-edit { display: flex; flex-direction: column; gap: 8px; }
.loan-edit input {
  font-family: inherit;
  font-size: 13px;
  font-weight: 300;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.loan-edit input:focus { border-color: var(--ink); }
.loan-edit .btn-ghost, .loan-edit .btn-solid { padding: 8px 14px; font-size: 11px; }
.loan-edit input { width: 100%; box-sizing: border-box; }
.loan-actions { display: flex; gap: 8px; align-items: center; }

/* Loan kind custom picker */
.loan-kind-picker { position: relative; width: 100%; }
.loan-kind-caret { transition: transform 0.2s; flex-shrink: 0; }
.loan-kind-trigger.open .loan-kind-caret { transform: rotate(180deg); }

.loan-kind-menu {
  position: fixed;
  background: #fff;
  box-shadow: var(--menu-shadow);
  min-width: 0;
  padding: var(--menu-padding-v) 0;
  z-index: 100;
  animation: rise 0.18s ease;
}
.loan-kind-menu[hidden] { display: none; }
.loan-kind-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--menu-font-size);
  letter-spacing: var(--menu-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: var(--menu-item-padding);
  cursor: pointer;
  transition: background 0.15s;
}
.loan-kind-menu button:hover { background: var(--hover); }
.loan-kind-menu button.selected { background: var(--ink); color: #fff; }

.book-head-cover {
  position: relative;
  width: 120px;
  flex-shrink: 0;
}
.book-head-cover .cover {
  width: 120px;
  height: 180px;
  margin: 0;
}
.cover-change-btn {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.6);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.book-head-cover:hover .cover-change-btn:not([hidden]) { opacity: 1; }

/* Edit-mode cover actions — sit below the cover thumbnail, only visible
   when in edit mode AND the book has an actual cover image (not a sketch). */
.cover-edit-actions {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  align-items: flex-start;
}
.book-modal.editing .book-head-cover[data-has-cover="true"] .cover-edit-actions {
  display: flex;
}
.cover-edit-actions button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s;
}
.cover-edit-actions button:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.cover-edit-actions button.danger { color: var(--danger); }
.cover-edit-actions button.danger:hover {
  color: var(--danger-hover);
  border-bottom-color: var(--danger-hover);
}

/* Confirm row */
.confirm-row[hidden] { display: none; }

/* ---------- In-place edit mode ---------- */
.book-modal.editing .book-head-title,
.book-modal.editing .book-head-author {
  outline: none;
  background: var(--surface);
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 4px;
  cursor: text;
  transition: background 0.2s ease;
}
.book-modal.editing .book-head-title:focus,
.book-modal.editing .book-head-author:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.book-modal.editing .book-head-author:empty::before {
  content: "Enter author name";
  color: var(--muted-mid);
  pointer-events: none;
}

.book-modal.editing .book-head-cat { display: none; }
.book-modal.editing .cat-picker { display: block; }

/* Align all edit-mode controls to full width */
.book-modal.editing .cat-trigger,
.book-modal.editing .status-pill,
.book-modal.editing .loan-kind-trigger { width: 100%; box-sizing: border-box; }
.book-modal.editing .status-row,
.book-modal.editing .loan-kind-picker { width: 100%; }

/* In full edit mode, the main Save button handles loan — hide inline Cancel/Save */
.book-modal.editing .loan-actions { display: none !important; }
/* Stack loan picker + name input vertically and full-width */
.book-modal.editing .loan-edit    { flex-direction: column; align-items: stretch; }
.book-modal.editing .loan-edit #loan-name { width: 100%; box-sizing: border-box; }

/* Custom category picker (dropdown-based) — only shown in edit mode */
.cat-picker { position: relative; margin: 18px 0 14px -8px; }
.cat-picker[hidden] { display: none; }

.cat-trigger svg { transition: transform 0.2s; }
.cat-trigger.open svg { transform: rotate(180deg); }

.cat-menu {
  position: fixed;   /* coordinates set in JS so the menu escapes the modal's overflow:hidden */
  background: #fff;
  box-shadow: var(--menu-shadow);
  min-width: 0;
  padding: var(--menu-padding-v) 0;
  z-index: 100;
  animation: rise 0.18s ease;
  max-height: 60vh;
  overflow-y: auto;
}
.cat-menu[hidden] { display: none; }
.cat-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--menu-font-size);
  letter-spacing: var(--menu-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: var(--menu-item-padding);
  cursor: pointer;
  transition: background 0.15s;
}
.cat-menu button:hover { background: var(--hover); }
.cat-menu button.selected { background: var(--ink); color: #fff; }
.cat-menu .cat-create-trigger {
  border-top: 1px solid var(--line);
  font-style: italic;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.04em;
}
.cat-menu .cat-create-trigger:hover { color: var(--ink); }

.cat-create {
  position: fixed;
  background: #fff;
  box-shadow: var(--menu-shadow);
  padding: 14px 16px;
  z-index: 100;
  display: flex;
  gap: 6px;
  align-items: center;
  animation: rise 0.18s ease;
}
.cat-create[hidden] { display: none; }
.cat-create input {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  padding: 7px 10px;
  outline: none;
  min-width: 180px;
}
.cat-create input:focus { border-color: var(--ink); }
.cat-create button {
  background: var(--ink);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.cat-create button#bm-cat-create-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* Edit-mode toolbar swap (Cancel link + Save solid button) */
.edit-cancel-link, .edit-save-btn {
  display: none;
}
.book-modal.editing .edit-cancel-link,
.book-modal.editing .edit-save-btn {
  display: inline-flex;
  align-items: center;
}
.book-modal.editing .more-link:not(.edit-cancel-link),
.book-modal.editing #book-expand,
.book-modal.editing #book-close,
.book-modal.editing #bm-cover-change { display: none; }

/* Pending-delete mode — hide normal controls, show delete/cancel */
.book-modal.pending-delete .kebab-wrap,
.book-modal.pending-delete #book-expand,
.book-modal.pending-delete #book-close { display: none; }
#pending-delete-cancel,
#pending-delete-confirm { display: none; }
.book-modal.pending-delete #pending-delete-cancel { display: inline-flex; }
.book-modal.pending-delete #pending-delete-confirm { display: inline-flex; }

.confirm-row {
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 52px;                       /* sits right below the sticky bar */
  z-index: 7;
  margin: 0 -56px 0;               /* break out of card's horizontal padding */
  padding: 14px 56px;
  background: rgba(176,68,68,0.06);
  font-size: 12px;
  color: var(--danger-hover);
  animation: rise 0.25s ease;
}
.confirm-row[hidden] { display: none; }
.confirm-row span { flex: 1; }
.btn-solid.danger,
.btn-solid--danger { background: var(--danger); border-color: var(--danger); }
.btn-solid.danger:hover,
.btn-solid--danger:hover { background: var(--danger-hover); }

/* ---------- Notes (free-form editor) ---------- */
.notes-section {
  padding-top: 36px;
  position: relative;
}
.notes-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--eyebrow-size);
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.notes-save-state {
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  color: var(--muted);
  font-style: italic;
  text-transform: none;
  opacity: 0;
  transition: opacity 0.4s;
}
.notes-save-state.visible { opacity: 1; }

/* ---------- Record area (sits between title and editor) ---------- */
.notes-record-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px 7px 12px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.record-btn:hover { color: var(--ink); border-color: var(--ink); }
.record-btn.recording {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  animation: pulse-ink 1.2s infinite;
}
.record-btn-label { line-height: 1; }
@keyframes pulse-ink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,26,26,0.35); }
  50% { box-shadow: 0 0 0 5px rgba(26,26,26,0); }
}

/* Listening indicator that sits next to the mic when recording */
.listening-pill {
  display: none;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--ink);
}
.listening-pill.visible { display: inline-flex; }
.listening-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  animation: pulse-dot 1s infinite;
}
.listening-pill .bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.listening-pill .bars span {
  width: 2px;
  background: var(--ink);
  animation: bar 0.9s ease-in-out infinite;
}
.listening-pill .bars span:nth-child(1) { animation-delay: 0s; }
.listening-pill .bars span:nth-child(2) { animation-delay: 0.15s; }
.listening-pill .bars span:nth-child(3) { animation-delay: 0.3s; }
.listening-pill .bars span:nth-child(4) { animation-delay: 0.45s; }
@keyframes bar {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* Editor */
.notes-editor {
  min-height: 240px;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: var(--line-height-reading);
  font-weight: 300;
  color: var(--ink);
  outline: none;
  padding: 4px 2px 20px;
  caret-color: var(--ink);
}
.notes-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-mid);
  font-style: italic;
  pointer-events: none;
}
.notes-editor h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  margin: 18px 0 8px;
  line-height: 1.2;
}
.notes-editor blockquote {
  border-left: 2px solid var(--line);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
}
.notes-editor ul, .notes-editor ol {
  padding-left: 22px;
  margin: 10px 0;
}
.notes-editor li { margin-bottom: 4px; }
.notes-editor p { margin: 0 0 12px; }
.notes-editor b, .notes-editor strong { font-weight: 500; }
.notes-editor a { color: var(--ink); text-decoration: underline; }

/* Sticky compact input bar at the bottom of the modal */
.notes-input-bar {
  position: sticky;
  bottom: -56px;
  margin: 24px -56px -56px;
  padding: 28px 56px 22px;
  background-image: url('torn-paper.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  z-index: 3;
  min-height: 96px;
}
.notes-input-bar::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  height: 36px;
  pointer-events: none;
  background: linear-gradient(to top, #fff, rgba(255,255,255,0));
}

.notes-input-bar textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  color: #2a2a2a;
  outline: none;
  resize: none;
  padding: 4px 0;
  max-height: 120px;
  overflow-y: auto;
}
.notes-input-bar textarea::placeholder { color: var(--muted); font-style: italic; }

.mic-btn, .send-btn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}
.mic-btn:hover, .send-btn:hover { color: var(--ink); background: var(--hover); }
.send-btn { background: var(--ink); color: #fff; }
.send-btn:hover { background: #000; color: #fff; transform: scale(1.05); }
.mic-btn.recording {
  color: #fff;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(176,68,68,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(176,68,68,0); }
}

/* Plain right-aligned notes */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 4px 0 12px;
}
.note {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  max-width: 80%;
  align-self: flex-end;
  animation: noteIn 0.25s ease;
}
@keyframes noteIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.note-text {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: var(--line-height-reading);
  color: var(--ink);
  font-weight: 300;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: text;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background 0.15s;
}
.note-text:hover { background: var(--hover); }
.note-text[contenteditable="true"] {
  background: var(--surface);
  outline: 1px solid var(--line);
  cursor: text;
  text-align: right;
}
.note-text[contenteditable="true"]:focus { outline-color: var(--ink); }

.note-date {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
}

.note-delete {
  position: absolute;
  top: -2px;
  left: -28px;
  background: none;
  border: none;
  color: var(--muted-light);
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  padding: 2px 6px;
  line-height: 1;
}
.note:hover .note-delete { opacity: 1; }
.note-delete:hover { color: var(--danger); }

.notes-empty {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

/* ---------- Smart search modal extras ---------- */
.ai-info {
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 24px;
  font-size: 12px;
  line-height: var(--line-height-reading);
  color: var(--muted);
  border-left: 2px solid var(--line);
}
.ai-info p { margin: 0; }
.ai-info p + p { margin-top: 10px; }
.ai-info strong { color: var(--ink); font-weight: 500; }
.ai-info a { color: var(--ink); text-decoration: underline; }

.provider-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 2px;
  vertical-align: 1px;
  font-weight: 500;
}
.tag-free { background: #e3eedb; color: #3a5d2a; }
.tag-paid { background: #f0e8df; color: #7a5320; }

/* Provider hint shown below the API key input */
.ai-key-hint {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 0 0;
  min-height: 14px;
}
.ai-key-hint:empty { display: none; }

/* ---------- Smart search results panel ---------- */
.ai-results {
  max-width: 1280px;
  margin: 24px auto 56px;
  padding: 0 64px;
  animation: rise 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.ai-results[hidden] { display: none; }
/* When smart picks are visible, suppress the shelf's "Nothing on this shelf" message */
body:has(#ai-results:not([hidden])) #shelf > div[style*="Nothing"] { display: none; }
.ai-results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.ai-results-eyebrow {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-results-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.ai-results-close:hover { color: var(--ink); }
.ai-results-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
}
.ai-pick {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  cursor: pointer;
  transition: transform 0.25s ease;
}
.ai-pick:hover { transform: translateY(-2px); }
.ai-pick-cover {
  width: 64px;
  height: 96px;
  flex-shrink: 0;
  background: var(--surface-warm);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 18px rgba(0,0,0,0.06);
}
.ai-pick-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-pick-text { flex: 1; min-width: 0; }
.ai-pick-title {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
}
.ai-pick-author {
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.ai-pick-reason {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  line-height: var(--line-height-reading);
}

/* Loading + empty + error states */
.ai-results-loading,
.ai-results-empty {
  text-align: center;
  padding: 28px 0 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--muted);
}
.ai-results-loading::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--ink);
  animation: blink 1.2s infinite;
  vertical-align: middle;
}
@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* Inline prompt in the search area when AI is off and user types a mood query */
.ai-nudge {
  max-width: 480px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: var(--surface-gold);
  border-left: 2px solid var(--gold);
  font-size: 12px;
  color: var(--gold-text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-nudge[hidden] { display: none; }
.ai-nudge button {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  border-bottom: 1px solid var(--ink);
}

/* ---------- Shelf context menu ---------- */
.ctx-menu {
  position: fixed;
  background: #fff;
  box-shadow: var(--menu-shadow);
  min-width: 180px;
  padding: var(--menu-padding-v) 0;
  z-index: 80;
  animation: rise 0.16s ease;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: var(--menu-font-size);
  letter-spacing: var(--menu-letter-spacing);
  text-transform: uppercase;
  color: var(--ink);
  padding: var(--menu-item-padding);
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger { color: var(--danger); }

/* Favorite star on shelf */
.book .fav-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--gold);
  font-size: 14px;
}
.cover { position: relative; }

/* ---------- Add tile ---------- */
.add-tile .cover {
  background: var(--surface);
  border: 1px dashed var(--line-warm);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  transition: all 0.25s ease;
}
.add-tile:hover .cover {
  border-color: var(--ink);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 20px 40px rgba(0,0,0,0.08);
}
.add-tile .plus {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 300;
  line-height: 1;
}
.add-tile .label {
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
}

/* ---------- Delete confirmation modal ---------- */
.delete-modal { z-index: 80; }
.delete-card {
  background: #fff;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: rise 0.2s ease;
}
/* .btn-danger removed — use .btn-solid--danger instead */

.delete-body { padding: 28px 24px 20px; }
.delete-book-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 10px;
}
.delete-message {
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  margin: 0 0 20px;
  line-height: var(--line-height-reading);
}
.delete-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--line);
}

.delete-notes-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  max-height: 140px;
}
.delete-notes-preview::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}
.delete-notes-content {
  font-size: 13px;
  font-weight: 300;
  color: var(--muted);
  line-height: var(--line-height-reading);
  overflow: hidden;
  max-height: 90px;
}
.delete-notes-content * { margin: 0; }
.delete-notes-open {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 1;
}
.delete-notes-open:hover { color: var(--ink); }

/* ---------- Delete undo toast ---------- */
.delete-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  z-index: 200;
  animation: rise 0.22s ease;
  white-space: nowrap;
}
.delete-toast[hidden] { display: none; }
.delete-toast-msg { opacity: 0.85; }
#undo-delete-btn {
  background: none;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fade 0.25s ease;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 460px;
  padding: 56px 56px 48px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.18);
  animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 8px;
}
.modal-close:hover { color: var(--ink); }

/* Modal frame: positioned wrapper that anchors the close button to the card's corner */
.modal-frame {
  position: relative;
  width: 100%;
}
.frame-narrow { max-width: 460px; }
.frame-wide   { max-width: 760px; }

/* Close button sitting outside the modal card, at its top-right corner */
.modal-close-outside {
  position: absolute;
  top: -52px;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: 50%;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 60;
}
.modal-close-outside:hover { background: #fff; transform: scale(1.05); }

.modal-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 36px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 32px;
}

.field {
  display: block;
  margin-bottom: 24px;
}
.field span {
  display: block;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0.05em;
  opacity: 0.6;
}
.field input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 8px 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease;
}
.field input:focus { border-bottom-color: var(--ink); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 36px;
}

.btn-ghost, .btn-solid {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  font-weight: 400;
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--ink); }

.btn-solid {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}
.btn-solid:hover { background: #000; }
.btn-solid:disabled { opacity: 0.5; cursor: wait; }

.modal-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
  min-height: 16px;
  text-align: right;
}
.modal-status.error { color: var(--danger); }

/* ---------- Duplicate notice ---------- */
.dup-notice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  margin-top: 8px;
  background: var(--surface-gold);
  border-left: 2px solid var(--gold);
  animation: rise 0.25s ease;
}
.dup-notice[hidden] { display: none; }
.dup-thumb {
  width: 36px;
  height: 52px;
  flex-shrink: 0;
  background: var(--surface-warm);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dup-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dup-label {
  font-size: var(--eyebrow-size);
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 4px;
}
.dup-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink);
  line-height: 1.2;
}

/* ---------- Preview ---------- */
.preview {
  display: block;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.preview[hidden] { display: none; }
.preview-body {
  display: flex;
  gap: 28px;
  align-items: center;
}
.preview-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  margin-bottom: 28px;
  background: var(--surface-gold);
  border-left: 3px solid var(--gold);
  color: var(--gold-text);
}
.preview-banner[hidden] { display: none; }
.preview-banner svg { color: var(--gold); flex-shrink: 0; margin-top: 2px; }
.preview-banner-title {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
}
.preview-banner-sub {
  font-size: 12px;
  color: var(--gold-text);
}
.preview-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 32px;
}
.preview-cover {
  width: 120px;
  flex-shrink: 0;
}
.preview-cover .cover {
  width: 120px;
  height: 180px;
  margin: 0;
}
.preview-meta { flex: 1; min-width: 0; }
.preview-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 6px;
}
.preview-author {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}
.preview-stamp {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink);
  border-top: 1px solid var(--ink);
  padding-top: 10px;
  animation: stamp 0.4s 0.2s both;
}
.preview-stamp.exists {
  color: var(--gold-text);
  border-top-color: var(--gold);
}
.preview-note {
  color: var(--muted);
  margin-top: 16px;
  font-style: italic;
  font-family: var(--font-display);
  font-size: 16px;
}
@keyframes stamp {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .shelf { grid-template-columns: repeat(4, 1fr); gap: 56px 40px; padding: 24px 48px 100px; }
}
@media (max-width: 860px) {
  .masthead { padding: 80px 32px 48px; }
  .title { font-size: 52px; }
  .controls { padding: 16px 32px 64px; }
  .shelf { grid-template-columns: repeat(3, 1fr); gap: 48px 32px; padding: 24px 32px 80px; }
}
@media (max-width: 560px) {
  .title { font-size: 40px; }
  .shelf { grid-template-columns: repeat(2, 1fr); gap: 40px 24px; padding: 24px 24px 64px; }
}

/* ========================================================
   Onboarding CTA + Modal
   ======================================================== */

/* CTA banner */
.onboarding-cta {
  max-width: 1280px;
  margin: -16px auto 0;
  padding: 0 64px 48px;
}
.ob-cta-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface-warm);
  border: 1px solid var(--line-warm);
  border-radius: 8px;
  padding: 18px 20px 18px 24px;
  position: relative;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ob-cta-glyph { flex-shrink: 0; line-height: 0; }
.ob-cta-copy { flex: 1; min-width: 0; }
.ob-cta-headline {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 3px;
}
.ob-cta-body {
  display: block;
  font-size: 13px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.5;
}
.ob-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s;
}
.ob-cta-btn:hover { background: #000; }
.ob-cta-dismiss {
  position: absolute;
  top: 10px; right: 12px;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  padding: 4px; line-height: 0;
  border-radius: 3px;
  transition: color 0.2s;
}
.ob-cta-dismiss:hover { color: var(--ink); }

/* Onboarding modal */
.ob-modal { z-index: 55; }
.ob-card {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  padding: 44px 52px 52px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.22);
  animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ob-card-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
  line-height: 0;
}
.ob-card-close:hover { color: var(--ink); background: var(--hover); }

/* Progress dots */
.ob-progress { display: flex; gap: 6px; margin-bottom: 36px; }
.ob-dot {
  height: 5px; width: 5px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.3s ease, width 0.3s ease;
}
.ob-dot--active { background: var(--ink); width: 20px; }

/* Shared pane styles */
.ob-eyebrow {
  font-size: 10px;
  letter-spacing: var(--eyebrow-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.ob-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 10px;
}
.ob-sub {
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 28px;
}
.ob-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}
.ob-found-num { color: var(--gold-text); }

/* Pane 1 — name */
.ob-name-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 300;
  color: var(--ink);
  border: none;
  border-bottom: 2px solid var(--ink);
  padding: 6px 0 8px;
  outline: none;
  background: transparent;
  letter-spacing: -0.01em;
}
.ob-name-input::placeholder { color: var(--muted-mid); }

/* Pane 2 — photo slots */
.ob-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.ob-slot {
  position: relative;
  aspect-ratio: 4/3;
  border: 1.5px dashed var(--line-warm);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}
.ob-slot:not(.ob-slot--locked):not(.ob-slot--filled):hover {
  border-color: var(--muted);
  background: var(--hover);
}
.ob-slot--locked { opacity: 0.35; cursor: not-allowed; }
.ob-slot--filled { border-style: solid; border-color: var(--line); cursor: default; }
.ob-slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}
.ob-slot--filled .ob-slot-inner { display: none; }
.ob-slot-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ob-slot-del {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  background: rgba(26,26,26,0.72);
  color: #fff; border: none;
  border-radius: 50%;
  font-size: 15px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  transition: background 0.2s;
}
.ob-slot-del:hover { background: var(--danger); }

/* API key */
.ob-key-section { margin-bottom: 4px; }
.ob-key-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.ob-key-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
  text-transform: none;
  letter-spacing: 0.04em;
}
.ob-key-link:hover { color: var(--ink); border-bottom-color: var(--ink); }
.ob-key-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 8px 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
  letter-spacing: 0.04em;
}
.ob-key-input:focus { border-bottom-color: var(--ink); }
.ob-key-input.ob-key-error { border-bottom-color: var(--danger); }

/* Pane 3 — scan animation */
.ob-pane--scan { text-align: center; padding: 16px 0 8px; }
.ob-shelf-anim {
  position: relative;
  height: 110px; width: 260px;
  margin: 0 auto 32px;
}
.ob-shelf-row {
  display: flex;
  align-items: flex-end;
  gap: 5px; height: 100%;
  padding-bottom: 8px;
}
.ob-spine {
  width: 22px;
  height: var(--h, 72px);
  background: var(--c, #f5f1e8);
  border-radius: 2px 2px 0 0;
  flex-shrink: 0;
  animation: ob-spine-pulse 2s ease-in-out infinite;
}
.ob-spine:nth-child(1) { animation-delay: 0s; }
.ob-spine:nth-child(2) { animation-delay: 0.22s; }
.ob-spine:nth-child(3) { animation-delay: 0.44s; }
.ob-spine:nth-child(4) { animation-delay: 0.66s; }
.ob-spine:nth-child(5) { animation-delay: 0.88s; }
.ob-spine:nth-child(6) { animation-delay: 1.1s; }
.ob-spine:nth-child(7) { animation-delay: 1.32s; }
.ob-spine:nth-child(8) { animation-delay: 1.54s; }
@keyframes ob-spine-pulse {
  0%, 70%, 100% { opacity: 0.55; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-6px); }
}
.ob-shelf-base {
  position: absolute;
  bottom: 0; left: -8px; right: -8px;
  height: 7px;
  background: var(--line-warm);
  border-radius: 2px;
}
.ob-scan-beam {
  position: absolute;
  top: 0; bottom: 8px;
  left: 0; width: 2px;
  background: linear-gradient(to bottom, transparent, var(--gold) 40%, var(--gold) 60%, transparent);
  opacity: 0;
  animation: ob-beam 2.4s ease-in-out infinite;
}
@keyframes ob-beam {
  0% { left: 0; opacity: 0; }
  8% { opacity: 0.95; }
  92% { opacity: 0.95; }
  100% { left: calc(100% - 2px); opacity: 0; }
}
.ob-scan-status {
  font-size: 13px; font-weight: 300;
  color: var(--muted); margin-top: 6px;
  font-style: italic; min-height: 20px;
}

/* Pane 4 — book review */
.ob-book-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 8px;
  border-top: 1px solid var(--line);
}
.ob-book-list::-webkit-scrollbar { width: 3px; }
.ob-book-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.ob-book-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  animation: ob-book-in 0.3s ease both;
}
@keyframes ob-book-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
.ob-book-num {
  width: 22px; font-size: 10px; color: var(--muted);
  flex-shrink: 0; text-align: right;
  font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
}
.ob-book-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ob-book-title, .ob-book-author {
  border: none; background: transparent;
  font-family: inherit; outline: none;
  color: var(--ink); width: 100%;
  padding: 3px 6px; border-radius: 3px;
  transition: background 0.15s;
}
.ob-book-title { font-size: 14px; font-weight: 400; }
.ob-book-author { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.ob-book-title:hover, .ob-book-author:hover { background: var(--hover); }
.ob-book-title:focus, .ob-book-author:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.ob-book-remove {
  background: none; border: none;
  color: var(--muted-light); cursor: pointer;
  font-size: 18px; line-height: 1;
  padding: 3px 7px; border-radius: 3px; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.ob-book-remove:hover { color: var(--danger); background: var(--hover); }
.ob-add-missing {
  background: none; border: none; font-family: inherit;
  font-size: 11px; letter-spacing: var(--label-spacing);
  text-transform: uppercase; color: var(--muted);
  cursor: pointer; padding: 10px 0;
  border-bottom: 1px solid transparent; display: block;
  transition: color 0.2s, border-color 0.2s;
}
.ob-add-missing:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* Responsive */
@media (max-width: 860px) {
  .onboarding-cta { padding: 0 32px 40px; }
  .ob-card { padding: 36px 32px 40px; }
  .ob-title { font-size: 28px; }
}
@media (max-width: 560px) {
  .onboarding-cta { padding: 0 24px 32px; }
  .ob-cta-inner { flex-wrap: wrap; }
  .ob-cta-btn { width: 100%; justify-content: center; }
  .ob-card { padding: 28px 24px 32px; max-height: 100vh; }
}
