/* A858 archive — tokens first, then layout, then components. */
:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --border: #dcdad3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #77756f;
  --link: #1f62b5;
  --accent: #2a78d6;
  --grid: #e6e4de;
  --ok: #08780a;
  --bad: #c42e2d;
  --mark-bg: #ffe08a;
  /* status (validated categorical order: blue, yellow, aqua, orange, violet, red) */
  --s-explained: #2a78d6;
  --s-inferred: #eda100;
  --s-solved: #1baf7a;
  --s-best-guess: #eb6834;
  --s-partial: #4a3aa7;
  --s-unsolved: #e34948;
  --s-excluded: #b9b7b0;
  /* encryption */
  --e-decrypted: #2a78d6;
  --e-unencrypted: #1baf7a;
  --e-encrypted: #eda100;
  --e-missing: #b9b7b0;
  /* run types */
  --r-seed: #2a78d6;
  --r-probable: #86b6ef;
  --r-fixed: #eda100;
  --r-open: #e34948;
  --r-other: #a3a19a;
  --r-companion: #c0457a;
  /* keys: the password pattern (categorical; the same hues as the status palette, read as categories here) */
  --k-name: #2a78d6;
  --k-namename: #1baf7a;
  --k-nametitle: #eb6834;
  --k-other: #4a3aa7;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #383835;
    --text: #f4f4f2; --text-2: #c3c2b7; --muted: #9b9a92; --link: #7fb0f0; --accent: #3987e5;
    --grid: #2c2c2a; --ok: #4cc34e; --bad: #f07878; --mark-bg: #6b5200;
    --s-explained: #3987e5; --s-inferred: #c98500; --s-solved: #199e70; --s-best-guess: #d95926;
    --s-partial: #9085e9; --s-unsolved: #e66767; --s-excluded: #5b5a55;
    --e-decrypted: #3987e5; --e-unencrypted: #199e70; --e-encrypted: #c98500; --e-missing: #5b5a55;
    --r-seed: #3987e5; --r-probable: #6d9fd8; --r-fixed: #c98500; --r-open: #e66767; --r-other: #6f6e68;
    --r-companion: #e27aa3;
    --k-name: #3987e5; --k-namename: #199e70; --k-nametitle: #d95926; --k-other: #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #383835;
  --text: #f4f4f2; --text-2: #c3c2b7; --muted: #9b9a92; --link: #7fb0f0; --accent: #3987e5;
  --grid: #2c2c2a; --ok: #4cc34e; --bad: #f07878; --mark-bg: #6b5200;
  --s-explained: #3987e5; --s-inferred: #c98500; --s-solved: #199e70; --s-best-guess: #d95926;
  --s-partial: #9085e9; --s-unsolved: #e66767; --s-excluded: #5b5a55;
  --e-decrypted: #3987e5; --e-unencrypted: #199e70; --e-encrypted: #c98500; --e-missing: #5b5a55;
  --r-seed: #3987e5; --r-probable: #6d9fd8; --r-fixed: #c98500; --r-open: #e66767; --r-other: #6f6e68;
  --r-companion: #e27aa3;
  --k-name: #3987e5; --k-namename: #199e70; --k-nametitle: #d95926; --k-other: #9085e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .hex { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 0.5em; }
h1 { font-size: 1.9rem; margin-top: 0.6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
h1 small { font-size: 0.55em; color: var(--muted); font-weight: 400; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }
.lede { font-size: 1.1rem; color: var(--text-2); max-width: 75ch; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

/* header / footer */
header.site { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-family: var(--mono); font-weight: 700; color: var(--text); white-space: nowrap; }
.brand .hex { color: var(--accent); }
header nav { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; font-size: 0.95rem; }
header nav a { color: var(--text-2); }
#theme { background: none; border: 1px solid var(--border); color: var(--text-2); border-radius: 6px; cursor: pointer; padding: 0 8px; font-size: 1rem; line-height: 1.6; }
footer { color: var(--muted); font-size: 0.88rem; padding-top: 32px; padding-bottom: 40px; border-top: 1px solid var(--border); margin-top: 48px; }
main { padding-bottom: 16px; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-top: 18px; }

/* tiles, cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile b { display: block; font-size: 1.75rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { color: var(--text-2); font-size: 0.9rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 6px; color: var(--link); }
.card p { margin: 0; color: var(--text-2); font-size: 0.93rem; }
.button { display: inline-block; border: 1px solid var(--accent); border-radius: 8px; padding: 6px 14px; }

/* badges and swatches */
.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; background: var(--sw, transparent); }
.badge.kind::before { display: none; }
.s-explained { --sw: var(--s-explained); } .s-inferred { --sw: var(--s-inferred); } .s-solved { --sw: var(--s-solved); }
.s-best-guess { --sw: var(--s-best-guess); } .s-partial { --sw: var(--s-partial); } .s-unsolved { --sw: var(--s-unsolved); }
.s-excluded { --sw: var(--s-excluded); }
.e-decrypted { --sw: var(--e-decrypted); } .e-unencrypted { --sw: var(--e-unencrypted); } .e-encrypted { --sw: var(--e-encrypted); }
.e-missing, .e-n\/a { --sw: var(--e-missing); }
.r-seed { --sw: var(--r-seed); } .r-probable { --sw: var(--r-probable); } .r-fixed { --sw: var(--r-fixed); } .r-open { --sw: var(--r-open); }
.r-short, .r-test, .r-single, .r-setup, .r-pre-automation { --sw: var(--r-other); }
.r-companion { --sw: var(--r-companion); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--sw); margin-right: 6px; vertical-align: -1px; }
.sw.boot { background: none; border: 2px solid var(--text-2); border-radius: 50%; }

