:root {
  --paper: #F3F5F2;
  --paper-2: #E8ECE8;
  --ink: #1B2430;
  --muted: #5B6672;
  --rule: #C9D0CC;
  --brass: #B08D2E;
  --brass-ink: #6E5612;
  --ok: #2E7D5B;
  --bad: #A33A3A;

  /* assumption families: classical in slates, post-quantum in distinct hues */
  --f-factoring: #7A8794;
  --f-ffdl: #A3AEB8;
  --f-ec: #5E6E7E;
  --f-pairing: #8C99A6;
  --f-lattice: #2A8C9A;
  --f-hash: #2E7D5B;
  --f-symmetric: #8FA33A;
  --f-multivariate: #8A5AA0;
  --f-code: #B84A62;
  --f-isogeny: #3F57B5;

  --sans: "Schibsted Grotesk", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --measure: 68ch;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--brass); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--gutter); top: 0.5rem; background: var(--ink); color: var(--paper); padding: 0.4rem 0.7rem; }

h1, h2, h3, button, label, nav, .wordmark, caption, th, input, select, textarea { font-family: var(--sans); }

header.site {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.75rem 2rem;
  padding: 1.25rem var(--gutter);
}
.wordmark { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; text-decoration: none; display: inline-flex; align-items: flex-end; gap: 0.45rem; }
.wordmark img { display: block; }
nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; font-size: 0.95rem; }
nav a { text-decoration: none; color: var(--muted); }
nav a:hover { color: var(--ink); }

main > section { padding: 0 var(--gutter); margin: 0 0 6rem; }

/* ---------- hero ---------- */
.hero { padding-top: clamp(3rem, 9vw, 7rem) !important; }
.hero-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.hero-head h1 { margin: 0; }
.hero-mark { width: clamp(7rem, 17vw, 15rem); height: auto; flex: 0 0 auto; margin-right: clamp(0rem, 6vw, 6rem); }
@media (max-width: 40rem) { .hero-mark { width: 6.5rem; } .hero-head { align-items: flex-start; } }
h1 {
  font-size: clamp(3rem, 10.5vw, 9.5rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.88;
  margin: 0 0 2rem;
  max-width: 11ch;
}
.lede { max-width: var(--measure); font-size: clamp(1.15rem, 1.6vw, 1.35rem); margin: 0 0 1.25rem; }
.aside { max-width: var(--measure); font-size: 1rem; color: var(--muted); margin: 0 0 1rem; }
.quote { max-width: var(--measure); margin: 0 0 3.5rem; padding-left: 1.1rem; border-left: 3px solid var(--rule); }
.quote blockquote { margin: 0; font-size: 1rem; font-style: italic; color: var(--ink); }
.quote blockquote p { margin: 0 0 0.4rem; }
.quote figcaption { padding: 0; font: 0.88rem/1.45 var(--sans); color: var(--muted); }

.ribbon-figure { margin: 0; }
.ribbon-switch { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.ribbon-switch button {
  font-size: 0.9rem; font-weight: 500; color: var(--muted);
  background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 0.3rem 0.85rem; cursor: pointer;
}
.ribbon-switch button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); background: var(--paper-2); }

.ribbon {
  display: flex; height: clamp(4.5rem, 11vw, 8rem); width: 100%; gap: 1px;
  background: var(--paper);
}
.seg {
  flex: 0 0 auto; min-width: 3px; height: 100%; border: 0; padding: 0; cursor: pointer;
  background: var(--c); position: relative;
  transition: filter 120ms;
}
.seg:hover, .seg:focus-visible, .seg[aria-pressed="true"] { filter: brightness(1.18) saturate(1.1); }
.seg[aria-pressed="true"] { box-shadow: inset 0 -6px 0 var(--brass); }
.seg .seg-name {
  position: absolute; left: 0.7rem; bottom: 0.55rem; color: #fff; font: 600 clamp(0.85rem, 1.8vw, 1.25rem)/1 var(--sans);
  white-space: nowrap; pointer-events: none; text-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
}
@media (prefers-reduced-motion: no-preference) {
  .ribbon.animate .seg { transform-origin: left; animation: grow 900ms cubic-bezier(.2,.7,.1,1) both; animation-delay: calc(var(--i) * 18ms); }
  @keyframes grow { from { transform: scaleX(0); } }
}

.ribbon-readout {
  display: flex; flex-wrap: wrap; gap: 0.2rem 1.5rem; align-items: baseline;
  border-bottom: 1px solid var(--rule); padding: 0.8rem 0; min-height: 3.4rem;
  font-family: var(--sans);
}
.ribbon-readout .r-name { font-weight: 700; font-size: 1.15rem; }
.ribbon-readout .r-meta { color: var(--muted); }
figcaption { color: var(--muted); padding: 0.8rem 0; max-width: var(--measure); }

