/* Thumbleaf's one stylesheet. Plain CSS, no build step.
 *
 * Every value lives in a custom property in :root, named by role (--color-fg, not --gray-900),
 * so dark mode can later be a token swap. Use the tokens; don't write raw colors or sizes below
 * the token block. Light mode only for now. See docs/app-conventions.md. */

/* --- Fonts ---------------------------------------------------------------------------------- */
/* Self-hosted, OFL (licenses next to the files; sources in internal/web/VENDORED.md). The type is
 * modelled on The Marginalian: a sturdy reading serif (Merriweather), a humanist sans with light
 * headline weights (Source Sans 3), and bold, tracked capitals for labels (Montserrat). The
 * "Fallback" faces are local fonts resized to the web font's metrics, so text doesn't jump when
 * the web font arrives. */

@font-face {
  font-family: "Merriweather"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/merriweather-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Merriweather"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/merriweather-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Merriweather"; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url("../fonts/merriweather-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Merriweather"; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url("../fonts/merriweather-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("../fonts/source-sans-3-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 200 700; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/montserrat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/montserrat-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Merriweather Fallback"; font-style: normal; src: local("Georgia");
  size-adjust: 107.63%; ascent-override: 91.43%; descent-override: 25.37%; line-gap-override: 0%;
}
@font-face {
  font-family: "Merriweather Fallback"; font-style: italic; src: local("Georgia Italic"), local("Georgia-Italic");
  size-adjust: 99.64%; ascent-override: 98.75%; descent-override: 27.40%; line-gap-override: 0%;
}
@font-face {
  font-family: "Source Sans 3 Fallback"; src: local("Arial"), local("ArialMT");
  size-adjust: 88.71%; ascent-override: 115.43%; descent-override: 45.09%; line-gap-override: 0%;
}
@font-face {
  font-family: "Montserrat Fallback"; font-weight: 700; src: local("Arial Bold"), local("Arial-BoldMT");
  size-adjust: 110.09%; ascent-override: 87.93%; descent-override: 22.80%; line-gap-override: 0%;
}

/* --- Tokens --------------------------------------------------------------------------------- */

:root {
  /* Palette: "marginalia red". Neutral off-white paper and true grays (deliberately not the warm
   * cream and tan of Goodreads), with one red-pencil accent, the traditional color of notes in
   * the margin. */
  --color-bg: #fcfcfb;
  --color-surface: #f5f5f3;
  --color-surface-2: #efefec;
  --color-surface-3: #e5e5e1;

  /* Text. --color-fg-muted is the lightest gray that still reads as body text (5.3:1 on the
   * background); --color-placeholder (3.3:1) is for placeholders and decoration only. */
  --color-fg: #141414;
  --color-fg-2: #363636;
  --color-fg-3: #555555;
  --color-fg-muted: #696969;
  --color-placeholder: #8c8c8c;

  --color-border: #e4e4e0;
  --color-border-strong: #d2d2cd;

  /* The accent, a red-pencil red: primary buttons (white text, 5.3:1), link underlines and the
   * current page in the nav (5.2:1 on the background). It's dark enough to mark things on the
   * page directly, so --color-accent-line is the same red. */
  --color-accent: #c23a2b;
  --color-accent-hover: #a82f22;
  --color-accent-line: #c23a2b;
  --color-on-accent: #ffffff;

  --color-focus: #1d4ed8;
  /* Rating stars and an active upvote: graphics, which need 3:1. The accent red. */
  --color-rating: var(--color-accent-line);
  /* The logo's leaf and full stop. Also hard-coded in static/img/favicon.svg. */
  --color-logo: var(--color-accent-line);
  --color-error: #e34948;

  /* Supporting colors, used sparingly: the backgrounds behind avatar initials now, tags and
   * genres later. Cool and neutral, plus a rose that sits with the red; --color-fg on each is at
   * least 6.5:1. */
  --color-sage: #a8bfa3;
  --color-sky: #9fbad8;
  --color-lavender: #bdb5da;
  --color-rose: #e2b0ae;
  --color-stone: #c8c7c1;
  --color-teal: #97c2bd;
  --color-slate: #8e9aae;

  /* Type, after The Marginalian: reading text is a serif at 18px with very open leading;
   * headings are a light sans; labels are small bold capitals. Phone sizes are at the bottom. */
  --font-sans: "Source Sans 3", "Source Sans 3 Fallback", system-ui, sans-serif;  /* UI, headings */
  --font-serif: "Merriweather", "Merriweather Fallback", Georgia, serif;          /* reading text */
  --font-label: "Montserrat", "Montserrat Fallback", Arial, sans-serif;           /* .label */
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;               /* code */
  --text-body: 1rem;          /* UI text: navigation, buttons, forms */
  --text-small: 0.9375rem;    /* bylines and metadata */
  --text-read: 1.125rem;      /* reading text: ledes and longer prose */
  /* Reviews follow the NYTimes homepage: the tl;dr at their 16px/22px summary size, the full
   * review smaller, at their 14px desktop summary size with a little more leading for paragraphs. */
  --text-tldr: 1rem;
  --leading-tldr: 1.375;
  --text-review: 0.875rem;
  --leading-review: 1.5;
  --text-label: 0.75rem;
  --text-h1: 2.25rem;
  --text-h2: 1.25rem;
  --text-h3: 1.25rem;         /* book titles */
  --text-title: 1.75rem;      /* a book's title under a page's h1 (the review form) */
  --leading-body: 1.5;
  --leading-read: 1.825;
  --leading-h1: 1.1;
  --leading-heading: 1.35;
  --weight-h1: 200;           /* extra-light, like The Marginalian's headlines */
  --tracking-label: 0.1em;

  /* Spacing in 4px steps. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --control-height: 36px;
  --control-height-large: 44px;
  --shadow-popup: 0 4px 24px rgb(0 0 0 / 5%);
  --shadow-stacked: 3px 0 6px rgb(0 0 0 / 14%); /* a cover's edge over the one behind it (.collection-covers) */
  --transition-fast: 150ms ease;
  --transition-slow: 300ms ease;

  --width-page: 64rem;
  --width-text: 40rem;
  --width-form: 28rem;   /* one-field forms: logging in, signing up */
  --width-feed: 44rem;
  --width-sidebar: 16rem;
}

/* --- Base ----------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-weight: 400;
  line-height: var(--leading-heading);
  text-wrap: balance;
  margin: 0 0 var(--space-4);
}
h1 { font-size: var(--text-h1); font-weight: var(--weight-h1); line-height: var(--leading-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

/* Reading text. Use .reading for prose meant to be read rather than scanned. Reviews have their
 * own, smaller sizes (.review-tldr, .review-body). */
.reading {
  font-family: var(--font-serif);
  font-size: var(--text-read);
  line-height: var(--leading-read);
}

p { margin: 0 0 var(--space-4); text-wrap: pretty; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--transition-fast);
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code { font-family: var(--font-mono); font-size: 0.9em; }

blockquote, .serif {
  font-family: var(--font-serif);
}

img { max-width: 100%; }

/* Small uppercase labels, and section headings that work as labels. */
.label {
  font-family: var(--font-label);
  font-size: var(--text-label);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-fg-muted);
}

.muted { color: var(--color-fg-muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* --- Layout --------------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--width-page);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-fg);
  color: var(--color-bg);
  border-radius: var(--radius-md);
  z-index: 10;
}
.skip-link:focus { top: var(--space-4); }