/* proportion bar + legend */
.propbar { display: flex; gap: 2px; height: 22px; margin: 10px 0 8px; }
.propbar .seg { background: var(--sw); min-width: 3px; }
.propbar .seg:first-child { border-radius: 4px 0 0 4px; }
.propbar .seg:last-child { border-radius: 0 4px 4px 0; }
.propbar .seg:hover { filter: brightness(1.12); }
.legend { list-style: none; padding: 0; margin: 4px 0 12px; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.9rem; color: var(--text-2); }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }

/* svg charts */
figure { margin: 14px 0 18px; }
figcaption { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
svg.chart { width: 100%; height: auto; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .tick, svg.chart .baseline { stroke: var(--text-2); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font: 11px var(--sans); }
svg.chart .axis.lane { fill: var(--text-2); font-size: 12px; }
svg.chart rect.hit { fill: transparent; }
svg.chart rect.hours-work { fill: var(--accent); }
svg.chart rect.hours-off { fill: var(--s-excluded); }
svg.chart [class^="s-"], svg.chart [class*=" s-"] { fill: var(--sw); }
svg.chart [class^="r-"] { fill: var(--sw); }
svg.chart .bar:hover rect:not(.hit) { filter: brightness(1.15); }
svg.chart .bar:hover rect.hit { fill: var(--text); opacity: 0.05; }
svg.chart .dot { stroke: var(--surface); stroke-width: 2; }
svg.chart a:hover .dot { stroke: var(--text); }
svg.chart .runbar:hover rect.hit { fill: var(--text); opacity: 0.06; }
svg.chart .boot { fill: none; stroke: var(--text-2); stroke-width: 1.2; }
svg.chart .bootline { stroke: var(--text-2); stroke-width: 0.6; stroke-dasharray: 2 2; opacity: 0.7; }
svg.chart .dot-ok { fill: var(--s-explained); }
svg.chart .dot-bad { fill: none; stroke: var(--bad); stroke-width: 1.5; }
svg.chart .dot-plain { fill: var(--muted); }
svg.chart .skip { fill: var(--s-inferred); }
svg.chart .skip-band { fill: var(--s-inferred); opacity: 0.35; }
/* keys timeline */
.k-name { --sw: var(--k-name); } .k-namename { --sw: var(--k-namename); }
.k-nametitle { --sw: var(--k-nametitle); } .k-other { --sw: var(--k-other); }
svg.chart .dot[class*="k-"] { fill: var(--sw); }
svg.chart .dot.dense { stroke: none; }
svg.chart line.span[class*="k-"] { stroke: var(--sw); stroke-width: 2; opacity: 0.5; }
svg.chart rect.nokey { fill: var(--surface-2); }
details.postlist summary { cursor: pointer; color: var(--link); white-space: nowrap; }
details.postlist p { margin: 6px 0 0; line-height: 1.9; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin: 12px 0; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.data th, table.data td { padding: 5px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: var(--surface-2); }
table.data tr.change td { color: var(--s-explained); font-size: 0.85rem; background: var(--surface); border-bottom: 1px dashed var(--border); }
table.data tr.gap td { color: var(--s-inferred); font-size: 0.85rem; background: var(--surface); border-bottom: 1px dashed var(--border); }
table.data tr.zone td { color: var(--text); font-size: 0.85rem; font-weight: 600; background: var(--mark-bg); border-bottom: 1px solid var(--border); }
table.data tr.break td { color: var(--s-best-guess); font-size: 0.85rem; font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--s-best-guess); }
table.data td.summary { max-width: 46ch; color: var(--text-2); }
.filter { width: 100%; max-width: 420px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; margin-top: 8px; }

/* key-value metadata */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 8px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
dl.kv dd p { margin: 0; }
dl.kv.small { font-size: 0.92rem; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.posthead h1 .hex { letter-spacing: 0.02em; }
dl.defs dt { margin-top: 8px; }
dl.defs dd { margin-left: 0; color: var(--text-2); }
details.defs summary { cursor: pointer; color: var(--link); }
details.listing summary { cursor: pointer; color: var(--link); margin: 10px 0; }

/* bodies */
pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; line-height: 1.45; }
pre.body { white-space: pre-wrap; word-break: break-all; }
/* Long bodies collapse only when site.js runs (it adds .js), so the text is never unreachable. */
.js pre.body.long:not(.open) { max-height: 26em; overflow-y: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent); }
pre.plain { white-space: pre; }
pre.guids { font-size: 0.86rem; }
pre.guids .ln { color: var(--muted); user-select: none; }
pre.guids mark { background: var(--mark-bg); color: inherit; border-radius: 2px; padding: 0 1px; }
pre.decrypted { border-left: 3px solid var(--accent); }
.presumed { background: var(--mark-bg); border-radius: 2px; }
.lost { color: var(--muted); }
.file { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 8px 0 16px; }
.file p { margin: 6px 0; }
img.gifpreview { display: block; max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
code.wrap { overflow-wrap: anywhere; word-break: break-all; }
.expand { display: none; }
.js .expand { display: inline-block; margin-top: -4px; }
.expand { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--link); padding: 4px 10px; cursor: pointer; font: inherit; font-size: 0.9rem; }
ol.steps { padding-left: 1.4em; }
ol.steps li { margin: 6px 0; }
/* the chain from the post to its content: each box, with the step that made it from the box above */
.chain h2 { margin-bottom: 0.2em; }
.chain .box { margin: 0 0 4px; }
.chain .box h3 { margin: 0 0 6px; font-size: 0.98rem; color: var(--text-2); }
.step { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 8px; color: var(--text-2); font-size: 0.95rem; }
.step .arrow { color: var(--muted); font-size: 1.15rem; line-height: 1.3; }
.step > div { min-width: 0; }
ul.how { margin: 0; padding-left: 1.1em; }
ul.how li { margin: 3px 0; }
pre.wrap-hex { white-space: pre-wrap; word-break: break-all; }
.explain, .solution, .related { margin-top: 28px; }
.related .relposts { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.related .relposts li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.related .relposts a { font-family: var(--mono); }
.related .relposts small { color: var(--muted); }
.related .relfindings { margin-top: 12px; }
ul.highlights { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
ul.highlights li { display: grid; grid-template-columns: minmax(10rem, max-content) auto; gap: 4px 10px; align-items: baseline; padding-bottom: 10px; border-bottom: 1px solid var(--grid); }
ul.highlights a { font-family: var(--mono); white-space: nowrap; }
ul.highlights small { color: var(--muted); }
ul.highlights .hook { grid-column: 1 / -1; color: var(--text-2); }
@media (min-width: 720px) { ul.highlights .hook { grid-column: 2; } }
.prevnext { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; font-family: var(--mono); }
.prevnext small { color: var(--muted); }

/* prose */
.prose { max-width: 80ch; }
.prose.page { max-width: none; }
.prose.page > :not(figure):not(.tiles):not(.tablewrap):not(ul.legend) { max-width: 86ch; }
.prose pre { font-size: 0.86rem; }
.prose table { border-collapse: collapse; margin: 12px 0; font-size: 0.92rem; }
.prose > table { display: block; max-width: 100%; overflow-x: auto; }
.prose table th, .prose table td { border-bottom: 1px solid var(--grid); padding: 4px 10px; text-align: left; }
.prose table th { background: var(--surface-2); }
.prose figure, .prose .tiles, .prose .tablewrap { max-width: none; }
.prose blockquote { border-left: 3px solid var(--border); margin-left: 0; padding-left: 14px; color: var(--text-2); }
.years a, .years b { margin-right: 8px; }

@media (max-width: 640px) {
  h1 { font-size: 1.45rem; }
  dl.kv { grid-template-columns: 1fr; gap: 0 0; }
  dl.kv dt { margin-top: 8px; }
  .tile b { font-size: 1.4rem; }
}
svg.chart .band { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.nowrap { white-space: nowrap; }

/* the AMA page: code tables, and each reply with its question */
.prose.page > .keypair { max-width: none; }
.keypair { display: flex; flex-wrap: wrap; gap: 0 20px; }
.keypair figure { margin: 8px 0; }
pre.keygrid { font-size: 0.82rem; line-height: 1.3; }
.ama .qa { overflow-wrap: anywhere; border-bottom: 1px solid var(--grid); padding: 10px 0 12px; }
.ama .qa-meta { margin: 0 0 4px; font-size: 0.85rem; color: var(--muted); }
.ama blockquote { margin: 4px 0 8px; font-size: 0.95rem; }
.ama blockquote p { margin: 4px 0; }
.ama .answer { white-space: pre-wrap; }
.ama .decoded { font-weight: 600; }
.ama .undecoded { color: var(--muted); font-style: italic; }
.ama .qa-note { margin: 6px 0 0; font-size: 0.88rem; color: var(--text-2); }
.ama .keyswitch { margin: 18px 0 6px; padding: 6px 10px; background: var(--mark-bg); border-radius: 6px; font-weight: 600; }

/* letter grids in post write-ups: the message cells bold, framing words marked */
pre.lettergrid { line-height: 1.35; }
pre.lettergrid b { color: var(--accent); }
pre.lettergrid mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }
