/* Our Shelf design system. See docs/design-system.md and the live page at /styleguide.
   Order: 1 tokens, 2 base, 3 app shell (collapsible left menu), 4 components, 5 pages.
   System typefaces only: nothing is fetched from other sites. */

/* === 1. Tokens ============================================================= */
:root {
  /* Colour: five neutrals, two brand colours, one for danger. Text pairs meet WCAG AA (4.5:1). */
  --paper: #f4f6f3;        /* page background */
  --surface: #ffffff;      /* fields, cards, the menu */
  --ink: #18211f;          /* text */
  --muted: #4f5b57;        /* secondary text */
  --line: #c3ccc6;         /* decorative dividers only */
  --edge: #6b7772;         /* borders that must be seen: fields, outlines (3:1) */
  --accent: #1d5846;       /* actions and links */
  --mark: #5a3e8e;         /* status: stamps, counts, focus ring */
  --amber: #7a5200;        /* the "free to keep" offer */
  --danger: #a22c27;       /* errors and destructive actions */
  --on-fill: #ffffff;      /* text and rims on a filled colour (buttons, counts, markers) */
  --tile-filter: none;     /* map tiles; dimmed in dark mode */
  --print-paper: #ffffff;  /* flyers and posters: black on white in every theme */
  --print-ink: #000000;
  color-scheme: light;

  /* Type: two families, one scale (steps of about 1.2). Page content uses these sizes only. */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.8125rem;    /* 13px: offer chips */
  --text-s: 0.875rem;      /* 14px: author, place, meta, footer */
  --text-menu: 0.9375rem;  /* 15px: menu items */
  --text-m: 1rem;          /* 16px: body */
  --text-l: 1.25rem;       /* 20px: section headings */
  --text-xl: 1.5rem;
  --text-2xl: clamp(1.5rem, 1rem + 2.5vw, 1.875rem);   /* page titles, 30px on wide screens */
  --text-3xl: clamp(2.2rem, 5vw, 3.6rem);

  /* Space: one scale, used for every gap and padding. */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;

  --radius: 4px;
  --target: 2.75rem;       /* smallest size of anything you press (44px) */
  --menu-open: 15rem;
  --menu-closed: 4.25rem;
  --measure: 65ch;
  --frame: 80rem;          /* one frame for page head, content and footer (1280px) */
  --frame-pad: clamp(1.5rem, 4vw, 3rem);
}

/* Dark mode: the same roles, lighter colours on dark ground. Pages are dark (data-theme="dark"
   on <html>); a member who chooses light on their profile gets data-theme="light", which uses
   the :root set above. Contrast is checked by tests/test_design_system.py for both sets. */
:root[data-theme="dark"] {
  --paper: #1f2422;
  --surface: #262c2a;
  --ink: #e4e9e6;
  --muted: #a3aea9;
  --line: #353c39;
  --edge: #88938e;
  --accent: #86c9b0;
  --mark: #bfa8ee;
  --amber: #e2c27d;
  --danger: #f2958d;
  --on-fill: #0f1513;
  --tile-filter: brightness(0.8) contrast(1.1);
  color-scheme: dark;
}

/* === 2. Base =============================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--text-m)/1.55 var(--sans); }
/* Light text on a dark ground looks bolder with subpixel smoothing (macOS); grayscale keeps both themes the same weight. */
:root[data-theme="dark"] body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0 0 var(--s3); }
h1 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--text-l); margin-top: var(--s6); }
h3 { font-size: var(--text-l); }
p { margin: 0 0 var(--s4); max-width: var(--measure); }
a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--ink); }
cite { font-family: var(--serif); }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; border-radius: 2px; }
.quiet { color: var(--muted); font-size: var(--text-s); }
.lede { font-size: var(--text-l); color: var(--muted); max-width: 52ch; }
[hidden] { display: none !important; }
html:not(.js) .needs-js, .js .no-js { display: none; }   /* scripts add .js to the page (app.js) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1.5rem; height: 1.5rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: var(--s4); top: var(--s4); background: var(--surface); padding: var(--s2) var(--s3); z-index: 10; }

/* === 3. App shell: collapsible left menu =================================== */
.shell { display: grid; grid-template-columns: var(--menu-open) minmax(0, 1fr); min-height: 100vh; }
.shell.menu-closed { grid-template-columns: var(--menu-closed) minmax(0, 1fr); }

.menu {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s5) var(--s3) var(--s4); background: var(--surface); border-right: 1px solid var(--line);   /* 24px: the band the page title shares */
}
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: var(--target); }
.wordmark { font: 600 var(--text-xl)/var(--target) var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; padding: 0 var(--s2); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 0.625rem; }
/* The mark: stroked in the text colour it's given, never filled. Before the name in the menu and the top bar; at the top of printed sheets in black. */
.mark { flex: none; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.wordmark .mark { height: 0.82em; width: auto; color: var(--accent); }
.mark-print { display: block; height: 2.75rem; width: auto; margin: 0 auto var(--s3); color: var(--print-ink); }
/* "Beta" beside the name while the site is in beta (BETA setting): the count pill's shape, outlined and muted. */
.brand { display: inline-flex; align-items: center; gap: var(--s1); }
.beta-tag, .staff-tag { padding: 0 0.5em; border: 1px solid var(--line); border-radius: 1em; color: var(--muted); font-size: var(--text-s); font-weight: 600; }
.menu-closed .menu .beta-tag { display: none; }
.beta-line { color: var(--muted); font-size: var(--text-s); }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: var(--target); height: var(--target);
  background: none; border: 0; border-radius: var(--radius); color: var(--ink); cursor: pointer;
}
.menu-toggle:hover { background: var(--paper); }
.menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.menu-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); }
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--target);
  padding: var(--s2) var(--s3); border: 0; border-radius: var(--radius); background: none;
  color: var(--ink); font: inherit; font-size: var(--text-menu); text-align: left; text-decoration: none; cursor: pointer;
}
/* Calm: the current page is a faint tint of ink and semibold, not a coloured fill; covers carry the colour. */
.menu-item:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.menu-item[aria-current="page"] { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); font-weight: 600; }
/* Groups: a small muted label over each, not a link. */
/* Group labels: small capitals in muted, at the icons' left edge (the items' own 12px), 28px above and 6px
   below, so each label sits against the group it opens. Uppercase is CSS only; the words stay as written. */
