:root {
  color-scheme: dark;
  --ink: #f1e4c5;
  --muted: #b9a989;
  --page: #111116;
  --page-2: #18171b;
  --line: #4e4035;
  --line-soft: #302b2c;
  --wood: #3b241f;
  --wood-dark: #24151a;
  --brass: #8d6a3d;
  --brass-hi: #d2a24c;
  --supply: #72c58b;
  --brew: #5ea7d8;
  --memory: #a878e6;
  --fire: #d98745;
  --danger: #d45c6d;
  --disabled: #5a4d5e;
  --ab-width: 390px;
  --ab-height: 844px;
  --ab-font-scale: 1;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); letter-spacing: 0; }
button, input, select { font: inherit; }
a { color: #8fc4e6; text-underline-offset: 3px; }
code { color: #e9ca82; overflow-wrap: anywhere; }

body[data-artboard-size="360"] { --ab-width: 360px; --ab-height: 780px; }
body[data-artboard-size="390"] { --ab-width: 390px; --ab-height: 844px; }
body[data-artboard-size="430"] { --ab-width: 430px; --ab-height: 932px; }
body[data-artboard-scale="130"] { --ab-font-scale: 1.3; }

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 12px;
  top: -80px;
  padding: 12px 16px;
  background: var(--ink);
  color: #161219;
}
.skip-link:focus { top: 12px; }

.book-header {
  border-bottom: 2px solid var(--brass);
  background: #161219;
}
.book-header__inner {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: end;
}
.eyebrow { margin: 0 0 12px; color: var(--brass-hi); font: 700 12px/1.2 ui-monospace, monospace; text-transform: uppercase; }
.book-header h1 { margin: 0; font-size: 46px; line-height: 1.04; font-weight: 760; letter-spacing: 0; }
.book-header h1 span { display: block; margin-top: 8px; color: var(--muted); font-size: 23px; font-weight: 550; }
.lede { max-width: 760px; margin: 22px 0 0; color: #d0c7b7; font-size: 17px; line-height: 1.75; }
.status-block { border: 1px solid var(--line); border-left: 4px solid var(--brass-hi); background: #1b181a; }
.status-block div { min-height: 52px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line-soft); }
.status-block div:last-child { border-bottom: 0; }
.status-block span { color: var(--muted); font-size: 12px; }
.status-block strong { max-width: 205px; text-align: right; font: 700 11px/1.35 ui-monospace, monospace; overflow-wrap: anywhere; }

.toc {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 52px;
  padding: 0 max(20px, calc((100vw - 1440px) / 2));
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  background: rgba(17, 17, 22, 0.97);
  border-bottom: 1px solid var(--line);
}
.toc a { min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; white-space: nowrap; color: #d8d0c1; text-decoration: none; font-size: 12px; border-bottom: 2px solid transparent; }
.toc a:hover, .toc a:focus-visible { color: var(--ink); border-color: var(--supply); outline: none; }

.book { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }
.spec-section { position: relative; padding: 72px 0; border-bottom: 1px solid var(--line-soft); }
.section-kicker { position: absolute; top: 76px; left: 0; width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--brass); color: var(--brass-hi); font: 800 15px/1 ui-monospace, monospace; }
.section-heading { max-width: 900px; margin: 0 0 34px 58px; }
.section-heading > p:first-child { margin: 0 0 6px; color: var(--brass-hi); font: 700 11px/1.3 ui-monospace, monospace; text-transform: uppercase; }
.section-heading h2 { margin: 0; font-size: 32px; line-height: 1.15; }
.section-heading h2 + p { margin: 12px 0 0; color: #c8c0b2; line-height: 1.7; }
h3 { margin: 34px 0 14px; font-size: 18px; }
h4 { margin: 8px 0; font-size: 14px; }
p, li { line-height: 1.65; }

.boundary-banner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--page-2); }
.boundary-banner > div { padding: 18px 20px; }
.boundary-banner > div + div { border-left: 1px solid var(--line); }
.boundary-banner p { margin: 10px 0 0; color: #ccc3b4; }
.scope-badge { display: inline-flex; min-height: 22px; align-items: center; padding: 2px 7px; border: 1px solid; font: 800 10px/1 ui-monospace, monospace; }
.scope-badge.current { color: var(--supply); border-color: #3e7650; background: #16231a; }
.scope-badge.proposed { color: #c8a8ef; border-color: #694c8d; background: #20172c; }

.contract-grid, .rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 24px 0; background: var(--line); border: 1px solid var(--line); }
.contract-grid article, .rule-grid article { padding: 22px; background: #171619; }
.contract-grid h3, .rule-grid h3 { margin: 0 0 10px; color: var(--brass-hi); font-size: 14px; }
.contract-grid p, .rule-grid p { margin: 0; color: #c8c0b2; font-size: 13px; }
.anti-pillars { margin-top: 24px; padding: 20px 22px; border-left: 4px solid var(--danger); background: #21171a; }
.anti-pillars h3 { margin: 0 0 8px; }
.anti-pillars ul { margin: 0; padding-left: 20px; color: #d3c5c0; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); }
.spec-table { width: 100%; min-width: 880px; border-collapse: collapse; background: #151518; font-size: 12px; line-height: 1.48; }
.spec-table th, .spec-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.spec-table th { color: #f0d99c; background: #211d1b; font-weight: 750; }
.spec-table tr:last-child td { border-bottom: 0; }
.spec-table td:last-child, .spec-table th:last-child { border-right: 0; }
.spec-table tbody tr:hover td { background: #1b1a1d; }
.spec-table .source-cell { max-width: 280px; font: 10px/1.5 ui-monospace, monospace; color: var(--muted); overflow-wrap: anywhere; }
.spec-table .id-cell { font: 10px/1.45 ui-monospace, monospace; color: #9bc4dc; }
.spec-table .numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
.spec-table.matrix .good { color: var(--supply); }
details { margin: 14px 0; border: 1px solid var(--line); background: #171619; }
details > summary { min-height: 48px; padding: 13px 16px; cursor: pointer; color: var(--brass-hi); font-weight: 700; }
details[open] > summary { border-bottom: 1px solid var(--line); }
details .table-wrap { border: 0; }

.ia-tree { padding: 26px; background: #171619; border: 1px solid var(--line); font: 12px/1.5 ui-monospace, monospace; }
.tree-root, .tree-branch, .tree-row span { min-height: 44px; padding: 10px 12px; display: flex; align-items: center; border: 1px solid var(--line); background: #1c191a; }
.tree-root { width: min(420px, 100%); margin: 0 auto 12px; justify-content: center; border-color: var(--memory); }
.tree-branch { width: min(520px, 100%); margin: 0 auto 12px; justify-content: center; border-color: var(--brass-hi); }
.tree-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.tree-row.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tree-row.five span { justify-content: center; color: var(--supply); }
.count-chip { display: inline-flex; min-width: 28px; height: 24px; margin-left: 8px; padding: 0 7px; align-items: center; justify-content: center; background: var(--wood); border: 1px solid var(--brass); color: var(--brass-hi); font: 700 11px/1 ui-monospace, monospace; }

.atlas-section { width: calc(100vw - 24px); margin-left: calc((min(1440px, calc(100vw - 40px)) - (100vw - 24px)) / 2); }
.atlas-section > .section-heading, .atlas-section > h3, .atlas-section > .atlas-toolbar, .atlas-section > .atlas-summary { width: min(1440px, calc(100% - 16px)); margin-left: auto; margin-right: auto; }
.atlas-toolbar { position: sticky; top: 52px; z-index: 90; padding: 10px 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: end; background: #18171bf2; border: 1px solid var(--line); }
.atlas-toolbar fieldset { min-width: 0; margin: 0; padding: 4px; display: flex; gap: 3px; border: 1px solid var(--line-soft); }
.atlas-toolbar legend { padding: 0 4px; color: var(--muted); font-size: 9px; }
.filter { min-height: 34px; padding: 0 10px; color: #c8c0b2; background: #211e20; border: 1px solid transparent; cursor: pointer; }
.filter.active { color: #171619; background: var(--brass-hi); border-color: #f0ca76; }
.filter:focus-visible { outline: 2px solid var(--supply); outline-offset: 2px; }
.atlas-summary { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.atlas-summary span { padding: 8px 10px; background: #19181a; border-left: 3px solid var(--brass); color: var(--muted); font: 11px/1 ui-monospace, monospace; }
.atlas-summary strong { color: var(--ink); }
.artboard-grid { width: min(1440px, calc(100% - 16px)); margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--ab-width) + 30px)), 1fr)); gap: 24px; align-items: start; }
.artboard-card { min-width: 0; padding: 14px; background: #171619; border: 1px solid var(--line); border-top: 4px solid var(--brass); }
.artboard-card[data-scope="proposed"] { border-top-color: var(--memory); }
.artboard-card[hidden] { display: none; }
.artboard-meta { min-height: 62px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.artboard-meta h4 { margin: 0; font: 700 12px/1.35 ui-monospace, monospace; color: #e4d8bf; }
.artboard-meta p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.artboard-viewport {
  position: relative;
  width: var(--ab-width);
  height: var(--ab-height);
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  color: var(--ink);
  background: #100d18;
  border: 2px solid #8d6a3d;
  font-size: calc(11px * var(--ab-font-scale));
  line-height: 1.25;
}
.artboard-viewport * { min-width: 0; }
.ab-shell { width: 100%; height: 100%; display: grid; grid-template-rows: 54px minmax(0, 1fr) 58px; background: #100d18; }
.ab-hud { z-index: 4; padding: 6px 8px; display: grid; grid-template-columns: minmax(0, 1fr) 44px 44px; gap: 4px; align-items: center; background: #1a1422; border-bottom: 2px solid var(--brass); }
.ab-resource { height: 42px; padding: 5px 8px; display: flex; align-items: center; gap: 8px; background: #24151a; border-left: 3px solid var(--brass-hi); }
.ab-resource strong { display: block; font-size: calc(15px * var(--ab-font-scale)); line-height: 1; font-variant-numeric: tabular-nums; }
.ab-resource small { color: var(--supply); font-size: calc(8px * var(--ab-font-scale)); }
.ab-icon { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; color: var(--ink); background: #241f22; border: 1px solid var(--brass); font-size: 18px; }
.ab-main { position: relative; min-height: 0; overflow: hidden; background: #160f18; }
.ab-nav { z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); background: #171316; border-top: 2px solid var(--brass); }
.ab-nav span { position: relative; min-height: 56px; padding: 7px 1px 4px; display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); border-right: 1px solid #382c28; font-size: calc(8px * var(--ab-font-scale)); text-align: center; }
.ab-nav span:last-child { border-right: 0; }
.ab-nav .active { color: var(--ink); background: #2a1d1b; }
.ab-nav .active::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 2px; height: 3px; background: var(--supply); }
.ab-nav .locked { color: #665b65; }
.ab-nav b { font-size: 15px; line-height: 1; }

.ab-world { position: relative; height: 100%; display: grid; grid-template-rows: minmax(0, 58%) auto; background: #100d18; }
.ab-scene { position: relative; overflow: hidden; background: center/cover no-repeat url("phase6/assets/world-busy.png"); image-rendering: pixelated; }
.ab-scene.opening { background-image: url("phase6/assets/world-opening.png"); }
.ab-scene.starved, .ab-scene.error { background-image: url("phase6/assets/world-starved.png"); }
.ab-scene.reward, .ab-scene.transformation, .ab-scene.next-cycle { background-image: url("phase6/assets/world-reward.png"); }
.ab-scene::before { content: ""; position: absolute; inset: 0; background: rgba(16, 13, 24, 0.08); pointer-events: none; }
.ab-object-label { position: absolute; left: 8px; top: 8px; max-width: 64%; padding: 5px 7px; background: #161118e8; border-left: 3px solid var(--brew); font-size: calc(9px * var(--ab-font-scale)); }
.ab-object-label strong { display: block; color: var(--ink); }
.ab-object-label small { color: #c7bda9; }
.ab-actor { position: absolute; right: 10px; bottom: 18px; width: 54px; height: 76px; display: grid; place-items: end center; color: #d9c79d; background: #271822; border: 2px solid #6d5144; clip-path: polygon(25% 0,75% 0,100% 24%,100% 100%,0 100%,0 24%); opacity: .9; }
.ab-actor::before { content: "M"; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--brass); background: #4b2b35; font-weight: 800; }
.ab-flow { position: absolute; left: 48%; top: 17%; width: 4px; height: 80px; background: none; }
.ab-flow::before { content: ""; display: block; width: 4px; height: 6px; background: var(--supply); box-shadow: 0 12px 0 var(--supply), 0 24px 0 var(--supply), 0 36px 0 var(--supply), 0 48px 0 var(--supply), 0 60px 0 var(--supply), 0 72px 0 var(--supply); }
.ab-scene.starved .ab-flow, .ab-scene.error .ab-flow { height: 22px; background: var(--danger); }
.ab-scene.starved .ab-flow::after, .ab-scene.error .ab-flow::after { content: "×"; position: absolute; left: -8px; bottom: -20px; color: var(--danger); font-size: 22px; }
.ab-pot-action { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); min-width: 124px; min-height: 44px; padding: 7px 12px; color: var(--ink); background: #2b2023e8; border: 2px solid var(--brass-hi); text-align: center; font-weight: 800; }
.ab-pot-action.disabled { color: #b09399; border-color: var(--danger); }
.ab-shelf { min-height: 180px; padding: 8px; display: grid; grid-template-rows: auto auto 46px; gap: 7px; background: #1b1519; border-top: 2px solid var(--brass); }
.ab-chain { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.ab-chain span { min-height: 46px; padding: 4px 2px; display: grid; place-items: center; align-content: center; gap: 2px; background: #251b1c; border: 1px solid #594331; text-align: center; font-size: calc(7px * var(--ab-font-scale)); }
.ab-chain span::before { content: "◆"; color: var(--supply); font-size: 10px; }
.ab-chain .blocked::before { content: "×"; color: var(--danger); }
.ab-chain .complete::before { content: "■"; color: var(--fire); }
.ab-chain .memory::before { content: "☾"; color: var(--memory); }
.ab-diagnosis { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.ab-diagnosis strong { display: block; color: var(--ink); font-size: calc(9px * var(--ab-font-scale)); }
.ab-diagnosis small { display: block; color: var(--muted); font-size: calc(7px * var(--ab-font-scale)); }
.ab-eta { color: var(--brew); font: 800 calc(10px * var(--ab-font-scale))/1 ui-monospace, monospace; }
.ab-primary { min-height: 46px; padding: 5px 10px; display: grid; place-items: center; color: #171316; background: var(--brass-hi); border: 2px solid #f0ca76; font-weight: 850; text-align: center; }
.ab-primary.supply { background: var(--supply); border-color: #a1e3ad; }
.ab-primary.memory { color: white; background: #694a91; border-color: #b994e9; }
.ab-primary.danger { color: white; background: #803746; border-color: var(--danger); }

.ab-page { height: 100%; display: grid; grid-template-rows: 48px 120px 42px minmax(0, 1fr); background: #171317; }
.ab-page-header { padding: 0 8px; display: grid; grid-template-columns: 44px 1fr 60px; align-items: center; border-bottom: 1px solid var(--brass); background: #1b1519; }
.ab-page-header strong { text-align: center; font-size: calc(13px * var(--ab-font-scale)); }
.ab-page-header small { text-align: right; color: var(--brew); font-size: calc(8px * var(--ab-font-scale)); overflow-wrap: anywhere; }
.ab-page-scene { position: relative; background: center 46%/cover no-repeat url("phase6/assets/world-busy.png"); image-rendering: pixelated; border-bottom: 2px solid var(--brass); }
.ab-page-scene::after { content: attr(data-object); position: absolute; left: 8px; bottom: 8px; padding: 4px 7px; background: #161118e8; border-left: 3px solid var(--supply); font-size: calc(8px * var(--ab-font-scale)); }
.ab-tabs { padding: 3px 4px; display: grid; grid-template-columns: repeat(var(--tab-count, 4), 1fr); gap: 2px; background: #211a1d; }
.ab-tabs span { min-height: 36px; display: grid; place-items: center; color: var(--muted); border-bottom: 2px solid transparent; font-size: calc(7px * var(--ab-font-scale)); text-align: center; }
.ab-tabs .active { color: var(--ink); border-color: var(--supply); background: #2b211f; }
.ab-content { min-height: 0; padding: 8px; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; background: #171317; }
.ab-focus { min-height: 120px; padding: 9px; background: #21191a; border-left: 4px solid var(--brass-hi); }
.ab-focus-head { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; align-items: center; }
.ab-pixel-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--ink); background: #342323; border: 2px solid var(--brass); font-size: 20px; }
.ab-focus h5 { margin: 0; font-size: calc(11px * var(--ab-font-scale)); }
.ab-focus p { margin: 4px 0 0; color: #c5baa7; font-size: calc(7px * var(--ab-font-scale)); line-height: 1.35; }
.ab-focus .ab-state { color: var(--supply); font: 800 calc(8px * var(--ab-font-scale))/1 ui-monospace, monospace; }
.ab-metrics { margin-top: 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.ab-metrics span { padding: 5px 3px; display: grid; gap: 2px; background: #171417; border-top: 1px solid #5a4233; color: var(--muted); font-size: calc(6px * var(--ab-font-scale)); }
.ab-metrics b { color: var(--ink); font-size: calc(8px * var(--ab-font-scale)); font-variant-numeric: tabular-nums; }
.ab-ledger { min-height: 0; display: grid; align-content: start; }
.ab-row { min-height: 49px; padding: 5px 6px; display: grid; grid-template-columns: 32px 1fr auto; gap: 7px; align-items: center; border-bottom: 1px solid #3c302b; }
.ab-row-icon { width: 30px; height: 30px; display: grid; place-items: center; background: #2b2022; border: 1px solid #66503b; }
.ab-row strong { display: block; font-size: calc(8px * var(--ab-font-scale)); }
.ab-row small { display: block; margin-top: 2px; color: var(--muted); font-size: calc(6px * var(--ab-font-scale)); line-height: 1.3; }
.ab-row-state { color: var(--brew); font: 800 calc(7px * var(--ab-font-scale))/1.1 ui-monospace, monospace; text-align: right; }
.ab-row-state.blocked { color: var(--danger); }
.ab-row-state.complete { color: var(--fire); }
.ab-action-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.ab-action { min-height: 46px; padding: 5px; display: grid; place-items: center; color: var(--ink); background: #2b2222; border: 1px solid var(--brass); text-align: center; font-weight: 750; font-size: calc(8px * var(--ab-font-scale)); }
.ab-action.primary { color: #171316; background: var(--brass-hi); border-color: #f0ca76; }
.ab-action.disabled { color: #776b74; border-color: #534950; background: #211e21; }

.ab-modal-context .ab-shell { filter: saturate(.72) brightness(.68); }
.ab-modal-overlay { position: absolute; z-index: 20; inset: 0; display: flex; align-items: flex-end; background: rgba(10, 8, 13, .36); }
.ab-sheet { width: 100%; max-height: 78%; padding: 10px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; background: #1d171a; border-top: 3px solid var(--brass-hi); box-shadow: 0 -8px 0 #100d18; }
.ab-sheet.tall { max-height: 88%; }
.ab-sheet-header { display: grid; grid-template-columns: 1fr 44px; align-items: center; gap: 8px; }
.ab-sheet-header h5 { margin: 0; font-size: calc(13px * var(--ab-font-scale)); }
.ab-sheet-header p { margin: 3px 0 0; color: var(--muted); font-size: calc(7px * var(--ab-font-scale)); }
.ab-close { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--brass); background: #251d20; font-size: 18px; }
.ab-sheet-body { min-height: 0; overflow: hidden; display: grid; align-content: start; gap: 6px; }
.ab-choice { min-height: 92px; padding: 8px; display: grid; grid-template-columns: 1fr auto; gap: 6px; background: #251c1e; border-left: 4px solid var(--supply); }
.ab-choice.brew { border-color: var(--brew); }
.ab-choice.memory { border-color: var(--memory); }
.ab-choice.danger { border-color: var(--danger); }
.ab-choice h6 { margin: 0 0 3px; font-size: calc(10px * var(--ab-font-scale)); }
.ab-choice p { margin: 0; color: #c5baa7; font-size: calc(7px * var(--ab-font-scale)); line-height: 1.35; }
.ab-choice b { color: var(--ink); font-size: calc(9px * var(--ab-font-scale)); text-align: right; }
.ab-callout { min-height: 48px; padding: 7px 8px; display: grid; align-content: center; background: #171417; border-left: 3px solid var(--fire); color: #d6c8b3; font-size: calc(7px * var(--ab-font-scale)); }
.ab-sheet-footer { min-height: 48px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.ab-sheet-footer.single { grid-template-columns: 1fr; }
.ab-sheet-footer span { min-height: 48px; padding: 6px; display: grid; place-items: center; background: #2c2223; border: 1px solid var(--brass); font-weight: 800; text-align: center; font-size: calc(8px * var(--ab-font-scale)); }
.ab-sheet-footer .primary { color: #171316; background: var(--brass-hi); border-color: #f0ca76; }
.ab-sheet-footer .danger { color: white; background: #7a3442; border-color: var(--danger); }
.ab-sheet-footer .disabled { color: #756b72; background: #211e21; border-color: #4c454b; }

.loop-ribbon { padding: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; background: #171619; border: 1px solid var(--line); }
.loop-ribbon span { min-height: 38px; padding: 8px 10px; display: inline-flex; align-items: center; background: #241b1d; border-bottom: 2px solid var(--supply); font-size: 12px; }
.loop-ribbon b { color: var(--brass-hi); }
.formula-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.formula-grid article { min-height: 170px; padding: 16px; background: #171619; border: 1px solid var(--line); }
.formula-grid code { display: block; margin: 8px 0; padding: 8px; background: #0d0d11; font-size: 11px; line-height: 1.5; }
.formula-grid p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.dominance-check, .identity-line, .implementation-acceptance, .source-map, .final-boundary { margin-top: 20px; padding: 18px 20px; background: #18171a; border-left: 4px solid var(--memory); }
.dominance-check h3, .implementation-acceptance h3, .source-map h3 { margin: 0 0 8px; }
.campaign-ending { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.campaign-ending article { padding: 18px; background: #171619; }
.campaign-ending p { color: #c9c0b2; font-size: 12px; }
.identity-line { color: #f0d99c; border-left-color: var(--fire); font-size: 18px; line-height: 1.6; }
.token-strip { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; margin: 18px 0; }
.token-strip span { min-height: 70px; padding: 8px; display: flex; align-items: flex-end; background: var(--token); border: 1px solid #6b5c52; color: white; font: 10px/1 ui-monospace, monospace; text-shadow: 0 1px 0 #000; }
.component-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.component-grid article { padding: 14px; background: #171619; border-top: 2px solid var(--brass); }
.component-grid p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.implementation-acceptance ol { margin: 8px 0 0; padding-left: 20px; }
.verification-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.verification-summary div { min-height: 90px; padding: 14px; display: grid; align-content: center; background: #171619; border-bottom: 3px solid var(--supply); }
.verification-summary strong { font-size: 24px; color: var(--ink); }
.verification-summary span { color: var(--muted); font-size: 11px; }
.evidence-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 22px; }
.evidence-grid article { padding: 18px; background: #171619; border: 1px solid var(--line); }
.evidence-grid h3 { margin: 0; }
.evidence-grid ul { padding-left: 18px; color: #c9c0b2; }
.final-boundary { border-left-color: var(--danger); }
.book-footer { min-height: 120px; padding: 32px max(20px, calc((100vw - 1440px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #0d0d11; border-top: 2px solid var(--brass); }

@media (max-width: 960px) {
  .book-header__inner { grid-template-columns: 1fr; }
  .status-block { max-width: 560px; }
  .contract-grid, .rule-grid { grid-template-columns: repeat(2, 1fr); }
  .formula-grid { grid-template-columns: repeat(2, 1fr); }
  .campaign-ending { grid-template-columns: repeat(2, 1fr); }
  .component-grid { grid-template-columns: repeat(2, 1fr); }
  .token-strip { grid-template-columns: repeat(3, 1fr); }
  .verification-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .book-header__inner, .book { width: min(100% - 24px, 1440px); }
  .book-header__inner { padding: 34px 0 28px; gap: 26px; }
  .book-header h1 { font-size: 34px; }
  .book-header h1 span { font-size: 18px; }
  .lede { font-size: 15px; }
  .spec-section { padding: 58px 0; }
  .section-kicker { top: 60px; }
  .section-heading { margin-left: 50px; }
  .section-heading h2 { font-size: 25px; }
  .boundary-banner, .contract-grid, .rule-grid, .formula-grid, .campaign-ending, .component-grid, .evidence-grid { grid-template-columns: 1fr; }
  .boundary-banner > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .tree-row, .tree-row.five { grid-template-columns: 1fr; }
  .atlas-section { width: calc(100vw - 8px); margin-left: calc((min(100% - 24px, 1440px) - (100vw - 8px)) / 2); }
  .atlas-toolbar { position: static; }
  .artboard-grid { display: block; }
  .artboard-card { margin-bottom: 18px; overflow-x: auto; }
  .artboard-viewport { max-width: none; }
  .verification-summary { grid-template-columns: 1fr 1fr; }
  .book-footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  .toc, .atlas-toolbar, .skip-link { display: none; }
  body { background: white; color: #171316; }
  .book-header, .spec-section, .book-footer { break-inside: avoid; }
  .artboard-card { break-inside: avoid; }
}
