/* Style books. A quiet shell: the art carries the page. Each book sets its own colours from its tokens.json (see layout.js). */
:root {
  --bg: #f6f7f9; --surface: #eceef3; --text: #1d2330; --muted: #5a6275; --accent: #2f6fb5; --accent-ink: #fff;
  --line: #d6dae3; --do: #e3f1e6; --never: #f8e4e4; --glow: transparent; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px -12px rgb(0 0 0 / .18);
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171e; --surface: #1d222d; --text: #e8ebf2; --muted: #9aa3b8; --accent: #8db6f0; --accent-ink: #10131a; --line: #2c3342; --do: #1d3326; --never: #3a2226; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body { overflow-wrap: break-word; margin: 0; background: var(--bg); color: var(--text); font: 1.0625rem/1.65 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: .08em; }
a:hover { text-decoration-thickness: .16em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
img { max-width: 100%; height: auto; display: block; }

/* Top bar and shell */
.top { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 82rem; margin: 0 auto; padding: .7rem 16px; display: flex; gap: 1.5rem; align-items: baseline; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.shell { max-width: 82rem; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: 3rem; }
.shell.solo { grid-template-columns: minmax(0, 1fr); }
.side { padding: 1.5rem 0 3rem; }
.navwrap > summary { display: none; }
.booknav { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); overflow: auto; font-size: .94rem; line-height: 1.35; padding-bottom: 1rem; }
.navtitle { font-weight: 700; font-size: 1.1rem; margin: 0 0 .6rem; }
.navtitle a { color: var(--text); text-decoration: none; }
.navhead { margin: 1.3rem 0 .3rem; font-weight: 650; color: var(--muted); font-size: .85rem; }
.navhead a { color: inherit; }
.navlist { list-style: none; margin: 0; padding: 0; }
.navlist a { display: block; padding: .28rem .6rem; margin: 0 -.6rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.navlist a:hover { background: var(--surface); }
.navlist a[aria-current] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.navtitle a[aria-current] { color: var(--accent); }
.main { padding: 2rem 0 4rem; min-width: 0; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.foot-in { max-width: 82rem; margin: 0 auto; padding: 1.5rem 16px 2.5rem; }

/* Type */
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.015em; margin: 2.4rem 0 .7rem; text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 4.6vw, 3.3rem); letter-spacing: -.03em; margin: 0 0 .5rem; font-weight: 750; }
h2 { font-size: clamp(1.5rem, 2.6vw, 1.95rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 680; }
h4 { font-size: 1.05rem; font-weight: 650; }
.lede { font-size: 1.25rem; line-height: 1.5; color: var(--muted); max-width: 46rem; margin: .4rem 0 1.5rem; text-wrap: pretty; }
.meta { color: var(--muted); font-size: .98rem; }
.prose > p, .prose > ul, .prose > ol, .prose > h2, .prose > h3, .prose > h4, .prose > blockquote, .prose > .note, .prose > hr { max-width: 44rem; }
.prose > ul.swatches, .prose > ul.models { max-width: none; }
.prose li { margin: .25rem 0; }
.prose > h2 { margin-top: 3.2rem; }
code { font: .9em/1.4 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; background: var(--surface); padding: .08em .35em; border-radius: 4px; }
code.hex { white-space: nowrap; font-family: var(--font); font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .01em; }
code.hex i { display: inline-block; width: .8em; height: .8em; border-radius: 50%; margin-right: .3em; vertical-align: -.05em; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
blockquote { margin: 1rem 0; padding: 0 0 0 1rem; border-left: 3px solid var(--line); color: var(--muted); }

/* Images */
figure { margin: 1.8rem 0; }
figure img { width: 100%; border-radius: var(--radius); background: var(--surface); }
figure.tall { max-width: 32rem; }
figure.tall img { width: auto; max-height: 72vh; }
figcaption { color: var(--muted); font-size: .92rem; line-height: 1.45; max-width: 46rem; margin-top: .55rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: 14px; margin: 1.8rem 0; align-items: start; }
.row figure { margin: 0; }
.row figure.tall { max-width: none; }
.row figure.tall img { width: 100%; max-height: none; }
.lead img { box-shadow: var(--shadow), 0 0 70px -24px var(--glow); }
.hero { margin-bottom: 1.5rem; }
.hero .lead { margin: 0 0 1.6rem; }

/* Tables */
.table { overflow-x: auto; margin: 1.5rem 0; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); }
.table table { border-collapse: collapse; width: 100%; font-size: .94rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
th { background: var(--surface); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; }

/* Swatches */
.swatches { list-style: none; margin: 1.2rem 0 1.8rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr)); gap: 12px; }
.sw { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: copy; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.sw:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip { display: block; height: 4.4rem; box-shadow: inset 0 -1px 0 rgb(0 0 0 / .12); }
.hexv { display: block; padding: .5rem .7rem 0; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.role { display: block; padding: 0 .7rem .6rem; font-size: .85rem; line-height: 1.3; color: var(--muted); }
.sw.copied .hexv::after { content: " copied"; font-weight: 500; color: var(--accent); }

/* Prompt and code boxes */
.codebox { margin: 1.3rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 60rem; }
.codehead { display: flex; justify-content: space-between; align-items: center; padding: .4rem .6rem .4rem 1rem; border-bottom: 1px solid var(--line); min-height: 2.6rem; }
.codename { font-weight: 650; font-size: .92rem; }
.copy { font: inherit; font-size: .88rem; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: .3rem .85rem; cursor: pointer; }
.copy:hover { filter: brightness(1.08); }
.codebox pre { margin: 0; padding: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.55; max-height: 28rem; overflow: auto; }
.codebox pre code { background: none; padding: 0; font: inherit; font-family: var(--font); }
.codenote { margin: 0; padding: 0 1rem .8rem; font-size: .9rem; color: var(--muted); }
.blockitem { margin: 0 0 2rem; }
.blockitem h3 { margin-bottom: .2rem; }
.proofs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: .9rem; max-width: 60rem; }
.proofs .proof { height: 5.5rem; width: auto; border-radius: 6px; }

/* Do and never */
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 14px; margin: 1.8rem 0; }
.pair > div { padding: 1rem 1.2rem; border-radius: var(--radius); }
.pair h4 { margin: 0 0 .4rem; }
.pair ul { margin: 0; padding-left: 1.2rem; }
.do { background: var(--do); }
.never { background: var(--never); }
.note { background: var(--surface); border-radius: var(--radius); padding: .9rem 1.2rem; margin: 1.5rem 0; }
.note > :first-child { margin-top: 0; } .note > :last-child { margin-bottom: 0; }
.note.raw { max-width: none; }

/* Book home */
.agentbox { background: var(--surface); border-radius: var(--radius); padding: .2rem 1.4rem 1rem; max-width: 48rem; }
.agentbox h2 { margin-top: 1rem; font-size: 1.3rem; }
ul.plain { padding-left: 1.2rem; }
.contents { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .2rem; max-width: 48rem; }
.contents a { display: block; padding: .7rem 1rem; border-radius: var(--radius); text-decoration: none; color: var(--text); }
.contents a:hover { background: var(--surface); }
.contents strong { display: block; font-size: 1.1rem; }
.contents span { color: var(--muted); font-size: .95rem; line-height: 1.4; display: block; }
.zonegrid, .bookgrid, .models { list-style: none; padding: 0; margin: 1.2rem 0; display: grid; gap: 22px 16px; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); }
.bookgrid { grid-template-columns: repeat(auto-fill, minmax(min(26rem, 100%), 1fr)); gap: 28px 20px; }
.zonegrid a, .bookcard > a { display: block; text-decoration: none; color: var(--text); }
.zonegrid img, .bookcard img, .models img { border-radius: var(--radius); aspect-ratio: 16 / 9; object-fit: cover; width: 100%; background: var(--surface); }
.models img { aspect-ratio: auto; }
.zname, .bname { display: block; font-weight: 700; font-size: 1.15rem; margin-top: .55rem; }
.bname { font-size: 1.5rem; letter-spacing: -.02em; }
.zfeel, .bsum { display: block; color: var(--muted); font-size: .95rem; line-height: 1.4; }
.bmeta { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; }
.zonegrid a:hover .zname, .bookcard a:hover .bname { color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 12px 24px; margin: 1.2rem 0 1.8rem; max-width: 60rem; }
.facts dt { font-size: .85rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; line-height: 1.35; }
model-viewer { width: 100%; height: 22rem; border-radius: var(--radius); background: var(--surface); }

/* Pager and toc */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 4rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.pager a { text-decoration: none; color: var(--text); font-weight: 650; max-width: 48%; }
.pager a span { display: block; font-weight: 400; color: var(--muted); font-size: .88rem; }
.pager .next { text-align: right; margin-left: auto; }
.toc { background: var(--surface); border-radius: var(--radius); padding: .6rem 1.2rem .8rem; margin: 0 0 2rem; max-width: 44rem; font-size: .95rem; }
.toc h2 { font-size: .95rem; margin: .4rem 0 .3rem; color: var(--muted); font-weight: 650; }
.toc ul { list-style: none; padding: 0; margin: 0; columns: 2 14rem; }
.toc li { margin: .15rem 0; break-inside: avoid; }

@media (max-width: 62rem) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .side { padding: .8rem 0 0; }
  .navwrap > summary { display: block; cursor: pointer; font-weight: 700; padding: .55rem .9rem; background: var(--surface); border-radius: var(--radius); list-style: none; }
  .navwrap > summary::after { content: " menu"; font-weight: 400; color: var(--muted); }
  .booknav { position: static; max-height: none; padding: .8rem .2rem 0; }
  .main { padding-top: 1.2rem; }
  .top { position: static; }
  .pair, .row { gap: 10px; }
}
@media print { .top, .side, .foot, .copy { display: none; } }