.menu-group { margin-top: 1.75rem; }
.menu-group-label { margin: 0 0 0.375rem; padding: 0 var(--s3); color: var(--muted);
  font-size: 0.75rem; font-weight: 600; line-height: 1rem; letter-spacing: 0.06em; text-transform: uppercase; }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  display: inline-block; min-width: 1.5em; padding: 0 0.4em; text-align: center;
  background: var(--mark); color: var(--on-fill); border-radius: 1em; font-size: var(--text-s); font-weight: 600;
}

/* Closed on a wide screen: an icon rail. Labels stay available to screen readers and as tooltips. */
.menu-closed .menu { padding-left: var(--s2); padding-right: var(--s2); }
.menu-closed .menu-head { justify-content: center; }
.menu-closed .wordmark { display: none; }
.menu-closed .menu-item { justify-content: center; padding: var(--s2); position: relative; }
.menu-closed .menu-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* In the rail a thin line separates the groups; their labels stay for screen readers. */
.menu-closed .menu-group-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
.menu-closed .menu-group { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
.menu-closed .menu-item .count { position: absolute; top: 0.1rem; right: 0.1rem; }   /* the rail's badge only, never a count elsewhere on the page */

.page { min-width: 0; display: flex; flex-direction: column; }

/* Signed out: a top bar instead of the menu (the way in for visitors, at the right). */
.shell-visitor { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
.shell-visitor main { margin-left: auto; margin-right: auto; }   /* signed-out pages sit in the middle */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); padding: var(--s2) var(--s5); border-bottom: 1px solid var(--line); }
.topbar .wordmark { padding-left: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.topbar-actions .button { white-space: nowrap; }   /* "Sign in" on one line, always */
.topbar-actions .button[aria-current] { text-decoration: underline; text-underline-offset: 0.2em; }
.button .icon { width: 1.1em; height: 1.1em; }
.button-lead .icon { width: 1.125rem; height: 1.125rem; margin-left: calc(var(--s1) * -1); }   /* a leading icon ("+ Add a book"): 18px */
/* One frame: page head, content and footer share a width and edges, centred right of the menu. */
main, .colophon { width: 100%; max-width: var(--frame); margin-left: auto; margin-right: auto; padding-left: var(--frame-pad); padding-right: var(--frame-pad); }
main { padding-top: var(--s5); padding-bottom: var(--s7); flex: 1; }
/* The foot of the page: one quiet row inside the frame, under a hairline. */
.colophon { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s5); padding-top: var(--s2); padding-bottom: var(--s2); color: var(--muted); font-size: var(--text-s); }
.colophon::before { content: ""; flex-basis: 100%; height: 0; margin-bottom: var(--s2); border-top: 1px solid var(--line); }   /* the hairline, inside the frame */
.colophon p, .colophon form { margin: 0; }
.colophon-name { font-family: var(--serif); font-weight: 600; color: var(--ink); }   /* the wordmark, small */
.colophon-motto { font-family: var(--serif); font-style: italic; }
.colophon nav { display: flex; flex-wrap: wrap; gap: 0 var(--s4); }
.colophon a { display: inline-flex; align-items: center; min-height: var(--target); color: var(--muted); }
.colophon a:hover { color: var(--ink); }
/* The language switch: the current language in ink, the others as quiet links that switch on one press. */
.colophon .language { margin-left: auto; }   /* beats ".colophon form { margin: 0 }" */
.language [role="group"] { display: flex; align-items: center; gap: var(--s3); }
.language .icon { width: 1.125rem; height: 1.125rem; color: var(--muted); }
.language [aria-current] { color: var(--ink); font-weight: 600; }
.language button { display: inline-flex; align-items: center; min-height: var(--target); padding: 0; border: 0; background: none;
  color: var(--muted); font: inherit; text-decoration: underline; text-underline-offset: 0.15em; cursor: pointer; }
.language button:hover { color: var(--ink); }
/* From five languages on: a disclosure at the foot that opens a list of the same buttons upwards. */
.language-menu { position: relative; }
.language-menu summary { list-style: none; display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--target);
  padding: 0 var(--s2); border: 1px solid transparent; border-radius: var(--radius); color: var(--ink); cursor: pointer; }
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu summary:hover, .language-menu summary:focus-visible { border-color: var(--edge); }
.language-menu summary::after { content: ""; width: 0.4em; height: 0.4em; margin: 0 0.15em 0.2em; border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }     /* a small chevron, pointing down */
.language-menu[open] summary::after { transform: rotate(-135deg); margin-bottom: -0.2em; }   /* up while open */
.language-menu ul { position: absolute; bottom: calc(100% + var(--s1)); right: 0; z-index: 5; list-style: none; margin: 0;
  padding: var(--s2) var(--s4); display: grid; grid-template-columns: max-content; gap: 0 var(--s5);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--print-ink) 22%, transparent); }
