/* Fonts (open licence, files and licence texts in static/fonts/). Only the Latin letters, to keep
   them small; text shows straight away in a stand-in font and swaps when the file arrives. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin.ada540c0e24a.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin.fb34450b3254.woff2") format("woff2");
  font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-italic.9be147cef3b5.woff2") format("woff2");
  font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url("fonts/dm-mono-latin-400.e1ed461ac183.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url("fonts/dm-mono-latin-500.c4598219c4b8.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap; }

/* Colours (docs/design-rules.md): warm paper, near-black ink, an ochre highlighter, a red pen.
   Dark is used when your device is in dark mode or when you pick Dark with the button in the top bar.
   --accent is the ochre fill (chosen / yes), always with --on-accent text on top; --link is ochre
   dark enough to read as text. Every text colour here passes 4.5 to 1 on --bg, --panel and --raised. */
:root {
  color-scheme: dark;
  --font-sans: "Bricolage Grotesque", system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
  --paper: #f6efdd; --ink: #1a1712;   /* the same in both themes: things printed on a cover */
  --bg: #1a1712; --panel: #24201a; --raised: #322c23; --border: #5c5242;   /* M90: lines and soft text lighter in dark */
  --text: #f3ead6; --muted: #d2c8ae;
  --spine-soft: #8f8468;   /* the soft spine on the home shelf (M87): visible on the dark page, ink label */
  --accent: #e3a72f; --on-accent: #1a1712; --link: #e3a72f;
  --red: #c23b2a; --ribbon: #e85d4a;
  --award: #e3a72f; --award-border: #6e5420;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --scroll-thumb: #3f382c; --scroll-thumb-hover: #5e5647;
  --star: #e3a72f; --danger: #ee6b57; --ok: #e3a72f;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6efdd; --panel: #ece2c8; --raised: #e3d7b8; --border: #d3c7a8;
    --text: #1a1712; --muted: #5e5647;
    --spine-soft: #ece2c8;
    --accent: #e3a72f; --on-accent: #1a1712; --link: #7a4f05;
    --red: #c23b2a; --ribbon: #e85d4a;
    --award: #7a4f05; --award-border: #e3a72f;
    --shadow: 0 6px 16px rgba(60, 45, 20, 0.16);
    --scroll-thumb: #d3c7a8; --scroll-thumb-hover: #b3a68a;
    --star: #7a4f05; --danger: #a92f1f; --ok: #7a4f05;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6efdd; --panel: #ece2c8; --raised: #e3d7b8; --border: #d3c7a8;
  --text: #1a1712; --muted: #5e5647;
  --spine-soft: #ece2c8;
  --accent: #e3a72f; --on-accent: #1a1712; --link: #7a4f05;
  --red: #c23b2a; --ribbon: #e85d4a;
  --award: #7a4f05; --award-border: #e3a72f;
  --shadow: 0 6px 16px rgba(60, 45, 20, 0.16);
  --scroll-thumb: #d3c7a8; --scroll-thumb-hover: #b3a68a;
  --star: #7a4f05; --danger: #a92f1f; --ok: #7a4f05;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); line-height: 1.5; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 24px; align-items: center; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar .logo { font-weight: 700; font-size: 1.2rem; color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
h1 { margin-top: 0; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 18px; }
.card { color: var(--text); font-size: 0.9rem; }
.card img, .card .nocover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 2px; background: var(--panel); display: block; }
.nocover { display: grid !important; place-items: center; padding: 8px; text-align: center; color: var(--muted); }
.card .title { font-weight: 600; margin-top: 6px; }
/* Cards stay the same height: titles stop after 2 lines and authors after 1, with "…" (the full text is in the tooltip). */
.card .title, .card .card-authors { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card .title { -webkit-line-clamp: 2; line-clamp: 2; }
.card .card-authors { -webkit-line-clamp: 1; line-clamp: 1; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); margin: 10px 0; }
.tag { display: inline-block; background: var(--raised); color: var(--text); border-radius: 0; padding: 2px 12px; margin: 0 6px 6px 0; font-size: 0.85rem; }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 28px; }
.pager { flex-wrap: wrap; align-items: baseline; }
.pager .pages { display: flex; gap: 10px; flex-wrap: wrap; }
.pager-note { text-align: center; margin-top: 8px; }

