/* LSSGB Exam Trainer. Colours validated with the dataviz validate_palette.js script (see README).
   Phase colours (--ph-*): identity of the five DMAIC phases, always shown with the phase name or its letter.
   Light set passes the validator on all pairs (CVD dE >= 8.1, normal dE >= 16.2); dark set passes in DMAIC
   order (CVD >= 13.3, normal >= 15.1). None is used for right/wrong (--ok/--bad) or for interaction (--accent). */

/* ---------- tokens ---------- */
:root {
  --bg: #f5f6fb;  --panel: #ffffff;  --raised: #eef1f7;  --line: #dde2ea;
  --text: #1a1f2b;  --muted: #586377;
  --accent: #3a47c2;        /* links, marks, focus ring: the one interactive colour */
  --btn: #3a47c2;  --btn-ink: #ffffff;
  --accent-soft: #e4e7fa;  --accent-mid: #8591e3;
  --ok: #0a8560;  --ok-ink: #0a6b4d;  --ok-bg: #e6f4ee;
  --bad: #c9373f;  --bad-ink: #a82a32;  --bad-bg: #fbeaea;
  --flag: #9a5c00;  --danger: #b8323a;
  --shadow: 0 1px 2px rgba(20, 28, 48, .06), 0 2px 8px rgba(20, 28, 48, .05);
  --radius: 12px;
  --ph-define: #248fcc;  --ph-measure: #b87800;  --ph-analyze: #8b5cf6;  --ph-improve: #c35aa4;  --ph-control: #92400e;
  --ph-general: #6b7280;
  --cheer-bg: #fff3d6;  --cheer-ink: #7a4a00;
  --hue-violet: #6d3fd0;  --hue-violet-tint: #efe9fd;  --hue-teal: #0f766e;  --hue-teal-tint: #dcf3ef;
  --hue-amber: #8a5300;  --hue-amber-tint: #fbf0dc;  --hue-indigo: #3a47c2;  --hue-indigo-tint: #e4e7fa;
  --hue-sky: #0b6aa3;  --hue-sky-tint: #e0f0fa;  --hue-rose: #b0285f;  --hue-rose-tint: #fbe6ee;  --hue-on: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b26;  --panel: #1c2331;  --raised: #242d3e;  --line: #313c51;
    --text: #e6ebf3;  --muted: #9aa6b8;
    --accent: #8b98f7;  --btn: #4b5bd6;  --btn-ink: #ffffff;
    --accent-soft: #2a3150;  --accent-mid: #5a66c4;
    --ok: #1f9f80;  --ok-ink: #5fd3b3;  --ok-bg: #173a33;
    --bad: #e25550;  --bad-ink: #ff8a83;  --bad-bg: #41212a;
    --flag: #d39a2e;  --danger: #b8323a;
    --ph-define: #1292c0;  --ph-measure: #af8724;  --ph-analyze: #6764dd;  --ph-improve: #a5598d;  --ph-control: #ae520a;
    --ph-general: #8a93a3;
    --cheer-bg: #3d3018;  --cheer-ink: #f3c46b;
    --hue-violet: #b79cfb;  --hue-violet-tint: #2e2552;  --hue-teal: #5ccfbf;  --hue-teal-tint: #163a37;
    --hue-amber: #f0b45a;  --hue-amber-tint: #3a2d17;  --hue-indigo: #8b98f7;  --hue-indigo-tint: #2a3150;
    --hue-sky: #74c0f0;  --hue-sky-tint: #16324a;  --hue-rose: #f08bb3;  --hue-rose-tint: #41202f;  --hue-on: #151b26;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151b26;  --panel: #1c2331;  --raised: #242d3e;  --line: #313c51;
  --text: #e6ebf3;  --muted: #9aa6b8;
  --accent: #8b98f7;  --btn: #4b5bd6;  --btn-ink: #ffffff;
  --accent-soft: #2a3150;  --accent-mid: #5a66c4;
  --ok: #1f9f80;  --ok-ink: #5fd3b3;  --ok-bg: #173a33;
  --bad: #e25550;  --bad-ink: #ff8a83;  --bad-bg: #41212a;
  --flag: #d39a2e;  --danger: #b8323a;
  --ph-define: #1292c0;  --ph-measure: #af8724;  --ph-analyze: #6764dd;  --ph-improve: #a5598d;  --ph-control: #ae520a;
  --ph-general: #8a93a3;
  --cheer-bg: #3d3018;  --cheer-ink: #f3c46b;
  --hue-violet: #b79cfb;  --hue-violet-tint: #2e2552;  --hue-teal: #5ccfbf;  --hue-teal-tint: #163a37;
  --hue-amber: #f0b45a;  --hue-amber-tint: #3a2d17;  --hue-indigo: #8b98f7;  --hue-indigo-tint: #2a3150;
  --hue-sky: #74c0f0;  --hue-sky-tint: #16324a;  --hue-rose: #f08bb3;  --hue-rose-tint: #41202f;  --hue-on: #151b26;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3, .h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#main:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tnum { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 16px; }
[hidden] { display: none !important; }
/* Reading width for explanations and notes (about 70 characters): long lines tire the eye. */
.prose, .why-text, .intro { max-width: 70ch; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- frame ---------- */
.dmaic-strip { display: flex; height: 4px; }
.dmaic-strip span { flex: 1; background: var(--ph); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  max-width: 820px; margin: 0 auto; padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--btn); color: var(--btn-ink); font-size: .8rem; letter-spacing: .02em;
}
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .95rem;
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); border-radius: 8px 8px 0 0; }
main { max-width: 820px; margin: 0 auto; padding: 0 16px 48px; }
.notice {
  max-width: 788px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--raised); border-left: 4px solid var(--flag); font-size: .9rem;
}
.nav a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 720px) {
  .nav { width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); }
  .nav a { justify-content: center; padding: 8px 2px; font-size: .9rem; }
}
@media (max-width: 540px) {
  .notice { margin: 0 16px 12px; }
  /* six items do not fit one row on a phone: two rows of three, each a full touch target */
  .nav { grid-template-columns: repeat(3, 1fr); }
  .nav a[aria-current="page"] { border-radius: 8px; background: var(--accent-soft); border-bottom-color: transparent; }
  h1 { font-size: 1.35rem; }
}

