/* IPE School — the reading surface.
   Scholarly, paper-first, phone-first. No external assets: works on file://. */

:root {
  --paper:      #faf7f1;
  --paper-2:    #f3ede3;
  --card:       #ffffff;
  --ink:        #1b1a18;
  --ink-soft:   #45423d;
  --ink-faint:  #7d776e;
  --rule:       #ded5c6;
  --rule-soft:  #ece4d7;
  --accent:     #7b2d26;   /* overridden per module */
  --navy:       #17324d;
  --gold:       #a8812c;
  --green:      #2f6b45;
  --red:        #9e2b25;
  --shadow:     0 1px 2px rgba(27,26,24,.06), 0 6px 18px rgba(27,26,24,.05);
  --serif:      Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --sans:       system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:       "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --wrap:       46rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #16151a;
    --paper-2:   #1e1c22;
    --card:      #201e25;
    --ink:       #ece7de;
    --ink-soft:  #c2bcb1;
    --ink-faint: #8d867b;
    --rule:      #3a3640;
    --rule-soft: #2c2933;
    --accent:    #c9776c;
    --navy:      #8fb4d6;
    --gold:      #d5ac5a;
    --green:     #7bbd93;
    --red:       #e08b84;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --paper:     #16151a;
  --paper-2:   #1e1c22;
  --card:      #201e25;
  --ink:       #ece7de;
  --ink-soft:  #c2bcb1;
  --ink-faint: #8d867b;
  --rule:      #3a3640;
  --rule-soft: #2c2933;
  --accent:    #c9776c;
  --navy:      #8fb4d6;
  --gold:      #d5ac5a;
  --green:     #7bbd93;
  --red:       #e08b84;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  padding: 0 0 5rem;
  overflow-wrap: break-word;
}
#app { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(0.9rem, 4vw, 1.6rem); }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent); }

/* ---------- masthead / home ---------- */
.masthead { text-align: center; padding: 2.6rem 0 1.4rem; }
.masthead .mark { font-size: 2.6rem; line-height: 1; }
.masthead h1 {
  font-family: var(--serif); font-size: clamp(1.9rem, 7vw, 2.6rem);
  margin: .5rem 0 .1rem; letter-spacing: -.01em; font-weight: 600;
}
.masthead .rule {
  width: 4.5rem; height: 2px; background: var(--gold); margin: .7rem auto .9rem; opacity: .8;
}
.masthead .sub {
  font-family: var(--serif); font-size: 1.02rem; color: var(--ink-soft);
  margin: 0 auto; max-width: 32rem; font-style: italic;
}
.doors { display: grid; gap: .8rem; margin: 1.6rem 0 1.2rem; }
@media (min-width: 40rem) { .doors { grid-template-columns: 1fr 1fr; } }
.door {
  text-align: left; background: var(--card); border: 1px solid var(--rule);
  border-radius: 14px; padding: 1.05rem 1.1rem; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.door:hover { transform: translateY(-1px); border-color: var(--accent); }
.door .d-ico { font-size: 1.5rem; }
.door h2 { font-family: var(--serif); font-size: 1.16rem; margin: .35rem 0 .25rem; font-weight: 600; }
.door p { margin: 0; font-size: .89rem; color: var(--ink-faint); line-height: 1.5; }

.home-progress {
  background: var(--paper-2); border: 1px solid var(--rule-soft); border-radius: 12px;
  padding: .8rem .95rem; font-size: .88rem; color: var(--ink-soft);
}
.progressbar {
  display: block;               /* the course list renders these as <span> */
  height: 5px; background: var(--rule-soft); border-radius: 3px;
  overflow: hidden; margin-top: .5rem;
}
.progressbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.review-nudge {
  display: block; width: 100%; text-align: left; background: #fff6e6;
  border: 1px solid var(--gold); border-radius: 12px; padding: .8rem .95rem;
  font-size: .89rem; color: #6b4c12; margin: .6rem 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .review-nudge {
    background: color-mix(in srgb, var(--gold) 14%, var(--card));
    color: var(--ink);
  }
}
:root[data-theme="dark"] .review-nudge {
  background: color-mix(in srgb, var(--gold) 14%, var(--card));
  color: var(--ink);
}
.footer-note {
  margin: 2.2rem 0 1rem; font-size: .78rem; color: var(--ink-faint);
  text-align: center; line-height: 1.6; border-top: 1px solid var(--rule-soft); padding-top: 1rem;
}
.sync-link {
  display: block; width: 100%; background: none; border: 1px dashed var(--rule);
  border-radius: 10px; padding: .6rem; font-size: .82rem; color: var(--ink-faint); margin-top: .9rem;
}

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .7rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule-soft);
  margin: 0 calc(-1 * clamp(0.9rem, 4vw, 1.6rem)) 1rem;
  padding: .55rem clamp(0.9rem, 4vw, 1.6rem);
}
.topbar .back {
  background: none; border: none; padding: .2rem .1rem; font-size: .86rem;
  color: var(--accent); font-weight: 600; white-space: nowrap;
}
.topbar .crumb {
  font-size: .8rem; color: var(--ink-faint); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.topbar .theme {
  background: none; border: none; font-size: 1rem; padding: .1rem .2rem; opacity: .6;
}
.pagehead { margin: .4rem 0 1.3rem; }
.pagehead h1 { font-family: var(--serif); font-size: 1.7rem; margin: 0 0 .3rem; font-weight: 600; }
.pagehead p { margin: 0; color: var(--ink-faint); font-size: .92rem; }

/* ---------- module list ---------- */
.mod-list { display: grid; gap: .6rem; }
.mod-card {
  display: flex; gap: .85rem; align-items: center; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: .85rem .95rem; box-shadow: var(--shadow);
}
.mod-card:hover { border-color: var(--accent); }
.mod-card .m-num {
  font-family: var(--serif); font-size: 1.05rem; color: var(--accent);
  font-weight: 700; min-width: 1.6rem; text-align: center;
}
.mod-card .m-body { flex: 1; min-width: 0; }
.mod-card h3 { font-family: var(--serif); font-size: 1.04rem; margin: 0 0 .12rem; font-weight: 600; }
.mod-card p { margin: 0 0 .45rem; font-size: .82rem; color: var(--ink-faint); line-height: 1.45; }
.mod-card .m-meta { font-size: .74rem; color: var(--ink-faint); text-align: right; min-width: 3.2rem; }
.mod-card .pct { font-size: .95rem; font-weight: 700; color: var(--accent); }
.part-label {
  font-family: var(--sans); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 1.5rem 0 .55rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--rule-soft); font-weight: 700;
}
.part-label:first-child { margin-top: .2rem; }

