/* Aceeași rachetă, trei nume, după cine o lansează
   Palette: a spec sheet, not a battlefield — pale technical paper, navy ink for
   structure, a stencil-orange flag for the decoded result. Both themes declared in
   full; no colour appears outside a token block. */

:root {
  --paper:        #eef0ee;
  --surface:      #f8f9f7;
  --surface-deep: #dfe3df;
  --rule:         #c7cdc6;
  --rule-strong:  #98a196;

  --text:         #10161a;
  --text-soft:    #34424a;
  --text-muted:   #4c5a60;

  --ink:          #1c4066;   /* structure — links, active states */
  --ink-deep:     #143152;
  --flag:         #b8460f;   /* the decoded result, the one flagged letter */
  --flag-deep:    #96390c;
  --ok:           #3c6e3f;
  --ghost:        #aab2a6;

  --map-land:     #e2e6e0;

  --shadow:       0 1px 2px rgba(16, 22, 26, .08), 0 8px 28px rgba(16, 22, 26, .10);
  --focus:        #1c4066;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --measure: 34rem;
  --gutter: clamp(1.15rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #0e1216;
    --surface:      #171c20;
    --surface-deep: #212a2c;
    --rule:         #2f3a3b;
    --rule-strong:  #4b5a5a;

    --text:         #eef2f2;
    --text-soft:    #c7d1d0;
    --text-muted:   #a6b2b0;

    --ink:          #6fa8d8;
    --ink-deep:     #8fc0ea;
    --flag:         #e2843f;
    --flag-deep:    #f0a266;
    --ok:           #7ebb81;
    --ghost:        #5e6b68;

    --map-land:     #1c2422;

    --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .38);
    --focus:        #6fa8d8;
  }
}
:root[data-theme="dark"] {
  --paper:        #0e1216;
  --surface:      #171c20;
  --surface-deep: #212a2c;
  --rule:         #2f3a3b;
  --rule-strong:  #4b5a5a;

  --text:         #eef2f2;
  --text-soft:    #c7d1d0;
  --text-muted:   #a6b2b0;

  --ink:          #6fa8d8;
  --ink-deep:     #8fc0ea;
  --flag:         #e2843f;
  --flag-deep:    #f0a266;
  --ok:           #7ebb81;
  --ghost:        #5e6b68;

  --map-land:     #1c2422;

  --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .38);
  --focus:        #6fa8d8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.62;
  text-rendering: optimizeLegibility;
}
@media (min-width: 46rem) { body { font-size: 1.125rem; line-height: 1.66; } }

a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: from-font; }
a:hover { text-decoration-color: var(--flag); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.wide { max-width: 78rem; margin: 0 auto; padding: 0 var(--gutter); }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--text);
  padding: .6rem .9rem; border: 1px solid var(--rule-strong); border-radius: 5px; z-index: 60;
}
.skip:focus { left: .8rem; top: .8rem; }

code, .mds { font-family: var(--mono); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .55rem;
  padding: .3rem var(--gutter); background: color-mix(in srgb, var(--paper) 97%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: .75rem; min-height: 2.5rem;
}
.topbar .home { font-weight: 600; text-decoration: none; color: var(--text-soft); flex: none; }
.topbar .spacer { flex: 1; }
.topnav {
  display: flex; gap: .1rem; overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none; margin-left: .25rem; min-width: 0;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a { padding: .2rem .5rem; border-radius: 999px; text-decoration: none; color: var(--text-muted); white-space: nowrap; }
.topnav a:hover { color: var(--flag); background: var(--surface-deep); }
.topnav a[aria-current="true"] { color: var(--text); background: var(--surface-deep); font-weight: 600; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.85rem; height: 1.85rem; padding: 0; border-radius: 999px; cursor: pointer;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--rule-strong);
}
.icon-btn:hover { color: var(--flag); border-color: var(--flag); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); text-decoration: none; font: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--flag); color: var(--flag); }
.chip[aria-current="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }
@media (max-width: 34rem) {
  .topbar .home { max-width: 6.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { gap: .35rem; }
  .topnav a { padding: .2rem .4rem; }
}

/* ---------- hero ---------- */
.hero { padding: clamp(2.4rem, 7vw, 4.6rem) 0 1.2rem; }
.kicker {
  font-family: var(--sans); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--flag); margin: 0 0 .85rem; font-weight: 650;
}
h1 {
  font-size: clamp(2.05rem, 6.4vw, 3.3rem); line-height: 1.07; letter-spacing: -.022em;
  font-weight: 650; margin: 0 0 1rem; text-wrap: balance;
}
.deck { font-size: 1.1rem; color: var(--text-soft); margin: 0 0 1.3rem; }
@media (min-width: 46rem) { .deck { font-size: 1.24rem; } }
.byline { font-family: var(--sans); font-size: .78rem; color: var(--text-muted); margin: 0; }

h2 {
  font-size: clamp(1.4rem, 3.6vw, 1.85rem); line-height: 1.16; letter-spacing: -.015em;
  font-weight: 650; margin: 2.8rem 0 .9rem; text-wrap: balance;
}
h3 { font-size: 1.09rem; font-weight: 650; margin: 1.9rem 0 .55rem; }
section { scroll-margin-top: 3.4rem; }
p { margin: 0 0 1.15rem; }
.lede::first-letter {
  float: left; font-size: 3.3em; line-height: .84; padding: .06em .09em 0 0;
  color: var(--flag); font-weight: 650;
}
strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }

.note {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--ghost);
  border-radius: 0 6px 6px 0; padding: 1rem 1.15rem; margin: 1.7rem 0;
  font-size: .9375rem; color: var(--text-soft);
}
.note h3 { margin: 0 0 .4rem; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.note p:last-child { margin-bottom: 0; }

/* ---------- reading rail ---------- */
.rail {
  display: none; position: fixed; top: 50%; right: 1.4rem; transform: translateY(-50%);
  flex-direction: column; align-items: flex-end; gap: .5rem; z-index: 30;
}
@media (min-width: 76rem) { .rail { display: flex; } }
.rail-dot { position: relative; display: flex; align-items: center; justify-content: flex-end; text-decoration: none; padding: .15rem 0; width: 14px; }
.rail-dot .dot {
  display: block; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--rule-strong); transition: background-color .15s ease, transform .15s ease;
}
.rail-dot:hover .dot, .rail-dot:focus-visible .dot { background: var(--text-soft); }
.rail-dot.active .dot { background: var(--flag); transform: scale(1.45); }
.rail-label {
  position: absolute; right: 100%; top: 50%; margin-top: -.85rem; margin-right: .5rem;
  font-family: var(--sans); font-size: .75rem; line-height: 1.2; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: .25rem .55rem; white-space: nowrap; box-shadow: var(--shadow);
  opacity: 0; transform: translateX(6px); pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { opacity: 1; transform: none; }
.rail-dot.active .rail-label { color: var(--text); border-color: var(--rule-strong); }
@media (prefers-reduced-motion: reduce) { .rail-dot .dot, .rail-label { transition: none; } }
@media print { .rail { display: none; } }

/* ---------- figures ---------- */
figure { margin: 2rem 0; }
figure img {
  display: block; width: 100%; height: auto; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--surface-deep);
}
figcaption { font-family: var(--sans); font-size: .8125rem; line-height: 1.5; color: var(--text-muted); margin-top: .55rem; }
figcaption b { color: var(--text-soft); font-weight: 650; }
figcaption .credit { display: block; margin-top: .25rem; font-size: .75rem; }

/* ---------- the decoder ---------- */
.decoder {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: clamp(1.1rem, 3vw, 1.7rem); margin: 1.8rem 0;
}
.decoder-input {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  font-family: var(--mono); margin: 0 0 1.1rem;
}
.decoder-input select {
  font: inherit; font-family: var(--mono); font-size: 1.35rem; font-weight: 650;
  padding: .3rem .5rem; border: 1px solid var(--rule-strong); border-radius: 6px;
  background: var(--paper); color: var(--text); appearance: none; -webkit-appearance: none;
  text-align: center; min-width: 3.4rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 56%, calc(100% - 7px) 56%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; padding-right: 1.5rem;
}
.decoder-input select:hover { border-color: var(--flag); }
.decoder-dash { font-size: 1.35rem; color: var(--text-muted); font-weight: 650; }
.decoder-input .num-input {
  font: inherit; font-family: var(--mono); font-size: 1.35rem; font-weight: 650;
  width: 4.6rem; padding: .3rem .4rem; border: 1px solid var(--rule-strong); border-radius: 6px;
  background: var(--paper); color: var(--text); text-align: center;
}
.decoder-input .num-input:hover { border-color: var(--flag); }
.decoder-code {
  font-family: var(--mono); font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 700;
  letter-spacing: .02em; margin: 0 0 1rem; color: var(--text);
}
.decoder-code .lit { color: var(--flag); }
.decoder-lines { display: grid; gap: .55rem; font-family: var(--sans); font-size: .92rem; }
.decoder-line { display: flex; gap: .6rem; align-items: baseline; }
.decoder-line .k {
  font-family: var(--mono); font-weight: 700; color: var(--flag); flex: none; width: 1.4rem;
  text-align: center;
}
.decoder-line .v { color: var(--text-soft); }
.decoder-line .years { color: var(--text-muted); font-size: .8em; margin-left: .35rem; }
.decoder-verdict {
  margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: .88rem; color: var(--text-soft);
}
.decoder-verdict b { color: var(--ok); }
.decoder-verdict.unused b { color: var(--flag); }
.decoder-verdict .matches { margin: .5rem 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; }
.decoder-verdict .matches li {
  background: var(--surface-deep); border: 1px solid var(--rule); border-radius: 999px;
  padding: .18rem .6rem; font-family: var(--mono); font-size: .8rem;
}

