/* =========================================================================
   Teorie čísel od A do Z — styles
   Dependency-free. Light + dark theme via [data-theme] on <html>.
   ========================================================================= */

:root {
  --accent: #6d5efc;          /* indigo/violet — main */
  --accent-2: #8b7bff;
  --accent-dark: #5446d6;
  --gold: #f0a500;            /* warm highlight */
  --teal: #11b3a3;

  /* light theme (default) */
  --bg: #f4f5fb;
  --bg-soft: #eef0f9;
  --card: #ffffff;
  --card-2: #fbfbfe;
  --ink: #1a1c2e;
  --ink-soft: #4a4d68;
  --ink-faint: #8b8fab;
  --line: #e4e6f1;
  --line-soft: #eef0f7;
  --code-bg: #f3f1fd;

  --header-grad-1: #2a2154;
  --header-grad-2: #15122e;
  --header-glow: rgba(109,94,252,.45);

  --shadow-sm: 0 1px 2px rgba(26,28,46,.05), 0 4px 12px rgba(26,28,46,.06);
  --shadow-md: 0 2px 6px rgba(26,28,46,.06), 0 12px 32px rgba(26,28,46,.10);

  --radius: 16px;
  --radius-sm: 11px;
  --sidebar-w: 280px;
  --content-w: 760px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-synthesis: none;
}

html[data-theme="dark"] {
  --bg: #0e1020;
  --bg-soft: #14172b;
  --card: #181b30;
  --card-2: #1d2138;
  --ink: #e8eaf6;
  --ink-soft: #b3b7d4;
  --ink-faint: #7f84a8;
  --line: #2b2f4a;
  --line-soft: #242843;
  --code-bg: #232744;

  --header-grad-1: #221b46;
  --header-grad-2: #0b0918;
  --header-glow: rgba(109,94,252,.40);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.30);
  --shadow-md: 0 2px 8px rgba(0,0,0,.40), 0 16px 40px rgba(0,0,0,.45);
}

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-dark); text-decoration: none; }
html[data-theme="dark"] a { color: var(--accent-2); }
a:hover { text-decoration: underline; }

