/* Code AILP: interactive lessons (ailp.html + js/ailp.js). Its own calm, minimal look. */
:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --card: #ffffff;
  --ink: #17171b;
  --muted: #74716a;
  --line: #e6e3db;
  --soft: #efede7;
  --accent: #2f6fed;
  --good: #1f9d6b;
  --good-soft: #e3f4ec;
  --bad: #d98a00;
  --bad-soft: #fdf1d8;
  --dr: #2f6fed;
  --cr: #c2410c;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 6px 20px rgba(20, 20, 30, 0.06);
  --lift: 0 10px 30px rgba(20, 20, 30, 0.18);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --text: var(--ink); /* for the shared calculator (css/calc.css) */
}
/* Dark mode: chosen with the toggle in the top bar (js/theme.js); light is the default. */
:root[data-theme="dark"] {
    --bg: #111113;
    --card: #1b1b1f;
    --ink: #f1f0ec;
    --muted: #9c998f;
    --line: #2c2c31;
    --soft: #232328;
    --accent: #6b9bff;
    --good: #3fcf8e;
    --good-soft: #17322a;
    --bad: #f5b041;
    --bad-soft: #3a2e12;
    --dr: #7aa6ff;
    --cr: #ff9a5c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
    --lift: 0 12px 34px rgba(0, 0, 0, 0.55);
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ailp {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.num, .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.ailp-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
/* The brand: home (all five subjects) */
.ailp-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.ailp-brand .brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font: 800 0.72rem var(--mono); letter-spacing: 0.02em;
}
.ailp-brand:hover .brand-name { text-decoration: underline; text-underline-offset: 3px; }
.ailp-toplink { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; white-space: nowrap; padding: 6px 10px; border-radius: 10px; }
.ailp-toplink:hover { color: var(--ink); background: var(--soft); }
.ailp-meter {
  flex: 1; height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden;
  opacity: 0; transition: opacity 0.3s;
}
.ailp-meter.show { opacity: 1; }
.ailp-meter span {
  display: block; height: 100%; width: 0%;
  border-radius: inherit; background: var(--good);
  transition: width 0.6s var(--spring), background 0.3s;
}
.ailp-meter.dip span { background: var(--bad); }
.ailp-sound {
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.ailp-sound:hover { background: var(--soft); color: var(--ink); }
.ailp-sound .off { display: none; }
.ailp-sound[aria-pressed="false"] .on { display: none; }
.ailp-sound[aria-pressed="false"] .off { display: block; }

.ailp-app {
  max-width: 760px; margin: 0 auto;
  padding: 12px 20px 160px;
}

/* ---------- buttons ---------- */
.ailp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 28px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); cursor: pointer; font-weight: 600;
  transition: transform 0.15s var(--ease), box-shadow 0.15s, background 0.15s;
}
.ailp-btn:hover { box-shadow: var(--shadow); }
.ailp-btn:active { transform: scale(0.97); }
.ailp-btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ailp-btn.primary:hover { box-shadow: var(--lift); }
.ailp-btn[disabled] { opacity: 0.35; pointer-events: none; }
.ailp-btn.wide { width: 100%; }
.ailp-btn { white-space: nowrap; }
.actions .ailp-btn:not(.wide) { flex: none; }
.ailp-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ailp-btn:focus:not(:focus-visible) { outline: none; }
.ailp-link { border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 0.85rem; }