.site-header {
  border-bottom: 1px solid var(--color-border);
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-8);
  min-height: 64px;
  padding-block: var(--space-3);
}
/* The logo: the mark (siteMark in layout.templ), then the name with a red full stop, round like
 * the rating dots. The stop is drawn, not typed, so screen readers read only "Thumbleaf". */
.site-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-mark { flex: none; width: 1.75rem; height: 1.75rem; }
.site-mark-leaf { fill: var(--color-logo); }
.site-mark-rib { stroke: var(--color-bg); }
.site-name-text::after {
  content: "";
  display: inline-block;
  width: 0.16em;
  height: 0.16em;
  margin-left: 0.04em;
  border-radius: 50%;
  background: var(--color-logo);
}

.site-nav ul {
  display: flex;
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  color: var(--color-fg-3);
  text-decoration: none;
}
.site-nav a:hover { color: var(--color-fg); }
.site-nav a[aria-current] {
  color: var(--color-fg);
  text-decoration: underline;
  text-decoration-color: var(--color-accent-line);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.4em;
}

.user-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-small);
}
.user-nav form { margin: 0; }
.user-name { color: var(--color-fg-2); }

/* Phones: logged in, the site name and your account share the first row, and the nav gets a row
 * of its own, rather than wrapping in source order. Your avatar stands for you there: the name
 * would push "Log out" onto a third row (it's still read out). Logged out, the site name has the
 * first row to itself and "Log in", drawn like a nav link, ends the nav's row. */
@media (max-width: 600px) {
  .site-header .container { column-gap: var(--space-4); }
  .site-nav { order: 1; flex-basis: 100%; }
  .user-name-text {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .site-header .container:has(.user-login) { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .site-header .container:has(.user-login) .site-name { grid-column: 1 / -1; justify-self: start; }
  .site-header .container:has(.user-login) .site-nav { order: 0; }
}

main {
  flex: 1;
  padding-block: var(--space-12) var(--space-16);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-6);
  color: var(--color-fg-muted);
  font-size: var(--text-small);
}

.footer-link { margin-left: var(--space-4); }

.prose { max-width: var(--width-text); }
.privacy h2 { margin-top: var(--space-8); }

/* --- Controls ------------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-fg);
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
.button:hover { background: var(--color-surface-3); }

.button-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.button-primary:hover, .button-primary:active {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.button-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--color-fg-3);
}
.button-quiet:hover { background: var(--color-surface-2); color: var(--color-fg); }

.button-large {
  height: var(--control-height-large);
  padding: 0 var(--space-6);
  font-size: 1.0625rem;
}

.field { display: grid; gap: var(--space-2); }
.field label { font-weight: 600; font-size: var(--text-small); }

.input {
  height: var(--control-height);
  width: 100%;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-fg);
  font: inherit;
  transition: border-color var(--transition-fast);
}
.input::placeholder { color: var(--color-placeholder); }
.input:hover { border-color: var(--color-placeholder); }
.input:focus-visible { border-color: var(--color-focus); }
.input-large { height: var(--control-height-large); padding: 0 var(--space-4); }

/* --- Pages ---------------------------------------------------------------------------------- */

/* The landing blurb at the top of the home page: a raised panel, set apart from the reviews
 * below it. Its text stays at reading width. */
.hero {
  padding: var(--space-12);
  margin-bottom: var(--space-16);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}
.hero > * { max-width: var(--width-text); }
.hero h1 { margin-bottom: var(--space-6); }
.hero p:last-child { margin-bottom: 0; }
.lede { color: var(--color-fg-2); margin-bottom: var(--space-8); }

.notice {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-fg-2);
}

.search-form { max-width: var(--width-text); margin-bottom: var(--space-8); }
.search-row { display: flex; gap: var(--space-2); }
.search-row .input { flex: 1; min-width: 0; } /* inputs won't shrink below their default size otherwise */
.search-row .button { flex: none; }

/* While HTMX fetches new results, the old ones fade a little. */
.search-results { transition: opacity var(--transition-fast); }
.search-results.htmx-request { opacity: 0.6; }
/* A query naming a genre links to its page, above the books (SearchResults). */
.search-genre { margin: 0 0 var(--space-4); font-weight: 600; }