/* ---------- scroll progress bar ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: transparent; z-index: 60; pointer-events: none;
}
.progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--teal));
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1240px;
  margin-inline: auto;
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  background: linear-gradient(170deg, var(--header-grad-1), var(--header-grad-2));
  color: #e9e7fb;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 280px at 30% -8%, var(--header-glow), transparent 65%);
  pointer-events: none;
}
.sidebar-inner { position: relative; padding: 24px 18px 28px; display: flex; flex-direction: column; min-height: 100%; }

.brand { display: flex; align-items: center; gap: 12px; color: #fff; margin-bottom: 22px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--serif);
  font-size: 1.6rem; line-height: 1;
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(109,94,252,.45);
}
.brand-text { display: flex; flex-direction: column; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.brand-text small { font-weight: 500; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #b9b4e8; }

/* TOC */
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc a {
  color: #c4c0e8;
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1.35;
  transition: background .14s, color .14s;
}
.toc a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.toc .toc-top { font-weight: 700; color: #ded9ff; margin: 2px 0; }
.toc-block { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.07); }
.toc-h { font-weight: 700; color: #fff !important; font-size: .94rem !important; display: flex; align-items: baseline; gap: 8px; }
.toc-h .num {
  font-size: .68rem; font-weight: 800;
  width: 18px; height: 18px; flex: none;
  display: inline-grid; place-items: center;
  background: rgba(255,255,255,.12); border-radius: 6px; color: #fff;
}
.toc-block > a:not(.toc-h) { padding-left: 26px; font-size: .83rem; }

/* active state from scrollspy */
.toc a.active {
  color: #fff; background: rgba(109,94,252,.30);
  box-shadow: inset 2px 0 0 var(--accent-2);
}
.toc-h.active .num { background: var(--accent); }

/* KaTeX inside TOC: keep small + inherit color */
.toc .katex { font-size: .92em; color: inherit; }

/* theme toggle */
.theme-btn {
  background: rgba(255,255,255,.08);
  color: #ece9ff;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  padding: 9px 12px;
  transition: background .15s, border-color .15s;
}
.theme-btn:hover { background: rgba(255,255,255,.16); }
.theme-btn.wide { margin-top: auto; padding-top: 18px; }
.theme-btn.wide { display: flex; align-items: center; gap: 9px; justify-content: center; margin-top: 24px; font-weight: 600; font-size: .9rem; }

/* scrim behind mobile drawer */
.scrim { position: fixed; inset: 0; background: rgba(8,8,20,.5); z-index: 44; border: 0; }

/* =========================================================================
   CONTENT
   ========================================================================= */
.content {
  width: 100%;
  max-width: calc(var(--content-w) + 96px);
  margin-inline: auto;
  padding: 0 clamp(20px, 5vw, 48px) 80px;
}
.section { padding-top: 14px; }
.block-start { margin-top: 46px; padding-top: 30px; border-top: 1px solid var(--line); }

.content h1, .content h2, .content h3, .content h4 { letter-spacing: -.018em; line-height: 1.18; color: var(--ink); }
.content h2 { font-size: clamp(1.55rem, 3.8vw, 2.1rem); margin: .2em 0 .55em; font-weight: 800; }
.content h2 .sub-h { font-weight: 500; color: var(--ink-faint); font-size: .62em; letter-spacing: 0; }
.content h3 { font-size: clamp(1.18rem, 2.6vw, 1.42rem); margin: 1.9em 0 .5em; font-weight: 750; scroll-margin-top: 12px; }
.content h3 .sub-h { font-weight: 500; color: var(--ink-faint); font-size: .82em; }
.content h4 { font-size: 1.06rem; margin: 0 0 .35em; font-weight: 750; }
.content p { margin: 0 0 1.05em; }
.content em { color: inherit; }
.content strong { font-weight: 700; }

.content section[id], .block-start[id] { scroll-margin-top: 14px; }

code {
  font-family: var(--mono); font-size: .88em;
  background: var(--code-bg); color: var(--accent-dark);
  padding: .1em .4em; border-radius: 6px;
}
html[data-theme="dark"] code { color: var(--accent-2); }

/* ---------- HERO ---------- */
.hero { padding-top: 54px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: .76rem; font-weight: 700;
  color: var(--accent-dark); margin: 0 0 14px;
}
html[data-theme="dark"] .eyebrow { color: var(--accent-2); }
.hero h1 {
  font-size: clamp(2.3rem, 7vw, 3.5rem);
  font-weight: 850; margin: 0 0 .28em; line-height: 1.05;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent), var(--teal) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: clamp(1.05rem, 2.4vw, 1.28rem); color: var(--ink-soft); max-width: 62ch; margin-bottom: 1.4em; }

.hero-meta { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 34px; }
.chip {
  font-size: .82rem; font-weight: 600;
  background: var(--card); border: 1px solid var(--line);
  color: var(--ink-soft); padding: 6px 13px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

/* roadmap cards */
.roadmap {
  display: grid; gap: 14px; margin: 0 0 34px;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}
.rm-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 16px 18px;
  box-shadow: var(--shadow-sm); color: var(--ink);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.rm-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent-2); text-decoration: none; }