/* ---------- course path ---------- */
.path-head { text-align: center; padding: 28px 0 8px; }
.path-kicker { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.path-head h1 { margin: 6px 0 6px; font-size: clamp(2rem, 6vw, 2.8rem); letter-spacing: -0.03em; line-height: 1.1; }
.path-head p { margin: 0 auto; max-width: 30em; color: var(--muted); }
.path { list-style: none; margin: 36px auto 0; padding: 0; max-width: 460px; position: relative; }
.path::before {
  content: ""; position: absolute; left: 31px; top: 30px; bottom: 30px; width: 2px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 12px);
}
.node {
  position: relative; display: flex; align-items: center; gap: 18px;
  width: 100%; padding: 12px 14px 12px 0; margin: 0 0 14px;
  border: 0; background: none; text-align: left; cursor: pointer; border-radius: 18px;
}
.node:disabled { cursor: default; }
.node .dot {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 2px solid var(--line);
  font-family: var(--mono); font-weight: 700; color: var(--muted);
  box-shadow: var(--shadow); position: relative; z-index: 1;
  transition: transform 0.2s var(--spring);
}
.node:not(:disabled):hover .dot { transform: scale(1.06); }
.node .txt strong { display: block; font-size: 1.05rem; }
.node .txt span { color: var(--muted); font-size: 0.9rem; }
.node.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.node.current .dot { background: var(--ink); border-color: var(--ink); color: var(--bg); animation: pulse 2s infinite; }
.node.locked { opacity: 0.45; }
.node.open .dot { border-style: dashed; }
.node .tag.xl { color: #1f7a4d; border-color: #1f7a4d; font-weight: 700; }
/* Dark mode: chosen with the toggle in the top bar (js/theme.js); light is the default. */
:root[data-theme="dark"] .node .tag.xl { color: #4fd18b; border-color: #4fd18b; }
.node.xl .dot { border-radius: 10px; }
.node .tag { margin-left: auto; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ink) 35%, transparent); }
  70% { box-shadow: 0 0 0 14px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.path-foot { text-align: center; margin-top: 28px; }

/* ---------- lesson screens ---------- */
.screen { animation: enter 0.45s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }
.screen.leave { animation: leave 0.22s var(--ease) both; }
@keyframes leave { to { opacity: 0; transform: translateY(-10px); } }

.kicker { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.screen h2 { margin: 0 0 10px; font-size: clamp(1.5rem, 4.5vw, 2rem); letter-spacing: -0.02em; line-height: 1.2; }
.screen .lead { margin: 0 0 22px; color: color-mix(in srgb, var(--ink) 80%, transparent); max-width: 36em; }
.focus-pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 14px;
  padding: 4px 12px; border-radius: 99px; font-size: 0.8rem; font-weight: 600;
  background: var(--bad-soft); color: var(--bad);
}
.concept { background: var(--card); border-radius: 22px; padding: 26px; box-shadow: var(--shadow); margin-bottom: 22px; }
.concept p { margin: 0 0 12px; }
.concept p:last-child { margin-bottom: 0; }
.concept b.dr { color: var(--dr); } .concept b.cr { color: var(--cr); }
.screen .actions { margin-top: 26px; display: flex; gap: 12px; }

/* Mini T diagram in concept cards */
.tee { display: grid; grid-template-columns: 1fr 1fr; margin: 6px 0 18px; border-top: 2px solid var(--ink); }
.tee > div { padding: 10px 14px 4px; min-height: 92px; position: relative; }
.tee > div + div { border-left: 2px solid var(--ink); }
.tee h4 { margin: 0 0 6px; font-size: 0.8rem; font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.tee .dr h4 { color: var(--dr); } .tee .cr h4 { color: var(--cr); }
.tee .coin {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: currentColor; opacity: 0; top: 50px;
}
.tee .dr .coin { color: var(--dr); left: -30px; animation: coin-in 2.4s var(--ease) infinite; }
.tee .cr .coin { color: var(--cr); left: 30%; animation: coin-out 2.4s var(--ease) infinite 1.2s; }
@keyframes coin-in { 0% { opacity: 0; transform: translateX(-20px); } 20% { opacity: 1; } 60%, 100% { opacity: 0; transform: translateX(90px); } }
@keyframes coin-out { 0% { opacity: 0; transform: translateX(0); } 20% { opacity: 1; } 60%, 100% { opacity: 0; transform: translateX(140px); } }

/* ---------- sort exercise ---------- */
.bins { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.bins.book { gap: 0; border-top: 2px solid var(--ink); background: var(--card); border-radius: 0 0 18px 18px; box-shadow: var(--shadow); }
.bin {
  min-height: 150px; padding: 14px; border-radius: 18px;
  border: 2px dashed var(--line); background: color-mix(in srgb, var(--card) 60%, transparent);
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--spring);
  display: flex; flex-direction: column; text-align: left; cursor: default;
}
.bins.book .bin { border: 0; border-radius: 0; background: none; min-height: 170px; }
.bins.book .bin + .bin { border-left: 1px solid var(--line); }
.bins.book .bin:nth-child(3) { border-left: 2px solid var(--ink); }
.bin .bin-label { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; overflow-wrap: break-word; hyphens: auto; }
.bin .bin-hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.bin.dr .bin-label { color: var(--dr); } .bin.cr .bin-label { color: var(--cr); }
.bin.over, .bin.armed:hover { border-color: var(--ink); background: var(--soft); transform: scale(1.02); }
.bins.book .bin.over, .bins.book .bin.armed:hover { background: var(--soft); transform: none; }
.bin.armed { cursor: pointer; border-color: color-mix(in srgb, var(--ink) 40%, transparent); }
.bin.flash-good { animation: flash-good 0.6s var(--ease); }
@keyframes flash-good { 30% { background: var(--good-soft); border-color: var(--good); } }
.bin ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bin li {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
  font-size: 0.82rem; padding: 6px 8px; border-radius: 8px; background: var(--good-soft);
  animation: pop 0.45s var(--spring) both;
}
.bin li .amt { font-weight: 600; white-space: nowrap; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }

.deck { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 80px; }
.card {
  position: relative; touch-action: none; user-select: none; -webkit-user-select: none;
  display: block;
  width: min(100%, 220px); padding: 14px 16px; border-radius: 16px;
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  cursor: grab; text-align: left; line-height: 1.35;
  transition: transform 0.35s var(--spring), box-shadow 0.2s, border-color 0.2s, opacity 0.3s;
}
.card .amt { font-weight: 700; white-space: nowrap; }
.card:hover { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.card.selected { border-color: var(--ink); box-shadow: var(--lift); transform: translateY(-4px); }
.card.dragging { cursor: grabbing; z-index: 50; box-shadow: var(--lift); transition: box-shadow 0.2s; }
.card.shake { animation: shake 0.45s; border-color: var(--bad); }
@keyframes shake { 20% { translate: -8px 0; } 40% { translate: 7px 0; } 60% { translate: -5px 0; } 80% { translate: 3px 0; } }
.card.gone { opacity: 0; pointer-events: none; }

.hintbar {
  min-height: 52px; margin-top: 16px; padding: 12px 16px; border-radius: 14px;
  font-size: 0.92rem; background: transparent; color: var(--muted); text-align: center;
  transition: background 0.25s, color 0.25s;
}
.hintbar.bad { background: var(--bad-soft); color: var(--ink); }
.hintbar.good { background: var(--good-soft); color: var(--ink); }

/* ---------- balance exercise ---------- */
.ledger { background: var(--card); border-radius: 0 0 18px 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.ledger-title { text-align: center; font-weight: 700; padding: 10px 0 6px; }
.ledger-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--ink); }
.side { padding: 10px 14px 14px; display: flex; flex-direction: column; border: 0; background: none; text-align: left; border-radius: 0; }
.side + .side { border-left: 2px solid var(--ink); }
.side h4 { margin: 0 0 6px; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.side.dr h4 { color: var(--dr); } .side.cr h4 { color: var(--cr); }
.side .row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: 0.9rem; border-bottom: 1px solid var(--soft); }
.side .row.new { animation: pop 0.45s var(--spring) both; font-weight: 600; color: var(--accent); }
.side .row.bd { border-bottom: 0; color: var(--accent); font-weight: 600; animation: pop 0.45s var(--spring) both; }
.side .spacer { flex: 1; }
.side .total { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 0; border-top: 1.5px solid var(--ink); border-bottom: 4px double var(--ink); font-weight: 700; }
.side .total input { width: 7.5em; text-align: right; }
.side.pickable { cursor: pointer; transition: background 0.2s; }
.side.pickable:hover { background: var(--soft); }
.side.picked-bad { animation: flash-bad 0.6s; }
@keyframes flash-bad { 30% { background: var(--bad-soft); } }
.side.picked-good { background: var(--good-soft); }
.num-input {
  font: 600 1.05rem var(--mono); padding: 8px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.num-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.num-input.bad { border-color: var(--bad); animation: shake 0.45s; }
.num-input.good { border-color: var(--good); background: var(--good-soft); }
.step-q { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }
.step-q .q { width: 100%; text-align: center; font-weight: 600; margin: 4px 0 6px; }

/* ---------- bottom sheet ---------- */
.ailp-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  background: var(--card); box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
  border-radius: 22px 22px 0 0;
  transform: translateY(110%); transition: transform 0.4s var(--spring);
}
.ailp-sheet.open { transform: none; }
.ailp-sheet[hidden] { display: block; visibility: hidden; }
.ailp-sheet.open[hidden] { visibility: visible; }
.ailp-sheet-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 16px; align-items: center; }
.ailp-sheet-text { flex: 1; }
.ailp-sheet-text strong { font-size: 1.15rem; }
.ailp-sheet-text p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.ailp-sheet.good { background: var(--good-soft); }
.ailp-sheet.good strong { color: var(--good); }
.ailp-sheet.bad { background: var(--bad-soft); }
.ailp-sheet.bad strong { color: var(--bad); }

/* ---------- level complete ---------- */
.done-wrap { text-align: center; padding-top: 30px; }
.done-badge {
  width: 110px; height: 110px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--good); color: #fff;
  animation: badge 0.7s var(--spring) both;
}
@keyframes badge { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } }
.done-badge svg { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.5s 0.35s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0; }
.stat { background: var(--card); border-radius: 16px; padding: 14px 8px; box-shadow: var(--shadow); }
.stat b { display: block; font: 700 1.4rem var(--mono); }
.stat span { font-size: 0.8rem; color: var(--muted); }
.tricky { color: var(--muted); font-size: 0.92rem; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- phones ---------- */
@media (max-width: 600px) {
  body.ailp { font-size: 16px; }
  .ailp-top { padding: 10px 14px; gap: 10px; }
  .ailp-brand .brand-name { display: none; }
  .ailp-toplink { padding: 6px 4px; }
  .ailp-app { padding: 6px 16px 170px; }
  .bins { gap: 8px; }
  .bins.four { --cols: 2 !important; }
  .bins.many { --cols: 3 !important; }
  .bins.many .bin { min-height: 92px; padding: 8px; }
  .bins.many .bin .bin-label { font-size: 0.66rem; letter-spacing: 0.04em; }
  .bins.book.four .bin:nth-child(3) { border-left: 0; }
  .bins.book.four .bin:nth-child(n+3) { border-top: 2px solid var(--ink); }
  .bin { min-height: 120px; padding: 10px; }
  .card { width: calc(50% - 6px); padding: 12px; font-size: 0.92rem; }
  .ailp-sheet-inner { flex-direction: column; align-items: stretch; }
  .ailp-sheet .ailp-btn { width: 100%; }
  .stats { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* balance: "Add up" inputs and small helper text */
.side .sum { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.side .sum label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side .sum input { width: 7.5em; text-align: right; }
.hint-small { width: 100%; text-align: center; font-size: 0.85rem; color: var(--muted); }

/* ---------- path: chapters + overall progress ---------- */
.path-progress { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 18px; font-size: 0.85rem; color: var(--muted); }
.pp-bar { width: 160px; height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.pp-bar span { display: block; height: 100%; background: var(--good); border-radius: inherit; }
.path li.chapter {
  position: relative; z-index: 1; margin: 26px 0 14px; padding: 8px 0 8px 84px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
}
.path li.chapter:first-child { margin-top: 0; }
.path li.chapter span { display: block; font: 600 0.7rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.mono-list { font-family: var(--mono); font-size: 0.9rem; line-height: 1.7; margin: 0; }
.tee .mono-list { padding-top: 2px; }

/* ---------- sort extras ---------- */
.card.half { border-style: dashed; border-color: var(--accent); }
.card.half::after {
  content: attr(data-badge); position: absolute; top: -10px; right: 10px;
  font: 600 0.68rem var(--mono); padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #fff;
}
.book-tag { display: block; font: 600 0.68rem var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }

/* T-accounts (posting day books) */
.taccts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.tacct { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 10px 8px; }
.tacct-name { text-align: center; font-weight: 700; font-size: 0.92rem; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.tacct-sides { display: grid; grid-template-columns: 1fr 1fr; }
.tacct .bin { min-height: 86px; border: 0; border-radius: 8px; padding: 8px; background: none; }
.tacct .bin + .bin { border-left: 2px solid var(--ink); border-radius: 0 8px 8px 0; }
.tacct .bin.over, .tacct .bin.armed:hover { background: var(--soft); transform: none; }
.tacct .bin li { font-size: 0.75rem; padding: 4px 6px; }

/* ---------- calc ---------- */
.calc-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; overflow-x: auto; }
.calc-rows { display: flex; flex-direction: column; gap: 12px; }
.calc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.calc-row > span { font-weight: 500; }
.calc-row .num-input { width: 9em; text-align: right; }
.calc-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.calc-table th, .calc-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--soft); }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table.book td:nth-child(2), .calc-table.book th:nth-child(2) { text-align: left; }
.calc-table thead th { font: 600 0.72rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--ink); }
.calc-table tfoot th, .calc-table tfoot td { border-top: 1.5px solid var(--ink); border-bottom: 4px double var(--ink); font-weight: 700; }
.calc-table td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.calc-table .num-input { width: 6.5em; text-align: right; padding: 6px 8px; font-size: 0.95rem; }
.num-input.need, .choice.need { border-color: var(--accent); border-style: dashed; }
.choice { display: inline-flex; gap: 6px; flex-wrap: wrap; padding: 3px; border-radius: 12px; border: 1.5px solid transparent; }
.choice button {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; font-weight: 600; font-size: 0.92rem; transition: background 0.15s, border-color 0.15s, transform 0.15s var(--spring);
}
.choice button:hover { border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.choice button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); transform: scale(1.03); }
.choice.good button.on, .choice button.good-pick { background: var(--good); border-color: var(--good); color: #fff; }
.choice.bad { animation: shake 0.45s; border-color: var(--bad); }
.choice button.bad-pick { animation: shake 0.45s; border-color: var(--bad); background: var(--bad-soft); }
.choice.wide { display: flex; flex-direction: column; width: 100%; max-width: 460px; }
.choice.wide button { text-align: left; padding: 12px 16px; }
.choice button:disabled { cursor: default; }

/* ---------- double entry ---------- */
.de-dots { display: flex; gap: 6px; justify-content: center; margin: -4px 0 14px; }
.de-dots i { width: 28px; height: 6px; border-radius: 99px; background: var(--soft); transition: background 0.3s; }
.de-dots i.on { background: color-mix(in srgb, var(--ink) 40%, transparent); }
.de-dots i.done { background: var(--good); }
.de { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 22px; }
.de.enter { animation: enter 0.4s var(--ease) both; }
.de-tx { font-size: 1.15rem; font-weight: 600; text-align: center; margin-bottom: 18px; line-height: 1.4; }
.de-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.slot {
  border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); padding: 12px; min-height: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.slot .slot-label { font: 700 0.72rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.slot.dr .slot-label { color: var(--dr); } .slot.cr .slot-label { color: var(--cr); }
.slot .slot-val { font-weight: 700; font-size: 1.05rem; color: var(--muted); }
.slot.filled { border-style: solid; border-color: var(--ink); }
.slot.filled .slot-val { color: var(--ink); }
.slot.pop .slot-val { animation: pop 0.4s var(--spring); }
.slot.bad { animation: shake 0.45s; border-color: var(--bad); background: var(--bad-soft); }
.slot.good { border-color: var(--good); background: var(--good-soft); cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 99px; padding: 9px 16px;
  font-weight: 600; cursor: pointer; transition: transform 0.15s var(--spring), opacity 0.2s, border-color 0.15s;
}
.chip:hover { border-color: var(--ink); transform: translateY(-2px); }
.chip.used { opacity: 0.25; pointer-events: none; }

@media (max-width: 600px) {
  .taccts { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tacct { padding: 8px 6px 6px; }
  .tacct-name { font-size: 0.8rem; }
  .tacct .bin { min-height: 70px; padding: 6px 4px; }
  .tacct .bin .bin-label { font-size: 0.65rem; }
  .tacct .bin li { font-size: 0.68rem; padding: 3px 4px; flex-direction: column; gap: 0; }
  .calc-card { padding: 12px; }
  .calc-table { font-size: 0.85rem; }
  .calc-table .num-input { width: 5.4em; font-size: 0.85rem; padding: 6px; }
  .calc-row .num-input { width: 8em; }
  .path li.chapter { padding-left: 0; text-align: center; }
  .de { padding: 16px; }
  .de-tx { font-size: 1.02rem; }
}

/* both sides keep room for the b/d line, so the totals line up */
.side .bd-slot { min-height: 36px; }

/* ---------- home: course cards ---------- */
.all-courses { display: inline-block; margin-top: 10px; text-decoration: none; }

/* ---------- charts (explore + small pictures) ---------- */
.explore { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 16px 16px 18px; margin-bottom: 16px; }
.chart { width: 100%; height: auto; display: block; }
.chart.small { max-width: 520px; margin: 0 auto 14px; }
.chart .grid { stroke: var(--soft); stroke-width: 1; }
.chart .axis { stroke: var(--ink); stroke-width: 1.5; }
.chart .tick { fill: var(--muted); font: 12px var(--mono); }
.chart .ln { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .ln.a, .legend i.a { stroke: var(--accent); background: var(--accent); }
.chart .ln.b, .legend i.b { stroke: var(--cr); background: var(--cr); }
.chart .ln.c, .legend i.c { stroke: var(--good); background: var(--good); }
.chart .ln.d, .legend i.d { stroke: var(--muted); background: var(--muted); stroke-dasharray: 6 6; }
.chart .dot { stroke: var(--card); stroke-width: 2.5; }
.chart .dot.a { fill: var(--accent); } .chart .dot.b { fill: var(--cr); } .chart .dot.c { fill: var(--good); } .chart .dot.d { fill: var(--muted); }
.chart .marker { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .hitline { stroke: var(--good); stroke-width: 3; }
.chart .pt { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .saw { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.chart .lvl { stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart .lvl.max { stroke: var(--cr); } .chart .lvl.rol { stroke: var(--accent); } .chart .lvl.min { stroke: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 0.82rem; color: var(--muted); margin: 6px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.readout { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; font-size: 0.88rem; color: var(--muted); min-height: 24px; }
.readout b { color: var(--ink); font-family: var(--mono); }
.readout .tot b { font-size: 1.05rem; }
.readout .pos b { color: var(--good); } .readout .neg b { color: var(--bad); }
.slider-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; font-weight: 600; font-size: 0.92rem; }
.slider-row b { font-family: var(--mono); min-width: 7.5em; text-align: right; }
.slider { flex: 1; accent-color: var(--ink); height: 28px; cursor: grab; }
.slider:active { cursor: grabbing; }
.follow-lead { margin-top: 22px; }

/* sort bins with a little graph (cost behaviour) and F/A bins */
.bin-graph { width: 44px; height: 30px; margin-bottom: 4px; }
.bin-graph .ax { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.bin-graph .gl { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.bin.fav .bin-label { color: var(--good); } .bin.adv .bin-label { color: var(--bad); }

/* ---------- FIFO stock layers ---------- */
.fifo { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.fifo-label { display: flex; justify-content: space-between; font: 600 0.72rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.stack { display: flex; gap: 6px; min-height: 84px; margin-bottom: 14px; }
.batch {
  flex: 1 1 0; min-width: 76px; border: 0; border-radius: 12px; padding: 10px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--ink);
  transition: flex-grow 0.45s var(--ease), transform 0.15s var(--spring), background 0.2s;
}
.batch:nth-child(2) { background: color-mix(in srgb, var(--accent) 28%, var(--card)); }
.batch:nth-child(3) { background: color-mix(in srgb, var(--accent) 40%, var(--card)); }
.batch:nth-child(4) { background: color-mix(in srgb, var(--accent) 52%, var(--card)); }
.batch:hover { transform: translateY(-2px); }
.batch .b-date { font: 600 0.7rem var(--mono); color: var(--muted); }
.batch .b-qty { font-weight: 700; }
.batch .b-price { font-family: var(--mono); font-size: 0.85rem; }
.batch.shake { animation: shake 0.45s; outline: 2px solid var(--bad); }
.batch.arrive { animation: pop 0.5s var(--spring); }
.tray { display: flex; flex-wrap: wrap; gap: 8px; min-height: 38px; }
.issued { padding: 7px 12px; border-radius: 99px; background: var(--good-soft); font: 600 0.88rem var(--mono); animation: pop 0.4s var(--spring); }
.event { text-align: center; margin: 4px 0 10px; }
.step-q .need { width: 100%; text-align: center; color: var(--muted); }
.step-q .need b { color: var(--ink); font-family: var(--mono); font-size: 1.1rem; }

@media (max-width: 600px) {
  .explore { padding: 10px 8px 14px; }
  .chart .tick { font-size: 15px; }
  .slider-row { flex-wrap: wrap; gap: 6px 10px; }
  .slider-row .slider { order: 3; flex-basis: 100%; }
  .batch { min-width: 60px; padding: 8px 4px; }
  .batch .b-qty { font-size: 0.85rem; }
}

/* calc tables with a text column and choices inside cells (cash book VAT, running balances) */
.calc-table td.txt { text-align: left; white-space: normal; font-family: var(--sans); min-width: 12em; line-height: 1.35; }
.calc-table .choice { flex-wrap: nowrap; gap: 4px; padding: 2px; }
.calc-table .choice button { padding: 6px 9px; font-size: 0.8rem; }
.calc-table.rb td:nth-child(3), .calc-table.rb td:nth-child(4) { color: var(--muted); }
@media (max-width: 600px) {
  .calc-table td.txt { min-width: 9em; font-size: 0.82rem; }
  .calc-table .choice button { padding: 5px 7px; }
}
.calc-table.rb .c-mob { display: none; }
@media (max-width: 600px) {
  .calc-table.rb .c-date, .calc-table.rb .c-dr, .calc-table.rb .c-cr { display: none; }
  .calc-table.rb .c-mob { display: table-cell; white-space: nowrap; font-size: 0.8rem; }
  .calc-table.rb td.txt { min-width: 6.5em; }
  .calc-table.rb .choice { flex-direction: column; }
  .calc-table.rb .num-input { width: 5em; }
}

/* MA: timesheet (clock card), piecework rate bands, two service centres */
.calc-table.ts td.txt { min-width: 0; font-size: 0.8rem; color: var(--muted); }
.calc-table.ts th:last-child { text-align: left; }
.calc-table.ts .num-input { width: 4.6em; }
.calc-table.ts + .calc-rows, .calc-table.bands + .calc-rows { margin-top: 16px; }
.calc-table.bands { max-width: 24em; }
.calc-table.bands td:last-child, .calc-table.bands th:last-child { text-align: right; }
@media (max-width: 600px) {
  .calc-table.ts th, .calc-table.ts td { padding: 7px 3px; }
  .calc-table.ts .num-input { width: 3.9em; }
  .calc-table.ts td.txt { font-size: 0.72rem; }
  .calc-table.wide5 { font-size: 0.8rem; }
  .calc-table.wide5 th, .calc-table.wide5 td { padding: 7px 2px; }
  .calc-table.wide5 tbody th, .calc-table.wide5 tfoot th { font-size: 0.78rem; }
  .calc-table.wide5 .num-input { width: 3.9em; padding: 6px 3px; }
}

/* ---------- build a formula (PC) ---------- */
.fb-ask { font-weight: 600; font-size: 1.05rem; line-height: 1.45; margin-bottom: 14px; }
.fb-sheets { display: grid; gap: 12px; margin-bottom: 14px; }
.fb-tab { display: inline-block; font: 600 0.72rem var(--mono); letter-spacing: 0.06em; padding: 4px 10px; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--soft); }
.fb-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fb-grid { border-collapse: collapse; font: 0.85rem var(--mono); font-variant-numeric: tabular-nums; min-width: 100%; }
.fb-grid th, .fb-grid td { border: 1px solid var(--line); padding: 5px 8px; white-space: nowrap; }
.fb-grid thead th, .fb-grid tbody th { background: var(--soft); color: var(--muted); font-weight: 600; font-size: 0.72rem; text-align: center; }
.fb-grid td { background: var(--bg); text-align: left; font-family: var(--sans); }
.fb-grid td.n { text-align: right; font-family: var(--mono); }
.fb-grid td.target { outline: 2.5px solid var(--accent); outline-offset: -2px; text-align: center; font-weight: 700; color: var(--accent); }
.fb-grid td.target.good { outline-color: var(--good); color: var(--good); animation: pop 0.4s var(--spring); }
.fb-bar { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 12px; margin-bottom: 14px; background: var(--bg); }
.fb-fx { font: italic 600 0.85rem var(--mono); color: var(--muted); }
.fb-cell { font: 600 0.8rem var(--mono); color: var(--muted); border-right: 1px solid var(--line); padding-right: 8px; }
.fb-formula { flex: 1; font: 600 1rem var(--mono); word-break: break-all; min-height: 1.4em; }
.fb-formula.bad { animation: shake 0.45s; color: var(--bad); }
.fb-back { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 1rem; }
.fb-back:hover { border-color: var(--ink); }
.fb-chips .chip { font-family: var(--mono); font-size: 0.9rem; padding: 8px 13px; }
@media (max-width: 600px) {
  .fb-chips .chip { padding: 8px 10px; font-size: 0.82rem; }
  .fb-grid th, .fb-grid td { padding: 4px 6px; }
}

/* ---------- contract timelines (Law) ---------- */
.tl { list-style: none; margin: 0 0 16px; padding: 0 0 0 4px; }
.tl li { position: relative; padding: 0 0 14px 26px; border-left: 2px solid var(--line); margin-left: 6px; line-height: 1.45; }
.tl li:last-child { border-left-color: transparent; padding-bottom: 4px; }
.tl li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2.5px solid var(--ink); }
.tl .when { display: block; font: 600 0.72rem var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.scenario { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.scenario:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.scenario h3 { font-size: 1rem; margin: 0 0 10px; }
.q-row { display: grid; gap: 8px; margin: 10px 0; }
.q-row > span { font-weight: 600; font-size: 0.95rem; }

/* ---------- tax bands (Tax) ---------- */
.bandbar { display: flex; height: 30px; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--line); margin: 4px 0 6px; background: var(--soft); }
.bandbar .band { position: relative; min-width: 0; border-right: 2px solid var(--card); }
.bandbar .band:last-child { border-right: none; }
.bandbar .fill { position: absolute; left: 0; top: 0; bottom: 0; animation: grow 0.9s var(--ease) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.b0 { background: #8a8f98; } .b1 { background: #3c8d6e; } .b2 { background: #4f7fc4; }
.b3 { background: #c98a2b; } .b4 { background: #c2593a; } .b5 { background: #8f3450; }
.bandkey { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 0.78rem; color: var(--muted); margin-bottom: 14px; }
.bandkey i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.band-range { font: 0.72rem var(--mono); color: var(--muted); }

/* ---------- path: done / in progress / checkpoints ---------- */
:root { --warn: #b7791f; --warn-soft: #fbf1df; --cp: #7c4dcc; }
/* Dark mode: chosen with the toggle in the top bar (js/theme.js); light is the default. */
:root[data-theme="dark"] { --warn: #f0b955; --warn-soft: #3a2e17; --cp: #b392f0; }
.path-progress { flex-wrap: wrap; }
.path-progress b.due { color: var(--warn); }
.path-head .resume { margin-top: 18px; max-width: 100%; white-space: normal; }
.path-head .all-done { margin-top: 16px; color: var(--good); font-weight: 600; }
.path-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 16px; font-size: 0.78rem; color: var(--muted); }
.path-key span { display: inline-flex; align-items: center; gap: 6px; }
.path-key .k { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); }
.path-key .k.done { background: var(--good); border-color: var(--good); }
.path-key .k.started { background: conic-gradient(var(--warn) 60%, var(--card) 0); border-color: var(--warn); }
.path-key .k.open { border-style: dashed; }
.path-key .k.cp { background: var(--cp); border-color: var(--cp); border-radius: 3px; transform: rotate(45deg) scale(0.85); }
/* In progress: a ring round the number showing how far the mastery bar got. */
.node.started .dot { border-color: transparent; background:
  radial-gradient(closest-side, var(--card) calc(100% - 5px), transparent calc(100% - 4px)),
  conic-gradient(var(--warn) calc(var(--p) * 1%), var(--line) 0); color: var(--ink); }
.node.current.started .dot { color: var(--ink); background:
  radial-gradient(closest-side, var(--card) calc(100% - 5px), transparent calc(100% - 4px)),
  conic-gradient(var(--warn) calc(var(--p) * 1%), var(--line) 0); }
.node.done .txt strong { color: color-mix(in srgb, var(--ink) 80%, transparent); }
.node .tag.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.node .tag.prog { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.node .tag.due { color: var(--warn); border-color: var(--warn); font-weight: 700; }
.node .tag.cp { color: var(--cp); border-color: color-mix(in srgb, var(--cp) 50%, transparent); }
/* Checkpoints: a diamond-ish badge in their own colour. */
.node.cp .dot { border-radius: 20px; transform: rotate(0); color: var(--cp); border-color: var(--cp); border-style: solid; }
.node.cp.current .dot { background: var(--cp); color: #fff; border-color: var(--cp); }
.node.cp.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.node.due .dot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.node.cp .txt strong { color: var(--cp); }
.node.cp.done .txt strong { color: inherit; }
.node.cp.final .dot { width: 72px; height: 72px; margin-left: -4px; }
/* lessons inside a checkpoint */
.from-pill { display: inline-block; margin: 0 0 12px; padding: 3px 11px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; background: color-mix(in srgb, var(--cp) 14%, transparent); color: var(--cp); }
.done-badge.retry { background: var(--cp); }
.done-badge.retry svg { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
.review-list { list-style: none; margin: 18px auto 0; padding: 0; max-width: 460px; text-align: left; }
.review-list li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.review-list .mark { font-weight: 800; width: 1.2em; text-align: center; }
.review-list li.ok .mark { color: var(--good); }
.review-list li.slip .mark { color: var(--bad); }
.review-list .rl-txt { flex: 1; font-size: 0.92rem; }
.ailp-btn.small { padding: 6px 12px; font-size: 0.82rem; border-radius: 10px; flex: none; }
.done-wrap .actions { justify-content: center; flex-wrap: wrap; }
/* Phones: the level's tag sits under its title, so long titles keep their width */
@media (max-width: 600px) {
  .node { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "dot txt" "dot tag"; column-gap: 16px; row-gap: 4px; align-items: center; }
  .node .dot { grid-area: dot; }
  .node .txt { grid-area: txt; align-self: end; }
  .node .tag { grid-area: tag; justify-self: start; align-self: start; margin-left: 0; }
  .node:not(:has(.tag)) .txt { grid-row: 1 / span 2; align-self: center; }
  .path-key { gap: 4px 12px; }
}

/* ---------- building up: steps and worked examples ---------- */
.stage-track { display: flex; align-items: center; gap: 6px; margin: 2px 0 12px; }
.stage-track span { width: 22px; height: 6px; border-radius: 99px; background: var(--line); }
.stage-track span.done { background: var(--good); }
.stage-track span.on { background: var(--accent); }
.stage-track b { margin-left: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.worked-wrap { position: relative; margin: 0 0 18px; padding: 18px 18px 8px; border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 20px; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.worked-tag { display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 99px; background: var(--accent); color: #fff; font: 700 0.7rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.worked-wrap .lead { margin-bottom: 14px; }
.calc-card.worked { box-shadow: none; }
.shown-ans { display: inline-flex; align-items: center; gap: 8px; min-width: 6em; justify-content: flex-end; padding: 8px 12px; border-radius: 12px; background: var(--good-soft); color: var(--good); font: 700 1rem var(--mono); }
.shown-ans i, .worked-steps li::before { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 0.7rem var(--sans); font-style: normal; }
.calc-table .shown-ans { min-width: 0; padding: 4px 8px; font-size: 0.9rem; }
.worked-steps { list-style: none; counter-reset: ws; margin: 16px 0 6px; padding: 0; display: grid; gap: 8px; }
.worked-steps li { counter-increment: ws; display: grid; grid-template-columns: 20px 1fr; column-gap: 10px; align-items: start; font-size: 0.93rem; line-height: 1.45; }
.worked-steps li::before { content: counter(ws); margin-top: 1px; }
.worked-steps li b { grid-column: 2; display: block; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.worked-steps li { color: var(--ink); }
.worked-steps li > span { grid-column: 2; font-family: var(--mono); font-size: 0.86rem; overflow-wrap: anywhere; }
.worked-sort { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.worked-sort li { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "card arrow bin" "why why why"; align-items: center; gap: 6px 10px; padding: 12px 14px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.worked-sort .ws-card { grid-area: card; font-weight: 600; }
.worked-sort .ws-arrow { grid-area: arrow; color: var(--muted); }
.worked-sort .ws-bin { grid-area: bin; padding: 3px 10px; border-radius: 99px; background: var(--good-soft); color: var(--good); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.worked-sort .ws-why { grid-area: why; font-size: 0.86rem; color: var(--muted); }
.concept.new-bit { border-left: 4px solid var(--accent); }
.concept.new-bit .nb-label { display: block; margin-bottom: 6px; font: 700 0.7rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.step-note { color: var(--muted); margin: 0 0 14px; }
details.stuck { margin: 18px 0 0; }
details.stuck > summary { cursor: pointer; display: inline-block; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 0.9rem; font-weight: 600; list-style: none; }
details.stuck > summary::-webkit-details-marker { display: none; }
details.stuck > summary:hover { color: var(--ink); border-color: var(--ink); }
details.stuck[open] > summary { margin-bottom: 14px; color: var(--accent); border-color: var(--accent); }
@media (max-width: 600px) {
  .worked-wrap { padding: 14px 12px 6px; }
  .shown-ans { min-width: 0; }
}
.worked-fifo td { vertical-align: top; font-size: 0.88rem; }
.worked-fifo td:nth-child(3) { font-family: var(--mono); font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 600px) { .worked-fifo { display: block; overflow-x: auto; } }
.worked-fifo th:nth-child(2), .worked-fifo td:nth-child(2) { text-align: left; }
/* FIFO: the oldest batch, pointed out after a couple of wrong taps */
.batch.hint-pulse { outline: 3px solid var(--accent); outline-offset: 2px; animation: pulse 1.4s infinite; }
/* Level results: quick tips */
.tips { max-width: 520px; margin: 14px auto 0; text-align: left; background: var(--card); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); }
.tips-label { font: 700 0.72rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.tips ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tips li { display: grid; gap: 2px; font-size: 0.92rem; line-height: 1.45; }
.tips li b { font-size: 0.95rem; }
.tips li span { color: color-mix(in srgb, var(--ink) 82%, transparent); }
.done-badge.retry { background: var(--warn, #b7791f); }

/* ---------- the front page: subjects as folders on a desktop ---------- */
.ailp-app:has(.home) { max-width: 1060px; }
.home { padding-top: 24px; }
.home-kicker { font: 600 0.72rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.home-title h1 { margin: 10px 0 0; font-size: clamp(2.2rem, 5.5vw, 3.1rem); letter-spacing: -0.03em; line-height: 1.05; }
/* The double rule under a final total */
.home-title h1::after { content: ""; display: block; width: 88px; height: 5px; margin: 18px 0 16px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.home-title p { margin: 0; max-width: 36em; color: var(--muted); line-height: 1.55; }

/* Each subject's colour. A folder is three layers: the back (with its tab), a sheet of ruled paper, and the front. */
.folder.fa { --c: #2f7a63; } .folder.ma { --c: #34609f; } .folder.pc { --c: #6c49a0; } .folder.tax { --c: #a9562a; } .folder.law { --c: #8f3450; }
.folder {
  --f-back: color-mix(in srgb, var(--c) 30%, #fff);
  --f-front: color-mix(in srgb, var(--c) 13%, #fff);
  --f-edge: color-mix(in srgb, var(--c) 38%, #fff);
  --f-ink: color-mix(in srgb, var(--c) 80%, #000);
  --paper: #fffdf8;
  --rule: rgba(47, 111, 237, 0.16);
}
.folder.resume { --c: #b8892d; --f-back: #e6cd8c; --f-front: #f6e7bd; --f-edge: #d9b866; --f-ink: #6d4f12; }
:root[data-theme="dark"] .folder.fa { --c: #5cc3a3; } :root[data-theme="dark"] .folder.ma { --c: #79a3e8; } :root[data-theme="dark"] .folder.pc { --c: #b595e3; }
:root[data-theme="dark"] .folder.tax { --c: #e5935f; } :root[data-theme="dark"] .folder.law { --c: #e5809e; }
:root[data-theme="dark"] .folder {
  --f-back: color-mix(in srgb, var(--c) 34%, #1b1b1f);
  --f-front: color-mix(in srgb, var(--c) 17%, #1b1b1f);
  --f-edge: color-mix(in srgb, var(--c) 45%, #1b1b1f);
  --f-ink: color-mix(in srgb, var(--c) 75%, #fff);
  --paper: #e9e5da;
  --rule: rgba(47, 111, 237, 0.22);
}
:root[data-theme="dark"] .folder.resume { --c: #d9b05a; --f-back: #5c4a22; --f-front: #3b3020; --f-edge: #7a6230; --f-ink: #f1d99a; }

.desktop { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 52px 24px; margin-top: 64px; } /* room for the sheets to slide out */
.folder {
  position: relative; display: flex; flex-direction: column; padding-top: 52px;
  border: 0; background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
/* The back of the folder, with its tab */
.folder::before { content: ""; position: absolute; z-index: 0; top: 26px; left: 0; right: 0; bottom: 0; background: var(--f-back); border-radius: 0 14px 14px 14px; }
.folder-tab {
  position: absolute; z-index: 0; top: 0; left: 0; height: 30px; min-width: 52%; max-width: 75%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px 4px;
  background: var(--f-back); border-radius: 10px 16px 0 0; color: var(--f-ink); font: 600 0.72rem var(--mono); letter-spacing: 0.06em;
}
.folder-tab b { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
/* Sheets of ruled paper inside, each titled with a chapter. They peek out of the top, and on hover
   (or keyboard focus) slide up out of the folder, fanned and staggered so every title shows. */
.folder-papers { position: absolute; z-index: 1; top: 33px; left: 0; right: 0; height: 120px; pointer-events: none; }
.sheet {
  position: absolute; top: 0; left: 14px; right: 14px; height: 120px; border-radius: 4px 4px 0 0;
  background:
    linear-gradient(to right, transparent 26px, rgba(214, 69, 65, 0.28) 26px 27px, transparent 27px),
    linear-gradient(to bottom, var(--paper) 0 24px, transparent 24px),
    repeating-linear-gradient(to bottom, var(--paper) 0 6px, var(--rule) 6px 7px);
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  transform-origin: 50% 100%;
  transition: transform 0.45s var(--spring);
}
.sheet.s1 { left: 22px; right: 10px; transform: rotate(0.9deg); }
.sheet.s2 { left: 10px; right: 20px; transform: rotate(-1.1deg); }
.sheet.s3 { left: 16px; right: 16px; transform: rotate(-0.3deg); }
.sheet-title {
  display: block; padding: 5px 10px 0 34px; font-size: 0.74rem; font-weight: 700; color: #2b2b30;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity 0.2s;
}
@media (hover: hover) {
  .folder:hover { z-index: 5; }
  .folder:hover .sheet.s1, .folder:focus-visible .sheet.s1 { transform: translate(6px, -76px) rotate(3deg); transition-delay: 0s; }
  .folder:hover .sheet.s2, .folder:focus-visible .sheet.s2 { transform: translate(-4px, -52px) rotate(-2.5deg); transition-delay: 0.05s; }
  .folder:hover .sheet.s3, .folder:focus-visible .sheet.s3 { transform: translate(2px, -28px) rotate(0.8deg); transition-delay: 0.1s; }
  .folder:hover .sheet-title, .folder:focus-visible .sheet-title { opacity: 1; transition-delay: 0.12s; }
}
.folder:focus-visible { z-index: 5; }
/* The front */
.folder-body {
  position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; gap: 3px; min-height: 178px;
  padding: 20px 20px 18px; background: var(--f-front); border-top: 1.5px solid var(--f-edge); border-radius: 4px 14px 14px 14px;
  box-shadow: 0 12px 26px -16px rgba(20, 20, 30, 0.45); transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.folder:hover .folder-body, .folder:focus-visible .folder-body { box-shadow: 0 18px 30px -16px rgba(20, 20, 30, 0.55); }
.folder:focus-visible { outline: none; }
.folder:focus-visible .folder-body { outline: 3px solid var(--accent); outline-offset: 2px; }
.folder strong { font-size: 1.2rem; letter-spacing: -0.015em; line-height: 1.25; }
.f-label { font: 600 0.68rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--f-ink); }
.f-course { font-size: 0.9rem; color: color-mix(in srgb, var(--ink) 80%, transparent); }
.f-chapters { margin-top: 6px; font-size: 0.8rem; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.f-foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 12px; }
.f-bar { flex: 1; height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--c) 18%, transparent); overflow: hidden; }
.f-bar span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.f-num { font: 0.82rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-num b { color: var(--ink); }
.f-due { margin-top: 6px; font-size: 0.78rem; font-weight: 700; color: var(--warn); }
.f-open { margin-top: auto; padding-top: 14px; font-weight: 700; color: var(--f-ink); }

/* The total, ruled like the foot of a trial balance */
.home-total {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 18px; align-items: baseline; margin-top: 34px; padding: 10px 4px;
  border-top: 1px solid var(--ink); border-bottom: 4px double var(--ink); font-variant-numeric: tabular-nums; font-size: 0.92rem; color: var(--muted);
}
.home-total > span:first-child { font: 700 0.72rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.home-total b, .home-total .ht-pct { color: var(--ink); font-weight: 700; }
.home-foot { margin: 16px 0 0; color: var(--muted); font-size: 0.85rem; }
.home-foot a { color: var(--ink); }

@media (max-width: 860px) {
  .desktop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .home { padding-top: 10px; }
  .desktop { grid-template-columns: 1fr; gap: 22px; margin-top: 26px; }
  .folder-body { min-height: 0; }
  .f-chapters { display: none; }
  .home-total { grid-template-columns: auto 1fr auto; }
  .home-total > span:nth-child(3) { display: none; }
}

/* ---------- light / dark toggle (js/theme.js) ---------- */
.theme-btn { width: 38px; height: 38px; border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.theme-btn:hover { background: var(--soft); color: var(--ink); }
.theme-btn .sun, :root[data-theme="dark"] .theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- search (js/search.js) ---------- */
.ailp-search { position: relative; flex: none; width: 270px; }
.ailp-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ailp-search input {
  width: 100%; padding: 8px 34px 8px 34px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 0.92rem;
}
.ailp-search input::placeholder { color: var(--muted); }
.ailp-search input:focus { outline: none; border-color: var(--ink); }
.ailp-search input::-webkit-search-cancel-button { display: none; }
.ailp-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; font: 0.72rem var(--mono); color: var(--muted); pointer-events: none; }
.ailp-search input:focus ~ kbd { display: none; }
.search-toggle { display: none; width: 38px; height: 38px; border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; place-items: center; }
.search-toggle:hover { background: var(--soft); color: var(--ink); }
.search-pop {
  position: fixed; z-index: 60; top: 64px; left: 50%; transform: translateX(-50%); width: min(640px, calc(100vw - 24px));
  max-height: min(70vh, 560px); overflow-y: auto; padding: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--lift);
}
.sp-note, .sp-empty { padding: 10px 12px; font-size: 0.88rem; color: var(--muted); }
.sp-item {
  display: grid; gap: 2px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.sp-item.on, .sp-item:hover { background: var(--soft); }
.sp-item.fa { --c: #2f7a63; } .sp-item.ma { --c: #34609f; } .sp-item.pc { --c: #6c49a0; } .sp-item.tax { --c: #a9562a; } .sp-item.law { --c: #8f3450; }
:root[data-theme="dark"] .sp-item.fa { --c: #5cc3a3; } :root[data-theme="dark"] .sp-item.ma { --c: #79a3e8; } :root[data-theme="dark"] .sp-item.pc { --c: #b595e3; }
:root[data-theme="dark"] .sp-item.tax { --c: #e5935f; } :root[data-theme="dark"] .sp-item.law { --c: #e5809e; }
.sp-where { font: 600 0.7rem var(--mono); letter-spacing: 0.04em; color: var(--c); }
.sp-xl { font-style: normal; margin-left: 4px; padding: 0 6px; border: 1px solid currentColor; border-radius: 99px; }
.sp-title { font-weight: 700; font-size: 0.98rem; }
.sp-sub { font-size: 0.86rem; color: var(--muted); }
.sp-snip { font-size: 0.82rem; color: color-mix(in srgb, var(--ink) 75%, transparent); line-height: 1.45; }
.search-pop mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
/* Narrow screens: a search button; tapping it opens the bar over the top of the page */
@media (max-width: 760px) {
  .ailp-search { display: none; }
  .search-toggle { display: grid; }
  body.searching .ailp-search { display: block; position: absolute; z-index: 30; left: 12px; right: 12px; top: 50%; transform: translateY(-50%); width: auto; }
  body.searching .ailp-search input { padding-top: 10px; padding-bottom: 10px; box-shadow: var(--shadow); }
  .search-pop { top: 60px; }
}
@media (hover: none) { .ailp-search kbd { display: none; } }

/* ---------- the Workshop (workshop.html, js/workshop.js) ---------- */
.ws-promo { display: inline-flex; gap: 10px; align-items: center; margin-top: 16px; padding: 8px 14px; border: 1.5px dashed var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 0.9rem; }
.ws-promo b { font: 700 0.68rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.ws-promo:hover { border-color: var(--ink); }
.ailp-app.ws-app { max-width: 1120px; }
.ws-head { padding-top: 24px; }
.ws-head h1 { margin: 8px 0 10px; font-size: clamp(1.9rem, 5vw, 2.6rem); letter-spacing: -0.03em; }
.ws-head p { color: var(--muted); max-width: 40em; margin: 0; }
.ws-list { display: grid; gap: 12px; margin-top: 26px; }
.ws-card { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; padding: 16px 18px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.ws-card:hover { box-shadow: var(--lift); }
.ws-n { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); font: 700 1rem var(--mono); }
.ws-card strong { display: block; font-size: 1.05rem; }
.ws-level { font: 600 0.68rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.ws-blurb { display: block; color: var(--muted); font-size: 0.9rem; }
.ws-title h2 { margin: 6px 0 16px; }
.ws-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.ws-pile { display: grid; gap: 8px; }
.ws-doc { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); opacity: 0.6; font-size: 0.88rem; }
.ws-doc.on { opacity: 1; border: 2px solid var(--ink); background: #fffdf6; box-shadow: var(--shadow); }
:root[data-theme="dark"] .ws-doc.on { background: var(--card); }
.ws-doc.done { opacity: 0.45; }
.ws-icon { font-size: 1.3rem; }
.ws-kind { display: block; font: 600 0.7rem var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ws-body { display: block; margin-top: 4px; line-height: 1.45; }
.ws-posted { color: var(--good); font-weight: 600; }
.ws-form { margin-top: 14px; padding: 16px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.ws-form-title { font-weight: 700; margin-bottom: 10px; }
.ws-row { display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 0.88rem; color: var(--muted); }
.ws-row .choice { display: flex; gap: 6px; flex-wrap: wrap; }
.ws-row .choice button { flex: 1; }
.ws-row input { width: 100%; }
.ws-form .ws-post { width: 100%; margin-top: 4px; }
.ws-note { font-size: 0.88rem; color: var(--muted); margin: 0; }
.ws-bookwrap { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; overflow-x: auto; }
.ws-book-title { font-weight: 700; margin-bottom: 8px; }
.ws-cb { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 640px; }
.ws-cb th { font: 600 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 5px 6px; border-bottom: 1px solid var(--ink); text-align: left; }
.ws-cb th.dr { color: var(--dr); } .ws-cb th.cr { color: var(--cr); border-left: 2px solid var(--ink); }
.ws-cb td { padding: 6px; border-bottom: 1px solid var(--line); height: 32px; }
.ws-cb td.n { text-align: right; font-family: var(--mono); }
.ws-cb td.split, .ws-cb tr:nth-child(2) th:nth-child(5) { border-left: 2px solid var(--ink); }
.ws-cb .ws-bal { width: 6.2em; padding: 4px 6px; font-size: 0.85rem; text-align: right; }
.ws-cb tr.ws-tot td { border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); font-weight: 700; }
.ws-balance { margin-top: 12px; }
.ws-hint { margin-top: 16px; }
.ws-done .actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.ws-done .actions a { text-decoration: none; }
@media (max-width: 860px) { .ws-grid { grid-template-columns: 1fr; } }
/* Workshop walkthrough: a mini animated version of the screen */
.wt-stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "doc book" "form book"; gap: 14px; padding: 18px; background: var(--soft); border-radius: 18px; overflow: hidden; min-height: 320px; }
.wt-doc { grid-area: doc; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 12px; background: #fffdf6; color: #222; border: 2px solid #222; border-radius: 12px; font-size: 0.88rem; opacity: 0; transform: translateY(14px); transition: all 0.5s var(--ease); }
.wt-doc.show { opacity: 1; transform: none; }
.wt-amt { transition: background 0.3s; border-radius: 4px; padding: 0 2px; }
.wt-amt.glow { background: #ffe58a; }
.wt-form { grid-area: form; display: grid; gap: 8px; padding: 12px; background: var(--card); border-radius: 12px; font-size: 0.82rem; }
.wt-btns { display: flex; gap: 6px; }
.wt-btn { flex: 1; text-align: center; padding: 7px; border: 1.5px solid var(--line); border-radius: 9px; transition: all 0.2s; }
.wt-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.wt-field { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; }
.wt-field i { font-style: normal; color: var(--muted); }
.wt-field span { min-height: 30px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 8px; font-family: var(--mono); background: var(--bg); }
.wt-book { grid-area: book; padding: 12px; background: var(--card); border-radius: 12px; font-size: 0.78rem; font-family: var(--mono); }
.wt-bh, .wt-bl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wt-bh { padding-bottom: 6px; border-bottom: 1px solid var(--ink); font-weight: 700; }
.wt-bh span:last-child, .wt-bl span:last-child { border-left: 2px solid var(--ink); padding-left: 8px; }
.wt-bl { padding: 6px 0; border-bottom: 1px solid var(--line); }
.wt-line, .wt-contra, .wt-od, .wt-bal .wt-bl { opacity: 0; transform: translateX(-30px); transition: all 0.6s var(--spring); }
.wt-line.show, .wt-contra.show, .wt-od.show, .wt-bal.show .b1, .wt-bal.show2 .b2, .wt-bal.show3 .b3 { opacity: 1; transform: none; background: color-mix(in srgb, var(--good) 10%, transparent); }
.wt-bl.tot { border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); font-weight: 700; }
.wt-cursor { position: absolute; left: 0; top: 0; width: 22px; height: 22px; margin: -4px 0 0 -4px; border-radius: 50%; background: rgba(47, 111, 237, 0.35); border: 2px solid var(--accent); opacity: 0; transition: transform 0.65s var(--ease), opacity 0.2s; pointer-events: none; z-index: 3; }
.wt-cursor.on { opacity: 1; }
.wt-cursor.press { box-shadow: 0 0 0 10px rgba(47, 111, 237, 0.2); }
.wt-caption { margin-top: 16px; padding: 18px 20px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.wt-count { font: 600 0.7rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.wt-caption p { margin: 6px 0 14px; font-size: 1rem; line-height: 1.55; }
.wt-actions { display: flex; gap: 10px; }
.wt-skip { margin-top: 10px; }
@media (max-width: 700px) { .wt-stage { grid-template-columns: 1fr; grid-template-areas: "doc" "form" "book"; } }
/* Workshop: per-part feedback */
.ws-row.right .choice button.on, .ws-row.right input { border-color: var(--good); }
.ws-row.right > span::after { content: " ✓"; color: var(--good); font-weight: 700; }
.ws-row.shown > span::after { content: " ●"; color: var(--warn); }
.ws-hint-f { font-size: 0.82rem; line-height: 1.45; margin: -4px 0 8px 84px; }
.ws-hint-f:empty { display: none; }
.ws-hint-f.good { color: var(--good); }
.ws-hint-f.bad { color: var(--bad); }
.ws-hint-f.shown { color: var(--warn); }
.ws-hint-f i { color: var(--muted); }
.choice.bad, .ws-form input.bad { animation: shake 0.35s; }
.ws-form .choice.bad button.on { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.ws-result { margin-top: 10px; font-size: 0.9rem; font-weight: 600; }
.ws-result.good { color: var(--good); } .ws-result.bad { color: var(--bad); } .ws-result.shown { color: var(--warn); }
.ws-form .ws-next { width: 100%; margin-top: 10px; }
.ws-cb tr.just td { animation: just 1.6s ease; }
@keyframes just { 0%, 40% { background: color-mix(in srgb, var(--good) 22%, transparent); } }
@media (max-width: 600px) { .ws-hint-f { margin-left: 0; } }
.ws-select { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: 0.9rem; }
.ws-select:focus { outline: none; border-color: var(--ink); }
.ws-select.bad { border-color: var(--bad); background: var(--bad-soft); }
.ws-select.good { border-color: var(--good); }
/* Live marking as you type (Workshop) */
.ws-form input.live-good, .ws-cb .ws-bal.good { border-color: var(--good); box-shadow: 0 0 0 2px color-mix(in srgb, var(--good) 25%, transparent); }
.ws-form input.live-bad, .ws-cb .ws-bal.bad { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 22%, transparent); }

/* ---------- the front door (index.html) and Greig's sign-in (greig/index.php) ---------- */
.ailp-app.chooser { max-width: 900px; padding-top: 30px; }
.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 40px; }
.choose-card .folder-body { min-height: 200px; }
.choose-card .folder-tab { min-width: 60%; }
@media (max-width: 640px) { .choose { grid-template-columns: 1fr; } }
button.ailp-toplink { border: 0; background: none; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.next-ass { margin-top: 16px; padding: 10px 14px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; font-size: 0.9rem; max-width: 40em; }
.next-ass b { display: block; font: 700 0.68rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--warn); }
.next-ass span { font-weight: 700; }
.next-ass i { display: block; font-style: normal; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.ws-promo { margin-left: 0; }
.home-title .next-ass + .ws-promo { margin-top: 10px; }
.ailp-app.gate { max-width: 420px; padding-top: 70px; }
.gate-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.gate-card h1 { margin: 6px 0 8px; }
.gate-card p { color: var(--muted); margin: 0 0 18px; }
.gate-card input { width: 100%; padding: 11px 14px; margin-bottom: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.gate-err { color: var(--bad) !important; margin: 10px 0 0 !important; min-height: 1em; }
/* HNC 2026 accounts: sign in / create an account, the name in the top bar, the owner's Accounts page */
.gate-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 16px; border-radius: 12px; background: var(--bg); border: 1.5px solid var(--line); }
.gate-tabs button { padding: 8px 6px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.gate-tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.gate-label { display: block; margin: 0 0 4px; font-size: .88rem; font-weight: 600; }
.gate-card .gate-note { font-size: .86rem; margin: -2px 0 12px; }
.gate-hp { position: absolute !important; left: -9999px; width: 1px !important; height: 1px; opacity: 0; }
.gate-keep { display: block; margin: 2px 0 14px; font-size: .9rem; cursor: pointer; }
.gate-card .gate-keep input { width: auto; margin: 0 6px 0 0; vertical-align: -1px; }
.gate-keep span { display: block; margin: 2px 0 0 22px; color: var(--muted); font-size: .84rem; }
.acct-chip { font-size: .86rem; font-weight: 600; color: var(--muted); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .acct-chip { display: none; } }
.ailp-app.admin-page { max-width: 760px; padding-top: 28px; }
.admin-lead { color: var(--muted); }
.admin-msg { padding: 10px 14px; border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
.admin-list { display: grid; gap: 10px; margin-top: 16px; }
.admin-user { padding: 14px 16px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.admin-who { display: grid; gap: 2px; margin-bottom: 6px; }
.admin-who span { color: var(--muted); font-size: .86rem; }
.admin-user details { margin-top: 6px; }
.admin-user summary { cursor: pointer; font-size: .9rem; color: var(--accent, inherit); }
.admin-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.admin-form input[type="text"] { flex: 1 1 200px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; }

/* HNC 2026 (owner's sign-in): course paths by week */
.week-bar { position: sticky; top: 64px; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 22px auto 0; max-width: 640px; padding: 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-radius: 14px; }
.week-bar a { padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 99px; color: var(--ink); text-decoration: none; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.week-bar a:hover { border-color: var(--ink); }
.week-bar a.latest { border-color: var(--accent); color: var(--accent); }
.week-bar a.all-done { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.path .chapter.week { scroll-margin-top: 130px; }
.path .chapter.week.latest > span { color: var(--accent); }
.wk-empty { display: block; margin-top: 6px; font-style: normal; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
@media (max-width: 600px) { .week-bar { top: 56px; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; } }

/* ---------- exam practice: revision notes and mock exams ---------- */
.exam-box { margin: 18px 0 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.eb-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 10px; }
.eb-head span { color: var(--muted); font-size: .92rem; }
.eb-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.eb-btns .ailp-btn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; max-width: 100%; white-space: normal; }
.eb-btns small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.mock-clock { position: fixed; right: 14px; bottom: 14px; z-index: 50; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 .95rem/1.2 ui-monospace, Menlo, monospace; box-shadow: var(--shadow); }
.mock-clock.over { background: var(--bad); color: #fff; }
.notes { max-width: 760px; margin: 0 auto 40px; }
.notes-ch h2 { margin: 30px 0 8px; padding-bottom: 6px; border-bottom: 3px double var(--rule, var(--line)); }
.notes-ch h2 span { display: block; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.notes-lv { padding: 10px 0 14px; border-bottom: 1px solid var(--line); }
.notes-lv h3 { margin: 6px 0; }
.notes-lv h3 small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.notes-card h4 { margin: 8px 0 2px; font-size: .95rem; }
.notes-card p { margin: 4px 0; }
.notes-rules { margin: 8px 0 0; padding-left: 18px; font-size: .93rem; }
.notes-rules li { margin: 3px 0; }
.notes-xl { color: var(--muted); font-size: .9rem; }
@media print {
  .ailp-top, .back-path, .print-btn, .mock-clock, .search-wrap { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .notes-lv { break-inside: avoid; }
}
.mock-review { text-align: left; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--card); }
.mock-review summary { cursor: pointer; font-weight: 600; }
.mock-review ol { padding-left: 20px; margin: 10px 0 0; }
.mock-review li { margin: 10px 0; }
.mr-q { font-size: .88rem; color: var(--muted); }
.mr-a { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 3px 0; }
.mr-a .bad { color: var(--bad); } .mr-a .good { color: var(--good); font-weight: 600; }
.mr-how { font-size: .9rem; }
details.formula { margin: 10px 0 2px; border: 1px dashed var(--line); border-radius: 10px; padding: 6px 12px; background: var(--card); }
details.formula summary { cursor: pointer; font-weight: 600; color: var(--accent, var(--ink)); }
details.formula ul { margin: 8px 0 4px; padding-left: 18px; font-size: .93rem; }
details.formula li { margin: 4px 0; }
.calc-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* warm-ups: one box to do, the rest given */
.calc-card .given { opacity: .55; }
.calc-card .num-input.given, .calc-card .choice.given button.on { border-style: dashed; }
.calc-card .focus-box { outline: 3px solid var(--accent, #2f7a63); outline-offset: 2px; border-radius: 6px; animation: focusPulse 1.6s ease-in-out 2; }
@keyframes focusPulse { 50% { outline-color: transparent; } }
.calc-card .later { display: inline-block; min-width: 3em; color: var(--muted); }
.calc-card .later::after { content: "…"; }

/* right = green glow, wrong = amber (8 Oct) */
.num-input { transition: box-shadow .25s, border-color .25s, background .25s; }
.num-input.good { box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 30%, transparent), 0 0 14px color-mix(in srgb, var(--good) 45%, transparent); }
.num-input.bad { background: var(--bad-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 30%, transparent); }
.choice.good button.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 30%, transparent), 0 0 14px color-mix(in srgb, var(--good) 45%, transparent); }
.choice.bad button.on { border-color: var(--bad); background: var(--bad-soft); }
.calc-card .given, .calc-card .given button { box-shadow: none !important; }
.num-input.bad.soft { animation: none; }
/* "Why it works" questions at the end of a lesson */
.why-opts { display: grid; gap: 10px; margin: 16px 0; }
.why-opt { text-align: left; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; line-height: 1.45; cursor: pointer; transition: border-color .15s, background .15s; }
.why-opt:hover:not(:disabled) { border-color: var(--accent, var(--ink)); }
.why-opt:disabled { cursor: default; }
.why-opt.right { border-color: var(--good); background: var(--good-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.why-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ass-all { margin-top: 8px; font-size: .88rem; }
.ass-all summary { cursor: pointer; color: var(--accent, var(--ink)); font-weight: 600; }
.ass-all ul { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 5px; }
.ass-all li { display: grid; grid-template-columns: 140px 1fr; gap: 10px; }
.ass-all li span { color: var(--muted); white-space: nowrap; }
.ass-all p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
@media (max-width: 520px) { .ass-all li { grid-template-columns: 1fr; gap: 0; } }
/* ---------- Greig's version: Assessments (#assessments) ---------- */
.ass-promo { display: block; margin: 10px 0 0; padding: 10px 14px; border: 1.5px solid var(--accent, var(--ink)); border-radius: 10px; color: var(--ink); text-decoration: none; background: var(--card); }
.ass-promo b { margin-right: 8px; }
.ass-promo:hover { background: var(--good-soft); }
.as-list { display: grid; gap: 12px; margin: 18px 0; }
.as-card { border: 1px solid var(--line); border-radius: 14px; background: var(--card); overflow: hidden; }
.as-card.past { opacity: .6; }
.as-card summary { display: grid; grid-template-columns: 170px 1fr 90px; gap: 14px; align-items: center; padding: 14px 16px; cursor: pointer; list-style: none; }
.as-card summary::-webkit-details-marker { display: none; }
.as-date { display: grid; gap: 2px; }
.as-date b { font-size: .95rem; }
.as-date i { font-style: normal; font-size: .8rem; color: var(--muted); }
.as-what { font-weight: 600; line-height: 1.35; }
.as-prog { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.as-prog span { display: block; height: 100%; background: var(--good); }
.as-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.as-tips { margin: 12px 0; padding-left: 18px; font-size: .92rem; }
.as-tips li { margin: 3px 0; }
.as-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 16px 0 8px; }
.as-head span { color: var(--muted); font-size: .85rem; }
.as-next { margin: 4px 0 10px; }
.as-all { color: var(--good); font-weight: 600; }
.as-group { margin: 8px 0; }
.as-gh { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.as-lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.as-lessons button { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; width: 100%; text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.as-lessons button:hover { border-color: var(--accent, var(--ink)); }
.as-lessons small { color: var(--muted); font-size: .8rem; }
.as-tick { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--line); font-size: .7rem; font-weight: 700; color: #fff; }
.as-lessons li.done .as-tick { background: var(--good); border: 0; }
.as-weak { margin: 0; padding-left: 18px; font-size: .92rem; display: grid; gap: 6px; }
.as-lab { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.as-lab li.done a { color: var(--good); }
.as-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.as-pasthead { margin: 28px 0 0; color: var(--muted); }
@media (max-width: 640px) { .as-card summary { grid-template-columns: 1fr; gap: 6px; } .as-prog { width: 100%; } }
/* A box holding a formula's result, like a cell: a small fx mark (the formula shows on hover; click in to change it) */
.num-input.fx { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10'%3E%3Ctext x='0' y='8' font-size='8' font-family='Georgia,serif' font-style='italic' fill='%232f6fed'%3Efx%3C/text%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 4px 3px; }
.hintbar code { font-family: var(--mono, ui-monospace, monospace); font-size: .92em; }
/* "Formulas work too" under number questions, and the touch-screen switch for a keyboard with = and * */
.fx-row { margin: 10px 0 0; font-size: .86rem; color: var(--muted); }
.fx-row code { font-family: var(--mono, ui-monospace, monospace); font-size: .92em; color: var(--ink); }
.fx-kbd { margin-left: 6px; padding: 3px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer; }
.fx-kbd[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
:root[data-theme="dark"] .num-input.fx { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10'%3E%3Ctext x='0' y='8' font-size='8' font-family='Georgia,serif' font-style='italic' fill='%236b9bff'%3Efx%3C/text%3E%3C/svg%3E"); }
/* Home: the row of feature cards (Today, Mistake notebook, Progress…) added by js/ailp-*.js through AILP.ext.addHomeTile */
.home-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 22px 0 4px; }
.home-tools:empty { display: none; }
@media (max-width: 520px) { .home-tools { grid-template-columns: 1fr; gap: 10px; } }
/* Hint button beside Check (every question but mock exams) */
.step-q .hint-btn { margin-left: 8px; }
.step-q.sort-hint { margin-top: 12px; }
.bin.hint-pulse { outline: 3px solid var(--accent); outline-offset: 2px; animation: pulse 1.4s infinite; }