.language-menu ul.two-columns { grid-template-columns: repeat(2, max-content); }
.language-menu li > button, .language-menu li > span { min-height: 2.25rem; display: inline-flex; align-items: center; }

/* Narrow screens: the menu becomes a bar on top that opens downwards. */
@media (max-width: 48rem) {
  .shell, .shell.menu-closed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }   /* a short page doesn't push itself down */
  .menu { position: static; height: auto; padding: var(--s2) var(--s3); border-right: 0; border-bottom: 1px solid var(--line); }
  .menu-closed .wordmark { display: inline-flex; }
  .menu-closed .menu .beta-tag { display: inline-block; }
  .menu-closed .menu-head { justify-content: space-between; }
  .js .menu-closed .menu nav, .js .menu-closed .menu-foot { display: none; }
  .menu-foot { margin-top: 0; }
  main { padding-top: var(--s4); padding-bottom: var(--s6); }
  .topbar { padding: var(--s2) var(--s4); }
  /* Phones: a smaller name and tighter buttons, so the bar never runs wider than the screen (which makes
     iPhone Safari lay the whole page out wider, and taller, than it is). Below about 340px it wraps. */
  .topbar .wordmark { font-size: var(--text-l); gap: var(--s2); }
  .topbar .brand { gap: var(--s1); }
  .topbar .beta-tag { font-size: var(--text-xs); }
  .topbar-actions .button { padding-left: var(--s3); padding-right: var(--s3); }
  .colophon .language { margin-left: 0; }
  .language-menu ul { right: auto; left: 0; }   /* the switch sits at the left here: open towards the page */
}

/* === 4. Components ========================================================= */
/* Buttons: one primary action per view (filled), everything else plain (outlined). */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--target);
  padding: var(--s2) var(--s4); border: 1.5px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--on-fill); font: 600 var(--text-m)/1.2 var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--ink); border-color: var(--ink); color: var(--on-fill); }
.button-plain { background: transparent; color: var(--accent); font-weight: 500; }   /* lighter than the one filled action */
/* A small button looks 32px tall, but an invisible layer keeps what you can press 44px high
   (--target): it grows up and down only, so side-by-side buttons never overlap. */
.button-small { position: relative; min-height: var(--s6); padding: var(--s1) var(--s3); font-size: var(--text-s); }
.button-small::before { content: ""; position: absolute; left: 0; right: 0; top: calc((100% - var(--target)) / 2); bottom: calc((100% - var(--target)) / 2); }
.linklike { background: none; border: 0; padding: var(--s2) 0; min-height: var(--target); color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.linklike.danger { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin: 0 0 var(--s4); }
.actions form { margin: 0; }
/* Report and Block: small, quiet, always in the same order */
/* Report and Block: quiet muted links, Report first, under someone else's words or things, never your own.
   They look one line tall; an invisible layer keeps what you can press 44px high (like .button-small). */
.safety { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); align-items: center; margin: var(--s3) 0 var(--s4); font-size: var(--text-s); }
.safety form { margin: 0; }
.safety a, .safety .linklike { position: relative; min-height: 0; padding: 0; color: var(--muted); }
.safety a:hover, .safety .linklike:hover { color: var(--ink); }
.safety a::before, .safety .linklike::before { content: ""; position: absolute; left: 0; right: 0; top: calc((1.5em - var(--target)) / 2); height: var(--target); }

/* Fields: label above, hint between, error below; never placeholder-only. */
form { margin: 0 0 var(--s5); }
.field { margin: 0 0 var(--s4); border: 0; padding: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin-bottom: var(--s1); padding: 0; }
.hint { margin: 0 0 var(--s1); color: var(--muted); font-size: var(--text-s); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: var(--target); padding: var(--s2) var(--s3);
  border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit;
}
textarea { resize: vertical; }
/* A select draws its own chevron, in --muted so it follows the theme: two thin diagonal strokes meeting
   in a V whose right end sits 16px in from the edge. The list that opens stays the browser's own. */
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 2.75rem;   /* long option text never runs under the chevron */
  background-color: var(--surface);
  background-image:   /* "\" then "/", overlapping 1px at the point */
    linear-gradient(45deg, transparent 40%, var(--muted) 40%, var(--muted) 60%, transparent 60%),
    linear-gradient(135deg, transparent 40%, var(--muted) 40%, var(--muted) 60%, transparent 60%);
  background-size: 6px 6px, 6px 6px;
  background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
  background-repeat: no-repeat;
}
select:not([multiple]):hover { border-color: var(--ink); }
.field-bad select:not([multiple]):hover { border-color: var(--danger); }   /* a problem stays red */
.field-bad input, .field-bad textarea, .field-bad select { border-color: var(--danger); border-width: 2px; }
fieldset.field-bad { border-left: 3px solid var(--danger); padding-left: var(--s3); }   /* a group of choices */
.error { color: var(--danger); font-weight: 600; margin: var(--s1) 0 0; }
.error-word { font-weight: 700; }
.choice { font-weight: 400; display: flex; gap: var(--s2); align-items: center; min-height: var(--target); }
.pair { display: grid; grid-template-columns: 1fr 2fr; gap: 0 var(--s4); }
/* A kind's own fields (kinds.py): full width, or two half-width ones side by side. */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
.fields > * { grid-column: 1 / -1; }
.fields > .half { grid-column: auto; }
.inline { display: flex; gap: var(--s2); }
.inline input { flex: 1; }
/* Hiding a listing or suspending a member (backoffice): the note, then the optional email to the member. */
.restrict-form { display: grid; gap: var(--s2); max-width: 36rem; margin: 0 0 var(--s3); }
.restrict-form .hint { margin: 0; }
.restrict-email { display: grid; gap: var(--s1); margin: 0; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--radius); }
.restrict-email textarea { min-height: 3.5rem; }
.restrict-form .button { justify-self: start; }
fieldset.group { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s4) 0; margin: 0 0 var(--s5); }
fieldset.group > legend { font: 600 var(--text-l) var(--serif); padding: 0 var(--s2); }