/* ---------- building blocks ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.row { display: flex; align-items: center; gap: 8px 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }
.count { margin-left: auto; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.empty p { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 10px; background: var(--btn); color: var(--btn-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--raised); filter: none; }
.btn.danger { background: var(--danger); }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }

.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: .8rem; font-weight: 600; }
.chip.dim { background: var(--raised); color: var(--muted); }
.chip.flag { background: var(--raised); color: var(--flag); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .03em; }
.tag.pass { background: var(--ok-bg); color: var(--ok-ink); }
.tag.fail { background: var(--bad-bg); color: var(--bad-ink); }
.tag.bonus { background: var(--raised); color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .68rem; vertical-align: 1px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 16px; min-width: 64px; text-align: center; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }

/* progress ring and bars */
.ring-box { position: relative; width: 96px; height: 96px; flex: none; }
.ring { width: 96px; height: 96px; }
.ring-track { fill: none; stroke: var(--raised); stroke-width: 9; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.15; }
.ring-label strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: .72rem; color: var(--muted); }
.bar { display: flex; height: 8px; border-radius: 99px; background: var(--raised); overflow: hidden; margin: 6px 0 0; }
.bar-a { background: var(--accent); }
.bar-b { background: var(--accent-mid); }
.bar > span + span { box-shadow: inset 2px 0 0 var(--panel); }   /* 2px surface gap between segments */
.bar.phased .bar-a { background: var(--ph); }
.bar.phased .bar-b { background: var(--accent-mid); background: color-mix(in srgb, var(--ph) 50%, var(--panel)); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 12px 0 0; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 6px; }
.sw:first-child { margin-left: 0; }
.sw-a { background: var(--muted); }
.sw-b { background: var(--line); background: color-mix(in srgb, var(--muted) 40%, var(--panel)); }

