/* The story page. Paper and Charter are the site's own; an instrument is a darker
   sheet set in the workspace's mono face. One verdigris ink means proven, amber
   means a person is needed, rust means a fault. */

@font-face { font-family: "Aporetic Sans Mono"; src: url("desk/fonts/aporetic-sans-mono-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Aporetic Sans Mono"; src: url("desk/fonts/aporetic-sans-mono-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #faf9f5;
  --ink: #1c1b18;
  --muted: #656259;
  --rule: #e4e1d8;
  --link-underline: #a8a296;
  --selection: #e8e2d0;
  --sheet: #f2f0e8;
  --sheet-2: #e9e6db;
  --sheet-line: #d6d2c4;
  --accent: #0b6157;
  --accent-soft: rgba(11, 97, 87, .11);
  --attn: #8f5407;
  --attn-soft: rgba(143, 84, 7, .12);
  --bad: #a3322b;
  --bad-soft: rgba(163, 50, 43, .1);
  --k-invariant: #0b6157;
  --k-mechanism: #3d4f8f;
  --k-gotcha: #a3322b;
  --k-directive: #7a5f00;
  --shadow: 0 1px 0 rgba(28, 27, 24, .04), 0 14px 34px -22px rgba(28, 27, 24, .35);

  --serif: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --mono: "Aporetic Sans Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --w: 73.75rem;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121210;
    --ink: #e6e4dd;
    --muted: #98958b;
    --rule: #282722;
    --link-underline: #67645b;
    --selection: #333129;
    --sheet: #1a1916;
    --sheet-2: #211f1b;
    --sheet-line: #35332c;
    --accent: #6fc9b9;
    --accent-soft: rgba(111, 201, 185, .13);
    --attn: #e2a94f;
    --attn-soft: rgba(226, 169, 79, .14);
    --bad: #ec7b72;
    --bad-soft: rgba(236, 123, 114, .13);
    --k-invariant: #6fc9b9;
    --k-mechanism: #9aaaf0;
    --k-gotcha: #ec7b72;
    --k-directive: #d8bf66;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .9);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.05rem, .98rem + .25vw, 1.2rem);
  line-height: 1.68;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection { background: var(--selection); }
p { margin: 0 0 1.1em; text-wrap: pretty; }
em { font-style: italic; }
code { font-family: var(--mono); font-size: .84em; padding: .06em .32em; border-radius: 3px; background: var(--sheet); border: 1px solid var(--rule); }
a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; text-decoration-color: var(--link-underline); transition: text-decoration-color .15s ease, color .15s ease; }
a:hover { text-decoration-color: var(--ink); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.grow { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }

.skip { position: absolute; left: -999px; top: .5rem; padding: .4rem .8rem; background: var(--ink); color: var(--bg); border-radius: 6px; font-family: var(--mono); font-size: .8rem; z-index: 20; }
.skip:focus { left: .5rem; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4em; font-family: var(--mono); font-size: .8rem; line-height: 1.2; padding: .62em .95em; border-radius: 8px; text-decoration: none; white-space: nowrap; transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink); color: var(--bg); }
.btn-ink:hover { background: var(--accent); color: var(--bg); }
.btn-line { box-shadow: inset 0 0 0 1px var(--ink); }
.btn-line:hover { background: var(--ink); color: var(--bg); }
.btn-lg { font-size: .9rem; padding: .85em 1.25em; }

/* ---------- top ---------- */
.top { max-width: var(--w); margin: 0 auto; padding: clamp(1.1rem, 3vh, 1.9rem) clamp(1.25rem, 4vw, 2rem) 0; }
.top-nav { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem 1.5rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--rule); font-size: .875rem; line-height: 1.4; color: var(--muted); }
.top-nav a:not(.btn) { color: var(--muted); text-decoration: none; }
.top-nav a:not(.btn):hover, .top-nav a:not(.btn):focus-visible { color: var(--ink); }
.top-links { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; }

/* ---------- the chapter rail ---------- */
.rail { display: none; }
@media (min-width: 1500px) {
  .rail { position: fixed; z-index: 4; left: max(1rem, calc((100vw - var(--w)) / 2 - 8.4rem)); top: 50%; transform: translateY(-50%); display: grid; gap: .1rem; font-family: var(--mono); font-size: .72rem; opacity: 0; transition: opacity .3s ease; pointer-events: none; }
  .rail.is-on { opacity: 1; pointer-events: auto; }
  .rail a { display: flex; align-items: baseline; gap: .6rem; padding: .32rem .2rem; color: var(--muted); text-decoration: none; }
  .rail a b { font-weight: 400; font-variant-numeric: tabular-nums; }
  .rail a span { opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s var(--ease); }
  .rail a:hover span, .rail a[aria-current] span, .rail a:focus-visible span { opacity: 1; transform: none; }
  .rail a[aria-current] { color: var(--ink); }
  .rail a[aria-current] b { color: var(--accent); font-weight: 700; }
}

/* ---------- hero ---------- */
.hero { max-width: var(--w); margin: 0 auto; padding: clamp(2rem, 6.5vh, 4.25rem) clamp(1.25rem, 4vw, 2rem) 0; }
.hero-text { max-width: 50rem; }
h1 { margin: 0 0 .5em; font-size: clamp(2.5rem, 1.35rem + 4.1vw, 4.7rem); font-weight: 600; line-height: 1.04; letter-spacing: -.028em; text-wrap: balance; }
h1 .dash { color: var(--muted); font-weight: 400; }
.lede { max-width: 41rem; margin: 0 0 1rem; font-size: clamp(1.15rem, 1.02rem + .5vw, 1.42rem); line-height: 1.5; font-style: italic; }
.byline { margin: 0; font-size: .9rem; color: var(--muted); }
.byline .sep { margin: 0 .35em; opacity: .7; }
.hero .inst { margin-top: clamp(1.75rem, 4.5vh, 2.75rem); }
.hero-after { max-width: 38rem; margin: clamp(2.5rem, 7vh, 4.5rem) auto 0; }
.hero-after p:last-child { margin-bottom: 0; }

/* ---------- chapters ---------- */
.chapter { max-width: var(--w); margin: 0 auto; padding: clamp(5rem, 15vh, 9.5rem) clamp(1.25rem, 4vw, 2rem) 0; scroll-margin-top: -2rem; }
.chapter-head { max-width: 46rem; margin-bottom: clamp(1.5rem, 4vh, 2.5rem); }
.num { margin: 0 0 .7rem; font-family: var(--mono); font-size: .78rem; letter-spacing: .02em; color: var(--accent); }
h2 { margin: 0; font-size: clamp(1.7rem, 1.2rem + 1.9vw, 2.75rem); font-weight: 600; line-height: 1.12; letter-spacing: -.02em; text-wrap: balance; }
h3 { margin: 0 0 .5rem; font-size: 1.22rem; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.step { max-width: 38rem; margin: 0 auto; padding: .4rem 0 1.1rem; }
.step p:last-child { margin-bottom: 0; }
.do { margin-top: -.3em; }
.link { font-family: var(--mono); font-size: .8rem; color: var(--accent); border-bottom: 1px solid var(--accent-soft); padding-bottom: 1px; transition: border-color .15s ease; }
.link::after { content: " →"; }
.link:hover { border-color: var(--accent); }
.scrolly > .inst { margin: 1.4rem auto 2rem; max-width: 44rem; }

/* The instrument stands beside the text only in a window wide and tall enough to hold it whole.
   A wide but short window (a small laptop) reads the page as a phone does: instruments in the
   flow, driven by hand. story.js asks the same question in the same words. */
@media (min-width: 1100px) and (min-height: 800px) {
  .scrolly { display: grid; grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); column-gap: clamp(2.5rem, 5vw, 4.75rem); align-items: start; }
  .scrolly > .step { grid-column: 1; margin: 0; min-height: 58vh; display: flex; flex-direction: column; justify-content: center; padding: 1rem 0; }
  .scrolly > .step:first-child { min-height: 46vh; }
  /* The last step is a whole window tall: while its text is in the middle of the window, the
     grid still reaches below the standing instrument, so the instrument is not pushed up and cut. */
  .scrolly > .step:last-child { min-height: 100vh; }
  /* The instrument stands in the window whole. Should its content ever outgrow a short window,
     it scrolls inside itself rather than hide its foot. */
  .scrolly > .inst { --stand: clamp(.75rem, 4vh, 4.5rem); grid-column: 2; grid-row: 1 / span 12; position: sticky; top: var(--stand); max-height: calc(100vh - 2 * var(--stand)); overflow-y: auto; scrollbar-width: thin; margin: 0; max-width: none; }
  /* The graph gives up height before the rest does: about 530px stands around it at its fullest. */
  .scrolly #mem-canvas { height: clamp(190px, calc(100vh - 2 * var(--stand) - 530px), 344px); }
  .js .scrolly > .step { opacity: .34; transition: opacity .45s ease; }
  .js .scrolly > .step.is-on, .js .scrolly > .step:focus-within { opacity: 1; }
}

/* ---------- an instrument ---------- */
.inst { margin: 0; background: var(--sheet); border: 1px solid var(--sheet-line); border-radius: 12px; box-shadow: var(--shadow); font-family: var(--mono); font-size: .8rem; line-height: 1.45; overflow: hidden; }
.inst figcaption { padding: .7rem 1rem .8rem; border-top: 1px solid var(--sheet-line); font-family: var(--serif); font-size: .88rem; line-height: 1.5; color: var(--muted); }
.inst figcaption b { color: var(--ink); font-weight: 600; }
.inst figcaption code { background: var(--sheet-2); border-color: var(--sheet-line); }
.inst-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; padding: .65rem .8rem; border-bottom: 1px solid var(--sheet-line); }
.input-name { color: var(--muted); margin-right: .15rem; }
.inst p.kind { font-family: var(--mono); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--sheet-line); max-width: 100%; }
.seg button { padding: .42em .8em; border-radius: 6px; color: var(--muted); white-space: nowrap; transition: background .18s ease, color .18s ease; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--sheet-line), 0 1px 2px rgba(0, 0, 0, .08); }
.seg-sub { color: var(--muted); font-size: .9em; margin-left: .35em; }

