@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: Archivo;
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
:root {
  --ink: #f3f2ed;
  --muted: #b8b8b1;
  --paper: #000;
  --sheet: #161616;
  --surface-raised: #222;
  --control: #101010;
  --rule: #454542;
  --control-edge: #70706b;
  --on-accent: #17160e;
  --yellow: #ffdb4d;
  --violet: #c6b6ed;
  --mint: #b4e5cf;
  --focus: var(--violet);
  --line: 1.6px solid var(--rule);
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, Arial, sans-serif;
  scroll-behavior: smooth;
}
* { box-sizing: border-box; }
::selection { color: var(--on-accent); background: var(--yellow); }
body { margin: 0; min-width: 280px; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select, a, summary { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
a { color: inherit; }
button { background: transparent; }
button:disabled { cursor: default; }
a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3, .brand, .footer-brand { font-family: Archivo, Arial, sans-serif; }
.wrap { width: min(1192px, calc(100% - 104px)); margin-inline: auto; }
.icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip:focus { position: absolute; z-index: 8; left: 10px; top: 10px; background: var(--yellow); color: var(--on-accent); padding: 10px; }
.masthead { border-bottom: var(--line); background: var(--paper); }
.mast-inner { height: 68px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.brand { display: inline-flex; gap: 12px; align-items: center; font-weight: 760; font-size: 1.55rem; letter-spacing: -.05em; text-decoration: none; }
.site-mark { display: block; flex: none; width: 34px; height: 34px; }
.main-nav, .nav-reference { display: flex; gap: 9px; align-items: center; }
.main-nav { gap: 32px; font-size: .89rem; font-weight: 600; }
.main-nav a { text-decoration: none; }
.nav-active { position: relative; }
.nav-active::after { content: ''; position: absolute; height: 3px; background: var(--yellow); border-radius: 3px; bottom: -6px; left: 0; right: 0; }
.nav-reference { padding: 9px 13px; border: var(--line); border-radius: 6px; background: var(--sheet); font-weight: 600; }
.nav-reference:hover, .square-btn:hover, .replay:hover { background: var(--surface-raised); border-color: var(--control-edge); }
.nav-reference .icon { width: 16px; height: 16px; }
.hero {
  background: var(--paper);
  border-bottom: var(--line);
}
.hero-inner { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 44px; padding-block: 30px 32px; }
.eyebrow, .small-mono, .phase, .field-label, .step-num, .formula-label, .table-wrap th, .sheet-row small, .ref-label {
  font-family: var(--mono); font-weight: 600; font-size: .75rem; letter-spacing: .075em; text-transform: uppercase;
}
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; font-size: .76rem; letter-spacing: .1em; }
.chapter-mark { display: inline-block; width: 21px; height: 12px; background: var(--violet); transform: skewX(-13deg); }
h1 { margin: 16px 0 17px; font-size: clamp(4.15rem, 5.65vw, 5.3rem); line-height: .96; letter-spacing: -.065em; word-spacing: .035em; font-weight: 820; }
.highlight { position: relative; isolation: isolate; display: inline-block; padding-right: .04em; }
.highlight::after { content: ''; position: absolute; z-index: -1; left: -.035em; right: -.02em; bottom: -.012em; height: .18em; background: var(--yellow); transform: rotate(-1.35deg); clip-path: polygon(0 8%, 100% 0, 99% 92%, .8% 100%); }
.hero-copy p { font-size: clamp(1rem, 1.25vw, 1.1rem); line-height: 1.55; max-width: 47ch; color: var(--muted); }
.dark-btn, .outline-btn, .subtle-btn, .mode-toggle button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 650; font-size: .91rem;
}
.dark-btn, .outline-btn {
  border: var(--line); border-radius: 6px; text-decoration: none; transition: transform .15s, box-shadow .15s, background-color .15s;
}
.outline-btn:hover { transform: translate(-1px,-1px); background: var(--surface-raised); border-color: var(--control-edge); }
.outline-btn:active { transform: translate(2px,2px); box-shadow: none; }
.hero-figure { display: grid; place-items: center; }
.hero-figure img { width: 100%; max-width: 560px; height: auto; display: block; }
.algorithm-hero .hero-inner { padding-block: clamp(10px, 1vw, 15px); }
/* Changing the width of the tilted underline must not move the scroll anchor. */
.hero-heading { overflow-anchor: none; }
.algorithm-hero .eyebrow { font-size: clamp(1rem, 1.35vw, 1.25rem); letter-spacing: .075em; }
.algorithm-hero h1 { margin: 10px 0 0; font-size: clamp(1.95rem, 4vw, 3.5rem); line-height: 1.1; }
.algorithm-hero .hero-figure img { width: 72%; min-width: min(185px, 100%); max-width: 370px; }
.lab { padding-block: 32px 32px; scroll-margin-top: 16px; }
.lab-heading, .lab-tools, .figure-head, .figure-title-wrap, .lesson-meta, .step-actions, .footer-inner, .source-links, .sheet-head { display: flex; align-items: center; }
.lab-heading, .figure-head, .lesson-meta, .step-actions, .footer-inner, .sheet-head { justify-content: space-between; gap: 16px; }
.sheet-body h2 { font-size: clamp(1.7rem, 2.5vw, 2.15rem); letter-spacing: -.045em; line-height: 1.12; font-weight: 780; }
.lab-tools { gap: 10px; }
.preset-wrap { position: relative; display: inline-flex; align-items: center; }
.preset-wrap select { appearance: none; min-height: 37px; border: var(--line); border-radius: 6px; background: var(--sheet); padding: 7px 34px 7px 36px; font-size: .85rem; font-weight: 600; }
.preset-wrap .icon { position: absolute; left: 12px; width: 15px; height: 15px; pointer-events: none; }
.preset-wrap .select-chevron { left: auto; right: 10px; width: 14px; }
.square-btn, .replay { display: inline-grid; place-items: center; width: 37px; height: 37px; border: var(--line); border-radius: 6px; background: var(--sheet); }
.square-btn .icon { width: 17px; }
.steps { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; margin-block: 20px 19px; }
.step-flow { position: relative; display: flow-root; }
.step-flow .steps { padding-block-start: 20px; row-gap: 34px; }
.step-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; color: var(--muted); }
.step-arrows path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.step-tab { min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 9px; background: var(--sheet); border: var(--line); border-radius: 6px; padding: 11px 8px; font-size: .91rem; font-weight: 600; }
.step-num { font-size: .75rem; font-weight: 600; color: var(--muted); }
.step-tab:hover { border-color: var(--control-edge); }
.step-tab[aria-selected="true"] { border-color: var(--yellow); background: var(--yellow); color: var(--on-accent); }
.step-tab[aria-selected="true"] .step-num { color: inherit; }
.workspace { display: grid; grid-template-columns: 1.22fr 1fr; gap: 20px; align-items: start; }
.lesson-card, .figure-card { border: var(--line); border-radius: 10px; background: var(--sheet); min-width: 0; }
.lesson-card { padding: 23px 26px 19px; }
.lesson-meta { margin-bottom: 12px; }
.phase { background: #2b2535; color: var(--violet); border: 1px solid #584b69; padding: 4px 7px; border-radius: 4px; font-size: .75rem; letter-spacing: .065em; }
.phase[data-stage="message"] { background: #1c3025; border-color: #3d5b48; color: var(--mint); }
.small-mono { color: var(--muted); font-weight: 500; font-size: .74rem; }
.lesson-card > h2 { font-weight: 770; font-size: clamp(1.6rem, 2.4vw, 2.1rem); letter-spacing: -.04em; line-height: 1.1; }
.intro { margin: 7px 0 18px; color: var(--muted); line-height: 1.5; font-size: .98rem; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { min-width: 0; }
.field label { font-size: .89rem; font-weight: 600; }
.field label var { font-family: Georgia, serif; font-weight: 700; font-size: 1.03rem; }
.field-input { position: relative; margin-top: 6px; }
.field-input input, .field-input textarea { width: 100%; background: var(--control); padding: 9px 34px 9px 12px; border: 1.5px solid var(--control-edge); border-radius: 5px; font-family: var(--mono); font-weight: 600; font-size: 1.18rem; line-height: 1.25; }
.field-input textarea { font: inherit; resize: vertical; min-height: 66px; padding-right: 12px; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: #e28d83; background: #2b1c1c; }
.input-check { color: var(--mint); position: absolute; top: 50%; right: 10px; transform: translateY(-50%); display: inline-flex; }
.input-check .icon { width: 16px; height: 16px; }
.field-error { color: #ffaba2; font-size: .84rem; line-height: 1.5; margin-top: 4px; }
.field-error:empty { display: none; }
.outline-btn { padding: 7px 11px; background: var(--sheet); font-size: .81rem; }
.shuffle { margin-top: 13px; }
.shuffle .icon { width: 15px; height: 15px; }
.step-actions { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--rule); }
.subtle-btn { border: 0; background: transparent; padding: 7px 0; color: var(--ink); }
.subtle-btn:disabled { color: #888883; }
.dark-btn { color: var(--on-accent); background: var(--ink); padding: 9px 14px; }
.dark-btn:hover:not(:disabled) { background: #fff; }
.dark-btn:disabled { background: var(--surface-raised); color: #a2a29c; }
.figure-card { overflow: hidden; }
.figure-head { padding: 10px 15px 10px 18px; background: var(--surface-raised); border-bottom: var(--line); }
.figure-title-wrap > .icon { color: var(--violet); }
.figure-title-wrap { gap: 10px; }
.figure-title-wrap .icon { width: 19px; height: 19px; }
.figure-title-wrap h3 { font-weight: 730; font-size: 1.04rem; letter-spacing: -.025em; }
.replay { height: 29px; width: 29px; background-color: var(--sheet); border-width: 1px; }
.replay .icon { width: 15px; height: 15px; }
.lab-note { display: flex; gap: 9px; color: var(--muted); margin-top: 23px; align-items: flex-start; }
.lab-note .icon { height: 15px; width: 15px; margin-top: 2px; }
.lab-note p { max-width: 91ch; font-size: .82rem; line-height: 1.55; }
.formula-box { border: 1px solid var(--rule); background: var(--control); padding: 11px 13px; border-radius: 6px; margin-top: 11px; overflow-wrap: anywhere; }
.formula-label { font-size: .68rem; letter-spacing: .07em; font-weight: 600; color: var(--muted); }
.math-line { font: 600 clamp(.91rem, 1.4vw, 1.04rem)/1.65 var(--mono); margin-top: 3px; }
.math-line sup, .sheet-row sup { line-height: 0; }
.good-result { background-color: #1b2c22; border-color: #435d4b; }
.good-result .formula-label { color: var(--mint); }
.details, .overview { border-top: 1px solid var(--rule); margin-top: 13px; padding-top: 10px; }
details summary { font-size: .87rem; font-weight: 600; line-height: 1.5; }
details p, .block-select { font-size: .88rem; line-height: 1.55; margin: 9px 0 6px; }
.table-wrap { overflow-x: auto; margin-block: 10px 0; }
.table-wrap table { border-collapse: collapse; width: 100%; font: .81rem var(--mono); }
.table-wrap th, .table-wrap td { padding: 5px 6px; border-bottom: 1px solid var(--rule); text-align: left; }
.table-wrap th { font-size: .68rem; background: var(--surface-raised); }
.mode-toggle { display: inline-flex; border: var(--line); border-radius: 5px; overflow: hidden; margin-bottom: 12px; }
.mode-toggle button { padding: 6px 12px; background: var(--sheet); font-size: .81rem; border: 0; }
.mode-toggle button + button { border-left: var(--line); }
.mode-toggle button[aria-pressed="true"] { background: var(--yellow); color: var(--on-accent); }
.block-select select { margin: 0 5px; padding: 3px; max-width: 100%; }
.recovered-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.need-input { padding: 10px 12px; background: #302819; color: #f2dda3; border: 1px solid #716040; border-radius: 5px; font-size: .87rem; line-height: 1.5; }
.need-input button { border: 0; font: inherit; display: inline; text-decoration: underline; padding: 0; font-weight: 650; }
footer { border-top: 1px solid var(--rule); background: var(--paper); }
.footer-inner { min-height: 60px; padding-block: 12px; }
.footer-brand { font-size: .9rem; font-weight: 750; display: inline-flex; align-items: center; gap: 7px; letter-spacing: -.03em; }
.footer-brand .site-mark { width: 20px; height: 20px; }
.footer-identity, .footer-author { display: flex; flex-wrap: wrap; align-items: center; }
.footer-identity { gap: 5px 16px; }
.footer-author { gap: 8px; font-size: .79rem; }
.footer-author a { text-underline-offset: 3px; }
.linkedin-link {
  display: inline-grid; place-items: center; width: 27px; height: 27px;
  border-radius: 4px; background: #0a66c2; color: white; text-decoration: none;
  font: 700 17px/1 Arial, sans-serif;
}
.linkedin-link:hover { background: #084d92; }
.source-links { gap: 14px; font-size: .79rem; }
.source-links span { color: var(--muted); }
.source-links a { text-underline-offset: 3px; }
dialog { width: min(580px, calc(100% - 36px)); max-height: 85dvh; padding: 0; border: var(--line); border-radius: 10px; box-shadow: 0 16px 48px #000b; background: var(--sheet); color: var(--ink); }
dialog::backdrop { background: #000b; }
.sheet-head { padding: 11px 18px; background: var(--surface-raised); border-bottom: var(--line); }
.sheet-head .small-mono { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 600; }
.sheet-body { padding: 22px; }
.sheet-body > p { line-height: 1.5; color: var(--muted); margin: 9px 0 14px; }
.sheet-row { width: 100%; display: grid; grid-template-columns: 9.5em 1fr; align-items: baseline; text-align: left; gap: 12px; border: 0; border-top: 1px solid var(--rule); padding: 12px 3px; }
.sheet-row span { font-family: var(--mono); line-height: 1.5; overflow-wrap: anywhere; }
.sheet-row small { font-size: .74rem; }
.sheet-row:hover { background-color: var(--surface-raised); }
.overview img { display: block; width: 100%; height: auto; margin-top: 12px; }
body:has(dialog[open]) { overflow: hidden; }
.noscript { position: fixed; bottom: 0; background: var(--yellow); color: var(--on-accent); padding: 10px; width: 100%; text-align: center; }
@media (min-width: 1550px) { .hero-inner { padding-block: 48px; } }
@media (max-width: 950px) {
  .wrap { width: min(100% - 56px, 1192px); }
  .hero-inner { gap: 18px; }
  .step-tab { gap: 5px; font-size: .82rem; }
  .workspace { grid-template-columns: 1.15fr 1fr; gap: 15px; }
  .lesson-card { padding: 19px; }
}
@media (max-width: 720px) {
  .wrap { width: calc(100% - 36px); }
  .mast-inner { height: 58px; }
  .brand { font-size: 1.3rem; gap: 9px; }
  .brand .site-mark { width: 29px; height: 29px; }
  .main-nav { gap: 16px; font-size: .8rem; }
  .hero-inner { grid-template-columns: 1.1fr 1fr; gap: 3px; padding-block: 31px; }
  h1 { font-size: clamp(3.35rem, 7.7vw, 4.1rem); }
  .hero-copy p { font-size: .98rem; }
  .hero-figure img { width: 104%; }
  .steps { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
  .step-tab { justify-content: flex-start; padding-left: 12px; }
  .workspace { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 520px) {
  .main-nav .nav-active { display: none; }
  .hero-inner { display: flex; flex-direction: column; align-items: stretch; padding-block: 26px 16px; }
  h1 { font-size: clamp(3rem, 10.2vw, 3.8rem); margin-block: 12px 13px; }
  h1 br { display: none; }
  h1 br::after { content: ' '; }
  .hero-copy p { max-width: 45ch; line-height: 1.5; }
  .hero-figure { margin: 9px auto 0; width: min(100%, 340px); }
  .hero-figure img { width: 100%; }
  .lab { padding-top: 23px; }
  .lab-heading { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .lab-tools { gap: 7px; }
  .steps { margin-block: 14px 16px; gap: 6px; }
  .step-tab { padding: 9px 4px 9px 8px; }
  .lesson-card { padding: 17px; }
  .fields { gap: 10px; }
  .lesson-card > h2 { font-size: 1.65rem; }
  .footer-inner { flex-wrap: wrap; }
  .sheet-row { grid-template-columns: 7.4em 1fr; }
}
@media (max-width: 350px) {
  .wrap { width: calc(100% - 28px); }
  .steps { grid-template-columns: repeat(2,1fr); }
  .source-links { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.trace-tools { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.current-bit { background-color: #3a311c; color: #ffdf79; }
.play-steps {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 37px;
  padding: 7px 12px; border: var(--line); border-radius: 6px; background: var(--sheet); font-size: .85rem; font-weight: 600;
}
.play-steps:hover, .play-steps[aria-pressed="true"] { background: var(--surface-raised); }
.play-shape { width: 10px; height: 12px; display: inline-block; background: var(--ink); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.play-steps[aria-pressed="true"] .play-shape { clip-path: polygon(0 0, 35% 0, 35% 100%, 65% 100%, 65% 0, 100% 0, 100% 100%, 0 100%); }
@media (min-width: 521px) and (max-width: 760px) {
  .lab-heading { flex-wrap: wrap; gap: 12px; }
}
@media (max-width: 355px) {
  .lab-tools { flex-wrap: wrap; }
}

.prompt-group { gap: clamp(10px, 1vw, 14px); }
.algorithm-picker {
  display: grid; justify-items: start;
  margin-block-end: clamp(16px, 1.8vw, 26px);
}
.nav-hint {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ink); font: 600 .8rem/1.3 var(--mono);
}
.nav-hint .icon { width: 18px; height: 18px; color: var(--yellow); }
.nav-hint .highlight { padding-inline: .28em; color: var(--on-accent); }
.nav-hint .highlight::after { bottom: 0; height: 96%; }
@media (prefers-reduced-motion: no-preference) {
  .nav-hint .highlight::after {
    --sweep-width: 6rem;
    background-image: linear-gradient(105deg, #ffc21c 12%, #ffdb4d 30%, #fff6ae 44% 58%, #ffdb4d 75%, #ffc21c 90%);
    background-size: var(--sweep-width) 100%;
    background-repeat: repeat-x;
    animation: marker-sweep 1.4s linear infinite;
  }
  @keyframes marker-sweep {
    from { background-position: 0 0; }
    to { background-position: var(--sweep-width) 0; }
  }
}
.segmented-control {
  display: inline-flex; align-items: stretch;
  border: var(--line); border-radius: 6px; background: var(--sheet); overflow: hidden;
}
.segmented-control > a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 17px;
  font-weight: 650; font-size: .88rem; line-height: 1.3; text-decoration: none; white-space: nowrap;
}
.segmented-control > * + * { border-inline-start: var(--line); }
.segmented-control > a:hover { background: var(--surface-raised); }
.segmented-control > a[aria-current="page"] { background: var(--yellow); color: var(--on-accent); }
.segmented-control > a:focus-visible {
  outline: 3px solid var(--focus); outline-offset: -3px;
}
.segmented-control > [aria-current="page"]:focus-visible { outline-color: var(--on-accent); }
body[data-lab] .nav-reference { font-size: .89rem; }
.steps[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.private-ranges { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.dh-party { min-width: 0; padding: 12px; border: 1px solid #554b65; border-radius: 7px; background: #28242e; }
.dh-party.dh-bob { border-color: #415e4b; background: #1c2921; }
.dh-range { display: block; width: 100%; margin: 11px 0 1px; min-height: 24px; accent-color: var(--violet); cursor: pointer; }
.dh-bob .dh-range { accent-color: var(--mint); }
.dh-range:focus-visible { outline-offset: 0; }
.dh-range-limits { display: flex; justify-content: space-between; font: .75rem var(--mono); color: var(--muted); }
@media (max-width: 720px) {
  .steps[data-count="4"] { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (min-width: 521px) and (max-width: 760px) {
  .algorithm-hero .hero-copy { display: contents; }
  .algorithm-hero .hero-inner { row-gap: 12px; }
  .algorithm-hero .algorithm-picker {
    grid-column: 1 / -1;
    justify-self: start;
    margin-block-end: 0;
  }
}
@media (max-width: 600px) {
  .algorithm-nav { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr 1.15fr; }
  .algorithm-nav a { padding-inline: clamp(5px, 2.2vw, 14px); }
}
@media (max-width: 710px) {
  .private-ranges { gap: 9px; }
  .dh-party { padding: 9px; }
}
@media (max-width: 310px) {
  .algorithm-nav a { padding-inline: 3px; font-size: .79rem; }
}

.lesson-card > .figure-card {
  margin: 16px 0;
  border-radius: 6px;
  box-shadow: none;
}