/* Result list: one row per book, quiet dividers instead of cards with shadows. */
.results {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  max-width: var(--width-text);
  border-top: 1px solid var(--color-border);
}
.result {
  display: flex;
  gap: var(--space-4);
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.cover {
  flex: none;
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
}
/* Links to book pages (bookTitle and bookCover in internal/views/book.templ): titles get a quiet
 * underline that turns red on hover, like reviewer names; a cover's link wraps it without
 * changing the layout around it, and the cover lifts on hover like a favorite book's (the rule is
 * with .favorite-link below). */
.book-link { text-decoration-color: var(--color-border-strong); }
.book-link:hover { text-decoration-color: var(--color-accent-line); }
.cover-link { display: block; flex: none; align-self: flex-start; line-height: 0; text-decoration: none; }
.cover-link > .cover { display: block; }
/* A book with no cover (coverBlank): a plain jacket in the site's palette, paper gray with a red
 * spine, the title in the reading serif and the first author below it in gray. The cover is a
 * container, so the text is sized to it (cqi: hundredths of its width), never below 7.5px; long
 * words hyphenate where the browser can, and break only when a word can't fit. The author drops away on small covers, and the title
 * only on the tiniest (profile sidebars, 36px), where the title is beside the cover anyway. Links
 * around a cover have no underline, which would otherwise run through the text. */
.cover.cover-blank {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: var(--color-fg);
  background: var(--color-surface-2);
  border-left: 3px solid var(--color-accent-line);
  line-height: 1.15;
}
.cover-blank-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  margin: 9cqi 6cqi 0;
  font-family: var(--font-serif);
  font-size: max(8px, 14cqi);
  font-weight: 700;
  overflow-wrap: break-word;
  hyphens: auto;
}
.cover-blank-author { margin: 0 6cqi 9cqi; font-size: 9.5cqi; color: var(--color-fg-3); }
@container (width < 88px) { .cover-blank-author { display: none; } }
/* A phone's review list (48px): a touch smaller, with narrower margins, so a word like "Catwoman"
 * fits on a line. */
@container (width < 60px) { .cover-blank-title { margin-inline: 4cqi 3cqi; font-size: 7.5px; } }
@container (width < 44px) { .cover-blank-title { display: none; } }
.result-title { font-size: var(--text-h3); line-height: 1.3; margin: 0 0 var(--space-1); }
.result-subtitle { color: var(--color-fg-2); margin: 0 0 var(--space-1); }
.result-meta { color: var(--color-fg-3); font-size: var(--text-small); margin: 0; }

.dev-users { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.dev-users form { display: flex; align-items: center; gap: var(--space-3); margin: 0; }

/* Avatars: round, at a fixed size set by an .avatar-N class (sizes are listed in
 * internal/views/avatar.templ). Without an uploaded image, the initials sit on one of the
 * supporting colors; --color-fg on each of them is at least 6.5:1. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface-3);
  outline: 1px solid rgb(0 0 0 / 6%); /* a hairline edge, so light avatars don't melt into the page */
  outline-offset: -1px;
  color: var(--color-fg);
  font-size: calc(var(--avatar-size) * 0.4);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar-28 { --avatar-size: 28px; }
.avatar-32 { --avatar-size: 32px; }
.avatar-96 { --avatar-size: 96px; }
.avatar-tone-0 { background: var(--color-sage); }
.avatar-tone-1 { background: var(--color-sky); }
.avatar-tone-2 { background: var(--color-lavender); }
.avatar-tone-3 { background: var(--color-rose); }
.avatar-tone-4 { background: var(--color-stone); }
.avatar-tone-5 { background: var(--color-teal); }
.avatar-tone-6 { background: var(--color-slate); }

.user-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none; /* a link to your profile */
}
.user-name:hover { color: var(--color-fg); }

/* Lists of reviews. Each row is the cover, then the review: book, byline, the tl;dr in the reading
 * serif, and the full review behind a <details> toggle. Rows without a cover (the front page, a
 * book page) are one column (.review-item-no-cover). */
.front-page { max-width: var(--width-feed); }

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--color-border);
}
.review-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: var(--space-4);
  padding-block: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
/* On the home page and a profile's reviews, reviews are separated by space alone, without rules. */
.front-page .review-item,
.profile-reviews .review-item { border-bottom: 0; }
.cover-large { width: 64px; height: 96px; }

.review-book { font-size: var(--text-h3); line-height: 1.3; margin: 0; }
.review-book-meta { font-size: var(--text-small); color: var(--color-fg-3); margin: 0 0 var(--space-2); }
.review-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
  font-size: var(--text-small);
  color: var(--color-fg-3);
  margin: 0 0 var(--space-3);
}
.review-byline a { text-decoration-color: var(--color-border-strong); }
.review-byline a:hover { text-decoration-color: var(--color-accent-line); }
/* An author's name links to their page (authorLinks). Under a book's linked title it has no
 * underline until hovered, so a book shows one underline, not two. On the book page, where the
 * title isn't a link, it keeps a quiet one. */
.author-link { text-decoration-line: none; }
.author-link:hover { text-decoration-line: underline; }
.book-page .book-authors .author-link { text-decoration-line: underline; text-decoration-color: var(--color-border-strong); }
.book-page .book-authors .author-link:hover { text-decoration-color: var(--color-accent-line); }
/* A rating as dots (ratingDots in review.templ), on reviews and shelves: the 404 page's dot, one
 * per whole star; a half star is the dot's outline with its left half filled. */
.rating-dots { display: inline-flex; align-items: center; gap: var(--space-1); }
.rating-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error);
}
.rating-dot-half {
  background: linear-gradient(to right, var(--color-error) 50%, transparent 50%);
  box-shadow: inset 0 0 0 1px var(--color-error);
}
.review-tldr {
  font-family: var(--font-serif);
  font-size: var(--text-tldr);
  line-height: var(--leading-tldr);
  margin: 0 0 var(--space-3);
}
/* The tl;dr links to the review's own page (except on that page): the whole paragraph is the link,
 * read as text, underlined on hover. */
.review-tldr-link { display: block; color: inherit; text-decoration: none; }
.review-tldr-link:hover {
  text-decoration: underline 1px var(--color-accent-line);
  text-underline-offset: 0.2em;
}
/* "Edited" (editedMark): a quiet line under the tl;dr, above "Read the full review". */
.review-edited {
  font-size: var(--text-small);
  color: var(--color-fg-muted);
  margin: calc(-1 * var(--space-2)) 0 var(--space-3);
}
/* The review's comparisons: shown with the full review when it's expanded, but as their own
 * paragraph after it (outside its indented block), in the tl;dr's type. Titles are links,
 * underlined in the star color. */
.review-comps {
  font-family: var(--font-serif);
  font-size: var(--text-tldr);
  line-height: var(--leading-tldr);
  margin: calc(var(--space-6) + var(--space-1)) 0 0; /* 28px */
}
.review-comps a { text-decoration-color: var(--color-rating); }
.review-comps cite { font-style: italic; }