/* --- Search and filter page (milestone 2) --- */
main { max-width: 1280px; }
.discover { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }
.filters { background: var(--panel); border-radius: 0; padding: 16px; display: grid; gap: 16px; }
.filters label, .filters legend { font-size: 0.85rem; color: var(--muted); display: block; padding: 0; }
.filters fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.filters legend { margin-bottom: 6px; }
input[type="search"], input[type="text"], input[type="number"], select {
  width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 0; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills label { margin: 0; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills span { display: block; padding: 3px 11px; border-radius: 0; border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 0.85rem; }
.pills input:checked + span { background: var(--accent); border-color: var(--text); color: var(--on-accent); font-weight: 600; }
.pills input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.filter-buttons { display: flex; gap: 16px; align-items: center; }
button { padding: 8px 18px; border: 0; border-radius: 0; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 18px; }
.toolbar h1 { margin: 0; font-size: 1.4rem; flex: 1; }
.sort { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.sort select { margin: 0; width: auto; }
.switch { display: flex; border: 1px solid var(--border); border-radius: 0; overflow: hidden; }
.switch a { padding: 6px 14px; color: var(--muted); font-size: 0.85rem; }
.switch a.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.switch a:hover { text-decoration: none; }
.rows { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 110px 1fr; gap: 18px; background: var(--panel); border-radius: 0; padding: 14px; }
.row img, .row .nocover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 2px; display: block; background: var(--bg); }
.row h2 { margin: 0; font-size: 1.1rem; }
.row h2 a { color: var(--text); }
.row .facts { margin: 6px 0; font-size: 0.9rem; }
.row p { margin: 8px 0 0; font-size: 0.9rem; }
@media (max-width: 800px) {
  .discover { grid-template-columns: 1fr; }
  .row { grid-template-columns: 80px 1fr; }
}
.tag.small { font-size: 0.75rem; color: var(--muted); }
.switch { width: fit-content; margin-bottom: 14px; }
.toolbar .switch { margin-bottom: 0; }

/* --- Home page (milestone 3) --- */
.topbar { position: sticky; top: 0; z-index: 5; }
.topsearch { width: min(320px, 45vw); }
.topsearch input { margin: 0; }
.home-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.home-head h1 { margin: 0; font-size: 2rem; }
.home-head p { margin: 4px 0 0; }
.shelf { margin-top: 34px; }
.shelf-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.shelf-head h2 { margin: 0; font-size: 1.3rem; }
.shelf-head span { font-size: 0.85rem; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 16px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.strip .card { scroll-snap-align: start; }
.card-cover { transition: transform 0.15s ease; }
.card:hover { text-decoration: none; }
.card:hover .card-cover { transform: translateY(-3px); }
@media (max-width: 640px) { .strip { grid-auto-columns: 110px; } .topbar { gap: 14px; flex-wrap: wrap; } }
@media (prefers-reduced-motion: reduce) { .card-cover { transition: none; } .card:hover .card-cover { transform: none; } }
.tag.award { border: 1px solid var(--award-border); color: var(--award); background: transparent; }
.filters fieldset > input, .filters fieldset > select { margin-top: 8px; }

/* --- Themes: finishing touches --- */
.theme-fading body { transition: background-color 0.2s ease, color 0.2s ease; }   /* only while you switch (theme.js) */
.filters, .row { border: 1px solid var(--border); }
.nocover { border: 1px dashed var(--border); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 6px 12px; font-weight: 500; font-size: 0.85rem; white-space: nowrap; }
button.ghost:hover { background: var(--raised); }
button.ghost.danger { color: var(--danger); }

/* --- Scrollbars: thin, rounded, in the theme's colours --- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
/* The rows of covers: the bar stays out of sight until you point at the row. */
.strip { scrollbar-color: transparent transparent; padding-bottom: 14px; }
.strip:hover, .strip:focus-within { scrollbar-color: var(--scroll-thumb) transparent; }
.strip::-webkit-scrollbar-thumb { background: transparent; }
.strip:hover::-webkit-scrollbar-thumb, .strip:focus-within::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: padding-box; }
@media (prefers-reduced-motion: reduce) { .theme-fading body { transition: none; } }

/* --- Accounts, shelves, ratings (milestones 4 and 5) --- */
.topbar form { margin: 0; }
.topbar .who { font-size: 0.85rem; }
.footer { padding: 28px 16px 36px; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 32px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }
.footer-cols { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px 64px; max-width: 900px; margin: 0 auto; }
.footer-h { margin: 0 0 8px; font-weight: 600; color: var(--text); }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-data { text-align: center; margin: 24px 0 0; font-size: 0.8rem; }
@media (max-width: 599px) { .footer-cols { flex-direction: column; gap: 18px; } }
.notice { padding: 10px 14px; border-radius: 0; border: 1px solid var(--border); background: var(--panel); margin: 0 0 16px; }
.notice.success { border-color: var(--ok); }
.notice.error { border-color: var(--danger); color: var(--danger); }
.account { max-width: 380px; margin: 40px auto; background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 24px; display: grid; gap: 14px; }
.account h1 { margin: 0; }
.account label, .stack label, .panel label { font-size: 0.85rem; color: var(--muted); display: block; }
input[type="password"], input[type="date"], textarea { width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 0; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.stack { display: grid; gap: 10px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: auto; margin: 0; }
.small-text { font-size: 0.8rem; }
.panel { margin-top: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 14px; display: grid; gap: 14px; }
.panel p { margin: 0; }
.status-buttons { display: grid; gap: 6px; }
.status-buttons button { width: 100%; text-align: left; }
.status-buttons button.on::before { content: "✓ "; }
.progress, .bar { height: 8px; border-radius: 0; background: var(--raised); overflow: hidden; }
.progress span, .bar span { display: block; height: 100%; background: var(--accent); border-radius: 0; }
.shelf-links { display: grid; gap: 2px; }
.shelf-links a { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 0; color: var(--text); }
.shelf-links a:hover { background: var(--raised); text-decoration: none; }
.shelf-links a.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.shelf-links span { opacity: 0.75; }
.danger-zone { margin-top: 28px; }
.stars { position: relative; display: inline-block; font-size: 1rem; line-height: 1; letter-spacing: 2px; white-space: nowrap; vertical-align: middle; }
.stars::before { content: "★★★★★"; color: var(--border); }
.stars::after { content: "★★★★★"; color: var(--star); position: absolute; left: 0; top: 0; overflow: hidden; width: calc(var(--value) / 5 * 100%); }
.stars.big { font-size: 2rem; cursor: pointer; }
.rating-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reviews { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 8px; }
.review-form { background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 16px; margin-bottom: 12px; max-width: 560px; }
.star-input { display: flex; gap: 14px; align-items: center; }
input[type="range"] { width: 100%; max-width: 260px; accent-color: var(--star); }
.breakdown { display: grid; gap: 4px; max-width: 320px; margin-bottom: 18px; font-size: 0.85rem; }
.breakdown > div { display: grid; grid-template-columns: 36px 1fr 28px; gap: 8px; align-items: center; }
.review { border-top: 1px solid var(--border); padding: 14px 0; }
.review header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.review details summary { cursor: pointer; color: var(--muted); margin-top: 8px; }
.prose { max-width: 720px; }
.prose li { margin-bottom: 8px; }
@media (max-width: 640px) { .topbar .who { display: none; } }

/* --- Home page rework (milestone 13) --- */
.card { position: relative; }
.card-cover { display: block; }
.card a.title { color: var(--text); }   /* display comes from the 2-line cap above */
.card-rating { color: var(--star); font-size: 0.8rem; margin-top: 2px; }
@media (hover: hover) {  /* with a mouse: the + shows when you point at the cover */
  .card-add { opacity: 0; transition: opacity 0.15s ease; }
  .card:hover .card-add, .card-add:focus-within { opacity: 1; }
}
.shelf.first { margin-top: 0; }
.home-head { display: block; }
.shelf-tools { display: flex; gap: 8px; align-items: center; }
.arrow { width: 32px; height: 32px; padding: 0; font-size: 1.2rem; line-height: 1; border-radius: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: 0; background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile span { color: var(--muted); font-size: 0.85rem; }
.genre-links { margin-top: 14px; }
.reading-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 320px); gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }  /* one row; more books scroll sideways */
.reading-grid .reading { scroll-snap-align: start; }
@media (max-width: 640px) { .reading-grid { grid-auto-columns: 85%; } }
.reading { display: grid; grid-template-columns: 70px 1fr; gap: 14px; padding: 12px; border-radius: 0; background: var(--panel); border: 1px solid var(--border); }
.reading img, .reading .cover-box { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 2px; display: block; }
.reading a.title { color: var(--text); font-weight: 600; }
.reading .progress { margin: 8px 0; }
.reading-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reading-form label { display: flex; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--muted); }
.reading-form input[type="number"] { width: 80px; margin: 0; padding: 5px 8px; }
@media (max-width: 640px) {
  .arrow { display: none; }  /* on a phone you swipe the row */
}
@media (prefers-reduced-motion: reduce) { .card-add { transition: none; } }
@media (max-width: 640px) {  /* on a phone the genre buttons form one line you swipe */
  .genre-links { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
  .genre-links .tag { flex: none; margin: 0; }
}

/* --- Import and export (milestone 6) --- */
.upload { max-width: 420px; margin: 16px 0; }
input[type="file"] { color: var(--text); font: inherit; }
a.button { display: inline-block; padding: 8px 18px; border-radius: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; }
a.button:hover { text-decoration: none; }
table.plain { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 0.9rem; }
table.plain th, table.plain td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
table.plain th { color: var(--muted); font-weight: 600; }
.prose .progress { margin: 10px 0; }

/* --- Stats (milestone 9) --- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-tiles .tile strong { font-size: 1.6rem; }
.card-box { background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 16px; margin-bottom: 14px; }
.card-box h2 { margin: 0 0 10px; font-size: 1.05rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart { display: grid; gap: 6px; font-size: 0.85rem; }
.chart > div { display: grid; grid-template-columns: 130px 1fr 30px; gap: 8px; align-items: center; }
.chart-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-number { text-align: right; }
.toolbar .switch { flex-wrap: wrap; }

/* --- Mood, pace, content warnings (milestone 8) --- */
.pills input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
details.tag-form, details.warnings { margin: 10px 0; }
details.tag-form > summary, details.warnings > summary { cursor: pointer; color: var(--link); }
details.tag-form form { background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 16px; margin-top: 10px; max-width: 640px; }
details.tag-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
details.tag-form legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.warning-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; }
.warning-grid label { font-size: 0.85rem; color: var(--text); }
.tag.warn { border: 1px solid var(--border); background: transparent; }
.tag.warn.graphic { border-color: var(--danger); color: var(--danger); }
details.avoid > summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

/* --- Friends and feed (milestone 11) --- */
.people { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.people li a { display: inline-block; padding: 6px 14px; border-radius: 0; background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.feed-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.feed-line:first-of-type { border-top: 0; }
.feed-line form { margin: 0; }
a.button.ghostlink { background: transparent; color: var(--text); border: 1px solid var(--border); font-weight: 500; font-size: 0.85rem; padding: 6px 12px; }
.prose.wide { max-width: 900px; }
.toolbar form { margin: 0; }
.pills.match { margin-top: 8px; }
.series-found { margin: 0 0 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 8px; }
.tabs a { padding: 6px 14px; border-radius: 0; border: 1px solid var(--border); color: var(--text); }
.tabs a[aria-current="page"], .pills a.tag[aria-current="page"] { background: var(--accent); border-color: var(--text); color: var(--on-accent); }
.ranking { padding-left: 1.6em; }
.ranking li { margin: 6px 0; }
.ranking .muted { margin-left: 8px; font-size: 0.85rem; }
.notice.standing { font-size: 0.9rem; }
.panel-box { margin: 20px 0; padding: 16px; border: 1px solid var(--border); border-radius: 0; background: var(--panel); }
.list-cards { list-style: none; padding: 0; display: grid; gap: 12px; }
.list-cards li { padding: 12px 14px; border: 1px solid var(--border); border-radius: 0; }
.list-cards .muted { display: block; font-size: 0.85rem; }
.edit-order li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.edit-order li span { flex: 1; min-width: 160px; }
.edit-order form { margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form select { margin: 0; width: auto; }
.lookup-results { list-style: none; padding: 0; display: grid; gap: 10px; }
.lookup-results li { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 0; }
.lookup-results img, .lookup-results .nocover.small { width: 44px; height: 66px; object-fit: cover; border-radius: 2px; font-size: 0.6rem; }
.lookup-results .muted { display: block; font-size: 0.85rem; }
.lookup-results form { margin: 0; }
.badges { margin: 6px 0; }
/* Genres, mood & pace, warnings and reader tags side by side on a book page */
.tag-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; }
.tag-columns h3 { font-size: 1rem; margin: 0 0 8px; }
.tag-columns details.more { display: inline; }
.tag-columns details.more > summary { list-style: none; cursor: pointer; }
.tag-columns details.more > summary::-webkit-details-marker { display: none; }
.tag-columns details.more[open] > summary { display: none; }
.tag-columns details.warnings { margin: 0; }

/* --- Phone fixes after the audit (2026-11-16) --- */
@media (max-width: 640px) {
  .topbar { position: static; }                 /* the tall bar no longer follows you down */
  .topbar .who { display: inline; }             /* keep "My filters" and your name */
  .topbar a { padding: 8px 0; }                 /* easier to tap */
  .pills span, .genre-links .tag { padding: 8px 14px; }
}

/* --- Phone layout: filters fold away, book title first (M26, M27) --- */
.filter-toggle { width: 100%; padding: 10px 14px; font-size: 0.95rem; }
@media (min-width: 801px) { .filter-toggle { display: none; } .filters.folded { display: grid; } }
@media (max-width: 800px) { .filters.folded { display: none; } .filter-toggle:not([hidden]) { display: block; } }

/* "Skip to content": hidden until a keyboard user tabs to it (M30) */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 8px 14px; border-radius: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 600; }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }

/* Genre buttons: click once to show a genre (ochre), again to leave it out (red strike), again to stop. */
.legend-hint { font-size: 0.75rem; opacity: 0.8; margin-left: 4px; }
.genre-pill button { display: block; padding: 3px 11px; border-radius: 0; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-weight: 400; font-size: 0.85rem; cursor: pointer; }
.genre-pill button:hover { background: var(--raised); }
.genre-pill.in button { background: var(--accent); border-color: var(--text); color: var(--on-accent); font-weight: 600; }
.genre-pill.out button { background: transparent; border-color: var(--danger); color: var(--danger);
  font-weight: 600; text-decoration: line-through; }
.genre-pill.in button::before { content: "✓ "; }
.genre-pill.out button::before { content: "✕ "; }
@media (max-width: 640px) { .genre-pill button { padding: 8px 14px; } }
.toolbar a.button.ghostlink { white-space: nowrap; }
.pills span.genre-pill { display: block; padding: 0; border: 0; border-radius: 0; background: none; }   /* not the pill look of .pills span */

/* --- Phone menu and home tiles (items 1 and 3) --- */
/* The links sit in a list. On a wide screen the list and its items "disappear" so the top bar looks as before;
   "order" keeps the old sequence: logo, main links, search, account links. */
.menu-links, .menu-links li { display: contents; }
.menu-toggle { display: none; }
@media (min-width: 901px) {
  .menu-links .m-main > * { order: 1; }
  .topsearch { order: 2; }
  .menu-links .m-acct > * { order: 3; }
}
@media (max-width: 900px) {
  .topbar { justify-content: flex-start; gap: 8px 12px; padding: 10px 16px; }
  .topsearch { flex: 1 1 120px; width: auto; min-width: 0; }
  .menu-links li { display: block; }
  .menu-links { width: 100%; list-style: none; margin: 0; padding: 0; }
  .menu-links a, .menu-links button { display: inline-block; padding: 10px 0; }
  .menu-links button.ghost { padding: 6px 12px; margin: 6px 0; }
  .menu-links li + li { border-top: 1px solid var(--border); }
  /* Only after menu.js has run: show the button and fold the links away until it is pressed. */
  .topbar.menu-js .menu-toggle { display: inline-block; }
  .topbar.menu-js .menu-links { display: none; }
  .topbar.menu-js.menu-open .menu-links { display: block; }
}
@media (max-width: 640px) {
  /* Home page shortcut tiles: one row you swipe, like the genre buttons */
  .tiles { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
  .tiles .tile { flex: 0 0 150px; }
}
@media (max-width: 640px) { .topbar .menu-links .who { font-size: 1rem; padding: 10px 0; } .menu-links form button.ghost { margin: 6px 0; } }   /* every menu line easy to tap */

/* Cover boxes never look empty: the drawn cover sits behind the picture until it has loaded (M81 block at the end). */
.editions { margin: 18px 0; }
.editions h2 { font-size: 1.1rem; margin: 0 0 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

/* --- Book page top (M39, restyled M83 after the mock-up) --- */
/* Cover with page edges and ribbon on the left; badges, big title, author/series, big facts and actions on the right. */
.book-hero { display: flex; flex-wrap: wrap; gap: 32px 56px; padding: 16px 0 40px; }
.hero-cover { flex: 0 1 330px; min-width: 220px; position: relative; display: flex; align-self: flex-start; }
.hero-cover .cover-box { flex: 1; min-width: 0; }
.hero-cover img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; }
.hero-cover .ribbon { right: 38px; top: -4px; min-width: 50px; padding: 8px 6px 18px; font-size: 0.85rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 11px), 0 100%); }
.hero-cover .drawn-cover .dc-title { font-size: clamp(20px, 13cqw, 46px); }
/* The edges of the pages, seen from the side (paper colours on purpose: it is the book itself). */
.page-edge { flex: 0 0 13px; margin: 8px 0; border-radius: 0 2px 2px 0; background: repeating-linear-gradient(90deg, #fffdf5 0 1px, #cbbf9f 1px 2.5px); }
.hero-info { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.book-head { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.book-head h1 { margin: 0; font-size: clamp(2.6rem, 7.5vw, 6.5rem); font-weight: 800; letter-spacing: -0.05em; line-height: 0.92; overflow-wrap: anywhere; }
.book-head p { margin: 0; }
.hero-by { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; }
.hero-by a, .hero-by .more-authors > summary { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.hero-series { color: var(--muted); }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-chips .tag { margin: 0; font-family: var(--font-mono); font-size: 0.8rem; color: var(--text); }
.hero-chips .tag:hover { text-decoration: none; background: var(--raised); }
.hero-chips .tag.year-badge.rated { border-color: var(--accent); color: var(--on-accent); }
.hero-chips .tag.year-badge.rated:hover { background: var(--accent); text-decoration: underline; }
/* The row of big facts between two ink lines. */
.hero-facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border-top: 1.5px solid var(--text); border-bottom: 1.5px solid var(--text); }
.hero-facts > div { padding: 14px 16px; border-left: 1px solid var(--text); min-width: 0; }
.hero-facts > div:first-child { padding-left: 0; border-left: 0; }
.hero-facts dt { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hero-facts dd { margin: 0; }
.fact-big { margin-top: 2px !important; font-size: 2.25rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.fact-small { font-family: var(--font-mono); font-size: 0.75rem; }
.fact-small .stars { font-size: 0.85rem; letter-spacing: 1px; }
/* Your actions: shelf buttons joined into one control, then plain links. */
.book-actions { display: flex; flex-direction: column; gap: 6px; }
.book-actions .panel { margin: 0; padding: 0; background: none; border: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.book-actions .status-buttons { display: flex; flex-wrap: wrap; gap: 0; }
.book-actions .status-buttons button { width: auto; min-height: 52px; padding: 0 20px; font-size: 1.05rem; font-weight: 600; text-align: center;
  background: transparent; color: var(--text); border: 1.5px solid var(--text); }
.book-actions .status-buttons button + button { border-left: 0; }
.book-actions .status-buttons button:hover { background: var(--raised); }
.book-actions .status-buttons button.on { background: var(--accent); color: var(--on-accent); font-weight: 800; }
.action-links { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; }
.action-link, .panel-more > summary, .panel-more.as-button > summary { display: inline-block; padding: 10px 0; border: 0; background: none;
  color: var(--text); font-size: 1rem; font-weight: 500; cursor: pointer; }
.action-link:hover, .panel-more > summary:hover { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.panel-more.as-button > summary { list-style: none; }
.panel-more.as-button > summary::-webkit-details-marker { display: none; }
.panel-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1.5px solid var(--text);
  border-radius: 0; background: var(--bg); color: var(--text); }
.panel-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.panel-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1.5px solid var(--text); position: sticky; top: 0; background: var(--bg); }
.panel-dialog-head h2 { margin: 0; font-size: 1.05rem; }
.panel-dialog-body { padding: 16px 18px 20px; }

/* Tabs: underlined words between an ink line and a thin line; the open one is ink with a red bar.
   overflow-y hidden + an inset bar: a link sticking 1px out below made the bar scroll up and down. */
.book-tabs { display: flex; gap: 0 32px; border-top: 1.5px solid var(--text); box-shadow: inset 0 -1px 0 var(--text); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.book-tabs::-webkit-scrollbar { display: none; }
.book-tabs a { flex: 0 0 auto; padding: 14px 0 11px; color: var(--muted); font-size: 1.1rem; font-weight: 600; border-bottom: 4px solid transparent; }
.book-tabs a:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border); }
.book-tabs a[aria-current="true"] { color: var(--text); border-bottom-color: var(--red); }
.tab-n { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 500; }
.book-tabs:not(.ready) { display: none; }       /* without the script, the sections simply follow each other */

/* Editions tab */
.edition-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.edition-filters button, .edition-filters select, .editions-more { font: inherit; font-size: 0.9rem; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 5px 12px; cursor: pointer; }
.edition-filters button[aria-pressed="true"] { border-color: var(--accent); font-weight: 600; }
.edition-list { list-style: none; margin: 0 0 12px; padding: 0; }
.edition-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.edition-row[hidden] { display: none; }
.edition-cover, .edition-nocover { flex: 0 0 auto; width: 48px; height: 72px; border-radius: 2px; background: var(--panel); border: 1px solid var(--border); object-fit: cover; }
.edition-info { display: flex; flex-wrap: wrap; gap: 2px 14px; min-width: 0; align-items: baseline; }
.edition-info > * { overflow-wrap: anywhere; }
.edition-format { font-weight: 600; }
.edition-info .muted { font-size: 0.9rem; }
.book-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px 72px; padding: 36px 0 48px; }
.tab-panel { min-width: 0; }
.tabs-ready .tab-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* the tab says it already */
.tab-panel > .reviews:first-child, .tab-panel > .tag-overview { margin-top: 0; }
.tabs-ready .tab-panel > .reviews:first-child { border-top: 0; padding-top: 0; }
.book-description { font-size: 1.3rem; line-height: 1.6; max-width: 64ch; }
.facts-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0 0 20px; }
.facts-list dt { color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; padding-top: 3px; }
.facts-list dd { margin: 0; }
.book-side { display: grid; gap: 18px; align-content: start; }
.side-box { background: none; border: 0; border-top: 1px solid var(--text); padding: 12px 0 0; }
.side-box h2 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }
.side-box p { margin: 0 0 8px; }
.side-box .breakdown { margin-bottom: 0; }

@media (max-width: 1000px) { .book-body { grid-template-columns: 1fr; } }
/* Phones: title, author and the facts first, then the cover (smaller), then your actions. */
@media (max-width: 640px) {
  .book-hero { flex-direction: column; gap: 20px; padding-top: 4px; }
  .hero-info { display: contents; }
  .book-head { order: 1; }
  .hero-cover { order: 2; flex: none; width: 200px; min-width: 0; }
  .book-actions { order: 3; }
  .hero-by { font-size: 1.2rem; }
  .hero-facts { grid-template-columns: 1fr 1fr; }
  .hero-facts > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .hero-facts > div:nth-child(n+3) { border-top: 1px solid var(--text); }
  .fact-big { font-size: 1.8rem; }
  .book-actions .status-buttons { width: 100%; }
  .book-actions .status-buttons button { flex: 1 1 auto; padding: 0 12px; font-size: 0.95rem; }
  .book-tabs { gap: 0 20px; }
  .facts-list { grid-template-columns: 120px 1fr; }
}

/* Buy links (M40) */
.buy-menu > summary { list-style: none; cursor: pointer; }
.buy-menu > summary::-webkit-details-marker { display: none; }
.buy-menu > summary::after { content: " ▾"; color: var(--muted); }
.buy-menu p, .shop-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.buy-menu a, .shop-links a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 0; background: var(--panel); color: var(--text); font-size: 0.9rem; }
.buy-menu a:hover, .shop-links a:hover { background: var(--raised); text-decoration: none; }

/* Year badges (M41) */
.tag.year-badge { font-weight: 600; border: 1px solid var(--accent); color: var(--link); background: transparent; }
.tag.year-badge.rated { border-color: var(--award-border); color: var(--award); }



/* Book discussions (M42) */
.discussion-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.discussion-list a { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 0; color: var(--text); }
.discussion-list a:hover { background: var(--raised); text-decoration: none; }
.spoiler-tag { font-size: 0.75rem; padding: 1px 8px; border-radius: 0; border: 1px solid var(--danger); color: var(--danger); }
.start-discussion > summary { list-style: none; display: inline-block; cursor: pointer; padding: 8px 18px; border-radius: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 600; margin-bottom: 12px; }
.start-discussion > summary::-webkit-details-marker { display: none; }
.post { border-top: 1px solid var(--border); padding: 14px 0; }
.post.first-post { border-top: 0; }
.post .muted.small-text { margin: 0 0 6px; }
details.spoiler > summary { cursor: pointer; color: var(--muted); }

/* Series reading order */
.series-order { list-style: none; margin: 16px 0; padding: 0; }
.series-row { display: grid; grid-template-columns: 64px 70px 1fr; gap: 14px; align-items: center; padding: 12px 8px; border-top: 1px solid var(--border); }
.series-row:first-child { border-top: 0; }
.series-num { font-size: 1.6rem; font-weight: 700; color: var(--muted); text-align: right; }
.series-gap { grid-template-columns: 64px 1fr; padding: 8px; border-top-style: dashed; opacity: 0.8; }
.series-cover { width: 70px; }
.series-info .title { font-weight: 600; }
.series-shelf { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.series-status { font-size: 0.8rem; color: var(--muted); border: 1px solid var(--border); border-radius: 0; padding: 1px 8px; }
.series-next { background: var(--panel); border-left: 4px solid var(--accent); border-radius: 0; }
.series-next-mark { font-size: 0.8rem; font-weight: 700; background: var(--accent); color: var(--on-accent); border-radius: 0; padding: 1px 8px; }
@media (max-width: 640px) {
  .series-row { grid-template-columns: 44px 56px 1fr; gap: 10px; }
  .series-gap { grid-template-columns: 44px 1fr; }
  .series-num { font-size: 1.2rem; }
  .series-cover { width: 56px; }
}
/* Award pages */
.award-list { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 6px; }
.award-list .muted { margin-left: 8px; font-size: 0.85rem; }
.award-year { margin: 24px 0; }
.award-nominees { margin-top: 12px; }
.award-nominees > summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }

/* Author page */
.author-head { margin-bottom: 20px; }
.author-years { margin: -8px 0 10px; }
.author-bio { max-width: 70ch; margin-bottom: 10px; }
.author-aliases { margin: 0 0 10px; }
.author-awards, .author-series { margin: 24px 0; }

/* Top bar dropdowns */
.menu-links .m-head { display: none; }
.nav-drop { position: relative; }
.nav-drop summary { cursor: pointer; list-style: none; color: var(--link); padding: 4px 0; }
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary::after { content: " \25BE"; font-size: 0.8em; }
.nav-drop summary:focus-visible, .nav-drop a:focus-visible, .nav-drop .linklike:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.nav-drop ul { list-style: none; margin: 0; padding: 6px 0; }
.nav-drop li a, .nav-drop .linklike { display: block; width: 100%; padding: 8px 16px; text-align: left; white-space: nowrap; background: none; border: 0; font: inherit; color: var(--link); cursor: pointer; box-sizing: border-box; }
.nav-drop li a:hover, .nav-drop .linklike:hover { background: var(--bg); }
.nav-drop form { margin: 0; }
.menu-links a[aria-current="page"] { font-weight: 700; }
@media (min-width: 901px) {
  .menu-links .m-main > *, .menu-links .m-acct > *, .menu-links .m-drop > * { order: 2; }
  .topsearch { order: 1; }
  .menu-links .m-acct { margin-left: auto; }
  .nav-drop > ul { position: absolute; top: 100%; left: 0; z-index: 20; min-width: 190px; background: var(--panel); border: 1px solid var(--border); border-radius: 0; }
  .nav-drop.nav-right > ul { left: auto; right: 0; }
}
@media (max-width: 900px) {
  .menu-links .m-head, .nav-drop summary { display: block; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text); padding: 10px 0 2px; pointer-events: none; }
  .nav-drop summary::after { content: none; }
  .nav-drop li a, .nav-drop .linklike { padding: 10px 0; }
  .menu-links .m-drop > details { display: block; }
}
/* Forum */
.board-list, .forum-rows { list-style: none; padding: 0; margin: 0 0 20px; }
.board-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border, #ddd); text-decoration: none; }
.board-list a > span:first-child { display: flex; flex-direction: column; }
.forum-tabs { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0; }
.forum-tabs a.current { font-weight: bold; text-decoration: underline; }
.forum-genre { margin: 8px 0 12px; }
.forum-pages { display: flex; gap: 14px; }
.lock-mark { font-size: 0.85em; }