.notice { background: var(--surface); border-left: 3px solid var(--edge); padding: var(--s3) var(--s4); margin: 0 0 var(--s5); max-width: none; }
/* "Make the shelf yours" (requirement 41): one quiet card at the top of Home's main column; done rows
   shrink to a ticked line. */
.start-card { margin: 0 0 var(--s7); padding: var(--s4) var(--s5); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.start-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); }
.start-head h2 { margin: 0; }
.start-head form { margin: 0; }
.start-card > .quiet { margin: var(--s1) 0 var(--s4); }
.start-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.start-step { padding: var(--s4) 0; border-top: 1px solid var(--line); }
.start-step h3 { margin: 0 0 var(--s1); font-size: var(--text-m); }
.start-step .hint { margin: 0 0 var(--s2); }
.start-step form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: 0 0 var(--s2); }
.start-step form input[type="text"], .start-step form select { width: auto; flex: 1 1 9rem; min-height: var(--target); }
.start-step form .ask-place-compact { flex: 1 1 100%; margin: 0; }
.start-step .link-copy { margin: 0 0 var(--s2); }
.start-step p:last-child { margin-bottom: 0; }
.start-done { padding: var(--s2) 0; }
.start-ticked { display: flex; align-items: center; gap: var(--s2); margin: 0; color: var(--muted); }
.start-ticked .icon { width: 1.125rem; height: 1.125rem; color: var(--accent); }
.start-finished h2 { margin: 0; }
.empty { border: 1.5px dashed var(--edge); border-radius: var(--radius); padding: var(--s5) var(--s4) var(--s2); margin: var(--s4) 0; }

/* Scores, one to five, each written as a word (ui.score). */
.scores { display: flex; flex-wrap: wrap; gap: 0 var(--s4); }
details.rate { flex-basis: 100%; }
details.rate summary { display: inline-flex; align-items: center; min-height: var(--target); color: var(--accent); text-decoration: underline; cursor: pointer; }
details.rate form { margin: var(--s2) 0 0; }

/* A plain table of amounts (the costs page). */
.ledger { width: 100%; max-width: var(--measure); border-collapse: collapse; margin: 0 0 var(--s5); }
.ledger th, .ledger td { padding: var(--s2) var(--s3) var(--s2) 0; border-top: 1px solid var(--line); text-align: left; font-weight: 400; }
.ledger td:nth-child(2) { color: var(--muted); }

.narrow { max-width: 30rem; }
.narrow-wide { max-width: 42rem; }
.reading-column { max-width: 40rem; }   /* sections under a full-width page head */
/* A row with a link at the left and a button at the right: the toolbar above a print sheet. */
.heading-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--s3) var(--s5); margin: 0 0 var(--s2); }
.heading-row .actions { margin: 0; }
/* Page head (ui.page_head): title, one muted line, actions at the right, then one line across:
   the page's tabs, or a 1px rule when it has none. Never both, never neither. */
.page-head { margin: 0 0 var(--s6); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.page-head-tabs { padding-bottom: 0; border-bottom: 0; }              /* the tabs' own underline is the line */
.page-head-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--s3) var(--s5); }
.page-head-words { min-width: 0; flex: 1 1 20rem; }
.page-head h1 { margin: 0; line-height: 1.2; min-height: var(--target); display: flex; align-items: center; }   /* one line keeps the 44px band with the wordmark; two wrap tightly */
.page-subtitle { margin: 0; font: 400 1.125rem/1.3 var(--serif); color: var(--muted); }   /* after a title's colon */
.page-line { margin: var(--s1) 0 0; color: var(--muted); font-size: var(--text-m); max-width: var(--measure); }
.page-actions { margin: 0; }
.page-back { margin: 0 0 var(--s2); font-size: var(--text-s); }
.page-head .tabs { margin: var(--s4) 0 0; }
/* A list straight after the page head: the head's rule is its top line, so the list doesn't draw another. */
.page-head + .rows > li:first-child, .page-head + .clubs > li { border-top: 0; }
.page-head + .clubs > li { padding-top: 0; }
/* A section's heading row: the heading at the left, "See all" (14px) at the right, on one baseline, over a
   hairline; then 24px to the content. The same in the main and the side column. */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4);
  margin: 0 0 var(--s5); padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; min-width: 0; }
.section-head h2 .count { vertical-align: 0.15em; margin-left: var(--s1); }
.section-head > a { flex: none; font-size: var(--text-s); white-space: nowrap; }

/* Home, signed in: the shelf (2fr) beside a column of sections (1fr), both starting at the same height.
   No boxes around the side sections; 48px between sections. */
