/* The Recurring Cast. Layout: a case-binder index. Top bar, then a narrow reading column for
   text and full-width panels for charts and lists. */
:root {
  --bg: #f2f4f7;
  --surface: #fcfcfd;
  --ink: #0f1722;
  --ink-2: #47515f;
  --muted: #6b7584;
  --grid: #e1e5eb;
  --rule: #c5ccd6;
  --lead: #184f95;
  --major: #3987e5;
  --minor: #9ec5f4;
  --on-lead: #ffffff;
  --on-major: #0a1a31;
  --on-minor: #0a1a31;
  --hl: rgba(57, 135, 229, 0.10);
  --hl-strong: rgba(57, 135, 229, 0.20);
  --accent: #1c5cab;
  --vote: #b8325a;
  --vote-bg: rgba(184, 50, 90, 0.08);
  --tab: #e7ebf1;
  --bar: #0f1722;
  --on-bar: #edf1f6;
  --shadow: 0 6px 24px rgba(15, 23, 34, 0.14);

  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f14;
    --surface: #141920;
    --ink: #edf1f6;
    --ink-2: #b6bfcc;
    --muted: #8a94a4;
    --grid: #232a34;
    --rule: #343d4a;
    --lead: #b7d3f6;
    --major: #5598e7;
    --minor: #1c5cab;
    --on-lead: #0a1a31;
    --on-major: #0a1a31;
    --on-minor: #e9f2fd;
    --hl: rgba(85, 152, 231, 0.12);
    --hl-strong: rgba(85, 152, 231, 0.24);
    --accent: #86b6ef;
  --vote: #f28aa3;
  --vote-bg: rgba(242, 138, 163, 0.14);
    --tab: #1b222c;
    --bar: #05070a;
    --on-bar: #edf1f6;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f14;
  --surface: #141920;
  --ink: #edf1f6;
  --ink-2: #b6bfcc;
  --muted: #8a94a4;
  --grid: #232a34;
  --rule: #343d4a;
  --lead: #b7d3f6;
  --major: #5598e7;
  --minor: #1c5cab;
  --on-lead: #0a1a31;
  --on-major: #0a1a31;
  --on-minor: #e9f2fd;
  --hl: rgba(85, 152, 231, 0.12);
  --hl-strong: rgba(85, 152, 231, 0.24);
  --accent: #86b6ef;
  --vote: #f28aa3;
  --vote-bg: rgba(242, 138, 163, 0.14);
  --tab: #1b222c;
  --bar: #05070a;
  --on-bar: #edf1f6;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar { background: var(--bar); color: var(--on-bar); }
.topbar .inner {
  max-width: 1500px;
  margin: 0 auto;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.01em;
  color: var(--on-bar);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand .mk { display: inline-grid; grid-template-columns: repeat(3, 6px); gap: 2px; }
.brand .mk i { width: 6px; height: 6px; border-radius: 1px; background: var(--major); }
.brand .mk i:nth-child(1), .brand .mk i:nth-child(5), .brand .mk i:nth-child(9) { background: var(--on-bar); }
.brand .mk i:nth-child(3), .brand .mk i:nth-child(7) { background: transparent; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.topbar nav a { color: var(--on-bar); text-decoration: none; opacity: 0.85; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.wrap {
  max-width: 1500px;
  margin: 0 auto;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 28px;
}
.wrap > * { min-width: 0; }

/* Header */
.masthead { display: grid; gap: 10px; }
.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(36px, 5.4vw, 60px);
  line-height: 0.95;
  margin: 0;
  text-wrap: balance;
}
h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}
h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
.lede { margin: 0; max-width: 68ch; color: var(--ink-2); font-size: 16.5px; }
.caveat { margin: 0; max-width: 80ch; font-size: 13.5px; color: var(--muted); }
.disclosure { margin: 0; font-size: 12.5px; color: var(--muted); }
.jump { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.section-head { display: grid; gap: 6px; margin-bottom: 14px; }
.section-head p { margin: 0; color: var(--ink-2); max-width: 70ch; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.field { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.field input, .field select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 5px 9px;
}
.field input { width: 170px; }
.legend { display: flex; gap: 14px; align-items: center; margin-left: auto; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 18px; height: 18px;
  border-radius: 3px;
  display: inline-grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500; font-style: normal;
  flex: none;
}
.r-L { background: var(--lead); color: var(--on-lead); }
.r-M { background: var(--major); color: var(--on-major); }
.r-m { background: var(--minor); color: var(--on-minor); }

/* Matrix */
.board {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: auto;
  max-height: 78vh;
  min-width: 0;
}
table.matrix { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 0; }
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  vertical-align: bottom;
}
.matrix thead th.corner { left: 0; z-index: 5; text-align: left; padding: 10px 12px; border-right: 1px solid var(--rule); }
.corner .hint { font-size: 12px; color: var(--muted); font-weight: 400; display: block; max-width: 170px; line-height: 1.35; }
.bookhead { width: 28px; min-width: 28px; cursor: pointer; border-left: 1px solid var(--grid); }
.bookhead button {
  all: unset;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 28px;
  padding: 8px 0 6px;
  cursor: pointer;
}
.bookhead button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.btitle {
  writing-mode: vertical-rl;
  text-orientation: sideways;
  transform: rotate(180deg);
  font-family: var(--display);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1;
  white-space: nowrap;
  text-align: left;
  color: var(--ink);
}
.bookhead.forth .btitle { font-style: italic; color: var(--ink-2); }
.byear { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.bser {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--tab);
  border-radius: 3px;
  padding: 1px 2px;
  line-height: 1.3;
}
.bookhead:hover, .bookhead.sel { background: var(--hl-strong); }
.matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  text-align: left;
  font-weight: 400;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--grid);
}
.namebtn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  width: 210px;
  padding: 5px 12px;
  cursor: pointer;
}
.namebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.namebtn .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.namebtn .ct { font-family: var(--mono); font-size: 11px; color: var(--muted); }
tr.sel th, tr.sel td { background-color: var(--hl-strong); }
tr.sel th .nm { color: var(--accent); }
.matrix tbody tr:hover th, .matrix tbody tr:hover td { background-color: var(--hl); }
.matrix td.cell {
  position: relative;
  width: 28px;
  height: 30px;
  border-left: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  text-align: center;
}
.matrix td.cell.colhl { background-color: var(--hl); }
.matrix td.cell.forth { background-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--grid) 5px 6px); }
.mark {
  all: unset;
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.mark.r-L { background: var(--lead); color: var(--on-lead); }
.mark.r-M { background: var(--major); color: var(--on-major); }
.mark.r-m { background: var(--minor); color: var(--on-minor); }
.mark:hover, .mark:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.notedot {
  position: absolute;
  top: 3px;
  right: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--surface);
  pointer-events: none;
}
.legend .notedot { position: static; display: inline-block; }
tr.grouprow td { background: var(--tab); border-bottom: 1px solid var(--rule); border-top: 1px solid var(--rule); height: 28px; }
.grouplabel {
  position: sticky;
  left: 0;
  display: inline-block;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }

/* Tooltip */
.tip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.4;
  pointer-events: none;
}
.tip .t1 { font-weight: 600; }
.tip .t2 { color: var(--ink-2); font-family: var(--display); font-size: 15px; font-weight: 600; }
.tip .t3 { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tip .note { margin-top: 6px; }

/* Detail sheet */
.sheet {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 22px 22px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.sheet h3 { font-size: 30px; font-weight: 700; line-height: 1; }
.sheet .meta { color: var(--ink-2); font-size: 14px; }
.sheet .stats { display: flex; flex-wrap: wrap; gap: 8px 22px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sheet .stats b { color: var(--ink); font-weight: 500; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.trail { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--grid); }
.trail li {
  display: grid;
  grid-template-columns: 52px 26px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--grid);
}
.trail .yr { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.trail .swatch { align-self: center; }
.trail .what { min-width: 0; }
.trail .bk { font-weight: 600; }
.trail .bk button { all: unset; cursor: pointer; border-bottom: 1px solid var(--rule); }
.trail .bk button:hover { border-color: var(--accent); color: var(--accent); }
.trail .bk button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.trail .nt { color: var(--ink-2); }
.trail .role { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 6px; }

/* Buy links */
.buy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  background: var(--surface);
}
.buy:hover { border-color: var(--accent); }
.buy.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); padding: 6px 14px; font-size: 14px; }
.buy.primary:hover { filter: brightness(1.08); }
.buy .arr { font-family: var(--mono); font-weight: 400; }