/* ---------- module hero + item list ---------- */
.mod-hero {
  text-align: center; padding: 1.2rem 0 1.3rem; border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 1.2rem;
}
.mod-hero .m-ico { font-size: 2rem; }
.mod-hero h1 { font-family: var(--serif); font-size: 1.55rem; margin: .4rem 0 .3rem; font-weight: 600; }
.mod-hero .tagline { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: .95rem; }
.item-list { display: grid; gap: .4rem; }
.item-row {
  display: flex; gap: .8rem; align-items: center; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--rule-soft); border-radius: 10px;
  padding: .7rem .85rem;
}
.item-row:hover { border-color: var(--accent); }
.item-row.done { background: var(--paper-2); }
.item-row .n {
  min-width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper-2); border: 1px solid var(--rule); font-size: .76rem;
  color: var(--ink-faint); font-weight: 700; flex-shrink: 0;
}
.item-row.done .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.item-row .l-body { flex: 1; min-width: 0; }
.item-row h4 { font-size: .93rem; margin: 0 0 .1rem; font-weight: 600; }
.item-row p { margin: 0; font-size: .77rem; color: var(--ink-faint); line-height: 1.4; }
.item-row .mins { font-size: .72rem; color: var(--ink-faint); white-space: nowrap; }
.item-row .kindtag {
  font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: .1rem .35rem; border-radius: 4px; margin-right: .35rem; vertical-align: 1px;
}

