/* Book browser: same palette and feel as the apps landing page. */
:root {
  --bg: #f6f8fb; --bg-accent-1: rgba(37, 99, 235, 0.08); --bg-accent-2: rgba(14, 165, 164, 0.08);
  --surface: #ffffff; --border: #e3e8f0; --border-hover: #b9c6dd;
  --text: #16233b; --text-soft: #4b5b74; --text-faint: #6b7a94;
  --accent: #2563eb; --accent-soft: rgba(37, 99, 235, 0.10);
  --chip-bg: #eef2f9; --chip-text: #40506b;
  --shadow: 0 1px 2px rgba(22, 35, 59, 0.05), 0 8px 24px -12px rgba(22, 35, 59, 0.12);
  --shadow-hover: 0 2px 4px rgba(22, 35, 59, 0.06), 0 16px 36px -12px rgba(22, 35, 59, 0.22);
  --ring: rgba(37, 99, 235, 0.35); --mark: #fff3bf;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1322; --bg-accent-1: rgba(96, 155, 255, 0.07); --bg-accent-2: rgba(45, 212, 191, 0.06);
    --surface: #161f33; --border: #263352; --border-hover: #3c4f7c;
    --text: #e8edf7; --text-soft: #a9b6cf; --text-faint: #8496b5;
    --accent: #7aa5ff; --accent-soft: rgba(122, 165, 255, 0.14);
    --chip-bg: #22304e; --chip-text: #b6c3dc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.45), 0 18px 40px -14px rgba(0, 0, 0, 0.75);
    --ring: rgba(122, 165, 255, 0.45); --mark: #4a4416;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); line-height: 1.55; min-height: 100vh; -webkit-font-smoothing: antialiased;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1100px 500px at 15% -10%, var(--bg-accent-1), transparent 60%),
              radial-gradient(900px 450px at 90% -15%, var(--bg-accent-2), transparent 55%), var(--bg);
}
a { color: var(--accent); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 40px 24px 64px; }
header.top { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 0 18px; }
/* The APMonitor logo is pale, so it carries its own dark plate in both themes. */
.ap-home { display: grid; width: 60px; height: 60px; grid-row: span 2; place-items: center; padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.3); border-radius: 15px; background: #10203a; text-decoration: none; }
.ap-home:hover { border-color: rgba(148, 163, 184, 0.55); background: #17304f; }
.ap-home img { display: block; width: 100%; height: 100%; object-fit: contain; }
header.top h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
header.top h1 .accent { color: var(--accent); }
header.top p.sub { margin: 0; max-width: 50rem; color: var(--text-soft); font-size: 1.02rem; }
.crumbs { margin: 0 0 18px; font-size: 0.9rem; color: var(--text-faint); }
.crumbs a { color: var(--text-soft); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 26px 0 8px; }
.search { flex: 1 1 320px; max-width: 480px; }
.search input { width: 100%; padding: 11px 14px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.search input:focus-visible, .btn:focus-visible, .chip:focus-visible, a:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.chip { font: inherit; font-size: 0.9rem; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--chip-bg); color: var(--chip-text); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
h2.group { margin: 34px 0 4px; font-size: 1.25rem; letter-spacing: -0.01em; }
p.group-note { margin: 0 0 16px; color: var(--text-soft); font-size: 0.95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-hover); }
.card img { display: block; width: 100%; height: auto; aspect-ratio: 7 / 10; background: #10203a; }
.card .meta { padding: 12px 14px 14px; }
.card .vol { font-size: 0.78rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.card .title { margin: 2px 0 4px; font-weight: 700; line-height: 1.25; }
.card .tag { margin: 0; font-size: 0.88rem; color: var(--text-soft); line-height: 1.4; }
.badge { display: inline-block; margin-top: 8px; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-text); }
.results { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.results li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.results .where { font-size: 0.82rem; color: var(--text-faint); }
.results a { font-weight: 650; text-decoration: none; }
.results p { margin: 2px 0 0; font-size: 0.9rem; color: var(--text-soft); }
.results .ra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.results .ra a { font-weight: 550; }
.count { margin: 10px 0 0; font-size: 0.9rem; color: var(--text-faint); }
[hidden] { display: none !important; }
/* ---- volume page */
.volume { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 34px; align-items: start; margin-top: 8px; }
.volume .cover img { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow-hover); }
.kind { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.volume h1 { margin: 4px 0 6px; font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; letter-spacing: -0.02em; }
.volume .tagline { margin: 0 0 14px; font-size: 1.1rem; color: var(--text-soft); }
.volume .blurb { margin: 0 0 16px; max-width: 46rem; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 0 0 18px; font-size: 0.93rem; }
dl.facts dt { color: var(--text-faint); } dl.facts dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 0.92rem; font-weight: 600;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--border-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { font-size: 0.84rem; padding: 5px 10px; font-weight: 550; }
.notice { margin: 16px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 0.92rem; }
h2.section { margin: 40px 0 12px; font-size: 1.3rem; }
ol.contents { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
ol.contents > li { display: grid; grid-template-columns: 2.4rem 2.6rem 1fr auto; gap: 4px 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; scroll-margin-top: 16px; }
ol.contents > li:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.num { font-weight: 700; color: var(--text-faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.icon { font-size: 1.5rem; line-height: 1.2; text-align: center; }
.ch h3 { margin: 0; font-size: 1.02rem; line-height: 1.3; }
.ch .sub { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-faint); }
.ch .q { margin: 6px 0 0; font-size: 0.92rem; color: var(--text-soft); max-width: 52rem; }
.ch-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 16rem; }
.cite { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.cite h3 { margin: 0 0 8px; font-size: 1rem; }
.cite .tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.cite pre { margin: 0 0 10px; padding: 12px; overflow: auto; max-height: 20rem; font-size: 0.82rem; line-height: 1.45;
  background: var(--chip-bg); border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.cite .how { margin: 0 0 10px; font-size: 0.92rem; }
footer.foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 0.86rem; color: var(--text-faint); }
@media (max-width: 760px) {
  .volume { grid-template-columns: 1fr; gap: 20px; }
  .volume .cover { max-width: 260px; }
  ol.contents > li { grid-template-columns: 2rem 2.2rem 1fr; }
  .ch-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}
@media (max-width: 620px) {
  header.top { grid-template-columns: 1fr; }
  .ap-home { grid-row: auto; margin-bottom: 12px; }
  .wrap { padding: 24px 16px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
}
/* Touch sizing keys on the pointer, not the width. */
@media (pointer: coarse) {
  .btn, .chip { min-height: 44px; padding-left: 16px; padding-right: 16px; }
  .btn.small { min-height: 44px; }
  .search input { min-height: 48px; }
}
