/* Brand: "Dragonhoard" - soft mauve + amethyst + champagne gold on a near-black
   plum, a premium private-library-at-night feel. Dark mode below is the headline
   experience; light mode is this :root default. Gold is reserved for section/
   field labels, cover underlines, and rating stars (never buttons/pills/tiles).
   (Pride-flag swatch colors live elsewhere and are never themed.) */
:root {
  /* Sticky app-bar height - drives every sticky offset below it. */
  --appbar-h: 83px;
  --bg: #f4f1e9;
  --panel: #ffffff;
  --panel-2: #f0ebe1;
  --surface: #f0ebe1;
  --surface-2: #e7e0d3;
  --ink: #241f2a;
  --muted: #6e6477;
  --faint: #9c917f;
  --accent: #6a45a2;
  --accent-2: #573a87;
  --mauve: #7c5794;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ink: #ffffff;
  --accent-grad: linear-gradient(180deg, #7e57b0, #6a45a2);
  --gold: #9a7a2b;
  --gold-2: #b8923a;
  --border: #e7e0d3;
  --border-soft: #e7e0d3;
  --positive: #2f8a5b;
  --danger: #c0344e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(36, 31, 42, 0.08);
  --shadow-lg: 0 14px 40px rgba(36, 31, 42, 0.18);
  --cover-bg: linear-gradient(160deg, #473468, #291f3e);
  --toast-bg: #241f2a;
  --toast-ink: #f4f1e9;
  --field-bg: #ffffff;
  --field-border: #d9cfbb;
  --field-placeholder: #9c917f;
  --glow: transparent;
  --star-empty: #ddd3c2;
  --cream: #fbf8f2;
  --lilac: #5f5270;
  --font-sans: "Hanken Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    ui-serif, serif;
}

/* Dark mode is the headline experience: a near-black plum base with layered
   mauve-grey surfaces, amethyst accents, soft-mauve highlights, and champagne
   gold reserved for labels and ratings. */
:root[data-theme="dark"] {
  --bg: #16131a;
  --panel: #211b27;
  --panel-2: #2b2433;
  --surface: #2b2433;
  --surface-2: #2b2433;
  --ink: #efe9f2;
  --muted: #a99fb2;
  --faint: #6b6473;
  --accent: #8f63cc;
  --accent-2: #7a52b0;
  --mauve: #b394c4;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-ink: #ffffff;
  --accent-grad: linear-gradient(180deg, #9a6fd4, #7e54bd);
  --gold: #cdb574;
  --gold-2: #dfc98a;
  --border: #382e40;
  --border-soft: #2a2333;
  --positive: #7fc49a;
  --danger: #e2696b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --cover-bg: linear-gradient(160deg, #473468, #291f3e);
  --toast-bg: #2b2433;
  --toast-ink: #efe9f2;
  --field-bg: #211b27;
  --field-border: #382e40;
  --field-placeholder: #8d8398;
  --star-empty: #463b52;
  --lilac: #cbb6dd;
  /* Subtle top glow on the screen background, per the brand spec. */
  --glow: radial-gradient(125% 60% at 50% -12%, #2c2142 0%, #16131a 58%);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--glow), var(--bg);
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

/* Quiet, themed scrollbars so the dark UI stays cohesive. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

h1, h2, h3 { font-family: var(--font-display); }

header.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.app-bar h1 { margin: 0; }
header.app-bar .brand { display: flex; align-items: center; gap: 11px; }
.app-bar-actions { display: flex; align-items: center; gap: 8px; }

.publisher-credit {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font: 500 12px/1.2 var(--font-sans); white-space: nowrap;
}
.publisher-credit strong { color: var(--ink); font-weight: 700; }
.publisher-mark {
  width: 20px; height: 20px; flex: none;
  background: url("/brand/pebbleset-icon-light.svg") center / contain no-repeat;
}
[data-theme="dark"] .publisher-mark,
.login-panel .publisher-mark { background-image: url("/brand/pebbleset-icon-dark.svg"); }
.login-panel .publisher-credit { color: #a99fb2; margin-top: 3px; }
.login-panel .publisher-credit strong { color: #f3eef6; }
.login-panel .publisher-mark { width: 24px; height: 24px; }

/* Login gate (handoff "option C": gold seal on green marble, left login panel) */
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #090f0b url("login-seal.png") center/cover no-repeat;
  display: flex; align-items: center;
}
/* The class rule above would otherwise override the [hidden] attribute, so the
   overlay would never disappear after login. This restores hide-on-hidden. */
.login-overlay[hidden] { display: none; }
/* 95deg dark gradient keeps the left panel legible over the marble seal. */
.login-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(95deg, rgba(9,15,11,.94) 0%, rgba(9,15,11,.72) 33%, rgba(9,15,11,.12) 58%, rgba(9,15,11,.5) 100%);
}
.login-vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 170px 50px rgba(0,0,0,.55); }
.login-stage { position: relative; z-index: 1; display: flex; align-items: center; width: 100%; height: 100%; }
.login-panel { width: 454px; flex: none; padding: 0 58px; box-sizing: border-box; }
.login-lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-appicon { width: 58px; height: 58px; border-radius: 14px; display: block; }
/* The medallion is the full embossed seal (wordmark + tagline baked in), used as
   the login hero in place of the small icon + text lockup. */
.login-medallion {
  width: 116px; height: 116px; border-radius: 50%; display: block;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, 0.6));
}
.login-wordmark { font-family: var(--font-display, "Iowan Old Style", Palatino, Georgia, serif); font-weight: 700; font-size: 24px; color: #f3eef6; line-height: 1; }
.login-title { font-family: var(--font-display, "Iowan Old Style", Palatino, Georgia, serif); font-weight: 700; font-size: 32px; color: #efe9f2; line-height: 1.05; margin: 0; }
.login-sub { color: #a99fb2; font-size: 15px; margin: 7px 0 0; }
.login-fields { display: flex; flex-direction: column; gap: 13px; margin-top: 26px; }
.login-field {
  background: rgba(33,27,39,.72); border: 1px solid #3a2f45; border-radius: 12px;
  padding: 14px 15px; display: flex; align-items: center; gap: 11px;
}
.login-field svg { width: 17px; height: 17px; flex: none; }
.login-field input { flex: 1; background: none; border: 0; outline: none; color: #efe9f2; font: inherit; font-size: 15px; }
.login-field input::placeholder { color: #6b6473; }
.login-show { background: none; border: 0; cursor: pointer; color: #b394c4; font-size: 13px; font-weight: 600; padding: 0; }
.login-submit {
  width: 100%; border: 0; cursor: pointer; border-radius: 13px; padding: 15px; margin-top: 20px;
  font: 600 15px var(--font-ui, "Hanken Grotesk", sans-serif); color: #fff;
  background: var(--accent-grad);
  box-shadow: 0 10px 26px -8px rgba(143,99,204,.6), inset 0 1px 0 rgba(255,255,255,.2);
  transition: filter .15s ease, transform .08s ease, box-shadow .15s ease;
}
.login-submit:hover { filter: brightness(1.07); transform: translateY(-1px); }
.login-submit:active { transform: translateY(0); }
.login-submit:disabled { opacity: .6; cursor: default; filter: none; transform: none; }
.login-submit:focus-visible { outline: 2px solid #b394c4; outline-offset: 2px; }
.login-field:focus-within { border-color: #8f63cc; box-shadow: 0 0 0 2px rgba(143,99,204,.3); }
.login-forgot { display: block; background: none; border: 0; cursor: pointer; color: #b394c4; font-size: 13px; font-weight: 600; margin-top: 14px; padding: 0; }
.login-divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; }
.login-divider span { flex: 1; height: 1px; background: rgba(255,255,255,.08); }
.login-divider em { color: #6b6473; font-size: 12px; font-style: normal; }
.login-sso { display: flex; gap: 12px; }
.login-oauth {
  flex: 1; cursor: pointer; border-radius: 12px; padding: 12px;
  font: 600 14px var(--font-ui, "Hanken Grotesk", sans-serif); color: #efe9f2;
  background: rgba(255,255,255,.04); border: 1px solid #3a2f45;
  display: flex; align-items: center; justify-content: center; gap: 9px;
}
.login-oauth svg { width: 15px; height: 15px; }
.login-gdot { width: 15px; height: 15px; border-radius: 50%; display: inline-block; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0 100%); }
.login-invite { color: #a99fb2; font-size: 14px; margin-top: 24px; }
.login-invite button { background: none; border: 0; cursor: pointer; color: #cdb574; font-weight: 600; font-size: 14px; padding: 0; }
.login-quote {
  flex: 1; align-self: flex-end; padding: 54px; text-align: right;
  font-family: var(--font-display, "Iowan Old Style", Palatino, Georgia, serif);
  font-weight: 700; font-style: italic; font-size: 30px; color: #efe9f2; line-height: 1.3;
  text-shadow: 0 2px 20px rgba(0,0,0,.6);
}
.login-quote span { color: #cdb574; }
.login-error { color: var(--danger); font-size: 0.85rem; }
/* On narrow screens the seal recedes; the panel goes full-width and centered. */
@media (max-width: 720px) {
  .login-panel { width: 100%; padding: 0 26px; }
  .login-quote { display: none; }
}

/* Admin / updates */
.admin-version { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.admin-actions { display: flex; gap: 10px; margin: 14px 0; }
.admin-status { font-size: 0.9rem; color: var(--ink); min-height: 1.2em; }
/* Error/failure states must read as errors, not body text. The .warn class is
   set in app.js on load/update failures; give it a semantic color. */
.admin-status.warn, .admin-status.err { color: var(--danger); font-weight: 600; }

/* Batch-job progress bar (Classify / Analyze / Harmonize / cover repair, ...).
   Determinate = the fill width tracks done/total; indeterminate = an animated
   sweep for one-shot jobs whose size we can't know. Themed to the accent. */
.pbar { margin: 8px 0 2px; }
.pbar[hidden] { display: none; }
.pbar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-grad, var(--accent));
  transition: width 0.35s ease;
}
.pbar-track.indeterminate .pbar-fill {
  width: 40%;
  transition: none;
  animation: pbar-sweep 1.15s ease-in-out infinite;
}
@keyframes pbar-sweep {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .pbar-track.indeterminate .pbar-fill { animation-duration: 2.4s; }
}
.admin-incoming { margin: 6px 0 0; padding-left: 18px; font-size: 0.84rem; color: var(--muted); }
.classify-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; flex-wrap: wrap; }
.classify-row .hint { margin-top: 0; }
.admin-warn { margin-top: 10px; color: #9a6700; background: #fff8e1; border-radius: 8px; padding: 8px 10px; font-size: 0.82rem; }

/* Series audit: variant groups, alias candidates, and author-split lists. */
.series-audit { margin-top: 4px; }
.series-audit-sec { margin-top: 12px; }
.series-audit-h {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.series-audit-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 0; font-size: 0.86rem;
  border-top: 1px solid var(--border, rgba(128, 128, 128, 0.18));
}
.series-audit-canon { font-weight: 600; color: var(--ink); }
.series-audit-variants { color: var(--muted); flex: 1; min-width: 120px; }
button.compact, .series-audit button.secondary {
  padding: 3px 10px; font-size: 0.78rem;
}
.modal-action-group { display: flex; gap: 8px; }

/* Admin section cards */
.admin-card { background: var(--surface-2); border: 1px solid var(--border, rgba(128,128,128,0.18)); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.admin-card:first-child { margin-top: 4px; }
.admin-card-title { margin: 0 0 8px; font-size: 0.98rem; font-weight: 700; letter-spacing: 0.01em; }
.admin-card .hint { margin-top: 0; }
.admin-card .admin-actions { margin-bottom: 6px; }
.admin-card .admin-actions:last-child { margin-bottom: 0; }

/* Provider health */
.health-results { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.health-group { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 8px 0 2px; }
.health-group:first-child { margin-top: 0; }
.health-row { display: flex; align-items: flex-start; gap: 9px; padding: 4px 0; }
.health-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.health-dot.health-ok { background: var(--positive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 20%, transparent); }
.health-dot.health-fail { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.health-dot.health-off { background: var(--muted); opacity: 0.6; }
.health-meta { min-width: 0; }
.health-name { font-size: 0.9rem; font-weight: 600; }
.health-row .hint { margin-top: 0; font-size: 0.8rem; }

/* Server panel */
.server-info { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.server-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.server-key { color: var(--muted); }
.server-val { color: var(--ink); text-align: right; word-break: break-all; }

/* Media scan cards (Audiobooks / Ebooks): explainer + folder + attachable list */
.media-how .media-steps {
  margin: 8px 0 0; padding-left: 20px; color: var(--muted);
  font-size: 0.86rem; line-height: 1.7;
}
.media-how .media-steps b { color: var(--ink); font-weight: 600; }
.media-scan { margin: 12px 0 2px; }
.media-folder { font-size: 0.86rem; color: var(--muted); }
.media-folder code {
  background: var(--surface-2, rgba(127,127,127,.12)); padding: 1px 6px;
  border-radius: 5px; color: var(--ink); font-size: 0.82rem;
}
.media-ok { color: var(--accent); font-weight: 600; }
.media-warn { color: var(--danger); font-weight: 600; }
.media-summary { margin: 10px 0 2px; font-size: 0.82rem; color: var(--muted); }
.media-file-list { display: flex; flex-direction: column; }
/* Scale guard on the Audiobooks/Ebooks cards: filter box, "To attach" queue
   up front, the attached bulk behind a collapsible, paged lists. */
.media-filter { width: 100%; margin: 10px 0 2px; }
.media-sec-label {
  margin-top: 12px; font: 700 11.5px var(--font-sans); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.media-group {
  margin-top: 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); overflow: hidden;
}
.media-group-head {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; padding: 11px 14px;
  font: 700 13px var(--font-sans); color: var(--ink);
}
.media-group-head::-webkit-details-marker { display: none; }
.media-group-head::after {
  content: "\e136"; font-family: "Phosphor"; color: var(--muted); font-size: 15px;
  line-height: 1; margin-left: auto; transition: transform .15s ease;
}
.media-group[open] > .media-group-head::after { transform: rotate(180deg); }
.media-group[open] > .media-group-head { border-bottom: 1px solid var(--border); }
.media-group-body { padding: 0 14px 10px; }
.media-more { margin: 8px 0 2px; align-self: flex-start; }
.media-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft);
}
.media-file-row:last-child { border-bottom: none; }
/* Rounded accent icon tile per file, matching the design mockup. */
.media-file-ic {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center; background: var(--surface-2);
  color: var(--accent); font-size: 17px;
}
.media-file-main { flex: 1; min-width: 0; }
.media-file-title {
  font-weight: 600; color: var(--ink); font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-file-sub { font-size: 0.77rem; color: var(--faint); margin-top: 1px; }
.media-file-sub .media-suggest { color: var(--ink); font-weight: 600; }

/* Edit-form "Attached media" section: linked ebook/audiobook + a detach. */
.attached-media-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.attached-media-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.attached-media-row > i { font-size: 18px; color: var(--muted); flex: none; }
.attached-media-row .amm-meta { flex: 1; min-width: 0; }
.attached-media-row .amm-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.attached-media-row .amm-title { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attached-media-row button { flex: none; }
.media-file-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.media-attached {
  color: var(--positive); font-size: 0.8rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
}
.media-mini-btn {
  cursor: pointer; border: 1px solid var(--border); background: transparent;
  color: var(--ink); border-radius: 9px; padding: 6px 12px;
  font: 600 0.78rem var(--font-sans);
}
.media-mini-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Unattached files get a filled accent "Attach" (the primary action). */
.media-mini-btn.attach { background: var(--accent-grad); color: #fff; border-color: transparent; }
.media-mini-btn.attach:hover { filter: brightness(1.06); color: #fff; }
.media-mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
/* The attach picker is wider than a plain confirm dialog so a list of files
   with titles + authors is readable, not squished into a narrow column. */
.modal.modal-confirm.media-pick { max-width: 560px; }
.media-pick .confirm-text { margin-bottom: 10px; }
.media-pick-search {
  width: 100%; box-sizing: border-box; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 0.92rem;
}
.media-pick-list { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; }

/* TBR reading queue */
.tbr-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tbr-row { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.tbr-num { font-weight: 700; color: var(--muted); min-width: 1.4em; text-align: center; }
.tbr-meta { flex: 1; min-width: 0; cursor: pointer; }
.tbr-meta .title { font-weight: 600; }
.tbr-meta .author { color: var(--muted); font-size: 0.88rem; }
.tbr-actions { display: flex; gap: 4px; align-items: center; }

/* User management */
.users-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.user-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; flex-wrap: wrap; }
.user-name { font-weight: 600; }
.user-badge { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 8px; }
.user-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
button.small { padding: 4px 10px; font-size: 0.82rem; }
.admin-actions input[type="text"], .admin-actions input[type="password"] { flex: 1; min-width: 120px; }
:root[data-theme="dark"] .admin-warn { color: #e3b341; background: #3a2f12; }

.layout { display: flex; gap: 26px; margin: 26px auto; padding: 0 22px; }

aside.sidebar { width: 240px; flex: 0 0 240px; }
.sidebar h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 10px; font-family: var(--font-sans); font-weight: 700; }

/* Grouped navigation: labeled sections (Libraries / Browse / Discover / Lists /
   Shelves) of flat nav links, so the sidebar reads as planned rather than a
   stack of buttons. */
.nav-group { margin-bottom: 20px; }
.nav-head {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--gold); font-weight: 700; margin: 0 2px 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; background: none; border: none; color: var(--ink);
  padding: 8px 11px; border-radius: 9px; cursor: pointer;
  font: inherit; font-size: 0.92rem; font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }

.library-list { list-style: none; margin: 0 0 6px; padding: 0; }
.library-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px; border-radius: 9px; cursor: pointer; font-size: 0.92rem;
  transition: background 0.12s ease, color 0.12s ease;
}
.library-list li:hover { background: var(--surface-2); }
.library-list li.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-weight: 600; box-shadow: 0 2px 8px var(--accent-soft);
}
.library-list li.active .count { color: var(--accent-ink); }
.library-list .count { color: var(--muted); font-size: 0.8rem; }
/* Name takes the middle stretch (left-aligned beside the kind glyph); count +
   pencil stay pinned right. Without flex:1 the li's space-between centers it. */
.library-list .lib-name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-list .lib-right { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.lib-edit {
  background: none; border: none; padding: 0 4px; line-height: 1; cursor: pointer;
  color: var(--muted); font-size: 0.9rem; opacity: 0.55;
}
.library-list li:hover .lib-edit { opacity: 1; }
.lib-edit:hover { color: var(--accent); }
.library-list li.active .lib-edit { color: var(--accent-ink); opacity: 0.9; }

main.content { flex: 1; min-width: 0; }


button {
  font: inherit; cursor: pointer; border: 1px solid transparent;
  border-radius: 9px; padding: 9px 15px; font-size: 0.9rem; font-weight: 500;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease,
    background 0.15s ease, filter 0.15s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-soft); }
button:active { transform: translateY(0); }
button.secondary {
  background: var(--surface); color: var(--ink); border-color: var(--border);
  box-shadow: none;
}
button.secondary:hover { background: var(--surface-2); border-color: var(--muted); box-shadow: none; }
button.danger {
  background: transparent; color: var(--danger); border-color: transparent;
  padding: 4px 8px; box-shadow: none;
}
button.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); transform: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Global disabled affordance - so a button that disables itself during an async
   op (save, scan, test) reads as inert instead of fully clickable. */
button:disabled, button[disabled] { opacity: 0.55; cursor: default; box-shadow: none; filter: saturate(0.85); }
button:disabled:hover, button[disabled]:hover { transform: none; box-shadow: none; filter: saturate(0.85); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; background: var(--surface-2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }

/* Cover wall: dense, covers only, title revealed on hover. */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 12px; }
.wall-card {
  position: relative; cursor: pointer; border-radius: 9px; overflow: hidden;
  box-shadow: var(--shadow); transition: transform 0.14s ease, box-shadow 0.18s ease;
}
.wall-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.wall-cover {
  aspect-ratio: 2 / 3; background: var(--cover-bg) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-family: var(--font-display); font-size: 0.72rem;
  text-align: center; padding: 8px; line-height: 1.25;
}
.wall-flags { position: absolute; top: 6px; right: 6px; display: flex; gap: 3px; }
.wall-cap {
  position: absolute; inset: auto 0 0 0; padding: 20px 8px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
  color: #fff; font-size: 0.74rem; opacity: 0; transition: opacity 0.15s ease;
}
.wall-card:hover .wall-cap { opacity: 1; }
.wall-cap .title {
  font-weight: 600; line-height: 1.2; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Active-filter chips */
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2);
  border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 0.82rem;
}
.chip-x { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 3px; font-size: 0.85rem; line-height: 1; }
.chip-x:hover { color: var(--danger); }
.clear-all { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.82rem; padding: 4px; }

/* List view. Capped width so rows don't stretch edge-to-edge on a wide desktop
   (which left a big empty channel between the title and the right-side rating);
   the grid/wall view stays full-width. */
.list { display: flex; flex-direction: column; gap: 2px; max-width: 860px; }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; background: var(--panel); border: 1px solid var(--border);
}
.row-item:hover { background: var(--surface-2); }
.row-cover { width: 64px; height: 96px; flex: 0 0 64px; border-radius: 5px; background: var(--cover-bg) center / cover no-repeat; box-shadow: var(--shadow); }
.row-meta { flex: 1; min-width: 0; }
.row-meta .title { font-weight: 600; font-size: 0.9rem; }
/* Stars + spice on one baseline so the flame row doesn't jump vertically
   between rated and unrated books. */
.row-stars { flex: 0 0 auto; color: var(--gold); font-size: 0.8rem; display: flex; align-items: center; gap: 8px; }
.author-link { cursor: pointer; }
.author-link:hover { color: var(--accent); text-decoration: underline; }

.card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* ---- bulk select ---- */
#select-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.card.selected, .wall-card.selected, .row-item.selected {
  outline: 2px solid var(--accent); outline-offset: -2px;
  border-color: var(--accent);
}
.row-item { position: relative; }
.sel-box {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--panel); border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.row-item .sel-box { position: relative; top: auto; left: auto; margin: auto 4px auto 0; flex: 0 0 auto; }
.sel-box.on { background: var(--accent); }
.sel-box.on::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.bulk-bar {
  position: sticky; bottom: 12px; z-index: 20; margin: 12px 0 4px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow-lg);
}
/* A class selector's display:flex otherwise overrides the [hidden] attribute,
   leaving an empty bar floating on every page. Let hidden win. */
.bulk-bar[hidden] { display: none; }
.bulk-count { font-weight: 600; font-size: 0.92rem; }
.bulk-spacer { flex: 1; }
.bulk-bar button.danger { color: #d1495b; }
.card .cover {
  aspect-ratio: 2 / 3; background: var(--cover-bg) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.82rem; font-family: var(--font-display);
  text-align: center; padding: 10px; line-height: 1.3;
}
/* Subtle gradient scrim under the cover so titles always sit on the card body. */
/* The meta block fills the card's remaining height so the flag chips can pin
   to the bottom edge - lining the flags up across a row of cards whose titles
   wrap differently. */
.card .meta { padding: 11px 12px 13px; flex: 1; display: flex; flex-direction: column; }
.card .meta .title { font-weight: 600; font-size: 0.92rem; line-height: 1.28; }
.card .meta .author { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.card .meta .stars { color: var(--gold); font-size: 0.82rem; margin-top: 5px; min-height: 1em; letter-spacing: 1px; }
/* Flags sit in the card body, pinned to the bottom (margin-top:auto inside the
   flex .meta) so they line up across the row however the titles wrap. */
.meta-flags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 8px; }

/* Identity flags - rendered as little gradient swatches (most have no emoji). */
.flag {
  display: inline-block; width: 22px; height: 14px; border-radius: 3px;
  vertical-align: middle; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}
.flag.sm { width: 18px; height: 12px; }
.flag.lg { width: 32px; height: 20px; border-radius: 4px; }
.flag.rainbow {
  background: linear-gradient(to bottom, #e40303 0 16.66%, #ff8c00 16.66% 33.33%,
    #ffed00 33.33% 50%, #008026 50% 66.66%, #004dff 66.66% 83.33%, #750787 83.33% 100%);
}
.flag.lesbian {
  background: linear-gradient(to bottom, #d52d00 0 20%, #ef7627 20% 40%,
    #ffffff 40% 60%, #d162a4 60% 80%, #a30262 80% 100%);
}
.flag.gay_men {
  background: linear-gradient(to bottom, #078d70 0 20%, #26ceaa 20% 40%,
    #ffffff 40% 60%, #7bade2 60% 80%, #3d1a78 80% 100%);
}
.flag.bisexual {
  background: linear-gradient(to bottom, #d60270 0 40%, #9b4f96 40% 60%, #0038a8 60% 100%);
}
.flag.transgender {
  background: linear-gradient(to bottom, #5bcefa 0 20%, #f5a9b8 20% 40%,
    #ffffff 40% 60%, #f5a9b8 60% 80%, #5bcefa 80% 100%);
}
.flag.nonbinary {
  background: linear-gradient(to bottom, #fcf434 0 25%, #ffffff 25% 50%,
    #9c59d1 50% 75%, #2c2c2c 75% 100%);
}
.flag.pansexual {
  background: linear-gradient(to bottom, #ff218c 0 33.33%, #ffd800 33.33% 66.66%, #21b1ff 66.66% 100%);
}
.flag.asexual {
  background: linear-gradient(to bottom, #000000 0 25%, #a3a3a3 25% 50%,
    #ffffff 50% 75%, #800080 75% 100%);
}
.flag.intersex {
  background: radial-gradient(circle at center, #ffd800 0 32%, #7902aa 32% 50%, #ffd800 50% 100%);
}

/* Flag + label pill, used in the detail view, filters and stats. */
.flag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 5px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink); font-size: 0.8rem; margin: 3px 3px 0 0;
}
.flag-chip.clickable { cursor: pointer; }
.flag-chip.clickable:hover { border-color: var(--accent); }
.flag-chip .count { color: var(--muted); font-size: 0.78rem; }

.row-flags { display: flex; flex-wrap: wrap; gap: 5px; flex: 0 0 auto; margin-top: 5px; }
.detail-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stat-flags { display: flex; flex-wrap: wrap; gap: 4px; }

/* Manual identity-flag checkboxes in the add/edit form. */
.flag-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.flag-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.flag-check input { width: auto; }

/* Physical edition / copy pills (list + grid views) and the wall-view dog-ear. */
.ed-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.ed-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-size: 0.74rem; white-space: nowrap;
}
.ed-pill i { color: var(--gold); font-size: 0.92rem; }
/* Specials (signed / sprayed / movie tie-in / special edition) read a touch
   stronger than the plain hardcover/paperback binding. */
.ed-pill.ed-signed, .ed-pill.ed-sprayed_edges,
.ed-pill.ed-movie_tie_in, .ed-pill.ed-special_edition {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--border));
  color: var(--ink);
}
/* A folded lower-right corner on a wall cover, carrying the edition glyph(s). */
.wall-ear {
  position: absolute; right: 0; bottom: 0;
  display: flex; align-items: flex-end; gap: 3px;
  padding: 12px 5px 4px 12px;
  border-top-left-radius: 11px;
  background: linear-gradient(135deg, transparent 45%, rgba(0, 0, 0, 0.74) 46%);
  color: var(--gold-2); font-size: 0.82rem; line-height: 1;
  pointer-events: none;
}


/* Hoard stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { background: var(--surface-2); border-radius: 10px; padding: 12px; text-align: center; }
.stat-card.gold .stat-value { color: var(--gold); }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.stat-section { margin-top: 16px; }
.stat-section strong { display: block; margin-bottom: 6px; font-size: 0.9rem; }
.stat-top { list-style: none; margin: 0; padding: 0; }
.stat-top li { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.stat-top .count { color: var(--muted); }
.stat-heat { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.heat-row { display: flex; align-items: center; gap: 10px; }
.heat-flames { font-size: 0.9rem; letter-spacing: 1px; width: 76px; flex: 0 0 76px; white-space: nowrap; }
.heat-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.heat-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 4px; }
.heat-row .count { color: var(--muted); font-size: 0.82rem; width: 28px; text-align: right; flex: 0 0 28px; }

/* Recommendations */
.rec-block + hr { margin: 16px 0; }
.rec-block > strong { display: block; font-size: 0.95rem; }
.rec-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rec-refresh { margin-top: 12px; }
.rec-row {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  cursor: pointer;
}
.rec-row.discover { cursor: default; }
.rec-row:hover:not(.discover) { border-color: var(--accent); }
.rec-cover {
  width: 36px; height: 52px; flex: 0 0 auto; border-radius: 4px;
  background: var(--surface); background-size: cover; background-position: center;
  font-size: 0.5rem; color: var(--muted); overflow: hidden;
}
.rec-meta { flex: 1 1 auto; min-width: 0; }
.rec-meta .title { font-weight: 600; font-size: 0.9rem; }
.rec-meta .author { color: var(--muted); font-size: 0.8rem; }
.rec-meta .stars { color: var(--gold); font-size: 0.8rem; }
.rec-why { margin-top: 3px; }
.rec-add { flex: 0 0 auto; }
.rec-pride { flex: 0 0 auto; }
.rec-flags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; flex: 0 0 auto; }
.rec-cover.empty {
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 0.6rem; color: var(--muted);
}
/* Discover suggestions get larger covers - you do judge a book by its cover. */
.rec-row.discover { align-items: flex-start; }
.rec-row.discover .rec-cover { width: 70px; height: 105px; }

/* Three-up form row (e.g. Room / Bookcase / Shelf) */
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.datalist-wrap { display: block; }

/* ============================================================================
   Themed dropdowns. Native <select> option-lists and <datalist> autocomplete
   popups are browser chrome CSS can't touch (bare light/grey lists that clash
   with the theme). enhanceSelect() hides the native <select> and shows a themed
   .dh-select trigger; themedCombo() gives location fields a themed suggestion
   menu. The floating .dh-menu is shared by both and uses the panel/border/
   accent tokens so it matches light + dark.
   ============================================================================ */
select.dh-native { display: none !important; }

.dh-select {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; box-sizing: border-box; margin: 0;
  padding: 9px 11px; border: 1px solid var(--field-border); border-radius: 8px;
  background: var(--field-bg); color: var(--ink); font: inherit; text-align: left;
  cursor: pointer; line-height: 1.3;
}
.dh-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh-caret { color: var(--muted); font-size: 0.9rem; flex: 0 0 auto; transition: transform 0.15s ease; }
.dh-select.dh-open .dh-caret { transform: rotate(180deg); }
.dh-select:hover { border-color: var(--accent); }
.dh-select:focus-visible, .dh-select.dh-open {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.dh-select.dh-disabled { opacity: 0.55; cursor: default; }
.dh-select.dh-disabled:hover { border-color: var(--field-border); }

/* Contextual sizing to match the native controls they replace. */
.filter-row-1 > .dh-select, .filter-row-2 .dh-select {
  width: auto; min-width: 150px; background: var(--panel); border-color: var(--border);
}
.filter-row-1 > .dh-select { border-radius: 11px; padding: 11px 15px; font-size: 14px; }
.filter-row-2 .dh-select { border-radius: 10px; padding: 9px 13px; font-size: 13px; color: var(--muted); min-width: 0; }
.set-select.dh-select { border-radius: 10px; padding: 10px 13px; }
.modal-page .dh-select { border-radius: 11px; padding: 12px 15px; }

/* The floating themed menu, shared by the select listbox and the combo. */
.dh-menu {
  position: fixed; z-index: 700; overflow-y: auto; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 5px;
  animation: dh-menu-in 0.12s ease;
}
@keyframes dh-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dh-opt {
  padding: 8px 11px; border-radius: 8px; cursor: pointer; font-size: 0.9rem;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dh-opt.active { background: var(--accent-soft); }
.dh-opt.sel { color: var(--accent); font-weight: 600; }

/* Themed autocomplete combo (location fields). */
.dh-combo { position: relative; display: block; }
.dh-combo > input { width: 100%; }

/* ISBN lookup diagnostic (admin): per-provider result rows. */
.diag-panel { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.diag-row {
  display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; border-radius: 8px;
  font-size: 0.86rem; background: var(--surface-2);
}
.diag-row .diag-k {
  flex: 0 0 92px; color: var(--muted); font-weight: 600; text-transform: capitalize;
}
.diag-row .diag-v { flex: 1; min-width: 0; color: var(--ink); word-break: break-word; }
.diag-row.diag-hit { background: color-mix(in srgb, var(--positive) 14%, var(--surface-2)); }
.diag-row.diag-hit .diag-v { color: var(--positive); }
.diag-row.diag-warn { background: color-mix(in srgb, var(--gold) 16%, var(--surface-2)); }
.diag-row.diag-miss .diag-v { color: var(--muted); }
.diag-row.diag-info .diag-v { color: var(--muted); font-style: italic; }
.diag-row.diag-final { margin-top: 4px; background: var(--surface); border: 1px solid var(--border); }
.diag-row.diag-final .diag-k { color: var(--gold); }
.diag-cfg { margin-top: 8px; text-align: center; }

/* Location: detail line + browser */
.detail-loc { font-size: 0.9rem; }
.detail-loc.clickable { cursor: pointer; color: var(--accent); }
.loc-room { margin-bottom: 12px; }
.loc-line {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-top: 6px; cursor: pointer; color: var(--ink);
}
.loc-line:hover { border-color: var(--accent); }
.loc-line .count { color: var(--muted); font-size: 0.8rem; }
.loc-room-line { font-weight: 600; }
.loc-bc-line { margin-left: 16px; width: calc(100% - 16px); }
.loc-shelf-line { margin-left: 32px; width: calc(100% - 32px); font-size: 0.88rem; }

/* Tropes / content warnings / series */
.detail-series { font-size: 0.92rem; }
.detail-series.clickable { cursor: pointer; color: var(--accent); }
.cw-chip {
  display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 0.75rem;
  margin: 3px 3px 0 0; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.series-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.series-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.series-name {
  display: inline-flex; align-items: center; gap: 8px; background: none; border: none;
  color: var(--ink); cursor: pointer; font-weight: 600; font-size: 0.95rem; padding: 0;
}
.series-name:hover { color: var(--accent); transform: none; box-shadow: none; }
.series-name .count { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.series-gap { color: var(--gold); font-size: 0.82rem; font-weight: 600; }
.series-complete { color: var(--muted); font-size: 0.78rem; }
.series-books { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.series-book {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 9px; font-size: 0.82rem; cursor: pointer;
}
.series-book:hover { border-color: var(--accent); }

/* Shelve mode */
.shelve-tag {
  align-self: center; border-radius: 999px; padding: 3px 10px; font-size: 0.72rem;
  font-weight: 600; white-space: nowrap;
}
.shelve-tag.moved {
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.shelve-tag.here {
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
}

/* Vibe search */
.vibe-interp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; }
.vibe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.vibe-card { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.vibe-card:hover .title { color: var(--accent); }
.vibe-meta .title { font-weight: 600; font-size: 0.9rem; }
.vibe-tropes { font-size: 0.74rem; color: var(--muted); }
.vibe-results { max-height: 60vh; overflow-y: auto; }

/* Series gap -> buy list */
.gap-add {
  /* Amethyst, not gold: gold is reserved for labels/ratings, never controls. */
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--ink); border-radius: 7px; padding: 1px 7px; margin-left: 4px;
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.gap-add:hover:not(:disabled) { border-color: var(--accent); transform: none; box-shadow: none; }
.gap-add:disabled { opacity: 0.6; cursor: default; }

/* Media servers (Audiobookshelf / Kavita): clean rows, action cluster pinned
   to the right edge, hairline divider between rows. */
.media-section .media-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; }
.media-section .media-row + .media-row { border-top: 1px solid var(--border); }
.media-label { font-size: 0.92rem; font-weight: 600; color: var(--ink); }
.media-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.media-none { font-size: 0.82rem; color: var(--muted); }
.media-go {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px;
  padding: 5px 14px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.media-go:hover { filter: brightness(1.06); }
.media-link {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 12px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.media-link:hover { border-color: var(--accent); }
.media-prog { font-size: 0.8rem; color: var(--gold); }
.media-fix { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; padding: 2px; line-height: 1; }
.media-fix:hover { color: var(--accent); }
.media-results { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; margin: 8px 0; }
.media-cand {
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 0.88rem; color: var(--ink);
}
.media-cand:hover { border-color: var(--accent); }

/* Smart shelves (saved views): flat rows that match the grouped nav links. */
.shelves-list { display: flex; flex-direction: column; gap: 2px; margin: 0 0 2px; }
.shelf-row { display: flex; align-items: center; gap: 4px; }
.shelf-link {
  flex: 1; text-align: left; background: none; border: none;
  border-radius: 9px; padding: 8px 11px; color: var(--ink); cursor: pointer;
  font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background 0.12s ease;
}
.shelf-link:hover { background: var(--surface-2); }
.shelf-del {
  flex: 0 0 auto; width: 28px; background: none; border: none;
  border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1;
}
.shelf-del:hover { color: var(--danger); }

/* Year in review */
.wrap-hero {
  text-align: center; padding: 20px 12px; border-radius: var(--radius);
  background: linear-gradient(155deg, var(--accent-soft), transparent);
  border: 1px solid var(--border); margin-bottom: 14px;
}
.wrap-year { font-family: var(--font-display); font-size: 2.6rem; color: var(--accent); line-height: 1; }
.wrap-headline { font-size: 1.1rem; font-weight: 600; margin-top: 6px; }
.wrap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.wrap-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.wrap-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }
.wrap-big { font-size: 1.4rem; font-weight: 700; }
.wrap-book { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.wrap-book:hover .title { color: var(--accent); }
.wrap-book .rec-cover { width: 40px; height: 60px; flex: 0 0 40px; }
.wrap-book-meta .title { font-weight: 600; font-size: 0.88rem; line-height: 1.25; }

/* Reading log: yearly goal + month chart */
.goal-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.goal-input { width: 70px; padding: 4px 8px; border-radius: 7px; border: 1px solid var(--field-border); background: var(--field-bg); color: var(--ink); }
.goal-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 5px; transition: width 0.25s ease; }
.month-chart { display: flex; align-items: flex-end; gap: 5px; height: 64px; margin-top: 12px; border-bottom: 1px solid var(--border-soft); }
.month-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; }
.month-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.month-fill { width: 100%; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-radius: 3px 3px 0 0; min-height: 2px; }
.month-label { font-size: 0.68rem; color: var(--muted); }

/* Read next */
.readnext-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.readnext-pick {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; cursor: pointer;
}
.readnext-pick:hover { border-color: var(--accent); }
.readnext-pick .rec-cover { width: 40px; height: 60px; flex: 0 0 40px; }
.readnext-meta .title { font-weight: 600; font-size: 0.9rem; }
.readnext-done { color: var(--muted); font-size: 0.85rem; }
.readnext-gap { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* Buy list */
.buylist { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow-y: auto; }
.buylist-row { display: flex; gap: 12px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.buylist-meta { flex: 1; min-width: 0; }
.buylist-meta .title { font-weight: 600; }
.buylist-owned { font-size: 0.78rem; color: var(--accent); margin-top: 2px; }
.buylist-add { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.buylist-add input { flex: 1; min-width: 120px; }

/* Store check (peek) */
.peek-result { margin-top: 14px; }
.peek-head { display: flex; gap: 14px; align-items: flex-start; }
.peek-head .rec-cover { width: 64px; height: 96px; }
.peek-headtext { flex: 1; min-width: 0; }
.peek-title { font-weight: 600; font-size: 1.05rem; font-family: var(--font-display); }
.peek-head .author { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.peek-spice { margin-top: 4px; font-size: 0.9rem; }
.peek-verdict { margin-top: 14px; border-radius: 10px; padding: 12px 14px; border: 1px solid var(--border); }
.peek-verdict.yes { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.peek-verdict.no { background: var(--surface-2); }
.peek-verdict.checking { background: var(--surface-2); color: var(--muted); display: flex; align-items: center; gap: 8px; }
.peek-verdict-line { font-size: 1.05rem; }
.spinner-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); display: inline-block; animation: spin 0.7s linear infinite; }
.scan-ok { color: var(--accent); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
.peek-owned { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.92rem; }
.peek-owned.yes { color: var(--accent); font-weight: 600; }
.peek-owned.no { color: var(--muted); }

/* Rapid bulk-add scanner */
.scan-form { display: flex; gap: 8px; margin-top: 10px; }
.scan-form input { flex: 1 1 auto; font-size: 1.05rem; }
.scan-form button { flex: 0 0 auto; }
.scan-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.scan-count { font-weight: 600; }
.scan-status { margin-top: 8px; min-height: 1.2em; }
.scan-status.warn { color: var(--gold); }
.scan-status.warn button { margin-left: 8px; }
.scan-tip { margin-top: 6px; }
.scan-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 40vh; overflow-y: auto; }
.scan-row {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.scan-cover {
  width: 34px; height: 50px; flex: 0 0 auto; border-radius: 4px;
  background: var(--surface); background-size: cover; background-position: center;
  font-size: 0.45rem; color: var(--muted); overflow: hidden;
}
.scan-meta { flex: 1 1 auto; min-width: 0; }
.scan-meta .title { font-weight: 600; font-size: 0.9rem; }
.scan-meta .author { color: var(--muted); font-size: 0.8rem; }
.scan-warn { color: var(--gold); }
/* A scanned row whose providers disagreed on the title - flag it for a look. */
.scan-row-warn { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); }
.scan-undo { flex: 0 0 auto; }
/* In-flight scan: the scanned number + a spinner, replaced by the book row. */
.scan-pending { opacity: 0.85; }
.scan-spin {
  width: 18px; height: 18px; flex: 0 0 auto; margin: 0 8px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
/* Sound cluster: mute toggle + volume + click-to-hear cue legend. */
.scan-sound { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.scan-mute, .glyph-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.scan-theme { padding: 5px 8px; font-size: 0.85rem; width: auto; }
.scan-vol { width: 90px; accent-color: var(--accent); }
.scan-cues { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; }

/* Modal / drawer */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 10, 14, 0.6);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 250; overflow-y: auto;
}
.modal {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); padding: 24px;
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal h2 { margin: 0 0 16px; font-size: 1.3rem; }
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 4px; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"],
input[type="url"], input[type="email"], textarea, select.full {
  width: 100%; padding: 9px 11px; border: 1px solid var(--field-border); border-radius: 8px;
  font: inherit; background: var(--field-bg); color: var(--ink);
}
textarea { resize: vertical; min-height: 70px; }

/* Readable placeholders + a clear focus ring across all fields. */
input[type="checkbox"] { accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--field-placeholder); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; }
.modal-actions .right { display: flex; gap: 10px; }

.lookup-row { display: flex; gap: 8px; align-items: flex-end; }
.lookup-row > div { flex: 1; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.toast {
  /* Top-right, just under the app bar: in the eye line near the action
     buttons that trigger it, and never cut off at the viewport bottom. */
  position: fixed; top: 72px; right: 20px;
  background: var(--toast-bg); color: var(--toast-ink); padding: 11px 18px; border-radius: 10px;
  font-size: 0.9rem; box-shadow: 0 8px 24px -8px rgba(0,0,0,.6);
  /* Above every overlay (modal backdrop 250, confirm 400) so it's never dimmed. */
  z-index: 600; opacity: 0; transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
  max-width: min(420px, 86vw); text-align: left;
}
.toast.show { opacity: 1; transform: translateY(0); }
.tag-chip { display: inline-block; background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 2px 9px; font-size: 0.75rem; margin: 3px 3px 0 0; }
.tag-chip.clickable { cursor: pointer; }
.tag-chip.clickable:hover { background: var(--accent); color: var(--accent-ink); }

/* Book detail view */
.detail-head {
  display: flex; gap: 16px; align-items: flex-start;
  padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.detail-cover {
  width: 132px; flex: 0 0 132px; aspect-ratio: 2 / 3; border-radius: 10px;
  background: var(--cover-bg) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.78rem; font-family: var(--font-display);
  text-align: center; padding: 8px; box-shadow: var(--shadow-lg);
}
.detail-headtext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; padding-top: 2px; }
.detail-author { color: var(--ink); font-size: 1rem; font-weight: 600; }
.detail-pride { font-size: 0.85rem; }
/* Header stats as a tidy labeled grid so nothing floats: each control sits
   under its own uppercase micro-label, aligned in a row. */
.detail-statgrid {
  display: flex; flex-wrap: wrap; gap: 10px 24px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.detail-stat { display: flex; flex-direction: column; gap: 6px; }
.detail-stat-label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 700;
}
.detail-stars { font-size: 1.35rem; letter-spacing: 2px; line-height: 1; }
.detail-stars .star { cursor: pointer; }
.detail-stars .star.on { color: var(--gold); }
.detail-status { font-size: 0.8rem; color: var(--ink); text-transform: capitalize; background: var(--surface-2); padding: 4px 11px; border-radius: 999px; align-self: flex-start; }
/* Spice / heat level */
.detail-spice { display: inline-flex; align-items: center; gap: 8px; min-height: 1.35rem; }
.spice-pick { display: inline-flex; gap: 1px; font-size: 1.15rem; line-height: 1; }
.spice-pick .flame { cursor: pointer; opacity: 0.25; filter: grayscale(1); }
.spice-pick .flame.on { opacity: 1; filter: none; }
.spice-label { font-size: 0.78rem; }
.spice { font-size: 0.8rem; white-space: nowrap; }
.card .meta .stars .spice { margin-left: 6px; }
.row-stars { display: flex; align-items: center; gap: 8px; }
.row-stars .stars { color: var(--gold); }
/* Structured detail sections: each is a contained card so nothing floats. */
.dsection {
  margin-top: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px;
}
.dsection-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--gold); font-weight: 700; margin-bottom: 10px;
}
.dfacts {
  display: grid; grid-template-columns: max-content 1fr;
  column-gap: 18px; row-gap: 9px; align-items: baseline;
}
.dfact { display: contents; }
.dfact-k {
  color: var(--muted); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.dfact-v { color: var(--ink); min-width: 0; word-break: break-word; font-size: 0.9rem; }
.dfact-link { color: var(--accent); cursor: pointer; }
.dfact-link:hover { text-decoration: underline; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

/* Quick actions in the detail header (TBR toggle). */
.detail-quickrow { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-tbr {
  font-size: 0.82rem; padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--field-border); cursor: pointer; transition: all 0.12s;
}
.detail-tbr:hover { border-color: var(--accent); }
.detail-tbr.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* A full-width "more like this" at the foot of the body, set off from content. */
.detail-morelike {
  width: 100%; margin-top: 18px; padding: 12px;
  border: none; border-top: 1px solid var(--border); border-radius: 0;
  background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}
.detail-morelike:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.detail-section { margin-top: 14px; }
.detail-meta { color: var(--muted); font-size: 0.82rem; }
.detail-notes { font-size: 0.92rem; white-space: pre-wrap; line-height: 1.5; }
.detail-price { font-size: 0.9rem; color: var(--gold); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 12px; }
.detail-label { font-size: 0.78rem; color: var(--muted); }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  aside.sidebar { width: 100%; flex: none; }
}

/* In-app web EPUB reader (full-screen overlay; themes set inline per-book). */
.reader-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  background: var(--reader-bg, #15181d); color: var(--reader-fg, #d7dee6);
}
.reader-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}
.reader-title {
  flex: 1; min-width: 0; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-tools { display: flex; gap: 6px; }
.reader-icon {
  background: transparent; border: 1px solid rgba(128, 128, 128, 0.3); color: inherit;
  border-radius: 8px; padding: 6px 11px; font-size: 0.85rem; cursor: pointer; line-height: 1;
}
.reader-icon:hover { border-color: var(--accent); transform: none; box-shadow: none; }
.reader-stage { flex: 1; display: flex; align-items: stretch; min-height: 0; }
.reader-view { flex: 1; min-width: 0; }
.reader-nav {
  flex: 0 0 auto; width: 56px; background: transparent; border: none; color: inherit;
  font-size: 2rem; cursor: pointer; opacity: 0.45; transition: opacity 0.12s;
}
.reader-nav:hover { opacity: 1; transform: none; box-shadow: none; }
.reader-foot {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
}
.reader-progress { flex: 1; height: 6px; background: rgba(128, 128, 128, 0.25); border-radius: 3px; overflow: hidden; }
.reader-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.reader-pct { font-size: 0.8rem; opacity: 0.8; min-width: 38px; text-align: right; }
.reader-toc {
  position: absolute; top: 53px; left: 0; bottom: 0; width: 300px; max-width: 80vw;
  background: var(--reader-bg); border-right: 1px solid rgba(128, 128, 128, 0.3);
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
}
.reader-toc.hidden { display: none; }
.reader-toc-head {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  opacity: 0.6; margin: 4px 6px 8px;
}
.reader-toc-item {
  text-align: left; background: transparent; border: none; color: inherit;
  padding: 8px; border-radius: 6px; cursor: pointer; font-size: 0.88rem;
}
.reader-toc-item:hover { background: rgba(128, 128, 128, 0.18); transform: none; box-shadow: none; }
.reader-error { padding: 36px; text-align: center; opacity: 0.85; }
.reader-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 100%; min-height: 200px; color: var(--muted); font-size: 14px;
}
@media (max-width: 600px) {
  .reader-nav { width: 38px; font-size: 1.5rem; }
}

/* ============================================================================
   Dragonhoard component system - exact treatments from the design prototype.
   Applied to the existing layout: serif titles, typographic cover placeholders
   on muted gradients with a gold rule, gold/dim rating stars, faded spice,
   status pills, gold section labels, and brand chips/tiles.
   ============================================================================ */

/* Typographic cover placeholder (book with no cover art) */
.cover-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  background-image: none;
}
.cover-ph .cover-title {
  font-family: var(--font-display); font-weight: 700; line-height: 1.2;
  color: var(--cream); font-size: 13px;
  /* Clamp very long titles so they can't crowd out the gold rule at small sizes. */
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-ph .cover-rule {
  width: 18px; height: 2px; background: var(--gold); border-radius: 2px;
  margin-top: 9px; opacity: 0.85;
}
.card .cover.cover-ph .cover-title { font-size: 14px; }
.wall-cover.cover-ph .cover-title { font-size: 13px; }
.row-cover.cover-ph { padding: 7px; }
.row-cover.cover-ph .cover-title { font-size: 10px; }
.row-cover.cover-ph .cover-rule { display: none; }
.rec-cover.cover-ph .cover-title { font-size: 11px; }
.detail-cover.cover-ph .cover-title { font-size: 16px; }
.detail-cover.cover-ph .cover-rule { width: 20px; opacity: 1; }

/* The six muted cover gradients. Paired with .cover-ph so they beat the more
   specific per-view cover rules (e.g. `.card .cover`). */
.cover-ph.cg-green { background: linear-gradient(160deg, #2f5a44, #1d3a2c); }
.cover-ph.cg-plum { background: linear-gradient(160deg, #54405f, #2f2438); }
.cover-ph.cg-teal { background: linear-gradient(160deg, #2f545f, #1d3a42); }
.cover-ph.cg-sage { background: linear-gradient(160deg, #4a5742, #2f3a2c); }
.cover-ph.cg-amethyst { background: linear-gradient(160deg, #473468, #291f3e); }
.cover-ph.cg-mauve { background: linear-gradient(160deg, #5f4a6b, #3a2c45); }

/* Serif titles on cards/rows/detail, matching the prototype */
.card .meta .title,
.row-meta .title,
.wall-cap .title,
.vibe-meta .title,
.peek-title {
  font-family: var(--font-display); font-weight: 700; color: var(--ink);
  letter-spacing: 0.01em;
}
.card .meta .title { font-size: 1.02rem; line-height: 1.15; }
.row-meta .title { font-size: 1.02rem; }
.card .meta .author, .row-meta .author { color: var(--muted); }

/* Rating stars: gold filled, muted remainder */
.stars { letter-spacing: 1px; }
.stars .st-full { color: var(--gold); }
.stars .st-empty { color: var(--star-empty); }

/* Spice: filled flames at full strength, the rest faded */
.spice .sp-empty { opacity: 0.18; }

/* Flag chip - swatch + label pill (real flag colors set inline on .flag) */
.flag-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px 5px 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--lilac); font-size: 12px; font-weight: 500;
}
.flag-chip .flag.sm { width: 21px; height: 14px; border-radius: 3px; }

/* Status pill with a colored dot (four brand states) */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.shelved { border: 1px solid #44485a; background: rgba(136, 145, 163, 0.1); color: #aab2c2; }
.status-pill.shelved .dot { background: #8891a3; }
.status-pill.reading { border: 1px solid #4a3a55; background: rgba(179, 148, 196, 0.08); color: var(--mauve); }
.status-pill.reading .dot { background: var(--mauve); }
.status-pill.finished { border: 1px solid #35513f; background: rgba(90, 168, 122, 0.1); color: #7fc49a; }
.status-pill.finished .dot { background: #5aa87a; }
.status-pill.wishlist { border: 1px solid #463a5e; background: rgba(143, 99, 204, 0.1); color: #b58fe0; }
.status-pill.wishlist .dot { background: var(--accent); }

/* Gold section labels (uppercase, wide tracking) */
.dsection-label,
.detail-stat-label,
.dfacts-label {
  font: 600 11px var(--font-sans); letter-spacing: 0.16em;
  color: var(--gold); text-transform: uppercase;
}
.detail-stat-label { font-weight: 700; font-size: 10px; letter-spacing: 0.14em; }

/* Tag chips - bordered, muted fill, lilac text */
.tag-chip {
  background: rgba(255, 255, 255, 0.02); color: var(--lilac);
  border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 14px; font-size: 13px;
}
.tag-chip.clickable:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

/* Stat tiles - card surface, serif numbers, gold labels */
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  border-top: 3px solid var(--accent); padding: 15px 10px;
}
.stat-card.gold { border-top-color: var(--gold); }
.stat-card .stat-value {
  font-family: var(--font-display); font-weight: 700; color: var(--ink);
  font-size: 26px; line-height: 1;
}
.stat-card .stat-label {
  font: 600 10px var(--font-sans); letter-spacing: 0.14em;
  color: var(--gold); text-transform: uppercase;
}
.stat-card.gold .stat-value { color: var(--ink); }

/* Book detail hero stat row - matches the iOS layout: three centered columns
   (Rating / Status / Spice), each with a gold label above its value. */
.detail-statgrid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  align-items: start; justify-items: center;
}
.detail-stat { align-items: center; text-align: center; gap: 10px; }
.detail-statgrid .detail-stat-label { font-size: 10px; letter-spacing: 0.14em; }
.detail-stars .star { color: var(--star-empty); }
.detail-stars .star.on { color: var(--gold); }

/* ============================================================================
   Web redesign (Canvas handoff): desktop shell + All-books page.
   Appended last so these rules win. Theme-aware via the brand tokens above.
   ============================================================================ */

/* Top bar: app-icon + wordmark/sublabel lockup, gradient primary, icon buttons. */
header.app-bar { padding: 18px 26px; border-bottom: 1px solid var(--border-soft); }
header.app-bar .brand { gap: 14px; }
header.app-bar .brand-icon { width: 46px; height: 46px; border-radius: 11px; display: block; }
header.app-bar .brand-lockup h1 {
  font-size: 26px; line-height: 1; letter-spacing: 0.01em; font-weight: 700; color: var(--ink);
}
.app-bar-actions { gap: 10px; }
.app-bar-actions button { transform: none; }
.app-bar-actions button:hover { transform: none; box-shadow: none; }
.tb-primary, .tb-btn, .tb-icon, .tb-ghost { white-space: nowrap; }
/* Tighten the action row on a narrow laptop so all buttons (incl. Log out) fit. */
@media (max-width: 1320px) {
  .tb-primary, .tb-btn, .tb-ghost { padding-left: 12px; padding-right: 12px; }
}
.tb-primary, .tb-btn, .tb-icon, .tb-ghost {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 600 14px var(--font-sans); border-radius: 11px;
}
.tb-primary {
  padding: 11px 18px; color: #fff; border: none;
  background: var(--accent-grad);
  box-shadow: 0 6px 18px -8px rgba(143, 99, 204, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.tb-btn { padding: 11px 16px; color: var(--lilac); background: var(--panel); border: 1px solid var(--border); }
.tb-btn:hover { border-color: var(--mauve); }
.tb-icon {
  width: 42px; height: 42px; padding: 0; justify-content: center;
  background: var(--panel); border: 1px solid var(--border);
}
.tb-ghost { padding: 11px 16px; color: var(--muted); background: transparent; border: 1px solid var(--surface-2); }

/* Layout widens to the 1440 shell. The sidebar is the only persistent nav. */
.layout { gap: 0; padding: 0; margin: 0 auto; }

/* Sidebar: 264px, gold section heads, amethyst active library pill + badge.
   A flex column so the user/settings footer pins to the bottom. */
.sidebar {
  width: 264px; flex: none; border-right: 1px solid var(--border-soft);
  padding: 24px 18px; margin: 0;
  display: flex; flex-direction: column; min-height: calc(100vh - var(--appbar-h));
}

/* Pinned bottom: avatar + username + settings gear. */
.sidebar-foot {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.sf-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #473468, #291f3e); color: #efe9f2;
  font: 700 14px var(--font-display); text-transform: uppercase;
}
.sf-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-gear {
  width: 34px; height: 34px; flex: none; border-radius: 9px; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: none; border: 1px solid var(--border); color: var(--muted);
}
.sf-gear:hover { border-color: var(--mauve); color: var(--mauve); }
.nav-group { margin: 0 0 4px; }
.nav-group + .nav-group { margin-top: 20px; }
.nav-head {
  font: 700 11px var(--font-sans); letter-spacing: 0.16em; color: var(--gold);
  text-transform: uppercase; margin: 0 0 12px 6px;
}
.library-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 11px; font-size: 14px; color: var(--lilac);
}
.library-list li.active {
  background: var(--accent-grad);
  box-shadow: 0 6px 16px -8px rgba(143, 99, 204, 0.6); margin-bottom: 4px;
}
.library-list li.active .lib-name { color: #fff; font-weight: 600; }
.library-list li.active .count {
  background: rgba(255, 255, 255, 0.22); color: #fff; font-weight: 700;
  border-radius: 7px; padding: 1px 8px; font-size: 12px;
}
.library-list .count { color: var(--faint, #6b6473); font-size: 12px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px;
  border-radius: 11px; color: var(--lilac); font-size: 14px; background: none; border: none;
  width: 100%; text-align: left; cursor: pointer; transform: none;
}
.nav-link:hover { background: var(--surface-2); transform: none; box-shadow: none; }

/* Content area + filter rows. */
.content { flex: 1; min-width: 0; padding: 26px 30px; }

/* All-books row cards (the list view) matched to the Canvas spec. Single column
   at a comfortable reading width by default; on a wide desktop it flows into two
   columns (capped so rows don't over-stretch on an ultrawide) instead of leaving
   the right half of the screen empty. */
#items-grid.list { display: grid; grid-template-columns: 1fr; gap: 10px; }
/* Laptops stay single-column; wide desktops get two columns; ultrawides three.
   Each tier is width-capped so rows keep a comfortable ~600px, not stretched. */
@media (min-width: 1600px) {
  #items-grid.list { grid-template-columns: 1fr 1fr; gap: 10px 16px; max-width: 1280px; }
}
@media (min-width: 2000px) {
  #items-grid.list { grid-template-columns: 1fr 1fr 1fr; max-width: 1920px; }
}
.row-item {
  display: flex; align-items: center; gap: 18px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px; padding: 16px 20px;
}
.row-item:hover { background: var(--panel); border-color: var(--mauve); }
.row-cover { width: 58px; height: auto; aspect-ratio: 2 / 3; flex: 0 0 58px; border-radius: 8px; }
.row-meta { flex: 1; min-width: 0; }
.row-meta .title { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.15; color: var(--ink); }
.row-meta .author { font-size: 14px; color: var(--muted); margin-top: 2px; }
.row-flags { margin-top: 10px; }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; flex: 0 0 auto; }
.row-right .stars { color: var(--gold); font-size: 14px; letter-spacing: 1px; }

/* Status pill (no gold), four states. */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.reading { color: #b394c4; border-color: #4a3a55; background: rgba(179, 148, 196, 0.08); }
.status-pill.reading .dot { background: #b394c4; }
.status-pill.finished { color: #7fc49a; border-color: #35513f; background: rgba(90, 168, 122, 0.1); }
.status-pill.finished .dot { background: #5aa87a; }
.status-pill.wishlist { color: #b58fe0; border-color: #463a5e; background: rgba(143, 99, 204, 0.12); }
.status-pill.wishlist .dot { background: #8f63cc; }
.status-pill.owned { color: #aab2c2; border-color: #44485a; background: rgba(136, 145, 163, 0.1); }
.status-pill.owned .dot { background: #8891a3; }

/* Empty states (handoff): amethyst icon badge, serif headline, explainer, CTA. */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 60px 24px; color: var(--ink);
}
.empty-state .es-badge {
  width: 62px; height: 62px; border-radius: 17px; background: rgba(143, 99, 204, 0.14);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px; color: var(--mauve);
}
.empty-state .es-badge svg { width: 27px; height: 27px; }
.empty-state .es-head { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink); }
.empty-state .es-text { color: var(--muted); font-size: 14px; margin-top: 7px; max-width: 360px; line-height: 1.45; }
.empty-state .es-cta {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 18px; border-radius: 11px; border: none; color: #fff;
  font: 600 14px var(--font-sans); background: var(--accent-grad);
  box-shadow: 0 6px 16px -8px rgba(143, 99, 204, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.empty-state .es-cta:hover { transform: translateY(-1px); filter: brightness(1.06); }
.empty-state .es-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.empty-state.lg { padding: 90px 24px; }
.empty-state.lg .es-badge { width: 88px; height: 88px; border-radius: 24px; margin-bottom: 26px; }
.empty-state.lg .es-badge svg { width: 40px; height: 40px; }
.empty-state.lg .es-head { font-size: 26px; }
.empty-state.lg .es-cta { padding: 13px 24px; font-size: 15px; }

/* Tool views read as full pages: a wide brand panel with a serif title. */
.modal.modal-page {
  max-width: 920px; width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px;
}
.modal.modal-page > h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--ink); margin: 0 0 4px;
}

/* Rainbow swatch for the "LGBTQ+ only" toggle (real flag colors, never themed). */
.flag-swatch-rainbow {
  display: inline-block; width: 20px; height: 13px; border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2); vertical-align: -2px;
  background: linear-gradient(#e40303 0 16.6%, #ff8c00 0 33.3%, #ffed00 0 50%, #008026 0 66.6%, #004dff 0 83.3%, #750787 0 100%);
}

/* Book detail page (Canvas layout): breadcrumb, cover + Read/Listen, then
   title/author/flag, a bordered Rating/Status/Spice row, Details + Subjects
   cards, and a synopsis. */
.modal.modal-wide { max-width: 1080px; }
.modal.modal-page > h2:empty { display: none; margin: 0; }
/* Gold although clickable - the owner's sanctioned exception to the
   gold-is-never-interactive rule (2026-07 design audit, finding 6). */
.bd-crumb { display: flex; align-items: center; gap: 8px; color: var(--gold); font-size: 14px; font-weight: 600; margin-bottom: 24px; cursor: pointer; }
.bd-layout { display: flex; gap: 36px; align-items: flex-start; }
.bd-left { width: 248px; flex: none; }
.bd-cover {
  width: 248px; aspect-ratio: 2 / 3; border-radius: 14px; background-size: cover;
  background-position: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 18px 36px -16px rgba(0,0,0,.7);
}
.bd-cover.cover-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.bd-cover.cover-ph .cover-title { font-family: var(--font-display); font-weight: 700; font-size: 25px; line-height: 1.2; color: var(--cream); }
.bd-cover.cover-ph .cover-rule { width: 30px; height: 2px; background: var(--gold); border-radius: 2px; margin-top: 14px; }
/* The media (Read/Listen) actions sit right under the cover. */
.bd-left .detail-section { margin-top: 18px; }
.bd-right { flex: 1; min-width: 0; }
.bd-title { font-family: var(--font-display); font-weight: 700; font-size: 40px; color: var(--ink); line-height: 1.04; }
.bd-author { font-size: 18px; color: var(--muted); margin-top: 7px; }
.bd-flag { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.bd-statrow {
  display: flex; gap: 48px; margin-top: 26px; padding: 22px 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.bd-statcol .lbl { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); text-transform: uppercase; margin-bottom: 9px; }
.bd-statcol .stars, .bd-statcol .detail-stars { color: var(--gold); font-size: 20px; letter-spacing: 2px; }
.bd-none { color: var(--muted); font-size: 14px; }
.bd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 24px; align-items: start; }
.bd-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.bd-card-label { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); text-transform: uppercase; margin-bottom: 14px; }
.bd-facts { display: flex; flex-direction: column; gap: 11px; font-size: 14px; }
.bd-fact { display: flex; justify-content: space-between; gap: 16px; }
.bd-fact .k { color: var(--muted); }
.bd-fact .v { color: var(--ink); text-align: right; }
.bd-fact .v a, .bd-fact .v button { color: var(--ink); background: none; border: none; padding: 0; cursor: pointer; font: inherit; }
.bd-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.bd-chip {
  padding: 7px 13px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--lilac); font-size: 13px; cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.bd-chip:not(.cw):hover { border-color: var(--accent); color: var(--accent); }
.bd-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bd-chip.cw { color: #e2a0a0; border-color: #5a3a3a; cursor: default; }
.bd-synopsis {
  margin-top: 18px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px;
}
.bd-synopsis-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.bd-synopsis-head .bd-card-label { margin-bottom: 0; }
/* Cap the synopsis height so it never blows up the page; scroll inside the box,
   or click it / the magnifier to read the whole thing in an overlay. */
.bd-synopsis .text {
  color: var(--lilac); font-size: 15px; line-height: 1.7;
  max-height: 168px; overflow-y: auto; cursor: zoom-in;
}
.bd-expand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted); cursor: pointer;
}
.bd-expand:hover { color: var(--ink); border-color: var(--mauve); }
/* Full-synopsis overlay (stacks over the detail page). */
.synopsis-popup { max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; }
.synopsis-popup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.synopsis-popup-head h2 { margin: 0; }
.synopsis-popup-body {
  overflow-y: auto; color: var(--lilac); font-size: 15px; line-height: 1.75;
  white-space: pre-wrap; padding-right: 4px;
}
.bd-quickrow { margin-top: 24px; display: flex; gap: 10px; align-items: center; }

/* ============================================================================
   Web design audit (Canvas) corrections. Appended last to win the cascade.
   ============================================================================ */

/* Tool/detail page titles are 32px serif (was 26). */
.modal.modal-page > h2 { font-size: 32px; }

/* Hoard stats: 2x2 -> 4-up accent tiles, bigger serif numerals, gold labels. */
.stat-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px; }
.stat-card .stat-value { font-size: 34px; }
.stat-card .stat-label { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); margin-top: 9px; text-transform: uppercase; }

/* Tool-modal list rows are panel cards (#211b27), not the raised hairline rows. */
.tbr-list { gap: 13px; }
.tbr-row {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 20px; gap: 18px;
}
.tbr-meta .title { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--ink); }
.readnext-pick {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 13px 18px;
}
.readnext-meta .title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.loc-line {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 18px; gap: 14px;
}
.loc-line .count { font-size: 13px; }
.loc-room-line, .series-name {
  font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--ink);
}
.series-row {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px 20px;
}
.vibe-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 15px; gap: 14px; align-items: center;
}
.vibe-meta .title { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); }

/* Settings: gold section labels and panel cards. */
.admin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 8px 22px 16px; margin: 0 0 18px; }
.admin-card-title { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); text-transform: uppercase; }
.admin-card .hint { color: var(--muted); font-size: 12px; }

/* Settings page: subtitle under the title + standard rows. */
.settings-sub { color: var(--muted); font-size: 15px; margin: -4px 0 22px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 0; border-bottom: 1px solid var(--border-soft);
}
.admin-card .set-row:last-child { border-bottom: none; }
.set-row-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.set-row-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.set-row .admin-actions { margin: 0; }
.set-select {
  border-radius: 10px; padding: 10px 13px; font-size: 14px; cursor: pointer;
  background: var(--field-bg); border: 1px solid var(--field-border); color: var(--ink);
}

/* Pill toggle switch (accent gradient on, muted off, white thumb). */
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; padding: 3px; transition: background .15s ease;
}
.switch input:checked + .switch-track { background: var(--accent-grad); border-color: transparent; }
.switch-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .15s ease;
}
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }

/* Accent color picker swatches. */
.accent-swatches { display: flex; gap: 10px; }
.accent-swatch {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.accent-swatch.sel { border-color: var(--ink); }

/* Library-default: hide spice flames everywhere when toggled off. */
body.hide-spice .spice { display: none; }

/* Add/Edit book form: gold field labels + spec input shape. */
.modal-page label { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); text-transform: uppercase; }
.modal-page input[type="text"], .modal-page input[type="search"], .modal-page input[type="number"],
.modal-page input[type="url"], .modal-page textarea, .modal-page select {
  border-radius: 11px; padding: 12px 15px; font-size: 14px;
}
/* Primary + secondary action buttons in page modals. */
.modal-page .modal-actions button:not(.secondary):not(.danger) {
  padding: 13px 26px; border-radius: 12px; font-weight: 600; font-size: 15px;
  background: var(--accent-grad); color: #fff; border: none;
}
.modal-page .modal-actions button.secondary {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 13px 22px; border-radius: 12px; font-weight: 600; font-size: 15px;
}

/* Empty states: faint body copy; larger first-run headline/body. */
.empty-state .es-text { color: var(--muted); }
.empty-state.lg .es-head { font-size: 30px; }
.empty-state.lg .es-text { font-size: 16px; max-width: 440px; }

/* Row cards: cover drop shadow + visible gold rule on placeholders. */
.row-cover { box-shadow: inset 0 0 0 1px rgba(255,255,255,.07), 0 8px 16px -8px rgba(0,0,0,.6); }
.row-cover.cover-ph .cover-rule { display: block; width: 14px; height: 2px; margin-top: 6px; }
.row-cover.cover-ph .cover-title { font-size: 9px; }
.row-stars { gap: 10px; }
.status-pill.finished { border-color: #4a4a3a; }
.flag-chip { padding: 5px 12px 5px 6px; }

#view-toggle { width: 40px; height: 38px; padding: 0; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); }

/* Shell detail tweaks. */
.tb-ghost { border-color: var(--border-soft); }
#add-library-btn { color: var(--muted); }
.library-list li.active { padding: 11px 14px; }
.nav-group + .nav-group { margin-top: 24px; }
.nav-head { margin-bottom: 10px; }

/* Two-row filter bar (replaces the single .toolbar row). */
.filter-row-1 { display: flex; gap: 12px; margin-bottom: 14px; }
.filter-row-2 { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.filter-row-1 .search-pill {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 11px 15px;
}
.filter-row-1 .search-pill svg { flex: none; color: var(--muted); }
.filter-row-1 .search-pill input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--ink); font: inherit; font-size: 14px;
}
.filter-row-1 > select, .filter-row-1 > input[type="search"] {
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  padding: 11px 15px; color: var(--ink); font-size: 14px;
}
#status-filter { width: 170px; }
#subject-filter { width: 230px; }
#trope-filter { width: 190px; }
#heat-filter { width: 150px; }
.filter-row-2 .toggle { display: flex; align-items: center; gap: 9px; color: var(--lilac); font-size: 14px; font-weight: 500; }
.filter-row-2 #sort { padding: 9px 13px; border-radius: 10px; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); }
.filter-row-2 .toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 19px; height: 19px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel); cursor: pointer; position: relative; margin: 0;
}
.filter-row-2 .toggle input[type="checkbox"]:checked { background: var(--accent-grad); border-color: #7e54bd; }
.filter-row-2 .toggle input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.filter-spacer { flex: 1; }
.result-count { color: var(--faint); font-size: 13px; }

/* Filter-row icon buttons (More filters / view / select). A cohesive set of
   equal squares, height-matched to the sort dropdown beside them, with one
   glyph size and centering so no icon looks bigger or off-center. Muted at
   rest, accent on hover, accent-tinted when active (view/select toggles carry
   .active / .on). */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; position: relative;
  width: 38px; height: 38px; padding: 0; border-radius: 10px;
  color: var(--muted);
}
.icon-btn .ph {
  font-size: 18px; line-height: 1; display: block;
  transition: transform 0.12s ease;
}
.icon-btn.secondary:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.secondary:hover .ph { transform: scale(1.08); }
.icon-btn.secondary:active .ph { transform: scale(0.94); }
.icon-btn.on, .icon-btn.active,
.icon-btn.on:hover, .icon-btn.active:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft);
}
/* "More filters" carries an accent dot when any of its filters are active, so a
   filter set in the (collapsed) panel isn't invisible. */
.more-filters-dot {
  position: absolute; top: 4px; right: 4px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.more-filters-dot[hidden] { display: none; }
.more-filters {
  display: flex; flex-wrap: wrap; gap: 14px 18px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 18px;
}
/* The class sets display:flex, which would beat the hidden attribute's implicit
   display:none - so the collapsed panel needs this explicit override. */
.more-filters[hidden] { display: none; }
.mf-field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.mf-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--muted);
}
/* Full-width divider label inside the More-filters panel (e.g. "Show all except…")
   so the exclusion pickers read as their own group. */
.mf-section {
  flex-basis: 100%; margin-top: 4px; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--gold, var(--muted));
}

/* Book detail: the Series row's inline "Identify" (AI) button sits after the value. */

/* Bulk "Find missing series" review list: one checkable row per suggestion. */
.series-sug-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.series-sug-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.series-sug-cover {
  width: 42px; height: 62px; flex: none; border-radius: 6px; overflow: hidden;
  background-size: cover; background-position: center;
  border: 1px solid var(--border);
}
/* Coverless book: keep just the gradient placeholder, drop its title/rule (too
   cramped at thumbnail size). */
.series-sug-cover .cover-title, .series-sug-cover .cover-rule { display: none; }
.series-sug-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.series-sug-title { font-weight: 600; color: var(--ink); }
.series-sug-author { font-size: 0.82rem; color: var(--muted); }
.series-sug-move { font-size: 0.85rem; color: var(--lilac, var(--accent)); margin-top: 2px; }
.series-sug-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.series-sug-conf {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--gold, var(--muted)); font-weight: 700;
}
/* Source tag: a web-grounded hit (Goodreads) is trustworthy; a plain-model
   "guess" earns scrutiny. */
.series-sug-src {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.series-sug-src.src-web { color: var(--accent-ink, #fff); background: var(--accent); }
.series-sug-src.src-model {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent);
}

/* Pride-flag swatch inside a chip: 1px translucent white border (not a dark inset). */
.flag-chip .flag { box-shadow: none; border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); }

/* Book detail: Read (mauve) + Listen (teal) actions under the cover. */
.bd-media-row { display: flex; gap: 12px; margin-top: 18px; }
.bd-media {
  cursor: pointer; border: none; border-radius: 13px; padding: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px var(--font-ui, "Hanken Grotesk", sans-serif);
  box-shadow: 0 8px 22px -8px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.14);
}
.bd-media .g { font-size: 15px; }
.bd-media.read { flex: 1.5; color: #f0eaf4; background: linear-gradient(180deg, #5f4a6b, #3a2c45); }
.bd-media.listen { flex: 1; color: #e4eef0; background: linear-gradient(180deg, #2f545f, #1d3a42); }
.bd-media:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 10px 24px -8px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.14); }

/* Book detail secondary actions (TBR + more-like): full-width bordered pills
   stacked directly beneath the Read / Listen media buttons. */
.bd-actions-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.bd-actions-col .detail-tbr, .bd-actions-col .secondary {
  width: 100%; justify-content: center; cursor: pointer;
  background: transparent; border: 1px solid var(--border);
  color: var(--lilac); border-radius: 12px; padding: 12px 18px;
  font: 600 14px var(--font-ui, "Hanken Grotesk", sans-serif);
  display: inline-flex; align-items: center; gap: 7px;
}
.bd-actions-col .detail-tbr.on {
  background: rgba(143,99,204,.14); border-color: #7e54bd; color: #b58fe0;
}
.bd-actions-col .detail-tbr:hover, .bd-actions-col .secondary:hover {
  border-color: var(--mauve); transform: none; box-shadow: none;
}

/* Admin Users: stack the username + its SSO email, and a quieter email line. */
.user-name-col { display: flex; flex-direction: column; gap: 2px; }
.user-email { font-size: 0.78rem; color: var(--muted); }

/* --- Light mode (Warm Paper) overrides for dark-tuned status colors --- */
/* The status-pill + content-warning rules above are dark-only hues; on white
   cards they wash out. These lift them to the design's light values. */
[data-theme="light"] .status-pill.reading { color: #6a45a2; border-color: #e6dcee; background: #f1ebf3; }
[data-theme="light"] .status-pill.reading .dot { background: #6a45a2; }
[data-theme="light"] .status-pill.finished { color: #2f8a5b; border-color: #cfe7d8; background: rgba(47, 138, 91, 0.1); }
[data-theme="light"] .status-pill.finished .dot { background: #2f8a5b; }
[data-theme="light"] .status-pill.wishlist { color: #6a45a2; border-color: #e6dcee; background: rgba(106, 69, 162, 0.1); }
[data-theme="light"] .status-pill.wishlist .dot { background: #6a45a2; }
[data-theme="light"] .status-pill.owned,
[data-theme="light"] .status-pill.shelved { color: #6e6477; border-color: #ddd6c8; background: rgba(110, 100, 119, 0.08); }
[data-theme="light"] .status-pill.owned .dot,
[data-theme="light"] .status-pill.shelved .dot { background: #8891a3; }
[data-theme="light"] .bd-chip.cw { color: #a1432f; border-color: #e6c9c0; background: rgba(161, 67, 47, 0.06); }

/* Inline error text inside auth + form modals. */
.modal-error { color: var(--danger); font-size: 13px; font-weight: 500; margin-top: 2px; }

/* Admin → Invites list. */
.invites-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.invite-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); }
.invite-row.spent { opacity: 0.55; }
.invite-code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--ink); letter-spacing: 0.04em; }
.invite-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.invite-meta .hint { font-size: 12px; }
.invite-actions { display: flex; gap: 6px; flex: none; }

/* ============================================================================
   Inline content-area pages (Settings et al.) — a real page in the content
   column, not a floating modal. The sidebar stays live; the catalog grid is
   hidden while a page is shown.
   ============================================================================ */
.page-view { max-width: 920px; }
/* Wide pages (Settings): let the two-column card layout breathe instead of
   leaving the right half of a big monitor empty. */
.page-view.page-wide { max-width: 1540px; }
.content.show-page > .filter-row-1,
.content.show-page > .filter-row-2,
.content.show-page > #more-filters,
.content.show-page > #active-filters,
.content.show-page > #items-grid,
.content.show-page > #empty-state { display: none !important; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 32px; color: var(--ink); margin: 0; line-height: 1.1; }
.page-close {
  flex: none; width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.page-close:hover { color: var(--ink); border-color: var(--ink); }
.page-body { margin-top: 8px; }

/* The Settings cards were authored against `.modal-page`; mirror the field +
   button styling now that Settings lives inside `.page-view`. */
.page-view label { font: 700 11px var(--font-sans); letter-spacing: .16em; color: var(--gold); text-transform: uppercase; }
.page-view input[type="text"], .page-view input[type="search"], .page-view input[type="number"],
.page-view input[type="url"], .page-view input[type="password"], .page-view textarea, .page-view select {
  border-radius: 11px; padding: 12px 15px; font-size: 14px;
}

/* Title-search candidate picker (Check + Add fallback when there's no barcode). */
.cand-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.cand-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--ink); cursor: pointer; font: inherit;
}
.cand-row:hover { border-color: var(--accent); }
.cand-cover { width: 38px; height: 57px; flex: none; border-radius: 6px; background-size: cover; background-position: center; background-color: var(--surface-2); }
.cand-cover-ph { background: linear-gradient(135deg, var(--surface-2), var(--panel)); }
.cand-meta { min-width: 0; }
.cand-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); }

/* ============================================================================
   Web feedback fixes (settings + sidebar). Appended last to win the cascade.
   ============================================================================ */

/* Bug: the user/settings footer scrolled off on tall pages (e.g. Settings)
   because it pinned to the bottom of a stretched sidebar. Stick it to the
   viewport bottom so it stays visible regardless of page height. */
.sidebar-foot {
  position: sticky; bottom: 0; z-index: 1;
  margin-top: auto; padding: 14px 0 8px;
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
}

/* Bug: nav items didn't read as buttons. Give them (and the non-active library
   rows) a hairline border + a clearer hover. */
.nav-link, .library-list li:not(.active) {
  border: 1px solid var(--border-soft);
}
.library-list li:not(.active) { cursor: pointer; margin-bottom: 4px; }
.nav-link:hover,
.library-list li:not(.active):hover {
  background: var(--surface-2); border-color: var(--border);
}
#add-library-btn, #save-shelf-btn { color: var(--muted); }

/* Bug: the Settings "Dark mode" switch is now an explicit reflection of the
   live theme (synced from applyTheme), so no extra CSS needed - just here for
   the record. */

/* Bug: admin/Users inputs (e.g. the email field, type=email) weren't themed and
   showed a white box in dark mode. Theme every settings input, not just a few
   named types. */
.page-view input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.page-view textarea,
.page-view select {
  background: var(--field-bg); border: 1px solid var(--field-border); color: var(--ink);
  border-radius: 11px; padding: 12px 15px; font-size: 14px;
}
.page-view input::placeholder, .page-view textarea::placeholder { color: var(--faint); }

/* Settings page: align font + spacing to the Claude Design settings mockup. */
.page-body.settings-body { max-width: 760px; margin-top: 0; }
.content.show-page .page-head { margin-bottom: 4px; }
.settings-sub { color: var(--muted); font-size: 15px; margin: 2px 0 26px; max-width: 620px; }
.admin-card { padding: 6px 22px 16px; margin: 0 0 18px; box-shadow: var(--shadow); }
/* A "feature" card (the marquee thing on a tab) gets a thin gold top rule. */
.admin-card.feature { border-top: 2px solid var(--gold); }
.admin-card-title {
  padding: 16px 0 5px; margin: 0; display: flex; align-items: center; gap: 8px;
}
/* An inline glyph in a card title reads as a quiet label, not an action. */
.admin-card-title i { color: var(--muted); font-size: 15px; }
.set-row-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.set-row-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
/* Focus ring on settings inputs/selects, matching the mockup. */
.page-view input:focus, .page-view textarea:focus, .page-view select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}

/* On the stacked (narrow) layout the sidebar isn't a tall column, so don't pin
   the footer to the viewport bottom (it would float over content). */
@media (max-width: 879px) {
  .sidebar-foot { position: static; }
}

/* In-panel login steps (forgot / redeem / reset): a "Back to log in" link and
   matching field spacing, so the flow reads as part of the branded login. */
.login-back {
  display: inline-block; background: none; border: 0; cursor: pointer;
  color: #b394c4; font-size: 13px; font-weight: 600; margin-top: 18px; padding: 6px 0;
}
.login-back:hover { color: #cdb574; }
#login-step .login-title { margin-top: 4px; }

/* Safety net: theme any input inside a dialog (some modals build raw inputs that
   otherwise render as a white box in dark mode). */
.modal input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.modal textarea, .modal select {
  background: var(--field-bg); border: 1px solid var(--field-border); color: var(--ink);
}
.modal input::placeholder, .modal textarea::placeholder { color: var(--faint); }

/* Branded confirmation dialog (replaces native confirm()). */
.modal.modal-confirm { max-width: 440px; }
.modal.modal-confirm h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); margin: 0 0 4px; }
.modal.modal-confirm .confirm-text { color: var(--muted); font-size: 14.5px; line-height: 1.55; margin: 4px 0 4px; }
.modal.modal-confirm .modal-actions { margin-top: 18px; }

/* Wider content cap so large monitors fill more of the screen (the design is
   1440-based; this lets 1440p/4K windows show more book columns). Beyond this,
   centered margins are intentional for readable line lengths. */

/* ---- Book-detail polish (iOS parity) ---------------------------------------- */
/* Center each stat (Rating / Status / Spice) under its label, in equal columns. */
.bd-statrow { gap: 24px; justify-content: space-between; }
.bd-statcol { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.bd-statcol .lbl { margin-bottom: 11px; }

/* Read / Listen: equal width, with crisp line glyphs + a saved-progress percent. */
.bd-media.read, .bd-media.listen { flex: 1; }
.bd-media .g { display: inline-flex; align-items: center; }
.bd-media .g svg { width: 18px; height: 18px; }
.bd-media-pct { font-weight: 500; opacity: 0.82; }

/* Icons on the secondary detail actions (Add to TBR / More books like this). */
.bd-actions-col .g { display: inline-flex; align-items: center; }
.bd-actions-col .g svg { width: 16px; height: 16px; }

/* Home / catalog cards: slightly larger, easier-to-read type. */
.card .meta .title { font-size: 1rem; }
.card .meta .author { font-size: 0.85rem; }
.card .meta .stars { font-size: 0.9rem; }

/* Location picker (Add/Edit book): a select of existing values + a "New..."
   text field that appears when chosen. */
.loc-combo { display: flex; flex-direction: column; gap: 8px; }
.loc-combo input[hidden] { display: none; }

/* ---- Icon cohesion pass ----------------------------------------------------
   Rounded joins/caps for the remaining real inline SVGs (back chevron, TBR /
   similar buttons, search magnifier). Nav/top-bar icons are Phosphor now. */
.bd-crumb svg, .bd-actions-col .g svg, .search-pill svg, .filter-row-1 svg {
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---- QA round 1 fixes ------------------------------------------------------- */
/* #21/#22: keep Read/Listen on one line even with the saved % on the Read button. */
.bd-media { white-space: nowrap; gap: 6px; padding: 13px 9px; font-size: 14px; }
.bd-media-pct { font-size: 12px; opacity: .82; }

/* #26: delete confirmations stack OVER the open page (book detail) and sit
   centered on screen, not pinned to the top. */
.confirm-backdrop { align-items: center; z-index: 400; }
/* Center small dialogs vertically. Using auto margins (not align-items:center)
   so a dialog taller than the viewport falls back to top-aligned + scroll
   instead of clipping its top. */
.modal-backdrop.modal-centered .modal { margin: auto 0; }

/* #28: lock the sidebar in place so its nav stays reachable while a long page
   (Settings) scrolls. --appbar-h = the sticky header's height. */
.sidebar {
  position: sticky; top: var(--appbar-h); align-self: flex-start;
  height: calc(100vh - var(--appbar-h)); overflow-y: auto;
}
@media (max-width: 879px) {
  .sidebar { position: static; height: auto; overflow: visible; }
}
/* Wider content on big monitors (1760 still left large margins on an ultrawide). */
.layout { max-width: 2000px; }

/* ---- #24 catalog cards ------------------------------------------------------ */
/* List view: bigger cover + larger right-side stars / flames. */
.row-cover { width: 80px; flex: 0 0 80px; }
.row-right .stars { font-size: 16px; }
.row-stars { font-size: 16px; align-items: center; }
/* Grid view: align the stars and the spice flames on one baseline. */
.card .meta .stars { display: inline-flex; align-items: center; }
/* Bigger pride-flag chips across list / grid / detail. */
.flag-chip .flag.sm { width: 24px; height: 16px; }
.flag-chip { font-size: 12.5px; }

/* ---- #25 Locations: manage / add ------------------------------------------- */
.loc-line .count { display: inline-flex; align-items: center; gap: 8px; }
.loc-del {
  /* Red, always: it deletes. (Without an explicit background this picked up
     the global button accent gradient and read as just another purple chip.) */
  color: var(--danger); font-size: 12px; line-height: 1; padding: 3px 8px;
  border-radius: 999px; cursor: pointer; box-shadow: none;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}
.loc-del:hover {
  background: var(--danger); color: #fff; border-color: var(--danger);
  box-shadow: none;
}
.loc-add {
  margin-top: 18px; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-2);
}
.loc-add-head { font-weight: 600; margin-bottom: 10px; }
.loc-add-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.loc-add-fields input { width: 100%; }

/* ---- #27 delete-user catalog choice ---------------------------------------- */
.confirm-check {
  display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); cursor: pointer; text-align: left;
}
.confirm-check input { width: auto; margin-top: 2px; flex: none; }
.confirm-check strong { display: block; font-size: 0.92rem; }
.confirm-check-sub { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }

/* ---- dev/prod staging box ---------------------------------------------------- */
.env-badge {
  align-self: center; margin-left: 10px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  color: #1c1410; background: linear-gradient(180deg, #e8c97a, #cdb574);
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
/* A thin amber hairline at the very top so dev never gets mistaken for prod. */
body.is-dev::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #cdb574, #e8c97a, #cdb574); z-index: 1000;
}
.dev-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--gold); border-radius: 12px;
  background: rgba(205, 181, 116, .10); color: var(--ink); font-size: 14px; line-height: 1.45;
}
.dev-chip {
  flex: none; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800;
  letter-spacing: .1em; color: #1c1410; background: linear-gradient(180deg, #e8c97a, #cdb574);
}
.incoming-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.incoming-list li { font-family: var(--mono, ui-monospace, monospace); }

/* ---- settings sub-blocks (Staging, API keys) -------------------------------- */
.set-block { padding: 14px 0; border-top: 1px solid var(--border); }
.set-block:first-of-type { border-top: none; padding-top: 6px; }
.set-block-head { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.set-block-sub { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-bottom: 9px; }
.staging-intro { margin-bottom: 6px; }
.api-keys .set-block input { min-width: 240px; }
/* The login-screen DEV badge sits inline with the wordmark. */
.login-wordmark .env-badge { font-size: 10px; padding: 2px 7px; vertical-align: 3px; }

/* ---- Server settings (collapsible grouped config) -------------------------- */
.cfg-group {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  margin: 8px 0; overflow: hidden;
}
.cfg-group-head {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; font: 700 13.5px var(--font-sans); color: var(--ink);
}
.cfg-group-head::-webkit-details-marker { display: none; }
.cfg-group-head::after {
  /* Phosphor ph-caret-down glyph (a pseudo-element can't hold an <i>). */
  content: "\e136"; font-family: "Phosphor"; color: var(--muted); font-size: 15px; line-height: 1;
  transition: transform .15s ease; margin-left: 4px;
}
.cfg-group[open] > .cfg-group-head::after { transform: rotate(180deg); }
.cfg-group[open] > .cfg-group-head { border-bottom: 1px solid var(--border); }
.cfg-group-count { margin-left: auto; font: 600 11.5px var(--font-sans); color: var(--muted); }
.cfg-group > .set-block { padding: 12px 14px; border-top: 1px solid var(--border); }
.cfg-group > .set-block:first-of-type { border-top: none; }
.server-settings .set-block input,
.server-settings .set-block textarea { width: 100%; }
.server-settings .set-block textarea { resize: vertical; min-height: 110px; font-family: inherit; line-height: 1.5; }
.cfg-bool { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cfg-bool .set-block-sub { margin-bottom: 0; }
/* The "changes apply right away" reminder at the foot of every config card. */
.cfg-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }

/* ---- Settings: tabbed sub-nav (replaces the one long scroll) ---------------- */
.page-body.settings-body { max-width: 1540px; }
.settings-layout { display: flex; gap: 26px; align-items: flex-start; }
.settings-nav {
  position: sticky; top: var(--appbar-h); flex: 0 0 180px; display: flex; flex-direction: column; gap: 3px;
}
.settings-tab {
  text-align: left; background: transparent; border: none; color: var(--muted);
  padding: 10px 14px; border-radius: 10px; font: 600 14.5px var(--font-sans); cursor: pointer;
  border-left: 3px solid transparent;
  display: flex; align-items: center; gap: 11px; transition: color .12s, background .12s;
}
.settings-tab i { font-size: 18px; opacity: .9; flex: none; }
.settings-tab:hover { background: var(--surface-2); color: var(--ink); }
.settings-tab.active {
  background: var(--surface-2); color: var(--ink); border-left-color: var(--accent);
}
.settings-panels { flex: 1 1 auto; min-width: 0; container-type: inline-size; }
.settings-panels .admin-card:first-child { margin-top: 0; }
/* Wide screens: fill the empty right side. Measured on the panel area itself
   (container query), so browser size AND the Interface-size zoom both count:
   with enough room, cards flow into two columns - Audiobooks next to Ebooks -
   instead of one narrow stack down the left. */
@container (min-width: 980px) {
  .settings-panel:not([hidden]) {
    display: grid; grid-template-columns: 1fr 1fr;
    column-gap: 20px; align-items: start;
  }
}
@media (max-width: 820px) {
  .settings-layout { flex-direction: column; gap: 14px; }
  .settings-nav {
    position: static; flex: none; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 6px;
    border-bottom: 1px solid var(--border); padding-bottom: 12px;
  }
  .settings-tab { border-left: none; border-bottom: 2px solid transparent; padding: 8px 12px; }
  .settings-tab.active { border-left: none; border-bottom-color: var(--accent); }
}

/* ---- Accounts / roles / permissions (Claude Design settings mockup) -------- */
/* Chips */
.rl-chip { display: inline-flex; align-items: center; gap: 6px; font: 600 11.5px var(--font-sans); border-radius: 999px; padding: 4px 11px; }
.rl-chip.role-admin { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--accent); }
:root[data-theme="dark"] .rl-chip.role-admin { color: #c9a9f0; }
.rl-chip.role-manage { background: color-mix(in srgb, var(--positive) 16%, transparent); color: var(--positive); }
.rl-chip.role-member { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .rl-chip.role-member { color: #b394c4; }
.rl-chip.role-guest { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.rl-chip.role-none { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.rl-chip.set { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; font-weight: 700; }
:root[data-theme="dark"] .rl-chip.set { color: #c9a9f0; border-color: color-mix(in srgb, #c9a9f0 40%, transparent); }
.rl-chip.admin-only { background: transparent; color: var(--gold); border: 1px dashed color-mix(in srgb, var(--gold) 50%, transparent); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; padding: 3px 8px; }

/* Accounts toolbar + list */
.acct-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.acct-count { color: var(--muted); font-size: 13.5px; }
.acct-row { display: flex; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); cursor: pointer; transition: border-color .13s, transform .13s; margin-bottom: 10px; box-shadow: var(--shadow); }
.acct-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 16px var(--font-sans); color: #fff; background: var(--accent-grad); flex: none; }
.avatar.ghost { background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); }
.acct-id { flex: 1; min-width: 0; }
.acct-name { font-size: 15px; font-weight: 600; color: var(--ink); }
.acct-email { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.acct-last { font-size: 12px; color: var(--faint); text-align: right; white-space: nowrap; }

/* Detail header */
.detail-back { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); background: none; border: none; cursor: pointer; font: 600 13px var(--font-sans); padding: 0; margin-bottom: 16px; }
.detail-back:hover { color: var(--ink); }
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.detail-head .avatar { width: 56px; height: 56px; font-size: 22px; }
.detail-name { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--ink); line-height: 1.1; display: flex; align-items: center; gap: 12px; }
.detail-email { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

/* Three-way permission control */
.tri { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface-2); flex: none; }
.tri button { border: none; background: transparent; color: var(--muted); font: 600 12px var(--font-sans); padding: 7px 13px; cursor: pointer; border-right: 1px solid var(--border); transition: background .12s, color .12s; }
.tri button:last-child { border-right: none; }
.tri button:hover { color: var(--ink); }
.tri button.on[data-kind="inherit"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.tri button.on[data-kind="allow"] { background: color-mix(in srgb, var(--positive) 16%, transparent); color: var(--positive); }
.tri button.on[data-kind="deny"] { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.perm-group-title { font: 700 10.5px var(--font-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); padding: 18px 0 4px; }
.perm-row { display: flex; align-items: center; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.perm-row:last-child { border-bottom: none; }
.perm-row.admin { opacity: .82; }
.perm-main { flex: 1; min-width: 0; }
.perm-label { font-size: 14px; font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.perm-desc { font-size: 12px; color: var(--faint); margin-top: 2px; }
.perm-hint { font-size: 12px; min-width: 120px; text-align: right; flex: none; }
.perm-hint.pos { color: var(--positive); }
.perm-hint.muted { color: var(--faint); }
.perm-hint.set { color: var(--accent); font-weight: 600; }
:root[data-theme="dark"] .perm-hint.set { color: #c9a9f0; }

/* Effective-value chip: the resolved Allowed/Denied outcome + where it comes
   from (the role, or "set here" for an override), so inherited vs overridden
   is unmistakable at a glance. */
.perm-eff { min-width: 132px; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; }
.perm-eff-txt { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; }
.perm-eff-txt i { font-size: 14px; }
.perm-eff.yes .perm-eff-txt { color: var(--positive); }
.perm-eff.no .perm-eff-txt { color: var(--faint); }
.perm-eff-src { font-size: 11px; color: var(--faint); font-weight: 400; }

/* Role picker (segmented) */
.seg-roles { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; margin: 8px 0 4px; }
.seg-roles button { border: none; background: transparent; color: var(--muted); font: 600 12.5px var(--font-sans); cursor: pointer; padding: 7px 13px; border-radius: 7px; }
.seg-roles button:hover { color: var(--ink); }
.seg-roles button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Roles manager */
.role-row { display: flex; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); margin-bottom: 10px; box-shadow: var(--shadow); }
.role-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: 19px; flex: none; }
.role-main { flex: 1; min-width: 0; }
.role-name { font-size: 15px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 9px; }
.role-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.role-count { font-size: 12px; color: var(--faint); min-width: 84px; text-align: right; white-space: nowrap; }
.lock { color: var(--gold); font-size: 14px; }

/* Role edit checklist */
.check-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.check-row:last-child { border-bottom: none; }
.rl-check { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--border); background: var(--field-bg); flex: none; display: grid; place-items: center; cursor: pointer; color: transparent; font-size: 13px; transition: background .12s, border-color .12s; }
.rl-check.on { background: var(--accent-grad); border-color: transparent; color: #fff; }
.rl-check.locked { opacity: .6; cursor: default; }

/* Invite */
.invite-code-box { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 12px; padding: 15px 16px; margin: 4px 0 6px; }
.invite-code-big { font-family: var(--font-mono, ui-monospace, monospace); font-size: 17px; letter-spacing: .06em; color: var(--ink); flex: 1; word-break: break-all; }
.rl-banner { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 10px 14px; font-size: 12.5px; font-weight: 600; margin: 6px 0 12px; }

/* Empty state */
.rl-empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--border); border-radius: 16px; background: var(--panel); }
.rl-empty-ic { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 16px; display: grid; place-items: center; font-size: 26px; color: var(--accent); background: var(--surface-2); }
.rl-empty-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--ink); margin-bottom: 6px; }
.rl-empty-sub { color: var(--muted); font-size: 14px; max-width: 360px; margin: 0 auto 18px; line-height: 1.5; }

/* ---- "contact the Dragon" no-access splash --------------------------------- */
.dragon-splash { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(120% 90% at 50% -10%, #3a2c52 0%, #1a1421 55%, #0f0b14 100%); }
:root[data-theme="light"] .dragon-splash { background: radial-gradient(120% 90% at 50% -10%, #efe7f4 0%, #e6ddcf 55%, #ded4c2 100%); }
.dragon-splash .wiz-vignette { position: absolute; inset: 0; box-shadow: inset 0 0 200px 60px rgba(0,0,0,.5); pointer-events: none; }
:root[data-theme="light"] .dragon-splash .wiz-vignette { box-shadow: inset 0 0 200px 60px rgba(120,100,70,.22); }
.dragon-splash .wiz-stars { position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(1.5px 1.5px at 20% 30%, #cdb574 40%, transparent), radial-gradient(1.5px 1.5px at 70% 20%, #b394c4 40%, transparent), radial-gradient(1px 1px at 40% 70%, #efe9f2 40%, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #9a6fd4 40%, transparent), radial-gradient(1px 1px at 60% 85%, #cdb574 40%, transparent); }
:root[data-theme="light"] .dragon-splash .wiz-stars { display: none; }
.dragon-splash .wiz-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; }
.dragon-splash .wiz-brand { display: flex; align-items: center; gap: 12px; }
.dragon-splash .wiz-seal { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-grad); color: #fff; font: 700 22px var(--font-display); }
.dragon-splash .wiz-word { font: 700 21px var(--font-display); color: var(--ink); line-height: 1; }
.dragon-splash .wiz-tag { font: 600 8.5px var(--font-sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-top: 4px; }
.dragon-splash .wiz-top-actions { display: flex; gap: 10px; align-items: center; }
.dragon-splash .wiz-card { position: relative; text-align: center; width: 460px; max-width: 90vw; padding: 0 30px; }
.dragon-splash .wiz-glyph { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 28px; display: grid; place-items: center; font-size: 44px; color: #fff; background: var(--accent-grad); box-shadow: 0 20px 60px -14px var(--accent); }
.dragon-splash .wiz-title { font: 700 33px var(--font-display); color: var(--ink); line-height: 1.12; margin: 0 0 14px; }
.dragon-splash .wiz-sub { color: var(--muted); font-size: 15.5px; margin: 0 0 32px; line-height: 1.5; }
.dragon-splash .wiz-actions { display: flex; gap: 12px; justify-content: center; }

/* Freeze the page behind any open overlay (book detail, dialogs) so the catalog
   can't scroll underneath. Toggled by syncScrollLock(); the fixed modal backdrop
   still scrolls internally. */
html.scroll-locked, html.scroll-locked body { overflow: hidden; }

/* ---- #30 interface size control -------------------------------------------- */
.ui-scale { display: flex; align-items: center; gap: 12px; }
.ui-scale input[type="range"] { width: 190px; accent-color: var(--accent); }
.ui-scale-val { min-width: 46px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- #26/#27 outline the destructive button in confirm dialogs ------------- */
.modal-confirm button.danger {
  padding: 9px 16px; border: 1px solid var(--danger); border-radius: 9px;
  background: color-mix(in srgb, var(--danger) 12%, transparent); box-shadow: none;
}
.modal-confirm button.danger:hover {
  background: color-mix(in srgb, var(--danger) 22%, transparent);
  border-color: var(--danger); transform: none;
}

/* ---- #22 reading progress on the Status pill ------------------------------- */
.status-pill-pct { opacity: .85; font-variant-numeric: tabular-nums; }

/* ---- #28 keep the Settings sub-nav locked while scrolling ------------------ */
/* Give the panels a tall min-height so the sticky nav's containing block never
   ends before the viewport, so the nav can't drift up at the bottom of a page. */
.settings-panels { min-height: calc(100vh - var(--appbar-h) - 67px); }

/* ---- #24 catalog card refinements ------------------------------------------ */
/* Grid: stack rating stars over spice flames, left-aligned + same size. */
.card .meta .stars {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  font-size: 15px; letter-spacing: 1px; margin-top: 6px;
}
.card .meta .stars .spice { margin-left: 0; font-size: 15px; }

/* Cover-only (wall): larger covers + clearly visible flag swatches. */
.wall { grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 16px; }
.wall-flags { gap: 4px; top: 8px; right: 8px; }
.wall-flags .flag {
  width: 28px; height: 18px; border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.3);
}

/* List rows: bigger title/author fill the row's height (uses the empty space). */
.row-meta .title { font-size: 22px; }
.row-meta .author { font-size: 15px; }

/* ---- nav / top-bar glyph wrappers ------------------------------------------ */
/* .nav-glyph/.tb-glyph own the fixed width + optical size so labels line up;
   the glyphs inside are Phosphor <i class="ph"> (see the block below). */
.nav-glyph {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; font-size: 17px; line-height: 1;
}
.tb-glyph { display: inline-flex; align-items: center; font-size: 16px; line-height: 1; }
.tb-icon .tb-glyph, .sf-gear .tb-glyph { font-size: 18px; }

/* ---- Phosphor icon glyphs (nav + top bar) ---------------------------------- */
/* New <i class="ph …"> glyphs adopt the mauve icon color; gold stays reserved
   for section labels + rating stars, and the primary Add button keeps its white
   plus. Sizes mirror the previous optical sizes. */
.nav-link .ph,
.tb-btn .ph,
.tb-icon .ph,
.sf-gear .ph,
#view-toggle .ph { color: var(--mauve); line-height: 1; }
.tb-primary .ph { color: #fff; }
.tb-primary .ph, .tb-btn .ph { font-size: 16px; }
.tb-icon .ph, .sf-gear .ph { font-size: 18px; }
.nav-glyph .ph, .nav-link .ph { font-size: 18px; }
#view-toggle .ph { font-size: 17px; }

/* ---- branded prompt() replacement ------------------------------------------ */
.modal-confirm .prompt-input {
  width: 100%; margin: 12px 0 2px; padding: 10px 12px; font-size: 15px;
}

/* ---- account footer: an intentional chip, not a flat band ------------------ */
/* The old flat var(--bg) fill read as a stray tan strip in light mode. Make it a
   clean bordered chip that matches the app's card language in both themes. */
.sidebar-foot {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px;
  margin: auto 0 4px; padding: 9px 11px; /* keep top:auto so it stays pinned to the bottom */
}

/* ---- a11y: focus ring for the custom (appearance:none) checkboxes ---------- */
.filter-row-2 .toggle input[type="checkbox"]:focus-visible,
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- native audiobook player ------------------------------------------------ */
.audio-player { max-width: 460px; }
.ap-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ap-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.2; }
.ap-author { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.ap-close { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ap-chapter { color: var(--mauve); font-size: 13px; min-height: 1.2em; margin: 12px 0 4px; }
.ap-seek-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.ap-seek { flex: 1; accent-color: var(--accent); }
.ap-time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; flex: none; }
.ap-controls { display: flex; align-items: center; justify-content: center; gap: 22px; margin-bottom: 14px; }
.ap-play {
  width: 62px; height: 62px; border-radius: 50%; padding: 0; font-size: 24px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-skip {
  position: relative; width: 46px; height: 46px; border-radius: 50%; padding: 0;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  box-shadow: none; font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ap-skip-n { position: absolute; font-size: 9px; font-weight: 700; top: 55%; left: 50%; transform: translate(-50%, -50%); }
.ap-skip .ph { font-size: 30px; opacity: .9; }
.ap-extras { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ap-mini {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: none;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px;
}
.ap-mini:hover { border-color: var(--mauve); box-shadow: none; }
.ap-list { margin-top: 14px; max-height: 240px; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.ap-list-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px;
  background: none; border: none; box-shadow: none; color: var(--ink); text-align: left;
  padding: 9px 8px; border-radius: 8px; font-size: 14px;
}
.ap-list-row:hover { background: var(--surface-2); transform: none; box-shadow: none; }

/* ---- audiobook mini-player (bottom bar) ------------------------------------- */
.mini-player {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px;
  /* Above the modal backdrop (250) so it stays crisp and visible while you
     browse a book's detail page - playback controls shouldn't disappear behind
     a blur. Still below confirm dialogs (400) and the full-screen reader. */
  z-index: 260;
  display: flex; align-items: center; gap: 14px;
  width: min(620px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .55);
}
.mp-info { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; cursor: pointer; }
.mp-cover {
  width: 40px; height: 40px; flex: none; border-radius: 8px;
  background: var(--cover-bg) center / cover no-repeat;
}
.mp-cover-ph { display: flex; align-items: center; justify-content: center; font-size: 18px; }
.mp-text { min-width: 0; }
.mp-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.mp-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.mp-btn {
  width: 38px; height: 38px; border-radius: 50%; padding: 0; font-size: 17px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.mp-btn:hover { border-color: var(--mauve); box-shadow: none; transform: none; }
.mp-play { background: var(--accent-grad); color: #fff; border: none; }
.mp-close { width: 32px; height: 32px; font-size: 14px; color: var(--muted); }
/* Keep the catalog's last row reachable above the bar. */
body.has-mini-player .layout { padding-bottom: 76px; }

/* Minimize + stop sit side by side in the player's top-right corner. */
.ap-head-btns { display: flex; gap: 8px; flex: none; align-items: center; }
.ap-head { align-items: flex-start; }

/* ---- label printing (web-only, Zebra) ------------------------------------ */
/* Raw ZPL preview shown when no printer is wired up. */
.zpl-preview {
  max-height: 46vh; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--surface-2, rgba(0,0,0,.04)); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin-top: 10px;
}
/* Book-detail "Print label" chooser: two stacked full-width choices. */
.label-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.label-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.label-choice .hint { font-weight: 400; }
.label-choice.primary .hint { color: var(--accent-ink); opacity: 0.85; }
/* Print actions under a location preset in the Locations modal. */
.loc-print { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px 14px; }
.loc-print-btn {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2, rgba(0,0,0,.04)); border: 1px solid var(--border);
  color: var(--ink); cursor: pointer;
}
.loc-print-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Audit result sections. */
.audit-sec { margin-top: 14px; }
.audit-sec-head { font-weight: 700; margin-bottom: 6px; }
.audit-sec.ok .audit-sec-head { color: var(--accent); }
.audit-sec.warn .audit-sec-head { color: var(--gold, #c9a227); }
.audit-sec.muted .audit-sec-head { color: var(--muted, #888); }
.audit-clean { margin-top: 12px; padding: 12px; border-radius: 10px;
  background: var(--surface-2, rgba(0,0,0,.04)); color: var(--accent); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted, #888); font-weight: 600; }

/* ---- version history + rollback (Settings -> Updates) --------------------- */
.ver-history { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.ver-row { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; }
.ver-row.current { border-color: var(--accent); }
.ver-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ver-act { font-weight: 700; }
.ver-badge {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px;
  padding: 1px 9px; font-size: 11px; font-weight: 700;
}
.ver-undo { margin-left: auto; }
.ver-notes { margin: 8px 0 2px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.ver-notes li { margin: 1px 0; }
/* Compact history row: headline over a mono meta line, control on the right. */
.ver-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ver-row-main { min-width: 0; }
.ver-summary { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ver-sha { font-size: 12px; color: var(--faint); }
.ver-commits {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  color: var(--muted); margin-top: 6px;
}
.danger-ghost { color: #c0392b; border-color: #c0392b; }
.danger-ghost:hover { background: rgba(192, 57, 43, 0.08); }

/* Kind glyph in the sidebar library list (book / film / controller). */
#library-list .lib-glyph { display: inline-flex; align-items: center; margin-right: 9px; opacity: .72; font-size: 15px; flex: none; }
#library-list li.active .lib-glyph { opacity: 1; }
.ver-row-compact { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.ver-row-compact .ver-commits { margin-top: 0; }
.ver-older { margin-top: 4px; }

/* Google's rendered sign-in button (GIS) - center it in the SSO area. */
.login-gsi { display: flex; justify-content: center; margin-top: 10px; }
/* Apple-spec pill for the custom Sign in with Apple button, sized to pair
   with Google's rendered pill below it. */
.login-sso { justify-content: center; }
.login-apple-pill {
  flex: none !important; width: 280px; height: 44px; border-radius: 22px;
  background: #000; border: none; color: #fff;
  font: 500 16px -apple-system, "Helvetica Neue", "Hanken Grotesk", sans-serif;
}
.login-apple-pill:hover { background: #111; }
.login-apple-pill svg { width: 16px; height: 16px; }
.login-gsi { min-height: 44px; }

/* ---- locations tree (collapsible rooms, compact rows) --------------------- */
.loc-room-d { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.loc-sum {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  cursor: pointer; list-style: none; font-weight: 700; font-size: 1rem;
}
.loc-sum::-webkit-details-marker { display: none; }
.loc-sum .loc-caret { transition: transform .15s ease; color: var(--muted); }
.loc-room-d[open] > .loc-sum .loc-caret { transform: rotate(90deg); }
.loc-sum-name { flex: none; }
.loc-sum .count { color: var(--muted); font-size: .8rem; }
.loc-bc-group { border-top: 1px solid var(--border); padding: 4px 10px 8px 14px; }
/* Nested collapsible bookcases: the summary is styled as a normal row. */
.loc-bc-d > summary { list-style: none; cursor: pointer; }
.loc-bc-d > summary::-webkit-details-marker { display: none; }
.loc-bc-d .loc-caret { transition: transform .15s ease; color: var(--muted); font-size: .85em; }
.loc-bc-d[open] > summary .loc-caret { transform: rotate(90deg); }
/* Inline rename input (swapped in for the name by the pencil chip). */
.loc-rename {
  font: inherit; width: 150px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--surface-2); color: var(--ink);
}
.loc-row { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 8px; }
.loc-row:hover { background: var(--surface-2); }
.loc-depth-1 > .loc-name { font-weight: 600; }
.loc-depth-2 { margin-left: 22px; }
.loc-depth-2 > .loc-name { font-size: .9rem; }
.loc-name {
  background: none; border: none; color: var(--ink); cursor: pointer;
  padding: 2px 4px; text-align: left; font: inherit;
}
.loc-name:hover { color: var(--accent); text-decoration: underline; transform: none; box-shadow: none; }
.loc-row .count, .loc-sum .count { flex: none; }
.loc-actions { display: inline-flex; gap: 5px; margin-left: auto; align-items: center; }
.loc-sum .loc-actions { margin-left: 4px; }
.loc-chip {
  font-size: 12px; padding: 3px 8px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2, rgba(0,0,0,.04)); border: 1px solid var(--border);
  color: var(--ink); display: inline-flex; align-items: center; gap: 4px;
}
.loc-chip:hover { border-color: var(--accent); color: var(--accent); transform: none; box-shadow: none; }
.loc-row .loc-del { margin-left: 2px; }

/* Cover picker: candidate covers from every source in a clickable grid. */
.cover-choices {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px; margin-top: 12px;
}
.cover-choice {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 6px 7px; cursor: pointer; display: flex; flex-direction: column;
  gap: 5px; align-items: center; box-shadow: none; color: var(--muted);
}
.cover-choice img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px;
  background: var(--cover-bg);
}
.cover-choice .src { font-size: 0.7rem; }
.cover-choice:hover { border-color: var(--accent); color: var(--accent); transform: none; }
.cc-loading { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
.cc-custom { margin-top: 14px; align-items: flex-end; }
.cc-custom > div { flex: 1; }

/* Find & acquire (Shelfmark): search, candidates, releases, downloads strip. */
.acq-note { margin-bottom: 10px; }
.acq-search { display: flex; gap: 8px; flex-wrap: wrap; }
/* Full-width search field on its own row so a long title isn't clipped; the
   type toggle + Search button wrap onto the next line. */
.acq-search input { flex: 1 1 100%; min-width: 0; }
.acq-stage { margin-top: 12px; min-height: 40px; }
.acq-cand {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 8px; margin-bottom: 8px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); color: var(--ink);
  cursor: pointer; box-shadow: none;
}
.acq-cand:hover { border-color: var(--accent); transform: none; }
.acq-cand img, .acq-cand-ph {
  width: 34px; height: 50px; flex: 0 0 auto; object-fit: cover;
  border-radius: 4px; background: var(--cover-bg); display: block;
}
.acq-cand-meta { flex: 1; min-width: 0; }
.acq-cand-meta .title { font-weight: 600; font-size: 0.92rem; }
.acq-back { margin-bottom: 10px; }
.acq-rel-head { margin-bottom: 6px; }
.acq-rel {
  display: flex; gap: 10px; align-items: center; padding: 7px 4px;
  border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.acq-rel .fmt {
  flex: 0 0 52px; font-weight: 700; text-transform: uppercase;
  font-size: 0.74rem; color: var(--accent);
}
.acq-rel .meta {
  flex: 1; min-width: 0; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acq-rel .get { flex: 0 0 auto; padding: 5px 14px; }
.acq-jobs { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.acq-jobs-head { font-weight: 600; margin-bottom: 6px; }
.acq-job { display: flex; align-items: center; gap: 9px; padding: 6px 2px; }
.acq-job > .ph { color: var(--muted); flex: 0 0 auto; }
.acq-job-meta { flex: 1; min-width: 0; }
.acq-job-meta .title { font-size: 0.9rem; font-weight: 600; }
.acq-status { font-size: 0.78rem; flex: 0 0 auto; color: var(--muted); }
.acq-status.ok { color: var(--accent); font-weight: 600; }
.acq-status.warn { color: var(--gold); }
.acq-status.err { color: var(--danger); }
.acq-bar {
  display: block; height: 4px; margin-top: 5px; border-radius: 2px;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
}
.acq-bar-fill { display: block; height: 100%; background: var(--accent); transition: width 0.6s ease; }

/* Top-bar Activity button + dropdown panel (the quick "what is downloading"). */
.activity-badge {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; padding: 1px 7px; margin-left: 7px;
  line-height: 1.5;
}
.activity-pop {
  position: fixed; top: 66px; right: 18px; width: 380px; max-width: calc(100vw - 24px);
  max-height: 62vh; overflow-y: auto; z-index: 300;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 12px 14px;
}
.activity-head {
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.activity-head .ph { color: var(--accent); }
.activity-clear { margin-top: 10px; width: 100%; }

.acq-fallback {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}

/* Anchor-mode toggle in Scan / Shelve. */
.anchor-armed { border-color: var(--accent) !important; color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent) inset; }

/* ============================================================================
   Settings design-parity polish - matching the Claude Design settings mockup.
   Compact in-row/toolbar buttons, outlined-danger deletes, config field labels
   as small uppercase, full-width span-2 cards, media section badges.
   ============================================================================ */
/* Compact action buttons (the mockup's .btn.sm) inside settings rows, the
   Accounts toolbar, per-user detail actions, and role rows. */
.set-row .admin-actions button,
.acct-toolbar button,
.detail-actions button,
.role-row > button,
.invite-row > button { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }

/* Delete buttons read as outlined danger, not the global borderless text link. */
.detail-actions button.danger,
.role-edit-actions button.danger,
.server-row button.danger {
  background: transparent; color: var(--danger); border: 1px solid var(--danger);
  padding: 7px 12px; border-radius: 9px; font-size: 12.5px;
}
.detail-actions button.danger:hover,
.role-edit-actions button.danger:hover,
.server-row button.danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger);
}

/* Config field labels: small uppercase caps above the input (mockup .cfg-field
   label), scoped to the managed-config cards so nothing else is affected. */
.server-settings .set-block-head {
  font: 600 11px var(--font-sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.server-settings .set-block-sub { font-size: 12px; }
/* Collapsible group heads a touch lighter, per the mockup. */
.cfg-group-head { font-weight: 600 !important; }
.cfg-group-head > span:first-child { display: inline-flex; align-items: center; gap: 8px; }

/* Full-width card in the two-column settings grid. Any direct child of the
   panel marked .span-2 spans both columns (cards and the Accounts flow alike). */
.settings-panel > .span-2 { grid-column: 1 / -1; }
/* A left-column group that stacks two cards vertically (e.g. Server's Storage +
   Sign-in) as one grid item, so they read as a pair beside a taller card. */
.settings-panel > .settings-stack { min-width: 0; }

/* Media "To attach" / "Attached" section headers: leading glyph + count badge. */
.media-sec {
  display: flex; align-items: center; gap: 8px; margin: 16px 0 6px;
  font: 700 10.5px var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.media-sec .count { color: var(--faint); font-weight: 700; }
.media-group-count {
  color: var(--faint); font-weight: 600; font-size: 12px; margin-left: 4px;
}
.media-group-head > i.ph-check-circle { color: var(--positive); }
.media-more { background: transparent; border: none; color: var(--muted); }
.media-more:hover { color: var(--ink); border: none; }

/* ============================================================================
   Phone tightening - EVERYTHING here is inside a max-width media query, so the
   desktop/laptop layout is not touched at all. Fixes the two things that were
   wrong at phone width: the top bar overflowed off the right edge (buttons cut
   off), and the sidebar was forced to a full viewport height above the catalog.
   ============================================================================ */
@media (max-width: 640px) {
  /* App bar never overflows: the brand shrinks and the action buttons wrap to
     their own row, so every control (including the settings gear) stays
     on-screen and tappable instead of being clipped off the right. */
  header.app-bar { flex-wrap: wrap; gap: 10px 8px; padding: 12px 15px; }
  header.app-bar .brand-lockup h1 { font-size: 20px; }
  header.app-bar .brand-icon { width: 38px; height: 38px; }
  .app-bar-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .tb-primary, .tb-btn, .tb-ghost { padding: 9px 13px; font-size: 13px; border-radius: 10px; }
  .tb-icon { width: 38px; height: 38px; }

  /* Stacked layout: don't force the sidebar to a full screen height before the
     catalog, and use comfortable phone edge padding. */
  aside.sidebar { min-height: 0; padding: 18px 15px; }
  main.content { padding: 18px 15px; }
  .layout { padding: 0; }

  /* The Settings page title + close sit tighter on a narrow screen. */
  .page-title { font-size: 26px; }
}

/* ---- AI council review (per-model verdicts in the edit modal) ------------- */
/* Shelf-audit result rows: themed row chrome + token-driven status colors. */
.audit-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 7px 10px; margin-top: 6px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
}
.audit-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-tag { font-weight: 600; font-size: 12px; white-space: nowrap; }
.audit-ok { color: var(--positive); }
.audit-bad { color: var(--danger); }
.audit-warn { color: var(--gold); }
.audit-muted { color: var(--muted); }

.council-row { display: flex; flex-direction: column; gap: 10px; }
.council-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.council-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}
.council-loading.err { color: var(--danger); }
.council-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
}
.council-h {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink);
}
.council-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
  border-top: 1px solid var(--border-soft);
}
.council-line:first-of-type { border-top: none; }
.council-model {
  color: var(--muted);
  white-space: nowrap;
}
.council-right { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.council-v { text-align: right; }
.council-tally { margin-top: 6px; font-size: 11.5px; }
.council-v.yes { color: var(--accent); font-weight: 600; }
.council-v.no { color: var(--muted); }
.council-v.muted { color: var(--muted); opacity: 0.55; }
.council-merged {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.council-apply-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Phone fixes (appended last to win the cascade). The stats tile grid is set
   to a hard 4 columns above; on a 390px viewport that overflows and clips the
   right-hand tiles, so collapse it to 2-up and tighten the tile padding.
   --------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 26px; }
}

/* Buy list -> gift-list sharing panel */
.buylist-share { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); }
.buylist-share .share-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.buylist-share .share-head .g i { color: var(--accent); }
.buylist-share .hint { margin: 4px 0 10px; }
.share-row { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.share-row .share-link { flex: 1; min-width: 0; font-size: 13px; }
.share-row input { flex: 1; min-width: 0; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-like { display: inline-flex; align-items: center; text-decoration: none; }
.share-row textarea { flex: 1; min-width: 0; resize: vertical; font: inherit;
  color: var(--ink); background: var(--field-bg); border: 1px solid var(--field-border);
  border-radius: 10px; padding: 8px 10px; }
.share-qr-wrap { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; }
.share-qr { width: 116px; height: 116px; background: #fff; border-radius: 10px; padding: 8px; flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   Phone / narrow reflow (appended last to win the cascade). The book detail,
   modals, and settings rows were fixed multi-column with no breakpoint, so on a
   phone the detail cover crushed its right column and modal field pairs / audit
   selects / permission rows overflowed. Collapse them to one column. */
@media (max-width: 700px) {
  .bd-layout { flex-direction: column; gap: 22px; }
  .bd-left { width: 100%; }
  .bd-left .bd-cover-wrap, .bd-left .bd-cover { max-width: 220px; margin-left: auto; margin-right: auto; }
  .bd-grid { grid-template-columns: 1fr; gap: 14px; }
  .modal .row { flex-direction: column; }
  .row3 { grid-template-columns: 1fr; }
  .lookup-row { flex-wrap: wrap; }
  .lookup-row > div { min-width: 160px; }
  .perm-row { flex-wrap: wrap; gap: 8px 12px; }
  .set-row { flex-wrap: wrap; }
  .set-row input[type="range"], .ui-scale input[type="range"] { flex: 1; min-width: 140px; }
}

/* UI audit — remaining polish (appended to win the cascade). */
/* Vibe-search "reading it as" chips (#6): the tropes/subjects/spice bits used an
   undefined .chip class and rendered as bare inline text beside the flag pills. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink); font-size: 0.8rem;
}
/* Per-row status lines only take vertical space once they have text (#22). */
.admin-card .admin-status:empty { min-height: 0; margin: 0; }
/* Dangling separators under the last list row (#40). */
.buylist-row:last-child { border-bottom: none; padding-bottom: 0; }
.series-row:last-child { border-bottom: none; }
/* A long download error must not force the row wider than the panel (#27). */
.acq-status { min-width: 0; flex-shrink: 1; overflow-wrap: anywhere; }
/* Council enrich value should wrap cleanly instead of fighting the model name (#37). */
.council-right { min-width: 0; }
.council-line .council-v { overflow-wrap: anywhere; }
/* Wall-view titles stay visible on touch devices, where there's no hover (#30). */
@media (hover: none) { .wall-cap { opacity: 1; } }
.order-name { color: var(--ink); font-weight: 600; }
.cfg-on { color: var(--positive); font-weight: 600; }
.cfg-off { color: var(--danger); font-weight: 600; }
/* Audit-mode selects fill their column evenly instead of shrinking to content (#21). */
.row3 .set-select { width: 100%; }

/* "To shelve" nav badge — count of un-located books waiting to be placed. */
.nav-count {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; text-align: center; line-height: 1.5;
}

/* Shelving planner: each target shelf card + the queued books going onto it. */
.plan-shelf {
  margin-top: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); overflow: hidden;
}
.plan-shelf-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.plan-shelf-label { font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 4px; }
.plan-shelf-label .ph { color: var(--gold); }
.plan-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 9px 14px; border-top: 1px solid var(--border-soft); flex-wrap: wrap;
}
.plan-shelf .plan-row:first-of-type { border-top: none; }
.plan-book { font-weight: 600; color: var(--ink); }
.plan-auth { font-weight: 400; color: var(--muted); }
.plan-where { color: var(--muted); font-size: 0.86rem; }