/* ---------- reader ---------- */
.reader { font-family: var(--serif); font-size: 1.045rem; line-height: 1.72; }
.reader-head { margin-bottom: 1.3rem; }
.reader-head .kicker {
  font-family: var(--sans); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: .4rem;
}
.reader-head h1 {
  font-family: var(--serif); font-size: clamp(1.5rem, 5.5vw, 1.95rem);
  margin: 0 0 .35rem; font-weight: 600; line-height: 1.22; letter-spacing: -.01em;
}
.reader-head .sub { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: .98rem; }
.reader p { margin: 0 0 1.05rem; }
.reader h2 {
  font-family: var(--serif); font-size: 1.24rem; font-weight: 600;
  margin: 2rem 0 .75rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule-soft);
}
.reader h3 { font-family: var(--serif); font-size: 1.06rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.reader ul, .reader ol { margin: 0 0 1.05rem; padding-left: 1.3rem; }
.reader li { margin-bottom: .45rem; }
.reader strong { font-weight: 700; color: var(--ink); }
.reader em { font-style: italic; }
.reader code {
  font-family: var(--mono); font-size: .87em; background: var(--paper-2);
  padding: .07em .32em; border-radius: 3px; border: 1px solid var(--rule-soft);
}

/* boxes */
.box {
  border-radius: 10px; padding: .85rem 1rem .3rem; margin: 0 0 1.15rem;
  border: 1px solid var(--rule); background: var(--card); font-size: .96rem;
}
.box .box-label {
  display: block; font-family: var(--sans); font-size: .66rem; letter-spacing: .11em;
  text-transform: uppercase; font-weight: 700; margin-bottom: .35rem; color: var(--ink-faint);
}
.box p { margin: 0 0 .6rem; }
.box ul, .box ol { margin: 0 0 .7rem; padding-left: 1.2rem; }
.box-analogy { background: color-mix(in srgb, var(--gold) 8%, var(--card)); border-color: color-mix(in srgb, var(--gold) 35%, var(--rule)); }
.box-analogy .box-label { color: var(--gold); }
.box-caveat  { background: color-mix(in srgb, var(--red) 6%, var(--card)); border-color: color-mix(in srgb, var(--red) 30%, var(--rule)); }
.box-caveat .box-label { color: var(--red); }
.box-example { background: var(--paper-2); }
.box-case    { border-left: 4px solid var(--navy); background: color-mix(in srgb, var(--navy) 5%, var(--card)); }
.box-case .box-label { color: var(--navy); }
.box-nepal   { border-left: 4px solid var(--green); background: color-mix(in srgb, var(--green) 6%, var(--card)); }
.box-nepal .box-label { color: var(--green); }
.box-hook {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
  font-family: var(--serif); font-style: italic; font-size: 1.03rem;
}
.box-hook .box-label { color: color-mix(in srgb, var(--paper) 60%, transparent); }
.box-hook strong { color: #fff; }
:root[data-theme="dark"] .box-hook strong { color: var(--ink); }
.box-redflags { background: color-mix(in srgb, var(--red) 6%, var(--card)); border-color: color-mix(in srgb, var(--red) 30%, var(--rule)); }
.box-redflags .box-label { color: var(--red); }

.ask {
  font-family: var(--serif); font-style: italic; font-size: 1.02rem;
  border-left: 3px solid var(--accent); padding: .15rem 0 .15rem .85rem;
  margin: 0 0 .9rem; color: var(--ink-soft);
}
.ask::before { content: "“"; }
.ask::after  { content: "”"; }

.pullquote {
  font-family: var(--serif); font-size: 1.1rem; font-style: italic;
  border-left: 3px solid var(--gold); padding-left: 1rem; margin: 1.3rem 0; color: var(--ink-soft);
}
.pullquote .who {
  display: block; font-style: normal; font-size: .8rem; font-family: var(--sans);
  color: var(--ink-faint); margin-top: .4rem;
}

/* steps — the argument, numbered */
.steps { counter-reset: st; margin: 0 0 1.2rem; }
.steps .st {
  position: relative; padding-left: 2.3rem; margin-bottom: .85rem; counter-increment: st;
}
.steps .st::before {
  content: counter(st); position: absolute; left: 0; top: .1rem;
  width: 1.65rem; height: 1.65rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-family: var(--sans); font-size: .75rem; font-weight: 700;
}
:root[data-theme="dark"] .steps .st::before { color: #16151a; }

/* timeline */
.timeline { margin: 0 0 1.2rem; border-left: 2px solid var(--rule); padding-left: 1rem; }
.timeline .tl { position: relative; margin-bottom: .8rem; }
.timeline .tl::before {
  content: ""; position: absolute; left: -1.36rem; top: .55rem;
  width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--paper);
}
.timeline .tl .when {
  font-family: var(--sans); font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  color: var(--accent); text-transform: uppercase;
}
.timeline .tl .what { font-size: .96rem; }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 0 1.2rem; -webkit-overflow-scrolling: touch; }
table.data {
  border-collapse: collapse; width: 100%; font-family: var(--sans);
  font-size: .84rem; min-width: 22rem;
}
table.data caption {
  font-family: var(--sans); font-size: .74rem; color: var(--ink-faint);
  text-align: left; padding-bottom: .4rem; font-style: italic;
}
table.data th {
  text-align: left; padding: .45rem .55rem; background: var(--paper-2);
  border-bottom: 2px solid var(--rule); font-weight: 700; font-size: .78rem;
  letter-spacing: .02em; white-space: nowrap;
}
table.data td { padding: .45rem .55rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }

/* formula */
.formula {
  font-family: var(--mono); font-size: .85rem; background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: 8px; padding: .7rem .85rem;
  white-space: pre-wrap; margin: 0 0 .4rem; line-height: 1.55; overflow-x: auto;
}
.formula-note {
  font-family: var(--sans); font-size: .8rem; color: var(--ink-faint);
  margin: 0 0 1.15rem; line-height: 1.5;
}

/* terms */
.terms { margin: 0 0 1.2rem; }
.terms .tm {
  border-bottom: 1px solid var(--rule-soft); padding: .5rem 0; font-size: .93rem;
}
.terms .tm:last-child { border-bottom: none; }
.terms .tm b { color: var(--accent); }

/* debate plate */
.debate {
  border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
  margin: 0 0 1.3rem; background: var(--card);
}
.debate .d-q {
  padding: .75rem .95rem; background: var(--paper-2); font-family: var(--serif);
  font-size: 1.02rem; font-weight: 600; border-bottom: 1px solid var(--rule);
}
.debate .d-side { padding: .75rem .95rem; border-bottom: 1px solid var(--rule-soft); }
.debate .d-side:last-of-type { border-bottom: none; }
.debate .d-who {
  font-family: var(--sans); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; color: var(--accent); margin-bottom: .25rem;
}
.debate .d-claim { font-size: .95rem; margin: 0; }
.debate .d-verdict {
  padding: .75rem .95rem; background: color-mix(in srgb, var(--navy) 7%, var(--card));
  border-top: 1px solid var(--rule); font-size: .92rem;
}
.debate .d-verdict b { color: var(--navy); }

/* reading cards */
.readcard {
  display: flex; gap: .75rem; width: 100%; text-align: left; align-items: flex-start;
  background: var(--card); border: 1px solid var(--rule); border-radius: 10px;
  padding: .7rem .85rem; margin: 0 0 .55rem; font-family: var(--sans);
}
.readcard:hover { border-color: var(--accent); }
.readcard .rc-ico { font-size: 1.1rem; line-height: 1.3; }
.readcard .rc-body { flex: 1; min-width: 0; }
.readcard .rc-cite { display: block; font-size: .86rem; font-weight: 600; line-height: 1.35; margin-bottom: .12rem; }
.readcard .rc-cite i { font-style: italic; font-weight: 400; }
.readcard .rc-thesis { display: block; font-size: .78rem; color: var(--ink-faint); line-height: 1.45; }
.readcard .rc-go { font-size: .72rem; color: var(--accent); font-weight: 700; white-space: nowrap; }
.tier-core   { border-left: 3px solid var(--accent); }
.tier-further{ border-left: 3px solid var(--rule); }
.tier-primary{ border-left: 3px solid var(--gold); }

/* reading page head */
.cite-plate {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 12px;
  padding: .9rem 1rem; margin: 0 0 1.3rem; font-family: var(--sans); font-size: .87rem;
}
.cite-plate .cp-row { display: flex; gap: .6rem; padding: .22rem 0; }
.cite-plate .cp-k {
  min-width: 5.2rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700; padding-top: .18rem; flex-shrink: 0;
}
.cite-plate .cp-v { flex: 1; min-width: 0; }
.cite-plate a { word-break: break-word; }
.badge {
  display: inline-block; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; padding: .12rem .4rem; border-radius: 4px; margin-right: .3rem;
}
.badge-core    { background: var(--accent); color: #fff; }
.badge-further { background: var(--rule); color: var(--ink-soft); }
.badge-primary { background: var(--gold); color: #3a2c08; }
:root[data-theme="dark"] .badge-core { color: #16151a; }

.thesis-plate {
  border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card));
  padding: .8rem 1rem; border-radius: 0 10px 10px 0; margin: 0 0 1.3rem;
  font-family: var(--serif); font-size: 1.05rem; font-style: italic;
}
.thesis-plate .tp-label {
  display: block; font-family: var(--sans); font-style: normal; font-size: .66rem;
  letter-spacing: .11em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); margin-bottom: .3rem;
}

/* ---------- interactive models ---------- */
.modelbox {
  border: 1px solid var(--rule); border-radius: 12px; background: var(--card);
  margin: 0 0 1.3rem; overflow: hidden; box-shadow: var(--shadow); font-family: var(--sans);
}
.modelbox .mb-head { padding: .8rem .95rem .55rem; border-bottom: 1px solid var(--rule-soft); }
.modelbox .mb-tag {
  font-size: .64rem; letter-spacing: .11em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); margin-bottom: .2rem;
}
.modelbox h4 { margin: 0 0 .25rem; font-size: 1rem; font-weight: 700; }
.modelbox .mb-blurb { margin: 0; font-size: .81rem; color: var(--ink-faint); line-height: 1.5; }
.mb-inputs { padding: .7rem .95rem; display: grid; gap: .55rem; }
@media (min-width: 30rem) { .mb-inputs { grid-template-columns: 1fr 1fr; } }
.mb-in { display: flex; flex-direction: column; gap: .18rem; }
.mb-in label { font-size: .74rem; color: var(--ink-soft); font-weight: 600; }
.mb-in input, .mb-in select {
  font-family: var(--sans); font-size: .92rem; padding: .42rem .5rem;
  border: 1px solid var(--rule); border-radius: 7px; background: var(--paper);
  color: var(--ink); width: 100%;
}
.mb-in input:focus, .mb-in select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.mb-out { padding: .3rem .95rem .9rem; }
.mb-line {
  display: flex; justify-content: space-between; gap: .8rem; align-items: baseline;
  padding: .38rem 0; border-bottom: 1px dashed var(--rule-soft); font-size: .87rem;
}
.mb-line:last-of-type { border-bottom: none; }
.mb-line span { color: var(--ink-soft); }
.mb-line b { font-size: 1rem; text-align: right; }
.mb-line.hi b { color: var(--accent); font-size: 1.1rem; }
.mb-note {
  margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--rule-soft);
  font-size: .8rem; color: var(--ink-faint); line-height: 1.55;
}
.mb-err { color: var(--red); font-size: .84rem; padding: .4rem 0; }
.mb-verdict {
  margin-top: .5rem; padding: .55rem .7rem; border-radius: 8px; font-size: .87rem;
  background: var(--paper-2); border: 1px solid var(--rule-soft); line-height: 1.5;
}
.mb-bars { margin-top: .6rem; }
.mb-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; font-size: .78rem; }
.mb-bar .bl { min-width: 7rem; color: var(--ink-soft); }
.mb-bar .bt { flex: 1; height: .8rem; background: var(--rule-soft); border-radius: 4px; overflow: hidden; }
.mb-bar .bt i { display: block; height: 100%; background: var(--accent); }
.mb-bar .bt i.neg { background: var(--red); }
.mb-bar .bv { min-width: 3.6rem; text-align: right; font-weight: 700; }
.mb-grid { overflow-x: auto; margin-top: .6rem; }
.mb-grid table { border-collapse: collapse; font-size: .78rem; width: 100%; }
.mb-grid th, .mb-grid td { padding: .32rem .45rem; border: 1px solid var(--rule-soft); text-align: right; }
.mb-grid th { background: var(--paper-2); font-weight: 700; }
.mb-grid td.lab { text-align: left; background: var(--paper-2); font-weight: 600; }

