/* PE II Exam Trainer – styles (mobile first, light/dark) */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface2: #eef3f9;
  --surface3: #e3ebf5;
  --text: #0f1f38;
  --muted: #5b6a82;
  --line: #d6dfeb;
  --accent: #0b7f8a;
  --accent-ink: #ffffff;
  --accent-soft: #d9f1f3;
  --ok: #15803d;
  --ok-soft: #dcf5e4;
  --bad: #c2410c;
  --bad-soft: #fde5d8;
  --warn: #a16207;
  --warn-soft: #fdf3d3;
  --unit: #8a4b16;
  --g1: #2563eb; --g2: #ea580c; --g3: #059669; --g4: #7c3aed; --g5: #dc2626; --g6: #0891b2;
  --chem: #2563eb; --ox: #7c3aed; --gas: #0d9488; --part: #ea580c; --mem: #db2777; --ac: #16a34a; --sys: #92400e; --tool: #475569;
  --water: rgba(59, 130, 246, 0.12);
  --shadow: 0 1px 2px rgba(15, 31, 56, 0.06), 0 4px 14px rgba(15, 31, 56, 0.06);
  --radius: 14px;
  --nav-h: 62px;
  --pm-water: rgba(37, 99, 235, 0.16); --pm-wline: #2563eb; --pm-sludge: #92400e; --pm-sludge-fill: rgba(146, 64, 14, 0.2);
  --pm-sand: #e2c27d; --pm-grav: #b6a07a; --pm-fe: #c2410c; --pm-mn: #5b21b6; --pm-carbon: #1f2937; --pm-metal: #64748b; --pm-air: #0d9488; --pm-chem: #7c3aed; --pm-earth: rgba(146, 64, 14, 0.13);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111e; --surface: #111a2b; --surface2: #172338; --surface3: #1e2c45; --text: #e7eef8; --muted: #93a3be;
    --line: #26344d; --accent: #2cc2cf; --accent-ink: #04222a; --accent-soft: #10343b; --ok: #4ade80; --ok-soft: #12321f;
    --bad: #fb8a5c; --bad-soft: #3b1d12; --warn: #facc15; --warn-soft: #3a3010; --unit: #e0a26b;
    --g1: #60a5fa; --g2: #fb923c; --g3: #34d399; --g4: #a78bfa; --g5: #f87171; --g6: #22d3ee;
    --chem: #60a5fa; --ox: #a78bfa; --gas: #2dd4bf; --part: #fb923c; --mem: #f472b6; --ac: #4ade80; --sys: #d6a46b; --tool: #94a3b8;
    --water: rgba(96, 165, 250, 0.14); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
    --pm-water: rgba(96, 165, 250, 0.2); --pm-wline: #60a5fa; --pm-sludge: #d6a46b; --pm-sludge-fill: rgba(214, 164, 107, 0.24); --pm-sand: #a8844a; --pm-grav: #7c6a4d; --pm-fe: #fb8a5c; --pm-mn: #a78bfa; --pm-carbon: #cbd5e1; --pm-metal: #94a3b8; --pm-air: #2dd4bf; --pm-chem: #c4b5fd; --pm-earth: rgba(214, 164, 107, 0.14);
  }
}
:root[data-theme="dark"] {
  --bg: #0a111e; --surface: #111a2b; --surface2: #172338; --surface3: #1e2c45; --text: #e7eef8; --muted: #93a3be;
  --line: #26344d; --accent: #2cc2cf; --accent-ink: #04222a; --accent-soft: #10343b; --ok: #4ade80; --ok-soft: #12321f;
  --bad: #fb8a5c; --bad-soft: #3b1d12; --warn: #facc15; --warn-soft: #3a3010; --unit: #e0a26b;
  --g1: #60a5fa; --g2: #fb923c; --g3: #34d399; --g4: #a78bfa; --g5: #f87171; --g6: #22d3ee;
  --chem: #60a5fa; --ox: #a78bfa; --gas: #2dd4bf; --part: #fb923c; --mem: #f472b6; --ac: #4ade80; --sys: #d6a46b; --tool: #94a3b8;
  --water: rgba(96, 165, 250, 0.14); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
  --pm-water: rgba(96, 165, 250, 0.2); --pm-wline: #60a5fa; --pm-sludge: #d6a46b; --pm-sludge-fill: rgba(214, 164, 107, 0.24); --pm-sand: #a8844a; --pm-grav: #7c6a4d; --pm-fe: #fb8a5c; --pm-mn: #a78bfa; --pm-carbon: #cbd5e1; --pm-metal: #94a3b8; --pm-air: #2dd4bf; --pm-chem: #c4b5fd; --pm-earth: rgba(214, 164, 107, 0.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
sub, sup { font-size: 0.72em; line-height: 0; }
sub { vertical-align: -0.25em; }
sup { vertical-align: 0.45em; }
.small { font-size: 0.86rem; }
.center { text-align: center; }
b, strong { font-weight: 650; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
}
.header-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.back-btn { border: 0; background: var(--surface2); width: 36px; height: 36px; border-radius: 10px; font-size: 1.2rem; cursor: pointer; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.brand-logo { width: 30px; height: 30px; flex: none; }
.brand h1 { font-size: 1.02rem; margin: 0; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 0; font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hstats { display: flex; gap: 6px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; background: var(--surface2); font-size: 0.82rem; font-weight: 600; }

/* ---------- main ---------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 16px 8px; }
h2 { font-size: 1.25rem; margin: 6px 0 10px; line-height: 1.25; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer; font-weight: 650;
  background: var(--accent); color: var(--accent-ink); min-height: 46px; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 0.9rem; border-radius: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px;
  font-size: 0.86rem; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text); display: inline-block;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px; font-weight: 600; }

/* ---------- tiles ---------- */
.tile {
  display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); min-height: 92px; position: relative; text-decoration: none; color: var(--text);
}
.tile .ti { font-size: 1.5rem; line-height: 1; }
.tile .tt { font-weight: 700; font-size: 0.97rem; line-height: 1.2; }
.tile .ts { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }
.tile .tn { position: absolute; top: 10px; right: 10px; font-size: 0.75rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); padding: 1px 7px; border-radius: 99px; }
.tile.hero { grid-column: 1 / -1; background: var(--accent); background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--g1))); color: var(--accent-ink); border: 0; min-height: 0; }
.tile.hero .ts { color: inherit; opacity: 0.85; }