.review-full summary,
.review-open,
.description-more summary,
.review-close {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-fg-3);
  cursor: pointer;
  list-style: none;
}
.review-full summary::-webkit-details-marker,
.description-more summary::-webkit-details-marker { display: none; }
.review-full summary::before,
.review-open::before,
.description-more summary::before,
.review-close::before {
  content: "";
  border-left: 5px solid currentColor;
  border-block: 4px solid transparent;
  transition: transform var(--transition-fast);
}
.review-full summary:hover,
.review-open:hover,
.description-more summary:hover,
.review-close:hover { color: var(--color-fg); }
/* "Read the full review" in a list is a link that loads the review (reviewItem), drawn as the
 * closed summary it turns into. */
.review-open { text-decoration: none; }
.review-full[open] summary::before { transform: rotate(90deg); }
.review-body {
  font-family: var(--font-serif);
  font-size: var(--text-review);
  line-height: var(--leading-review);
  color: var(--color-fg-2);
  margin-top: var(--space-3);
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-border);
}
.review-body p:last-child { margin-bottom: 0; }
/* On the review's own page the full review isn't opened from anything (reviewItem), so it lines
 * up with the tl;dr rather than being set off; the tl;dr is set larger, as the review's headline,
 * and space separates the two. */
.review-main > .review-body { padding-left: 0; border-left: 0; margin-top: var(--space-6); }
.review-page .review-tldr { font-size: var(--text-h3); }
/* "Close the full review" at the bottom of an expanded review, styled like the summary that opened
 * it with the marker pointing up. Only with JavaScript (reviews.js adds .js), since closing a
 * <details> from inside takes a script; without it no dead button shows. */
.review-close {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  margin-top: var(--space-4);
}
.review-close::before { transform: rotate(-90deg); }
html:not(.js) .review-close { display: none; }

/* The upvote (UpvoteControl) sits in the review's top-right corner. The review's first line (the
 * book's title, or the byline on a book page) keeps clear of it; the lines below run full width. */
.review-main { position: relative; }
.helpful { position: absolute; top: 0; right: 0; margin: 0; }
.review-main:has(> .helpful) > :first-child { padding-right: calc(28px + var(--space-2)); }
.review-byline:first-child ~ .helpful { top: -3px; } /* centered on the byline, which is shorter than a title */

/* The review's action row: "Read the full review" on the left and, on the viewer's own review,
 * "Edit" and "Delete" on the right, positioned over the row so that, when the review is expanded,
 * its text still spans the full width underneath. */
.review-actions { position: relative; }
.review-actions .review-full summary,
.review-actions .review-open { margin-right: 120px; } /* keep clear of Edit and Delete */
/* On the review's own page the full review sits above the row, so Edit and Delete have the row to
 * themselves, on the right. */
.review-actions-standalone { display: flex; justify-content: flex-end; margin-top: var(--space-4); }
.review-actions-standalone .own-review-actions { position: static; }
.own-review-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: var(--space-4);
  margin: 0;
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 28px; /* so it lines up with "Read the full review" */
}
/* The arrow alone, in a 28px square that shades on hover. */
.helpful-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-fg-3);
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.helpful-button:hover { color: var(--color-fg); background: var(--color-surface-2); }
.helpful-button .upvote-arrow { color: var(--color-placeholder); transition: color var(--transition-fast); }
.helpful-button:hover .upvote-arrow { color: var(--color-fg-3); }
/* --color-rating means "you marked this helpful"; hover only darkens. */
.helpful-button[aria-pressed="true"] { color: var(--color-fg); }
.helpful-button[aria-pressed="true"] .upvote-arrow { color: var(--color-rating); }
.upvote-arrow { fill: currentColor; flex: none; }

@media (max-width: 600px) {
  :root {
    --text-read: 1rem;
    --text-review: 0.9375rem;
    --text-h1: 1.75rem;
    --text-h3: 1.125rem;
  }
  .review-item { grid-template-columns: 48px minmax(0, 1fr); gap: var(--space-3); }
  .hero { padding: var(--space-8) var(--space-6); margin-bottom: var(--space-12); }
  .cover-large { width: 48px; height: 72px; }
}

/* Main column and sidebar (the home page), after The Marginalian's sidebar: a narrow column behind
 * a hairline rule that runs the height of the content, with large, light, lowercase module
 * headings. Which side it's on is set by SidebarSide in internal/views/sidebar.templ. */
.with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--width-sidebar);
  gap: var(--space-8);
}
.sidebar-left { grid-template-columns: var(--width-sidebar) minmax(0, 1fr); }
.sidebar-left .sidebar {
  order: -1;
  padding-right: var(--space-8);
  border-right: 1px solid var(--color-border);
}
.sidebar-right .sidebar {
  padding-left: var(--space-8);
  border-left: 1px solid var(--color-border);
}

.sidebar-module + .sidebar-module { margin-top: var(--space-12); }
.sidebar-heading {
  font-size: 1.75rem;
  font-weight: var(--weight-h1);
  line-height: 1.1;
  text-transform: lowercase;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-placeholder);
}
/* On profiles, the shelves' headings ("reading", "read", "want to read") are the red of the rating
 * dots (13 Nov 2026); their rules stay gray. It's 3.75:1 on the background: enough for text this
 * large (AA's large-text 3:1), not for body text. */
.profile-sidebar .sidebar-heading { color: var(--color-error); }
.sidebar-text {
  font-family: var(--font-serif);
  font-size: var(--text-review);
  line-height: 1.6;
  color: var(--color-fg-2);
  margin: 0;
}

.sidebar-books {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}
.sidebar-book {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
}
.cover-small { width: 36px; height: 54px; }
.sidebar-book-title { font-size: var(--text-body); line-height: 1.3; margin: 0; }
.sidebar-book-meta { font-size: 0.875rem; color: var(--color-fg-3); margin: 0 0 var(--space-1); }
.sidebar-book .label { margin: 0; }

/* Collections, in the sidebar and on the Collections page: each shows the covers of its first
 * books fanned like books on a table, the first on top, overlapping by --overlap. */
.collection-covers {
  --overlap: 16px;
  display: flex;
  flex: none;
  align-self: flex-start;
  line-height: 0;
  text-decoration: none;
}
.collection-covers .cover { position: relative; box-shadow: var(--shadow-stacked); }
.collection-covers .cover + .cover { margin-left: calc(-1 * var(--overlap)); }
.collection-covers .cover:nth-child(1) { z-index: 5; }
.collection-covers .cover:nth-child(2) { z-index: 4; }
.collection-covers .cover:nth-child(3) { z-index: 3; }
.collection-covers .cover:nth-child(4) { z-index: 2; }
.sidebar-collections {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-6);
}
.sidebar-collections .collection-covers { --overlap: 20px; margin-bottom: var(--space-2); }
.sidebar-collections .label { margin: var(--space-1) 0 0; }