/* ---------- phases ---------- */
.ph-define { --ph: var(--ph-define); }    .ph-measure { --ph: var(--ph-measure); }  .ph-analyze { --ph: var(--ph-analyze); }
.ph-improve { --ph: var(--ph-improve); }  .ph-control { --ph: var(--ph-control); }  .ph-general { --ph: var(--ph-general); }
/* letter badge: 19px bold letters count as large text, so the 3:1 floor applies (every phase fill is >= 3.3:1 with white) */
.ph-badge {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px;
  background: var(--ph); color: #fff; font-size: 1.2rem; font-weight: 800; line-height: 1;
}
/* small badge: decoration beside the phase name, which carries the meaning */
.ph-badge.sm { width: 24px; height: 24px; border-radius: 7px; font-size: .8rem; }
h2 .ph-badge { margin-right: 10px; vertical-align: -6px; }
.phase-card { border-top: 4px solid var(--ph); }
.phase-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--raised); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ph); }
.phase-cell { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- home ---------- */
.summary { display: flex; align-items: center; gap: 20px; }
.summary-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.streak { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.streak.on .icon { color: var(--flag); width: 18px; height: 18px; }
.welcome { padding: 22px 22px 18px; border-top: 4px solid var(--accent); }
.welcome-title { font-size: 1.35rem; line-height: 1.3; margin: 0 0 8px; max-width: 34ch; }
.welcome .prose { color: var(--muted); margin-bottom: 16px; }
.welcome .fine { margin: 14px 0 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 16px; }
.tile {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px; min-height: 84px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
@media (hover: hover) { .tile:hover { border-color: var(--accent); transform: translateY(-1px); } }
.tile-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex: none; background: var(--accent-soft); color: var(--accent); }
.tile-icon .icon { width: 22px; height: 22px; }
.tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-title { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 700; }
.tile-sub { color: var(--muted); font-size: .9rem; }
.badge { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--btn); color: var(--btn-ink); font-size: .8rem; font-variant-numeric: tabular-nums; }
.phase-rows { display: grid; gap: 14px; }
.phase-row { display: flex; align-items: center; gap: 12px; }
.phase-main { flex: 1; min-width: 0; }
.phase-row .row { flex-wrap: wrap; gap: 0 12px; }
.phase-name { font-weight: 700; color: var(--text); text-decoration: none; }
.phase-name:hover { text-decoration: underline; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: grid; grid-template-columns: 6.5rem 1fr 3.5rem auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr; gap: 8px; }
  .tile { min-height: 0; padding: 12px 14px; }
  .summary { gap: 14px; align-items: flex-start; }
  .welcome { padding: 18px 16px 14px; }
  .history li { grid-template-columns: 5.5rem 1fr 3rem auto; font-size: .9rem; }
}

