:root {
  --paper: #f3efe6;
  --ink: #1f2430;
  --muted: #5c6470;
  --line: #d5cec0;
  --math: #3b6aa0;
  --phys: #2f7a6a;
  --chem: #b4532a;
  --hot: #c0452a;
  --ok: #2a7a4d;
  --panel: #fffcf6;
  --shadow: 0 10px 30px rgba(31, 36, 48, 0.08);
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { display: grid; grid-template-rows: auto auto 1fr auto; }
header.app-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1.2rem;
  padding: 0.7rem 1.1rem 0.45rem; border-bottom: 1px solid var(--line); background: #fffcf7;
}
header.app-head h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.02em; font-weight: 700; }
header.app-head .sub { color: var(--muted); font-size: 0.82rem; }
#mods { display: flex; flex-wrap: wrap; gap: 0.65rem 1.25rem; padding: 0.4rem 1.1rem 0.6rem; background: #fffcf7; border-bottom: 1px solid var(--line); }
.mod-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.mod-group > span { font-size: 0.75rem; color: var(--muted); margin-right: 0.2rem; }
.mod-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 0.28rem 0.7rem; border-radius: 999px; cursor: pointer; font-size: 0.82rem;
}
.mod-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#workspace { display: grid; grid-template-columns: 1fr min(420px, 38vw); min-height: 0; }
#stage-wrap { position: relative; min-height: 420px; background: #efe8da; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.css2d-layer { position: absolute; inset: 0; pointer-events: auto; }
aside.panel {
  background: var(--panel); border-left: 1px solid var(--line);
  overflow: auto; padding: 0.85rem 1rem 1.4rem;
}
#toggle-panel {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 5;
  border: 1px solid var(--line); background: #fffcf7cc; cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 8px;
}
body.panel-collapsed #workspace { grid-template-columns: 1fr 0; }
body.panel-collapsed aside.panel { display: none; }
.kicker { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.3rem; }
#mod-subject { font-size: 0.72rem; border: 1px solid var(--line); padding: 0.05rem 0.4rem; border-radius: 99px; }
#mod-subject[data-sub="math"] { color: var(--math); border-color: var(--math); }
#mod-subject[data-sub="phys"] { color: var(--phys); border-color: var(--phys); }
#mod-subject[data-sub="chem"] { color: var(--chem); border-color: var(--chem); }
#mod-title { font-size: 1.05rem; margin: 0 0 0.7rem; }
.goals dt { font-size: 0.75rem; color: var(--muted); margin-top: 0.45rem; }
.goals dd { margin: 0.1rem 0 0; font-size: 0.88rem; line-height: 1.5; }
#controls, #questions { margin-top: 0.9rem; }
#controls button, .check, #controls select, #controls input[type="number"], #questions input {
  font: inherit; font-size: 0.82rem;
}
#controls button, .check {
  border: 1px solid var(--line); background: #fff; padding: 0.28rem 0.6rem; border-radius: 8px; cursor: pointer; margin: 0.15rem 0.15rem 0.15rem 0;
}
#controls button:hover, .check:hover { background: #f3efe6; }
.row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.35rem 0; }
label { display: block; font-size: 0.82rem; margin: 0.35rem 0; color: var(--ink); }
.hint, .src, .axis, .legend { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.readout { font-variant-numeric: tabular-nums; background: #f3efe6; padding: 0.4rem 0.55rem; border-radius: 8px; font-size: 0.85rem; }
.proj-wrap { display: grid; grid-template-columns: 1fr; gap: 0.6rem; margin-top: 0.5rem; }
.proj-wrap h4 { margin: 0 0 0.25rem; font-size: 0.82rem; }
.proj-grid { display: grid; grid-template-columns: repeat(var(--n), 18px); gap: 2px; }
.proj-grid span { width: 18px; height: 18px; border: 1px solid #bbb; background: transparent; }
.proj-grid span.on { background: #6e97c2; border-color: #2a3340; }
.q { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.75rem; margin: 0.6rem 0; background: #fff; }
.q header { font-weight: 650; font-size: 0.88rem; }
.prompt { font-size: 0.88rem; line-height: 1.55; }
.q img.stem, .choice img, .stem-row img { max-width: 100%; max-height: 280px; width: auto; height: auto; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.stem-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stem-row figure { margin: 0; text-align: center; }
.stem-row figcaption { font-size: 0.75rem; color: var(--muted); }
.choices { display: grid; gap: 0.35rem; }
.choice { display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.3rem; cursor: pointer; }
.choice img { max-height: 72px; background: #fff; }
.cid { font-weight: 700; min-width: 1.1rem; }
.fb { margin-top: 0.5rem; padding: 0.45rem 0.55rem; border-radius: 8px; font-size: 0.85rem; line-height: 1.5; }
.fb.ok { background: #e5f3ea; color: #164a2c; }
.fb.bad { background: #fbe8e4; color: #6d2418; }
.tag {
  background: #fffcf7ee; border: 1px solid #cfc6b4; color: #1f2430;
  padding: 0.08rem 0.4rem; border-radius: 6px; font-size: 12px; white-space: pre; pointer-events: none;
}
.tag-sm { font-size: 11px; padding: 0.04rem 0.28rem; }
.tag-hot { border-color: #c0452a; color: #8a2a1c; }
.tag-ok { border-color: #2a7a4d; color: #164a2c; }
footer.app-foot { border-top: 1px solid var(--line); padding: 0.45rem 1.1rem; font-size: 0.75rem; color: var(--muted); background: #fffcf7; }
@media (max-width: 820px) {
  #workspace { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; }
  aside.panel { border-left: 0; border-top: 1px solid var(--line); }
  body.panel-collapsed #workspace { grid-template-rows: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
