/* ---------------------------------------------------------------
   Poker Theory — a statistics workbook for no-limit hold'em
   Visual system: Airwallex
   Roles: action #6533f6 · ink #000 · muted #707273 · canvas #fdfdfd
          surface #f6f7f9 · border #bebfc3 · dark #1c1f24
          orange #f06c46 · coral #f75f58 · lilac #d0c6f1
   Typography: Circular voice (DM Sans substitute), 400/500/700
   --------------------------------------------------------------- */

:root {
  /* --- Airwallex brand roles --- */
  --action: #6533f6;
  --action-hover: #5526e0;
  --action-deep: #4a1cc9;
  --action-soft: #f0ecfe;
  --action-line: #d9cffb;

  --ink: #000000;
  --ink-2: #1c1f24;
  --muted-ink: #707273;
  --dim: #8e9095;

  --canvas: #fdfdfd;
  --surface: #f6f7f9;
  --surface-2: #eef0f3;
  --surface-3: #e6e8ec;

  --border: #e3e4e8;
  --border-strong: #bebfc3;

  --dark: #1c1f24;
  --dark-2: #23272e;

  --accent-orange: #f06c46;
  --accent-coral: #f75f58;
  --accent-lilac: #d0c6f1;

  /* --- data semantics (charts, meters, deltas) --- */
  --green: #12805a;
  --green-soft: #e7f4ee;
  --red: #d0453f;
  --red-soft: #fdeceb;
  --blue: #3b6ef5;

  /* --- legacy aliases: the rest of the sheet keys off these --- */
  --gold: var(--action);
  --gold-soft: var(--action-soft);
  --panel: #ffffff;
  --panel-raise: var(--surface);
  --panel-solid: #ffffff;
  --line: var(--border);
  --line-strong: var(--border-strong);
  --text: var(--ink);
  --muted: var(--muted-ink);
  --bg: var(--canvas);
  --bg-soft: var(--surface);

  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: var(--font-sans);
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-raise: 0 4px 12px -2px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
}

body { min-height: 100vh; }

::selection { background: var(--action-soft); color: var(--action-deep); }

/* ---------------- layout ---------------- */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 18px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px 4px;
  cursor: pointer;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  background: var(--action);
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
}
.brand-name em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-ink);
  margin-top: 3px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  padding-right: 4px;
  margin: 0 -4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--muted-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--action-soft);
  color: var(--action-deep);
  font-weight: 700;
}
.nav-item.done .nav-dot { background: var(--action); border-color: var(--action); }
.nav-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
}
.nav-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--dim);
  min-width: 13px;
}
.nav-item.active .nav-num { color: var(--action); }

.side-foot {
  margin-top: auto;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
}
.progress-line {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-ink);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}
.progress-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--action);
  transition: width 0.4s ease;
}
.side-note {
  margin-top: 12px;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.5;
}

.main { min-width: 0; background: var(--canvas); }

.content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 52px 40px 120px;
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- typography ---------------- */
.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--action);
  margin-bottom: 14px;
}
.eyebrow .sep { color: var(--border-strong); margin: 0 6px; }

h1 {
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  font-weight: 700;
  color: var(--ink);
}

h2 {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 52px 0 14px;
  color: var(--ink);
}

h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
  color: var(--ink);
}

.lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted-ink);
  max-width: 64ch;
  margin: 0 0 10px;
}

p { line-height: 1.6; color: #3f4145; margin: 0 0 15px; max-width: 72ch; }
p strong, li strong { color: var(--ink); font-weight: 700; }
p em { color: var(--ink-2); font-style: italic; }

ul, ol { color: #3f4145; line-height: 1.6; padding-left: 22px; margin: 0 0 16px; max-width: 70ch; }
li { margin-bottom: 7px; }

a { color: var(--action); text-decoration: none; border-bottom: 1px solid var(--action-line); }
a:hover { color: var(--action-hover); border-bottom-color: var(--action); }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink-2);
}

.note {
  border-left: 2px solid var(--action);
  background: var(--surface);
  padding: 15px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 22px 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: #3f4145;
  max-width: 72ch;
}
.note strong { color: var(--ink); font-weight: 700; }
.note.warn { border-color: var(--accent-coral); background: var(--red-soft); }
.note.warn strong { color: var(--red); }
.note.good { border-color: var(--green); background: var(--green-soft); }
.note.good strong { color: var(--green); }

