/* ============================================================
   Limner — design system
   ------------------------------------------------------------
   "Dark academia refined": mahogany + espresso grounds, aged
   parchment ink, antique brass accents. Cormorant Garamond for
   titles, system type for controls, Georgia for book prose.

   The app is a mobile PWA first: fixed chrome, a scrolling
   content frame, a bottom tab bar, 17px inputs (so iOS never
   zooms on focus) and 44px+ touch targets. Wider viewports get
   the same components with the top nav restored.

   Sections
     1  Fonts
     2  Tokens (dark ground, parchment daylight)
     3  Reset + the app shell
     4  Chrome: top bar, screen headers, tab bar
     5  Typography
     6  Layout helpers
     7  Surfaces: cards, list groups, sheets
     8  Controls: buttons, forms, chips, segmented
     9  Badges, pills, alerts, the save toast
     10 Stats + meters
     11 Covers, shelves, spines
     12 Screens: dashboard, book, loans, members, more, scan
     13 Footer + auth
   ============================================================ */

/* ------------------------------------------------------------
   1 · Fonts
   ------------------------------------------------------------ */

@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/static/fonts/cormorant-garamond.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("/static/fonts/cormorant-garamond-italic.woff2") format("woff2");
}

/* ------------------------------------------------------------
   2 · Tokens

   The dark ground is the default. Daylight parchment is applied
   two ways, and both must exist: `prefers-color-scheme` for
   readers who never touch the setting, and `[data-theme]` for
   the explicit choice in More → Appearance. Every colour is
   defined once here on bare `:root`; the theme blocks only
   redefine tokens, never rules.

   A handful of tokens deliberately do NOT flip. Book covers are
   leather in both themes, so cover ink stays parchment-pale, and
   the primary button keeps its brass plate.
   ------------------------------------------------------------ */

:root {
  color-scheme: dark;

  /* grounds */
  --bg: #16110c;
  --bg-deep: #100c08;
  --surface: #201811;
  --surface-raised: #271e15;
  --surface-press: #2e2419;

  /* ink */
  --ink: #e8ddc6;
  --ink-strong: #f4ecd9;
  --muted: #a6957a;
  --faint: #6f6250;

  /* accents */
  --brass: #b28f4f;
  --brass-bright: #d3b271;
  --oxblood: #6e2f33;
  --oxblood-bright: #9c4a4f;
  --oxblood-ink: #e4b8b4;
  --forest: #35503f;
  --forest-bright: #5d8168;
  --forest-ink: #9fc2a8;

  /* edges */
  --border: #392c1e;
  --border-strong: #4d3c28;
  --hairline: #2a211a;
  --border-gold: rgba(178, 143, 79, 0.45);

  /* washes: inset wells, bar fills, overlays */
  --well: rgba(0, 0, 0, 0.35);
  --sunk: rgba(0, 0, 0, 0.4);
  --chrome: rgba(16, 12, 8, 0.94);
  --chrome-edge: rgba(178, 143, 79, 0.35);
  --veil: rgba(16, 12, 8, 0.9);
  --scrim: rgba(6, 4, 3, 0.55);
  --tint: rgba(178, 143, 79, 0.18);
  --tint-soft: rgba(178, 143, 79, 0.1);
  --glow: rgba(178, 143, 79, 0.08);

  /* gradients */
  --grad-card: linear-gradient(160deg, #271e15, #201811);
  --grad-avatar: linear-gradient(160deg, #2e2419, #201811);
  --grad-shelf: linear-gradient(180deg, #1c140e, #140e09);
  --grad-shelf-board: linear-gradient(180deg, #4d3c28, #2e2419);

  /* shadows */
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 8px 22px rgba(0, 0, 0, 0.35);
  --shadow-sheet: 0 -14px 40px rgba(0, 0, 0, 0.6);
  --shadow-cover: inset 3px 0 6px -3px rgba(0, 0, 0, 0.7), 0 10px 20px rgba(0, 0, 0, 0.4);
  --shadow-cover-lg: inset 3px 0 6px -3px rgba(0, 0, 0, 0.7), 0 22px 44px rgba(0, 0, 0, 0.6);

  /* fixed across themes — leather covers, brass plate */
  --cover-ink: #f4ecd9;
  --cover-accent: #b28f4f;
  --cover-edge: rgba(178, 143, 79, 0.45);
  --cover-art:
    linear-gradient(155deg, rgba(178, 143, 79, 0.14), transparent 45%),
    linear-gradient(180deg, #3b2a22, #241812);
  --plate: linear-gradient(180deg, #8a6a34, #6f5227);
  --plate-ink: #fdf6e4;

  /* radii — 12/14 for wells and cards, 16 for panels, 22 for sheets */
  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-sheet: 22px;
  --radius-pill: 999px;

  /* type */
  --serif-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --serif-text: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --ui: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;

  /* metrics */
  --tap: 44px;            /* smallest allowed touch target */
  --tabbar-h: 56px;
  /* One gutter drives .wrap, the sticky chrome and every edge-bleeding
     strip, so a chip row lines up with the cards above it. */
  --gutter: 22px;
  --pad-top: 26px;        /* main's top padding, before the safe-area inset */
}

/* Daylight parchment — for readers on the system setting who have
   not made an explicit choice. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    --bg: #faf4e6;
    --bg-deep: #f1e7d2;
    --surface: #f6ecd6;
    --surface-raised: #fffdf6;
    --surface-press: #e7d9bb;

    --ink: #3b2f20;
    --ink-strong: #241a10;
    --muted: #7d6d51;
    --faint: #a4936f;

    --brass: #b28f4f;
    --brass-bright: #8a6a34;
    --oxblood: #9c4a4f;
    --oxblood-bright: #8a3a3f;
    --oxblood-ink: #8a3a3f;
    --forest: #5d8168;
    --forest-bright: #3f6a4e;
    --forest-ink: #3f6a4e;

    --border: #e0d2b4;
    --border-strong: #cdbb96;
    --hairline: #ece0c4;

    --well: rgba(93, 70, 38, 0.06);
    --sunk: rgba(93, 70, 38, 0.08);
    --chrome: rgba(250, 244, 230, 0.94);
    --veil: rgba(255, 253, 246, 0.88);
    --scrim: rgba(59, 47, 32, 0.45);
    --glow: rgba(178, 143, 79, 0.16);

    --grad-card: linear-gradient(160deg, #fffdf6, #f6ecd6);
    --grad-avatar: linear-gradient(160deg, #f6ecd6, #e7d9bb);
    --grad-shelf: linear-gradient(180deg, #f3e8cf, #eadbba);
    --grad-shelf-board: linear-gradient(180deg, #cdbb96, #b9a47c);

    --shadow: 0 22px 48px rgba(93, 70, 38, 0.25);
    --shadow-soft: 0 10px 26px rgba(93, 70, 38, 0.14);
    --shadow-lift: 0 8px 22px rgba(93, 70, 38, 0.14);
    --shadow-sheet: 0 -14px 40px rgba(93, 70, 38, 0.28);
    --shadow-cover: inset 3px 0 6px -3px rgba(0, 0, 0, 0.45), 0 10px 20px rgba(93, 70, 38, 0.25);
    --shadow-cover-lg: inset 3px 0 6px -3px rgba(0, 0, 0, 0.45), 0 22px 44px rgba(93, 70, 38, 0.32);
  }
}

/* The same parchment, chosen explicitly. Kept as its own block so
   the toggle wins in both directions: a reader on a light phone can
   still pin the dark ground, and vice versa. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #faf4e6;
  --bg-deep: #f1e7d2;
  --surface: #f6ecd6;
  --surface-raised: #fffdf6;
  --surface-press: #e7d9bb;

  --ink: #3b2f20;
  --ink-strong: #241a10;
  --muted: #7d6d51;
  --faint: #a4936f;

  --brass: #b28f4f;
  --brass-bright: #8a6a34;
  --oxblood: #9c4a4f;
  --oxblood-bright: #8a3a3f;
  --oxblood-ink: #8a3a3f;
  --forest: #5d8168;
  --forest-bright: #3f6a4e;
  --forest-ink: #3f6a4e;

  --border: #e0d2b4;
  --border-strong: #cdbb96;
  --hairline: #ece0c4;

  --well: rgba(93, 70, 38, 0.06);
  --sunk: rgba(93, 70, 38, 0.08);
  --chrome: rgba(250, 244, 230, 0.94);
  --veil: rgba(255, 253, 246, 0.88);
  --scrim: rgba(59, 47, 32, 0.45);
  --glow: rgba(178, 143, 79, 0.16);

  --grad-card: linear-gradient(160deg, #fffdf6, #f6ecd6);
  --grad-avatar: linear-gradient(160deg, #f6ecd6, #e7d9bb);
  --grad-shelf: linear-gradient(180deg, #f3e8cf, #eadbba);
  --grad-shelf-board: linear-gradient(180deg, #cdbb96, #b9a47c);

  --shadow: 0 22px 48px rgba(93, 70, 38, 0.25);
  --shadow-soft: 0 10px 26px rgba(93, 70, 38, 0.14);
  --shadow-lift: 0 8px 22px rgba(93, 70, 38, 0.14);
  --shadow-sheet: 0 -14px 40px rgba(93, 70, 38, 0.28);
  --shadow-cover: inset 3px 0 6px -3px rgba(0, 0, 0, 0.45), 0 10px 20px rgba(93, 70, 38, 0.25);
  --shadow-cover-lg: inset 3px 0 6px -3px rgba(0, 0, 0, 0.45), 0 22px 44px rgba(93, 70, 38, 0.32);
}

/* ------------------------------------------------------------
   3 · Reset + the app shell
   ------------------------------------------------------------ */

* { box-sizing: border-box; }

html {
  background: var(--bg-deep);
  /* iOS rubber-band overscroll exposes the page behind the shell;
     painting the root the same colour keeps that gutter in-theme. */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--serif-text);
  font-size: 16px;
  background-color: var(--bg-deep);
  /* NOTE: no background-attachment: fixed here — fixed-attachment gradients
     plus a backdrop-filter sticky header trigger blank-page compositing bugs
     in Safari. */
  background-image:
    radial-gradient(1200px 500px at 50% -10%, var(--glow), transparent 60%),
    linear-gradient(var(--bg), var(--bg-deep));
  background-repeat: no-repeat;
  background-size: 100% 100vh;
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

/* The tab bar floats over the content frame, so the scrolling page has to
   reserve its height or the last row hides underneath. Only where the bar
   is actually shown — see the shell breakpoint at the foot of this file. */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--pad-top) var(--gutter) 26px;
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
}
.narrow { max-width: 480px; }

/* In a standalone PWA the viewport runs under the status bar. The top bar
   absorbs that inset on a desk; on a phone the top bar is gone, so the
   content frame absorbs it instead (see `.topbar .wrap` below). Only one
   of the two is ever visible, so the inset is never counted twice. */
main.wrap { padding-top: calc(var(--pad-top) + env(safe-area-inset-top)); }

/* ------------------------------------------------------------
   4 · Chrome: top bar, screen headers, tab bar
   ------------------------------------------------------------ */

.topbar {
  border-bottom: 1px solid var(--border-gold);
  /* Nearly opaque, so skipping the blur costs little visually; the blur is
     opt-in via @supports to keep Safari's compositor out of trouble. */
  background: var(--chrome);
  position: sticky;
  top: 0;
  z-index: 1000;
}
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .topbar {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* The top bar is the element that clears the status bar on a desk. */
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: 12px;
}

.brand {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
  text-decoration: none;
  white-space: nowrap;
}
.brand .brand-mark { color: var(--oxblood-bright); margin-right: 8px; }
.brand:hover { color: var(--ink-strong); }

.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--ui);
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav a:hover, .nav a.active { color: var(--ink-strong); background: var(--tint-soft); }
.nav .muted.small { margin-left: 6px; }

/* The household switcher's desktop trigger — a button dressed as a nav
   link (docs/MULTI_TENANCY_PLAN.md, Stage 6), so it sits in the same row
   without the global button rule's 44px floor or button chrome; a mouse
   pointer doesn't need the touch-target minimum the phone sheet does. */
.nav button.household-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 7px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.nav button.household-chip:hover { color: var(--ink-strong); background: var(--tint-soft); }
.nav button.household-chip svg { flex: none; opacity: 0.7; }

/* Screen header — the large title that replaces the top bar on a
   phone. `eyebrow` above, an optional trailing action to the right. */
.screen-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.screen-header .screen-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.1;
  color: var(--ink-strong);
  margin: 0;
  letter-spacing: 0.01em;
}
.screen-header .screen-action {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--brass-bright);
  text-decoration: none;
  padding-bottom: 6px;
  white-space: nowrap;
}
.screen-header .screen-count {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--muted);
  padding-bottom: 6px;
  white-space: nowrap;
}