.rm-num {
  font-family: var(--serif); font-weight: 700;
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 9px; color: #fff; margin-bottom: 6px;
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
}
.rm-card b { font-size: 1.02rem; }
.rm-card span:last-child { font-size: .85rem; color: var(--ink-faint); line-height: 1.4; }
.rm-card.finale { background: linear-gradient(160deg, var(--card), var(--code-bg)); border-color: var(--accent-2); }
.rm-card.finale .rm-num { background: linear-gradient(140deg, var(--gold), #d98b00); box-shadow: 0 6px 16px rgba(240,165,0,.35); }

/* block kicker */
.block-kicker {
  text-transform: uppercase; letter-spacing: .16em; font-size: .76rem; font-weight: 800;
  color: var(--accent-dark); margin: 0 0 4px;
}
html[data-theme="dark"] .block-kicker { color: var(--accent-2); }
.finale-block .block-kicker { color: #c98c00; }
html[data-theme="dark"] .finale-block .block-kicker { color: var(--gold); }

/* =========================================================================
   CALLOUTS
   ========================================================================= */
.callout {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px 6px;
  margin: 18px 0 24px;
  box-shadow: var(--shadow-sm);
}
.callout > p:last-child { margin-bottom: 14px; }
.callout-label {
  display: inline-block;
  font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent-dark); margin-bottom: 8px;
}
html[data-theme="dark"] .callout-label { color: var(--accent-2); }
.callout-label.tight { margin-bottom: 0; }

.callout.def    { border-left-color: var(--accent); }
.callout.thm    { border-left-color: var(--teal); background: linear-gradient(180deg, color-mix(in srgb, var(--teal) 6%, var(--card)), var(--card)); }
.callout.thm .callout-label { color: var(--teal); }
.callout.goal   { border-left-color: var(--gold); background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 8%, var(--card)), var(--card)); }
.callout.goal .callout-label { color: #c98c00; }
html[data-theme="dark"] .callout.goal .callout-label { color: var(--gold); }
.callout.example { border-left-color: var(--ink-faint); background: var(--card-2); }
.callout.example .callout-label { color: var(--ink-faint); }
.callout.note   { border-left-color: var(--accent-2); background: var(--card-2); }
.callout.idea   { border-left-color: var(--gold); }
.callout.idea .callout-label { color: #c98c00; }
html[data-theme="dark"] .callout.idea .callout-label { color: var(--gold); }
.callout.idea.small { padding-bottom: 4px; }
.callout.warn   { border-left-color: #e0483d; background: linear-gradient(180deg, color-mix(in srgb, #e0483d 7%, var(--card)), var(--card)); }
.callout.warn .callout-label { color: #d63a2f; }
.callout.history { border-left-color: #b0795a; background: linear-gradient(180deg, color-mix(in srgb, #b0795a 8%, var(--card)), var(--card)); }
.callout.history .callout-label { color: #9a6240; }
html[data-theme="dark"] .callout.history .callout-label { color: #d9a679; }
.callout.history p b { color: var(--ink); }

.callout ul, .callout ol { margin: 0 0 14px; padding-left: 1.3em; }
.callout li { margin: .3em 0; }
.recap { list-style: none; padding-left: 0; }
.recap li { padding-left: 1.4em; position: relative; }
.recap li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

.aside-note { font-size: .92rem; color: var(--ink-soft); border-left: 2px solid var(--line); padding-left: 14px; margin: 0 0 1.1em; }

.kbd {
  font-family: var(--mono); font-size: .82em;
  background: var(--code-bg); border: 1px solid var(--line);
  padding: .08em .45em; border-radius: 6px; color: var(--ink-soft); white-space: nowrap;
}

/* ---------- proofs (details/summary) ---------- */
.proof {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card-2); margin: -8px 0 24px; overflow: hidden;
}
.proof > summary {
  cursor: pointer; list-style: none;
  font-weight: 700; font-size: .9rem; color: var(--ink-soft);
  padding: 11px 16px; display: flex; align-items: center; gap: 9px;
  user-select: none;
}
.proof > summary::-webkit-details-marker { display: none; }
.proof > summary::before {
  content: "▸"; color: var(--accent); transition: transform .16s; display: inline-block;
}
.proof[open] > summary::before { transform: rotate(90deg); }
.proof > summary::after { content: "Důkaz"; position: absolute; left: -9999px; }
.proof[open] > summary { border-bottom: 1px solid var(--line); color: var(--ink); }
.proof > :not(summary) { padding-inline: 18px; }
.proof > p:first-of-type { padding-top: 12px; }
.proof > p:last-child, .proof > ul:last-child { padding-bottom: 14px; margin-bottom: 0; }
.proof ul { margin-bottom: 12px; }

/* ---------- steps / lists ---------- */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; margin: 0 0 22px; }
ol.steps > li {
  counter-increment: step; position: relative;
  padding: 4px 0 14px 44px; margin: 0;
}
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  color: #fff; font-weight: 700; font-size: .9rem; border-radius: 9px;
  box-shadow: var(--shadow-sm);
}
ol.steps > li:not(:last-child)::after {
  content: ""; position: absolute; left: 14px; top: 34px; bottom: 4px;
  width: 2px; background: var(--line);
}
.ref { font-size: .8em; color: var(--accent-dark); font-weight: 600; white-space: nowrap; }
html[data-theme="dark"] .ref { color: var(--accent-2); }

ul.next, ul.recap { line-height: 1.6; }
ul.next { padding-left: 1.2em; }
ul.next li { margin: .45em 0; }

/* RSA key pair cards */
.keypair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 24px; }
.key {
  border-radius: var(--radius-sm); padding: 16px 18px; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 5px; box-shadow: var(--shadow-sm);
}
.key.pub { background: linear-gradient(160deg, color-mix(in srgb, var(--teal) 9%, var(--card)), var(--card)); border-color: color-mix(in srgb, var(--teal) 35%, var(--line)); }
.key.prv { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--card)), var(--card)); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.key-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.key-val { font-size: 1.3rem; }
.key-note { font-size: .82rem; color: var(--ink-faint); }

/* =========================================================================
   NOTATION LEGEND (Tahák)
   ========================================================================= */
.lead-sm { font-size: 1.02rem; color: var(--ink-soft); max-width: 64ch; }

.legend-details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  margin: 16px 0 8px;
  overflow: hidden;
}
.legend-details > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-weight: 700; font-size: 1.02rem;
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--card)), var(--card));
}
.legend-details > summary::-webkit-details-marker { display: none; }
.legend-details > summary::after {
  content: "▸"; margin-left: auto; color: var(--accent);
  font-size: 1.1rem; transition: transform .18s;
}
.legend-details[open] > summary::after { transform: rotate(90deg); }
.legend-details[open] > summary { border-bottom: 1px solid var(--line); }
.sum-ico { font-size: 1.15rem; }
.sum-hint { font-weight: 500; font-size: .82rem; color: var(--ink-faint); }
.legend-body { padding: 4px 18px 14px; }