/* Reading order */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; }
.series-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; align-items: start; }
.series-block { display: grid; gap: 10px; }
.series-block .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
ol.order { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--grid); }
ol.order li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--grid);
}
ol.order .n { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
ol.order .t { font-weight: 600; }
ol.order .sub { display: block; font-size: 13px; color: var(--ink-2); font-weight: 400; }
ol.order .y { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 6px; font-weight: 400; }

/* Character directory */
.cast-group { display: grid; gap: 10px; margin-top: 18px; }
.cast-group:first-of-type { margin-top: 0; }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.cast-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  align-content: start;
}
.cast-card h4 { margin: 0; font-size: 16px; font-weight: 600; }
.cast-card .d { margin: 0; color: var(--ink-2); font-size: 14px; }
.cast-card .s { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.cast-card .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.follow { font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.follow:hover { color: var(--accent); }

/* Home */
.hero { display: grid; gap: 14px; }
.hero h1 { font-size: clamp(44px, 7vw, 84px); }
.searchbox { display: grid; gap: 8px; max-width: 640px; position: relative; }
.searchbox label { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.searchbox input {
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 11px 14px;
  width: 100%;
}
.results { display: grid; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow: hidden; }
.results a { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 9px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--grid); }
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a:focus-visible { background: var(--hl); }
.results .k { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 3px; }
.results .l { font-weight: 600; }
.results .s { display: block; font-size: 13px; color: var(--ink-2); font-weight: 400; }
.results .none { padding: 12px 14px; color: var(--muted); }
.figures { display: flex; flex-wrap: wrap; gap: 8px 28px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.figures b { color: var(--ink); font-weight: 500; font-size: 15px; }
.author-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px; }
.author-card {
  display: grid;
  gap: 6px;
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px 12px;
  text-decoration: none;
  color: var(--ink);
}
.author-card:hover { border-color: var(--accent); }
.author-card .nm { font-family: var(--display); font-size: 23px; font-weight: 700; line-height: 1.05; }
.author-card .leads { font-size: 14px; color: var(--ink-2); }
.author-card .meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.author-card .tick { display: flex; gap: 2px; height: 12px; align-items: flex-end; margin-top: 4px; overflow: hidden; }
.author-card .tick i { flex: 1 1 0; max-width: 6px; min-width: 2px; height: 100%; background: var(--minor); border-radius: 1px; }
.author-card .tick i.L { background: var(--major); }
/* Genre filter: books outside the chosen genre shrink and fade, so matches stand out without relying on colour */
.author-card .tick i.off, .author-card .tick i.L.off { background: var(--grid); height: 40%; }

/* Home page filter rows */
.filters { display: grid; gap: 10px; margin-bottom: 16px; }
.filter-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; align-items: start; }
.filter-label { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 8px; }
.none-match { margin: 0 0 12px; color: var(--ink-2); }
@media (max-width: 600px) {
  .filter-row { grid-template-columns: minmax(0, 1fr); }
  .filter-label { padding-top: 0; }
  .filter-row .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .filter-row .chip { flex: 0 0 auto; }
}

/* Genre labels on author pages */
.gtags { display: flex; flex-wrap: wrap; gap: 6px; }
.gtag { font-family: var(--mono); font-size: 11.5px; line-height: 1.5; padding: 2px 8px; border-radius: 4px; background: var(--tab); color: var(--ink-2); text-decoration: none; }
a.gtag:hover { color: var(--accent); }
.controls #genreChips { flex-basis: 100%; }
.newlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 0 24px; }
.newlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.newlist .t { font-weight: 600; }
.newlist .sub { display: block; font-size: 13px; color: var(--ink-2); font-weight: 400; }
.prose { max-width: 70ch; display: grid; gap: 10px; color: var(--ink-2); }
.prose p { margin: 0; }

