        :root {
            --primary: #667eea;
            --primary-dark: #5a6fd6;
            --success: #52c41a;
            --warning: #faad14;
            --danger: #ff4d4f;
            --bg: #f5f7fa;
            --card-bg: #fff;
            --text: #333;
            --text-secondary: #666;
            --border: #e8e8e8;
            --radius: 10px;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
            background: var(--bg);
            color: var(--text);
            line-height: 1.6;
            min-height: 100vh;
        }
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #fff;
            padding: 20px 40px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 14px;
            position: relative;
            box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
        }
        .header h1 { font-size: 1.5rem; font-weight: 600; text-align: center; }
        .header .user-info { position: absolute; top: 18px; right: 24px; }
        .header-right { display: none; }
        .api-key-wrapper { display: block; max-width: 640px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 10px; }
        .ai-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
        .ai-tab {
            flex: 1; padding: 9px 0; font-size: .85rem; text-align: center; cursor: pointer;
            border-radius: 8px; border: 1px solid rgba(255,255,255,.35); color: rgba(255,255,255,.9);
            background: rgba(255,255,255,.12); font-weight: 500;
            transition: all .18s; user-select: none;
        }
        .ai-tab:hover { background: rgba(255,255,255,.22); color: #fff; }
        .ai-tab.active {
            background: #fff; color: #4a3f8f; border-color: #fff; font-weight: 700;
            box-shadow: 0 2px 10px rgba(0,0,0,.28);
        }
        .ai-tab small { display: block; font-size: .68rem; opacity: .75; font-weight: 400; margin-top: 2px; }
        .ai-pane { display: none; }
        .ai-pane.active { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
        .ai-pane label { color: rgba(255,255,255,.8); font-size: .78rem; min-width: 0; }
        .ai-pane input,
        .ai-pane select {
            padding: 6px 10px; border: none; border-radius: 6px; font-size: .8rem; outline: none;
            background: #fff; color: #333;
        }
        .ai-pane input { min-width: 200px; flex: 1 1 220px; }
        .ai-pane select { min-width: 150px; max-width: 220px; }
        .ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1 1 100%; }
        .ai-row .btn { white-space: nowrap; flex-shrink: 0; }
        .ai-hint { color: rgba(255,255,255,.55); font-size: .72rem; line-height: 1.3; flex: 1 1 100%; padding: 0 2px 2px; margin-top: -4px; }
        .custom-status {
            flex: 1 1 auto; min-width: 0; font-size: .8rem; color: rgba(255,255,255,.9);
            background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
            border-radius: 6px; padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        /* ---- 自备 API Key 弹窗 ---- */
        .modal-overlay {
            position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
            display: flex; align-items: center; justify-content: center; padding: 20px;
        }
        .modal-card {
            width: 100%; max-width: 460px; background: #fff; border-radius: 12px;
            padding: 24px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
        }
        .modal-title { font-size: 1.05rem; font-weight: 700; color: #333; margin-bottom: 16px; }
        .modal-label { display: block; font-size: .8rem; color: #666; margin: 10px 0 4px; }
        .modal-card input {
            width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d9d9d9;
            border-radius: 6px; font-size: .85rem; outline: none; transition: border-color .15s;
        }
        .modal-card input:focus { border-color: var(--primary); }
        .modal-hint { font-size: .72rem; color: #999; line-height: 1.5; margin-top: 10px; }
        .modal-hint code { color: #d48806; }
        .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
        .modal-btn { padding: 8px 18px; border-radius: 6px; font-size: .85rem; cursor: pointer; border: 1px solid transparent; transition: all .15s; }
        .modal-btn-cancel { background: #f5f5f5; color: #666; border-color: #d9d9d9; }
        .modal-btn-cancel:hover { color: #333; }
        .modal-btn-save { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
        .modal-btn-save:hover { opacity: .9; }
        .container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
        .card {
            background: var(--card-bg); border-radius: var(--radius);
            padding: 24px; margin-bottom: 20px;
            box-shadow: 0 1px 4px rgba(0,0,0,0.06);
        }
        .card-title {
            font-size: 1.05rem; font-weight: 600; margin-bottom: 16px;
            padding-bottom: 10px; border-bottom: 2px solid var(--border);
        }
        .steps { display: flex; gap: 0; margin-bottom: 24px; }
        .step {
            flex: 1; text-align: center; padding: 12px 8px;
            background: #e8e8e8; color: #999; font-size: .85rem;
            position: relative; cursor: pointer; transition: all .3s;
        }
        .step:first-child { border-radius: 8px 0 0 8px; }
        .step:last-child { border-radius: 0 8px 8px 0; }
        .step.active { background: var(--primary); color: #fff; font-weight: 600; }
        .step.completed { background: #b7eb8f; color: #389e0d; }
        .step.disabled { cursor: not-allowed; opacity: 0.6; }
        .step .step-num { display: block; font-size: 1.2rem; font-weight: 700; }
        .form-row { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
        .form-group { flex: 1; min-width: 200px; }
        .form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
        .form-group select, .form-group textarea {
            width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9;
            border-radius: 6px; font-size: .88rem; outline: none;
            transition: border-color .3s;
        }
        .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
        .form-group textarea { resize: vertical; min-height: 100px; font-family: inherit; }
        .btn {
            padding: 10px 20px; border: none; border-radius: 6px; font-size: .9rem;
            cursor: pointer; transition: all .3s; display: inline-flex; align-items: center; gap: 6px;
        }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn-primary { background: var(--primary); color: #fff; }
        .btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
        .btn-success { background: var(--success); color: #fff; }
        .btn-success:hover:not(:disabled) { background: #49aa19; }
        .btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
        .btn-outline:hover:not(:disabled) { background: #f0f2ff; }
        .btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
        .prereq-list { list-style: none; padding: 0; }
        .prereq-list li {
            display: flex; align-items: center; gap: 8px;
            padding: 8px 12px; margin: 4px 0; background: #f0f5ff;
            border-left: 3px solid var(--primary); border-radius: 0 6px 6px 0;
            font-size: .88rem; transition: all .2s;
        }
        .prereq-list li:hover { background: #e6f0ff; }
        .prereq-list li .prereq-text { flex: 1; cursor: pointer; }
        .prereq-list li .prereq-text:hover { text-decoration: underline; text-decoration-color: #667eea; text-decoration-style: dotted; }
        .prereq-actions { display: flex; gap: 4px; flex-shrink: 0; }
        .prereq-actions button {
            width: 26px; height: 26px; border: 1px solid #d9d9d9; border-radius: 4px;
            background: #fff; cursor: pointer; font-size: .75rem; display: flex;
            align-items: center; justify-content: center; transition: all .2s;
        }
        .prereq-actions .btn-edit:hover { background: #e6f7ff; border-color: #1890ff; color: #1890ff; }
        .prereq-actions .btn-del:hover { background: #fff2f0; border-color: #ff4d4f; color: #ff4d4f; }
        .btn-add-prereq {
            display: inline-flex; align-items: center; gap: 4px; margin-top: 8px;
            padding: 6px 14px; border: 1px dashed #667eea; border-radius: 6px;
            background: transparent; color: #667eea; cursor: pointer; font-size: .82rem; transition: all .2s;
        }
        .btn-add-prereq:hover { background: #f0f5ff; }
        .question-card {
            background: #fafafa; border: 1px solid #e8e8e8; border-radius: 8px;
            padding: 16px; margin-bottom: 12px;
        }
        .question-card .q-title { font-weight: 600; margin-bottom: 8px; color: var(--primary); }
        .question-card .q-answer { color: var(--success); font-size: .85rem; margin-top: 8px; }
        .question-card .q-type { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .75rem; background: #e6f7ff; color: #1890ff; }
        .q-options { margin: 10px 0 6px; padding-left: 18px; }
        .q-option-item { display: block; margin-bottom: 3px; line-height: 1.7; font-size: .9rem; }
        .method-checkbox {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 8px 14px; border: 1.5px solid #d9d9d9; border-radius: 20px;
            cursor: pointer; font-size: .85rem; transition: all .2s;
            user-select: none;
        }
        .method-checkbox:hover { border-color: var(--primary); }
        .method-checkbox.checked { background: #f0f5ff; border-color: var(--primary); color: var(--primary); font-weight: 500; }
        .method-checkbox input { display: none; }
        .alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 12px; font-size: .88rem; }
        .alert-error { background: #fff2f0; border: 1px solid #ffccc7; color: #ff4d4f; }
        .alert-warning { background: #fffbe6; border: 1px solid #ffe58f; color: #d48806; }
        .alert-info { background: #e6f7ff; border: 1px solid #91d5ff; color: #1890ff; }
        .alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
        .hidden { display: none !important; }
        .spinner {
            display: inline-block; width: 16px; height: 16px;
            border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
            border-radius: 50%; animation: spin .6s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }
        .toast {
            position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
            padding: 10px 24px; border-radius: 6px; color: #fff; font-size: .88rem;
            z-index: 9999; animation: fadeInOut 3s ease;
        }
        @keyframes fadeInOut {
            0% { opacity: 0; top: 0; }
            10% { opacity: 1; top: 20px; }
            80% { opacity: 1; top: 20px; }
            100% { opacity: 0; top: 0; }
        }
        .lesson-section { margin-bottom: 20px; }
        .lesson-section h4 { color: var(--primary); margin-bottom: 8px; }
        .lesson-section h5 { font-size: .95rem; margin: 12px 0 6px; color: #222; }
        .lesson-section ol { padding-left: 22px; margin: 8px 0; }
        .lesson-section ol li { margin-bottom: 4px; line-height: 1.7; }
        .lesson-section ul { padding-left: 22px; margin: 8px 0; }
        .lesson-section ul li { margin-bottom: 4px; line-height: 1.7; }
        .lesson-section code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; font-size: .85rem; }
        .homework-level { background: #fafafa; border-radius: 8px; padding: 14px; margin-bottom: 10px; }
        .homework-level h5 { margin-bottom: 6px; }
        .homework-level ol { padding-left: 20px; }
        /* 全局停止生成按钮（流式输出期间显示，右下角悬浮） */
        .stop-btn {
            position: fixed;
            right: 24px;
            bottom: 24px;
            z-index: 999;
            background: #e74c3c;
            color: #fff;
            border: none;
            border-radius: 24px;
            padding: 10px 22px;
            font-size: .9rem;
            cursor: pointer;
            box-shadow: 0 4px 14px rgba(0,0,0,.3);
            white-space: nowrap;
        }
        .stop-btn:hover { background: #c0392b; }

        /* ===== 逐题错误人数快速录入 ===== */
        .tally-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 12px;
            border: 1px solid #e8e8e8;
            border-radius: 8px;
            margin-bottom: 8px;
            background: #fafafa;
        }
        .tally-q { font-size: .88rem; color: #333; }
        .tally-q .q-type { margin-left: 4px; }
        .tally-controls { display: flex; align-items: center; gap: 12px; }
        .tally-btn {
            width: 32px;
            height: 32px;
            border: 1px solid #d9d9d9;
            background: #fff;
            border-radius: 8px;
            font-size: 1.15rem;
            line-height: 1;
            color: #333;
            cursor: pointer;
            transition: all .15s;
        }
        .tally-btn:hover { border-color: #667eea; color: #667eea; }
        .tally-btn:active { transform: scale(.92); }
        .tally-input {
            width: 60px;
            text-align: center;
            font-weight: 600;
            font-size: .95rem;
            border: 1px solid #d9d9d9;
            border-radius: 6px;
            padding: 5px 4px;
            outline: none;
            background: #fff;
        }
        .tally-input:focus { border-color: #667eea; }
        /* 隐藏原生数字步进箭头（界面已有自己的 +/- 按钮） */
        .tally-input::-webkit-outer-spin-button,
        .tally-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
        .tally-input { -moz-appearance: textfield; appearance: textfield; }
        .tally-total-row { justify-content: flex-start; gap: 12px; max-width: 240px; background: #fff; }
        .tally-total-row input {
            width: 80px;
            text-align: center;
            font-weight: 600;
            border: none;
            outline: none;
            font-size: .95rem;
            background: transparent;
        }

        /* 教案环节配图（懒加载 GeoGebra 画布） */
        .lesson-figure { margin-top: 10px; }
        .fig-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
        .fig-title { font-size: .85rem; color: #555; font-weight: 600; }
        .fig-head .btn-sm { padding: 3px 10px; font-size: .78rem; }
        .fig-body { margin-top: 8px; }
        .lesson-fig-frame { width: 100%; height: 420px; border: 1px solid #e0e0e0; border-radius: 8px; background: #fff; display: block; }

        @media (max-width: 768px) {
            .header { padding: 16px 20px; flex-direction: column; gap: 10px; }
            .form-row { flex-direction: column; }
            .steps { flex-wrap: wrap; }
            .step { flex: 1 1 45%; }
        }
        /* 用户信息 */
        .user-info { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
        .user-info .user-name { font-weight: 600; color: #fff; }
        .user-info .btn-sm {
            padding: 4px 10px; border: 1px solid rgba(255,255,255,.4); border-radius: 4px;
            background: transparent; color: #fff; cursor: pointer; font-size: .78rem; transition: all .2s;
        }
        .user-info .btn-sm:hover { background: rgba(255,255,255,.15); }
        .btn-sm { padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 5px; background: #fff; cursor: pointer; font-size: .82rem; transition: all .2s; }
        .btn-sm:hover { border-color: var(--primary); color: var(--primary); }
        /* 模态框 */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center;
        }
        .modal {
            background: #fff; border-radius: 12px; width: 700px; max-width: 90vw; max-height: 80vh;
            display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,.2);
        }
        .modal-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 16px 20px; border-bottom: 1px solid #e8e8e8;
        }
        .modal-header h3 { font-size: 1.05rem; margin: 0; }
        .modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #999; padding: 4px 8px; }
        .modal-close:hover { color: #333; }
        .modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
        .history-item {
            border: 1px solid #e8e8e8; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
            cursor: pointer; transition: all .2s;
        }
        .history-item:hover { border-color: #667eea; box-shadow: 0 2px 8px rgba(102,126,234,.1); }
        .history-item .hi-header {
            display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
        }
        .history-item .hi-type {
            display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .75rem; font-weight: 500;
        }
        .hi-type.questions { background: #fff7e6; color: #d48806; }
        .hi-type.analysis { background: #e6f7ff; color: #1890ff; }
        .hi-type.board { background: #f6ffed; color: #389e0d; }
        .hi-type.homework { background: #f9f0ff; color: #722ed1; }
        .hi-type.lesson { background: #fff0f6; color: #eb2f96; }
        .history-item .hi-date { font-size: .78rem; color: #999; }
        .history-item .hi-preview { font-size: .83rem; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .history-empty { text-align: center; padding: 40px; color: #999; }
        /* 详情模态框专属样式 */
        .detail-modal { width: 800px; max-width: 95vw; }
        .detail-modal .modal-body { max-height: 70vh; overflow-y: auto; padding: 20px 24px; }
        .detail-modal .modal-body .question-card { margin-bottom: 12px; }
        .detail-modal .modal-body .lesson-section { margin-bottom: 16px; }
        .detail-modal .modal-body .lesson-section h4 { font-size: .95rem; margin-bottom: 8px; }
        .detail-modal .modal-body .homework-level { margin-bottom: 8px; }
        .detail-modal .modal-body pre { font-size: .9rem; line-height: 1.8; }
        @media (max-width: 600px) {
            .detail-modal { width: 100vw; max-width: 100vw; border-radius: 0; max-height: 100vh; }
            .detail-modal .modal-body { max-height: 80vh; padding: 14px 16px; }
        }