/* Sticky chrome for search-led screens (Library). Sits under the
   status bar, scrolls the results beneath it. */
.screen-chrome {
  position: sticky;
  top: 0;
  z-index: 900;
  /* Bleed back out through main's padding so the bar spans the full width
     and re-absorbs the status-bar inset it just cancelled. */
  margin-top: calc((var(--pad-top) + env(safe-area-inset-top)) * -1);
  margin-left: calc((var(--gutter) + env(safe-area-inset-left)) * -1);
  margin-right: calc((var(--gutter) + env(safe-area-inset-right)) * -1);
  padding: calc(var(--pad-top) + env(safe-area-inset-top)) var(--gutter) 12px;
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
  background: var(--chrome);
  border-bottom: 1px solid rgba(178, 143, 79, 0.3);
}
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .screen-chrome {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

/* Bottom tab bar — the app's spine on a phone. Five destinations,
   each a 44px+ target, over a blurred bar with a brass hairline. */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--chrome);
  border-top: 1px solid var(--chrome-edge);
}
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .tabbar {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

.tabbar a {
  flex: 1 1 0;
  min-width: 56px;
  min-height: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 6px;
  text-decoration: none;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.01em;
  color: var(--faint);
}
.tabbar a svg { display: block; }
/* One stroke colour drives the whole glyph, so the icon and its
   label light up together on the active tab. */
.tabbar a svg [stroke] { stroke: currentColor; }
.tabbar a svg [fill]:not([fill="none"]) { fill: currentColor; }
.tabbar a.active { color: var(--brass-bright); font-weight: 600; }

/* ------------------------------------------------------------
   5 · Typography
   ------------------------------------------------------------ */

h1, h2, h3 {
  font-family: var(--serif-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-strong);
  line-height: 1.2;
}

h1 { margin: 0 0 14px; font-size: 34px; }
h2 { margin: 0 0 12px; font-size: 24px; }
h3 { margin: 0 0 10px; font-size: 20px; }

p { margin: 0 0 12px; }
a { color: var(--brass-bright); }
a:hover { color: var(--ink-strong); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 22px; }
.text-right { text-align: right; }
.ui { font-family: var(--ui); }

/* small-caps section label, the "chapter heading" motif */
.section-label,
.eyebrow {
  font-family: var(--serif-text);
  font-variant: small-caps;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  font-size: 12px;
  color: var(--brass);
  margin: 0 0 6px;
}

/* Book prose — descriptions and blurbs stay in Georgia, the one
   place the reading face is used at body size. */
.prose {
  font-family: var(--serif-text);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}

.rule {
  border: 0;
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
}

.ornament {
  text-align: center;
  color: var(--brass);
  letter-spacing: 0.6em;
  margin: 10px 0;
  user-select: none;
}

/* ------------------------------------------------------------
   6 · Layout helpers
   ------------------------------------------------------------ */

.row { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.row--start { justify-content: flex-start; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--center { justify-content: center; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-tags { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.dashboard-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }

.gap-sm { gap: 10px; }
.gap-md { gap: 18px; }
/* The spacing utilities live at the foot of this file — components reset
   their own margins (`.list-group`, `.list-clean`), and a utility has to
   come after them to win. */

/* ------------------------------------------------------------
   7 · Surfaces: cards, list groups, sheets
   ------------------------------------------------------------ */

.card {
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.card h2:first-child, .card h3:first-child { margin-top: 0; }

.card-muted { opacity: 0.85; }
.card-warning { border-color: var(--oxblood); }
.card-success { border-color: var(--forest); padding: 12px 16px; }

/* A list group is the workhorse: one bordered panel, hairline-
   separated rows, each row a 44px+ target with an optional
   chevron. Rows may be <a>, <li>, or <div>. */
.list-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--grad-card);
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-height: var(--tap);
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: inherit;
}
.list-item:last-child { border-bottom: none; }
a.list-item:hover { background: var(--tint-soft); }

/* A row that is a control rather than a link has to shed the button
   chrome — the panel already draws the edges. */
button.list-item {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  text-align: left;
  font-family: var(--ui);
  color: inherit;
  cursor: pointer;
}
.list-group > button.list-item:last-child { border-bottom: none; }
button.list-item:hover { color: inherit; background: var(--tint-soft); }

/* A row that is a switch is a <label> wrapping a checkbox, and has to shed
   the form-label typography (small caps, letterspaced, muted) the same way
   the button above sheds its chrome. Wrapping rather than pairing with
   `for=` makes the whole 44px row the target instead of the 20px box. */
label.list-item {
  display: flex;
  margin: 0;
  font-variant: normal;
  letter-spacing: normal;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}
label.list-item:hover { background: var(--tint-soft); }
label.list-item input[type="checkbox"] { flex: none; width: 20px; height: 20px; }

/* A single full-width row standing on its own, e.g. Sign out. */
.list-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--grad-card);
  font-family: var(--ui);
  font-size: 16px;
  color: var(--ink-strong);
  text-decoration: none;
}
.list-action--danger { color: var(--oxblood-bright); }
.list-action--danger:hover { color: var(--oxblood-bright); border-color: var(--oxblood); }

/* The account row at the head of More. */
.profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--grad-card);
  text-decoration: none;
  color: inherit;
}
.profile-row:hover { border-color: var(--border-gold); }