.home { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s7) var(--s6); align-items: start; }
@media (min-width: 48.0625rem) {
  /* The last row takes what's left, so a tall shelf never spreads the side sections apart. */
  .home { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: repeat(3, auto) 1fr; }
  .home-main { grid-column: 1; grid-row: 1 / 5; }
  .home > .home-side { grid-column: 2; }
}
.home-side p:last-child { margin-bottom: 0; }
.home-side .clubs { grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin: 0 0 var(--s4); }
.home-side .clubs h3 { font-size: var(--text-m); margin-bottom: var(--s1); }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.two-up { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 0 var(--s7); }

.tabs { display: flex; flex-wrap: wrap; gap: 0 var(--s5); border-bottom: 1px solid var(--line); margin: var(--s3) 0 var(--s4); }
.tabs a { display: inline-flex; align-items: center; min-height: var(--target); color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
/* Books and Map: one row, search first, then Distance and Offer; all 44px high, no visible labels. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin: 0 0 var(--s2); }
.toolbar-search { position: relative; flex: 1 1 16rem; min-width: 0; }
.toolbar-search .icon { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); width: 1.25rem; height: 1.25rem; color: var(--muted); pointer-events: none; }
.toolbar input[type="search"] { width: 100%; min-height: var(--target); padding-left: 2.5rem; padding-right: var(--target); }
.toolbar input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }   /* one × only: ours */
.toolbar-clear { position: absolute; right: 0; top: 0; bottom: 0; width: var(--target); border: 0; background: none;
  color: var(--muted); font-size: var(--text-l); line-height: 1; cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0; }
.toolbar-clear:hover { color: var(--ink); }
.results { transition: opacity 0.12s ease; }
.toolbar select { min-height: var(--target); width: auto; }
.toolbar-distance { flex: 0 0 13.75rem; }
.toolbar-offer { flex: 0 0 11.875rem; }
.toolbar .button { min-height: var(--target); }
.result-line { margin: 0 0 var(--s5); color: var(--muted); font-size: var(--text-s); }
@media (max-width: 48rem) {
  .toolbar-search { flex-basis: 100%; }
  .toolbar-distance, .toolbar-offer { flex: 1 1 0; min-width: 0; }
}
/* List | Map: an icon and a word each; on one line. */
.view-tabs { flex-wrap: nowrap; }
.view-tabs a { gap: var(--s2); }
.view-tabs .icon { width: 1.125rem; height: 1.125rem; }

/* Status stamp: always words, colour is only an accent. */
.stamp {
  display: inline-block; padding: 0.05rem 0.45rem; border: 1px solid var(--edge); border-radius: var(--radius);
  color: var(--muted); font-size: 0.82rem; font-weight: 600;
}

/* Book cover: the catalog image, or a plain paper cover with the title, in the page's own colours. */
/* Every cover keeps a fixed 2:3 box, so nothing beside it moves when a picture arrives. */
.cover { display: block; height: 10.5rem; aspect-ratio: 2 / 3; border-radius: 1px 3px 3px 1px; }
.cover-framed { position: relative; }
.cover-picture { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--print-ink) 20%, transparent); background: transparent; }
.cover-cloth { width: 7rem; padding: var(--s3) var(--s2) var(--s2) var(--s3); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--line); box-shadow: none; }
.cover-title { font: 600 0.95rem/1.15 var(--serif); overflow-wrap: normal; hyphens: manual;   /* never mid-word: app.js shrinks a long word to fit */
   display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cover-author { font-size: 0.72rem; line-height: 1.2; }

/* Book cards (Home, Books, a member's page): one box per book, and the whole box is one link: the title's
   link stretches over it (::after), the offer chips sit above that as links of their own. */
.cards { list-style: none; margin: 0 0 var(--s5); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s5); }
.result-line + .cards { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }   /* Books: 5 across at 1440px; Home's column: 4 */
.card { position: relative; display: flex; flex-direction: column; gap: var(--s1); min-width: 0; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--radius); }
.card:hover, .card:has(.card-title:focus-visible) { background: var(--surface); border-color: var(--edge); }
.card:has(.card-title:focus-visible) { outline: 3px solid var(--mark); outline-offset: 2px; }
.card .cover { width: 100%; height: auto; margin-bottom: var(--s1); }    /* full width at 2:3; 8px to the title */
.card-title { font: 600 var(--text-m)/1.25 var(--serif); color: var(--ink); text-decoration: none; min-height: 2.5em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card-title:hover { color: var(--ink); }
.card-title:focus-visible { outline: none; }      /* the card draws the ring */
.card-meta { color: var(--muted); font-size: var(--text-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .chips { position: relative; z-index: 1; }

/* Offer chips: a dot of the offer's colour and the word in ink, on a faint tint of the same colour. */
.chips { display: flex; flex-wrap: wrap; gap: var(--s1); }
.chip { --chip: var(--muted); display: inline-flex; align-items: center; gap: var(--s2); height: 1.75rem; padding: 0 0.625rem;
  border-radius: var(--radius); background: color-mix(in srgb, var(--chip) 12%, transparent); color: var(--ink);
  font-size: var(--text-xs); font-weight: 500; text-decoration: none; white-space: nowrap; }
.chip::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--chip); flex: none; }
:root[data-theme="dark"] .chip { background: color-mix(in srgb, var(--chip) 16%, transparent); }
a.chip:hover { color: var(--ink); background: color-mix(in srgb, var(--chip) 26%, transparent); }
.chip-lend { --chip: var(--accent); }
.chip-swap { --chip: var(--mark); }
.chip-give { --chip: var(--amber); }

.rows { list-style: none; margin: var(--s3) 0 var(--s5); padding: 0; }
.rows li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.rows li.done { color: var(--muted); }
.rows form { margin: 0; }

.thread { list-style: none; margin: var(--s4) 0; padding: 0; display: grid; gap: var(--s3); }
.thread li { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.thread li.mine { align-items: flex-end; }
.message { max-width: 34rem; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mine .message { border: 2px solid var(--accent); }
.thread p { margin: 0; }
.thread .safety { margin: var(--s1) 0 0; }   /* under their words, outside the bubble */
.said { white-space: pre-line; overflow-wrap: anywhere; }

/* === 5. Pages ============================================================== */
.book { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; gap: 0 var(--s6); }
/* Wide screens: the cover to the left of the title and everything under it (the head box steps aside). */
.book-head { display: contents; }
.book-cover { grid-column: 1; grid-row: 1 / span 2; }
.book-title { grid-column: 2; grid-row: 1; }
.book-body { grid-column: 2; grid-row: 2; min-width: 0; }
.book-title .page-head { border-bottom: 0; padding-bottom: 0; margin-bottom: var(--s3); }
.book-offers { margin: 0 0 var(--s4); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }   /* the head's one line, under the offers */
/* Previous / next in the list the book came from: a 44px row above the book. */
.book-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s3); min-height: var(--target); margin: 0 0 var(--s4); }
.book-nav a { display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--target); text-decoration: none; }
.book-nav a[rel="next"] { justify-self: end; }
.book-nav .icon { width: 1.125rem; height: 1.125rem; }
.book-nav-where { margin: 0; color: var(--muted); font-size: var(--text-s); text-align: center; }
.book-cover .cover { height: 16rem; }
.book-cover .cover-cloth { width: calc(16rem * 2 / 3); padding: var(--s4) var(--s3) var(--s3) var(--s4); }
.book-cover .cover-title { font-size: 1.4rem; }
.book-cover .cover-author { font-size: 0.9rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4); margin: var(--s4) 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
blockquote { margin: var(--s4) 0; padding: var(--s1) 0 var(--s1) var(--s4); border-left: 3px solid var(--line); font: italic var(--text-m)/1.5 var(--serif); max-width: 55ch; }
.chosen { margin-bottom: var(--s4); }

