:root {
  --navy: #10243e;
  --navy-2: #173553;
  --blue: #1c6b8f;
  --paper: #eef3f7;
  --white: #ffffff;
  --line: #cad7e1;
  --muted: #617488;
  --lime: #dff36e;
  --coral: #ee6d54;
  --amber: #f0bd61;
  --success: #2d7d62;
  --shadow: 0 18px 45px rgba(16, 36, 62, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--navy);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.hidden { display: none !important; }

.lesson-header {
  padding: 24px clamp(24px, 5vw, 78px) 34px;
  background: var(--navy);
  color: white;
  border-bottom: 6px solid var(--lime);
}
.brand-line, .title-row { display: flex; justify-content: space-between; gap: 28px; }
.brand-line { align-items: center; padding-bottom: 28px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand { display: flex; align-items: center; gap: 10px; color: white; font-weight: 700; text-decoration: none; letter-spacing: .04em; }
.brand > span { display: grid; place-items: center; width: 32px; height: 32px; background: var(--lime); color: var(--navy); font-family: "Songti SC", serif; font-size: 20px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.live-chip { display: flex; align-items: center; gap: 8px; color: #c6d5e1; font-size: 13px; }
.live-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 5px rgba(223,243,110,.12); }
.quiet-btn { border: 1px solid rgba(255,255,255,.3); background: transparent; color: white; padding: 8px 12px; border-radius: 4px; }
.quiet-btn:hover { border-color: var(--lime); color: var(--lime); }
.title-row { align-items: flex-end; padding-top: 32px; }
.breadcrumb { margin: 0 0 11px; color: #92abc0; font-size: 13px; }
h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(40px, 5vw, 68px); line-height: .98; letter-spacing: -.06em; }
h1 span { display: block; margin-top: 12px; color: var(--lime); font-family: "PingFang SC", sans-serif; font-size: clamp(19px, 2vw, 28px); font-weight: 600; letter-spacing: .08em; }
.lesson-lede { max-width: 760px; margin: 20px 0 0; color: #c0d0dc; line-height: 1.8; font-size: 16px; }
.lesson-lede code { padding: 2px 5px; color: var(--lime); background: rgba(255,255,255,.08); }
.lesson-facts { display: flex; gap: 1px; margin: 0; border: 1px solid rgba(255,255,255,.16); }
.lesson-facts div { width: 92px; padding: 17px 10px 15px; text-align: center; border-left: 1px solid rgba(255,255,255,.16); }
.lesson-facts div:first-child { border-left: 0; }
.lesson-facts dt { color: var(--lime); font: 700 28px/1 ui-monospace, monospace; }
.lesson-facts dd { margin: 8px 0 0; color: #9eb3c3; font-size: 12px; }

main { padding: 28px clamp(24px, 5vw, 78px) 42px; }
.route-panel { padding: 22px 25px 20px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.route-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.route-heading span, .stage-kicker, .side-label, .lab-heading span { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.route-heading h2 { margin: 5px 0 0; font-family: "Songti SC", serif; font-size: 22px; }
.route-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.node-route { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 27px; margin-top: 25px; overflow-x: auto; padding: 4px 3px 12px; }
.route-node { position: relative; min-width: 110px; border: 0; background: transparent; padding: 0; text-align: left; color: var(--muted); }
.route-node::after { content: "→"; position: absolute; top: 13px; right: -21px; color: #9aafbe; font: 18px ui-monospace, monospace; }
.route-node:last-child::after { content: "-1"; right: -26px; color: var(--coral); font-size: 12px; top: 16px; }
.route-node b { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid #b8c8d4; background: var(--paper); color: #7690a3; font: 800 13px ui-monospace, monospace; }
.route-node span { display: block; margin-top: 8px; font-size: 13px; white-space: nowrap; }
.route-node.current b { background: var(--lime); border-color: var(--navy); color: var(--navy); box-shadow: 5px 5px 0 var(--navy); }
.route-node.current span { color: var(--navy); font-weight: 800; }
.route-node.done b { background: var(--success); border-color: var(--success); color: white; }
.route-node.locked { cursor: not-allowed; opacity: .48; }
.route-legend { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; border-top: 1px solid var(--line); padding-top: 13px; color: var(--muted); font-size: 12px; }
.route-legend span { display: flex; align-items: center; gap: 6px; }
.route-legend i { width: 9px; height: 9px; }
.head-dot { background: var(--lime); border: 1px solid var(--navy); }.done-dot { background: var(--success); }.lock-dot { background: #b9c7d2; }
.route-legend code { margin-left: auto; color: var(--coral); }

.learning-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: clamp(24px, 3vw, 44px); margin-top: 31px; }
.stage-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 15px; padding-left: 14px; border-left: 4px solid var(--lime); }
.stage-heading h2 { margin: 5px 0 0; font-family: "Songti SC", serif; font-size: 30px; }
.question-meta { display: grid; justify-items: end; gap: 5px; color: var(--muted); font-size: 12px; }
.question-meta b { color: var(--amber); letter-spacing: .04em; }
.question-card { padding: clamp(24px, 3vw, 38px); background: white; border-top: 5px solid var(--navy); box-shadow: var(--shadow); }
.question-summary { margin-bottom: 22px; color: var(--blue); font-size: 14px; font-weight: 700; }
.markdown-body { color: #263d54; line-height: 1.85; }
.markdown-body p { margin: 0 0 15px; }
.markdown-body pre, .option-markdown pre { overflow-x: auto; margin: 13px 0; padding: 15px 17px; background: var(--navy); color: #edf5fb; border-left: 4px solid var(--lime); font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-body code, .option-markdown code { padding: 2px 5px; background: #e5edf3; color: #1b5270; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-body pre code, .option-markdown pre code { padding: 0; color: inherit; background: transparent; }
.markdown-body img { display: block; max-width: 100%; max-height: 380px; margin: 18px auto; border: 1px solid var(--line); }
.option-list { display: grid; gap: 11px; margin-top: 24px; }
.answer-option { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: start; width: 100%; padding: 14px 16px; border: 1px solid var(--line); background: #f8fafc; color: var(--navy); text-align: left; }
.answer-option:hover { border-color: var(--blue); background: #f1f8fb; }
.answer-option.selected { border: 2px solid var(--navy); padding: 13px 15px; background: #f4f9dd; }
.answer-option.correct-answer { border-color: var(--success); background: #e9f7f0; }
.answer-option.correct-answer .option-letter { background: var(--success); color: white; }
.answer-option:disabled { cursor: default; opacity: .72; }
.answer-option .option-letter { display: grid; place-items: center; width: 32px; height: 32px; background: var(--navy); color: var(--lime); font: 800 14px ui-monospace, monospace; }
.option-markdown { min-width: 0; line-height: 1.65; font-size: 15px; }
.option-markdown p { margin: 4px 0; }
.question-actions { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.question-actions > span { color: var(--muted); font-size: 13px; }
.primary-btn, .next-btn { border: 0; background: var(--navy); color: white; padding: 12px 18px; font-weight: 700; }
.primary-btn:hover, .next-btn:hover { background: var(--blue); }
.primary-btn:disabled { cursor: not-allowed; opacity: .42; }
.feedback-panel { margin-top: 18px; padding: 17px 18px; border-left: 4px solid var(--amber); background: #fff8e8; line-height: 1.75; }
.feedback-panel.correct { border-left-color: var(--success); background: #edf8f3; }
.feedback-panel.final { border-left-color: var(--coral); background: #fff0eb; }
.feedback-panel strong { display: block; margin-bottom: 5px; }
.feedback-explanation { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(16,36,62,.12); color: #3c5266; white-space: pre-wrap; }
.next-btn { display: block; margin: 17px 0 0 auto; background: var(--coral); }
.next-btn span { margin-left: 18px; }

.python-lab { margin-top: 28px; padding: clamp(22px, 3vw, 32px); background: var(--navy); color: white; box-shadow: var(--shadow); }
.lab-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.lab-heading span { color: var(--lime); }
.lab-heading h2 { margin: 5px 0 0; font-family: "Songti SC", serif; font-size: 27px; }
.lab-heading .runtime-state { color: #9db2c2; font-weight: 500; letter-spacing: 0; }
.lab-intro { color: #bccbd7; line-height: 1.75; }
.python-lab .CodeMirror { height: 300px; border: 1px solid #4b6580; background: #091a2b; color: #eef6fb; font: 16px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace; }
.python-lab .CodeMirror-gutters { background: #112b44; border-right-color: #36526b; }
.python-lab .CodeMirror-linenumber { color: #88a0b4; }
.python-lab .CodeMirror-cursor { border-left-color: var(--lime); }
.python-lab .CodeMirror-selected { background: #355773; }
.python-lab .cm-keyword { color: #ffac8f; }.python-lab .cm-string { color: #f4d18f; }.python-lab .cm-number { color: #9ed8f5; }.python-lab .cm-comment { color: #8fa6b8; }.python-lab .cm-builtin { color: #9bdbbd; }
.python-lab .executed-line { background: #294735; }
.lab-controls { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.lab-controls button { padding: 10px 14px; border-radius: 3px; }
.lab-primary { border: 0; background: var(--lime); color: var(--navy); font-weight: 800; }
.lab-secondary { border: 1px solid #607b94; background: transparent; color: #e1ebf2; }
.lab-stop { border: 1px solid var(--coral); background: transparent; color: #ffb9a8; }
.lab-controls button:disabled { cursor: not-allowed; opacity: .48; }
.lab-results { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 15px; }
.lab-results section { min-width: 0; border: 1px solid #36526b; background: #091a2b; }
.lab-results section > span { display: block; padding: 9px 12px; color: #94adbf; border-bottom: 1px solid #36526b; font-size: 12px; }
.lab-results pre { min-height: 84px; max-height: 230px; overflow: auto; margin: 0; padding: 13px; white-space: pre-wrap; color: #edf5fa; font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }
.lab-note { margin: 13px 0 0; color: #91a7b8; font-size: 12px; }

.learning-sidebar { display: grid; align-content: start; gap: 18px; }
.mission-card, .signal-card, .policy-card { padding: 22px; border-left: 1px solid var(--line); }
.mission-card h2 { margin: 7px 0 10px; font-family: "Songti SC", serif; font-size: 25px; }
.mission-card p, .policy-card > p { color: var(--muted); line-height: 1.75; font-size: 14px; }
.mini-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 17px; font: 12px ui-monospace, monospace; }
.mini-chain b { color: var(--coral); }.mini-chain span { display: grid; place-items: center; width: 25px; height: 25px; background: var(--navy); color: var(--lime); }.mini-chain i { color: #8da2b2; font-style: normal; }.mini-chain em { color: var(--coral); font-style: normal; }
.side-card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.side-card-title b { color: var(--blue); font: 800 24px ui-monospace, monospace; }
.signal-item { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.signal-item strong { color: var(--navy); }
.mastery-track { height: 7px; margin: 15px 0 12px; background: #d5dfe7; }
.mastery-track i { display: block; width: 0; height: 100%; background: var(--blue); transition: width .25s ease; }
.signal-card p { color: var(--muted); line-height: 1.65; font-size: 13px; }
.policy-card ol { list-style: none; margin: 15px 0 0; padding: 0; }
.policy-card li { display: grid; gap: 4px; padding: 13px 0; border-top: 1px solid var(--line); }
.policy-card li b { font-size: 14px; }.policy-card li span { color: var(--muted); font-size: 13px; line-height: 1.55; }
.policy-card > p { padding-top: 13px; border-top: 1px solid var(--line); font-size: 12px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px clamp(24px, 5vw, 78px); background: #dfe8ef; color: var(--muted); font-size: 12px; }

@media (max-width: 1050px) {
  .learning-layout { grid-template-columns: 1fr; }
  .learning-sidebar { grid-template-columns: repeat(3, 1fr); }
  .mission-card, .signal-card, .policy-card { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .brand-line, .title-row, .route-heading, .stage-heading, .lab-heading { align-items: flex-start; flex-direction: column; }
  .lesson-facts { width: 100%; }.lesson-facts div { flex: 1; }
  .node-route { grid-template-columns: repeat(6, 120px); }
  .learning-sidebar { grid-template-columns: 1fr; }
  .lab-results { grid-template-columns: 1fr; }
  .question-actions { align-items: stretch; flex-direction: column; }
  .question-meta { justify-items: start; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; }.mastery-track i { transition: none; } }