/* round complete, review done, exam result: the ring grows in once */
.done-msg { font-weight: 600; margin: 0 0 8px; flex-basis: 100%; }
.summary.done .ring-box { animation: grow .45s ease-out; }
.summary.passed { border-color: var(--ok); }
@keyframes grow { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- by topic ---------- */
.phase-head h2 { margin: 0; }
.phase-head + p { margin: 4px 0 8px; }
.topic-stats { list-style: none; padding: 0; margin: 0; }
.topic-stats li { padding: 10px 0; border-top: 1px solid var(--line); }
.topic-stats .bar { margin-top: 6px; }
/* right / wrong by latest answer: validated status pair, always with the counts in words beside it */
.bar-ok { background: var(--ok); }
.bar-bad { background: var(--bad); }
.sw-ok { background: var(--ok); }
.sw-bad { background: var(--bad); }

/* ---------- question ---------- */
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.quiet-link { color: var(--muted); font-size: .9rem; white-space: nowrap; background: none; border: 0; padding: 4px 0; min-height: 44px; min-width: 44px; font-family: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.qhead + .bar { margin: 6px 0 16px; }
/* pre-line: a line break (\n) in the data (e.g. short Minitab-style output) shows as a line break */
.qtext { font-size: 1.2rem; line-height: 1.45; margin: 4px 0 18px; font-weight: 600; white-space: pre-line; max-width: 62ch; }
.why-text { white-space: pre-line; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; min-height: 52px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background-color .12s;
}
/* hover only where a pointer hovers: on touch screens it would stick to the last tapped option */
@media (hover: hover) { .opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); } }
.opt:disabled { cursor: default; opacity: 1; }
.key {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--raised); color: var(--muted); font-weight: 700; font-size: .9rem;
}
.opt-t { padding-top: 2px; }
.opt.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-picked .key { background: var(--btn); color: var(--btn-ink); }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-correct .key { background: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.is-wrong .key { background: var(--bad); color: #fff; }
.opt.is-other { color: var(--muted); }
.actions { margin-top: 16px; min-height: 44px; }
.hint { margin: 0; }
.qcard .hint:last-child { margin-top: 10px; }

/* feedback: appears below the options and actions, so nothing above it moves */
.explain { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 1.1rem; margin-bottom: 12px; }
.verdict .sched { margin-left: auto; }
.cheer { padding: 1px 10px; border-radius: 99px; background: var(--cheer-bg); color: var(--cheer-ink); font-size: .85rem; font-weight: 700; animation: pop .35s ease-out; }
.verdict-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; }
.explain.ok .verdict-icon { background: var(--ok); }
.explain.bad .verdict-icon { background: var(--bad); }
.explain.ok .verdict strong { color: var(--ok-ink); }
.explain.bad .verdict strong { color: var(--bad-ink); }
.why { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.why p { margin: 0; }
.why-key { flex: none; font-weight: 700; width: 20px; color: var(--muted); }
.why-t { font-weight: 600; }
.why.main { border-left: 4px solid; }
.why.main .why-text { font-size: 1.02rem; }
.why.good { background: var(--ok-bg); border-color: var(--ok); }
.why.badw { background: var(--bad-bg); border-color: var(--bad); }
.why.good .why-key { color: var(--ok-ink); }
.why.badw .why-key { color: var(--bad-ink); }
.others { margin-top: 12px; }
.others .label { margin-bottom: 4px; }
.why.compact { padding: 6px 0; font-size: .9rem; margin: 0; border-top: 1px solid var(--line); border-radius: 0; }
.why.compact .why-t { font-weight: 600; color: var(--text); }
.why.compact .why-text { color: var(--muted); }
.ref { margin: 12px 0 0; line-height: 1.8; }

/* answer animation: once, short, and none when the user asks for reduced motion */
.opt.is-correct.anim { animation: pop .32s ease-out; }
.opt.is-wrong.anim { animation: shake .32s ease-in-out; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl caption { text-align: left; font-weight: 700; padding: 0 0 8px; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
/* no text-transform: uppercase would turn σ into Σ (and μ into Μ) in data-driven headers */
.tbl th { color: var(--muted); font-size: .85rem; font-weight: 700; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .bar-col { width: 30%; vertical-align: middle; }
.tbl .bar-col .bar { margin: 0; }

/* ---------- mock ---------- */
.rules { font-weight: 600; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); }
.mode h2 { margin-bottom: 6px; }
.mode p { margin: 0 0 12px; }
.mode.row p { margin: 0; }
.exam-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; margin-bottom: 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.clock { display: inline-block; min-width: 7ch; text-align: center; font-weight: 700; font-size: 1.1rem; padding: 2px 8px; border-radius: 8px; background: var(--raised); }
.clock.low { color: var(--bad-ink); background: var(--bad-bg); }
.flag-btn.on { color: var(--flag); border-color: var(--flag); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.nav-cell {
  position: relative; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--text); font: inherit; font-size: .85rem; font-variant-numeric: tabular-nums; cursor: pointer;
}
.nav-cell.done { background: var(--accent-soft); border-color: var(--accent-mid); }
.nav-cell.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 2px; background: var(--flag); }
.nav-cell.cur { outline: 2px solid var(--text); outline-offset: 1px; }
.nav-cell.mini { display: inline-block; width: 18px; height: 18px; vertical-align: middle; margin-left: 8px; cursor: default; }
.legend .nav-cell.mini:first-child { margin-left: 0; }
.verdict-big { font-size: 1.8rem; font-weight: 800; margin: 0 0 4px; letter-spacing: .02em; }
.verdict-big.pass { color: var(--ok-ink); }
.verdict-big.fail { color: var(--bad-ink); }
.review-head { margin: 24px 0 12px; }
.review-head h2 { margin: 0; }

/* ---------- learn ---------- */
.search {
  width: 100%; min-height: 48px; padding: 10px 14px; margin: 0 0 16px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.search::placeholder { color: var(--muted); }
.result-list { list-style: none; padding: 0; margin: 0; }
.result { margin-bottom: 10px; }
.snippet { margin: 6px 0 0; }
.topic-links { list-style: none; padding: 0; margin: 0; }
.topic-links li { display: flex; align-items: baseline; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.topic-links li:first-child { border-top: 0; }
.crumbs { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.learn .lead { font-size: 1.05rem; }
.learn section, .learn .traps, .learn .scroll-x { margin-top: 18px; }
.learn h2 { font-size: 1rem; margin-bottom: 6px; }
.learn ul { margin: 0; padding-left: 20px; }
.learn li { margin-bottom: 4px; }
.formulas, .terms { margin: 0; }
.formulas dt, .terms dt { font-weight: 600; margin-top: 8px; }
.formulas dd, .terms dd { margin: 2px 0 0; max-width: 70ch; }
.formulas code { display: inline-block; padding: 4px 8px; border-radius: 6px; background: var(--raised); font-family: ui-monospace, Consolas, monospace; font-size: .95rem; overflow-wrap: anywhere; }
.traps { background: var(--raised); border-left: 4px solid var(--flag); border-radius: 8px; padding: 12px 14px; }

/* ---------- resources ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.filter {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
}
@media (hover: hover) { .filter:hover { border-color: var(--accent); } }
.filter[aria-pressed="true"] { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.filter-n { font-size: .8rem; opacity: .85; }
.res-list { list-style: none; padding: 0; margin: 0; }
.res-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.res-list li:first-child { border-top: 0; }
.res-list .chip { flex: none; margin-top: 2px; }
.res-link { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; }
.res-title { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.res-sum { color: var(--muted); font-size: .9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.res-list.compact li { padding: 8px 0; }
.chip-link { text-decoration: none; }
.chip-link:hover { text-decoration: underline; }
.res .lead { white-space: pre-line; }
/* figures are drawn for white: a white panel in both themes (docs/CONTENT_GUIDE.md, Diagram style) */
.fig { margin: 18px 0 0; }
.fig-panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.fig-panel img { display: block; width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.fig figcaption { margin-top: 6px; }
/* a wide table scrolls inside its own box, so the page never scrolls sideways on a phone */
.table-box { overflow-x: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; }
.table-box .tbl th, .table-box .tbl td { padding: 8px 12px; min-width: 5.5rem; }
.table-box .tbl tbody tr:nth-child(even) { background: var(--raised); }
.table-box .tbl tr:last-child td { border-bottom: 0; }
.note { margin: 6px 0 0; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 10px; }
.step { counter-increment: step; position: relative; padding: 10px 14px 10px 50px; border-radius: 10px; background: var(--raised); }
.step::before {
  content: counter(step); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: .85rem;
}
.step p { margin: 0; }
.step-label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.step-text { white-space: pre-line; max-width: 70ch; }
.step-given { background: var(--accent-soft); }
.step-answer { background: var(--ok-bg); box-shadow: inset 4px 0 0 var(--ok); }
.step-answer .step-label { color: var(--ok-ink); }
.step-answer .step-text { font-weight: 600; }

/* ---------- colour identity: modes and resource kinds ----------
   Six hues for the Home mode tiles and the resource kind chips (--hue-<name> ink, --hue-<name>-tint background).
   Decoration only: the tile title or chip text always names the mode or kind. Ink on tint >= 4.7:1 in both themes;
   the tile order (violet, teal / amber, indigo / sky, rose) keeps grid neighbours apart (validator: normal dE >= 17.8,
   colour-blind dE >= 8.9, light and dark). Phase colours (--ph-*) stay reserved for DMAIC phases. */
.hue-violet { --hue: var(--hue-violet); --hue-tint: var(--hue-violet-tint); }
.hue-teal   { --hue: var(--hue-teal);   --hue-tint: var(--hue-teal-tint); }
.hue-amber  { --hue: var(--hue-amber);  --hue-tint: var(--hue-amber-tint); }
.hue-indigo { --hue: var(--hue-indigo); --hue-tint: var(--hue-indigo-tint); }
.hue-sky    { --hue: var(--hue-sky);    --hue-tint: var(--hue-sky-tint); }
.hue-rose   { --hue: var(--hue-rose);   --hue-tint: var(--hue-rose-tint); }

.tile[class*="hue-"] { background: linear-gradient(135deg, var(--hue-tint), var(--panel) 65%); border-color: color-mix(in srgb, var(--hue) 25%, var(--line)); }
.tile[class*="hue-"] .tile-icon { background: var(--hue); color: var(--hue-on); }
@media (hover: hover) { .tile[class*="hue-"]:hover { border-color: var(--hue); } }

.chip.kind-table      { background: var(--hue-sky-tint);    color: var(--hue-sky); }
.chip.kind-diagram    { background: var(--hue-violet-tint); color: var(--hue-violet); }
.chip.kind-example    { background: var(--hue-teal-tint);   color: var(--hue-teal); }
.chip.kind-cheatsheet { background: var(--hue-amber-tint);  color: var(--hue-amber); }
.filter[data-kind="table"]::before, .filter[data-kind="diagram"]::before,
.filter[data-kind="example"]::before, .filter[data-kind="cheatsheet"]::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--k);
}
.filter[data-kind="table"] { --k: var(--hue-sky); }
.filter[data-kind="diagram"] { --k: var(--hue-violet); }
.filter[data-kind="example"] { --k: var(--hue-teal); }
.filter[data-kind="cheatsheet"] { --k: var(--hue-amber); }
.filter[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--btn-ink); }

/* welcome: soft washes of the phase colours behind the text (<= 12%, text contrast stays >= 4.5:1) */
.welcome {
  position: relative; overflow: hidden; border-top: 0;
  background:
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--ph-analyze) 12%, transparent), transparent 45%),
    radial-gradient(circle at 0 100%, color-mix(in srgb, var(--ph-define) 10%, transparent), transparent 50%),
    var(--panel);
}
.welcome::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 5px;
  background: linear-gradient(90deg, var(--ph-define), var(--ph-measure), var(--ph-analyze), var(--ph-improve), var(--ph-control));
}
.welcome-art { display: flex; gap: 6px; float: right; margin: 0 0 8px 16px; }
.welcome-art .ph-badge { transform: rotate(-6deg); box-shadow: 0 2px 6px rgba(20, 28, 48, .15); }
.welcome-art .ph-badge:nth-child(even) { transform: rotate(5deg) translateY(4px); }
@media (max-width: 480px) { .welcome-art { float: none; margin: 0 0 12px; } }