/* Narrow screens: one column, with the sidebar after the main column. */
@media (max-width: 900px) {
  .with-sidebar, .sidebar-left { grid-template-columns: minmax(0, 1fr); gap: var(--space-12); }
  /* No rule above the sidebar: its first heading has its own. */
  .sidebar-left .sidebar, .sidebar-right .sidebar {
    order: 0;
    padding: 0;
    border: 0;
  }
}

/* Profile page: the name and avatar, then the reviews (with recommendations above them) next to
 * the reading and read shelves in the sidebar. With no shelves to show, the main column stands
 * alone at feed width. */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding-bottom: var(--space-8);
  margin-bottom: var(--space-12);
  border-bottom: 1px solid var(--color-border);
}
/* The name block shrinks next to the avatar rather than wrapping under it; the favorites wrap. */
.profile-names { flex: 1 1 16rem; min-width: 0; }
.profile-name { margin: 0 0 var(--space-1); }
.profile-facts { margin: 0; }
.profile-settings { margin: var(--space-2) 0 0; font-size: var(--text-small); }

/* Following someone: "Follow" under the name, where your own profile has Settings; once you do,
 * "Following" with "Unfollow" beside it, at the button's height so the page doesn't move. In
 * settings, a row per person you follow. */
.follow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-3);
  min-height: var(--control-height);
  margin: var(--space-3) 0 0;
  font-size: var(--text-small);
}
.follow-state { color: var(--color-fg-2); font-weight: 600; }
.follow-state::before { content: "✓"; margin-right: var(--space-1); }
.follow .link-button { color: var(--color-fg-3); }
.followed-users { list-style: none; margin: var(--space-6) 0 0; padding: 0; }
.followed-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-2);
}
.followed-user + .followed-user { border-top: 1px solid var(--color-border); }
.followed-user-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.followed-user .follow { margin: 0; }
.followed-none { margin: var(--space-4) 0 0; }
.favorites-empty { max-width: var(--width-sidebar); }
.favorites-empty p { margin: 0; font-size: var(--text-small); }
.profile-main { max-width: var(--width-feed); }

.profile-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}
.profile-section-head h2 { margin: 0; color: var(--color-fg-3); }

.shelf-rating { display: flex; margin: 0; }
.shelf-page-books .shelf-rating { margin-top: var(--space-1); }
.see-all { margin: var(--space-6) 0 0; }
.sidebar-module .see-all { margin-top: var(--space-4); }
.shelf-page-books { max-width: none; }
.author-page .book-description { max-width: var(--width-text); margin: 0 0 var(--space-6); } /* the bio, above the book count */
.author-page .book-description:has(+ .text-credit) { margin-bottom: var(--space-2); }
/* The credit under Wikipedia text: "From Wikipedia · CC BY-SA 4.0 · edited". */
.text-credit { font-size: var(--text-label); color: var(--color-fg-muted); margin: 0 0 var(--space-6); }
.text-credit a { color: inherit; text-decoration-color: var(--color-border-strong); }
.text-credit a:hover { text-decoration-color: var(--color-accent-line); }

/* A page that belongs to a profile, such as a status shelf's: a link back to the profile above
 * the heading. */
.subpage-header { margin-bottom: var(--space-8); }
.subpage-back { font-size: var(--text-small); color: var(--color-fg-3); margin: 0 0 var(--space-3); }
.subpage-back a { text-decoration-color: var(--color-border-strong); }
.subpage-back a:hover { text-decoration-color: var(--color-accent-line); }
.subpage-header h1 { margin-bottom: var(--space-3); }
.subpage-header .profile-section-head { margin-bottom: 0; }
.subpage-header .label { margin: 0; }

/* "More": the last item of a list, replaced by the next items (HTMX) or a link to the page with
 * more of them. */
.more-item { padding-top: var(--space-6); transition: opacity var(--transition-fast); }
.sidebar-books .more-item { padding-top: 0; }
.more-item.htmx-request { opacity: 0.6; }

/* The owner's show/hide control on each shelf. A hidden shelf's books are dimmed for its owner,
 * since nobody else sees them. */
.shelf-visibility {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-fg-muted);
}
.sidebar-module .shelf-visibility { margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
.shelf-visibility-private .shelf-visibility-state { color: var(--color-fg-2); font-weight: 600; }
.sidebar-module:has(.shelf-visibility-private) .sidebar-books { opacity: 0.55; }
.shelf-hint { margin: 0; }

/* A button that looks like a link, for small inline actions. */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-fg);
  font: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button:hover { text-decoration-thickness: 2px; }

/* Favorite books: up to three covers on the right of the profile header. Below 600px they move
 * under the name. */
.profile-header { flex-wrap: wrap; }
.favorites-header { margin-left: auto; }
.favorites-header h2 { margin: 0 0 var(--space-2); }
.favorites-row { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-3); }
.favorite-cover-small { width: 64px; height: 96px; }
/* Each cover links to its book: it lifts a little on hover, like every linked cover. */
.favorite-link { display: block; border-radius: var(--radius-sm); text-decoration: none; }
.favorite-link .cover,
.cover-link .cover,
.collection-covers .cover { transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.favorite-link:hover .cover,
.cover-link:hover .cover { transform: translateY(-2px); box-shadow: var(--shadow-popup); }
.collection-covers:hover .cover { transform: translateY(-2px); }

@media (max-width: 600px) {
  .favorites-header { margin-left: 0; width: 100%; }
  .profile-header { gap: var(--space-4); }
  .profile-header .avatar { --avatar-size: 64px; }
}

/* The Collections page: a card per collection (its fanned covers, title, description and size) in
 * a grid across the page's full width. A collection's page and an author's page show their books
 * as a .book-grid across the full width too, each a large cover that fills its column
 * (.cover-fluid), with the title and a line or two under it. */
.collection-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-8);
}
.collection-card .collection-covers { --overlap: 28px; margin-bottom: var(--space-3); }
.collection-card-title { font-size: var(--text-h3); line-height: 1.3; margin: 0 0 var(--space-1); }
.collection-card-description { color: var(--color-fg-2); font-size: var(--text-small); margin: 0 0 var(--space-2); }
.collection-card .label { margin: 0; }
.collection-page .lede { max-width: var(--width-text); margin-bottom: var(--space-4); }
.book-grid {
  --shelf-min: 13rem;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--shelf-min), 1fr));
  gap: var(--space-12) var(--space-8);
}
.book-grid-item { min-width: 0; }
.book-grid-item .cover-link { align-self: auto; margin-bottom: var(--space-3); }
.cover.cover-fluid { width: 100%; height: auto; aspect-ratio: 2 / 3; }
.book-grid-title { font-size: var(--text-body); font-weight: 600; line-height: 1.3; margin: 0 0 var(--space-1); }
.book-grid-meta { font-size: var(--text-small); color: var(--color-fg-3); margin: 0; }
.book-grid > .more-item { grid-column: 1 / -1; padding-top: 0; } /* "More books" on a row of its own */
.collection-note { margin: var(--space-2) 0 0; color: var(--color-accent-line); }
@media (max-width: 600px) {
  .collection-card .collection-covers { --overlap: 20px; }
  .book-grid { --shelf-min: 8rem; gap: var(--space-8) var(--space-4); }
}