/* ---------- letter tables ---------- */
.lettergrid { display: grid; gap: 1.4rem; margin: 1.6rem 0; }
@media (min-width: 58rem) { .lettergrid { grid-template-columns: 1fr 1fr; } }
.lettergrid .tablewrap { margin: 0; }
.lettergrid h3 { margin: 0 0 .6rem; }
.lettergrid table td:first-child, .lettergrid table th:first-child { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.yr { color: var(--text-muted); font-size: .78rem; font-family: var(--sans); }

/* ---------- bar charts ---------- */
.bars { margin: 1.6rem 0; }
.barchart { display: block; width: 100%; height: auto; font-family: var(--sans); }
.barchart .bl { font-size: 13px; fill: var(--text-soft); }
.barchart .bv { font-size: 13px; fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.barchart .btrack { fill: var(--surface-deep); }
.barchart .bar { fill: var(--flag); }
.barchart .bar.dim { fill: var(--ghost); }

/* ---------- tables ---------- */
.tablewrap {
  overflow-x: auto; margin: 1.7rem 0; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface);
}
@media (min-width: 52rem) {
  .wrap .tablewrap {
    width: min(70rem, calc(100vw - 2 * var(--gutter)));
    margin-left: 50%; transform: translateX(-50%);
  }
}
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .84rem; }
caption { text-align: left; padding: .8rem .9rem .1rem; color: var(--text-muted); font-size: .8rem; }
th, td { text-align: left; padding: .48rem .9rem; border-top: 1px solid var(--rule); vertical-align: top; }
td:first-child { font-weight: 600; color: var(--text); }
@media (min-width: 52rem) { td:first-child, th:first-child { white-space: nowrap; } }
thead th { border-top: 0; color: var(--text-muted); font-weight: 600; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.code { font-family: var(--mono); }
tbody tr:hover { background: var(--surface-deep); }
[hidden] { display: none !important; }
.morewrap { margin: .9rem 0 0; }
.chip.more { font-family: var(--sans); }

/* ---------- corpus filter ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.1rem; font-family: var(--sans); font-size: .82rem;
}
.filterbar button {
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); cursor: pointer; padding: .28rem .68rem; font: inherit;
}
.filterbar button:hover { border-color: var(--flag); color: var(--flag); }
.filterbar button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink-deep); color: var(--paper); font-weight: 600; }
.searchbox {
  font: inherit; font-family: var(--sans); font-size: .88rem; padding: .4rem .7rem;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--paper); color: var(--text);
  min-width: 12rem; flex: 1 1 12rem;
}

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 1.8rem 0; padding: 0; border-left: 2px solid var(--rule); }
.timeline li { position: relative; padding: 0 0 1.3rem 1.4rem; }
.timeline li::before {
  content: ""; position: absolute; left: -.4rem; top: .3rem; width: .55rem; height: .55rem;
  border-radius: 50%; background: var(--flag);
}
.timeline .yr-tag { font-family: var(--mono); font-weight: 700; color: var(--text); display: block; font-size: .88rem; }
.timeline p { margin: .2rem 0 0; color: var(--text-soft); font-size: .95rem; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); margin-top: 3.2rem; padding: 1.8rem 0 3rem; font-family: var(--sans); font-size: .84rem; color: var(--text-muted); }
footer a { color: var(--text-soft); }
footer ul { margin: .5rem 0 0; padding-left: 1.1rem; }
footer li { margin: .2rem 0; }
.totop { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text-soft); }

@media print {
  .topbar, .decoder, .filterbar { display: none; }
  body { background: #fff; color: #000; }
}