/* question card: phase colour on top, phase chip in a tint of the same colour */
.qcard[class*="ph-"] { border-top: 4px solid var(--ph); }
.qcard .phase-chip { background: color-mix(in srgb, var(--ph) 18%, var(--panel)); }
.qcard .dot { width: 10px; height: 10px; }

/* learn and resource pages: the phase colour on top of the article, a small badge in the breadcrumb */
.learn[class*="ph-"] { border-top: 4px solid var(--ph); }
.ph-badge.xs { width: 20px; height: 20px; border-radius: 6px; font-size: .72rem; margin-right: 6px; vertical-align: -4px; }
.learn .lead { padding-left: 12px; border-left: 3px solid var(--ph, var(--accent)); }

/* topic and learn lists: a faint wash of the phase colour under the card header */
.phase-card { background: linear-gradient(to bottom, color-mix(in srgb, var(--ph) 8%, var(--panel)), var(--panel) 96px); }

/* home summary: a soft accent wash, the ring in the accent */
.summary { background: linear-gradient(120deg, var(--accent-soft), var(--panel) 55%); }
.summary.passed .ring-fill { stroke: var(--ok); }

/* feedback: a single soft burst behind the verdict icon on Confirm (none with reduced motion) */
.feedback.anim .explain.ok .verdict-icon { animation: burst-ok .7s ease-out; }
.feedback.anim .explain.bad .verdict-icon { animation: burst-bad .5s ease-out; }
.feedback.anim .cheer { animation: pop .35s ease-out, burst-cheer .8s ease-out; }
@keyframes burst-ok { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); transform: scale(.7); }
  50% { transform: scale(1.15); } 100% { box-shadow: 0 0 0 16px transparent; transform: none; } }
@keyframes burst-bad { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes burst-cheer { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cheer-ink) 45%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.explain.ok .verdict-icon { box-shadow: 0 0 0 4px var(--ok-bg); }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0; max-width: min(440px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(10, 14, 24, .5); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin-bottom: 8px; }
.dialog-body p { color: var(--muted); }