.series-lookup { margin-top: 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
/* --- Search as you type (static/search.js, docs/plans/search.md) --- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topsearch { position: relative; }
.search-list { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: max(100%, 420px); max-height: min(70vh, 560px);
  overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 0; padding: 6px 0; text-align: left; }
.search-list[hidden] { display: none; }
.search-head { padding: 8px 14px 4px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.search-option { display: flex; gap: 10px; align-items: center; padding: 6px 14px; color: var(--text); text-decoration: none; }
.search-option:hover, .search-option[aria-selected="true"] { background: var(--raised); }
.search-option[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.search-cover { flex: 0 0 32px; height: 48px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.search-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-words { display: flex; flex-direction: column; min-width: 0; }
.search-title, .search-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-title mark { background: none; color: var(--link); font-weight: 700; }
.search-meta { font-size: 0.82rem; color: var(--muted); }
.search-stars { color: var(--star); }
.search-option.search-all { margin-top: 4px; border-top: 1px solid var(--border); padding: 10px 14px; color: var(--link); font-weight: 600; }
.search-option.search-recent .search-title::before { content: "↺ "; color: var(--muted); }
.search-note { margin: 8px 14px; color: var(--muted); font-size: 0.9rem; }
.search-clear { display: block; margin: 4px 14px 6px auto; background: none; border: 0; padding: 4px 0; font: inherit; font-size: 0.82rem; color: var(--muted); cursor: pointer; text-decoration: underline; }
.search-tabs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.search-tabs a { padding: 6px 0; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.search-tabs a[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.result-list { list-style: none; padding: 0; margin: 0 0 16px; }
.result-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
@media (max-width: 900px) {
  /* Phones and tablets: the list spans the width of the top bar, just under it. */
  .topsearch { position: static; }
  .search-list { top: 100%; left: 8px; right: 8px; width: auto; max-height: 65vh; }
}
@media (max-width: 640px) {
  .topbar { position: relative; }   /* the bar no longer follows you down here, but still anchors the list */
}

/* Light/dark switch in the top bar (theme.js): a round button, last on wide screens, next to Menu on phones. */
.theme-switch { width: 36px; height: 36px; padding: 0; border-radius: 0; font-size: 1.05rem; line-height: 1; display: inline-grid; place-items: center; }
@media (min-width: 901px) {
  .theme-switch { order: 10; flex: 0 0 auto; }
  .topbar { flex-wrap: nowrap; }                /* one line; the search box gives way a little */
  .topsearch { flex: 0 1 320px; min-width: 140px; }
  .nav-drop summary, .menu-links .m-main a { white-space: nowrap; }
}
@media (max-width: 900px) { .topsearch { flex-basis: 70px; } .theme-switch { width: 34px; height: 34px; } }   /* logo, search, light/dark and Menu fit on one line */

/* ===== UX audit fixes (2026-11-19) ===== */

/* --- from the UX audit, part a --- */
/* UX finding 7: email fields look like the other text fields (copied from site.css rule for search/text/number). */
input[type="email"] {
  width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 0; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; }

/* UX finding 1: invite-only hero on the home page */
.home-hero { display: grid; gap: 10px; }
.home-hero .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.home-hero .hero-actions .secondary { padding: 8px 14px; }

/* UX finding 13: start-here box and empty forum states */
.start-here { border: 1px solid var(--border); border-radius: 0; padding: 14px 16px; margin: 0 0 20px; display: grid; gap: 8px; }
.start-here h2 { margin: 0; }
.start-here .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* --- from the UX audit, part b --- */
/* Builder B: discovery UX findings. Merge into site.css. */

/* 4: active filter chips above the results */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.filter-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 0;
  border: 1px solid var(--border); background: var(--raised); color: var(--text); font-size: 0.85rem; text-decoration: none; }
.filter-chip:hover { border-color: var(--accent); }
.filter-chip-clear { font-size: 0.85rem; color: var(--link); margin-left: 4px; }

/* 4: on phones the Show results button stays at the bottom of the open panel */
@media (max-width: 800px) {
  .filters .filter-buttons { position: sticky; bottom: 0; z-index: 5; background: var(--panel);
    padding: 10px 0; margin-top: 4px; border-top: 1px solid var(--border); }
  .filters .filter-buttons button { flex: 1; padding: 12px 14px; }
}

/* 9: "See all results" is pinned at the bottom of the dropdown; results tab counts */
.search-list .search-option.search-all { position: sticky; bottom: -6px; background: var(--panel); margin-bottom: -6px; z-index: 1; }
.tab-count { font-size: 0.8em; color: var(--muted); font-weight: 400; margin-left: 2px; }
.search-tabs a[aria-current="page"] .tab-count { color: var(--text); }

/* 11: genre legend, readable */
.genre-legend { margin: 0 0 8px; font-size: 0.9rem; color: var(--text); opacity: 0.85; line-height: 1.4; }

/* --- from the UX audit, part c --- */
/* ===== UX fixes batch C (lead merges into site.css) ===== */

/* 3. Book page tabs: wrap onto two lines on phones instead of scrolling sideways */
@media (max-width: 640px) {
  .book-tabs { flex-wrap: wrap; overflow: visible; gap: 0 2px; }
  .book-tabs a { flex: 1 1 auto; text-align: center; padding: 10px 8px; }
}

/* 5. Short "Saved" note moved next to the thing you just changed by static/notice.js */
.notice.near-action { margin: 8px 0; font-size: 0.9rem; padding: 6px 10px; }
.card .notice.near-action { position: absolute; left: 4px; right: 4px; top: 40px; margin: 0; z-index: 3; font-size: 0.8rem; text-align: center; }
.card { position: relative; }
.card:target .card-cover { outline: 2px solid var(--text); outline-offset: 2px; }

/* 8. Shelf badge with words; my rating on cards; sort form; shelves fold on phones */
.card .my-rating { color: var(--link); }
.sort-form { display: flex; gap: 8px; align-items: center; }
.sort-form select { font: inherit; }
.shelves-fold > summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
@media (min-width: 801px) { .shelves-fold > summary { display: none; } }

/* 12. Hero: authors list that folds */
.more-authors { display: inline; }
.more-authors > summary { display: inline; cursor: pointer; color: var(--link); }
.more-authors[open] > summary { margin-right: 6px; }

/* 15. Rating slider greyed out until you rate */
#star-range.unrated { opacity: 0.45; }
#star-number { min-width: 5.5em; }

/* --- from the UX audit, part d --- */
/* Phone tap targets (44px) and top-bar search. Merge into site.css after the last @media (max-width: 900px) rules. */
@media (max-width: 900px) {
  /* Top bar: row 1 = logo (left), light/dark + Menu (right); row 2 = full-width search box.
     Explicit "order" keeps the opened menu list (.menu-links) below the search box. */
  .topbar .logo { order: 1; margin-right: auto; display: inline-flex; align-items: center; min-height: 44px; }
  .topbar .theme-switch { order: 2; }
  .topbar .menu-toggle { order: 3; }
  .topbar .topsearch { order: 4; flex: 1 1 100%; width: 100%; }
  .topbar .topsearch input[type="search"] { width: 100%; min-height: 44px; box-sizing: border-box; }
  .topbar .menu-links { order: 5; }

  /* Buttons in the bar */
  .topbar .theme-switch, #theme-toggle { width: 44px; height: 44px; min-width: 44px; padding: 0; }
  .topbar .menu-toggle, button.ghost.menu-toggle { min-height: 44px; min-width: 44px; padding-top: 0; padding-bottom: 0; }
  .nav-drop summary { padding-top: 12px; padding-bottom: 12px; min-height: 44px; box-sizing: border-box; }
  .menu-links button.ghost, .menu-links form button.ghost { min-height: 44px; }

  /* Grid/List switch and Filters button */
  .switch a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; box-sizing: border-box; }
  .filter-toggle { min-height: 44px; }

  /* Genre chips (home) and filter genre buttons / pills */
  .genre-links .tag { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; }
  .pills span { display: flex; align-items: center; min-height: 44px; box-sizing: border-box; }
  .pills a.tag { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; }
  .search-tabs a { display: inline-flex; align-items: center; min-height: 44px; }

  /* Card title links: taller hit area without moving the text (padding cancelled by negative margin) */
  .card a.title { padding: 10px 0; margin-top: -4px; margin-bottom: -10px; }
}

@media (max-width: 900px) and (pointer: coarse) {
  /* Card "+": 36px look, 44px hit area via an invisible overlay */
  .card-add button { position: relative; }
  .card-add button::before { content: ""; position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); }
}

/* Home rows on phones: keep "See all →" on one line; swiping replaces the arrow buttons. */
.shelf-tools a { white-space: nowrap; }
@media (max-width: 640px) {
  .shelf-tools .arrow { display: none; }
  .shelf-head { align-items: flex-start; }
}