/* figures */
.figure { margin: 0 0 1.3rem; }
.figure svg { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--rule); background: var(--card); }
.figure .fig-cap {
  font-family: var(--sans); font-size: .76rem; color: var(--ink-faint);
  margin-top: .4rem; line-height: 1.5; font-style: italic;
}

/* ---------- reader nav ---------- */
.donebar {
  text-align: center; font-size: .82rem; color: var(--green); font-weight: 700;
  padding: .6rem; font-family: var(--sans);
}
.reader-nav { display: flex; gap: .55rem; margin: 1.6rem 0 1rem; flex-wrap: wrap; }
.reader-nav button {
  flex: 1; min-width: 8.5rem; padding: .72rem .8rem; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--card); font-size: .87rem; font-weight: 600;
  font-family: var(--sans);
}
.reader-nav button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
:root[data-theme="dark"] .reader-nav button.primary { color: #16151a; }

/* ---------- library ---------- */
.lib-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.libsearch {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--card); color: var(--ink); font-size: .92rem; margin-bottom: .7rem;
  font-family: var(--sans);
}
.lib-count { font-size: .8rem; color: var(--ink-faint); margin-bottom: .7rem; }
.lib-group-head {
  font-family: var(--sans); font-size: .7rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700; margin: 1.3rem 0 .5rem;
  border-bottom: 1px solid var(--rule-soft); padding-bottom: .28rem;
}