.notation-group { margin: 20px 0; }
.notation-group h4 { margin: 0 0 6px; font-size: 1.04rem; }
.notation-group .muted { font-weight: 500; color: var(--ink-faint); font-size: .82em; }
.group-note { font-size: .9rem; color: var(--ink-soft); margin: 8px 0 0; }

table.notation { width: 100%; border-collapse: collapse; }
table.notation td {
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top; font-size: .95rem;
}
table.notation tr:last-child td { border-bottom: none; }
table.notation .sym {
  width: 1%; white-space: nowrap; text-align: center;
  font-size: 1.08rem;
}
table.notation .sym .katex { color: var(--ink); }
table.notation .read {
  color: var(--accent-dark); font-weight: 650; line-height: 1.4;
}
html[data-theme="dark"] table.notation .read { color: var(--accent-2); }
table.notation .mean { color: var(--ink-soft); }

.decode {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 1.05rem;
}
.decode .dc { color: var(--accent-dark); font-weight: 650; }
html[data-theme="dark"] .decode .dc { color: var(--accent-2); }

.orig-legend { font-size: .86rem; color: var(--ink-faint); margin: 6px 0 0; }
.orig-chip { display: inline-block; font-weight: 700; color: var(--accent); }
table.notation .orig {
  display: block; margin-top: 5px; font-size: .82em;
  color: var(--ink-faint); line-height: 1.45;
}
table.notation .orig::before { content: "↳ původ: "; font-weight: 700; color: var(--accent); }
table.notation .orig b, table.notation .orig strong, table.notation .orig em { color: var(--ink-soft); }

@media (max-width: 560px) {
  table.notation, table.notation tbody, table.notation tr, table.notation td { display: block; width: auto; }
  table.notation tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.notation tr:last-child { border-bottom: none; }
  table.notation td { border: none; padding: 2px 0; }
  table.notation .sym { text-align: left; font-size: 1.2rem; margin-bottom: 4px; }
}

/* =========================================================================
   WIDGETS
   ========================================================================= */
.challenge-head {
  margin: 30px 0 0;
  padding: 16px 18px 4px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, var(--card)), var(--card));
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.challenge-head h4 { margin: 4px 0 .3em; font-size: 1.12rem; }
.challenge-head p { font-size: .92rem; color: var(--ink-soft); margin-bottom: 14px; }

.widget {
  background: var(--card);
  border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 18px;
  margin: 0 0 28px;
  box-shadow: var(--shadow-md);
}