/* Book page: the cover next to the title, subtitle, authors and facts; the description; then the
 * reviews, which leave out the book (.review-item-no-cover). One column at feed width. */
.book-page { max-width: var(--width-feed); }
.book-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}
/* The shelf buttons, under the description and above the reviews. */
.book-page > .book-actions { margin: 0 0 var(--space-12); }
.book-page > .book-actions:not(:has(*)) { display: none; } /* no buttons (a review you didn't finish): no empty row */
.book-description:has(+ .book-actions > *) { margin-bottom: var(--space-8); }
.cover-book { width: 128px; height: 192px; }
.book-facts { flex: 1; min-width: 0; } /* fills the row beside the cover, so it never wraps under it */
.book-title { margin: 0 0 var(--space-2); }
.book-subtitle { font-size: var(--text-h3); color: var(--color-fg-2); margin: 0 0 var(--space-3); }
.book-authors { font-size: var(--text-read); margin: 0 0 var(--space-3); }
.book-year { color: var(--color-fg-3); }
.book-genres { font-size: var(--text-small); color: var(--color-fg-3); margin: 0 0 var(--space-3); }
/* "Suggest a correction", under the description: quiet, since few readers need it. */
.book-correction { font-size: var(--text-label); color: var(--color-fg-muted); margin: 0 0 var(--space-12); }
.book-correction:has(+ .book-actions > *) { margin-bottom: var(--space-8); }
.book-description:has(+ .book-correction) { margin-bottom: var(--space-3); }
.book-correction a { color: inherit; text-decoration-color: var(--color-border-strong); }
.book-correction a:hover { text-decoration-color: var(--color-accent-line); }
.book-meta { color: var(--color-fg-3); margin: 0; }
.book-meta + .book-meta { margin-top: var(--space-1); }
.book-description {
  font-family: var(--font-serif);
  font-size: var(--text-small); /* the size of "Read the full review" (13 Nov 2026) */
  line-height: var(--leading-review);
  color: var(--color-fg-2);
  margin-bottom: var(--space-12);
  overflow-wrap: anywhere; /* descriptions can hold long bare URLs */
}
.book-description p:last-child { margin-bottom: 0; }
.description-more summary { font-family: var(--font-sans); margin-top: var(--space-1); }
/* Open, "More" moves below the text it showed and points up, like "Close the full review". A
 * browser that can't lay out details as flex keeps it above the text. */
.description-more[open] { display: flex; flex-direction: column; }
.description-more[open] summary {
  order: 1;
  align-self: flex-start;
  margin-top: calc(var(--space-4) + var(--space-1)); /* the closed gap: a paragraph's margin, plus 4px */
}
.description-more[open] summary::before { transform: rotate(-90deg); }
.review-item-no-cover { grid-template-columns: minmax(0, 1fr); }

/* The front page's Popular and New tabs, the book page's Print and Audiobook tabs and the
 * profile's All Reviews and Recommendations tabs: links in a
 * row on a hairline, the current one marked like the current page in the site nav. The rule under
 * them is the review list's top border. */
.review-tabs {
  display: flex;
  gap: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.review-tab {
  padding-bottom: var(--space-3);
  margin-bottom: -1px; /* the current tab's line sits on the rule */
  border-bottom: 2px solid transparent;
  color: var(--color-fg-3);
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: none;
}
.review-tab:hover { color: var(--color-fg); }
/* "page" on the tab's own page; "true" on a page under it (a genre's page, under Genres). */
.review-tab[aria-current] { color: var(--color-fg); border-bottom-color: var(--color-accent-line); }
.review-tabs + .review-list { border-top: 0; }
.review-tabs-empty,
.feed-end { margin: var(--space-6) 0 0; }
.book-reviews.htmx-request,
.profile-reviews.htmx-request,
.front-page.htmx-request { opacity: 0.6; transition: opacity var(--transition-fast); }
/* The front page's lists have no rule above them: the tabs or a genre's bar sit over them. */
.front-page .review-list { border-top: 0; }

/* A genre's page (genreBar in home.templ): the links to every genre, then the genre's name with its
 * Popular and New, laid out like a section head on the Genres tab. */
.genre-page-head { margin-top: var(--space-6); }
.genre-sorts { display: flex; gap: var(--space-4); font-size: var(--text-small); font-weight: 600; }
.genre-sorts a { color: var(--color-fg-3); text-decoration: none; }
.genre-sorts a:hover { color: var(--color-fg); }
.genre-sorts a[aria-current] {
  color: var(--color-fg);
  text-decoration: underline 2px var(--color-accent-line);
  text-underline-offset: 0.4em;
}

/* A review's own page (ReviewPageBody): the review at feed width, with no rules around it. */
.review-page { max-width: var(--width-feed); }
.review-page .review-list { border-top: 0; }
.review-page .review-item { border-bottom: 0; }

/* A labelled section head under the front page's tabs: a genre's section or page. The label on
 * the left, a link or two on the right. */
.feed-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}
.feed-section-head .label { margin: 0; color: var(--color-fg-3); }