/* chips */
.chiprow { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  border: 1px solid var(--rule); background: var(--card); border-radius: 999px;
  padding: .34rem .72rem; font-size: .8rem; color: var(--ink-soft); font-family: var(--sans);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .chip.on { color: #16151a; }
.group { margin-bottom: 1.2rem; }
.group h3 {
  font-size: .78rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 .45rem; font-weight: 700; font-family: var(--sans);
}

/* ---------- quiz ---------- */
.quiz-meta {
  display: flex; justify-content: space-between; font-size: .78rem;
  color: var(--ink-faint); margin-bottom: .6rem; font-family: var(--sans);
}
.quiz-meta .score b { color: var(--accent); font-size: .95rem; }
.qcard {
  background: var(--card); border: 1px solid var(--rule); border-top: 3px solid var(--accent);
  border-radius: 12px; padding: 1rem 1.05rem; box-shadow: var(--shadow);
}
.qcard .topic {
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); margin-bottom: .45rem; font-family: var(--sans);
}
.qcard .qtext { font-family: var(--serif); font-size: 1.06rem; line-height: 1.6; margin-bottom: .9rem; }
.opts { display: grid; gap: .45rem; }
.opt {
  display: flex; gap: .6rem; align-items: flex-start; text-align: left; width: 100%;
  border: 1px solid var(--rule); background: var(--paper); border-radius: 9px;
  padding: .6rem .7rem; font-size: .9rem; line-height: 1.45;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .letter {
  min-width: 1.35rem; height: 1.35rem; border-radius: 5px; display: grid; place-items: center;
  background: var(--paper-2); border: 1px solid var(--rule); font-size: .7rem; font-weight: 700;
  color: var(--ink-faint); flex-shrink: 0; margin-top: .05rem;
}
.opt.correct { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--paper)); }
.opt.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--paper)); }
.opt.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.opt.dim { opacity: .5; }
.verdict { margin-top: .9rem; padding: .8rem .9rem; border-radius: 10px; font-size: .89rem; line-height: 1.6; }
.verdict.good { background: color-mix(in srgb, var(--green) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--green) 40%, var(--rule)); }
.verdict.bad  { background: color-mix(in srgb, var(--red) 8%, var(--card));  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--rule)); }
.verdict .v-head { font-weight: 700; margin-bottom: .35rem; font-family: var(--sans); font-size: .82rem; }
.verdict.good .v-head { color: var(--green); }
.verdict.bad .v-head { color: var(--red); }
.verdict .v-wrongwhy { margin-bottom: .5rem; }
.nextbtn {
  width: 100%; margin-top: .8rem; padding: .8rem; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-size: .93rem; font-weight: 700; font-family: var(--sans);
}
:root[data-theme="dark"] .nextbtn { color: #16151a; }
.bigstart {
  width: 100%; padding: .9rem; border-radius: 12px; border: none; background: var(--accent);
  color: #fff; font-size: 1rem; font-weight: 700; font-family: var(--sans);
}
:root[data-theme="dark"] .bigstart { color: #16151a; }
.result-hero { text-align: center; padding: 1.6rem 0 1rem; }
.result-hero .big { font-family: var(--serif); font-size: 3rem; font-weight: 700; color: var(--accent); }
.result-hero .lbl { font-size: .9rem; color: var(--ink-faint); }
.leak-row {
  display: flex; justify-content: space-between; gap: .7rem; padding: .5rem 0;
  border-bottom: 1px solid var(--rule-soft); font-size: .87rem; font-family: var(--sans);
}
.leak-row:last-child { border-bottom: none; }
.leak-row b { white-space: nowrap; }
.leak-row .ok { color: var(--green); }
.leak-row .no { color: var(--red); }

/* sync */
.syncbox {
  width: 100%; min-height: 8rem; font-family: var(--mono); font-size: .7rem;
  border: 1px solid var(--rule); border-radius: 10px; padding: .6rem; background: var(--card);
  color: var(--ink); resize: vertical;
}
