        /* ============== CSS 变量 & 基础重置 ============== */
        :root {
            --bg:        #e9e4dc;
            --page-bg:   #fcf9f2;
            --text:      #2b2a26;
            --text-dim:  #5f5b52;
            --text-fade: #7a7366;
            --accent:    #a8907a;
            --accent-dk: #8a7a64;
            --gold:      #f0c27a;
            --gold-dk:   #c8932b;
            --green:     #27ae60;
            --nav-bg:    #3c3a36;
            --panel-bg:  #f5f2ec;
            --border:    #c0b8a8;
            --border-lt: #d0c8b8;
            --code-bg:   #1e1d1b;
            --radius-sm: 4px;
            --radius:    6px;
            --radius-lg: 8px;
            --font-mono: 'Consolas','Monaco','Courier New',monospace;
            --font-ui:   'Segoe UI','Microsoft YaHei','PingFang SC',sans-serif;
            --fs-body:   28px;
            --fs-small:  24px;
            --fs-h1:     36px;
            --fs-h2:     30px;
            --gap-xs: 3px;
            --gap-sm: 6px;
            --gap:    8px;
            --gap-md: 10px;
            --col-left: 60fr;
            --col-right: 40fr;
        }

        * { margin:0; padding:0; box-sizing:border-box; }
        html, body { height:100%; overflow:hidden; }
        body {
            background: var(--bg);
            font-family: var(--font-ui);
            font-size: var(--fs-body);
            color: var(--text);
        }

        /* ============== 页面容器 ============== */
        .page {
            width: 100vw;
            min-height: 100vh;
            background: var(--page-bg);
            padding: 6px 14px;
            display: none;
            flex-direction: column;
            gap: var(--gap);
            overflow: auto;
        }
        .page.chapter{display:none}
        .page.active { display: flex; }

        /* ============== A1 顶部导航栏 ============== */
        .top-nav {
            display: none; /* 章节页不再需要顶部导航 */
            align-items: center;
            gap: var(--gap-md);
            padding: 5px 14px;
            background: linear-gradient(135deg, #3c3a36, #5a5650);
            border-radius: var(--radius);
            flex-shrink: 0;
        }
        .top-nav .nav-title {
            color: #fff;
            font-size: var(--fs-h1);
            font-weight: 700;
            white-space: nowrap;
        }
        .top-nav .nav-btn {
            background: rgba(255,255,255,.15);
            border: none;
            color: #fff;
            padding: 5px 14px;
            border-radius: var(--radius-sm);
            font-size: var(--fs-small);
            cursor: pointer;
            transition: .15s;
            white-space: nowrap;
        }
        .top-nav .nav-btn:hover { background: rgba(255,255,255,.25); }

        /* ============== A2 章节头部 ============== */
        .chapter-header {
            display: flex;
            align-items: center;
            gap: var(--gap-md);
            padding: 2px 0;
            border-bottom: 2px solid var(--border-lt);
            flex-shrink: 0;
        }
        .chapter-header .ch-id {
            background: var(--nav-bg);
            color: #fff;
            padding: 3px 10px;
            border-radius: 3px;
            font-family: var(--font-mono);
            font-size: var(--fs-small);
            font-weight: 700;
            white-space: nowrap;
        }
        .chapter-header .ch-name {
            font-size: 40px;
            font-weight: 700;
            color: var(--text);
            white-space: nowrap;
        }
        .chapter-header .ch-en {
            color: var(--text-fade);
            font-style: italic;
            font-size: var(--fs-small);
        }

        /* ============== 左右两栏主体 ============== */
        .row-body {
            display: grid;
            grid-template-columns: var(--col-left) var(--col-right);
            gap: var(--gap);
            flex: 1 1 0;
        }
        .col-left {
            display: flex;
            flex-direction: column;
            gap: var(--gap);
            min-width: 0;
        }
        .col-right {
            display: flex;
            flex-direction: column;
            gap: 0;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        /* ============== B1 题目描述 ============== */
        .problem-stmt {
            background: #fff;
            border-left: 4px solid var(--accent-dk);
            padding: 8px 14px;
            border-radius: var(--radius-sm);
            font-size: var(--fs-body);
            line-height: 1.55;
            flex-shrink: 0;
            overflow-y: auto;
            min-height: 98px;
            max-height: 120px;
        }
        .problem-stmt .label {
            font-weight: 700;
            color: var(--text-dim);
            margin-right: 8px;
        }

        /* ============== C1 操作+内存+变量 (内联) ============== */
        .info-right {
            display: flex;
            gap: var(--gap-xs);
            flex: 1 1 0;
            min-height: 0;
        }
        .narration {
            background: #fefcf8;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 6px 10px;
            font-size: var(--fs-small);
            display: flex;
            align-items: center;
            gap: var(--gap-sm);
            flex: 0 0 220px;
            min-width: 0;
            flex-wrap: wrap;
        }
        .narration .nlabel {
            background: var(--accent-dk);
            color: #fff;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 22px;
            font-weight: 700;
            white-space: nowrap;
        }
        .narration .step-num {
            background: #e8e2d8;
            padding: 2px 6px;
            border-radius: 8px;
            font-size: 20px;
            font-weight: 700;
            color: var(--accent-dk);
            white-space: nowrap;
        }
        .narration .op-text {
            font-size: var(--fs-body);
            color: var(--text);
            flex: 1;
            min-width: 60px;
        }
        .narration .state-text {
            font-size: 20px;
            color: #1d5a2a;
            background: #e8f0e8;
            padding: 2px 6px;
            border-radius: 3px;
            font-family: var(--font-mono);
            white-space: nowrap;
        }
        .mem-panel-inline {
            background: var(--panel-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 4px 6px;
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1;
            min-width: 0;
            overflow: hidden;
        }
        .mem-panel-inline .panel-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-dim);
            flex-shrink: 0;
            margin: 0; padding: 0; border: none;
        }
        .mem-row-inline {
            display: flex;
            gap: 3px;
            flex-wrap: wrap;
            overflow-y: auto;
            flex: 1;
        }
        .mem-cell-inline {
            background: #fff;
            border: 1px solid #b8aa96;
            border-radius: 3px;
            padding: 1px 4px;
            text-align: center;
            font-family: var(--font-mono);
            font-size: 18px;
            line-height: 1.2;
        }
        .mem-cell-inline.highlight {
            background: var(--gold);
            border-color: var(--gold-dk);
            box-shadow: 0 0 0 2px rgba(240,194,122,.3);
        }
        .mem-cell-inline .addr { font-size: 16px; color: var(--accent-dk); }
        .mem-cell-inline .val  { font-size: 26px; font-weight: 700; color: var(--text); }
        .mem-cell-inline .name { font-size: 18px; color: var(--text-dim); font-weight: 600; }
        .vars-panel-inline {
            background: var(--panel-bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 4px 6px;
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1;
            min-width: 0;
            overflow: hidden;
        }
        .vars-panel-inline .panel-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-dim);
            flex-shrink: 0;
            margin: 0; padding: 0; border: none;
        }
        .var-list-inline {
            display: flex;
            flex-direction: column;
            gap: 1px;
            overflow-y: auto;
            flex: 1;
            font-family: var(--font-mono);
            font-size: 20px;
        }
        .var-row-inline {
            display: flex;
            justify-content: space-between;
            background: #fff;
            padding: 1px 5px;
            border-radius: 3px;
            border: 1px solid #e0d8cc;
            font-size: 20px;
        }
        .var-row-inline .var-name { font-weight: 700; color: var(--accent-dk); }
        .var-row-inline .var-val  { font-weight: 700; color: var(--text); }
        .var-row-inline.changed  { background: #e8f0e8; border-color: #7ac0a8; }

        /* ============== B2 主动画区 (固定画布, 溢出滚动) ============== */
        .anim-area {
            display: flex;
            flex-direction: column;
            flex: 1 1 0;
            min-height: 80px;
        }
        .anim-stage {
            background: #f8f4ee;
            border-radius: var(--radius-lg);
            padding: 6px;
            border: 1px solid #ddd4c6;
            display: flex;
            flex-direction: column;
            flex: 1;
            overflow: auto;
        }
        .anim-stage canvas {
            background: #ffffff;
            border-radius: var(--radius);
            border: 1px solid #ccc0b0;
            display: block;
            flex-shrink: 0;
        }
        .anim-controls {
            display: flex;
            gap: var(--gap);
            margin-bottom: 6px;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            padding: 5px 10px;
            background: #f0e8d8;
            border-radius: var(--radius);
            flex-shrink: 0;
        }
        .anim-controls button {
            background: #e8e2d8;
            border: 1px solid #b8aa96;
            padding: 4px 14px;
            border-radius: 14px;
            font-size: var(--fs-small);
            font-weight: 600;
            cursor: pointer;
            color: var(--text);
            transition: .15s;
            white-space: nowrap;
        }
        .anim-controls button:hover { background: #d6cec0; }
        .anim-controls .btn-primary { background: var(--accent); color: #fff; border-color: var(--accent-dk); }
        .anim-controls .btn-primary:hover { background: var(--accent-dk); }
        .anim-controls .status {
            font-size: var(--fs-small);
            color: var(--text-dim);
            min-width: 50px;
            text-align: center;
            white-space: nowrap;
        }
        .anim-controls .progress { flex: 1; min-width: 60px; max-width: 260px; }
        .progress-bar {
            width: 100%; height: 7px;
            background: #e8e2d8;
            border-radius: var(--radius-sm);
            overflow: hidden;
        }
        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--accent), #c0a888);
            border-radius: var(--radius-sm);
            transition: width .3s;
        }
        .step-text {
            font-size: var(--fs-small);
            color: var(--text-fade);
            text-align: center;
            white-space: nowrap;
        }

        /* ============== B3 步骤可视化 (固定画布, 溢出滚动) ============== */
        .step-visual {
            display: flex;
            flex-direction: column;
            background: var(--panel-bg);
            border-radius: var(--radius-lg);
            border: 1px solid var(--border);
            padding: 8px 12px;
            flex: 1 1 0;
            min-height: 60px;
        }
        .step-visual .sv-head {
            display: flex;
            align-items: center;
            gap: var(--gap);
            flex-shrink: 0;
            flex-wrap: wrap;
        }
        .step-visual .sv-badge {
            background: var(--accent);
            color: #fff;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: var(--fs-small);
            font-weight: 700;
            white-space: nowrap;
        }
        .step-visual .sv-title {
            font-weight: 700;
            font-size: var(--fs-h2);
            color: var(--text);
        }
        .step-visual .sv-text {
            color: #2d2b27;
            font-size: var(--fs-small);
            flex-shrink: 0;
            margin: 3px 0;
        }
        .step-visual .sv-keypoint {
            background: #fff8e8;
            border-left: 4px solid var(--gold);
            padding: 4px 10px;
            border-radius: 3px;
            font-size: var(--fs-small);
            color: #5a3a2a;
            flex-shrink: 0;
        }
        .step-visual .sv-keypoint::before { content: "💡 "; color: var(--gold-dk); }
        .step-visual .sv-canvas-wrap {
            margin-top: var(--gap-sm);
            overflow: auto;
            flex: 1;
            min-height: 0;
            display: flex;
            align-items: flex-start;
        }
        .step-visual .sv-canvas-wrap canvas {
            background: #fff;
            border-radius: var(--radius-sm);
            border: 1px dashed var(--border);
            display: block;
            width: 100%;
            height: auto;
            aspect-ratio: 480 / 150;
        }

        /* ============== C2 代码面板 ============== */
        .code-panel {
            background: var(--code-bg);
            color: #f0ede8;
            border-radius: var(--radius-lg);
            border: 1px solid #3d3a34;
            font-family: var(--font-mono);
            font-size: var(--fs-body);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            flex: 0 0 auto;
            max-height: 320px;
            min-height: 180px;
        }
        .code-panel .code-header {
            background: #2b2a26;
            padding: 5px 12px;
            font-size: var(--fs-small);
            color: #d6cec0;
            border-bottom: 1px solid #3d3a34;
            flex-shrink: 0;
        }
        .code-panel pre {
            margin: 0;
            padding: 2px 0;
            overflow: auto;
            line-height: 1.5;
            flex: 1;
            min-height: 0;
        }
        .code-line {
            display: flex;
            padding: 1px 12px;
            transition: background .2s;
        }
        .code-line:hover { background: rgba(255,255,255,.04); }
        .code-line.current {
            background: rgba(240,194,122,.18);
            border-left: 3px solid var(--gold);
            padding-left: 9px;
        }
        .code-line.current .ln { color: var(--gold); font-weight: 700; }
        .code-line .ln {
            color: #6f6a5f;
            width: 28px;
            flex-shrink: 0;
            text-align: right;
            padding-right: 10px;
            user-select: none;
            font-size: 22px;
        }
        .code-line .code-text { flex: 1; white-space: pre; font-size: var(--fs-body); }
        .code-comment {
            background: #2b2a26;
            border-top: 2px solid var(--gold);
            padding: 6px 12px;
            font-size: var(--fs-small);
            line-height: 1.5;
            color: #f0ede8;
            flex-shrink: 0;
            max-height: 160px;
            overflow-y: auto;
        }
        .code-comment .cc-line { color: var(--gold); font-weight: 700; margin-bottom: 2px; font-size: var(--fs-small); }
        .code-comment .cc-explain { color: #c5e88f; font-style: italic; font-size: var(--fs-small); }
        .code-comment .cc-link { color: #8fc8e8; font-size: 22px; margin-top: 2px; display: block; }

        /* ============== 小屏适配 ============== */
        @media (max-width: 1100px) {
            .row-body {
                grid-template-columns: 1fr;
                grid-template-rows: auto 1fr;
            }
            .info-right { flex-wrap: wrap; }
            .mem-panel-inline, .vars-panel-inline { flex: 1; min-width: 120px; }
        }
        @media (max-width: 700px) {
            .anim-controls .progress { display: none; }
            .code-comment { max-height: 120px; }
            .step-visual .sv-canvas-wrap { min-height: 100px; }
        }


        /* ==========================================================
           module: oi-lesson-theme.css
           可直接抽离为独立 CSS 文件；本页内嵌作为离线回退版本。
           ========================================================== */
        :root {
            --canvas-main-w: 1100;
            --canvas-main-h: 300;
            --canvas-step-w: 960;
            --canvas-step-h: 180;
        }
        .anim-stage {
            display: grid;
            grid-template-rows: auto minmax(0, 1fr);
        }
        .main-canvas-wrap {
            min-height: 0;
            overflow: visible;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 8px;
            border: 1px solid #dfe6ef;
            border-radius: 12px;
            background:
                linear-gradient(rgba(52,120,246,.025) 1px, transparent 1px),
                linear-gradient(90deg, rgba(52,120,246,.025) 1px, transparent 1px),
                #fff;
            background-size: 24px 24px;
        }
        .anim-stage > canvas { display: none !important; }
        .main-canvas-wrap canvas {
            display: block;
            width: min(100%, 1100px);
            height: auto;
            max-height: 100%;
            aspect-ratio: 11 / 3;
            object-fit: contain;
            border: 0;
            border-radius: 10px;
            background: transparent;
        }
        .step-visual .sv-canvas-wrap {
            min-height: 112px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 6px;
            overflow: hidden;
            border: 1px dashed #dce3ec;
            border-radius: 10px;
            background: #fbfdff;
        }
        .step-visual .sv-canvas-wrap canvas {
            display: block;
            width: min(100%, 960px);
            height: auto;
            max-height: 100%;
            aspect-ratio: 32 / 10;
            object-fit: contain;
            border: 0;
            background: transparent;
        }
        .difficulty-chip,
        .concept-chip {
            display: inline-flex;
            align-items: center;
            min-height: 25px;
            padding: 0 9px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 750;
            white-space: nowrap;
        }
        .difficulty-chip {
            color: #8a5200;
            background: #fff4d8;
            border: 1px solid #f4d28b;
        }
        .concept-chip {
            color: #1f5cae;
            background: #edf5ff;
            border: 1px solid #cfe1fa;
        }
        .chapter-header .chapter-tags {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-left: auto;
        }
        .data-import-btn {
            min-height: 38px;
            padding: 7px 11px;
            color: #fff;
            border: 1px solid rgba(255,255,255,.18);
            border-radius: 10px;
            background: rgba(255,255,255,.10);
            font: 650 13px/1 var(--font-ui);
            cursor: pointer;
        }
        .data-import-btn:hover { background: rgba(255,255,255,.20); transform: translateY(-1px); }
        .sdk-state {
            color: rgba(255,255,255,.66);
            font-size: 10px;
            white-space: nowrap;
        }
        @media (max-width: 1320px) {
            .sdk-state { display: none; }
        }
        @media (max-width: 1040px) {
            .main-canvas-wrap { min-height: 320px; }
            .step-visual .sv-canvas-wrap { min-height: 150px; }
        }
        @media (max-width: 700px) {
            .chapter-header .chapter-tags { width: 100%; margin-left: 0; }
            .main-canvas-wrap { min-height: 240px; padding: 4px; }
            .step-visual .sv-canvas-wrap { min-height: 126px; }
            .data-import-btn { flex: 1; }
        }

        /* 课程广场侧栏 cs-* 折叠样式（迁移自 inline style，加折叠/展开） */
        #cs-level-list .cs-item{display:flex;align-items:center;gap:8px;padding:11px 16px;cursor:pointer;font-size:13px;font-weight:700;color:#4f5d73;border-left:3px solid transparent;user-select:none}
        #cs-level-list .cs-item:hover{background:#f5f8ff}
        #cs-level-list .cs-item.cs-sub{padding:8px 16px 8px 32px;font-weight:400;font-size:12px;color:#64748b}
        #cs-level-list .cs-item.is-active{color:#172033;border-left-color:#3478f6;background:#f5f8ff;font-weight:700}
        #cs-level-list .cs-item.cs-head{padding:10px 16px;font-weight:700;color:#4f5d73}
        #cs-level-list .cs-item:focus-visible{outline:2px solid #4f8df7;outline-offset:-2px;border-radius:4px}
        #cs-level-list .cs-count{font-size:11px;color:#94a3b8;margin-left:auto}
        /* caret 用细 CSS 三角形：宽 0 + 透明字符文字，避免在 emoji 旁出现两套形状 */
        #cs-level-list .cs-caret{display:inline-block;width:0;height:0;border-left:5px solid #94a3b8;border-top:4px solid transparent;border-bottom:4px solid transparent;vertical-align:middle;transition:transform .15s ease;transform:rotate(90deg);flex-shrink:0;margin-right:8px;color:transparent;font-size:0;line-height:0;text-indent:-9999px;overflow:hidden}
        #cs-level-list .cs-wrap.is-collapsed > .cs-item.cs-head .cs-caret{transform:rotate(0deg)}
        #cs-level-list .cs-wrap.is-collapsed > .cs-section{display:none}