/* --- News page (/news/) --- */
.news-sources { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.news-sources a { padding: .35rem .8rem; border: 1px solid currentColor; border-radius: 0; text-decoration: none; opacity: .75; min-height: 44px; display: inline-flex; align-items: center; box-sizing: border-box; }
.news-sources a[aria-current="page"] { opacity: 1; font-weight: 600; }
.news-page-list { list-style: none; padding: 0; margin: 0; }
.news-page-list .news-more-item { padding: 1rem 0; text-align: center; list-style: none; }
.news-more { display: inline-block; padding: .6rem 1.4rem; min-height: 44px; box-sizing: border-box; border: 1px solid currentColor; border-radius: 0; text-decoration: none; }

/* --- News cards (home "From around the web" and /news/): the whole card is the link --- */
.news-page { max-width: 64rem; margin: 0 auto; }
.news-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.news-list > li { display: flex; }
.news-page-list .news-more-item { grid-column: 1 / -1; }
.news-card { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: 0; background: var(--panel); color: var(--text); text-decoration: none;
  transition: border-color .15s ease, transform .15s ease; }
.news-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.news-card:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.news-meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); min-width: 0; }
.news-source { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.news-when { margin-left: auto; white-space: nowrap; }
.news-badge { flex: none; display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 0;
  font-size: 0.7rem; font-weight: 700; letter-spacing: .02em; color: #fff; background: #5d6873; }
.news-title { font-size: 1.02rem; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.news-site { margin-top: auto; font-size: 0.78rem; color: var(--muted); }
.news-card:hover .news-title { color: var(--link); }
.src-book-riot { background: #d9480f; }
.src-literary-hub { background: #2f6690; }
.src-the-new-york-times { background: #3a3a3a; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.src-the-guardian { background: #052962; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.src-npr-books { background: #c8102e; }
.src-reactor { background: #6d3fc4; }
@media (prefers-reduced-motion: reduce) { .news-card { transition: none; } .news-card:hover { transform: none; } }

/* --- Staff dashboard (/staff/dashboard/) --- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.dash-grid section { min-width: 0; }
.dash-grid .chart { max-height: 22rem; overflow-y: auto; }
.dash-note { font-size: .9rem; opacity: .8; }

/* Reading text (descriptions, reviews, discussions, bios) in the serif. DM Mono (--font-mono) is ready for numbers and labels from M80 on. */
.book-description, .review > p, .review details, .post-text, .author-bio, .list-description { font-family: var(--font-serif); }
.book-description .wiki-credit, .review summary, .post-text summary { font-family: var(--font-sans); }

/* ===== Restyle M80: top bar, footer and shared pieces (docs/design-rules.md) =====
   Square corners, 1.5 px ink lines, ochre only for the chosen state, ink for the main button. */
h1 { font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
h2, h3 { letter-spacing: -0.01em; }
a:hover { text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Small label in mono capitals ("EXPLORE", "01 / READING NOW"). */
.section-label { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text); }

/* Buttons: ink fill for the main action, a plain ink line for the rest. */
button, a.button, .start-discussion > summary { background: var(--text); color: var(--bg); border: 1.5px solid var(--text); }
button.ghost, a.button.ghostlink, .panel-more.as-button > summary, .action-link, .buy-menu a, .shop-links a,
.edition-filters button, .edition-filters select, .editions-more {
  background: transparent; color: var(--text); border: 1.5px solid var(--text); }
button.ghost:hover, a.button.ghostlink:hover, .action-link:hover, .buy-menu a:hover, .shop-links a:hover { background: var(--raised); }
button.ghost.danger { color: var(--danger); border-color: var(--danger); }
.edition-filters button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Fields: no fill, an ink line, tall enough to tap. */
input[type="search"], input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], select, textarea {
  background: transparent; border: 1.5px solid var(--text); min-height: 42px; }
select { background: var(--bg); }        /* the open list needs a ground */

/* Tags and chips: a thin ink frame, no fill. */
.tag { background: transparent; border: 1.5px solid var(--text); padding: 1px 10px; }
.tag.small { border-color: var(--border); }
.tag.year-badge { background: transparent; border-color: var(--accent); color: var(--text); }
.tag.year-badge.rated { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pills span, .genre-pill button, .tabs a, .filter-chip, .people li a, .news-sources a, .news-more, .series-status, .spoiler-tag {
  border-width: 1.5px; }
.pills span, .genre-pill button, .tabs a, .filter-chip { border-color: var(--text); background: transparent; }
.genre-pill button:hover, .filter-chip:hover { background: var(--raised); }
.genre-pill.in button, .pills input:checked + span { background: var(--accent); border-color: var(--text); color: var(--on-accent); }
/* Left out: dashed line and a red strike through the word. */
.genre-pill.out button { background: transparent; border: 1.5px dashed var(--text); color: var(--text); font-weight: 500;
  text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2.5px; }
.switch { border: 1.5px solid var(--text); }
.switch a { color: var(--text); }
.switch a + a { border-left: 1.5px solid var(--text); }

/* Page numbers: squares; the current page is filled with ink. */
.pager { gap: 6px; align-items: center; }
.pager .pages { gap: 6px; }
.pager a, .pager strong { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px;
  padding: 0 10px; border: 1.5px solid var(--text); color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; }
.pager a:hover { background: var(--raised); text-decoration: none; }
.pager strong { background: var(--text); color: var(--bg); font-weight: 500; }
.pager-note { font-family: var(--font-mono); font-size: 0.8rem; }

/* Tables: ink line under the heading row, thin lines between rows. */
table.plain th { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text); border-bottom: 1.5px solid var(--text); }

/* Messages: an ink frame; "done" is highlighted ochre, a problem gets a dashed red line. */
.notice { background: transparent; border: 1.5px solid var(--text); }
.notice.success { background: var(--accent); color: var(--on-accent); border-color: var(--text); }
.notice.error { border: 1.5px dashed var(--danger); color: var(--danger); }
.progress, .bar { border-radius: 0; }

/* --- Top bar: logo with the ochre mark, plain ink links, underlined search box, one ink line below --- */
.topbar { background: var(--bg); border-bottom: 1.5px solid var(--text); padding: 6px max(16px, calc((100% - 1248px) / 2)); justify-content: flex-start; }
.logo { font-weight: 800; letter-spacing: -0.03em; color: var(--text); }
.logo:hover { text-decoration: none; }
.topbar .logo { font-size: 1.6rem; line-height: 1.2; }
.menu-links .m-main a, .menu-links .m-acct > a, .nav-drop summary { color: var(--text); font-weight: 500; }
.menu-links .m-main a:hover, .menu-links .m-acct > a:hover, .nav-drop summary:hover { text-decoration: none; box-shadow: inset 0 -2px 0 var(--red); }
.menu-links a[aria-current="page"] { font-weight: 800; box-shadow: inset 0 -4px 0 var(--red); }
.nav-drop li a, .nav-drop .linklike { color: var(--text); }
.nav-drop li a:hover, .nav-drop .linklike:hover { background: var(--raised); text-decoration: none; }
.topsearch { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1.5px solid var(--text); }
.topsearch .search-icon { flex: none; }
.topsearch input[type="search"] { flex: 1; min-width: 0; min-height: 0; margin: 0; padding: 8px 0; border: 0; background: transparent; font-size: 1.05rem; }
.topsearch input[type="search"]:focus-visible { outline: none; }
.topsearch:focus-within { box-shadow: 0 1.5px 0 var(--text); }   /* the line doubles while you type */
.search-key { flex: none; font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.4; border: 1.5px solid var(--text); padding: 0 6px; }
.topsearch:focus-within .search-key { display: none; }
.search-list { background: var(--bg); border: 1.5px solid var(--text); }
.search-head { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.1em; color: var(--text); }
.theme-switch { border-radius: 0; color: var(--text); }
@media (min-width: 901px) {
  .topbar { gap: 8px 22px; padding-top: 0; padding-bottom: 0; }
  .menu-links .m-main a, .menu-links .m-acct > a, .nav-drop summary { display: inline-block; padding: 18px 0 16px; }
  .topsearch { flex: 1 1 240px; max-width: 420px; }
  .theme-switch { width: 40px; height: 40px; }
  .nav-drop > ul { background: var(--bg); border: 1.5px solid var(--text); }
}
@media (max-width: 900px), (pointer: coarse) { .search-key { display: none; } }
@media (max-width: 900px) {
  .topsearch input[type="search"] { min-height: 42px; }
  .menu-links a[aria-current="page"] { box-shadow: none; text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; }
  .menu-links li + li { border-top-color: var(--text); }
}

/* --- Footer: a quiet strip on the paper, one ink line above --- */
.footer { border-top: 1.5px solid var(--text); padding: 28px 16px 36px; font-size: 0.95rem; color: var(--muted); }
.footer-inner { max-width: 1248px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 20px 40px; }
.footer-logo { flex: 0 0 150px; font-size: 1.25rem; }
.footer-body { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 20px 32px; max-width: none; margin: 0; }
.footer .footer-h { margin: 0 0 4px; }
.footer ul { gap: 0; }
.footer li a { display: inline-block; padding: 5px 0; color: var(--text); }
.footer li a:hover { color: var(--text); }
.footer-data { margin: 0; padding-top: 14px; border-top: 1px solid var(--text); text-align: left; font-family: var(--font-mono); font-size: 0.75rem; }
.footer-data a { color: var(--muted); }
@media (max-width: 599px) { .footer-cols { grid-template-columns: 1fr 1fr; } }

/* ===== Restyle M81: cover cards ===== */
/* A cover is an object lying on the page: the only thing with a shadow, plus a faint spine fold on the left. */
.cover-box { position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 2px; background: var(--raised);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 12px 16px -12px rgba(26, 23, 18, 0.55); }
.cover-box::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  box-shadow: inset 5px 0 0 rgba(0, 0, 0, 0.14), inset 6px 0 0 rgba(255, 255, 255, 0.12); }
.cover-box img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.card-figure { position: relative; }

/* Drawn cover: title and author on one of 12 colour pairs, with one shape (covers.py picks the classes).
   Every pair has 4.5 to 1 or better between ground and text; the text stays in the top half, the shape in the bottom. */
.drawn-cover { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 5%; padding: 9% 9% 8% 13%;
  overflow: hidden; container-type: inline-size; text-align: left; background: var(--dc-bg); color: var(--dc-fg); }
.dc-shape { position: absolute; width: 78%; aspect-ratio: 1; background: var(--dc-shape); }
.dc-round .dc-shape { border-radius: 50%; }
.dcs-0 .dc-shape { left: 40%; top: 52%; }
.dcs-1 .dc-shape { left: -26%; top: 58%; }
.dcs-2 .dc-shape { left: 48%; top: 62%; }
.dcs-3 .dc-shape { left: -18%; top: 55%; }
.dc-title, .dc-author { position: relative; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.dc-title { font-size: clamp(12px, 11.5cqw, 30px); line-height: 1.05; -webkit-line-clamp: 3; line-clamp: 3; }
.dc-author { font-family: var(--font-sans); font-size: clamp(9px, 6.5cqw, 14px); font-weight: 600; letter-spacing: 0.04em; line-height: 1.2; -webkit-line-clamp: 2; line-clamp: 2; }
.dcf-0 .dc-title { font-family: var(--font-serif); font-weight: 600; }
.dcf-1 .dc-title { font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.02em; }
.dcf-2 .dc-title { font-family: var(--font-serif); font-weight: 500; font-style: italic; }
.dc-0  { --dc-bg: #1e4d6b; --dc-fg: #f6ebd2; --dc-shape: #e9b44c; }
.dc-1  { --dc-bg: #e2b33c; --dc-fg: #231a0e; --dc-shape: #b77f1b; }
.dc-2  { --dc-bg: #7fa99b; --dc-fg: #14241f; --dc-shape: #dcebdd; }
.dc-3  { --dc-bg: #5a6a3e; --dc-fg: #f3efd9; --dc-shape: #40502c; }
.dc-4  { --dc-bg: #31406b; --dc-fg: #f4ead0; --dc-shape: #c7a24a; }
.dc-5  { --dc-bg: #f0e3d0; --dc-fg: #3b2a1e; --dc-shape: #c98b5e; }
.dc-6  { --dc-bg: #c9302c; --dc-fg: #fff4e0; --dc-shape: #8e1b1b; }
.dc-7  { --dc-bg: #3a1f3d; --dc-fg: #f4e6d8; --dc-shape: #b5476b; }
.dc-8  { --dc-bg: #6e9c9c; --dc-fg: #10201f; --dc-shape: #a9c9c2; }
.dc-9  { --dc-bg: #20242b; --dc-fg: #ede6d6; --dc-shape: #3c4656; }
.dc-10 { --dc-bg: #9fb4c7; --dc-fg: #17212b; --dc-shape: #6f89a2; }
.dc-11 { --dc-bg: #9c5232; --dc-fg: #fbefe2; --dc-shape: #7e3e1f; }

/* Ribbon marker hanging from the top of the cover: on your shelves (Want / Reading 56% / Read / DNF). */
.ribbon { position: absolute; top: -3px; right: 10px; z-index: 3; min-width: 38px; padding: 5px 5px 13px; background: var(--ribbon);
  color: var(--ink); font-size: 0.7rem; font-weight: 800; line-height: 1.1; text-align: center; white-space: nowrap;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 8px), 0 100%); }

/* "+" (Want to read) sits on the cover's bottom-right corner, paper on the picture. */
.card-add { position: absolute; right: 8px; bottom: 8px; z-index: 3; margin: 0; }
.card-add button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 2px;
  background: var(--paper); color: var(--ink); font-size: 1.35rem; font-weight: 500; line-height: 1; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.card-add button:hover { background: var(--accent); }
.card-add button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Restyle M82: home page ===== */
/* Numbered sections: a small label on the left ("01 / Be fussy"; the number is counted here), the content on the right. */
.home { counter-reset: home; }
.home-sec { counter-increment: home; display: flex; flex-wrap: wrap; gap: 16px 40px; padding: 28px 0 44px; border-top: 1.5px solid var(--text); }
.home > .home-sec:first-child { border-top: 0; padding-top: 12px; }
.home-label { flex: 0 0 150px; margin: 0; padding-top: 6px; }
.home-label::before { content: counter(home, decimal-leading-zero) " / "; }
.home-body { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.home-hero { padding: 24px 0 36px; }
.home-hero h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); margin: 0 0 12px; }
.home-hero p { font-size: 1.15rem; max-width: 46rem; margin: 0 0 16px; }

/* 01: the live count and the genre buttons */
.fit-form { display: flex; flex-direction: column; gap: 22px; }
.fit-count { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 18px; line-height: 0.9; }
.fit-number { font-size: clamp(56px, 12vw, 148px); font-weight: 800; letter-spacing: -0.05em; }
.fit-words { font-size: clamp(24px, 3vw, 40px); font-weight: 500; letter-spacing: -0.02em; }
.home-genres { display: flex; flex-wrap: wrap; gap: 8px; }
.home-genres .genre-pill button { min-height: 44px; padding: 0 16px; font-size: 1rem; }
.fit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.see-them { display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 28px; font-size: 1.1rem; font-weight: 700; }
.fit-actions a { color: var(--text); font-weight: 500; padding: 12px 0; }
.fit-hint { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.quick-picks { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.quick-picks a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* 02: reading now, two columns */
.reading-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 28px 48px; }
.reading-item { display: flex; gap: 18px; align-items: center; }
.reading-item .cover-box { flex: 0 0 60px; }
.reading-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.reading-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); }
.read-line { height: 4px; background: var(--border); margin-top: 4px; }
.read-line span { display: block; height: 100%; background: var(--red); }
.reading-words .reading-form { font-family: var(--font-mono); font-size: 0.8rem; gap: 6px 10px; }
.reading-words .reading-form label { font-size: 0.8rem; color: var(--text); }
.reading-words .reading-form input[type="number"] { width: 76px; min-height: 36px; font-family: var(--font-mono); }
.reading-words .reading-form button { min-height: 36px; padding: 0 14px; font-family: var(--font-sans); }
.reading-percent { font-weight: 500; }

/* First row: number one big, then 2 to 5 */
.top-five { display: flex; flex-wrap: wrap; gap: 36px 48px; }
.top-one { flex: 1 1 420px; min-width: 0; display: flex; flex-wrap: wrap; gap: 24px; }
.top-one-cover { flex: 0 0 230px; }
.top-one-text { flex: 1 1 160px; display: flex; flex-direction: column; gap: 10px; }
.big-rank { font-size: clamp(72px, 9vw, 120px); font-weight: 800; letter-spacing: -0.06em; line-height: 0.8; }
.top-one h3 { margin: 8px 0 0; font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.top-one h3 a, .top-title { color: var(--text); }
.top-by { font-size: 1.1rem; color: var(--muted); }
.top-rating { font-family: var(--font-mono); font-size: 0.875rem; }
.top-list { flex: 1 1 340px; min-width: 0; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.top-list li { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-top: 1px solid var(--text); }
.top-rank { flex: 0 0 62px; font-size: 2.75rem; font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.top-cover { flex: 0 0 48px; }
.top-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.top-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.top-add { margin: 0; }
.top-add button { width: 44px; height: 44px; padding: 0; background: transparent; color: var(--text); font-size: 1.4rem; line-height: 1; }
.top-add button:hover { background: var(--accent); color: var(--on-accent); }
.top-status { font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap; }
@media (max-width: 640px) {
  .top-one-cover { flex-basis: 150px; }
  .top-list li { gap: 12px; }
  .top-rank { flex-basis: 40px; font-size: 2rem; }
  .home-label { flex-basis: 100%; }
}

/* The shelf: one spine per main genre, wider for bigger genres; plain links to Browse. */
.genre-shelf { display: flex; align-items: flex-end; gap: 6px; overflow-x: auto; padding-top: 14px; border-bottom: 6px solid var(--text); }
.spine { flex-shrink: 1; flex-basis: 0; min-width: 38px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 0; border-radius: 2px 2px 0 0; box-shadow: inset 0 0 0 1px rgba(26, 23, 18, 0.3); transition: transform 0.15s ease; }
.spine:hover { transform: translateY(-10px); text-decoration: none; }
.spine:focus-visible { outline-offset: -4px; }
.spine-bands { flex: none; width: 100%; height: 9px; border-top: 2px solid currentColor; border-bottom: 1px solid currentColor; opacity: 0.55; }
.spine-name { flex: 1 1 auto; min-height: 0; overflow: hidden; text-overflow: ellipsis; writing-mode: vertical-rl; white-space: nowrap;
  font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; }
.spine-count { flex: none; font-family: var(--font-mono); font-size: 0.625rem; }
.spine-0 { background: var(--text); color: var(--bg); }
.spine-1 { background: var(--panel); color: var(--text); }
.spine-2 { background: var(--red); color: var(--paper); }
.spine-3 { background: var(--muted); color: var(--bg); }
.spine-4 { background: var(--accent); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .spine { transition: none; } .spine:hover { transform: none; } }
/* Genre buttons on the home page: folded to two rows plus a faded peek of the third (home_count.js). */
.home-genres.folded { max-height: 126px; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 76%, transparent); mask-image: linear-gradient(to bottom, #000 76%, transparent); }
.genre-more { align-self: flex-start; margin-top: -10px; min-height: 44px; }

/* ===== Restyle M83: book page, below the top ===== */
.book-side { gap: 32px; }
.buy-menu p { gap: 0; flex-direction: column; }
.buy-menu a { display: flex; justify-content: space-between; padding: 12px 0; border: 0; border-top: 1px solid var(--text); background: none; font-size: 1.05rem; font-weight: 500; }
.buy-menu a:last-child { border-bottom: 1px solid var(--text); }
.buy-menu a:hover { background: none; text-decoration: underline; text-decoration-color: var(--red); }
.buy-menu[open] { max-width: 420px; }
.review-form { background: none; border: 0; border-top: 1.5px solid var(--text); padding: 16px 0 0; }
.review { border-top-color: var(--text); }
.review header { font-family: var(--font-mono); font-size: 0.8rem; }
.review header strong { font-family: var(--font-sans); font-size: 1rem; }
.facts-list { border-top: 1.5px solid var(--text); padding-top: 14px; }
.discussion-list a { background: none; border: 0; border-top: 1px solid var(--text); padding: 12px 0; }
.discussion-list a:hover { background: none; text-decoration: underline; text-decoration-color: var(--red); }
.tag-columns h3 { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }
.book-similar .home-label::before { content: none; }   /* a label without a number */
.book-similar { counter-increment: none; }

.book-actions .panel-more[open]:not(.as-button) { flex-basis: 100%; }   /* without the script it folds open under the buttons */
/* The links under the shelf buttons are plain words (an earlier rule gave them the outlined-button look). */
.book-actions .action-link, .book-actions .panel-more > summary, .book-actions .panel-more.as-button > summary {
  padding: 10px 0; border: 0; background: none; font-weight: 500; }
.book-actions .action-link:hover, .book-actions .panel-more > summary:hover { background: none; }

/* ===== Restyle M84: browse and search ===== */
/* Above the columns: the big count, sort and Grid/List, then the chips. */
.browse-head { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }
.browse-head .toolbar { margin: 0; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.browse-count, .toolbar .browse-count { margin: 0; flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 18px;
  font-size: inherit; line-height: 0.9; min-width: 0; }
.big-count { font-size: clamp(56px, 10vw, 124px); font-weight: 800; letter-spacing: -0.05em; }
.count-words { font-size: clamp(22px, 3vw, 40px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
.search-results .browse-count { margin-bottom: 24px; }
.toolbar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.sort { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); }
.sort select { min-height: 44px; font-family: var(--font-sans); font-size: 0.95rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.switch a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; font-size: 0.95rem; font-weight: 600; }

/* Chips: ochre for a yes filter, dashed with a red strike for something left out. */
.filter-chips { gap: 8px; margin: 0; }
.filter-chip { min-height: 40px; padding: 0 12px; gap: 10px; background: var(--accent); color: var(--on-accent); border: 1.5px solid var(--text);
  font-size: 0.95rem; font-weight: 700; }
.filter-chip:hover { background: var(--accent); text-decoration: underline; }
.filter-chip.no { background: transparent; color: var(--text); border-style: dashed; font-weight: 500; }
.filter-chip.no:hover { background: var(--raised); }
.filter-chip.no s { text-decoration-color: var(--red); text-decoration-thickness: 2.5px; }
.filter-chip-clear { color: var(--text); font-weight: 600; padding: 10px 6px; }

/* The filter panel without a box: groups separated by thin lines, small mono labels. */
.discover { grid-template-columns: 270px minmax(0, 1fr); gap: 36px 40px; padding-top: 28px; border-top: 1.5px solid var(--text); }
.filters { background: none; border: 0; padding: 0; gap: 0; }
.filters > fieldset, .filters > label, .filters > details, .filters > .filter-buttons { padding: 20px 0; border-top: 1px solid var(--text); }
.filters > :first-child { border-top: 0; padding-top: 0; }
.filters fieldset > legend { float: left; width: 100%; margin: 0 0 10px; }
.filters fieldset > legend + * { clear: both; }
.filters legend, .filters > label, .filters details.avoid > summary { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text); }
.filters details.avoid > summary { margin: 0; }
.filters details.avoid[open] > summary { margin-bottom: 10px; }
.filters input, .filters select, .filters .pills span, .filters .genre-pill button { font-family: var(--font-sans); letter-spacing: 0; text-transform: none; }
.filters .genre-legend { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); opacity: 1; }
.filters .filter-buttons { gap: 16px; }
.filters .filter-buttons button { min-height: 52px; flex: 1; font-size: 1.05rem; }
@media (max-width: 800px) {
  .discover { grid-template-columns: minmax(0, 1fr); border-top: 0; padding-top: 0; }
  .filters .filter-buttons { background: var(--bg); border-top: 1.5px solid var(--text); }
}

/* Search: result tabs with a red bar under the open one; matched letters highlighted in the dropdown. */
.search-tabs { gap: 0 28px; border-bottom: 1px solid var(--text); margin: 0; }
.search-tabs a { padding: 10px 0 7px; color: var(--muted); font-weight: 600; border-bottom: 4px solid transparent; }
.search-tabs a:hover { color: var(--text); border-bottom-color: var(--border); }
.search-tabs a[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--red); }
.tab-count { font-family: var(--font-mono); }
.search-title mark { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.search-option[aria-selected="true"] { box-shadow: inset 4px 0 0 var(--red); }
.search-option.search-all { color: var(--text); }
.result-list li { border-bottom-color: var(--text); }
.result-list li a { color: var(--text); font-weight: 600; }

/* ===== Restyle M85: the remaining pages ===== */
/* Outlined link-buttons ("button ghost" on a link) look like the other secondary buttons. */
a.button.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--text); }
a.button.ghost:hover { background: var(--raised); text-decoration: none; }

/* Thin lines instead of filled boxes: List view rows, panels, tiles, stat boxes, list cards, news cards, forms. */
.row { background: none; border: 0; border-top: 1px solid var(--text); padding: 18px 0; }
.rows { gap: 0; }
.row h2 a { color: var(--text); }
.panel, .panel-box, .card-box, .tile, .list-cards li, details.tag-form form, .start-here, .lookup-results li {
  background: none; border: 0; border-top: 1.5px solid var(--text); padding: 14px 0; }
.account { background: none; border: 0; border-top: 1.5px solid var(--text); padding: 24px 0; }
.tile:hover { border-color: var(--text); background: none; }
.tile { color: var(--text); }
.stat-tiles { gap: 12px 28px; }
.stat-tiles .tile strong { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.stat-tiles .tile span { font-family: var(--font-mono); font-size: 0.75rem; }
.card-box h2, .panel-box h2 { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }
.chart-label { color: var(--text); }
.chart-number { font-family: var(--font-mono); }

/* My books: the shelf list on the left. */
.shelf-links a { padding: 8px 10px; }
.shelf-links span { font-family: var(--font-mono); font-size: 0.8rem; opacity: 1; }

/* Series reading order: the number big like a ranking; "next to read" without the coloured side bar. */
.series-row { border-top-color: var(--text); }
.series-num { color: var(--text); font-weight: 800; letter-spacing: -0.04em; }
.series-next { background: var(--raised); border-left: 0; }
.series-status { border: 1.5px solid var(--text); font-family: var(--font-mono); font-size: 0.75rem; }
.series-next-mark { border-radius: 0; font-family: var(--font-mono); font-weight: 500; }

/* Forum: boards on thin ink lines; the open tab with the red bar. */
.board-list a { border-bottom-color: var(--text); color: var(--text); }
.board-list a > span:first-child > :first-child { font-weight: 700; }
.forum-tabs { gap: 0 24px; border-bottom: 1px solid var(--text); }
.forum-tabs a { padding: 10px 0 7px; color: var(--muted); font-weight: 600; border-bottom: 4px solid transparent; }
.forum-tabs a.current { color: var(--text); text-decoration: none; border-bottom-color: var(--red); }

/* News: cards become ruled entries; the chosen source is ochre. */
.news-card { background: none; border: 0; border-top: 1.5px solid var(--text); padding: 14px 0; }
.news-card:hover { transform: none; }
.news-card:hover .news-title { color: var(--text); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.news-badge { border-radius: 0; }
.news-sources a { border-width: 1.5px; opacity: 1; color: var(--text); }
.news-sources a[aria-current="page"] { background: var(--accent); color: var(--on-accent); border-color: var(--text); }
.news-more { border: 1.5px solid var(--text); color: var(--text); }
.news-meta, .news-site { font-family: var(--font-mono); font-size: 0.72rem; }

/* People and feed */
.people li a { border: 1.5px solid var(--text); background: none; }
.feed-line { border-top-color: var(--text); }

/* While a cover picture loads (or when it never does) the drawn cover behind it shows: the picture has no ground of its own. */
.cover-box img, .card .cover-box img, .row .cover-box img, .hero-cover .cover-box img, .reading img { background: transparent; }
.cover-box img[hidden] { display: none; }

/* ===== Restyle M86: check at phone and desktop size ===== */
/* Awards index: long prize names wrap instead of pushing the page sideways. */
.award-list { grid-template-columns: minmax(0, 1fr); }
.award-list li { overflow-wrap: anywhere; }
/* The genre shelf fits a wide screen without scrolling (25 spines). */
@media (min-width: 1100px) { .genre-shelf { gap: 5px; } .spine { min-width: 30px; } }
@media (max-width: 640px) {
  /* An odd last fact takes the whole row, so the lines close. */
  .hero-facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
/* Phone tap targets, the rest (44 px). */
@media (max-width: 900px) {
  .footer li a, .quick-picks a, .shelf-tools a, .tabs a { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; }
  .genre-pill button { min-height: 44px; }
  .panel-dialog button { min-height: 44px; }
  .reading-form button, .reading-form input[type="number"], .reading-words .reading-form button,
  .reading-words .reading-form input[type="number"], input[type="file"] { min-height: 44px; }
  main details:not(.more):not(.more-authors):not(.nav-drop) > summary { padding-top: 10px; padding-bottom: 10px; }
  /* Small chips keep their look; an unseen margin makes them easier to hit. */
  .hero-chips a.tag, .badges a.tag { position: relative; }
  .hero-chips a.tag::after, .badges a.tag::after { content: ""; position: absolute; inset: -10px 0; }
}

/* ===== M87 shelf pop-up and home titles ===== */
/* The pop-up behind the "+" on a cover (static/shelf_pick.js): pick the shelf. */
.shelf-pick { width: min(360px, calc(100vw - 32px)); padding: 18px; border: 1.5px solid var(--text); border-radius: 0;
  background: var(--bg); color: var(--text); }
.shelf-pick::backdrop { background: rgba(0, 0, 0, 0.55); }
.shelf-pick h2 { margin: 0 0 14px; font-family: var(--font-sans); font-size: 1.15rem; line-height: 1.2; overflow-wrap: anywhere; }
.shelf-pick-hint { margin: 0 0 4px; font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; color: var(--muted); }
.shelf-pick-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.shelf-pick-choices button { width: 100%; min-height: 44px; border: 1.5px solid var(--text); border-radius: 0;
  background: transparent; color: var(--text); font: inherit; font-weight: 600; text-align: left; padding: 0 14px; cursor: pointer; }
.shelf-pick-choices button:hover { background: var(--accent); color: var(--on-accent); }
.shelf-pick-choices button:focus-visible, .shelf-pick-close:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.shelf-pick-close { width: 100%; min-height: 44px; }

/* Trending list: the shelf mark sits in the same 44 px square as the "+", so the title never loses width. */
.top-list .top-add, .top-list .top-status { flex: 0 0 44px; width: 44px; height: 44px; }
.top-status { display: grid; place-items: center; font-family: var(--font-mono); font-size: 1.1rem; border: 1.5px solid var(--text); }
.top-words { min-width: 0; }
.top-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }

/* Long titles on the home page: smaller when long (filter title_size; Japanese signs count double), never wider than their column. */
.top-one-text { min-width: 0; }
.top-one h3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
.top-one h3.title-long { font-size: clamp(1.3rem, 2vw, 1.6rem); line-height: 1.1; }
.top-one h3.title-xlong { font-size: clamp(1.1rem, 1.6vw, 1.3rem); line-height: 1.15; }
.reading-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.card .title { overflow-wrap: anywhere; }

/* ===== M87 audit fixes ===== */
/* Filter panel on a computer: bigger genre buttons and pills, and tick boxes you can hit (phones already have 44 px). */
@media (min-width: 901px) {
  .filters .genre-pill button, .filters .pills span { display: flex; align-items: center; box-sizing: border-box;
    min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
}
.filters label.check { min-height: 32px; cursor: pointer; }   /* the whole line is clickable */
.filters label.check input { width: 18px; height: 18px; flex: none; }

/* "More filters": the less used filters, folded on phones (static/filters.js). Same thin lines as the rest of the panel. */
.filters .more-filters > summary { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text); cursor: pointer; padding: 8px 0; }   /* stays a list item, so the ▸ marker shows */
.filters .more-filters > fieldset, .filters .more-filters > label, .filters .more-filters > details { padding: 20px 0; border-top: 1px solid var(--text); }
.filters .more-filters[open] > summary { margin-bottom: 20px; }
.filters .more-filters > label { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); }
.filters .more-filters > details.avoid > summary { margin: 0; }
@media (max-width: 900px) { .filters .more-filters > summary { padding: 14px 0; } }

/* Home shelf: the soft spine has its own setting (--spine-soft), so it shows on the dark page too; ink label on it. */
.spine-1 { background: var(--spine-soft); color: var(--ink); }

/* ===== M87 book page ===== */
/* Long titles get smaller so they don't fill the whole screen (class from the title_size filter). */
.book-head h1.title-long { font-size: clamp(2rem, 4.5vw, 3.6rem); letter-spacing: -0.02em; line-height: 1.1; }
.book-head h1.title-xlong { font-size: clamp(1.6rem, 3vw, 2.4rem); letter-spacing: -0.01em; line-height: 1.1; }
/* "Your rating": five square buttons next to the shelf buttons; the chosen one is filled ochre. */
.quick-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.quick-rating fieldset { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; border: 0; margin: 0; padding: 0; min-width: 0; }
.quick-rating legend { float: left; margin: 0 10px 0 0; padding: 0; }
.rate-square { width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--text); border-radius: 0; background: transparent;
  color: var(--text); font-family: var(--font-mono); font-size: 1rem; font-weight: 500; cursor: pointer; }
.rate-square:hover { background: var(--raised); }
.rate-square.on, .rate-square.on:hover { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.rate-exact { margin-left: 6px; font-family: var(--font-mono); font-size: 0.85rem; }
.rate-finer { color: var(--text); }
/* Right-hand column: outlined tag links, a ruled shop list, and your lists with a Remove button. */
.side-tags .tag-columns { grid-template-columns: 1fr; gap: 14px; }
.side-tags .tag { background: none; border: 1.5px solid var(--text); padding: 6px 12px; font-weight: 500; }
.side-tags .tag:hover { background: var(--raised); text-decoration: none; }
.side-tags details.more > summary.tag { font-family: var(--font-mono); }
.buy-list { list-style: none; margin: 0 0 8px; padding: 0; }
.buy-list a { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--text); color: var(--text); font-size: 1.05rem; font-weight: 500; }
.buy-list li:last-child a { border-bottom: 1px solid var(--text); }
.buy-list a:hover { text-decoration: underline; text-decoration-color: var(--red); }
.my-lists-with-book { list-style: none; margin: 0 0 12px; padding: 0; }
.my-lists-with-book li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--text); }
.my-lists-with-book li:last-child { border-bottom: 1px solid var(--text); }
.my-lists-with-book form { margin: 0; }
.tag-forms { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--text); }
@media (max-width: 900px) {
  .side-tags .tag, .side-tags details.more > summary.tag, .my-lists-with-book button, .rate-finer { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; }
  .buy-list a { min-height: 44px; box-sizing: border-box; }
}

/* ===== M87 lead review ===== */
/* A long name without spaces (a series, an author) wraps instead of pushing the book page sideways. */
.book-head { min-width: 0; }
.hero-by, .hero-by a { overflow-wrap: anywhere; }

/* ===== M88 feedback round ===== */
/* Standing filters: one quiet grey line, no box (not on the home page). */
.standing-note { margin: 0 0 14px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.standing-note a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.standing-note a:hover { color: var(--text); }

/* Home 01: the tap hint sits above the genre buttons it explains; "See them" and "More filters" side by side;
   the quick picks are their own small group under a thin line. */
.fit-form > .fit-hint { margin: 0 0 -8px; }
.fit-actions .more-filters-link { min-height: 52px; display: inline-flex; align-items: center; padding: 0 22px; font-weight: 600; }
.quick-picks { display: block; margin: 8px 0 0; padding-top: 18px; border-top: 1px solid var(--border); }
.quick-picks h3 { margin: 0 0 10px; }
.quick-picks p { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.quick-picks a.tag { margin: 0; padding: 6px 12px; text-decoration: none; background: transparent; border: 1.5px solid var(--text); color: var(--text); font-weight: 500; }
.quick-picks a.tag:hover { background: var(--accent); color: var(--on-accent); }

/* Book page actions, as in the mock-up: shelf buttons; then "Your rating"; then one row of plain links. */
.book-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px 28px; }
.book-actions .panel { display: contents; }
.book-actions .status-buttons, .book-actions .quick-rating { flex: 0 0 100%; }
.book-actions .panel-more, .book-actions .action-links { flex: 0 0 auto; }
.book-actions .action-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 28px; }
.book-actions .panel-more.as-button > summary, .book-actions .action-link { font-size: 1rem; font-weight: 500; }
.quick-rating .rate-finer { color: var(--muted); }

/* "Add to a list": a small drop-down under its link. */
.list-menu { position: relative; }
.list-menu > summary { list-style: none; cursor: pointer; }
.list-menu > summary::-webkit-details-marker { display: none; }
.list-menu > summary::after { content: " ▾"; font-size: 0.8em; }
.list-menu-box { position: absolute; z-index: 20; top: 100%; left: 0; width: min(340px, calc(100vw - 32px)); padding: 12px 14px;
  background: var(--bg); border: 1.5px solid var(--text); display: flex; flex-direction: column; gap: 8px; }
.list-menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
.list-menu-row > span { min-width: 0; overflow-wrap: anywhere; }
.list-menu-row button { min-height: 40px; padding: 0 14px; flex: none; }
.list-menu-new { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.list-menu-new input[type="text"] { flex: 1; min-width: 0; margin: 0; min-height: 40px; }

/* Top page: genre buttons with a "leave out" state, like Browse. */
.top-genres { margin: 0 0 16px; }
.top-genres .fit-hint { margin: 8px 0 0; }
.top-genres .fit-hint a { color: var(--link); }
@media (max-width: 900px) { .list-menu-row button, .list-menu-new input[type="text"] { min-height: 44px; } }
.top-genres .genre-pill button { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
@media (max-width: 900px) { .top-genres .genre-pill button { min-height: 44px; } }

/* Browse: every filter group folds (M88). The heading is the button; "· on" shows a group in use. */
.filters .fgroup { border-top: 1px solid var(--text); }
.filters .fgroup > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  min-height: 44px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); }
.filters .fgroup > summary::-webkit-details-marker { display: none; }
.filters .fgroup > summary::after { content: "+"; font-size: 1.1rem; line-height: 1; }
.filters .fgroup[open] > summary::after { content: "–"; }
.filters .fgroup-on { margin-right: auto; padding-left: 6px; color: var(--link); text-transform: none; letter-spacing: 0; }
.filters .fgroup > fieldset, .filters .fgroup > input { margin: 0 0 18px; }
.filters .fgroup > fieldset > legend + * { clear: none; }
.filters fieldset > legend.visually-hidden { float: none; width: 1px; margin: 0; padding: 0; }

/* ===== M89 consistency pass: the same piece looks the same on every page ===== */
/* Page titles: 2rem everywhere (only the home count, Browse count and the book title are bigger on purpose). */
.toolbar h1 { font-size: 2rem; }
/* Section headings inside a page: 1.5rem, also on Stats and reader pages. */
.shelf-head h2 { font-size: 1.5rem; }
/* Outline buttons: same height and type as the main button, only the fill differs. */
button.ghost, a.button.ghostlink, a.button.ghost { font-size: 0.95rem; font-weight: 600; min-height: 42px; padding: 0 16px; }
a.button.ghostlink, a.button.ghost { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
/* A button that deletes something: a red line, never the ink fill of a main action. */
button.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
button.danger:hover { background: var(--raised); }
/* Text boxes: 1rem type (also stops phones zooming in), whatever label they sit in. */
input[type="search"], input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], select, textarea { font-size: 1rem; }
@media (max-width: 640px) { .toolbar h1 { font-size: 1.6rem; } }
/* Phones: every button 44 px to tap (the M89 sizes above are for a mouse). Small controls with their own rule
   (cover "+", the Update box) keep theirs and have an unseen 44 px hit area. */
@media (max-width: 900px) {
  main button, main button.ghost, main button.danger, main a.button, main a.button.ghost, main a.button.ghostlink,
  .panel-dialog button, .panel-dialog button.ghost, .shelf-pick button { min-height: 44px; }
}

/* ===== M90 feedback round ===== */
/* Home 01: a smaller count, bigger section numbers; the count itself opens the books (no "See them" button). */
.fit-number { font-size: clamp(48px, 9vw, 112px); }
.home-label, .home-label.section-label { font-size: 0.9rem; letter-spacing: 0.08em; }
.fit-link { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 18px; color: var(--text); text-decoration: none; }
.fit-link:hover .fit-words, .fit-link:focus-visible .fit-words { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 6px; }
.fit-arrow { display: inline-block; transition: transform 0.15s ease; }
.fit-link:hover .fit-arrow { transform: translateX(6px); }
@media (prefers-reduced-motion: reduce) { .fit-arrow { transition: none; } }
/* "Or start from": a list of ideas with a short note each, not buttons that look like the genre buttons. */
.start-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 0 24px; }
.start-list li { border-top: 1px solid var(--border); }
.start-list a { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; color: var(--text); text-decoration: none; min-height: 44px; }
.start-title { font-weight: 700; }
.start-title::after { content: " →"; color: var(--link); }
.start-hint { font-size: 0.85rem; color: var(--muted); }
.start-list a:hover .start-title { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* The logo (M96): "Fussy" in the italic reading font, "Reader" heavy in ink, closed by a red-pen full stop. */
/* Only the letters F, u, s, y of the italic reading font at weight 600 (cut with fonttools from Source Serif 4, OFL; see
   static/fonts/OFL-source-serif-4.txt), so the logo does not pull in the whole 51 KB italic file. */
@font-face { font-family: "Fussy Logo"; src: url("fonts/fussy-logo.eaf6f13eab25.woff2") format("woff2"); font-weight: 600; font-style: italic; font-display: swap; }
.logo-mark { font-family: "Fussy Logo", var(--font-serif); font-style: italic; font-weight: 600; letter-spacing: -0.02em; margin-right: 0.04em; }
.logo-dot { color: var(--ribbon); }

/* Light/dark button: the icon in the middle (outline-button padding does not apply to it). */
#theme-toggle, .theme-switch { padding: 0; min-height: 0; display: inline-grid; place-items: center; }
#theme-toggle svg { display: block; }

/* Editions without a cover picture get the same drawn cover as the book. */
.edition-drawn { flex: 0 0 auto; width: 48px; height: 72px; container-type: inline-size; }
.edition-drawn .drawn-cover .dc-title { font-size: 7px; }
.edition-drawn .dc-author { display: none; }

/* A spot named in the address (#reviews, #buy) is not hidden under the top bar. */
[id] { scroll-margin-top: 84px; }
/* Book page: "✕ Remove" closes the row of shelf buttons once the book is on a shelf (asks first). */
.book-actions .status-buttons button.shelf-remove { color: var(--danger); font-weight: 600; }
.book-actions .status-buttons button.shelf-remove:hover { background: var(--raised); }
/* The ribbon and the trending ✓ open the shelf pop-up. */
.ribbon-link { color: inherit; }
.ribbon-link:hover .ribbon, .ribbon-link:focus-visible .ribbon { filter: brightness(1.08); outline: 2px solid var(--text); outline-offset: 1px; }
a.top-status { color: var(--text); text-decoration: none; }
a.top-status:hover { background: var(--raised); }
.shelf-pick-choices button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 800; }
.shelf-pick-choices button[aria-pressed="true"]::before { content: "✓ "; }
.shelf-pick-remove { width: 100%; margin-top: 10px; }
/* Dark: small mono text a little heavier, so thin letters on the dark page stay easy to read. */
:root[data-theme="dark"] :is(.section-label, .fit-hint, .standing-note, .fact-small) { font-weight: 500; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.section-label, .fit-hint, .standing-note, .fact-small) { font-weight: 500; }
}
/* An edition picture sits on its drawn cover, which shows if the picture is missing (covers.js hides a failed picture). */
.edition-drawn .edition-cover { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 1; }
.edition-drawn { position: relative; }
.quick-picks .start-list a { display: flex; align-items: flex-start; }

/* ===== Round 5, M97 (docs/plans/round-5.md) ===== */
/* Home 01: "Show me … but never …, rated … and …", a sentence you fill in. */
.fit-form { gap: 26px; }
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  font-size: clamp(1.3rem, 3vw, 2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; color: var(--text); }
.sentence .joined { margin-left: -10px; }   /* ", rated" sits right after the chip before it */

/* Chips, "+ genre" and the two selects share one shape: square, 1.5px line, small text. */
.sentence .chip, .pick > summary, .sentence select {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px; box-sizing: border-box;
  border: 1.5px solid var(--text); border-radius: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; font-weight: 500; letter-spacing: 0; cursor: pointer; }
.sentence .chip:hover { background: var(--raised); }
.sentence .chip.yes { background: var(--accent); color: var(--on-accent); border-color: var(--on-accent); }
.sentence .chip.yes::before { content: "✓"; }
.sentence .chip.no { border-style: dashed; text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.sentence select { appearance: auto; padding: 0 10px; width: auto; max-width: 100%; margin: 0; }

/* "+ genre" opens a list of tick boxes under it. */
.pick { position: relative; }
.pick > summary { list-style: none; border-style: dashed; color: var(--muted); }
.pick > summary::-webkit-details-marker { display: none; }
.pick > summary:hover, .pick[open] > summary { color: var(--text); background: var(--raised); }
.pick-list { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(460px, calc(100vw - 32px));
  max-height: 320px; overflow: auto; padding: 8px; box-sizing: border-box;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px;
  background: var(--bg); border: 1.5px solid var(--text); font-size: 1rem; font-weight: 500; letter-spacing: 0; }
.pick-list label { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px; cursor: pointer; }
.pick-list label:hover { background: var(--raised); }
.pick-list input { margin: 0; accent-color: var(--accent); }

/* The count, its words and "See the books" on one line, under a rule. */
.fit-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 24px; padding-top: 18px; border-top: 1.5px solid var(--text); }
.fit-row .button { align-self: center; }

/* "Or start from:" one line of plain links (the old tiles are gone). */
.start-from { margin: 0; color: var(--muted); }
.start-from a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.start-from a:hover { text-decoration-color: var(--red); }

/* Phones: one column of 44px rows; the list stays inside the screen. */
@media (max-width: 900px) {
  .sentence .chip, .pick > summary, .sentence select, .fit-row .button { min-height: 44px; }
  .start-from a { display: inline-flex; align-items: center; min-height: 44px; }
  .pick { position: static; }   /* the list lines up with the sentence, not with a "+ genre" near the right edge */
  .sentence { position: relative; }
  .pick-list { left: 0; right: 0; top: auto; width: auto; max-width: none; grid-template-columns: 1fr; }
  .pick-list label { min-height: 44px; }
}

/* ===== Round 5, M91 (docs/plans/round-5.md) ===== */
/* ===== M91 one page frame =====
   Two layouts only. "page-wide" (the default from base.html) uses main's full 1280px.
   "page-read" is one centred column for text and form pages: templates opt in with
   {% block page_class %}page-read{% endblock %}. */
main.page-read { max-width: 760px; }

/* Inside the reading column everything uses the full column width. Older rules made
   some pages narrower or centred them on their own; those limits are lifted here. */
main.page-read .prose,
main.page-read .prose.wide,        /* buddy read page (was 900px) */
main.page-read .review-form,       /* reply and start-discussion forms (was 560px) */
main.page-read .upload { max-width: none; }   /* Goodreads upload box (was 420px) */

/* Login, code, choose-name and account pages: they were a small 380px box centred
   with 40px above it and a line on top. Now they sit in the column like any other page. */
main.page-read .account { max-width: none; margin: 0; border-top: 0; padding: 0; gap: 12px; }

/* ===== Same rhythm for every page title =====
   The page title (h1) is 2rem with no space above; the intro line right under it is soft ink;
   the first section starts the same distance below on every page.
   Left alone on purpose: the home page, the Browse and search big count, the book page. */
main h1:not(.browse-count, .visually-hidden, .home h1, .book-hero h1, .browse-head h1) {
  font-size: 2rem; margin-top: 0; }
/* Title on its own line (not in a toolbar next to buttons): small gap to the intro... */
main h1:not(.browse-count, .visually-hidden, .home h1, .book-hero h1, .browse-head h1, .toolbar > h1) {
  margin-bottom: 12px; }
main h1:not(.browse-count, .visually-hidden, .home h1, .book-hero h1, .browse-head h1, .toolbar > h1) + p {
  margin-top: 0; margin-bottom: 28px; color: var(--muted); }
/* ...and with no intro, the first section starts the same 28px below the title. */
main h1:not(.browse-count, .visually-hidden, .home h1, .book-hero h1, .browse-head h1, .toolbar > h1) + :not(p) {
  margin-top: 28px; }
/* A title inside a toolbar (feed, profile, stats): the toolbar keeps the same 28px gap below. */
main .toolbar:has(> h1:not(.browse-count)) { margin-bottom: 28px; }

/* The account-style forms space their parts with a 12px grid gap, so the title needs no
   margin of its own there; the intro then adds 16px to make the same 28px. */
main.page-read .account > h1 { margin-bottom: 0; }
main.page-read .account > h1 + p { margin-bottom: 16px; }
main.page-read .account > h1 + :not(p) { margin-top: 16px; }

/* Phones: titles a little smaller, the same on every page (was only for toolbar titles). */
@media (max-width: 640px) {
  main h1:not(.browse-count, .visually-hidden, .home h1, .book-hero h1, .browse-head h1) { font-size: 1.6rem; }
}
/* Phones: the reading column adds no side padding of its own beyond main's 16px. */
@media (max-width: 900px) {
  main.page-read { padding-left: 16px; padding-right: 16px; }
}

/* ===== Round 5, M92 (docs/plans/round-5.md) ===== */
/* ===== One genre control: the same buttons on Browse, Top and My filters ===== */
/* The row: buttons start at the left edge of their group and wrap with 8 px gaps. */
.pills.genre-pills { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin: 0; padding: 0; }
/* The holder of each button is not a pill itself (site.css gave ".filters .pills span" padding: that was the indent). */
.pills.genre-pills span.genre-pill { display: block; flex: 0 0 auto; width: auto; min-height: 0; margin: 0; padding: 0;
  border: 0; background: none; }
.pills.genre-pills .genre-pill button { display: inline-flex; align-items: center; box-sizing: border-box; width: auto;
  min-height: 42px; margin: 0; padding: 0 14px; border: 1.5px solid var(--text); border-radius: 0;
  background: transparent; color: var(--text); font-family: var(--font-sans); font-size: 0.95rem; font-weight: 500;
  line-height: 1.2; letter-spacing: 0; text-transform: none; text-align: left; text-decoration: none; }
.pills.genre-pills .genre-pill button:hover { background: var(--raised); }
/* Yes: ochre fill with a tick. */
.pills.genre-pills .genre-pill.in button { background: var(--accent); color: var(--on-accent); border-style: solid; }
.pills.genre-pills .genre-pill.in button::before { content: "✓\00a0"; }
/* No: dashed line, the word struck through in red (no extra mark in front). */
.pills.genre-pills .genre-pill.out button { background: transparent; color: var(--text); border-style: dashed;
  text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2.5px; }
.pills.genre-pills .genre-pill.out button::before { content: none; }
@media (max-width: 900px) { .pills.genre-pills .genre-pill button { min-height: 44px; } }

/* The one hint line (mono, like the home page's), above the buttons on Browse and My filters, below them on Top. */
.genre-hint { margin: 0 0 10px; }
.top-genres .genre-hint { margin: 10px 0 0; }

/* My filters: the language pills beside the genres get the same height and padding. */
@media (min-width: 901px) {
  .standing-form .pills label span { min-height: 42px; padding: 0 14px; font-size: 0.95rem; }
}

/* ===== Top ===== */
/* Heading with Grid/List at its right end, like the Browse heading. */
.top-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin: 0 0 12px; }
.top-head h1 { flex: 1 1 auto; min-width: 0; margin: 0; }
.top-head .switch { flex: none; margin: 0; }

/* On phones the genres fold behind the "Genres" button (static/top_genres.js); on a computer they always show. */
.genre-toggle { display: none; }
@media (max-width: 900px) {
  .genre-toggle:not([hidden]) { display: block; width: 100%; min-height: 44px; margin: 0 0 16px; }
  .top-genres.folded { display: none; }
}

/* ===== Round 5, M93 (docs/plans/round-5.md) ===== */
/* One size for every control (docs/design-rules.md): buttons and text boxes 42px on a computer, 44px on phones,
   square corners, 1.5px ink lines, ochre fill only for something chosen. This file comes after site.css and wins. */

/* --- 1. Sizes ---
   Buttons in the page: 42px tall, the height comes from min-height (padding top/bottom 0, the text sits in the middle).
   Left alone on purpose: cover "+" (.card-add), home row arrows (.arrow), the light/dark button, link-looking buttons
   (.linklike), the rating squares (.quick-rating), page numbers (.pager), the small Update box on the home page
   (.reading-words) and genre buttons/chips, which have their own chip size. */
main :is(button, a.button, input[type="submit"]):not(:where(.card-add *, .arrow, .theme-switch, #theme-toggle, .linklike,
  .quick-rating *, .rate-square, .pager *, .reading-words *, .genre-pill *)) {
  min-height: 42px; padding-top: 0; padding-bottom: 0; border-radius: 0; }
main a.button { display: inline-flex; align-items: center; justify-content: center; }

/* Text boxes and drop-down lists: 42px, 1rem type. Textareas keep their own height. */
main :is(select, input[type="text"], input[type="number"], input[type="search"], input[type="email"]):not(:where(.reading-words *)) {
  min-height: 42px; padding-top: 0; padding-bottom: 0; font-size: 1rem; border-radius: 0; }

/* Rules in site.css that drew a button or box bigger or smaller than 42px. */
.filters .filter-buttons button { min-height: 42px; font-size: 1rem; }        /* "Show results" was 52px */
.sort select, .switch a { min-height: 42px; }                                  /* Browse sort and Grid/List were 44px */
.book-actions .status-buttons button { min-height: 42px; font-size: 1rem; }    /* shelf buttons on the book page were 52px */
.list-menu-row button, .list-menu-new input[type="text"] { min-height: 42px; } /* "Add to a list" was 40px */

@media (max-width: 900px) {
  main :is(button, a.button, input[type="submit"]):not(:where(.card-add *, .arrow, .theme-switch, #theme-toggle, .linklike,
    .quick-rating *, .rate-square, .pager *, .reading-words *, .genre-pill *)),
  main :is(select, input[type="text"], input[type="number"], input[type="search"], input[type="email"]):not(:where(.reading-words *)),
  .filters .filter-buttons button, .sort select, .switch a, .book-actions .status-buttons button,
  .list-menu-row button, .list-menu-new input[type="text"] { min-height: 44px; }
}

/* --- 2. Send buttons as wide as their words, at the start of the form ---
   No weight at all (:where), so the Browse panel, the joined shelf buttons and pop-up lists keep their own widths. */
:where(main form button:not([type="button"], [type="reset"]), main form input[type="submit"]) { width: auto; justify-self: start; }

/* --- 3. Own tick boxes and round-choice boxes (square here, like everything else) ---
   Hidden inputs behind pills and genre buttons are left alone. */
main :is(input[type="checkbox"], input[type="radio"]):not(:where([hidden], .pills *)) {
  appearance: none; -webkit-appearance: none; display: inline-grid; place-items: center; flex: none;
  width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; vertical-align: middle;
  border: 1.5px solid var(--text); border-radius: 0; background: transparent; color: var(--on-accent); cursor: pointer; }
main input[type="checkbox"]:checked:not(:where([hidden], .pills *)) { background: var(--accent); }
main input[type="checkbox"]:not(:where([hidden], .pills *))::before {
  content: "✓"; font-size: 13px; font-weight: 800; line-height: 1; visibility: hidden; }
main input[type="checkbox"]:checked:not(:where([hidden], .pills *))::before { visibility: visible; }
main input[type="radio"]:not(:where([hidden], .pills *))::before {
  content: ""; width: 8px; height: 8px; background: var(--text); visibility: hidden; }
main input[type="radio"]:checked:not(:where([hidden], .pills *))::before { visibility: visible; }
main :is(input[type="checkbox"], input[type="radio"]):focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
main :is(input[type="checkbox"], input[type="radio"]):disabled { opacity: 0.5; cursor: default; }
@media (max-width: 900px) {
  main label:has(> input[type="checkbox"]:not([hidden]), > input[type="radio"]:not([hidden])):not(:where(.pills *)) {
    display: flex; align-items: center; gap: 10px; min-height: 44px; }
}

/* File chooser: the button looks like an outlined button, the file name in soft ink. */
main input[type="file"] { max-width: 100%; color: var(--muted); font: inherit; font-size: 1rem; }
main input[type="file"]::file-selector-button {
  min-height: 42px; margin-right: 12px; padding: 0 16px; border: 1.5px solid var(--text); border-radius: 0;
  background: transparent; color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
main input[type="file"]::file-selector-button:hover { background: var(--raised); }
@media (max-width: 900px) { main input[type="file"]::file-selector-button { min-height: 44px; } }

/* Groups of choices in a form: no browser frame; the heading as a small mono label (like .section-label). */
:where(main form) fieldset:not(:where(.quick-rating, .quick-rating *)) { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
:where(main form) fieldset:not(:where(.quick-rating, .quick-rating *)) > legend {
  padding: 0; margin-bottom: 8px; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text); }
.choices { display: grid; gap: 4px; }
.choices label.check { min-height: 36px; cursor: pointer; }

/* Import page: the Import button as wide as its word, like "Download my library". */
.upload { justify-items: start; }

/* --- 4. Grid/List at the right end of the page heading; under the title on phones --- */
.list-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 20px; align-items: start; margin-bottom: 14px; }
.list-head > * { grid-column: 1; }
.list-head > h1 { margin-top: 0; }
.list-head > .switch { grid-column: 2; grid-row: 1; align-self: center; margin: 0; }
@media (max-width: 640px) {
  .list-head { grid-template-columns: minmax(0, 1fr); }
  .list-head > .switch { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* Reader search: the box grows, the button sits beside it; stacked only on very narrow screens. */
.search-row { display: flex; gap: 8px; align-items: stretch; max-width: 560px; margin: 0 0 20px; }
.search-row input[type="search"] { flex: 1; min-width: 0; width: auto; margin: 0; }
.search-row button { flex: none; }
@media (max-width: 480px) {
  .search-row { flex-direction: column; }
  .search-row button { align-self: flex-start; }
}

/* ===== Round 5, M94 (docs/plans/round-5.md) ===== */
/* Book page fixes: one rating control, quieter badges and award tags, whole rows of similar books, a tidier phone layout. */

/* --- 1. One rating control (reviews/_rating_control.html + static/rating.js), at the top and in the review form --- */
fieldset.rate-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.rate-control[hidden], .rate-control .rate-step[hidden], .rate-fallback[hidden] { display: none; }
.quick-rating fieldset.rate-control legend, fieldset.rate-control legend { float: none; width: 100%; margin: 0 0 8px; padding: 0; }
.rate-squares { display: flex; gap: 4px; }
/* A filled square = ochre; the square after the last full one is filled part of the way for quarters (3.75 = 3 full + 75%). */
.rate-square.full, .rate-square.full:hover { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.rate-square.part.q25 { background: linear-gradient(90deg, var(--accent) 25%, transparent 25%); }
.rate-square.part.q50 { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.rate-square.part.q75 { background: linear-gradient(90deg, var(--accent) 75%, transparent 75%); }
.rate-square.part .rate-n { padding: 0 3px; background: var(--bg); color: var(--text); }   /* the number stays readable on half ochre, half paper */
/* "−¼ 3.75 +¼": two 44px buttons around the value in mono. The ¼ buttons need the script, the value does not. */
.rate-step { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
fieldset.rate-control .rate-nudge { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1.5px solid var(--text); border-radius: 0;
  background: transparent; color: var(--text); font-family: var(--font-mono); font-size: 1rem; cursor: pointer; }
fieldset.rate-control .rate-nudge:hover { background: var(--raised); }
fieldset.rate-control .rate-nudge:disabled { opacity: 0.4; cursor: default; background: transparent; }
.rate-control:not(.ready) .rate-nudge { display: none; }
.rate-value { min-width: 3.2em; text-align: center; font-family: var(--font-mono); font-size: 1rem; }
.rate-control .rate-clear { margin-left: 10px; }
.rate-fallback input { max-width: 8em; }
.review-form fieldset.rate-control { margin-bottom: 4px; }

/* --- 2. Series on its own line under the authors --- */
.hero-series { margin-top: -10px; font-size: 1.1rem; color: var(--muted); overflow-wrap: anywhere; }
.hero-series a { color: var(--text); }

/* --- 3. Award and bestseller tags under the description: the normal outlined tag, no fill --- */
.badges .tag.award { background: transparent; border: 1.5px solid var(--text); color: var(--text); }
.badges .tag.award:hover { background: var(--raised); text-decoration: none; }
.award-kind { margin-right: 4px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* --- 4. Year badges: ink outline and a small ink mark, no ochre (ochre means "you chose this") --- */
.hero-chips .tag.year-badge, .hero-chips .tag.year-badge:hover { background: transparent; border: 1.5px solid var(--text); color: var(--text);
  font-family: var(--font-mono); font-weight: 500; }
.hero-chips .tag.year-badge:hover { background: var(--raised); }
.badge-mark { color: var(--text); font-weight: 700; }

/* --- 5. Similar books: whole rows only. 12 books come from the view; 6 columns on a computer, 4 in between.
   With fewer books, the cards that would start an incomplete last row are hidden (only after the first row).
   On phones they become one row you swipe sideways, like the home page rows. --- */
@media (min-width: 1101px) {
  .book-similar .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .book-similar .grid > :nth-child(6n+7):nth-last-child(-n+5), .book-similar .grid > :nth-child(6n+7):nth-last-child(-n+5) ~ * { display: none; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .book-similar .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .book-similar .grid > :nth-child(4n+5):nth-last-child(-n+3), .book-similar .grid > :nth-child(4n+5):nth-last-child(-n+3) ~ * { display: none; }
}
@media (max-width: 900px) {
  .book-similar .grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 140px; overflow-x: auto; padding-bottom: 10px;
    scroll-snap-type: x proximity; }
  .book-similar .grid > * { scroll-snap-align: start; }
}

/* --- 6. Phones and small tablets: badges, title, authors, series; a small cover beside the facts; shelf buttons, rating, links --- */
@media (max-width: 900px) {
  .book-hero { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px 16px; padding: 4px 0 28px; }
  .book-hero .hero-info, .book-hero .book-head { display: contents; }
  .book-hero .hero-chips { order: 1; grid-column: 1 / -1; gap: 6px; }
  .book-hero .book-head h1 { order: 2; grid-column: 1 / -1; }
  .book-hero .book-head h1:not(.title-long, .title-xlong) { font-size: 2.3rem; }
  .book-hero .hero-by { order: 3; grid-column: 1 / -1; font-size: 1.15rem; }
  .book-hero .hero-series { order: 4; grid-column: 1 / -1; margin-top: -6px; font-size: 1rem; }
  .book-hero .hero-cover { order: 5; grid-column: 1; width: 96px; min-width: 0; flex: none; align-self: start; }
  .book-hero .hero-cover .page-edge { flex-basis: 5px; margin: 3px 0; }
  .book-hero .hero-cover .ribbon { right: 10px; top: -3px; min-width: 30px; padding: 4px 3px 10px; font-size: 0.65rem;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 6px), 0 100%); }
  .book-hero .hero-cover .drawn-cover .dc-title { font-size: 13cqw; }
  .book-hero .book-actions { order: 7; grid-column: 1 / -1; }

  /* The facts stacked on the right of the cover: label above, number below, thin lines between. */
  .book-hero .hero-facts { order: 6; grid-column: 2; align-self: start; grid-template-columns: minmax(0, 1fr); border-top: 0; border-bottom: 0; }
  .book-hero .hero-facts > div, .book-hero .hero-facts > div:first-child { grid-column: auto; padding: 4px 0 6px; border: 0; border-top: 1px solid var(--text); }
  .book-hero .hero-facts > div:first-child { border-top: 1.5px solid var(--text); padding-top: 4px; }
  .book-hero .fact-big { font-size: 1.35rem; }
  .book-hero .hero-facts > div:not(.hero-rating) .fact-small { display: none; }

  /* Shelf buttons: two columns, two rows; "✕ Remove" a quieter full-width row under them (only when on a shelf). */
  .book-actions .status-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
  .book-actions .status-buttons button, .book-actions .status-buttons button + button { width: 100%; min-height: 44px; padding: 0 8px;
    border: 1.5px solid var(--text); font-size: 0.95rem; }
  .book-actions .status-buttons button.shelf-remove { grid-column: 1 / -1; border: 1px solid var(--border); font-weight: 500; }

  /* Rating squares share the row width; the ¼ row sits under them. */
  .quick-rating fieldset.rate-control { width: 100%; gap: 6px; }
  .quick-rating .rate-squares { flex: 1 1 100%; }
  .quick-rating .rate-square { flex: 1 1 0; width: auto; }
  .book-actions { gap: 10px 24px; }

  /* Tabs: one row that scrolls sideways, no visible scrollbar, 44px tall; the current tab keeps its red bar. */
  .book-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: 0 22px; scrollbar-width: none; }
  .book-tabs::-webkit-scrollbar { display: none; }
  .book-tabs a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box;
    padding: 0; text-align: left; white-space: nowrap; font-size: 1rem; }
}

/* ===== Round 5, M95 (docs/plans/round-5.md) ===== */
/* 1. Reader tags index: one outlined tag each, the book count as a small mono number inside it. */
.rtag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.rtag { display: inline-flex; align-items: baseline; gap: 8px; padding: 4px 12px; border: 1.5px solid var(--text);
  background: none; color: var(--text); font-size: 0.9rem; }
.rtag:hover { background: var(--raised); text-decoration: none; }
.rtag-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.rtag-empty { color: var(--muted); border: 1px solid var(--border); }

/* 2. Awards index: ruled lists in columns, name left, number of winners right. */
.award-group { margin-top: 32px; padding-top: 12px; border-top: 1.5px solid var(--text); }
.award-group h2 { font-size: 1.5rem; margin: 0 0 8px; }
.award-group .award-list { display: block; columns: 1; column-gap: 40px; margin: 0 0 8px; }
.award-group .award-list li { break-inside: avoid; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.award-group .award-list a { color: var(--text); font-weight: 600; }
.award-count { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
@media (min-width: 700px) { .award-group .award-list { columns: 2; } }
@media (min-width: 1100px) { .award-group .award-list { columns: 3; } }

/* 3. Empty states: a short line, then one clear next step. */
.empty-next { margin: 16px 0; }
.empty-next p { margin: 0 0 12px; }
.people li.empty-line { padding: 0; border: 0; background: none; color: var(--muted); }
/* Forum: the "start one on a board" buttons in one tidy, wrapping row of the same height. */
.board-starts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.board-starts a.button.ghost { min-height: 42px; margin: 0; }

/* 4. Reader profile: name as the page title, then a line of big numbers like the book page. */
.profile-facts { margin: 0 0 12px; }
.profile-visible { margin: 0 0 24px; }
@media (max-width: 640px) {
  /* Three per row; the doubled class wins over the book page's two-per-row rules. */
  .profile-facts.hero-facts { grid-template-columns: repeat(3, 1fr); }
  .profile-facts.hero-facts > div:nth-child(n) { padding: 10px 8px; border-left: 1px solid var(--text); border-top: 0; grid-column: auto; }
  .profile-facts.hero-facts > div:nth-child(3n+1) { padding-left: 0; border-left: 0; }
  .profile-facts.hero-facts > div:nth-child(n+4) { border-top: 1px solid var(--text); }
  .profile-facts .fact-big { font-size: 1.6rem; }
}

/* 5. My books on phones: heading on its own line, Sort and Grid/List together below it. */
@media (max-width: 640px) {
  .discover > section > .toolbar { gap: 12px; }
  .discover > section > .toolbar h1 { flex: 1 1 100%; }
}

/* Tap targets on phones. */
@media (max-width: 900px) {
  .rtag, .board-starts a.button.ghost { min-height: 44px; box-sizing: border-box; align-items: center; }
  .award-group .award-list a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ===== Round 5 follow-up: forum, lists, account and review forms after testing with real rows ===== */
/* List forms: one readable column, the tick box beside its words. */
.list-form { max-width: 560px; }
.list-form p { margin: 0; }
.list-form p:has(input[type="checkbox"]) { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 10px; }
.list-form p:has(input[type="checkbox"]) label { font-size: 0.95rem; color: var(--text); }
.list-form + form { margin-top: 10px; }
/* The review form: Update and "Delete my review" sit apart, the delete button below with a little air. */
.review-form + form { margin-top: 10px; }
/* Account page: each part under a thin line, no loose gaps between a heading and its text. */
main.page-read .account h2 { margin: 16px 0 0; padding-top: 20px; border-top: 1px solid var(--border); }
main.page-read .account p { margin: 0; }
/* Forum rows on phones: the reply count and date go under the title instead of squeezing beside it. */
@media (max-width: 640px) { .forum-rows a { flex-direction: column; gap: 4px; } }
/* Numbers on the book tabs keep a little distance from the word. */
.tab-n { margin-left: 4px; }

/* ===== Audit fixes (U1–U7) ===== */
/* The "+ genre" list ends with the live number and Done; it stays at the bottom while the list scrolls. */
.pick-foot { grid-column: 1 / -1; position: sticky; bottom: -8px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 6px -8px -8px; padding: 8px; background: var(--bg); border-top: 1.5px solid var(--text); }
.pick-count { font-family: var(--font-mono); font-size: 0.85rem; }
.pick-foot button { min-height: 36px; padding: 0 16px; }
@media (max-width: 900px) { .pick-foot button { min-height: 44px; } }
/* Logged-out book page: the way in is a real button. */
.join-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; }
/* Feed and lists: small covers so the rows are not bare text. */
.feed-event { justify-content: flex-start; align-items: center; gap: 12px; }
.feed-cover { flex: 0 0 34px; width: 34px; height: 51px; container-type: inline-size; }
.feed-cover img, .list-covers img { width: 100%; height: 100%; object-fit: cover; display: block; }
.list-cards li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: start; }
.list-cards li > * { grid-column: 2; }
.list-cards li > .list-covers { grid-column: 1; grid-row: 1 / span 3; display: flex; gap: 4px; min-width: 44px; }
.list-covers .cover-box { width: 44px; height: 66px; container-type: inline-size; position: relative; overflow: hidden; }
@media (max-width: 640px) { .list-covers .cover-box:nth-child(n+3) { display: none; } }
/* Two buttons side by side keep a gap, also when they wrap (empty My books on a phone). */
main p:has(> a.button + a.button) { display: flex; flex-wrap: wrap; gap: 10px; }
/* Author page: years sit right under the name, the bio right under that. */
.author-head { margin-bottom: 12px; }
.author-head .list-head { margin-bottom: 8px; row-gap: 0; }
.author-head .list-head > h1 { margin-bottom: 4px; }
.author-head .author-years { margin: 0; }
/* Top: the hint now sits above the genre buttons, as on Browse. */
.top-genres .genre-hint { margin: 0 0 8px; }

/* "Are you sure?" in our own pop-up (static/confirm.js) instead of the browser's. */
.confirm-box .confirm-text { margin: 0 0 16px; font-size: 1rem; line-height: 1.45; overflow-wrap: anywhere; }
.confirm-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.confirm-buttons button { min-height: 44px; }

/* ===== M99: the home sentence keeps its one flowing line on every screen (the "one clause per row" phone layout was
   tried and taken back, 2026-11-19). The clause wrappers in the markup do nothing. ===== */
.clause, .clause-value { display: contents; }