/* Footer */
.footer { border-top: 1px solid var(--rule); }
.footer .inner {
  max-width: 1500px;
  margin: 0 auto;
  padding-block: 20px 36px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.footer p { margin: 0; max-width: 90ch; }

@media (max-width: 640px) {
  .namebtn { width: 136px; padding: 5px 8px; }
  .namebtn .nm { font-size: 13px; }
  .corner .hint { max-width: 120px; }
  .legend { margin-left: 0; }
  .field input { width: 140px; }
  .sheet { padding: 16px; }
  .trail li { grid-template-columns: 44px 22px minmax(0, 1fr); }
  .trail li .buy { grid-column: 3; justify-self: start; }
  ol.order li { grid-template-columns: 28px minmax(0, 1fr); }
  ol.order li .acts { grid-column: 2; justify-self: start; }
  .panel { padding: 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  .chip, .mark, .buy, .author-card { transition: box-shadow 120ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease; }
}

/* Votes */
.vote {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.4;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px; padding: 3px 10px;
  cursor: pointer; white-space: nowrap;
}
.vote .vi { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.vote:hover { border-color: var(--vote); color: var(--vote); }
.vote[aria-pressed="true"] { color: var(--vote); border-color: var(--vote); background: var(--vote-bg); }
.vote[aria-pressed="true"] .vi { fill: currentColor; }
.vote.big { padding: 6px 14px; font-size: 14px; }
.vote.big .vi { width: 15px; height: 15px; }
.acts { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.vote-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 14px; color: var(--ink-2); }
.fav-link { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.fav-link a { font-weight: 600; }
.vote-note {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--surface); font-size: 14px; box-shadow: var(--shadow);
}

/* Favourites page */
.fav-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: start; }
.fav { display: grid; gap: 10px; }
.fav-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.fav-head h2 { font-size: 26px; }
.fav-head .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.empty-note { margin: 0; color: var(--ink-2); font-size: 14px; }
.restable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.restable th, .restable td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.restable thead th { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--rule); }
.restable .rk { width: 2.6em; font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; padding-right: 10px; }
.restable .num { width: 3.5em; text-align: right; font-family: var(--mono); font-size: 14px; }
.restable .act { width: 1%; white-space: nowrap; text-align: right; }
.restable thead th.rk, .restable thead th.num { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.restable .nm a { font-weight: 600; text-decoration: none; }
.restable .nm a:hover { text-decoration: underline; }
.restable .sub { display: block; font-size: 12.5px; color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shared additions ---------- */
.topbar nav a[aria-current="page"] { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.totop {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 40;
  font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center;
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
}
.totop:hover { border-color: var(--accent); color: var(--accent); }
.sub-in { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tablewrap { overflow-x: auto; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagrow .gtags { display: contents; }
.ctag { font-family: var(--mono); font-size: 11.5px; line-height: 1.5; padding: 2px 8px; border-radius: 4px; background: var(--ink); color: var(--surface); text-decoration: none; }
.ctag:hover { background: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14.5px; }
.quick a { font-weight: 600; }
.results a.all { background: var(--tab); }
.results a.all .l { font-weight: 600; }

/* My books control */
select.shelf {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px; padding: 3px 8px; max-width: 10.5em; cursor: pointer;
}
select.shelf:hover { border-color: var(--accent); }
select.shelf[data-state="read"] { color: var(--surface); background: var(--lead); border-color: var(--lead); }
select.shelf[data-state="reading"] { color: var(--on-major); background: var(--major); border-color: var(--major); }
select.shelf[data-state="wish"] { color: var(--accent); border-color: var(--accent); background: var(--hl); }
.progress { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; font-size: 13px; color: var(--ink-2); }
.pbar { display: inline-block; width: 120px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: var(--lead); }

/* Series navigation, story order, crossovers */
.series-nav { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; align-items: start; margin-bottom: 14px; }
.series-nav .chip { text-decoration: none; }
.series-nav .cn { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.order-toggle { display: flex; flex-wrap: wrap; gap: 6px; }
.series-block.story ol.order .n { color: var(--accent); font-weight: 600; }
.xbadge { display: inline-block; margin-left: 8px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--accent); color: var(--accent); vertical-align: 1px; }
.sub.xwhy { color: var(--accent); }
.cast-card .xref, .sheet .xref { color: var(--accent); }
.cast-card .xref a { color: inherit; }

/* Search page */
.sp { display: grid; gap: 14px; }
.sp-box input, .xbox input { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); color: var(--ink); }
.sp-selects { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.sp-selects select, .sp-selects input { font: inherit; font-size: 14px; padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--ink); max-width: 15em; }
.sp-count { margin: 0; color: var(--ink-2); font-size: 14px; }
.sp-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sp-item { display: grid; grid-template-columns: 86px minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 14px; }
.sp-item .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sp-main { display: grid; gap: 3px; min-width: 0; }
.sp-title { font-weight: 600; font-size: 16px; text-decoration: none; }
.sp-title:hover { text-decoration: underline; }
.sp-meta { font-size: 13.5px; color: var(--ink-2); }
.sp-extra { font-size: 13px; color: var(--muted); }
.sp-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.sp-none { color: var(--ink-2); }

/* Crossover explorer */
.xexp { display: grid; gap: 12px; }
.xbox { position: relative; }
.xhead { display: grid; gap: 4px; }
.xhead h3 { font-size: 28px; margin: 0; }
.xhead p { margin: 0; }
.xhead .d { color: var(--ink-2); }
.xcols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.xcols h4 { margin: 0 0 8px; font-size: 15px; font-family: var(--mono); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.xtimeline { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--grid); }
.xtimeline li { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--grid); }
.xtimeline .yr { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.xtimeline .what { display: grid; gap: 2px; }
.xtimeline .t { font-weight: 600; }
.xtimeline .sub, .restable .sub, .xb-author .sub, .fy-card .sub, .mb-prog .sub { display: block; font-size: 12.5px; color: var(--ink-2); }
.xb-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); align-items: start; }
.xb-author { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 12px 16px; }
.xb-author h3 { margin: 0 0 6px; font-size: 18px; }
.xb-author ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.xb-author .t { font-weight: 600; }

/* My books */
.mb-figures { margin-bottom: 4px; }
.mb-tools { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 14px; }
.mb-tools .buy { cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.mb-tools .buy:disabled { opacity: 0.5; cursor: default; }
#mbOut { display: grid; gap: 16px; }
.mb-sec { display: grid; gap: 10px; }
.mb-prog { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mb-prog li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--grid); }
.mb-prog li > .sub { grid-column: 1 / -1; }

/* For you */
.fy-pick { display: grid; gap: 12px; }
.fy-cats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.fy-cat h3 { margin: 0 0 6px; font-size: 15px; }
.fy-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); align-items: start; }
.fy-card { display: grid; gap: 8px; }
.fy-card h3 { margin: 0; font-size: 22px; }
.fy-card h3 a { text-decoration: none; }
.fy-card p { margin: 0; }
.fy-why { font-size: 14px; color: var(--ink); }
.fy-start { display: grid; gap: 6px; }
.fy-start .acts { justify-content: flex-start; }

@media (max-width: 640px) {
  .sp-item { grid-template-columns: minmax(0, 1fr); }
  .sp-acts { justify-content: flex-start; }
  .series-nav { grid-template-columns: minmax(0, 1fr); }
  .series-nav .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .series-nav .chip { flex: 0 0 auto; }
  .xtimeline li { grid-template-columns: 44px minmax(0, 1fr); }
  .xtimeline li .buy { grid-column: 2; justify-self: start; }
  .totop { padding: 8px 12px; }
}

/* Privacy page */
.prose { max-width: 720px; margin: 0 auto 32px; }
.prose h2 { font-size: 1.35rem; margin: 22px 0 8px; }
.prose h2:first-child { margin-top: 0; }