/* The Genres tab (genreIndex): links to every genre, then a section per genre. */
.genre-section { margin-top: var(--space-8); }
.genre-section + .genre-section { margin-top: var(--space-12); }
.genre-more { font-size: var(--text-small); font-weight: 600; }
.genre-all { margin-top: var(--space-6); }
.genre-note { font-size: var(--text-small); color: var(--color-fg-muted); margin: var(--space-3) 0 0; }
.genre-all a[aria-current] { font-weight: 600; text-decoration-thickness: 2px; }
.genre-all ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The viewer's buttons under the book's facts: "Want to read", "Reading" and "Have read". A pressed button
 * (the book is on that shelf) is filled with the accent and checked. */
.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.book-action { margin: 0; }

/* "Write a review" / "Edit your review", on its own row above the shelf buttons. Those add the book
 * to your lists; this writes about it, so it's outlined in the red-pencil accent with a pencil,
 * unlike the shelf buttons (and unlike a pressed one, which is filled red). */
.book-review-action { margin-top: var(--space-4); }
.button-review {
  gap: var(--space-2);
  border-color: var(--color-accent-line);
  background: var(--color-bg);
  color: var(--color-accent-line);
}
.button-review:hover { background: var(--color-surface-2); border-color: var(--color-accent-hover); color: var(--color-accent-hover); }
.pencil-icon { fill: currentColor; flex: none; }
.book-action-button[aria-pressed="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.book-action-button[aria-pressed="true"]:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}
.book-action-button[aria-pressed="true"]::before { content: "✓"; margin-right: var(--space-2); }

@media (max-width: 600px) {
  .book-header { gap: var(--space-4); }
  .cover-book { width: 80px; height: 120px; }
  .book-authors { font-size: var(--text-body); }
}

/* --color-error is a fill and border color; as text it's only 3.75:1. */
/* Settings (settings.templ): one column of small forms, grouped under Profile and Account. */
.settings-page { max-width: var(--width-text); }
.settings-group { margin-top: var(--space-12); }
.settings-group > .label { padding-bottom: var(--space-2); border-bottom: 1px solid var(--color-border); }
.settings-section { padding-block: var(--space-8); border-bottom: 1px solid var(--color-border); scroll-margin-top: var(--space-4); }
.settings-section h3 { margin: 0 0 var(--space-4); }
.settings-section .account-form { margin-bottom: 0; }
.settings-notice { margin-bottom: var(--space-4); }
.settings-photo { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-6); }
.settings-photo .account-form { flex: 1 1 var(--width-sidebar); }
.settings-section > .account-aside { margin: var(--space-6) 0 0; }

/* Logging in and signing up (login.templ): one narrow column of short forms. */
.account-page { max-width: var(--width-form); padding-block: var(--space-8); }
.account-form { display: grid; gap: var(--space-6); margin-bottom: var(--space-8); }
.account-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.account-aside { font-size: var(--text-small); color: var(--color-fg-muted); }
.account-aside a, .account-aside .link-button { color: var(--color-fg-2); }
.account-code { font-variant-numeric: tabular-nums; }

.error-page { max-width: var(--width-text); padding-block: var(--space-12); }
.error-page .label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--color-error);
}

/* --- Review form ---------------------------------------------------------------------------- */
/* Writing or editing a review (GET /books/{id}/review): the book, then the fields in one column at
 * reading width. The first form with validation errors: the summary at the top and the messages
 * under each field's label are the pattern for later forms. */

.review-form-page { max-width: var(--width-text); }
/* The heading, then the book as its page shows it (.book-header, smaller): the cover, with the
 * title and the authors and year beside it. */
.review-form-header { margin-bottom: var(--space-12); }
.review-form-title { margin: 0 0 var(--space-6); }
.review-form-book { display: flex; align-items: flex-start; gap: var(--space-6); }
.cover-review { width: 96px; height: 144px; }
@media (max-width: 600px) {
  .review-form-book { gap: var(--space-4); }
  .cover-review { width: 64px; height: 96px; }
}
.review-form-book-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-title);
  font-weight: var(--weight-h1);
  line-height: var(--leading-h1);
}
.review-form { display: grid; gap: var(--space-8); }
.review-form-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.review-form-delete { margin-left: auto; font-size: var(--text-small); color: var(--color-fg-3); }

/* A fieldset as a .field: no box, its legend like a field's label. */
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-weight: 600;
  font-size: var(--text-small);
}
.field-hint { margin: 0; font-size: var(--text-small); color: var(--color-fg-muted); }

/* A multi-line .input, in the same font as every other input (the review form's two texts match). */
.textarea {
  height: auto;
  padding: var(--space-2) var(--space-3);
  line-height: var(--leading-body);
  resize: vertical;
}
.input[aria-invalid="true"] { border-color: var(--color-error); }

/* The corrections form's genres: checkboxes in columns, two on phones. */
.correction-genre-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-2) var(--space-6); }
.correction-thanks p:last-child { margin-bottom: 0; }

/* The admin pages (admin.templ): the settings page's groups, with reports as result rows and the
 * corrections as plain lists. A reader's note is quoted, like a review's tl;dr on its delete page. */