.w-controls { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; }
.w-field { display: flex; flex-direction: column; gap: 5px; }
.w-field label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.w-field input, .w-field select {
  font: inherit; font-size: .96rem;
  color: var(--ink); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; width: 100%; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.w-field input[type="number"] { width: 120px; }
.w-field input:focus, .w-field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.w-field.grow { flex: 1 1 220px; }
.w-field.grow input { width: 100%; }

.btn {
  font: inherit; font-weight: 700; font-size: .92rem;
  color: #fff; background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  border: none; border-radius: 9px; padding: 10px 18px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: filter .14s, transform .08s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent; color: var(--accent-dark);
  border: 1px solid var(--line); box-shadow: none; font-weight: 600;
}
html[data-theme="dark"] .btn.ghost { color: var(--accent-2); }
.btn.ghost:hover { background: var(--code-bg); filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* widget output */
.w-out { margin-top: 16px; }
.w-out:empty { display: none; }
.result-line {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--card-2); border: 1px solid var(--line); margin-bottom: 10px;
  font-size: 1.02rem;
}
.result-line.good { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: color-mix(in srgb, var(--teal) 9%, var(--card)); }
.result-line.bad  { border-color: color-mix(in srgb, #e0483d 45%, var(--line)); background: color-mix(in srgb, #e0483d 8%, var(--card)); }
.result-line .rl-k { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
.result-line .rl-v { font-weight: 700; }
.result-line .rl-v.mono { font-family: var(--mono); font-weight: 600; word-break: break-all; }

.badge { font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.badge.ok  { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }
.badge.no  { background: color-mix(in srgb, #e0483d 16%, transparent); color: #d63a2f; }

.steps-note { font-size: .82rem; color: var(--ink-faint); margin: 4px 0 10px; }

/* tables in widgets */
.w-table-wrap { overflow-x: auto; margin: 10px 0 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.w-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; }
table.w-table th, table.w-table td { padding: 8px 12px; text-align: right; white-space: nowrap; }
table.w-table th { background: var(--card-2); color: var(--ink-soft); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
table.w-table td { border-bottom: 1px solid var(--line-soft); font-family: var(--mono); }
table.w-table tr:last-child td { border-bottom: none; }
table.w-table tr.highlight td { background: color-mix(in srgb, var(--gold) 12%, var(--card)); font-weight: 700; }
table.w-table td:first-child, table.w-table th:first-child { text-align: left; }

/* general solution slider */
.slider-box { margin-top: 12px; padding: 14px; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.slider-box input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.slider-val { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }

.w-error { color: #d63a2f; font-weight: 600; font-size: .92rem; padding: 10px 14px; background: color-mix(in srgb, #e0483d 8%, var(--card)); border: 1px solid color-mix(in srgb, #e0483d 35%, var(--line)); border-radius: var(--radius-sm); }

.crt-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.crt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crt-row .lab { font-family: var(--mono); color: var(--ink-soft); font-size: .9rem; white-space: nowrap; }
.crt-row input { width: 92px; }
.crt-row .rm { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px; }
.crt-row .rm:hover { color: #d63a2f; }

.flow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 12px 0; font-family: var(--mono); font-size: .92rem;
}
.flow .pill { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; }
.flow .arr { color: var(--accent); font-weight: 700; }

/* =========================================================================
   FOOTER + misc
   ========================================================================= */
.page-footer { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); color: var(--ink-faint); }
.ft-title { font-weight: 800; color: var(--ink); margin: 0 0 4px; font-size: 1.05rem; }
.ft-sub { font-size: .9rem; margin: 0 0 8px; color: var(--ink-soft); }
.ft-tiny { font-size: .82rem; margin: 0; }

.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1.3rem; cursor: pointer; box-shadow: var(--shadow-md);
  transition: transform .15s, opacity .2s;
}
.to-top:hover { transform: translateY(-3px); color: var(--accent); }

/* topbar (mobile only) */
.topbar { display: none; }

/* KaTeX sizing tweaks */
.katex { font-size: 1.04em; }
.katex-display { margin: 1em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.callout .katex-display { margin: .6em 0; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 50;
    background: linear-gradient(160deg, var(--header-grad-1), var(--header-grad-2));
    color: #fff; padding: 11px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
  }
  .topbar-title { font-weight: 800; letter-spacing: -.01em; flex: 1; font-size: 1rem; }
  .topbar .theme-btn { padding: 6px 10px; }
  .menu-btn {
    width: 38px; height: 34px; border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08); border-radius: 9px; cursor: pointer;
    display: grid; place-content: center; gap: 4px; padding: 0;
  }
  .menu-btn span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
  .menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh;
    width: min(86vw, 320px); z-index: 45;
    transform: translateX(-102%); transition: transform .26s ease;
    border-right: 1px solid rgba(255,255,255,.08);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.5); }
  .theme-btn.wide { display: none; } /* mobile uses topbar toggle */
  .content { max-width: 720px; padding-top: 4px; }
  .hero { padding-top: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

@media (max-width: 560px) {
  .keypair { grid-template-columns: 1fr; }
  .roadmap { grid-template-columns: 1fr 1fr; }
  .w-field input[type="number"] { width: 100%; }
  .content { padding-inline: 18px; }
  .callout { padding-inline: 14px; }
}
@media (max-width: 380px) {
  .roadmap { grid-template-columns: 1fr; }
}