.chip { font-family: var(--mono); font-size: .8rem; line-height: 1.45; padding: .4em .8em; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--sheet-line); background: var(--bg); white-space: nowrap; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.chip:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.chip.is-ink { background: var(--ink); color: var(--bg); box-shadow: none; }
.chip.is-ink:hover { background: var(--accent); }
.chip.is-point { box-shadow: inset 0 0 0 1px var(--attn), 0 0 0 3px var(--attn-soft); }
.chip[disabled], .chip.is-ink[disabled] { background: none; color: var(--muted); cursor: default; box-shadow: inset 0 0 0 1px var(--sheet-line); }

.input, .cues, .proposals { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.input button, .cues button, .proposals button { padding: .34em .7em; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--sheet-line); background: var(--bg); transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.input button:hover, .cues button:hover, .proposals button:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.input button[aria-pressed="true"], .cues button[aria-pressed="true"], .proposals button[aria-pressed="true"] { background: var(--accent); color: var(--bg); box-shadow: none; }
.inputs { display: flex; flex-wrap: wrap; gap: .45rem 1.1rem; }

.say { margin: 0; font-family: var(--serif); font-size: .92rem; line-height: 1.45; color: var(--ink); min-height: 2.9em; }
.say b { font-weight: 600; }
.say .claim { color: var(--attn); }

/* ---------- hero: the streams ---------- */
.dial { display: inline-flex; align-items: center; gap: .7rem; }
.dial input { width: clamp(7rem, 22vw, 13rem); accent-color: var(--accent); }
.dial output { min-width: 1.6em; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tally { display: flex; gap: 1.1rem; margin: 0; font-variant-numeric: tabular-nums; }
.tally div { display: flex; align-items: baseline; gap: .4rem; }
.tally dt { color: var(--muted); }
.tally dd { margin: 0; min-width: 1.6em; font-weight: 700; font-size: 1.05rem; }
.tally .is-bad dd { color: var(--bad); }
#streams-canvas { display: block; width: 100%; height: 232px; background: var(--sheet); }

/* ---------- 01 attention ---------- */
.tabs { display: flex; gap: 2px; padding: .45rem .5rem 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--sheet-line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; display: inline-flex; align-items: center; gap: .4rem; padding: .38em .6em; border-radius: 6px 6px 0 0; color: var(--muted); font-size: .74rem; }
.tabs button[aria-selected="true"] { background: var(--sheet-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--sheet-line); }
.tabs .n { min-width: 1.8em; padding: 0 .35em; border-radius: 999px; background: var(--sheet-2); font-size: .68rem; text-align: center; font-variant-numeric: tabular-nums; }
.tabs button[aria-selected="true"] .n { background: var(--bg); }
.log { margin: 0; padding: .5rem 0; list-style: none; height: 300px; overflow-y: auto; overscroll-behavior: contain; background: var(--sheet-2); font-size: .74rem; line-height: 1.55; }
.log li { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: .7em; padding: 0 .8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.log li::before { content: attr(data-n); color: var(--muted); text-align: right; opacity: .7; font-variant-numeric: tabular-nums; }
.log .dim { color: var(--muted); }
.log .ok { color: var(--accent); }
.log .is-q { transition: background .5s ease, box-shadow .5s ease; }
.log .is-q.is-shown { background: var(--attn-soft); box-shadow: inset 3px 0 0 var(--attn); color: var(--ink); font-weight: 700; }
.att-status { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; padding: .55rem .8rem; border-top: 1px solid var(--sheet-line); color: var(--muted); font-variant-numeric: tabular-nums; }
.att-status .warn { color: var(--attn); }

.att-inbox { padding: .9rem .9rem 1rem; display: grid; gap: .7rem; min-height: 386px; align-content: start; }
.inbox-head { margin: 0; font-family: var(--serif); font-size: 1.25rem; line-height: 1.2; }
.inbox-head b { color: var(--attn); font-weight: 600; font-variant-numeric: tabular-nums; }
.card { background: var(--bg); border: 1px solid var(--sheet-line); border-radius: 9px; padding: .75rem .85rem .85rem; transition: box-shadow .4s ease; }
.card.is-point { box-shadow: 0 0 0 2px var(--attn); }
.card .kind { margin: 0 0 .3rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--attn); }
.card[data-kind="look"] .kind { color: var(--k-mechanism); }
.card h4 { margin: 0 0 .35rem; font-family: var(--serif); font-size: 1rem; font-weight: 600; line-height: 1.35; }
.card .detail { margin: 0 0 .6rem; font-family: var(--serif); font-size: .9rem; line-height: 1.45; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.opts button { padding: .45em .8em; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--sheet-line); transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.opts button:hover { background: var(--ink); color: var(--bg); box-shadow: none; }
.opts button i { font-style: normal; margin-left: .5em; font-size: .86em; color: var(--accent); }
.opts button:hover i { color: inherit; opacity: .8; }
.deadline { margin: .6rem 0 0; color: var(--muted); font-size: .76rem; }
.deadline time { color: var(--attn); font-weight: 700; font-variant-numeric: tabular-nums; }
.deadline .link { font-size: 1em; }
.shot { display: block; width: 100%; margin: .2rem 0 .55rem; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--sheet-line); cursor: zoom-in; }
.shot img { display: block; width: 100%; height: 118px; object-fit: cover; object-position: 0 0; }
.shot[aria-expanded="true"] { cursor: zoom-out; }
.shot[aria-expanded="true"] img { height: auto; aspect-ratio: 1120 / 600; }
.card.is-settled { padding: .5rem .85rem; color: var(--muted); font-size: .78rem; }
.card.is-settled > :not(.settled) { display: none; }
.settled { margin: 0; }
.tick { color: var(--accent); font-weight: 700; }
.landed { border-top: 1px dashed var(--sheet-line); padding-top: .55rem; }
.fold { display: flex; align-items: baseline; gap: .5em; width: 100%; text-align: left; color: var(--muted); font-size: .78rem; }
.fold .caret { margin-left: auto; transition: transform .25s var(--ease); }
.fold[aria-expanded="true"] .caret { transform: rotate(90deg); }
/* The fold is one grid row that closes from 1fr to 0fr, so the list's height is never animated itself. */
.landed-rows { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .5s var(--ease), opacity .35s ease; }
.landed ul { min-height: 0; overflow: hidden; margin: 0; padding: 0; list-style: none; font-size: .76rem; color: var(--muted); }
.landed ul > li:first-child { margin-top: .4rem; }
.landed ul > li { min-height: 0; padding: .14rem 0; display: flex; gap: .5em; align-items: baseline; }
.landed ul > li code { margin-left: auto; background: none; border: 0; padding: 0; }
.landed.is-folded .landed-rows { grid-template-rows: 0fr; opacity: 0; visibility: hidden; transition: grid-template-rows .5s var(--ease), opacity .35s ease, visibility 0s .5s; }
.inbox-done { margin: 0; padding: .6rem .85rem; border-radius: 9px; background: var(--accent-soft); font-family: var(--serif); font-size: .95rem; }

/* ---------- 02 the machine ---------- */
.mach-stage { background: var(--sheet-2); padding: .4rem; }
#mach-svg { display: block; width: 100%; height: auto; font-family: var(--mono); }
.st rect { fill: var(--bg); stroke: var(--sheet-line); stroke-width: 1.2; transition: fill .3s ease, stroke .3s ease; }
.st text { fill: var(--ink); font-size: 12.5px; text-anchor: middle; dominant-baseline: central; }
.st .sub { fill: var(--muted); font-size: 10px; }
.st.is-now rect { stroke: var(--accent); stroke-width: 2.2; fill: var(--accent-soft); }
.st.is-end.is-now rect { fill: var(--accent); }
.st.is-end.is-now text { fill: var(--bg); }
.st.is-ask.is-now rect { stroke: var(--attn); fill: var(--attn); }
.mv path { fill: none; stroke: var(--ink); stroke-width: 1.6; transition: stroke .4s ease; }
.mv .head { fill: var(--ink); stroke: none; transition: fill .4s ease; }
.mv .lab rect { fill: var(--sheet-2); }
.mv .lab text { fill: var(--muted); font-size: 10.5px; text-anchor: middle; dominant-baseline: central; }
.mv.is-claim path { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.3; }
.mv.is-claim .head { fill: var(--muted); }
.mv.is-point path { stroke: var(--attn); stroke-width: 2.2; }
.mv.is-point .head { fill: var(--attn); }
.mv.is-point .lab text { fill: var(--attn); }
.mv.is-fresh path { stroke: var(--accent); stroke-width: 2.4; }
.mv.is-fresh .head { fill: var(--accent); }
.mv.is-ready .lab text { fill: var(--accent); font-weight: 700; }
#mach-token { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
#mach-svg.is-tall .st text { font-size: 13.5px; }
#mach-svg.is-tall .st .sub { font-size: 11px; }
#mach-svg.is-tall .mv .lab text { font-size: 11.5px; }
.mach-foot { padding: .7rem 1rem .75rem; display: grid; gap: .45rem; }
.proven { margin: 0; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; font-size: .76rem; }
.proven .lg { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.proven .count { margin-left: auto; white-space: nowrap; }
.proven b { color: var(--ink); font-variant-numeric: tabular-nums; }
.legend { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ink); }
.legend.dashed { border-top: 2px dashed var(--muted); }

/* ---------- 03 memory ---------- */
.mem-stage { position: relative; background: var(--sheet-2); }
#mem-canvas { display: block; width: 100%; height: 344px; cursor: grab; touch-action: pan-y; }
#mem-canvas.is-drag { cursor: grabbing; }
#mem-canvas.is-over { cursor: pointer; }
.mem-tools { position: absolute; bottom: .5rem; right: .5rem; display: grid; gap: 2px; padding: 2px; border-radius: 8px; background: var(--bg); box-shadow: 0 0 0 1px var(--sheet-line); }
.mem-stage.is-tall .mem-tools { top: .5rem; bottom: auto; }
.mem-tools button { min-width: 1.9rem; height: 1.7rem; padding: 0 .5em; border-radius: 6px; color: var(--muted); }
.mem-tools button:hover { background: var(--sheet-2); color: var(--ink); }
.mem-key { margin: 0; padding: .45rem 1rem; list-style: none; display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .7rem; color: var(--muted); border-top: 1px solid var(--sheet-line); background: var(--sheet); }
.mem-key li::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .4em; background: currentColor; }
.mem-key [data-kind="invariant"]::before { color: var(--k-invariant); transform: rotate(45deg); }
.mem-key [data-kind="mechanism"]::before { color: var(--k-mechanism); }
.mem-key [data-kind="gotcha"]::before { color: var(--k-gotcha); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.mem-key [data-kind="directive"]::before { color: var(--k-directive); border-radius: 50%; }
.mem-tip { position: absolute; z-index: 2; max-width: 16rem; padding: .35rem .55rem; border-radius: 6px; background: var(--ink); color: var(--bg); font-size: .72rem; line-height: 1.35; pointer-events: none; transform: translate(-50%, calc(-100% - 12px)); }
.mem-foot { padding: .7rem 1rem .8rem; display: grid; gap: .5rem; }
.mem-foot .say { min-height: 1.45em; }
.mem-hits { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem; }
.mem-hits:empty { display: none; }
.mem-hits button { display: flex; align-items: baseline; gap: .45em; width: 100%; padding: .3em .6em; border-radius: 6px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--sheet-line); font-size: .72rem; text-align: left; }
.mem-hits button:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.mem-hits .hop { color: var(--muted); white-space: nowrap; margin-left: auto; }
.mem-hits .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kdot { flex: none; display: inline-block; width: .55em; height: .55em; background: currentColor; align-self: center; }
.kdot[data-kind="invariant"] { color: var(--k-invariant); transform: rotate(45deg); }
.kdot[data-kind="mechanism"] { color: var(--k-mechanism); }
.kdot[data-kind="gotcha"] { color: var(--k-gotcha); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.kdot[data-kind="directive"] { color: var(--k-directive); border-radius: 50%; }
.mem-card { padding: .65rem .8rem .7rem; border-radius: 9px; background: var(--bg); border: 1px solid var(--sheet-line); }
.mem-card .kind { margin: 0 0 .2rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: center; gap: .5em; }
.mem-card h4 { margin: 0 0 .25rem; font-family: var(--serif); font-size: 1rem; font-weight: 600; line-height: 1.3; }
.mem-card p { margin: 0 0 .4rem; font-family: var(--serif); font-size: .9rem; line-height: 1.45; }
.mem-card .anchors { margin: 0; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.mem-card .drift { color: var(--attn); font-weight: 700; }
.badge-drift { padding: 0 .45em; border-radius: 4px; background: var(--attn); color: var(--bg); font-weight: 700; letter-spacing: .02em; }

/* ---------- 04 judgment ---------- */
.night-steps { margin: 0; padding: .55rem .6rem 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.night-steps button { width: 100%; padding: .45em .5em .5em; text-align: left; color: var(--muted); border-top: 2px solid var(--sheet-line); font-size: .74rem; line-height: 1.3; transition: border-color .25s ease, color .25s ease; }
.night-steps button b { display: block; color: inherit; }
.night-steps button[aria-current="step"] { border-color: var(--accent); color: var(--ink); }
.night-steps button.is-done { border-color: var(--accent-soft); }
.night-body { padding: .7rem .8rem .2rem; min-height: 318px; }
.night-body h4 { margin: 0 0 .5rem; font-family: var(--serif); font-size: 1rem; font-weight: 600; line-height: 1.35; }
.rawlog { margin: 0; padding: .5rem .2rem; list-style: none; background: var(--sheet-2); border-radius: 8px; font-size: .72rem; line-height: 1.6; }
.rawlog li { display: grid; grid-template-columns: 3.3em 6.6em minmax(0, 1fr); gap: .6em; padding: 0 .6rem; border-left: 3px solid transparent; transition: background .4s ease, border-color .4s ease, opacity .4s ease; }
.rawlog .t, .rawlog .who { color: var(--muted); }
.rawlog .cmd { overflow-wrap: anywhere; }
.rawlog .err { color: var(--bad); }
.rawlog .tag { justify-self: start; grid-column: 3; margin: .05rem 0 .25rem; padding: 0 .5em; border-radius: 4px; font-weight: 700; display: none; }
.rawlog.is-mined li { opacity: .45; }
.rawlog.is-mined li[data-g] { opacity: 1; }
.rawlog.is-mined li[data-g="loop"] { background: var(--bad-soft); border-color: var(--bad); }
.rawlog.is-mined li[data-g="work"] { background: var(--attn-soft); border-color: var(--attn); }
.rawlog.is-mined .tag { display: inline-block; }
.rawlog .tag.loop { background: var(--bad); color: var(--bg); }
.rawlog .tag.work { background: var(--attn); color: var(--bg); }
.rawlog .refused { color: var(--attn); font-weight: 700; }
.rawlog .fine { color: var(--accent); }
.rule { margin: 0 0 .6rem; padding: .8rem .9rem; border-radius: 9px; background: var(--bg); border: 1px solid var(--sheet-line); }
.rule .kind { margin: 0 0 .3rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.rule p { margin: 0; font-family: var(--serif); font-size: 1.02rem; line-height: 1.45; }
.rule p + p { margin-top: .5rem; font-size: .9rem; color: var(--muted); }
.night-note { margin: .6rem 0 0; font-family: var(--serif); font-size: .9rem; line-height: 1.45; color: var(--muted); }
.night-note b { color: var(--ink); font-weight: 600; }
.night-nav { display: flex; justify-content: space-between; gap: .5rem; padding: .6rem .8rem .8rem; }

.proposals { padding: .7rem .8rem 0; }
.rings-stage { display: grid; grid-template-columns: minmax(0, 12.5rem) minmax(0, 1fr); gap: .4rem 1rem; align-items: center; padding: .4rem .8rem .9rem; min-height: 352px; }
#ring-svg { display: block; width: 100%; height: auto; font-family: var(--mono); overflow: visible; }
#ring-svg .orbit { fill: none; stroke: var(--sheet-line); stroke-width: 1; }
#ring-svg .core { fill: var(--ink); }
#ring-svg .core-t { fill: var(--bg); font-size: 9px; text-anchor: middle; dominant-baseline: central; }
#ring-svg .dot { fill: var(--bg); stroke: var(--muted); stroke-width: 1.2; transition: fill .3s ease, stroke .3s ease; }
#ring-svg .dot[data-v] { fill: var(--bad); stroke: var(--bad); }
#ring-svg .dot[data-v="build"] { fill: var(--accent); stroke: var(--accent); }
#ring-svg .dot[data-v="smaller"] { fill: var(--attn); stroke: var(--attn); }
#ring-svg .dot.is-on { stroke: var(--ink); stroke-width: 3; }
.ring-list { width: 100%; margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.ring-list button { display: grid; grid-template-columns: 1.3em minmax(0, 1fr) auto; gap: .5em; align-items: baseline; width: 100%; padding: .32em .55em; border-radius: 6px; text-align: left; transition: background .18s ease, opacity .3s ease; }
.ring-list button b { font-weight: 400; color: var(--muted); }
.ring-list button:hover:not([disabled]) { background: var(--bg); }
.ring-list button[aria-pressed="true"] { background: var(--bg); box-shadow: inset 0 0 0 1px var(--sheet-line); }
.ring-list button[disabled] { opacity: .4; cursor: default; }
.ring-list .v:empty { display: none; }
.ring-panel { display: grid; gap: .6rem; align-content: center; justify-items: start; }
.ring-card { width: 100%; padding: .75rem .85rem; border-radius: 9px; background: var(--bg); border: 1px solid var(--sheet-line); min-height: 8.6rem; }
.ring-card .kind { margin: 0 0 .3rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; gap: .6em; align-items: center; flex-wrap: wrap; }
.ring-card p { margin: 0; font-family: var(--serif); font-size: .98rem; line-height: 1.45; }
.v { padding: 0 .5em; border-radius: 4px; background: var(--bad); color: var(--bg); font-weight: 700; letter-spacing: .02em; text-transform: none; }
.v { font-size: .9em; white-space: nowrap; }
[data-v="build"] > .v { background: var(--accent); }
[data-v="smaller"] > .v { background: var(--attn); }
.ring-verdict { margin: 0; padding: .65rem .85rem; border-radius: 9px; background: var(--accent-soft); font-family: var(--serif); font-size: .93rem; line-height: 1.45; }
.ring-verdict b { font-weight: 600; }

/* ---------- closing ---------- */
.closing { max-width: 46rem; margin: 0 auto; padding: clamp(5rem, 16vh, 10rem) clamp(1.25rem, 4vw, 2rem) 0; }
.closing h2 { margin-bottom: 1.1rem; }
.closing > p { font-size: 1.12em; line-height: 1.6; }
.cta { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1.8rem 0 1.4rem; }
.closing .fine { font-size: .9rem; color: var(--muted); max-width: 36rem; }
.foot { max-width: var(--w); margin: clamp(4rem, 12vh, 7rem) auto 0; padding: 1.4rem clamp(1.25rem, 4vw, 2rem) clamp(2.5rem, 7vh, 4rem); border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1.5rem; font-size: .9rem; color: var(--muted); }
.foot a { color: var(--muted); text-decoration-color: transparent; }
.foot a:hover, .foot a:focus-visible { color: var(--ink); text-decoration-color: var(--link-underline); }
.foot-links { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }

/* ---------- a wide but short window: the standing instrument must fit in it ---------- */
@media (min-width: 1100px) and (min-height: 800px) and (max-height: 840px) {
  .log { height: 236px; }
  .att-inbox { min-height: 0; }
  .shot img { height: 84px; }
  .night-body { min-height: 286px; }
  .rings-stage { min-height: 0; }
  .inst figcaption { padding-top: .5rem; padding-bottom: .55rem; }
}

/* ---------- narrow ---------- */
@media (max-width: 719px) {
  .top-links { gap: .5rem 1.1rem; }
  .top-links .btn { order: 3; }
  .inst { border-radius: 10px; font-size: .76rem; }
  .tally { gap: .8rem; }
  .tally dt { font-size: .9em; }
  #streams-canvas { height: 196px; }
  .log { height: 250px; }
  #mem-canvas { height: 330px; }
  .mem-hits { grid-template-columns: minmax(0, 1fr); }
  .rings-stage { grid-template-columns: minmax(0, 1fr); }
  #ring-svg { max-width: 11rem; margin: 0 auto; }
  .seg button { padding: .42em .6em; }
  .seg-sub { display: none; }
  .rawlog li { grid-template-columns: 3.1em minmax(0, 1fr); }
  .rawlog .who { display: none; }
  .rawlog .tag { grid-column: 2; }
  .btn-lg { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .top, .rail, .foot, .do { display: none; }
}