.list-item-body { flex: 1; min-width: 0; }
/* A settings row whose label needs a line of explanation puts the pair in
   a .list-item-body and they stack; a .list-item-detail on its own is a
   trailing value ("6 books") and stays where it is. */
.list-item-body > .list-item-label,
.list-item-body > .list-item-detail { display: block; }
.list-item-body > .list-item-detail { margin-top: 2px; }
.list-item-title {
  display: block;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink-strong);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.list-item-title { text-decoration: none; }
a.list-item-title:hover { color: var(--brass-bright); }
.list-item-sub {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--muted);
}
/* Rows whose label is a control, not a title, use UI type. */
.list-item-label {
  flex: 1;
  font-family: var(--ui);
  font-size: 16px;
  color: var(--ink-strong);
}
.list-item-detail {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--faint);
}
.list-item-glyph {
  width: 24px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brass);
}
.list-item-glyph svg { flex: none; }
.list-item-thumb { width: 40px; flex: none; }
.list-item-thumb .cover-frame { box-shadow: none; }

/* A chevron on its own is an 8px target. Wrapping it keeps the row's
   "go here" affordance thumb-sized without drawing a button. */
.row-edit {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-height: var(--tap);
  margin-right: -6px;
  text-decoration: none;
}

/* CSS chevron — one element, no icon font, inherits the row's colour. */
.chevron {
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--faint);
  border-bottom: 2px solid var(--faint);
  transform: rotate(-45deg);
  margin-right: 2px;
}

/* Bottom sheet — how the app asks for input. Lending, filters and
   scan results slide up over the current screen instead of
   navigating away from it.

   Closed state is `hidden` on the host element, so a sheet whose
   JS never runs simply stays shut rather than covering the page. */
.sheet-host[hidden] { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: var(--scrim);
  animation: scrim-in 0.2s ease;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--grad-card);
  border: 1px solid var(--border-gold);
  border-bottom: none;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 10px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  animation: sheet-up 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim { animation: none; }
}

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  margin: 0 auto 14px;
}
.sheet-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 24px;
  color: var(--ink-strong);
  margin: 0;
  line-height: 1.2;
}
.sheet-sub {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 0;
}
.sheet-section { margin-top: 16px; }
.sheet-section > label,
.sheet-label {
  display: block;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

/* Wide viewports get a centred dialog instead of a bottom sheet. */
@media (min-width: 760px) {
  .sheet {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, calc(100vw - 48px));
    border-radius: var(--radius-xl);
    border-bottom: 1px solid var(--border-gold);
    box-shadow: var(--shadow);
    animation: none;
    padding-bottom: 24px;
  }
  .sheet-handle { display: none; }
}

/* ------------------------------------------------------------
   8 · Controls: buttons, forms, chips, segmented

   Controls speak system type, per the design — the serif is for
   titles and prose, not for things you tap.
   ------------------------------------------------------------ */

.btn, button, input[type="submit"] {
  appearance: none;
  font-family: var(--ui);
  font-size: 15px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  color: var(--ink-strong);
  background: linear-gradient(180deg, var(--surface-press), var(--surface-raised));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn:hover, button:hover, input[type="submit"]:hover {
  border-color: var(--brass);
  color: var(--brass-bright);
}

.btn-primary, button.btn-primary {
  background: var(--plate);
  border-color: var(--brass);
  color: var(--plate-ink);
  font-weight: 600;
}
.btn-primary:hover { color: #fff; border-color: var(--brass-bright); }

.btn-danger, button.btn-danger {
  border-color: var(--oxblood);
  color: var(--oxblood-bright);
}
.btn-danger:hover { background: var(--oxblood); color: #f4e4e0; border-color: var(--oxblood-bright); }

/* Full-width 50px CTA pinned at the foot of a screen or sheet. */
.btn-block {
  display: flex;
  width: 100%;
  min-height: 50px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  min-height: 0;
  color: var(--brass-bright);
  cursor: pointer;
  font-size: 15px;
  font-family: var(--ui);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: var(--ink-strong); border: none; background: none; }

/* Circular 40px chrome button — back arrow, overflow menu. */
.round-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  flex: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--veil);
  border: 1px solid var(--border);
  color: var(--brass-bright);
  font-size: 17px;
  text-decoration: none;
}

label {
  display: block;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 4px;
}
label.inline { display: inline-flex; font-variant: normal; letter-spacing: normal; }

/* 17px is the floor that keeps iOS Safari from zooming the viewport
   when a field takes focus. Every text control clears it. */
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], input[type="tel"], input[type="url"],
input[type="file"], input:not([type]), textarea, select {
  width: 100%;
  font-family: var(--ui);
  font-size: 17px;
  color: var(--ink-strong);
  background: var(--well);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: var(--tap);
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--brass); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brass); }
select { appearance: auto; }
input[type="file"] { padding: 10px 12px; }