.matches { list-style: none; margin: var(--s4) 0; padding: 0; }
.matches li { display: flex; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.matches .cover { height: 6rem; flex: none; }
.matches .cover-cloth { width: 4rem; padding: 0.4rem; }
.matches .cover-title { font-size: 0.62rem; }
.matches .cover-author { display: none; }
.match-title { font: 600 var(--text-m)/1.2 var(--serif); margin: 0 0 0.1rem; }
.matches .quiet { margin-bottom: var(--s2); }

.clubs { list-style: none; margin: var(--s4) 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--s4) var(--s6); }
.clubs li { border-top: 1px solid var(--line); padding-top: var(--s3); }
.clubs p { margin-bottom: var(--s1); }
.places { color: var(--muted); }
.reading { display: flex; gap: var(--s4); align-items: flex-end; margin-top: var(--s5); }
.reading h2 { margin-top: 0; }

.providers { display: grid; gap: var(--s2); margin: var(--s4) 0; }
.or { color: var(--muted); margin: var(--s4) 0 var(--s3); }

/* Map: tiles and markers are placed by map.js; the list next to it carries the same books. */
.map-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr); gap: var(--s5); align-items: start; }
.map { position: relative; height: 30rem; overflow: hidden; border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--line); touch-action: none; cursor: grab; }
.map:active { cursor: grabbing; }
.map img.tile { filter: var(--tile-filter); position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; pointer-events: none; }
.map-marker {
  position: absolute; transform: translate(-50%, -50%); min-width: var(--target); height: var(--target); padding: 0 var(--s2);
  border: 3px solid var(--on-fill); border-radius: 2rem; background: var(--accent); color: var(--on-fill); font: 700 var(--text-m) var(--sans); cursor: pointer;
  box-shadow: 0 1px 4px rgb(24 33 31 / 0.5);
}
/* Chosen: not colour alone. The border turns from white to ink and the marker grows. */
.map-marker[aria-pressed="true"] { background: var(--mark); border-color: var(--ink); transform: translate(-50%, -50%) scale(1.2); z-index: 1; }
/* The member's own spot sits just below its point, so a marker for books at the same place stays readable. */
.map-marker.me { margin-top: 2.1rem; display: flex; align-items: center; background: var(--surface); color: var(--ink); border-color: var(--ink); font-size: var(--text-s); }
.map-controls { position: absolute; top: var(--s2); right: var(--s2); display: grid; gap: var(--s1); z-index: 2; }
.map-controls button { width: var(--target); height: var(--target); border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: 700 var(--text-l) var(--sans); cursor: pointer; }
.map-credit { position: absolute; right: 0; bottom: 0; z-index: 2; margin: 0; padding: 0.1rem var(--s2); background: color-mix(in srgb, var(--surface) 90%, transparent); font-size: 0.75rem; }
.map-list li[hidden] { display: none; }