/* ---------- progress ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.4s; }
.bar.thin { height: 5px; }
.ring { width: 54px; height: 54px; flex: none; }
.ring circle { fill: none; stroke-width: 6; }
.ring .rb { stroke: var(--surface3); }
.ring .rf { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.6s; }
.ring text { font-size: 15px; font-weight: 700; fill: var(--text); }

/* ---------- topic list ---------- */
.topic-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; text-decoration: none; color: var(--text);
}
.tnum { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: 0.95rem; }
.topic-row .tb { flex: 1; min-width: 0; }
.topic-row .tt { font-weight: 650; line-height: 1.25; }
.topic-row .ts { font-size: 0.78rem; color: var(--muted); }
.prio { font-size: 0.7rem; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--surface2); color: var(--muted); }
.prio.A { background: var(--bad-soft); color: var(--bad); }
.prio.B { background: var(--warn-soft); color: var(--warn); }
.grp-chem { background: var(--chem); } .grp-ox { background: var(--ox); } .grp-gas { background: var(--gas); }
.grp-part { background: var(--part); } .grp-mem { background: var(--mem); } .grp-ac { background: var(--ac); }
.grp-sys { background: var(--sys); } .grp-tool { background: var(--tool); }
.heat { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.heat a { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 0.9rem; color: var(--text); text-decoration: none; border: 1px solid var(--line); position: relative; overflow: hidden; background: var(--surface); }
.heat a i { position: absolute; left: 0; bottom: 0; width: 100%; opacity: 0.32; }
.heat a span { position: relative; }

/* ---------- learn content ---------- */
.learn h3 { display: flex; align-items: center; gap: 8px; }
.learn p { margin: 6px 0 10px; }
.learn ul, .learn ol { padding-left: 20px; margin: 6px 0 10px; }
.learn li { margin: 3px 0; }
.fx { background: var(--surface2); border-radius: 10px; padding: 9px 11px; margin: 8px 0; }
.fx .mb { margin: 0; }
.wh { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
.wh::before { content: "↪ "; }
.trap, .tip, .note {
  border-radius: 10px; padding: 9px 12px; margin: 10px 0; font-size: 0.95rem; border-left: 4px solid;
}
.trap { background: var(--bad-soft); border-color: var(--bad); }
.trap::before { content: "⚠️ Trap: "; font-weight: 700; }
.tip { background: var(--ok-soft); border-color: var(--ok); }
.tip::before { content: "💡 Tip: "; font-weight: 700; }
.note { background: var(--surface2); border-color: var(--accent); }
.recipe { counter-reset: r; list-style: none; padding-left: 0 !important; }
.recipe li { counter-increment: r; position: relative; padding-left: 32px; margin: 8px 0; }
.recipe li::before {
  content: counter(r); position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 0.8rem; display: grid; place-items: center;
}
details.ex { background: var(--surface2); border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
details.ex summary { cursor: pointer; font-weight: 650; }
.spick { display: inline-block; font-size: 0.78rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 6px; }
.exam-ref { display: inline-block; font-size: 0.75rem; font-weight: 700; color: var(--muted); background: var(--surface2); padding: 1px 7px; border-radius: 6px; margin: 2px 3px 2px 0; text-decoration: none; }
table.t { border-collapse: collapse; width: 100%; font-size: 0.86rem; margin: 8px 0; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
table.t th { color: var(--muted); font-weight: 650; }
.tscroll { overflow-x: auto; }

/* ---------- math ---------- */
.m {
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", Georgia, serif;
  font-size: 1.06em; white-space: normal; line-height: 1.35; overflow-wrap: anywhere;
}
.m .fr, .m .sqrt, .m .lr, .m .un { white-space: nowrap; overflow-wrap: normal; }
.m .fn { margin-right: 0.12em; }
.mb .m { white-space: nowrap; overflow-wrap: normal; }
.m i { font-style: italic; }
.m .w, .m .fn, .m .tx { font-style: normal; }
.m .tx { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 0.9em; }
.m sub, .m sup { font-size: 0.7em; line-height: 0; }
.m sub { vertical-align: -0.28em; }
.m sup { vertical-align: 0.5em; }
.m .op { padding: 0 0.2em; }
.m sub .op, .m sup .op { padding: 0 0.05em; }
.m .fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.12em; line-height: 1.15; }
.m .fr > span { padding: 0 0.15em; }
.m .fr > span:first-child { border-bottom: 1px solid currentColor; padding-bottom: 0.08em; }
.m .fr > span:last-child { padding-top: 0.08em; }
.m .fr .fr { font-size: 0.92em; }
.m .sq { border-top: 1px solid currentColor; padding: 0.04em 0.1em 0; margin-left: 0.04em; }
.m .ov { border-top: 1px solid currentColor; }
.m .lr { display: inline-flex; align-items: center; }
.m .dl { font-size: 1.45em; line-height: 1; transform: scaleY(1.15); font-weight: 300; }
.m .bx { border: 1.5px solid var(--accent); border-radius: 6px; padding: 0.1em 0.35em; }
.m .ts { display: inline-block; width: 0.17em; } .m .ms { display: inline-block; width: 0.27em; } .m .qd { display: inline-block; width: 1em; }
.un { color: var(--unit); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 0.82em; font-style: normal; margin-left: 0.3em; white-space: nowrap; }
.mb { overflow-x: auto; overflow-y: hidden; padding: 4px 0; margin: 4px 0; text-align: center; -webkit-overflow-scrolling: touch; }
.mb .m { font-size: 1.12em; }

/* ---------- graphs ---------- */
.gwrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 10px 0; }
.gtitle { font-weight: 700; font-size: 0.95rem; margin: 2px 2px 6px; }
.gsvg svg { width: 100%; height: auto; display: block; }
svg.plot { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
svg.plot .gr { stroke: var(--line); stroke-width: 0.7; }
svg.plot .ax { stroke: var(--muted); stroke-width: 1.1; }
svg.plot .tk { fill: var(--muted); font-size: 10px; }
svg.plot .al { fill: var(--muted); font-size: 11px; }
svg.plot .lb { fill: var(--text); font-size: 11px; }
svg.plot .lg { fill: var(--text); font-size: 10px; }
svg.plot .small { fill: var(--muted); font-size: 10px; }
svg.plot.diag .small { font-size: 10.5px; }
svg.plot.diag .lb { font-size: 12px; }
svg.plot .iso { fill: var(--muted); font-size: 9px; }
svg.plot .ssub, svg.plot .ssup { font-size: 0.75em; }
svg.plot .ln { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
svg.plot .ln.thin { stroke-width: 1.1; }
svg.plot .ln.thick { stroke-width: 3.2; }
svg.plot .c1 { stroke: var(--g1); fill: var(--g1); } svg.plot .c2 { stroke: var(--g2); fill: var(--g2); }
svg.plot .c3 { stroke: var(--g3); fill: var(--g3); } svg.plot .c4 { stroke: var(--g4); fill: var(--g4); }
svg.plot .c5 { stroke: var(--g5); fill: var(--g5); } svg.plot .c6 { stroke: var(--g6); fill: var(--g6); }
svg.plot .cm { stroke: var(--muted); fill: var(--muted); }
svg.plot path.ln, svg.plot line.ln { fill: none; }
svg.plot .ok { fill: var(--ok); stroke: var(--surface); stroke-width: 2; }
svg.plot .bad { fill: var(--bad); stroke: var(--bad); }
svg.plot line.bad { stroke-width: 2; }
svg.plot .dt { stroke: var(--surface); stroke-width: 1.5; }
svg.plot .zone { stroke: none; }
svg.plot .z1 { fill: rgba(234, 88, 12, 0.10); } svg.plot .z2 { fill: rgba(37, 99, 235, 0.09); } svg.plot .z3 { fill: rgba(5, 150, 105, 0.16); }
svg.plot .dbox { fill: var(--surface2); stroke: var(--muted); stroke-width: 1.2; }
svg.plot .dbox.water { fill: var(--water); }
svg.plot .dbox.ground { fill: rgba(161, 98, 7, 0.10); }
svg.plot .parcel { fill: var(--g1); }
svg.plot .arh { fill: var(--muted); }
svg.plot .bar { stroke: none; }
svg.plot .barl { fill: #fff; font-size: 12px; font-weight: 700; }
.gacts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.gctrls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-top: 6px; }
.gc { display: flex; flex-direction: column; font-size: 0.84rem; color: var(--muted); min-width: 0; }
.gc b { color: var(--text); }
.gc input[type=range] { width: 100%; min-width: 0; accent-color: var(--accent); height: 26px; }
.gc.sel { gap: 4px; }
.gc select { width: 100%; min-width: 0; max-width: 100%; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font: inherit; font-size: 0.9rem; }
.gwrap { min-width: 0; overflow: hidden; }
.ginfo { font-size: 0.88rem; background: var(--surface2); border-radius: 10px; padding: 8px 10px; margin-top: 8px; line-height: 1.45; }

/* ---------- play / quiz ---------- */
.play-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.play-top .bar { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 44px; text-align: right; }
.q-kind { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.q-text { font-size: 1.05rem; font-weight: 550; margin: 2px 0 12px; line-height: 1.45; }
.q-ctx { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 11px 13px;
  cursor: pointer; line-height: 1.4; transition: border-color 0.15s, background 0.15s; width: 100%;
}
.opt:active { transform: scale(0.99); }
.opt.ok { border-color: var(--ok); background: var(--ok-soft); }
.opt.bad { border-color: var(--bad); background: var(--bad-soft); }
.opt.dim { opacity: 0.55; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt .ol { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface2); font-size: 0.78rem; font-weight: 800; margin-right: 8px; vertical-align: 1px; }
.fb { margin-top: 12px; border-radius: 12px; padding: 10px 12px; font-size: 0.95rem; }
.fb.ok { background: var(--ok-soft); } .fb.bad { background: var(--bad-soft); } .fb.neutral { background: var(--surface2); }
.fb h4 { margin: 0 0 4px; font-size: 0.98rem; }
.next-bar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); margin-top: 12px; z-index: 5; }

/* flashcard */
.flash { perspective: 1200px; min-height: 230px; cursor: pointer; }
.flash-in { position: relative; min-height: 230px; transition: transform 0.45s; transform-style: preserve-3d; }
.flash.flip .flash-in { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; justify-content: center; text-align: center; box-shadow: var(--shadow); overflow: auto;
}
.flash-face.back { transform: rotateY(180deg); background: var(--surface2); text-align: left; }
.flash-face .hint { font-size: 0.75rem; color: var(--muted); margin-top: 10px; text-align: center; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.grades .btn { flex-direction: column; gap: 0; padding: 8px 4px; font-size: 0.86rem; min-height: 54px; }
.grades .btn small { font-weight: 500; opacity: 0.8; font-size: 0.7rem; }

/* trend */
.trend-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trend-row:last-child { border-bottom: 0; }
.trend-row .tl { flex: 1; font-size: 0.95rem; }
.tbtns { display: flex; gap: 4px; flex: none; }
.tbtn { width: 42px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.1rem; cursor: pointer; font-weight: 800; }
.tbtn.sel { border-color: var(--accent); background: var(--accent-soft); }
.tbtn.ok { border-color: var(--ok); background: var(--ok-soft); }
.tbtn.bad { border-color: var(--bad); background: var(--bad-soft); }

/* factor */
.factor-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.factor-opts .opt { text-align: center; font-size: 1.25rem; font-weight: 800; padding: 16px 8px; }

/* order */
.ostep { display: flex; gap: 10px; align-items: flex-start; }
.ostep .on { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed var(--line); display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; }
.opt.picked .on { border: 0; background: var(--accent); color: var(--accent-ink); }
.opt.ok .on { background: var(--ok); color: #fff; border: 0; }
.opt.bad .on { background: var(--bad); color: #fff; border: 0; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.match .opt { font-size: 0.9rem; padding: 9px 10px; min-height: 48px; }
.match .opt.done { opacity: 0.45; border-style: dashed; }

/* exam tackle */
.ctx-card { background: var(--surface2); border-radius: 12px; padding: 11px 13px; font-size: 0.93rem; margin-bottom: 12px; }
.ctx-card .ctx-h { font-weight: 800; font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.sub-head { display: flex; align-items: baseline; gap: 8px; }
.sub-l { font-weight: 900; font-size: 1.15rem; color: var(--accent); }
.pts { font-size: 0.78rem; font-weight: 700; color: var(--muted); background: var(--surface2); padding: 1px 8px; border-radius: 99px; }
.dummy { font-size: 0.82rem; color: var(--muted); font-style: italic; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 8px 0; }
.steps li { counter-increment: s; position: relative; padding: 6px 0 6px 34px; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 24px; height: 24px; border-radius: 7px; background: var(--surface3); font-weight: 800; font-size: 0.8rem; display: grid; place-items: center; }
.answer { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-weight: 600; }
.answer::before { content: "✅ Official result: "; font-weight: 800; }
.exam-card { display: flex; gap: 12px; align-items: center; }
.exam-year { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-weight: 900; font-size: 1.05rem; background: var(--surface2); flex: none; line-height: 1; text-align: center; }
.exam-year small { display: block; font-size: 0.65rem; font-weight: 700; color: var(--muted); }
.task-list { display: grid; gap: 8px; }
.tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 2px; }

/* summary / badges */
.big-emoji { font-size: 3rem; text-align: center; margin: 4px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid .sv { font-size: 1.35rem; font-weight: 800; }
.stat-grid .sl { font-size: 0.72rem; color: var(--muted); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.bdg { text-align: center; padding: 10px 6px; border-radius: 12px; background: var(--surface2); font-size: 0.75rem; }
.bdg .be { font-size: 1.7rem; display: block; }
.bdg.locked { opacity: 0.35; filter: grayscale(1); }
.lvl { display: flex; align-items: center; gap: 12px; }
.lvl .le { font-size: 2rem; }
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%) translateY(-150%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; z-index: 100;
  transition: transform 0.35s; max-width: 90vw; text-align: center; box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-in { display: flex; width: 100%; max-width: 760px; }
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  height: var(--nav-h); text-decoration: none; color: var(--muted); font-size: 0.68rem; font-weight: 650;
}
.bottom-nav a .ni { font-size: 1.3rem; line-height: 1.1; filter: grayscale(0.6); opacity: 0.8; }
.bottom-nav a.on { color: var(--accent); }
.bottom-nav a.on .ni { filter: none; opacity: 1; }

/* ---------- forms ---------- */
.field { display: grid; gap: 4px; margin: 10px 0; font-size: 0.9rem; }
.field input, .field select, textarea {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); width: 100%;
}
.seg { display: flex; background: var(--surface2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); }
.sep { height: 1px; background: var(--line); margin: 12px 0; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; background: var(--surface2); padding: 1px 5px; border-radius: 5px; }

/* ---------- plant roadmap ---------- */
.pm-card { padding: 6px; }
.pm-wrap { max-width: 470px; margin: 0 auto; }
svg.pm { width: 100%; height: auto; display: block; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-user-select: none; user-select: none; }
svg.pm .st { cursor: pointer; }
svg.pm .st:focus { outline: none; }
svg.pm .hit { fill: transparent; }
svg.pm .bx { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; transition: stroke 0.15s, fill 0.15s; }
svg.pm .st.minor .bx { fill: var(--surface2); }
svg.pm .st.opt .bx { stroke: var(--muted); stroke-dasharray: 4 3; }
svg.pm .st:hover .bx, svg.pm .st:focus-visible .bx { stroke: var(--accent); }
svg.pm .st.on .bx { stroke: var(--accent); stroke-width: 2.6; fill: var(--accent-soft); stroke-dasharray: none; }
svg.pm.flt .st { opacity: 0.22; transition: opacity 0.2s; }
svg.pm.flt .st.hl { opacity: 1; }
svg.pm.flt .st.hl .bx { stroke: var(--accent); stroke-width: 2; }
svg.pm .st.ok .bx { stroke: var(--ok); stroke-width: 2.8; fill: var(--ok-soft); stroke-dasharray: none; }
svg.pm .st.bad .bx { stroke: var(--bad); stroke-width: 2.8; fill: var(--bad-soft); stroke-dasharray: none; }
svg.pm .sn { font-size: 11px; font-weight: 700; fill: var(--text); }
svg.pm .ss { font-size: 9px; fill: var(--muted); }
svg.pm .lane { font-size: 8.5px; font-weight: 800; letter-spacing: 0.08em; fill: var(--muted); }
svg.pm .fll { font-size: 8.2px; fill: var(--muted); font-style: italic; }
svg.pm .lgt { font-size: 8.4px; fill: var(--muted); }
svg.pm .lgbox { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 2; }
svg.pm .tb text { font-size: 8px; font-weight: 800; fill: #fff; }
svg.pm .b-chem { fill: var(--chem); } svg.pm .b-ox { fill: var(--ox); } svg.pm .b-gas { fill: var(--gas); } svg.pm .b-part { fill: var(--part); }
svg.pm .b-mem { fill: var(--mem); } svg.pm .b-ac { fill: var(--ac); } svg.pm .b-sys { fill: var(--sys); } svg.pm .b-tool { fill: var(--tool); }
svg.pm .fl { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
svg.pm .fw { stroke: var(--pm-wline); }
svg.pm .fs { stroke: var(--pm-sludge); }
svg.pm .fr { stroke: var(--pm-sludge); stroke-width: 1.5; stroke-dasharray: 5 3; }
svg.pm .fw2 { stroke: var(--surface); stroke-width: 1.1; stroke-dasharray: 1.5 9; animation: pmflow 1.3s linear infinite; }
@keyframes pmflow { to { stroke-dashoffset: -10.5; } }
svg.pm .mk-w { fill: var(--pm-wline); } svg.pm .mk-s { fill: var(--pm-sludge); }
svg.pm .gw { fill: var(--pm-water); stroke: var(--pm-wline); stroke-width: 0.9; }
svg.pm .gwl { fill: none; stroke: var(--pm-wline); stroke-width: 1.1; stroke-linecap: round; }
svg.pm .gsl { fill: var(--pm-sludge-fill); }
svg.pm .gsl2 { fill: var(--pm-sludge-fill); stroke: var(--pm-sludge); stroke-width: 1; }
svg.pm .gfl { fill: var(--pm-sludge); }
svg.pm .gm { fill: none; stroke: var(--pm-metal); stroke-width: 1.3; stroke-linecap: round; }
svg.pm .gm2, svg.pm .gmk { fill: var(--pm-metal); }
svg.pm .gbub { fill: var(--surface); stroke: var(--pm-wline); stroke-width: 0.8; }
svg.pm .gsand, svg.pm .gsandf { fill: var(--pm-sand); }
svg.pm .ggrav { fill: var(--pm-grav); }
svg.pm .gfe { fill: var(--pm-fe); } svg.pm .gmn { fill: var(--pm-mn); }
svg.pm .gk { fill: var(--pm-carbon); }
svg.pm .guv { fill: var(--pm-chem); }
svg.pm .guvg { stroke: var(--pm-chem); stroke-width: 1.2; stroke-linecap: round; }
svg.pm .gtx { font-size: 9px; font-weight: 800; fill: var(--pm-wline); }
svg.pm .gtree { fill: var(--ac); }
svg.pm .gpipe { fill: var(--surface3); stroke: var(--pm-metal); stroke-width: 0.9; }
svg.pm .gcry { fill: var(--surface); stroke: var(--pm-sludge); stroke-width: 0.8; }
svg.pm .gtw { fill: var(--pm-water); stroke: var(--pm-metal); stroke-width: 1; }
svg.pm .gpack { fill: none; stroke: var(--pm-metal); stroke-width: 0.7; opacity: 0.8; }
svg.pm .ga { fill: none; stroke: var(--pm-air); stroke-width: 1.4; }
svg.pm .gak { fill: var(--pm-air); }
svg.pm .gfib { stroke: var(--pm-metal); stroke-width: 1.1; }
svg.pm .gro, svg.pm .gsteps, svg.pm .ghouse { fill: var(--surface3); stroke: var(--pm-metal); stroke-width: 0.9; }
svg.pm .gearth { fill: var(--pm-earth); }
svg.pm .chem { fill: var(--pm-chem); }
svg.pm .chemt { font-size: 7.6px; font-weight: 800; fill: var(--pm-chem); }
.pm-story { border-left: 4px solid var(--accent); font-size: 0.93rem; }
.pm-row { width: 100%; text-align: left; font: inherit; color: var(--text); }
.pm-ic { font-size: 1.35rem; width: 34px; text-align: center; flex: none; line-height: 1; }
.chip.sm { padding: 3px 9px; font-size: 0.8rem; }
.tnum.xs { width: 20px; height: 20px; border-radius: 6px; font-size: 0.72rem; display: inline-grid; vertical-align: -5px; margin-right: 5px; }
#pmTags { align-items: center; margin-bottom: 10px; }
.pm-sheet {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  max-width: 760px; margin: 0 auto; max-height: 62vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(15, 31, 56, 0.2); transform: translateY(105%); visibility: hidden;
  transition: transform 0.28s ease, visibility 0s linear 0.28s;
}
.pm-sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.28s ease, visibility 0s; }
.pm-sheet .sh-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 9px; border-bottom: 1px solid var(--line); }
.pm-sheet .sh-ic { font-size: 1.6rem; line-height: 1; }
.pm-sheet .sh-t { font-weight: 800; line-height: 1.2; }
.pm-sheet .sh-s { font-size: 0.76rem; color: var(--muted); }
.pm-sheet .sh-body { overflow-y: auto; padding: 8px 14px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pm-sheet .sh-body h4 { margin: 12px 0 6px; font-size: 0.76rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.pm-sheet .chips .chip { white-space: normal; max-width: 100%; }
.pm-sheet .sh-nav { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); }
main.pm-open { padding-bottom: 62vh; }
.tile.wide { grid-column: 1 / -1; min-height: 0; }
.tile .trail { font-size: 1.05rem; letter-spacing: 0.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (min-width: 700px) {
  body { font-size: 16.5px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .heat { grid-template-columns: repeat(9, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
