:root {
  --bg: #f6f7fb; --card: #fff; --ink: #1c2230; --muted: #5d6677; --line: #e3e6ee;
  --brand: #1f4fd1; --brand-soft: #e8eefc;
  --ok: #138a4a; --ok-soft: #e4f6ec; --bad: #c2362b; --bad-soft: #fdeceb;
  --warn: #a35d00; --warn-soft: #fff4e0; --violet: #6b3fc4; --violet-soft: #f1ebfd;
  --teal: #0c7d86; --teal-soft: #e2f5f6;
  --r: 14px; --shadow: 0 1px 2px rgba(20,30,60,.06), 0 4px 16px rgba(20,30,60,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b; --card: #191d27; --ink: #e8ebf2; --muted: #9aa3b5; --line: #2a3040;
    --brand: #7aa0ff; --brand-soft: #1c2643;
    --ok: #4cc983; --ok-soft: #14301f; --bad: #ff7b70; --bad-soft: #3a1a18;
    --warn: #f0b04a; --warn-soft: #33270f; --violet: #b49bff; --violet-soft: #251d3d;
    --teal: #4fd0d8; --teal-soft: #11303a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
small { color: var(--muted); }
b, strong { font-weight: 650; }

/* top nav */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1040px; margin: auto; padding: 8px 16px; display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.top-in::-webkit-scrollbar { display: none; }
.top .home { font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; margin-right: 6px; }
.top .chip { white-space: nowrap; text-decoration: none; font-size: 13.5px; padding: 5px 11px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.top .chip:hover { border-color: var(--brand); color: var(--brand); }

.wrap { max-width: 1040px; margin: auto; padding: 18px 16px 80px; }
.hero { padding: 26px 0 8px; }
.hero .kicker { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.hero h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.1; margin: 6px 0 10px; letter-spacing: -.02em; }
.hero p { color: var(--muted); max-width: 720px; margin: 0; }

section { margin-top: 38px; }
h2 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
h2 .num { font-size: 13px; background: var(--brand); color: var(--bg); border-radius: 8px; padding: 2px 8px; }
.sub { color: var(--muted); margin: 0 0 14px; }
h3 { font-size: 17px; margin: 0 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* number tiles */
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); position: relative; }
.tile .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--brand); }
.tile .big small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.tile .lbl { margin-top: 6px; font-size: 14.5px; }
.tile.v .big { color: var(--violet); } .tile.t .big { color: var(--teal); } .tile.w .big { color: var(--warn); } .tile.r .big { color: var(--bad); } .tile.g .big { color: var(--ok); }