/* The front page: one centred column, the words above the shelf. */
.hero { display: flex; flex-direction: column; align-items: center; gap: var(--s6); margin: var(--s6) auto var(--s7); text-align: center; }
.hero-words { display: flex; flex-direction: column; align-items: center; }
.hero h1 { font-size: var(--text-3xl); line-height: 1.04; letter-spacing: -0.02em; margin-bottom: var(--s4); max-width: 18ch; }
.hero .lede { margin-left: auto; margin-right: auto; }
.hero .actions { justify-content: center; }
.hero .spines { width: min(100%, 30rem); }
/* The button and the free promise are one group: the promise is the button's footnote. */
.hero .actions { margin-bottom: var(--s3); }
.motto { font: italic var(--text-l) var(--serif); color: var(--muted); }
/* The shelf is an illustration under the words, so it stays lighter than them: shorter spines,
   centred, standing on the same 2px shelf line as the covers elsewhere. */
.spines { list-style: none; margin: 0; padding: 0 var(--s4); display: flex; align-items: flex-end; gap: 3px; border-bottom: 2px solid var(--edge); }
.spine {
  flex: 1 1 0; max-width: 3.2rem; min-width: 0; display: flex; justify-content: center; overflow: hidden;
  position: relative;                                   /* for the library label */
  --band: color-mix(in srgb, var(--edge) 75%, transparent);
  border-radius: 3px 3px 1px 1px;
  padding: 1.625rem 0 1.375rem;                         /* the title sits between the bands */
  color: var(--ink); border: 1px solid var(--line); border-bottom: 0;
  background-color: var(--surface);
  /* Two bands at the top, one at the foot, as printed on a book's spine. */
  background-image: linear-gradient(var(--band), var(--band)), linear-gradient(var(--band), var(--band)), linear-gradient(var(--band), var(--band));
  background-size: 100% 1px; background-repeat: no-repeat;
  background-position: 0 0.5625rem, 0 0.8125rem, 0 calc(100% - 0.6875rem);
  /* A rounded spine: a little light on the left, a little shade on the right. */
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--print-paper) 7%, transparent), inset -3px 0 0 color-mix(in srgb, var(--print-ink) 9%, transparent);
}
/* Two neutral tones, picked per title by the tint filter, so blank spines read as separate books.
   background-color, not the background shorthand, which would wipe the bands. */
.spine.tint-1, .spine.tint-3 { background-color: var(--line); --band: color-mix(in srgb, var(--paper) 55%, transparent); }
/* A cloth binding: a block band near the top instead of lines. */
.spine:nth-child(4n+2) { background-image: linear-gradient(var(--band), var(--band)), linear-gradient(var(--band), var(--band));
  background-size: 100% 0.5625rem, 100% 1px; background-position: 0 0.75rem, 0 calc(100% - 0.6875rem); padding-top: 2rem; }
/* A library label near the foot; the title stops above it. */
.spine:nth-child(4n+3) { padding-bottom: 2.625rem; }
.spine:nth-child(4n+3)::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 1.125rem; height: 1.125rem;
  background: color-mix(in srgb, var(--ink) 14%, transparent); border: 1px solid var(--band); border-radius: 1px; }
/* Books are not all the same thickness. */
.spine:nth-child(3n+1) { flex-grow: 1.15; }
.spine:nth-child(3n) { flex-grow: 0.8; }
/* The title: small print on a spine, in ink, on up to two balanced lines (in vertical-rl the width is the
   block axis, so max-width caps the lines). Line clamping doesn't work in vertical text, so the page
   shortens long titles at a word itself; screen readers get the whole title from a hidden copy. */
.spine .spine-name { writing-mode: vertical-rl; font: 400 0.8125rem/1.1 var(--serif); letter-spacing: 0.02em;
  white-space: normal; text-wrap-style: balance; display: block; height: 100%; max-width: calc(2 * 1.1em);
  overflow: hidden; text-overflow: clip; }
.spine-h0 { height: 12rem; }
.spine-h1 { height: 10rem; }
.spine-h2 { height: 13rem; }
.spine-h3 { height: 11rem; }
/* The last book leans back against the row, resting on its bottom corner on the shelf line.
   Its top meets the corner of the book before it (a lean of 7° moves the top about 0.12 of the height). */
.spine:last-child { height: 11.5rem; margin-left: 1.3rem; transform: rotate(-7deg); transform-origin: bottom left; }
/* "Free, always": said where people decide whether to join. Plain words, a little louder than the text around. */
.free { font: 400 var(--text-m) var(--sans); color: var(--ink); margin-top: 0; }   /* regular, in ink: present, not loud */
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--s2) var(--s6); border-top: 1px solid var(--line); max-width: 60rem; margin: 0 auto; }

/* Style guide page */
.swatches { list-style: none; margin: 0 0 var(--s5); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--s4); }
.swatch { height: 4rem; border: 1px solid var(--edge); border-radius: var(--radius); margin-bottom: var(--s1); }
.swatches code, .specimen code { font-size: var(--text-s); }

