:root {
  --paper: #f4f6f2;
  --paper-deep: #e8ede7;
  --card: #ffffff;
  --ink: #172336;
  --muted: #657184;
  --line: #cfd8d4;
  --blue: #315add;
  --blue-deep: #193b9a;
  --blue-soft: #e9eeff;
  --mint: #0b8b70;
  --mint-soft: #e1f5ef;
  --coral: #c84f45;
  --coral-soft: #fff0ec;
  --amber: #a46308;
  --amber-soft: #fff4d8;
  --shadow: 0 18px 50px rgba(29, 49, 82, .12);
  --header-height: 136px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(46, 82, 99, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 82, 99, .04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(49, 90, 221, .35); outline-offset: 2px; }
code, pre, .memory-table { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.study-header {
  position: fixed;
  z-index: 80;
  inset: 0 0 auto 0;
  min-height: var(--header-height);
  color: #fff;
  background: rgba(23, 35, 54, .97);
  box-shadow: 0 8px 30px rgba(13, 28, 45, .2);
  backdrop-filter: blur(14px);
}
.header-main { height: 76px; padding: 0 30px; display: grid; grid-template-columns: 240px 1fr auto; align-items: center; gap: 24px; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 11px; }
.brand > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #12233f; background: #d8ff72; font-size: 15px; font-weight: 900; transform: rotate(-4deg); }
.brand b { white-space: nowrap; font-size: 18px; letter-spacing: .02em; }
.lesson-identity { min-width: 0; }
.lesson-identity p { margin: 0 0 2px; color: #b9c7df; font-size: 13px; letter-spacing: .08em; }
.lesson-identity h1 { margin: 0; font-size: clamp(22px, 2vw, 31px); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.class-chip { border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 6px 12px; color: #d9e4f7; font-size: 13px; }
.header-btn { border: 1px solid rgba(255,255,255,.22); border-radius: 12px; background: rgba(255,255,255,.08); color: #fff; padding: 9px 13px; font-weight: 700; }
.header-btn:hover { background: rgba(255,255,255,.15); }
.icon-only { width: 42px; padding-inline: 0; }

.module-progress { height: 60px; padding: 0 30px; border-top: 1px solid rgba(255,255,255,.09); display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); align-items: stretch; }
.progress-step { position: relative; border: 0; border-right: 1px solid rgba(255,255,255,.08); color: #afbdd2; background: transparent; display: grid; grid-template-columns: 32px 1fr; grid-template-rows: 1fr 1fr; column-gap: 9px; text-align: left; align-content: center; padding: 7px 15px; }
.progress-step:first-child { border-left: 1px solid rgba(255,255,255,.08); }
.progress-step span { grid-row: 1 / 3; align-self: center; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #65748c; font: 700 12px/1 Consolas, monospace; }
.progress-step b { align-self: end; font-size: 14px; color: #e4ebf6; }
.progress-step small { align-self: start; font-size: 11px; }
.progress-step::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 4px; background: #d8ff72; transition: right .25s ease; }
.progress-step.current { background: rgba(216,255,114,.07); }
.progress-step.current span { color: #14233c; border-color: #d8ff72; background: #d8ff72; }
.progress-step.done { color: #c5f4e7; }
.progress-step.done span { color: #fff; border-color: #39b898; background: #16876e; }
.progress-step.done::after { right: 0; }

.classroom-layout { width: min(1880px, calc(100% - 36px)); margin: 0 auto; padding: calc(var(--header-height) + 22px) 0 70px; display: grid; grid-template-columns: minmax(0, 1fr) 470px; gap: 22px; align-items: start; }
.lesson-main { min-width: 0; }
.lesson-hero { min-height: 210px; color: #fff; background: linear-gradient(125deg, #2448b6, #132a62 70%); border-radius: 24px; padding: 32px 36px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr 250px; gap: 35px; align-items: end; overflow: hidden; position: relative; }
.lesson-hero::after { content: ""; position: absolute; width: 280px; height: 280px; border: 1px solid rgba(216,255,114,.38); border-radius: 50%; right: -75px; top: -120px; box-shadow: 0 0 0 40px rgba(216,255,114,.04), 0 0 0 80px rgba(216,255,114,.025); }
.hero-label { display: inline-block; padding: 5px 10px; border-radius: 8px; color: #193156; background: #d8ff72; font-size: 13px; font-weight: 900; }
.lesson-hero h2 { margin: 13px 0 7px; font-size: clamp(30px, 3.2vw, 51px); line-height: 1.1; letter-spacing: -.04em; }
.lesson-hero p { max-width: 760px; margin: 0; color: #dce7f9; font-size: 18px; }
.hero-evidence { z-index: 1; border-left: 1px solid rgba(255,255,255,.22); padding-left: 24px; display: grid; gap: 5px; }
.hero-evidence span, .hero-evidence small { color: #b7c7e4; font-size: 12px; }
.hero-evidence b { font-size: 15px; }

.lesson-modules { display: grid; gap: 24px; margin-top: 24px; }
.learning-module { scroll-margin-top: calc(var(--header-height) + 18px); background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 25px rgba(32, 51, 77, .06); overflow: hidden; }
.module-titlebar { padding: 25px 30px 20px; border-bottom: 1px solid #e4eae7; display: flex; gap: 18px; align-items: center; justify-content: space-between; }
.module-title { display: flex; gap: 14px; align-items: center; }
.module-number { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 16px 16px 16px 4px; display: grid; place-items: center; color: #fff; background: var(--blue); font: 800 15px/1 Consolas, monospace; }
.module-title span { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.module-title h2 { margin: 1px 0 0; font-size: 27px; line-height: 1.25; }
.module-goal { max-width: 330px; margin: 0; text-align: right; color: var(--muted); font-size: 14px; }
.module-content { padding: 28px 30px 32px; }
.content-lede { max-width: 790px; margin: 0 auto 22px; color: #37465b; font-size: 18px; }

.whatis-card { margin: 0; padding: 26px; overflow-x: auto; color: var(--ink); background: #fbfaf4; border: 1px solid #ddd9c9; border-radius: 18px; }
.whatis-card svg { display: block; width: 100%; min-width: 650px; height: auto; overflow: visible; }
.whatis-card figcaption { width: min(760px, 100%); margin: 14px auto 0; color: var(--muted); font-size: 13px; }
.diagram-ink { stroke: #26364a; fill: none; stroke-width: 3; }
.diagram-box { fill: #fffef8; stroke: #26364a; stroke-width: 2; }
.diagram-accent { fill: #e7edff; stroke: #315add; stroke-width: 3; }
.diagram-muted { fill: #edf0eb; stroke: #9ca8a3; stroke-width: 2; }
.diagram-text { fill: #172336; font: 700 22px "PingFang SC", sans-serif; }
.diagram-small { fill: #667184; font: 15px "PingFang SC", sans-serif; }
.diagram-code { fill: #172336; font: 700 17px Consolas, monospace; }

.concept-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0; }
.concept-grid > div { border: 1px solid var(--line); border-radius: 15px; padding: 17px; background: #f9fbfa; }
.concept-grid b { display: block; margin-bottom: 5px; font-size: 16px; }
.concept-grid span { color: var(--muted); font-size: 14px; }
.source-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

.quick-check { margin-top: 24px; padding: 22px; border-radius: 18px; background: #f4f7fb; border: 1px solid #dbe2ec; }
.quick-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.quick-head span { color: var(--blue); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.quick-head h3 { margin: 3px 0 0; font-size: 18px; }
.attempt-chip { border-radius: 999px; padding: 5px 10px; color: var(--muted); background: #fff; font-size: 12px; white-space: nowrap; }
.check-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 17px; }
.check-option { min-height: 54px; border: 1px solid #ccd6e0; border-radius: 12px; padding: 11px 14px; text-align: left; color: var(--ink); background: #fff; }
.check-option:hover:not(:disabled), .check-option.selected { border-color: var(--blue); background: var(--blue-soft); }
.check-option.correct { border-color: var(--mint); background: var(--mint-soft); }
.check-option.wrong { border-color: var(--coral); background: var(--coral-soft); }
.check-feedback { min-height: 28px; margin: 13px 0 0; color: var(--muted); font-size: 14px; }
.check-feedback.success { color: #08735d; }
.check-feedback.error { color: #a33d34; }

.array-board, .shift-board, .traverse-board, .pointer-lab { margin: 22px 0; padding: 22px; border-radius: 18px; border: 1px solid var(--line); background: #f8faf9; }
.array-grid { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 10px; max-width: 580px; margin: 16px auto; }
.array-cell { min-height: 68px; border: 2px solid #bcc8c3; border-radius: 12px; background: #fff; display: grid; place-items: center; color: var(--ink); font-weight: 800; position: relative; }
.array-cell small { position: absolute; top: 3px; left: 7px; color: #8a96a7; font: 11px Consolas, monospace; }
.array-cell.selected { border-color: var(--blue); background: var(--blue-soft); }
.array-cell.correct { border-color: var(--mint); background: var(--mint-soft); }
.interaction-feedback { margin: 12px 0 0; padding: 11px 13px; border-radius: 10px; background: #fff; color: var(--muted); }
.interaction-feedback.error { color: #9b3f37; background: var(--coral-soft); }
.interaction-feedback.success { color: #086b58; background: var(--mint-soft); }

.shift-row { display: flex; flex-wrap: wrap; align-items: end; justify-content: center; gap: 8px; min-height: 100px; margin: 18px 0; }
.array-block { width: 64px; min-height: 64px; border: 2px solid #9caab4; border-radius: 12px; background: #fff; display: grid; place-items: center; font-weight: 900; position: relative; transition: transform .3s ease, background .3s ease; }
.array-block small { position: absolute; bottom: -24px; color: var(--muted); font: 11px Consolas, monospace; }
.array-block.moving { transform: translateX(12px); background: var(--amber-soft); border-color: #d58b18; }
.array-block.new { background: var(--mint-soft); border-color: var(--mint); }
.interaction-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.memory-layout { display: grid; grid-template-columns: minmax(340px, .85fr) minmax(0, 1.15fr); gap: 18px; }
.memory-table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid #bdc8c3; border-radius: 14px; background: #fff; font-size: 14px; }
.memory-table th, .memory-table td { padding: 10px 12px; border-right: 1px solid #d7dfdb; border-bottom: 1px solid #d7dfdb; text-align: center; }
.memory-table tr:last-child td { border-bottom: 0; }
.memory-table th:last-child, .memory-table td:last-child { border-right: 0; }
.memory-table th { color: #556277; background: #edf1ef; }
.memory-table tr.changed td { background: var(--amber-soft); }
.memory-table tr.detached td { color: #929da8; background: #f1f3f2; }
.chain-stage { min-height: 230px; border-radius: 14px; background: #fff; border: 1px solid #cbd5d0; padding: 18px; }
.chain-title { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.chain-flow { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: center; margin: 30px 0 15px; }
.chain-node { min-width: 78px; border: 2px solid #2c3b50; border-radius: 10px; background: #fff; overflow: hidden; }
.chain-node b { display: block; padding: 10px; text-align: center; font-size: 19px; }
.chain-node span { display: block; border-top: 1px solid #9aa6b3; padding: 5px 8px; color: #5c6879; background: #eef2f1; text-align: center; font: 12px Consolas, monospace; }
.chain-node.new { border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.chain-arrow { color: var(--blue); font-size: 27px; font-weight: 900; }
.chain-terminal { color: var(--muted); font: 700 16px Consolas, monospace; }

.traverse-indexes { display: flex; flex-wrap: wrap; gap: 9px; margin: 15px 0; }
.traverse-indexes button { border: 2px solid #bcc6cf; border-radius: 12px; padding: 10px 14px; background: #fff; }
.traverse-indexes button.expected { border-color: var(--blue); background: var(--blue-soft); }
.traverse-indexes button.done { color: #fff; border-color: var(--mint); background: var(--mint); }
.trail { min-height: 42px; padding: 10px 13px; border-radius: 11px; color: #fff; background: #1d3152; font-family: Consolas, monospace; }

.pointer-task { color: #3d4d62; font-size: 15px; }
.pointer-sources { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.pointer-token { border: 2px dashed #526579; border-radius: 11px; padding: 10px 13px; background: #fff; color: var(--ink); font: 700 14px Consolas, monospace; }
.pointer-token.active, .pointer-token.dragging { color: #fff; border-style: solid; border-color: var(--blue); background: var(--blue); }
.pointer-token.done { color: #08725d; border-color: var(--mint); background: var(--mint-soft); }
.pointer-targets { display: grid; grid-template-columns: repeat(4, minmax(90px, 1fr)); gap: 12px; }
.pointer-target { min-height: 86px; border: 2px solid #acb9c2; border-radius: 13px; background: #fff; display: grid; place-items: center; }
.pointer-target b { font-size: 21px; }
.pointer-target span { color: var(--muted); font: 12px Consolas, monospace; }
.pointer-target.ready { border-color: var(--blue); background: var(--blue-soft); }
.pointer-target.correct-drop { animation: correct-pop .45s ease; }
@keyframes correct-pop { 50% { transform: scale(1.04); background: var(--mint-soft); border-color: var(--mint); } }
.sync-code { margin: 16px 0 0; border-radius: 14px; overflow: hidden; color: #dce7f5; background: #172336; }
.sync-code header { padding: 8px 13px; color: #9fb0c9; background: #22334c; font-size: 12px; }
.sync-code pre { min-height: 76px; margin: 0; padding: 14px; white-space: pre-wrap; font-size: 14px; }

.lesson-summary { margin-top: 24px; padding: 28px 30px; border-radius: 22px; color: #fff; background: #1d3152; }
.lesson-summary span { color: #aec0db; font-size: 12px; }
.lesson-summary h2 { margin: 2px 0 14px; font-size: 24px; }
.lesson-summary textarea { display: block; width: 100%; min-height: 120px; resize: vertical; border: 1px solid #53657e; border-radius: 13px; padding: 13px; color: #fff; background: #13243c; }
.lesson-summary > div:last-child { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

.tool-dock { position: sticky; top: calc(var(--header-height) + 22px); display: grid; gap: 16px; max-height: calc(100vh - var(--header-height) - 40px); overflow-y: auto; scrollbar-width: thin; }
.tool-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); overflow: hidden; }
.tool-head { min-height: 70px; padding: 15px 17px; border-bottom: 1px solid #e0e6e3; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tool-head span { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.tool-head h2 { margin: 0; font-size: 21px; }
.tool-head-actions { display: flex; gap: 6px; }
.fold-btn { border: 1px solid #ced8d4; border-radius: 9px; padding: 6px 9px; color: #435168; background: #fff; font-size: 12px; }
.tool-status { margin: 14px 15px 8px; padding: 8px 10px; border-radius: 9px; color: #80560e; background: var(--amber-soft); font-size: 12px; }
.tool-status i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #d28c20; }
.tool-status.online { color: #08725d; background: var(--mint-soft); }
.tool-status.online i { background: var(--mint); }
.suggestions { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 15px; }
.suggestions button { border: 1px solid #cad4df; border-radius: 999px; padding: 7px 10px; color: #46566b; background: #fff; font-size: 13px; }
.chat-log { height: 154px; overflow-y: auto; padding: 8px 15px; }
.chat { max-width: 92%; margin: 7px 0; padding: 10px 12px; border-radius: 11px; background: #eef2f5; font-size: 14px; }
.chat.user { margin-left: auto; color: #fff; background: var(--blue); }
.chat b { display: block; margin-bottom: 2px; font-size: 11px; }
.chat p { margin: 0; }
.chat-form { display: grid; grid-template-columns: 1fr 40px; gap: 7px; padding: 12px 15px 15px; }
.chat-form input { min-width: 0; border: 1px solid #cbd6d1; border-radius: 10px; padding: 9px 10px; }
.chat-form button { border: 0; border-radius: 10px; color: #fff; background: var(--blue); font-size: 19px; }

.python-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 13px 14px 8px; }
.python-toolbar select { min-width: 0; border: 1px solid #cbd4d0; border-radius: 8px; padding: 7px; background: #fff; }
.python-toolbar button { border: 0; border-radius: 8px; padding: 7px 10px; color: #fff; background: var(--blue); }
.python-toolbar span { grid-column: 1 / 3; color: var(--muted); font-size: 11px; }
.python-workspace { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); min-height: 340px; margin: 0 14px; border: 1px solid #31415a; border-radius: 12px; overflow: hidden; background: #111c2d; }
.editor-pane { min-width: 0; border-right: 1px solid #3b4b63; overflow: hidden; }
.CodeMirror { height: 340px; color: #e6edf7; background: #111c2d; font: 15px/1.65 "SFMono-Regular", Consolas, monospace; }
.CodeMirror-gutters { border-right: 1px solid #334158; background: #152238; }
.CodeMirror-linenumber { color: #74849e; }
.cm-s-default .cm-keyword, .cm-s-default .cm-builtin { color: #8eb7ff; }
.cm-s-default .cm-string { color: #c8e88a; }
.cm-s-default .cm-number { color: #ffbd85; }
.executed-line { background: rgba(216,255,114,.12); }
.result-pane { min-width: 0; color: #dfe8f6; background: #172336; overflow: auto; }
.result-tabs { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; color: #afbdd1; background: #22334b; font-size: 11px; }
.result-pane pre { margin: 0; padding: 11px; white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.55; }
#courseOutput { min-height: 125px; border-bottom: 1px solid #34445d; color: #fff; }
#courseTrace { color: #b9c8dc; }
.python-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 11px 14px 5px; }
.primary-action, .secondary-action, .danger-action { border-radius: 10px; padding: 8px 12px; font-weight: 800; }
.primary-action { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.secondary-action { border: 1px solid #bfcac5; color: #314054; background: #fff; }
.danger-action { border: 1px solid var(--coral); color: var(--coral); background: #fff; }
.python-note { margin: 5px 14px 13px; color: var(--muted); font-size: 11px; }
.python-tool.maximized { position: fixed; z-index: 95; top: calc(var(--header-height) + 14px); right: 20px; width: min(1050px, calc(100vw - 40px)); max-height: calc(100vh - var(--header-height) - 30px); overflow: auto; box-shadow: 0 28px 80px rgba(13, 28, 45, .35); }
.python-tool.maximized .python-workspace { min-height: 510px; }
.python-tool.maximized .CodeMirror { height: 510px; font-size: 16px; }

.catalog-drawer { position: fixed; z-index: 110; top: 0; right: 0; width: min(560px, 94vw); height: 100vh; padding: 22px; overflow-y: auto; background: #fff; box-shadow: -25px 0 70px rgba(18, 35, 58, .24); transform: translateX(105%); transition: transform .25s ease; }
.catalog-drawer.open { transform: translateX(0); }
.drawer-mask { position: fixed; z-index: 105; inset: 0; background: rgba(15, 28, 44, .45); }
.drawer-head { display: flex; justify-content: space-between; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.drawer-head span { color: var(--muted); font-size: 12px; }
.drawer-head h2 { margin: 1px 0 0; font-size: 27px; }
.drawer-head button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; font-size: 25px; }
.textbook-tree, .vault-tree { margin-top: 18px; }
.textbook-tree details, .vault-tree { border: 1px solid var(--line); border-radius: 13px; margin-bottom: 9px; background: #fbfcfb; overflow: hidden; }
.textbook-tree summary, .vault-tree > summary { list-style: none; padding: 13px 15px; font-weight: 900; cursor: pointer; }
.textbook-tree summary small, .vault-tree summary small { float: right; color: var(--muted); font-weight: 500; }
.textbook-tree p { margin: 0; padding: 0 15px 13px; color: var(--muted); font-size: 13px; }
.chapter-tree { padding: 0 10px 10px; }
.chapter-tree details { border-color: #dce3e0; background: #fff; }
.chapter-tree summary { padding: 10px 12px; font-size: 14px; }
.chapter-tree button { display: grid; grid-template-columns: 70px 1fr auto; width: 100%; border: 0; border-top: 1px solid #e8ecea; padding: 10px 12px; text-align: left; color: var(--ink); background: #fff; }
.chapter-tree button:hover:not(:disabled), .chapter-tree button.current { background: var(--blue-soft); }
.chapter-tree button small { color: var(--muted); }
#vaultTree { max-height: 370px; overflow: auto; padding: 0 13px 13px; }
.vault-node { margin: 4px 0 4px 12px; }
.vault-node > summary { cursor: pointer; font-size: 13px; }
.vault-file { margin: 2px 0 2px 23px; color: #778397; font-size: 12px; }
.drawer-policy { padding: 12px; color: #6a552c; background: var(--amber-soft); border-radius: 11px; font-size: 12px; }

.toast { position: fixed; z-index: 140; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 999px; color: #fff; background: #172336; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden, [hidden] { display: none !important; }

@media (max-width: 1240px) {
  :root { --header-height: 128px; }
  .classroom-layout { grid-template-columns: minmax(0, 1fr) 400px; }
  .header-main { grid-template-columns: 210px 1fr auto; padding-inline: 20px; }
  .class-chip { display: none; }
  .module-progress { padding-inline: 20px; }
  .progress-step { padding-inline: 8px; }
  .python-workspace { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid #3b4b63; }
}

@media (max-width: 940px) {
  :root { --header-height: 140px; }
  .header-main { height: 76px; grid-template-columns: auto 1fr auto; gap: 12px; }
  .brand b { display: none; }
  .header-btn { font-size: 0; }
  .header-btn span, .icon-only { font-size: 17px; }
  .module-progress { height: 64px; grid-template-columns: repeat(5, 1fr); padding-inline: 8px; }
  .progress-step { grid-template-columns: 1fr; grid-template-rows: auto auto; place-items: center; text-align: center; padding: 5px 2px; }
  .progress-step span { grid-row: auto; width: 27px; height: 27px; }
  .progress-step small { display: none; }
  .progress-step b { font-size: 11px; }
  .classroom-layout { width: min(100% - 18px, 900px); grid-template-columns: 1fr; }
  .tool-dock { position: static; max-height: none; grid-row: 1; }
  .lesson-main { grid-row: 2; }
  .lesson-hero { grid-template-columns: 1fr; }
  .hero-evidence { border: 0; border-top: 1px solid rgba(255,255,255,.22); padding: 14px 0 0; }
  .memory-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .lesson-identity p { display: none; }
  .lesson-identity h1 { font-size: 19px; }
  .lesson-hero { padding: 24px 20px; border-radius: 18px; }
  .lesson-hero h2 { font-size: 32px; }
  .module-titlebar { padding: 20px; align-items: flex-start; }
  .module-title h2 { font-size: 22px; }
  .module-goal { display: none; }
  .module-content { padding: 20px; }
  .concept-grid, .check-options { grid-template-columns: 1fr; }
  .pointer-targets { grid-template-columns: repeat(2, 1fr); }
  .array-grid { grid-template-columns: repeat(4, 1fr); }
  .array-cell { min-height: 55px; }
  .lesson-summary > div:last-child { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