.field-sm { max-width: 110px; } .field-md { max-width: 180px; }
.field-lg { max-width: 260px; } .field-wide, .field-xl { max-width: 380px; }
.field-xxl { max-width: 520px; } .field-auto { width: auto; }

.input-search { max-width: 420px; }

form.stack label { margin-bottom: 0; }

/* Search well — leading magnifier, 17px field, no visible box seam. */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--well);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
/* The magnifier is two shapes, not an icon font: a ring, and a handle
   struck off its lower right at 45°. */
.search-field::before {
  content: "";
  flex: none;
  width: 13px;
  height: 13px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  margin-right: 6px;
}
.search-field::after {
  content: "";
  position: absolute;
  left: 26px;
  top: calc(50% + 3px);
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: var(--muted);
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}
.search-field input {
  border: none;
  background: none;
  padding: 13px 0;
  border-radius: 0;
}
.search-field input:focus { border: none; }
.search-field:focus-within { border-color: var(--brass); }

/* Filter chips — a horizontally swipeable strip of pill filters.
   The strip bleeds to the screen edges so the last chip is
   reachable with a thumb. */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter) 2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  font-family: var(--ui);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--muted);
  background: none;
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
  cursor: pointer;
}
.chip:hover { border-color: var(--brass); color: var(--brass-bright); }
/* A chip acting as a row's action (Lend, Return, Save) is a primary
   target, not a filter, so it clears the full 44px. */
.list-item .chip, .page-row .chip { min-height: var(--tap); }
.chip.is-active,
.chip[aria-current="true"] {
  font-weight: 600;
  background: var(--tint);
  border-color: var(--brass);
  color: var(--brass-bright);
}

/* Segmented control — mutually exclusive options in one well.
   Used for reading status and loan durations. */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.segmented > * {
  flex: 1;
  min-height: 40px;
  padding: 8px 4px;
  text-align: center;
  justify-content: center;
  font-family: var(--ui);
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.segmented > *:hover { color: var(--brass-bright); }
.segmented > .active,
.segmented > [aria-pressed="true"] {
  font-weight: 600;
  background: var(--tint);
  border-color: var(--brass);
  color: var(--brass-bright);
}

/* Loose row of choice pills, when the options are suggestions
   rather than a closed set (recent borrowers, say). */
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   9 · Badges, pills, alerts, the save toast
   ------------------------------------------------------------ */

.badge, .pill, .tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-family: var(--ui);
  font-size: 12px;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: none;
  text-decoration: none;
  white-space: nowrap;
}
a.tag-pill:hover { border-color: var(--brass); color: var(--brass-bright); }

.badge-out { border-color: var(--oxblood-bright); color: var(--oxblood-ink); }
.badge-in { border-color: var(--forest-bright); color: var(--forest-ink); }
.badge-gold { border-color: var(--brass); color: var(--brass-bright); }
.badge-reading { border-color: var(--brass); color: var(--brass-bright); }

/* All-caps micro badge for statuses stamped over artwork. */
.badge-stamp {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  text-transform: uppercase;
}

.is-overdue { color: var(--oxblood-bright); font-weight: bold; }

.alert {
  border: 1px solid var(--oxblood);
  background: rgba(122, 42, 35, 0.14);
  color: var(--oxblood-ink);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.alert-success {
  border: 1px solid var(--forest);
  background: rgba(58, 92, 58, 0.14);
  color: var(--forest-ink);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

/* The save toast. Forms save in place (app.js), so the thing that
   changed is often off-screen — a row three screens up, a count in a
   header. This is the receipt for it: above the tab bar, out of the
   thumb's way, gone in a couple of seconds. Never a control; the page
   underneath is always the real record of what happened. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 1600;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-pill);
  background: var(--chrome);
  box-shadow: var(--shadow-lift);
  color: var(--ink-strong);
  font-family: var(--ui);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.toast.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.toast--error { border-color: var(--oxblood-bright); color: var(--oxblood-ink); }

/* Above 900px the tab bar is gone, so the toast comes down with it. */
@media (min-width: 900px) {
  .toast { bottom: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* A save in flight. The button that started it stays where it is and
   dims — nothing moves, because the page is still the page. */
[aria-busy="true"] { opacity: 0.55; cursor: progress; }

/* ------------------------------------------------------------
   10 · Stats + meters
   ------------------------------------------------------------ */

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

/* On a phone the dashboard stats compress into one taut strip of
   equal columns rather than wrapping into a stack of wide cards. */
.stat-strip { display: flex; gap: 8px; }
.stat-strip .stat { flex: 1; min-width: 0; padding: 10px 12px; }
.stat-strip .stat .num { font-size: 26px; }
.stat-strip .stat .stat-label { font-size: 11px; letter-spacing: 0.12em; }

.stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--grad-card);
  text-decoration: none;
  display: block;
}
a.stat:hover { border-color: var(--border-gold); }
.stat .num {
  font-family: var(--serif-display);
  font-size: 34px;
  font-weight: 600;
  color: var(--brass-bright);
  line-height: 1.1;
  display: block;
}
.stat .stat-label {
  font-variant: small-caps;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
}
.num { font-family: var(--serif-display); font-weight: 600; }

/* Progress meter — reading position, yearly goals. */
.meter {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--sunk);
  overflow: hidden;
  margin-top: 6px;
}
.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brass), var(--brass-bright));
}

/* ------------------------------------------------------------
   11 · Covers, shelves, spines
   ------------------------------------------------------------ */

.cover-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  background: #241812;
  box-shadow: var(--shadow-cover);
}
.cover-frame::after {
  /* spine highlight */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.10), transparent);
  pointer-events: none;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Starts transparent over .cover-frame's dark background and fades in
     once app.js sets `src` and the browser actually has the bytes — the
     visible cue that covers are filling in top to bottom rather than
     popping in all at once whenever each request happens to land. */
  opacity: 0;
  transition: opacity 0.25s ease;
}
.cover-img.is-loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .cover-img { transition: none; }
}