/* ---------------- panels ---------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin: 22px 0;
  box-shadow: var(--shadow);
}
.panel.flush { background: var(--surface); }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-title {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-ink);
  font-weight: 700;
}
.panel-sub { font-size: 12px; color: var(--dim); font-family: var(--font-mono); }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 15px;
}
.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted-ink);
  margin-bottom: 9px;
}
.stat-value {
  font-family: var(--font-sans);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-value.pos { color: var(--green); }
.stat-value.neg { color: var(--red); }
.stat-value.gold { color: var(--action); }
.stat-sub { font-size: 12px; color: var(--muted-ink); margin-top: 7px; line-height: 1.5; }

/* ---------------- mathematics ---------------- */

/* Math fonts carry a MATH table, so fractions and radicals stretch properly;
   every platform has one, and the serif entry is only a last resort. */
math {
  font-family: "Noto Sans Math", "STIX Two Math", "Cambria Math", "DejaVu Math TeX Gyre", "Latin Modern Math", serif;
  font-size: 1.1em;
  color: inherit;
}

/* ---------------- formulas: the dark technical band ---------------- */

/* The band is a two-column grid -- label, then maths. Each .frow is
   display: contents, so the label and expression of every row share the
   band's columns and align down the block. Below 640px rows stack. */
.formula {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 22px;
  background: var(--dark);
  border: none;
  border-radius: var(--radius);
  padding: 15px 20px;
  margin: 18px 0;
  overflow-x: auto;
  color: #e6e7ec;
  font-size: 14px;
  line-height: 1.5;
  max-width: none;
}
.formula .frow { display: contents; }
.formula .flabel {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8d93a1;
  padding: 9px 0 0;
  white-space: nowrap;
}
.formula .fexpr {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 7px 0;
}
.formula .fnote { font-size: 12px; color: #8a8f9c; }
.formula .fgap { grid-column: 1 / -1; height: 7px; }
.formula .fwide { grid-column: 1 / -1; width: max-content; max-width: 100%; padding: 5px 0; }
.formula .fprose { grid-column: 1 / -1; padding: 3px 0; font-size: 13px; line-height: 1.7; color: #a9afbb; }
.formula .fnote-line { grid-column: 1 / -1; padding: 5px 0; font-size: 12px; color: #8a8f9c; }
.formula .hl { color: #ab93ff; }
.formula math { font-size: 1.34em; math-style: normal; }
.formula .fprose math, .formula .fnote-line math, .formula .fnote math { font-size: 1em; math-style: compact; }

@media (max-width: 640px) {
  .formula { display: block; }
  .formula .frow { display: block; padding: 7px 0; }
  .formula .flabel { display: block; padding: 0 0 2px; }
  .formula .fexpr { padding: 0; }
  .formula .fwide, .formula .fprose, .formula .fnote-line { padding: 5px 0; }
}

/* ---------------- cards ---------------- */
.card-face {
  width: 46px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  padding: 3px 5px 4px;
  font-family: var(--font-mono);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.07);
  user-select: none;
  position: relative;
}
.card-face.red { color: #cc2b3c; }
.card-face .rk { font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.card-face .rk.bot { justify-self: end; transform: rotate(180deg); }
.card-face .su { font-size: 22px; line-height: 1; place-self: center; }
.card-face.sm { width: 38px; height: 54px; border-radius: 5px; padding: 3px 4px; grid-template-rows: auto 1fr; }
.card-face.sm .rk { font-size: 11px; }
.card-face.sm .rk.bot { display: none; }
.card-face.sm .su { font-size: 19px; margin-top: -2px; }
.card-face.lg { width: 62px; height: 87px; border-radius: 7px; }
.card-face.lg .rk { font-size: 16px; }
.card-face.lg .su { font-size: 30px; }
.card-face.empty, .card-face.back {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  box-shadow: none;
  color: var(--dim);
}

.hand-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hand-row .card-face { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.hand-row .card-face:hover { transform: translateY(-2px); box-shadow: var(--shadow-raise); }

/* ---------------- card picker ---------------- */
.picker { display: flex; flex-direction: column; gap: 16px; }
.picker-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.picker-div { width: 1px; align-self: stretch; background: var(--border); }
.slot-group { display: flex; flex-direction: column; gap: 7px; }
.slot-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted-ink);
}
.slot-row { display: flex; gap: 6px; }
.slot {
  width: 40px;
  height: 56px;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  background: var(--surface);
}
.slot:hover { border-color: var(--muted-ink); background: #fff; }
.slot.active {
  border: 1px solid var(--action);
  background: var(--action-soft);
  box-shadow: 0 0 0 3px rgba(101, 51, 246, 0.1);
}
.slot.vacant .slot-plus { color: var(--dim); font-size: 17px; }
.slot .card-face { width: 38px; height: 53px; }

.deck {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 4px;
  max-width: 540px;
}
.deck-card {
  aspect-ratio: 4 / 5;
  min-width: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  display: grid;
  place-content: center;
  gap: 0;
  line-height: 1.05;
  padding: 0;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s, border-color 0.12s;
}
.deck-card:hover { background: var(--surface); transform: translateY(-1px); border-color: var(--border-strong); }
.deck-card.red { color: #cc2b3c; }
.deck-card.dead { opacity: 0.22; cursor: default; }
.deck-card.ontable { background: var(--action); border-color: var(--action); color: #fff; }
.dc-r { font-weight: 700; }
.dc-s { font-size: 10px; opacity: 0.8; }

/* ---------------- controls ---------------- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.btn:hover { background: var(--surface); border-color: var(--muted-ink); }
.btn:active { transform: translateY(0.5px); }
.btn.primary {
  background: var(--action);
  color: #fff;
  border-color: var(--action);
  font-weight: 700;
  box-shadow: none;
}
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); filter: none; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--action); }
.btn.ghost:hover { background: var(--action-soft); border-color: transparent; }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.range-row { margin: 16px 0; }
.range-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
}
.range-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.range-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--action);
  font-variant-numeric: tabular-nums;
}
.range-hint { font-size: 11.5px; color: var(--muted-ink); margin-top: 6px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--action);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.16);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--action);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.16);
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.seg-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--muted-ink);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: #fff; color: var(--action); font-weight: 700; box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

.text-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus { border-color: var(--action); box-shadow: 0 0 0 3px rgba(101, 51, 246, 0.12); }
.range-feedback { font-size: 11.5px; color: var(--muted-ink); margin-top: 7px; font-family: var(--font-mono); }
.range-feedback.good { color: var(--green); }
.range-feedback.bad { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted-ink);
  cursor: pointer;
  transition: all 0.14s;
}
.chip:hover { border-color: var(--action); color: var(--action); background: var(--action-soft); }

/* ---------------- equity meter ---------------- */
.meter { margin: 4px 0; }
.meter-bar {
  display: flex;
  height: 34px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.meter-seg {
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  white-space: nowrap;
}
.meter-seg.win { background: var(--green); }
.meter-seg.tie { background: var(--border-strong); color: #fff; }
.meter-seg.lose { background: var(--accent-coral); }
.meter-legend {
  display: flex;
  gap: 16px;
  margin-top: 9px;
  font-size: 12px;
  color: var(--muted-ink);
  flex-wrap: wrap;
}
.meter-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.meter-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.meter-legend .win i { background: var(--green); }
.meter-legend .tie i { background: var(--border-strong); }
.meter-legend .lose i { background: var(--accent-coral); }

/* ---------------- matrix ---------------- */
.matrix-wrap { overflow-x: auto; padding-bottom: 4px; }
.matrix {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 2px;
  min-width: 480px;
  max-width: 620px;
}
.mcell {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(240, 108, 70, calc(var(--i) * 0.34));
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.12s;
}
.mcell:hover { transform: scale(1.08); border-color: var(--action); z-index: 2; }
.mcell.pair { background: rgba(28, 31, 36, calc(var(--i) * 0.38)); }
.mcell.suited { background: rgba(101, 51, 246, calc(var(--i) * 0.42)); }
.mcell.offsuit { background: rgba(240, 108, 70, calc(var(--i) * 0.36)); }
.mcell.gone { background: var(--surface-2); color: var(--dim); }
.mcell.sel { border-color: var(--action); box-shadow: 0 0 0 2px rgba(101, 51, 246, 0.35); }
.mc-name { font-size: 9px; letter-spacing: -0.02em; }
.mc-n { font-size: 8.5px; opacity: 0.6; }

/* ---------------- quiz ---------------- */
.quiz-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 12px;
  background: #fff;
}
.quiz-q {
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.quiz-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--action);
  background: var(--action-soft);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.quiz-options { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  text-align: left;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: #3f4145;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: all 0.14s;
}
.opt:hover:not(:disabled) { background: var(--surface); border-color: var(--border-strong); }
.opt:disabled { cursor: default; }
.opt-key {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted-ink);
  background: var(--surface);
  border-radius: 4px;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
}
.opt.right { border-color: var(--green); background: var(--green-soft); color: #0a3d2a; }
.opt.right .opt-key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--accent-coral); background: var(--red-soft); color: #5c1c19; }
.opt.wrong .opt-key { background: var(--red); color: #fff; }
.quiz-why {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.6;
  color: #3f4145;
  display: none;
}
.quiz-why.show { display: block; animation: rise 0.25s ease both; }
.quiz-why b { color: var(--action); font-weight: 700; }
.quiz-score {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-ink);
  text-align: right;
  margin-top: 6px;
}

/* ---------------- tables ---------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 16px 0;
}
.table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-ink);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-strong);
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: #3f4145;
}
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table tr:hover td { background: var(--surface); }
.table .em { color: var(--action); font-weight: 700; }

/* ---------------- misc ---------------- */
.split {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 28px;
  align-items: start;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.lesson-nav .btn { max-width: 46%; text-align: left; line-height: 1.35; }
.lesson-nav .btn .lbl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 3px;
}
.lesson-nav .btn:hover .lbl { color: var(--action); }

.tip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted-ink);
  background: #fff;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-ink);
}
.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  border-top-color: var(--action);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-inline {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar-inline > div {
  height: 100%;
  background: var(--action);
  transition: width 0.2s linear;
}

.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100%; display: block; }

/* ---------------- chapter cards ---------------- */
.chapter {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s;
}
.chapter:hover {
  border-color: var(--action);
  background: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-raise);
}
.ch-top { display: flex; align-items: baseline; gap: 10px; }
.ch-num { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--action); }
.ch-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.ch-blurb { font-size: 13px; color: var(--muted-ink); line-height: 1.55; }
.ch-go { font-size: 10.5px; font-weight: 700; color: var(--dim); letter-spacing: 0.07em; text-transform: uppercase; margin-top: 5px; }
.chapter:hover .ch-go { color: var(--action); }

/* ---------------- responsive ---------------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    background: var(--canvas);
  }
  .brand { padding: 0; flex: 0 0 auto; }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; font-size: 15px; }
  .brand-name { font-size: 14px; }
  .brand-name em { display: none; }
  .nav { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: 1; }
  .nav-item { white-space: nowrap; padding: 6px 9px; font-size: 12.5px; }
  .nav-num { display: none; }
  .side-foot { display: none; }
  .content { padding: 30px 20px 90px; }
  .split { grid-template-columns: 1fr; gap: 10px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .deck { grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 3px; }
  .deck-card { font-size: 9px; }
  .dc-s { display: none; }
  .picker-div { display: none; }
  .slot { width: 34px; height: 48px; }
  .slot .card-face { width: 32px; height: 45px; }
  .quiz-item { padding: 16px; }
  .panel { padding: 16px; }
  .content { padding: 26px 16px 80px; }
  h2 { margin-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- combo inspector ---------------- */
.combo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.combo-pair {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  transition: opacity 0.2s;
}
.combo-pair.dead { opacity: 0.2; }
.combo-pair .card-face:hover { transform: none; box-shadow: none; }

/* ---------------- confidence interval ---------------- */
.ci-wrap { padding: 10px 4px 6px; }
.ci-track {
  position: relative;
  height: 30px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: visible;
}
.ci-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--action-soft);
  border-left: 2px solid var(--action);
  border-right: 2px solid var(--action);
  transition: left 0.3s, width 0.3s;
}
.ci-point {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--action-deep);
  transition: left 0.3s;
}
.ci-zero {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--accent-coral);
  transition: left 0.3s;
}
.ci-zero::after {
  content: "0";
  position: absolute;
  bottom: -18px;
  left: -3px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
}
.ci-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-ink);
  margin-top: 24px;
}