/* callouts */
.callout { border-radius: 12px; padding: 12px 14px; border: 1px solid; font-size: 15px; }
.callout.trap { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.callout.tip { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout.note { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout.info { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.callout b:first-child { margin-right: 4px; }
.callout + .callout { margin-top: 10px; }
.grid > .callout + .callout { margin-top: 0; }

/* tables */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--brand-soft); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
td.y { color: var(--ok); font-weight: 700; text-align: center; } td.n { color: var(--bad); font-weight: 700; text-align: center; } td.m { color: var(--warn); font-weight: 700; text-align: center; }
th.c { text-align: center; }

/* flow diagrams */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; }
.step { flex: 1 1 150px; background: var(--card); border: 2px solid var(--brand); border-radius: 12px; padding: 12px; position: relative; min-width: 140px; }
.step .s-n { font-size: 12px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }
.step .s-t { font-weight: 700; margin: 2px 0 4px; }
.step .s-d { font-size: 13.5px; color: var(--muted); }
.arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 6px; color: var(--muted); font-size: 22px; font-weight: 700; flex: 0 0 auto; }
.arrow .lbl { font-size: 11.5px; text-align: center; color: var(--warn); font-weight: 800; line-height: 1.1; max-width: 90px; }
.ar { display: inline-block; font-weight: 800; }
.arrow-col { display: flex; flex-direction: column; align-items: center; justify-content: center; }
@media (max-width: 720px) {
  .flow { flex-direction: column; }
  .flow .step { flex: 0 0 auto; min-width: 0; }
  .flow .arrow { flex-direction: row; gap: 8px; padding: 4px 0; }
  .flow .arrow .ar { transform: rotate(90deg); }
  .flow .arrow .lbl { max-width: none; }
}

/* org chart */
.org { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org .node { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; text-align: center; min-width: 220px; max-width: 520px; }
.org .node.main { border-color: var(--brand); background: var(--brand-soft); }
.org .node small { display: block; }
.org .vline { width: 2px; height: 18px; background: var(--muted); }
.org .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.org .row .node { min-width: 0; flex: 1 1 140px; max-width: 200px; font-size: 14px; }

/* ladder */
.ladder { display: flex; flex-direction: column-reverse; gap: 8px; }
.rung { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--brand)); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.rung .who { font-weight: 800; }
.rung .who small { display: block; font-weight: 500; }
.rung ul { margin: 0; padding-left: 18px; font-size: 14.5px; }
@media (max-width: 600px) { .rung { grid-template-columns: 1fr; } }

/* timeline */
.tl { position: relative; padding: 8px 0 0; }
.tl-bar { display: flex; height: 44px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tl-seg { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; text-align: center; padding: 0 6px; }
.tl-ticks { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* money flow */
.money { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 8px; }
.money .party { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; font-weight: 700; }
.money .party small { display: block; font-weight: 500; }
.money .party.b { border-color: var(--brand); }
.money .pipe { font-size: 26px; color: var(--ok); text-align: center; font-weight: 800; }
.money .pipe small { display: block; font-size: 11px; color: var(--ok); }
.nope { margin-top: 10px; display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 700; color: var(--bad); flex-wrap: wrap; text-align: center; }
.nope .x { text-decoration: line-through; text-decoration-thickness: 3px; }
@media (max-width: 640px) { .money { grid-template-columns: 1fr; } .money .pipe { display: flex; gap: 6px; justify-content: center; align-items: center; } .money .pipe .ar { transform: rotate(90deg); } }

/* reveal / cloze */
.reveal { cursor: pointer; border-radius: 6px; padding: 0 5px; user-select: none; }
.reveal:not(.shown) { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; height: 24px; padding: 0 8px; vertical-align: -6px; font-size: 0; box-sizing: border-box; background: var(--brand-soft); border: 1.5px dashed var(--brand); }
.reveal:not(.shown)::before { content: "tap ?"; font-size: 12px; font-weight: 800; color: var(--brand); }
.reveal.shown { font-weight: 750; color: var(--ink); background: var(--ok-soft); box-shadow: inset 0 -2px 0 var(--ok); }
.drill { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.drill li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }

/* buttons */
.btn { font: inherit; font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 10px; background: var(--brand); color: var(--bg); border: 1px solid var(--brand); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn:hover { filter: brightness(1.08); }

/* quiz */
.quiz-head { position: sticky; top: 50px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; box-shadow: var(--shadow); }
.score { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; }
.score-num { font-size: 22px; font-weight: 800; white-space: nowrap; }
.score-num span { font-size: 13px; color: var(--muted); font-weight: 500; }
.meter { position: relative; flex: 1; height: 10px; background: var(--line); border-radius: 99px; overflow: visible; min-width: 80px; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--muted); transition: width .3s; }
.meter-fill.ok { background: var(--ok); } .meter-fill.bad { background: var(--bad); }
.meter-line { position: absolute; left: 70%; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .6; }
.score-pct { font-weight: 700; white-space: nowrap; }
.quiz-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.quiz-list { display: grid; gap: 12px; margin-top: 12px; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.q-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.q-n { font-weight: 800; color: var(--brand); font-size: 13px; }
.tag { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--violet-soft); color: var(--violet); }
.q-text { font-weight: 600; margin-bottom: 10px; }
.opts { display: grid; gap: 6px; }
@media (min-width: 760px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { font: inherit; text-align: left; display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.opt b { color: var(--muted); }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:disabled { cursor: default; opacity: .75; }
.opt.correct { background: var(--ok-soft); border-color: var(--ok); opacity: 1; }
.opt.correct b { color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); opacity: 1; }
.opt.wrong b { color: var(--bad); }
.why { margin-top: 10px; font-size: 14.5px; padding: 10px 12px; border-radius: 10px; }
.why.ok { background: var(--ok-soft); } .why.bad { background: var(--bad-soft); }

/* flashcards */
.fc-bar, .sort-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toggle { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.fc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.fc { perspective: 900px; height: 170px; cursor: pointer; outline: none; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-front, .fc-back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--r); border: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; justify-content: center; text-align: center; box-shadow: var(--shadow); }
.fc-front { background: var(--card); font-weight: 750; font-size: 17px; }
.fc-front small { font-weight: 400; font-size: 12px; margin-top: 8px; }
.fc-back { background: var(--brand-soft); transform: rotateY(180deg); font-size: 14px; justify-content: space-between; }
.fc-back > div:first-child { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; }
.fc.known .fc-front { border-color: var(--ok); }
.fc.known .fc-front::after { content: "✔ known"; font-size: 11px; color: var(--ok); margin-top: 6px; }
.fc:focus-visible .fc-front { outline: 3px solid var(--brand); }
.fc-acts { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.mini { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.mini.ok { background: var(--ok); color: var(--bg); border-color: var(--ok); }

/* sorter */
.sort-list { display: grid; gap: 8px; }
.sort-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.sort-row.ok { border-color: var(--ok); } .sort-row.bad { border-color: var(--bad); }
.sort-btns { display: flex; gap: 6px; }
.pill { font: inherit; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; white-space: nowrap; }
.pill.red { border-color: var(--bad); color: var(--bad); } .pill.green { border-color: var(--ok); color: var(--ok); } .pill.blue { border-color: var(--brand); color: var(--brand); }
.pill:disabled { opacity: .35; cursor: default; }
.pill.is-answer { opacity: 1; color: var(--bg); }
.pill.red.is-answer { background: var(--bad); } .pill.green.is-answer { background: var(--ok); } .pill.blue.is-answer { background: var(--brand); }
.sort-why { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
@media (max-width: 600px) { .sort-row { grid-template-columns: 1fr; } }

/* exam format bar */
.exam-bar { display: flex; height: 54px; border-radius: 12px; overflow: hidden; font-weight: 700; color: var(--bg); font-size: 14px; }
.exam-bar > div { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 8px; line-height: 1.15; }

.pattern { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: start; }
.pattern .k { font-weight: 800; color: var(--violet); white-space: nowrap; }
@media (max-width: 600px) { .pattern { grid-template-columns: 1fr; gap: 2px; } .pattern .k { margin-top: 8px; } }

.src { font-size: 13.5px; color: var(--muted); }
.src li { margin-bottom: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; vertical-align: middle; }
.badge.law { background: var(--ok-soft); color: var(--ok); } .badge.book { background: var(--violet-soft); color: var(--violet); } .badge.prep { background: var(--warn-soft); color: var(--warn); }
.mnemonic { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--teal); background: var(--teal-soft); padding: 1px 6px; border-radius: 6px; }
/* prev / hub / next links at the bottom of unit pages */
.bottom-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.bottom-nav a { text-decoration: none; font-weight: 700; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.bottom-nav a:hover { border-color: var(--brand); color: var(--brand); }
footer { margin-top: 50px; color: var(--muted); font-size: 13px; text-align: center; }
@media print { .top, .quiz-head .quiz-btns, .btn { display: none; } .reveal { color: var(--ink); } section { break-inside: avoid-page; } }

/* commission seats */
.seats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seat { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--bg); }
.seat.b { background: var(--brand); } .seat.p { background: var(--ok); } .seat.g { background: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* test equation */
.eq { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.eq .term { flex: 1 1 150px; border-radius: 12px; padding: 12px; background: var(--card); border: 2px solid var(--line); text-align: center; }
.eq .term b { display: block; font-size: 15px; }
.eq .term small { display: block; margin-top: 2px; }
.eq .op { display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--muted); }
.eq .term.res { border-color: var(--bad); background: var(--bad-soft); }
.eq .term.res b { color: var(--bad); font-size: 18px; }
@media (max-width: 640px) { .eq { flex-direction: column; } }

/* buckets */
.bucket h3 { display: flex; align-items: center; gap: 8px; }
.bucket ul { margin: 0; padding-left: 18px; }
.bucket li { margin: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* term calendar */
.cal { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: 8px; }
.cal div { height: 30px; border-radius: 4px; background: var(--brand-soft); position: relative; }
.cal div.y2 { background: color-mix(in srgb, var(--ok) 25%, transparent); }
.cal div.ce { background: var(--warn); }
.cal div.end { background: var(--bad); }
.cal-labels { display: grid; grid-template-columns: 1fr 1fr; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.cal-labels span:last-child { text-align: right; }
.pins { display: grid; gap: 6px; margin-top: 10px; font-size: 14.5px; }
.pins div { display: flex; gap: 8px; align-items: baseline; }
.pins > div > i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: 0 0 auto; transform: translateY(1px); }

/* escalator */
.esc { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.esc .st { flex: 1 1 140px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.esc .st b { display: block; font-size: 22px; letter-spacing: -.02em; }
.esc .st:nth-child(1) { min-height: 90px; } .esc .st:nth-child(2) { min-height: 120px; border-color: var(--warn); } .esc .st:nth-child(3) { min-height: 150px; border-color: var(--bad); }
.esc .st:nth-child(2) b { color: var(--warn); } .esc .st:nth-child(3) b { color: var(--bad); }

.bookbox { border: 2px dashed var(--violet); border-radius: var(--r); padding: 14px 16px; background: var(--violet-soft); }
.bookbox h3 { color: var(--violet); }
.bookbox ol { margin: 6px 0 0; padding-left: 20px; columns: 2 260px; }
.statebar { display: grid; grid-template-columns: 22fr 3fr 2fr 3fr; gap: 3px; margin-top: 10px; }
.statebar div { border-radius: 8px; padding: 8px 6px; font-size: 12.5px; font-weight: 700; text-align: center; line-height: 1.2; }
.statebar .hit { outline: 3px solid var(--bad); outline-offset: -3px; }
@media (max-width: 640px) { .statebar { grid-template-columns: 1fr 1fr; } }
td.y, td.n { font-size: 17px; }
@media (max-width: 600px) { th, td { padding: 7px 8px; font-size: 13.5px; } th { font-size: 11.5px; } }