.cover-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 9px;
  text-align: center;
  background: var(--cover-art);
  border: 1px solid var(--cover-edge);
  border-radius: inherit;
}
.cover-ph::before { content: "❦"; color: var(--cover-accent); font-size: 12px; }
.cover-ph-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  color: var(--cover-ink);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cover-ph-author {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 8px;
  color: var(--cover-accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* grid of covers (the shelf) — three across on a phone */
.cover-grid {
  display: grid;
  gap: 18px 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.cover-card { text-decoration: none; color: inherit; display: block; position: relative; }
.cover-card .cover-frame { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.cover-card:hover .cover-frame {
  transform: translateY(-4px);
  box-shadow: inset 3px 0 6px -3px rgba(0, 0, 0, 0.7), 0 16px 30px rgba(0, 0, 0, 0.55);
}
.cover-card-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  margin: 7px 0 1px;
  color: var(--ink-strong);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cover-card-sub {
  font-family: var(--ui);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cover-card .cover-flag {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  background: var(--veil);
}

/* horizontal shelf strip */
.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100px;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 2px 10px;
  scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.shelf::-webkit-scrollbar { display: none; }
.shelf .cover-card-title { font-size: 13px; }

/* Bookcase miniature — the real spines of a shelf, drawn at scale
   so a bookcase row reads like the physical thing. */
.shelf-mini {
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  margin-top: 5px;
  padding-bottom: 2px;
  border-bottom: 2px solid var(--border-strong);
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
}
.shelf-mini i {
  display: block;
  flex: none;
  border-radius: 1px 1px 0 0;
  background: var(--spine, #4d3c28);
}

/* Shelf case — the spine board on a shelf detail page. */
.shelf-case {
  border: 1px solid var(--chrome-edge);
  border-radius: var(--radius-xl);
  background: var(--grad-shelf);
  padding: 22px 14px 0;
  box-shadow: inset 0 6px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.shelf-spines {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  min-height: 124px;
  overflow-x: auto;
  scrollbar-width: none;
}
.shelf-spines::-webkit-scrollbar { display: none; }
.spine {
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 2px 2px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  overflow: hidden;
  background: var(--spine, linear-gradient(90deg, #4a3527, #3b2a22));
  text-decoration: none;
  /* horizontal drags reorder; vertical stays a scroll */
  touch-action: pan-y;
}
.spine span {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.04em;
  color: #e8ddc6;
  white-space: nowrap;
}
.shelf-board {
  height: 12px;
  margin: 0 -14px;
  background: var(--grad-shelf-board);
  border-radius: 0 0 15px 15px;
  border-top: 1px solid rgba(211, 178, 113, 0.35);
}

/* Drag to reorder — the shelf-order list and the spines themselves. */
.order-num {
  width: 20px;
  flex: none;
  text-align: center;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--brass);
}
.order-chip {
  width: 8px;
  height: 26px;
  flex: none;
  border-radius: 1px;
}
.drag-handle {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: var(--tap);
  margin-right: -8px;
  color: var(--faint);
  cursor: grab;
  /* Without this, touch drags scroll the page instead of moving the row. */
  touch-action: none;
}
.drag-handle[hidden] { display: none; }

.order-row.is-dragging {
  background: var(--tint-soft);
  box-shadow: var(--shadow-lift);
  position: relative;
  z-index: 5;
}
/* The comp's lifted spine: raised off the board, brass-edged. */
.spine.is-dragging {
  transform: translateY(-16px);
  border-color: var(--brass-bright);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.75);
  z-index: 5;
}
body.is-reordering { user-select: none; -webkit-user-select: none; }

/* Drag to match the room — the bookcases page. Rows are links, so drags
   start on handles only; a lifted shelf row matches the order rows above,
   a lifted bookcase group gets the whole-card treatment. */
a.list-item.is-dragging {
  background: var(--tint-soft);
  box-shadow: var(--shadow-lift);
  position: relative;
  z-index: 5;
}
.list-group.is-dragging {
  border-color: var(--brass);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.55);
  position: relative;
  z-index: 5;
}

/* "Where is it?" — the deep-linked copy, marked in both shelf views. */
.spine.is-highlighted {
  border-color: var(--brass-bright);
  box-shadow: 0 0 0 2px var(--brass), 0 10px 22px rgba(0, 0, 0, 0.6);
  z-index: 4;
}
.order-row.is-highlighted {
  background: var(--tint);
  box-shadow: inset 3px 0 0 var(--brass-bright);
}
@media (prefers-reduced-motion: no-preference) {
  .spine.is-highlighted {
    animation: highlight-pulse 1.2s ease-in-out 2;
  }
  @keyframes highlight-pulse {
    50% { transform: translateY(-10px); }
  }
}

/* Arrange this shelf — strategy chips, the AI instruction row, and the
   proposal card that holds Apply / Put it back. */
.ai-arrange-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-arrange-row input { flex: 1; min-width: 0; }
.ai-arrange-row .btn { flex: none; }
.arrange-preview {
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  background: var(--tint-soft);
  padding: 12px 14px;
}
.arrange-preview p { margin-bottom: 10px; }

/* The printable "move these books" sheet. Never rendered on screen; the
   app's one @media print pattern, and it is deliberately scoped under
   body.printing-moves (set only while the Print list button runs
   window.print()) so printing any other page is untouched. */
.print-sheet { display: none; }

@media print {
  body.printing-moves .topbar,
  body.printing-moves .tabbar,
  body.printing-moves .footer,
  body.printing-moves main > *:not(.print-sheet) {
    display: none !important;
  }
  body.printing-moves {
    background: #fff;
  }
  body.printing-moves .print-sheet {
    display: block;
    color: #000;
    background: #fff;
    font-size: 12pt;
  }
  body.printing-moves .print-sheet h2 {
    color: #000;
    font-size: 16pt;
    margin-bottom: 4pt;
  }
  body.printing-moves .print-sheet p {
    color: #333;
    margin-bottom: 10pt;
  }
  body.printing-moves .print-sheet ol {
    padding-left: 18pt;
  }
  body.printing-moves .print-sheet li {
    margin-bottom: 4pt;
  }
  body.printing-moves .print-sheet li.print-move { font-weight: 600; }
  body.printing-moves .print-sheet li.print-stay { color: #777; }
}

/* ------------------------------------------------------------
   12 · Screens
   ------------------------------------------------------------ */

/* Dashboard ------------------------------------------------- */

.hero { padding: 4px 0 8px; }
.hero h1 { font-size: 34px; margin-bottom: 4px; }
.hero .hero-sub { color: var(--muted); font-style: italic; font-size: 15px; }

.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: var(--grad-avatar);
  font-family: var(--serif-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--brass-bright);
  text-decoration: none;
}
.avatar-lg { width: 56px; height: 56px; font-size: 24px; }

.hero-search { position: relative; margin: 14px 0 0; }
.hero-search .search-field { box-shadow: var(--shadow-lift); background: var(--surface); border-color: var(--border-gold); }

.autocomplete { position: relative; }
.autocomplete-results, .hero-search-results {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  background: var(--surface-raised);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 420px;
  overflow-y: auto;
  text-align: left;
}
.hero-search-results:empty { display: none; }

.search-hit {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--hairline);
  min-height: var(--tap);
}
.search-hit:last-child { border-bottom: none; }
.search-hit:hover { background: var(--tint-soft); }
.search-hit .cover-frame { width: 40px; flex: none; box-shadow: none; }
.search-hit .cover-ph::before { display: none; }
.search-hit .cover-ph { padding: 4px 2px; }
.search-hit .cover-ph-title { font-size: 8px; -webkit-line-clamp: 3; }
.search-hit .cover-ph-author { display: none; }
.search-hit-title { font-family: var(--serif-display); font-weight: 600; font-size: 17px; color: var(--ink-strong); }
.search-hit-meta { font-family: var(--ui); font-size: 13px; color: var(--muted); }
.search-hit-none { padding: 14px; color: var(--muted); }

/* Book detail ----------------------------------------------- */

.book-hero { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.book-hero .cover-frame { box-shadow: var(--shadow-cover-lg); }

/* On a phone the book presents itself the way a book does: cover
   centred, title beneath, everything else below the fold. */
@media (max-width: 760px) {
  .book-hero { grid-template-columns: 1fr; gap: 16px; text-align: center; }
  /* The cover is 132px, but its column is full width — otherwise the
     "Change cover…" disclosure under it wraps to three words a line. */
  .book-hero > :first-child { display: flex; flex-direction: column; align-items: center; }
  .book-hero > :first-child .cover-frame { width: 132px; }
  .book-hero > :last-child { text-align: left; }
  .book-hero .book-headline { text-align: center; }
}
.book-headline h1 { font-size: 30px; margin-bottom: 2px; }
/* Sits between the title and the byline, in the same display serif but
   upright and smaller — part of the name of the book, not a second
   heading competing with it. */
.book-subtitle {
  font-family: var(--serif-display);
  font-size: 19px;
  color: var(--ink);
  margin: 0 0 2px;
  line-height: 1.25;
}
.book-byline {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 18px;
  color: var(--muted);
  margin: 0;
}

.meta-line { color: var(--muted); margin: 2px 0; font-family: var(--ui); font-size: 13px; }
.meta-line strong { color: var(--ink); font-weight: normal; }

.copy-row { display: flex; align-items: center; gap: 12px; }
.copy-thumb { width: 42px; flex: none; }
.copy-thumb .cover-frame { box-shadow: none; }

/* at thumbnail size, placeholders reduce to a plain leather spine */
.copy-thumb .cover-ph, .loan-cover .cover-ph, .search-hit .cover-ph,
.list-item-thumb .cover-ph { padding: 3px; justify-content: center; }
.copy-thumb .cover-ph::before, .loan-cover .cover-ph::before,
.list-item-thumb .cover-ph::before { display: none; }
.copy-thumb .cover-ph-title, .loan-cover .cover-ph-title,
.list-item-thumb .cover-ph-title { font-size: 8px; -webkit-line-clamp: 4; }
.copy-thumb .cover-ph-author, .loan-cover .cover-ph-author,
.list-item-thumb .cover-ph-author { display: none; }

/* reading status — a segmented control, one choice at a time */
.status-set { display: flex; gap: 4px; background: var(--well); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.status-set button {
  flex: 1;
  min-height: 40px;
  padding: 8px 4px;
  font-size: 13px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.status-set button:hover { color: var(--brass-bright); }
.status-set button.active {
  font-weight: 600;
  border-color: var(--brass);
  color: var(--brass-bright);
  background: var(--tint);
}

/* "On page 83 of 300" — the reading-position row */
.page-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.page-row label { flex: 1; margin: 0; font-variant: normal; letter-spacing: normal; font-family: var(--ui); font-size: 14px; }
.page-row input { width: 84px; text-align: center; font-weight: 600; }
/* The spinner arrows eat a third of a field this narrow, and the number
   is typed, not nudged. */
.page-row input::-webkit-outer-spin-button,
.page-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-row input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.page-row .page-total { font-family: var(--ui); font-size: 14px; color: var(--faint); }

/* your rating — a row of tappable stars, same card as .page-row */
.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.rating-row-label { flex: 1; margin: 0; font-family: var(--ui); font-size: 14px; color: var(--muted); }
.star-set { display: flex; }
.star-set .star {
  background: none;
  border: none;
  padding: 4px 2px;
  min-height: var(--tap);
  min-width: 32px;
  font-size: 20px;
  line-height: 1;
  color: var(--faint);
}
.star-set .star:hover { color: var(--brass); }
.star-set .star.filled { color: var(--brass-bright); }

/* started/finished — editable so a book can be logged after the fact */
.dates-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  background: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.dates-row label { margin: 0; font-variant: normal; letter-spacing: normal; font-family: var(--ui); font-size: 14px; color: var(--muted); }
.dates-row input[type="date"] { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.dates-row .chip { margin-left: auto; }

/* A screen's one primary action, pinned to the bottom edge above the
   tab bar rather than scrolling away with the content. */
.screen-cta {
  position: sticky;
  bottom: 12px;
  z-index: 600;
  margin-top: 20px;
}
@media (max-width: 899px) {
  /* the tab bar is fixed, so the CTA floats above it */
  .screen-cta { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
}
@media (min-width: 900px) {
  .screen-cta { position: static; max-width: 320px; }
}

/* Loans ------------------------------------------------------ */

.loan-row { display: flex; gap: 14px; align-items: center; }
.loan-cover { width: 40px; flex: none; }
.loan-cover .cover-frame { box-shadow: none; }

/* Swipe-to-return. The face slides left over a fixed "Returned" panel;
   the panel is the real form, so the row still returns without JS via
   its visible chip. */
.swipe-row { position: relative; overflow: hidden; }
.swipe-under {
  position: absolute;
  inset: 0 0 0 auto;
  width: 108px;
  display: flex;
}
.swipe-under button {
  flex: 1;
  border: none;
  border-radius: 0;
  min-height: 0;
  background: var(--forest);
  color: #dceadf;
  font-size: 14px;
  font-weight: 600;
}
.swipe-under button:hover { background: var(--forest); color: #dceadf; border: none; }
.swipe-face {
  position: relative;
  z-index: 1;
  /* Opaque over the underlay; restarting the panel gradient per-row is
     visually flat at row height. */
  background: var(--grad-card);
  touch-action: pan-y;
}
.swipe-face.swipe-face--dragging { transition: none; }
.swipe-face.swipe-face--settling { transition: transform 0.18s ease; }
@media (prefers-reduced-motion: reduce) {
  .swipe-face.swipe-face--settling { transition: none; }
}

/* Members ---------------------------------------------------- */

.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.member-card {
  text-align: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--grad-card);
  padding: 18px 14px;
  display: block;
}
a.member-card:hover { border-color: var(--border-gold); }
.member-card h3 { font-size: 19px; margin: 8px 0 0; }
.member-initial {
  width: 56px; height: 56px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: var(--grad-avatar);
  font-family: var(--serif-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--brass-bright);
}

/* Charts (member pages) -------------------------------------- */

.chart { display: flex; flex-direction: column; gap: 8px; }
.chart-row { display: flex; align-items: center; gap: 10px; }
.chart-label { flex: 0 0 90px; font-size: 13px; color: var(--muted); }
.chart-bar { flex: 1; height: 10px; background: var(--sunk); border-radius: var(--radius-pill); overflow: hidden; }
.chart-fill { height: 100%; background: linear-gradient(90deg, var(--brass), var(--brass-bright)); border-radius: var(--radius-pill); }
.chart-value { flex: 0 0 60px; text-align: right; font-size: 13px; color: var(--muted); }
/* Scan -------------------------------------------------------

   The capture screen is the one place the app stops looking like a
   document. On a phone it goes full-bleed: the camera fills the
   frame, the only chrome is two floating pills, and the result
   arrives in a sheet that sits over the viewfinder rather than
   scrolling it away. Above 900px — where there is a mouse and no
   tab bar to sit above — the same pieces lay out in normal flow.
   ------------------------------------------------------------ */

.scan-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Floating chrome: where the scans land, and how many so far. */
.scan-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scan-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--veil);
  border: 1px solid var(--border);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  letter-spacing: normal;
  text-transform: none;
  font-variant: normal;
  white-space: nowrap;
  max-width: 62%;
}
/* `display` on the class beats the hidden attribute; restate it. */
.scan-pill[hidden] { display: none; }
/* Flexbox treats inline SVG's min-width as 0, so the select squeezes the
   icon to nothing without this. */
.scan-pill svg { flex: none; }
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .scan-pill { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}
.scan-pill--place { border-color: var(--border-gold); color: var(--brass-bright); }

/* The location control is a pill, so the native select has to shed its
   own box and inherit the pill's type. */
.scan-pill select,
.scan-pill input {
  width: auto;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  border-radius: 0;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}
.scan-pill select:focus, .scan-pill input:focus { border: none; outline: none; }

.scan-pill--stop {
  cursor: pointer;
  border-color: var(--oxblood);
  color: var(--oxblood-bright);
}

/* The stage: viewfinder, brackets, and the one line of instruction. */
.scan-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background-color: #000;
  background-image: radial-gradient(420px 320px at 50% 38%, #1d1710, #0a0806 75%);
  min-height: 260px;
  padding: 18px;
}

/* The video and canvas Quagga injects are absolutely positioned, so the
   frame has to carry its own size or it collapses to nothing and the
   camera is invisible. */
.scanner-frame, .scan-frame {
  position: relative;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-gold);
  background: #000;
}
#scanner { position: absolute; inset: 0; }
.scanner-frame video,
.scanner-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Brass corner brackets rather than a full rectangle: they frame the
   barcode without covering it. */
.scan-box {
  position: relative;
  width: 76%;
  aspect-ratio: 1.9;
  max-height: 78%;
}
.scan-box::before, .scan-box::after,
.scan-box > i::before, .scan-box > i::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border: 0 solid var(--brass-bright);
}
.scan-box::before { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 12px; }
.scan-box::after { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 12px; }
.scan-box > i::before { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 12px; }
.scan-box > i::after { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 12px; }

/* the sweep line across the middle of the viewfinder */
.scan-beam {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(211, 178, 113, 0.9), transparent);
}

.scan-box--hit { animation: scan-hit 0.35s ease; }
@keyframes scan-hit {
  0% { filter: brightness(1.8); }
  100% { filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scan-box--hit { animation: none; }
}

.scan-hint {
  position: relative;
  z-index: 3;
  margin: 0;
  text-align: center;
  font-family: var(--ui);
  font-size: 13px;
  color: var(--muted);
}
.scan-hint .btn { margin-top: 10px; }

/* offscreen but interactive — display:none would suppress the iOS haptic */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The result sheet. Same material as a modal sheet, but permanent —
   it is where every scan lands, and it never covers the viewfinder
   entirely. */
.scan-sheet {
  background: var(--grad-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-sheet);
  padding: 8px 16px 16px;
}

.scan-sheet-grip {
  display: block;
  width: 100%;
  min-height: 24px;
  padding: 6px 0 10px;
  background: none;
  border: none;
  cursor: pointer;
}
.scan-sheet-grip:hover { background: none; border: none; }
.scan-sheet-grip .sheet-handle { margin: 0 auto; }

.scan-sheet-empty {
  margin: 0;
  text-align: center;
  font-family: var(--ui);
  font-size: 14px;
  color: var(--muted);
}

.scan-sheet-more { margin-top: 16px; border-top: 1px solid var(--hairline); padding-top: 16px; }
.scan-sheet-more[hidden] { display: none; }

/* One scan result: cover, what it is, what to do about it. */
.scan-card { margin-top: 12px; }
.scan-card:first-child { margin-top: 0; }

.scan-result { display: flex; align-items: flex-start; gap: 14px; }
.scan-result-cover { width: 52px; flex: none; }
.scan-result-cover img {
  width: 100%;
  display: block;
  border-radius: 2px 4px 4px 2px;
  border: 1px solid var(--cover-edge);
}
.scan-result-body { flex: 1; min-width: 0; }
.scan-result-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink-strong);
  margin: 5px 0 0;
}
.scan-result-meta {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 0;
}

/* The action row the comp calls for: one primary, then square icon
   buttons for the secondary paths. */
.scan-actions { display: flex; gap: 10px; align-items: stretch; margin-top: 14px; }
.scan-actions .btn-primary { flex: 1; }

.btn-icon {
  width: 50px;
  min-height: 50px;
  flex: none;
  padding: 0;
  font-size: 19px;
  background: var(--well);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

/* Status is carried by the badge, and echoed on the sheet's left edge so
   "already have it" reads before you get to the words. */
.badge.new { border-color: var(--forest-bright); color: var(--forest-ink); background: rgba(58, 92, 58, 0.16); }
.badge.exact { border-color: var(--oxblood-bright); color: var(--oxblood-ink); background: rgba(122, 42, 35, 0.16); }
.badge.soft { border-color: var(--brass-bright); color: var(--brass-bright); background: var(--tint); }

.scan-card--primary { border-left: 3px solid transparent; padding-left: 11px; margin-left: -14px; }
.scan-card--primary.status-new { border-left-color: var(--forest-bright); }
.scan-card--primary.status-exact { border-left-color: var(--oxblood-bright); }
.scan-card--primary.status-soft { border-left-color: var(--brass-bright); }

/* Session history and the manual-entry form live behind the grip. */
.scan-card--hist {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--well);
}
.scan-card--hist.status-new { border-left-color: var(--forest-bright); }
.scan-card--hist.status-exact { border-left-color: var(--oxblood-bright); }
.scan-card--hist.status-soft { border-left-color: var(--brass-bright); }
.scan-card--hist .scan-result-title { font-size: 17px; }
.scan-card--hist .scan-actions .btn-primary { flex: 0 0 auto; }

.scan-isbn { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.scan-meta { color: var(--muted); font-family: var(--ui); font-size: 13px; }
.scan-note { color: var(--faint); font-family: var(--ui); font-size: 12px; margin-top: 10px; }
.scan-link { color: var(--brass-bright); }
.scan-list { list-style: none; margin: 0; padding: 0; }

.scan-search { position: relative; margin-top: 10px; }
.scan-search-input { width: 100%; }
.scan-search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface-raised);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 300px;
  overflow-y: auto;
}
.scan-search-results:empty { display: none; }
.scan-search-results button { width: 100%; justify-content: flex-start; border-radius: 0; border-width: 0 0 1px; }
.scan-soft-card { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 12px; margin-top: 10px; }
.scan-soft-list { list-style: none; margin: 8px 0 0; padding: 0; }
.scan-soft-footer { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* Phone: the capture screen takes the whole frame above the tab bar.
   Fixed rather than tall-with-scroll, so the viewfinder can never be
   scrolled off while you are aiming at a book. */
@media (max-width: 899px) {
  .scan-screen {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    z-index: 700;
    gap: 0;
    padding: 0;
    background-color: #000;
    background-image: radial-gradient(420px 320px at 50% 38%, #1d1710, #0a0806 75%);
  }
  .scan-chrome {
    flex: none;
    padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 0;
  }
  .scan-stage {
    flex: 1;
    min-height: 0;
    border-radius: 0;
    background: none;
    padding: 12px var(--gutter);
  }
  .scanner-frame, .scan-frame { max-width: none; }
  /* The sheet reaches the bottom edge of the capture area, so its lower
     corners square off against the tab bar. */
  .scan-sheet {
    flex: none;
    max-height: 62%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    border-bottom: none;
    padding-bottom: 18px;
  }
}

/* A phone held sideways has almost no height; give the viewfinder the
   width instead and let the sheet take the other half. */
@media (max-width: 899px) and (orientation: landscape) {
  .scan-screen { flex-direction: row; flex-wrap: wrap; }
  .scan-chrome { flex: 1 0 100%; }
  .scan-stage { flex: 1 1 55%; }
  .scan-sheet {
    flex: 1 1 45%;
    max-height: none;
    border-radius: var(--radius-sheet) 0 0 0;
  }
}
/* Tables ----------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-weight: 500;
  font-size: 13px;
  color: var(--brass);
  border-bottom: 1px solid var(--border-gold);
  padding: 8px 10px;
}
.table td { padding: 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* A table is a desktop shape. On a phone each row becomes its own
   block, labelled by its column header, so nothing scrolls sideways. */
@media (max-width: 700px) {
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--well);
  }
  .table td { border: none; padding: 4px 0; }
  .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-variant: small-caps;
    letter-spacing: 0.14em;
    font-size: 12px;
    color: var(--brass);
  }
  .table td.actions .row { justify-content: flex-start; }
}

/* The library list view ---------------------------------------
   A management shape, not a browsing one: eleven columns of real
   catalogue data. Above the card-reflow breakpoint it scrolls
   sideways inside its own well rather than crushing the columns. */

.table-scroll { overflow-x: auto; }
@media (min-width: 701px) {
  /* Eleven columns just fit the 1080px frame; below that the well
     scrolls sideways rather than crushing the names. */
  .book-table { min-width: 1040px; }
  /* The toolbar's select-all is the phone's substitute for the one in
     the header row, which the card reflow hides. */
  .table-toolbar { display: none; }
}
.table-toolbar { margin-bottom: 8px; }
.table-toolbar label { margin: 0; gap: 8px; }
.book-table td { padding: 8px 10px; font-family: var(--ui); font-size: 14px; }
.book-table .col-pick { width: 34px; }
.book-table .col-num { text-align: right; white-space: nowrap; }
.book-table td[data-label="Author"], .book-table td[data-label="Added"] { white-space: nowrap; }
.book-table-title {
  font-family: var(--serif-display);
  font-size: 16px;
  color: var(--ink-strong);
  margin-right: 6px;
}
.book-table .tag-pill { margin: 0 4px 2px 0; font-size: 11px; padding: 2px 8px; }
.book-table input[type="checkbox"] { width: 20px; height: 20px; }
.book-table td.col-pick { padding: 8px 6px 8px 10px; }

/* On a phone the row is a card — but eleven stacked labelled lines is a
   card the length of the screen. The labels go inline instead, so the
   title leads and everything else reads as one wrapped run beneath it. */
@media (max-width: 700px) {
  .book-table tr { position: relative; padding: 12px 46px 12px 14px; }
  .book-table td { display: inline-block; width: auto; padding: 0 10px 2px 0; }
  .book-table td[data-label]::before { display: inline; margin-right: 4px; }
  .book-table td[data-label="Title"] { display: block; width: 100%; padding-bottom: 4px; }
  .book-table td[data-label="Title"]::before { display: none; }
  .book-table .col-num { text-align: left; }
  /* Pinned to the corner rather than sitting in the run, so ticking a
     row never means aiming between two lines of metadata. */
  .book-table td.col-pick {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    padding: 0;
  }
}

/* Room for the selection bar, so the last row isn't trapped under it —
   added by app.js only while the bar is actually up, so an untouched
   list doesn't carry a strip of empty page under it. */
#books-bulk.has-selection { padding-bottom: 72px; }

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-link:hover { color: var(--brass-bright); }
.sort-link.is-active { color: var(--brass-bright); font-weight: 600; }
/* One caret, flipped for ascending. flex: none because flexbox will
   otherwise crush an inline SVG to nothing to fit the label. */
.sort-arrow { display: inline-flex; flex: none; }
.sort-arrow.is-asc { transform: rotate(180deg); }

/* The selection bar rides above the tab bar — the actions have to be
   where the thumb already is, not at the foot of a hundred rows. */
.bulk-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  background: var(--chrome);
  border-top: 1px solid var(--chrome-edge);
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
}
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .bulk-bar { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
}
.bulk-bar[hidden] { display: none; }
@media (max-width: 899px) {
  .bulk-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: 10px; }
}
.bulk-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
}
.bulk-count { margin: 0; font-size: 14px; color: var(--ink-strong); font-weight: 600; }
.bulk-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-variant: normal; letter-spacing: normal; }
.bulk-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.chip-danger { color: var(--oxblood-bright); }
.chip-danger:hover { color: var(--oxblood-bright); border-color: var(--oxblood-bright); }
/* Delete is turned off while the selection is "everything matching" —
   the server refuses that, so the chip shouldn't look like a way in. */