.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.4rem; font: 0.9rem var(--sans); }
.legend li { display: flex; align-items: center; gap: 0.45rem; }
.legend li::before { content: ""; width: 0.8rem; height: 0.8rem; background: var(--c); }
.legend .pq-split { flex-basis: 100%; height: 0; }

/* ---------- prose ---------- */
h2 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 0 0 1.5rem; }
.prose { max-width: calc(var(--measure) + 2 * var(--gutter)); }
.prose p, .prose-narrow { max-width: var(--measure); }
.schemes { display: grid; gap: 1.5rem 3rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin: 2rem 0; max-width: 72rem; }
.prose .schemes { max-width: none; width: min(72rem, calc(100vw - 2 * var(--gutter))); }
.schemes dt { font: 700 1.2rem var(--sans); margin-bottom: 0.4rem; }
.schemes dd { margin: 0; }
.warning { border-left: 4px solid var(--brass); padding: 0.2rem 0 0.2rem 1rem; color: var(--ink); }

/* ---------- tables ---------- */
.tables { display: grid; gap: 2.5rem 3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 31rem), 1fr)); align-items: start; max-width: 72rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font: 0.95rem/1.4 var(--sans); }
caption { text-align: left; font-weight: 700; font-size: 1.15rem; padding-bottom: 0.6rem; }
th, td { text-align: left; padding: 0.38rem 0.75rem 0.38rem 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
th { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; padding-left: 0.75rem; }
td .swatch { display: inline-block; width: 0.65rem; height: 0.65rem; background: var(--c); margin-right: 0.5rem; }
td.fam { color: var(--muted); white-space: nowrap; }
tr.unsupported td:first-child::after { content: " (not in browser build)"; color: var(--bad); font-size: 0.8rem; }

/* ---------- tools ---------- */
.tools { border: 1px solid var(--ink); background: #fff; max-width: 72rem; }
.tools-loading, .tools-error { padding: 2rem; margin: 0; }
.tools-error { color: var(--bad); }
.tool-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--ink); background: var(--paper-2); }
.tool-tabs button {
  border: 0; border-right: 1px solid var(--rule); background: none; padding: 0.75rem 1.1rem; font-size: 0.95rem; font-weight: 500; cursor: pointer; color: var(--muted);
}
.tool-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: inset 0 -3px 0 var(--brass); }
.tool-panel { padding: 1.5rem clamp(1rem, 3vw, 2rem) 2rem; }
.tool-panel[hidden] { display: none; }
.tool-panel h3 { font-size: 1.25rem; margin: 0 0 0.4rem; }
.tool-panel .intro { color: var(--muted); max-width: var(--measure); margin: 0 0 1.25rem; font-size: 1rem; }
.field { display: grid; gap: 0.3rem; margin-bottom: 1rem; max-width: 44rem; }
.field label, .field .label { font-weight: 600; font-size: 0.9rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; font-family: var(--sans); }
input[type="text"], input[type="number"], select, textarea {
  font: 0.95rem/1.4 var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); padding: 0.5rem 0.6rem; width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
textarea.hexout { font-family: var(--mono); font-size: 0.85rem; background: var(--paper-2); }
input[type="file"] { font: 0.9rem var(--sans); }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.5rem 0 1rem; }
button.primary, button.secondary {
  font-size: 0.95rem; font-weight: 600; padding: 0.55rem 1.1rem; cursor: pointer; border: 1px solid var(--ink);
}
button.primary { background: var(--ink); color: var(--paper); }
button.secondary { background: none; color: var(--ink); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.status { font: 0.95rem var(--sans); margin: 0.5rem 0; min-height: 1.5rem; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }
.status.busy::before { content: ""; display: inline-block; width: 0.7rem; height: 0.7rem; border: 2px solid var(--brass); border-right-color: transparent; border-radius: 50%; margin-right: 0.5rem; vertical-align: -0.05rem; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status.busy::before { animation: none; } }

.keyring { border-top: 1px solid var(--rule); margin-top: 1.5rem; padding-top: 1rem; }
.keyring table td { font-size: 0.9rem; }
.keyring code, .mono { font-family: var(--mono); font-size: 0.85rem; }
.notice { background: var(--paper-2); border-left: 4px solid var(--bad); padding: 0.6rem 0.9rem; font: 0.92rem/1.45 var(--sans); max-width: 52rem; margin: 0 0 1.25rem; }
.recipients label { font-weight: 400; display: flex; gap: 0.5rem; align-items: center; font-size: 0.95rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font: 600 0.9rem var(--sans); margin-bottom: 0.3rem; padding: 0; }

footer.site { border-top: 1px solid var(--rule); padding: 1.5rem var(--gutter) 3rem; color: var(--muted); font-size: 1rem; }
footer.site p { max-width: var(--measure); margin: 0; }

@media (max-width: 40rem) {
  body { font-size: 1.05rem; }
  .seg .seg-name { display: none; }
}
.keyring td.num, .keyring th.num { padding-right: 1.5rem; }
.tool-panel h3.sub { margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