.admin-page { max-width: var(--width-text); }
.admin-page .results { border-top: 0; } /* the section heading is ruled already */
.admin-bio-name { margin-bottom: var(--space-8); }
.admin-notice { margin: var(--space-6) 0 0; }
.admin-empty { margin: var(--space-4) 0 0; }
.admin-report { flex: 1; min-width: 0; }
.admin-report > .result-meta { margin-bottom: var(--space-2); }
.admin-genres { margin: 0 0 var(--space-2); }
.admin-quote {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-border-strong);
  color: var(--color-fg-2);
}
.admin-quote p { margin: 0 0 var(--space-2); }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }
.admin-actions form { margin: 0; }
.admin-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.admin-list li { padding-block: var(--space-3); border-bottom: 1px solid var(--color-border); }
.admin-note { margin: var(--space-1) 0; color: var(--color-fg-2); white-space: pre-line; }
.admin-list .result-meta { margin: 0; }
.admin-book-reports { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.admin-book-reports li { padding-block: var(--space-3); border-top: 1px solid var(--color-border); }
.admin-book-reports .choice { margin-bottom: var(--space-2); }
.admin-remove, .admin-bio-links { margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.admin-remove .field-hint { margin-top: 0; }
.admin-bio-links ul { margin: var(--space-3) 0 0; padding-left: var(--space-6); }
/* The tabs between admin areas, for an admin who may use more than one. */
.admin-tabs { margin-bottom: var(--space-8); }
/* The collections admin (admincollections.templ): the list of collections, each with Up and Down
 * on the right; a collection's books as compact rows, numbered, each with its note under the title
 * and its buttons on the right. */
.admin-collections-new { margin: var(--space-6) 0 0; }
.review-form-page .admin-notice { margin: 0 0 var(--space-8); }
.admin-collection-row { display: flex; align-items: center; gap: var(--space-4); }
.admin-collection-text { flex: 1; min-width: 0; }
/* Up and Down keep their columns, so the first and last collections' single button lines up. */
.admin-move { display: grid; grid-template-columns: repeat(2, 5rem); gap: var(--space-2); margin: 0; }
.admin-move button[value="down"] { grid-column: 2; }
.collection-books .search-row { margin-top: var(--space-3); }
.admin-collection-books { margin-top: var(--space-4); }
.admin-collection-book { align-items: flex-start; gap: var(--space-3); padding-block: var(--space-3); }
.admin-collection-position {
  flex: none;
  min-width: 2ch;
  padding-top: var(--space-1);
  text-align: right;
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  color: var(--color-fg-muted);
}
.admin-collection-book-text { flex: 1; min-width: 0; }
.admin-collection-note { margin-top: var(--space-2); }
.admin-collection-book-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex: none;
  font-size: var(--text-small);
}
.user-admin { color: var(--color-fg-3); text-decoration: none; }
.user-admin:hover { color: var(--color-fg); }

/* Radio buttons and checkboxes with their labels, and a hint under the label. */
.choice-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2) var(--space-8); }
.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-2);
  align-items: center;
}
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); }
.choice label { font-weight: 400; font-size: var(--text-body); cursor: pointer; }
.choice-hint { grid-column: 2; font-size: var(--text-small); color: var(--color-fg-muted); }

/* Errors. --color-error is too light for text, so messages are the accent red (5.2:1), marked
 * with the error pages' red dot. */
.field-error {
  margin: 0;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-accent-line);
}
.field-error::before,
.char-count-over::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--color-error);
  vertical-align: 0.05em;
}
.form-errors {
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-8);
  border: 2px solid var(--color-error);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.form-errors-heading { margin: 0 0 var(--space-2); }
.form-errors ul { margin: 0; padding-left: var(--space-6); }
.form-errors li + li { margin-top: var(--space-1); }

/* "Similar books": the chosen books as checkboxes, then a search like the search page's, its
 * results as compact rows with "Add" on the right. */
.similar-chosen { display: grid; gap: var(--space-3); margin-block: var(--space-2); }
.similar-results { margin-top: var(--space-2); }
.similar-result { align-items: center; gap: var(--space-3); padding-block: var(--space-3); }
.similar-result-text { flex: 1; min-width: 0; }
.similar-result-title { margin: 0; font-weight: 600; line-height: 1.3; }
.similar-result .button { flex: none; }
.similar-added { flex: none; padding-inline: var(--space-4); font-size: var(--text-small); color: var(--color-fg-muted); }

/* Character counts (review-form.js): "73 / 100" after the hint, or "12 characters over". */
.char-count { margin-left: var(--space-1); font-variant-numeric: tabular-nums; }
.char-count-over { color: var(--color-accent-line); font-weight: 600; }

/* The rating: ten visually hidden radio inputs, each labelled by half a dot. Five dots of 32px
 * with 16px between them, so each half is a 24px-wide, 44px-tall target (half the dot plus half
 * the gap), the minimum target size, and the targets touch: the picker has no dead space. Everything up to the checked half is filled; on hover,
 * everything up to the hovered half is filled in a lighter red, as a preview. The DOM order is
 * the visual order (1 to 10), so the arrow keys go the way they look: halves after the checked or
 * hovered one are emptied with the ~ sibling selector, and :has() fills the rest. */
.rating-input { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.rating-picker { display: flex; border-radius: var(--radius-md); }
.rating-radio {
  position: absolute; width: 1px; height: 1px; margin: 0; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0;
}
.rating-half { position: relative; width: 24px; height: 44px; cursor: pointer; }
.rating-half::before {
  content: "";
  position: absolute;
  top: 6px;
  width: 16px;
  height: 32px;
  border: 2px solid var(--color-rating);
  transition: background-color var(--transition-fast);
}
.rating-half-left::before { right: 0; border-right: 0; border-radius: 16px 0 0 16px; }
.rating-half-right::before { left: 0; border-left: 0; border-radius: 0 16px 16px 0; }
.rating-picker:has(.rating-radio:checked) .rating-half::before { background: var(--color-rating); }
.rating-radio:checked + .rating-half ~ .rating-half::before { background: none; }
.rating-picker:has(.rating-half:hover) .rating-half::before { background: var(--color-rose); }
.rating-picker .rating-half:hover ~ .rating-half::before { background: none; }
.rating-picker:has(.rating-radio:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
/* The checked value as text. */
.rating-value { font-size: var(--text-small); }
.rating-value::after { content: "No rating yet"; color: var(--color-fg-muted); }
.rating-input:has(#review-rating-1:checked) .rating-value::after { content: "½ star"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-2:checked) .rating-value::after { content: "1 star"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-3:checked) .rating-value::after { content: "1½ stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-4:checked) .rating-value::after { content: "2 stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-5:checked) .rating-value::after { content: "2½ stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-6:checked) .rating-value::after { content: "3 stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-7:checked) .rating-value::after { content: "3½ stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-8:checked) .rating-value::after { content: "4 stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-9:checked) .rating-value::after { content: "4½ stars"; color: var(--color-fg-2); }
.rating-input:has(#review-rating-10:checked) .rating-value::after { content: "5 stars"; color: var(--color-fg-2); }
.review-finished { gap: var(--space-4); }

/* The delete page quotes the review's rating and tl;dr. */
.review-delete-quote {
  margin: 0 0 var(--space-6);
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-border-strong);
}
.review-delete-quote blockquote { margin: 0; }

/* "Your review" at the top of a book page's reviews, above the tabs. */
.your-review { margin-bottom: var(--space-8); }
.your-review-heading { margin: var(--space-6) 0 var(--space-2); }