.chip[disabled] { opacity: 0.4; cursor: not-allowed; }
.chip[disabled]:hover { border-color: var(--border); color: var(--muted); }
.chip-danger[disabled]:hover { color: var(--oxblood-bright); }
/* A chip that removes the filter it names. */
.chip-clear { border-style: dashed; }
/* Checkbox-bearing chips in the filter and tag sheets. */
.choice-row label.chip { margin: 0; gap: 8px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager-nav .btn svg { flex: none; }
.icon-flip { display: inline-flex; transform: rotate(180deg); }
.pager-position { white-space: nowrap; }
.pager-size { display: flex; align-items: center; gap: 8px; }
.pager-size-link {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.pager-size-link.is-active { color: var(--brass-bright); font-weight: 600; background: var(--tint); }

.list-clean { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  min-height: var(--tap);
}
.list-row:last-child { border-bottom: none; }

/* ------------------------------------------------------------
   13 · Footer + auth
   ------------------------------------------------------------ */

.footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  text-align: center;
  font-style: italic;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 40px 34px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  background: var(--grad-card);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 34px; margin-bottom: 2px; }
.auth-card .ornament { margin: 4px 0 16px; }
.auth-card form { text-align: left; }
.auth-card button[type="submit"] { width: 100%; margin-top: 14px; }

/* ------------------------------------------------------------
   Spacing utilities

   Last of the unconditional rules on purpose. Components above
   reset their own margins — a `<ul class="list-group mt-md">`
   only gets its 20px if these come after `.list-group`.
   ------------------------------------------------------------ */

.mt-xs { margin-top: 4px; } .mt-sm { margin-top: 10px; } .mt-md { margin-top: 20px; }
.mt-lg { margin-top: 30px; } .mt-xl { margin-top: 44px; }
.mb-0 { margin-bottom: 0; } .mb-xs { margin-bottom: 4px; } .mb-md { margin-bottom: 20px; }
.center { text-align: center; }

/* ------------------------------------------------------------
   Responsive: the phone shell vs. the desk
   ------------------------------------------------------------ */

/* Below this width the app is the PWA: no top bar, a tab bar
   instead, and screen headers carrying the wayfinding. */
@media (max-width: 899px) {
  :root { --pad-top: 14px; --gutter: 20px; }
  .topbar { display: none; }
  .tabbar { display: flex; }
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .wrap { padding-bottom: 20px; }
  .screen-chrome { padding-bottom: 10px; }
  .footer { display: none; }
}

@media (min-width: 900px) {
  /* The desk gets the full title scale back. */
  h1 { font-size: 38px; }
  .screen-header .screen-title { font-size: 38px; }
  .hero h1 { font-size: 44px; }
  /* The greeting keeps the avatar on its right, so the whole hero stays
     left-aligned with the rest of the page rather than half-centring. */
  .hero { padding: 22px 0 8px; }
  .hero .hero-sub { font-size: 17px; }
  .hero-search { max-width: 620px; margin-top: 18px; }
  .stat-strip { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat-strip .stat { padding: 14px 16px; }
  .stat-strip .stat .num { font-size: 34px; }
}

@media (max-width: 560px) {
  .cover-grid { grid-template-columns: repeat(3, 1fr); gap: 18px 14px; }
  .member-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 32px 22px; }
}