/* A sheet to print: a neighbour flyer or a swap poster. Black on white whatever the theme. */
.flyer { max-width: 34rem; margin: var(--s5) auto; padding: var(--s6); text-align: center; background: var(--print-paper); color: var(--print-ink); border: 1px solid var(--line); border-radius: var(--radius); }
.flyer h1 { font-size: var(--text-2xl); margin-bottom: var(--s3); }
.flyer p { margin-left: auto; margin-right: auto; }
.flyer-place { font: 600 var(--text-xl) var(--serif); letter-spacing: 0.02em; }
.flyer-lede { font-size: var(--text-l); }
.flyer-code svg { display: block; width: min(100%, 15rem); height: auto; margin: var(--s4) auto; }
.flyer-link { font-size: var(--text-s); overflow-wrap: anywhere; }
.flyer-name { margin-top: var(--s5); font-style: italic; }
@media print {
  .menu, .topbar, .colophon, .skip, .no-print, .notice { display: none !important; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  body { background: var(--print-paper); }
  .flyer { border: 0; margin: 0 auto; padding: 0; }
}

/* The invite page: sections 48px apart, the hint under each heading row. */
.invite-section + .invite-section { margin-top: var(--s7); }
.invite-section .section-head + .quiet { margin-top: calc(var(--s5) * -1 + var(--s3)); }
/* A link and its Copy button as one control: the field fills the column, the button joins its right edge.
   Without scripts the button is hidden and the field keeps all four corners. */
.link-copy { display: flex; margin: var(--s3) 0 var(--s4); }
.link-copy input { flex: 1; min-width: 0; min-height: var(--target); font: var(--text-s)/1.5 var(--sans); }
.js .link-copy input { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.link-copy .button { border-radius: 0 var(--radius) var(--radius) 0; flex: none; }
.send-ways { display: flex; flex-wrap: wrap; gap: var(--s3); margin: 0 0 var(--s2); }
.send-ways + .quiet { margin-top: 0; }
/* Something to copy and pass on: a link or a short text (ui.copy). */
.copy textarea, .copy input { font: var(--text-s)/1.5 var(--sans); }
.copy textarea { min-height: 9rem; }
.copy .actions { margin-top: var(--s2); }

/* The owner's photo of their copy. */
.photo { margin: var(--s4) 0; max-width: 22rem; }
.photo img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.photo figcaption { color: var(--muted); font-size: var(--text-s); margin-top: var(--s1); }

/* Optional parts of a long form, folded away until wanted. */
details.more { margin: 0 0 var(--s5); border-top: 1px solid var(--line); }
details.more > summary { display: flex; align-items: center; min-height: var(--target); font: 600 var(--text-l) var(--serif); cursor: pointer; }
details.more > summary .quiet { font: var(--text-s) var(--sans); margin-left: var(--s3); }
.specimen { border-top: 1px solid var(--line); padding: var(--s4) 0; }

@media (max-width: 48rem) {
  .hero { margin-top: var(--s4); }
  .spine-h0 { height: 9rem; } .spine-h1 { height: 7.5rem; } .spine-h2 { height: 9.75rem; } .spine-h3 { height: 8.25rem; }
  .spine:last-child { height: 8.75rem; margin-left: 1rem; }
  /* Narrow screens: every spine as thick as the next and a little less room at the shelf's ends, so each
     still holds a title on two lines (about 29px) even at 375px. */
  .spines { padding: 0 var(--s2); }
  .spine:nth-child(n) { flex-grow: 1; }
  /* Phones: the head (cover to offers) centred, everything under it left-aligned. */
  .book { display: block; }
  .book-head { display: flex; flex-direction: column; align-items: center; text-align: center; touch-action: pan-y; }
  .book-head .cover { height: auto; width: 10.625rem; }       /* about 170px */
  .book-head .cover-cloth { width: 10.625rem; }
  .book-head .page-head-words { display: flex; flex-direction: column; align-items: center; }
  .book-head .page-head h1 { justify-content: center; }
  .book-head .page-head-row { justify-content: center; }
  .book-head .book-title { align-self: stretch; }               /* the line under the offers spans the column */
  .book-offers { justify-content: center; }
  .book-cover { margin-bottom: var(--s4); }
  .book-nav-where { font-size: var(--text-xs); }
  .pair, .fields { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  .map { height: 22rem; }
  .cards, .result-line + .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }   /* two across on a phone */
}

@media (prefers-reduced-motion: no-preference) {
  .shell { transition: grid-template-columns 0.15s ease; }
  /* The leaning book settles into its lean once, as the page opens: a small wobble, then it tips back and
     rests. It never turns past the resting -7deg or forwards, so it can't cut into its neighbour or the
     shelf line, and it ends exactly where the static rule above leaves it. */
  @keyframes settle {
    0%   { transform: rotate(0deg);    animation-timing-function: ease-in-out; }
    12%  { transform: rotate(-1.4deg); animation-timing-function: ease-in-out; }
    26%  { transform: rotate(-0.3deg); animation-timing-function: ease-in; }
    55%  { transform: rotate(-7deg);   animation-timing-function: ease-out; }
    68%  { transform: rotate(-5.6deg); animation-timing-function: ease-in-out; }
    82%  { transform: rotate(-7deg);   animation-timing-function: ease-out; }
    91%  { transform: rotate(-6.7deg); animation-timing-function: ease-in; }
    100% { transform: rotate(-7deg); }
  }
  .spine:last-child { animation: settle 1.6s 0.4s both; }
}
@media (forced-colors: active) {
  .menu-item[aria-current="page"] { outline: 2px solid; }
  .cover-cloth, .spine { border: 1px solid; }
  select:not([multiple]) { appearance: auto; -webkit-appearance: auto; background-image: none; padding-right: var(--s3); }   /* the native arrow */
}
.tone-paper { background: var(--paper); } .tone-surface { background: var(--surface); } .tone-ink { background: var(--ink); }
.tone-muted { background: var(--muted); } .tone-line { background: var(--line); } .tone-edge { background: var(--edge); }
.tone-accent { background: var(--accent); } .tone-mark { background: var(--mark); } .tone-danger { background: var(--danger); }
