        /* Dark Mode (Default) */
        :root {
            --background: #09090b;
            --surface: #18181b;
            --surface-highlight: #27272a;
            --primary: #3b82f6;
            --primary-hover: #2563eb;
            --primary-rgb: 59, 130, 246;
            --success: #10b981;
            --warning: #f59e0b;
            --accent: #8b5cf6;
            --accent-rgb: 139, 92, 246;
            --error: #ef4444;
            --text-primary: #fafafa;
            --text-secondary: #a1a1aa;
            --border-color: rgba(255, 255, 255, 0.08);
            --border-hover: rgba(255, 255, 255, 0.15);
            --glass-bg: rgba(24, 24, 27, 0.6);
            --glass-bg-hover: rgba(39, 39, 42, 0.7);
            --ai-icon-color: #14b8a6;
        }

        /* Light Mode */
        body[data-theme='light'],
        html[data-initial-theme='light'] {
            --background: #f5f5f5;
            --surface: #ffffff;
            --surface-highlight: #f0f0f0;
            --text-primary: #18181b;
            --text-secondary: #71717a;
            --border-color: rgba(0, 0, 0, 0.12);
            --border-hover: rgba(0, 0, 0, 0.2);
            --glass-bg: rgba(255, 255, 255, 0.95);
            --glass-bg-hover: rgba(255, 255, 255, 1);
            --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        }

        /* 浅色模式滚动条样式 */
        body[data-theme='light'],
        body[data-theme='light'] *,
        html:has(body[data-theme='light']) {
            scrollbar-color: #a1a1aa #e5e5e5;
        }

        body[data-theme='light']::-webkit-scrollbar,
        body[data-theme='light'] *::-webkit-scrollbar,
        html:has(body[data-theme='light'])::-webkit-scrollbar {
            width: 12px;
            background: #e5e5e5;
        }

        body[data-theme='light']::-webkit-scrollbar-track,
        body[data-theme='light'] *::-webkit-scrollbar-track,
        html:has(body[data-theme='light'])::-webkit-scrollbar-track {
            background: #e5e5e5;
        }

        body[data-theme='light']::-webkit-scrollbar-thumb,
        body[data-theme='light'] *::-webkit-scrollbar-thumb,
        html:has(body[data-theme='light'])::-webkit-scrollbar-thumb {
            background: #a1a1aa;
            border-radius: 6px;
            border: 2px solid #e5e5e5;
        }

        body[data-theme='light']::-webkit-scrollbar-thumb:hover,
        body[data-theme='light'] *::-webkit-scrollbar-thumb:hover {
            background: #71717a;
        }

        /* 深色模式滚动条样式 (默认) */
        html,
        body,
        * {
            scrollbar-color: #3f3f46 #18181b;
        }

        ::-webkit-scrollbar {
            width: 12px;
            background: #18181b;
        }

        ::-webkit-scrollbar-track {
            background: #18181b;
        }

        ::-webkit-scrollbar-thumb {
            background: #3f3f46;
            border-radius: 6px;
            border: 2px solid #18181b;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #52525b;
        }

        /* Enhanced card styles for light mode */
        body[data-theme='light'] .glass-panel,
        body[data-theme='light'] .card,
        body[data-theme='light'] .question-card,
        body[data-theme='light'] .quiz-card {
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        body[data-theme='light'] .glass-panel:hover,
        body[data-theme='light'] .quiz-card:hover {
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
            border-color: rgba(0, 0, 0, 0.15);
        }

        body[data-theme='light'] .modal-content {
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
            border: 1px solid rgba(0, 0, 0, 0.1);
        }

        /* Light mode scrollbar - more visible */
        body[data-theme='light']::-webkit-scrollbar {
            width: 12px;
            height: 12px;
        }

        body[data-theme='light']::-webkit-scrollbar-track {
            background: #e2e8f0 !important;
        }

        body[data-theme='light']::-webkit-scrollbar-thumb {
            background: #94a3b8 !important;
            border: 3px solid #e2e8f0 !important;
            border-radius: 10px;
        }

        body[data-theme='light']::-webkit-scrollbar-thumb:hover {
            background: #64748b !important;
        }

        body[data-theme='light'] * {
            scrollbar-width: auto;
            scrollbar-color: #94a3b8 #e2e8f0;
        }

        /* Hide scrollbar */
        .no-scrollbar::-webkit-scrollbar {
            display: none;
        }

        .no-scrollbar {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        /* Soft, Semi-Transparent Low-Saturation Scrollbar */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(148, 163, 184, 0.24);
            border-radius: 9999px;
            border: 1px solid transparent;
            background-clip: padding-box;
            transition: background 0.2s ease;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(148, 163, 184, 0.42);
            background-clip: padding-box;
        }

        /* Standard scrollbar (Firefox & Chromium 121+) */
        * {
            scrollbar-width: thin;
            scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
        }

        /* List View for Quiz Library */
        .list-view .quiz-card {
            flex-direction: row !important;
            align-items: center !important;
            min-height: auto !important;
            padding: 1rem 1.25rem !important;
            gap: 1rem;
        }

        .list-view .quiz-card>div:first-child {
            flex-direction: row !important;
            align-items: center;
            gap: 1rem;
            flex: 1;
        }

        .list-view .quiz-card .flex.gap-2.mt-auto {
            margin-top: 0 !important;
        }

        .list-view #createQuizCard {
            flex-direction: row !important;
            min-height: auto !important;
            padding: 1rem 1.25rem !important;
            gap: 1rem;
        }

        /* Base styles */
        body {
            font-family: 'Inter', system-ui, sans-serif;
            background-color: var(--background);
            color: var(--text-primary);
            transition: background-color 0.3s ease, color 0.3s ease;
            line-height: 1.6;
            min-height: 100vh;
        }

        /* Glass Panel - Core design element */
        /* Heatmap flicker animation (tech vibe, theme-aware) */
        @keyframes heatmapFlicker {
            0% { opacity: 0.25; background-color: rgba(var(--primary-rgb), 0.08); }
            50% { opacity: 0.85; background-color: rgba(var(--primary-rgb), 0.52); }
            100% { opacity: 0.3; background-color: rgba(var(--primary-rgb), 0.12); }
        }

        /* Today cell: border glow flow animation */
        .today-glow-cell {
            border: 1.5px solid rgba(var(--primary-rgb), 0.2) !important;
            background-clip: padding-box;
            animation: todayBorderFlow 3s linear infinite !important;
        }
        @keyframes todayBorderFlow {
            0%, 15%   { border-color: rgba(var(--primary-rgb), 0.95) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12); box-shadow: 0 -2px 4px rgba(var(--primary-rgb), 0.35); }
            25%, 40%  { border-color: rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.95) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12); box-shadow: 2px 0 4px rgba(var(--primary-rgb), 0.35); }
            50%, 65%  { border-color: rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.95) rgba(var(--primary-rgb), 0.12); box-shadow: 0 2px 4px rgba(var(--primary-rgb), 0.35); }
            75%, 90%  { border-color: rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.95); box-shadow: -2px 0 4px rgba(var(--primary-rgb), 0.35); }
            100%      { border-color: rgba(var(--primary-rgb), 0.95) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12) rgba(var(--primary-rgb), 0.12); box-shadow: 0 -2px 4px rgba(var(--primary-rgb), 0.35); }
        }

        .glass-panel {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
        }

        .glass-panel:hover {
            border-color: var(--border-hover);
            background: var(--glass-bg-hover);
        }

        /* Card styles */
        .card {
            background-color: var(--surface);
            border-radius: 16px;
            border: 1px solid var(--border-color);
            padding: 1.5rem;
            transition: all 0.3s ease;
        }

        /* Button styles */
        .btn {
            padding: 0.625rem 1.25rem;
            border-radius: 10px;
            font-weight: 500;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            cursor: pointer;
            border: 1px solid var(--border-color);
            background-color: transparent;
            color: var(--text-primary);
        }

        .btn:hover:not(:disabled) {
            background-color: var(--surface-highlight);
            border-color: var(--border-hover);
            transform: translateY(-1px);
        }

        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn-primary {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
            box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.25);
        }

        .btn-primary:hover:not(:disabled) {
            background: var(--primary-hover);
            border-color: var(--primary-hover);
            box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.35);
        }

        .btn-secondary {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--border-color);
        }

        .btn-red {
            background-color: rgba(239, 68, 68, 0.1);
            color: var(--error);
            border-color: var(--error);
        }

        .btn-red:hover:not(:disabled) {
            background-color: var(--error);
            color: white;
        }

        .btn-success {
            background-color: #10b981 !important;
            color: white !important;
            border-color: #10b981 !important;
        }

        .btn-success:hover:not(:disabled) {
            background-color: #059669 !important;
            border-color: #059669 !important;
        }

        .btn-sm {
            padding: 0.5rem 1rem;
            font-size: 0.875rem;
        }

        /* Short answer action buttons - always icon-only, equal width */
        .short-answer-camera-btn,
        .short-answer-upload-btn,
        .short-answer-handwrite-btn {
            width: 3rem;
            padding: 0.5rem !important;
            justify-content: center;
        }

        .short-answer-camera-btn .btn-text,
        .short-answer-upload-btn .btn-text,
        .short-answer-handwrite-btn .btn-text {
            display: none !important;
        }

        /* Mobile responsive - hide text, show only icons */
        @media (max-width: 480px) {
            .mobile-hide {
                display: none !important;
            }

            .btn-sm {
                padding: 0.5rem 0.75rem;
            }
        }

        /* Quiz Card (Bento Grid Item) */
        .quiz-card {
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .quiz-card:hover {
            transform: translateY(-4px);
        }

        /* Question Card */
        .question-card {
            background-color: var(--surface);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 1.5rem;
            margin-bottom: 1rem;
            position: relative;
            transition: all 0.3s ease;
        }

        .question-card.result-correct {
            border-left: 4px solid var(--success);
            background-color: rgba(16, 185, 129, 0.05);
        }

        .question-card.result-incorrect {
            border-left: 4px solid var(--error);
            background-color: rgba(239, 68, 68, 0.05);
        }

        .question-card.result-graded {
            border-left: 4px solid var(--ai-icon-color);
            background-color: rgba(20, 184, 166, 0.05);
        }

        /* Option styles */
        .option-item {
            display: flex;
            align-items: center;
            padding: 1rem;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background-color: var(--background);
            cursor: pointer;
            transition: all 0.2s ease;
            margin-bottom: 0.75rem;
        }

        .option-item:hover {
            background-color: var(--surface-highlight);
            border-color: var(--border-hover);
        }

        .option-item.selected {
            border-color: var(--primary);
            background-color: rgba(var(--primary-rgb), 0.1);
        }

        /* Fill-in-blank input */
        .fill-in-blank-input {
            border: 1px dashed var(--text-secondary);
            border-radius: 8px;
            padding: 0.4rem 0.8rem;
            margin: 0 0.25rem;
            width: 100px;
            text-align: center;
            background-color: var(--background);
            color: var(--text-primary);
            transition: all 0.3s ease;
        }

        .fill-in-blank-input:focus {
            outline: none;
            border-style: solid;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
        }

        .fill-in-blank-input.result-correct {
            border-color: var(--success);
            background-color: rgba(16, 185, 129, 0.1);
        }

        .fill-in-blank-input.result-incorrect {
            border-color: var(--error);
            background-color: rgba(239, 68, 68, 0.1);
        }

        .passage-block {
            margin-bottom: 1rem;
            padding: 1rem 1.1rem;
            border-radius: 14px;
            border: 1px solid var(--border-color);
            background: rgba(var(--primary-rgb), 0.08);
        }

        .passage-block__title {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 0.7rem;
        }

        .passage-block__content {
            line-height: 1.8;
            color: var(--text-primary);
            word-break: break-word;
        }

        .word-bank-panel {
            margin-bottom: 1rem;
            padding: 1rem;
            border-radius: 14px;
            border: 1px solid var(--border-color);
            background: rgba(139, 92, 246, 0.08);
        }

        .word-bank-panel__title {
            font-size: 0.85rem;
            font-weight: 700;
            color: var(--accent);
            margin-bottom: 0.75rem;
        }

        .word-bank-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 0.55rem;
        }

        .word-bank-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.42rem 0.72rem;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid var(--border-color);
            font-size: 0.9rem;
        }

        .word-bank-chip__key {
            font-weight: 700;
            color: var(--accent);
        }

        .word-bank-fill-list {
            display: flex;
            flex-direction: column;
            gap: 0.9rem;
            margin-top: 0.75rem;
        }

        .word-bank-fill-item {
            padding: 0.9rem 1rem;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            background: var(--background);
            line-height: 1.8;
        }

        .word-bank-fill-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 1.7rem;
            height: 1.7rem;
            border-radius: 999px;
            margin-right: 0.6rem;
            font-size: 0.8rem;
            font-weight: 700;
            color: white;
            background: var(--primary);
        }

        .word-bank-select {
            min-width: 138px;
            max-width: 100%;
            padding: 0.45rem 0.7rem;
            margin: 0 0.3rem;
            border-radius: 9px;
            border: 1px dashed var(--text-secondary);
            background: var(--surface);
            color: var(--text-primary);
            vertical-align: middle;
        }

        .word-bank-select:focus {
            outline: none;
            border-style: solid;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
        }

        .word-bank-select.result-correct {
            border-color: var(--success);
            background-color: rgba(16, 185, 129, 0.1);
        }

        .word-bank-select.result-incorrect {
            border-color: var(--error);
            background-color: rgba(239, 68, 68, 0.1);
        }

        .word-bank-passage {
            line-height: 1.95;
            word-break: break-word;
        }

        /* Short Answer Textarea */
        .short-answer-textarea {
            width: 100%;
            min-height: 120px;
            padding: 1rem;
            border: 1px solid var(--border-color);
            border-radius: 12px;
            background-color: var(--background);
            color: var(--text-primary);
            resize: vertical;
            transition: all 0.3s ease;
        }

        .short-answer-textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
        }

        /* Progress tracker */
        .progress-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 0.5rem;
            max-height: 300px;
            overflow-y: scroll;
            scrollbar-gutter: stable;
            padding-right: 4px;
        }

        .progress-button {
            width: 100%;
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 0.875rem;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.2s ease;
            border: 1px solid var(--border-color);
            background-color: var(--surface);
            color: var(--text-primary);
        }

        .progress-button:hover {
            transform: scale(1.05);
        }

        .progress-button.status-answered {
            background-color: var(--surface-highlight);
            color: var(--text-secondary);
            border-color: var(--text-secondary);
        }

        .progress-button.status-correct {
            background-color: rgba(16, 185, 129, 0.15);
            color: var(--success);
            border-color: var(--success);
        }

        .progress-button.status-incorrect {
            background-color: rgba(239, 68, 68, 0.15);
            color: var(--error);
            border-color: var(--error);
        }

        .progress-button.status-graded {
            background-color: rgba(20, 184, 166, 0.15);
            color: var(--ai-icon-color);
            border-color: var(--ai-icon-color);
        }

        /* Peek answer button - subtle helper */
        .peek-answer-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            padding: 0.25rem 0.5rem;
            font-size: 0.7rem;
            color: var(--text-secondary);
            background: transparent;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            opacity: 0.5;
            transition: all 0.2s ease;
        }

        .peek-answer-btn:hover {
            opacity: 1;
            color: var(--text-primary);
            border-color: var(--text-secondary);
            background: var(--surface-highlight);
        }

        /* AI Explanation content */
        .ai-explanation-content,
        .ai-grading-feedback {
            margin-top: 1rem;
            padding: 1rem;
            border-radius: 12px;
            background-color: var(--surface-highlight);
            border: 1px solid var(--border-color);
            color: var(--text-secondary);
            font-size: 0.9rem;
            line-height: 1.7;
        }

        .ai-grading-feedback {
            color: var(--text-primary);
        }

        .ai-grading-feedback strong {
            color: var(--ai-icon-color);
        }

        /* Modal */
        body:has(.modal-overlay:not(.hidden):not(.ai-chat-compact)) {
            overflow: hidden;
        }

        .modal-overlay {
            position: fixed;
            inset: 0;
            background-color: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 100;
            overscroll-behavior: contain;
        }

        .modal-content {
            background-color: var(--surface);
            padding: 2rem;
            border-radius: 20px;
            width: 100%;
            max-width: 480px;
            max-height: 90vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            scrollbar-width: thin;
            clip-path: inset(0 round 20px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
            border: 1px solid var(--border-color);
            position: relative;
        }

        /* Scrollbar styling */
        .modal-content::-webkit-scrollbar {
            width: 5px;
        }
        .modal-content::-webkit-scrollbar-track {
            background: transparent;
        }
        .modal-content::-webkit-scrollbar-thumb {
            background: rgba(148, 163, 184, 0.24);
            border-radius: 9999px;
        }
        .modal-content::-webkit-scrollbar-thumb:hover {
            background: rgba(148, 163, 184, 0.42);
        }
        .modal-content {
            scrollbar-width: thin;
            scrollbar-color: rgba(148, 163, 184, 0.24) transparent;
        }

        /* DeepSeek Web Chat Style Tokens, Sider & Responsive Layout */
        #aiAssistantModal {
            --ds-bg-base: rgb(21, 21, 23);
            --ds-bg-elevated: rgb(44, 44, 46);
            --ds-sider-bg: rgb(27, 27, 28);
            --ds-sider-hover: rgb(44, 44, 46);
            --ds-sider-active: rgb(53, 54, 56);
            --ds-sider-btn-bg: rgb(67, 69, 74);
            --ds-bubble-user: rgb(44, 44, 46);
            --ds-brand: rgb(86, 134, 254);
            --ds-brand-hover: rgb(57, 100, 254);
            --ds-brand-text: rgb(103, 158, 254);
            --ds-text-primary: rgb(249, 250, 251);
            --ds-text-secondary: rgb(207, 211, 214);
            --ds-text-tertiary: rgb(173, 178, 184);
            --ds-text-caption: rgb(129, 133, 140);
            --ds-border-l1: rgba(255, 255, 255, 0.06);
            --ds-border-l2: rgba(255, 255, 255, 0.12);
            --ds-hover-bg: rgba(255, 255, 255, 0.08);
            --ds-code-bg: rgb(27, 27, 28);
            --ds-scroll-color: rgba(255, 255, 255, 0.15);
            --ds-shadow-input: 0 4px 12px rgba(0, 0, 0, 0.18);
            --ds-shadow-newchat: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.18);
        }

        body[data-theme='light'] #aiAssistantModal,
        html[data-initial-theme='light'] #aiAssistantModal {
            --ds-bg-base: #ffffff;
            --ds-bg-elevated: #ffffff;
            --ds-sider-bg: rgb(249, 250, 251);
            --ds-sider-hover: rgb(241, 243, 245);
            --ds-sider-active: rgb(211, 226, 255);
            --ds-sider-btn-bg: #ffffff;
            --ds-bubble-user: rgb(237, 243, 254);
            --ds-brand: rgb(57, 100, 254);
            --ds-brand-hover: rgb(86, 134, 254);
            --ds-brand-text: rgb(57, 100, 254);
            --ds-text-primary: rgb(15, 17, 21);
            --ds-text-secondary: rgb(97, 102, 107);
            --ds-text-tertiary: rgb(129, 133, 140);
            --ds-text-caption: rgb(173, 178, 184);
            --ds-border-l1: rgba(15, 23, 42, 0.09);
            --ds-border-l2: rgba(15, 23, 42, 0.16);
            --ds-hover-bg: rgba(38, 49, 72, 0.06);
            --ds-code-bg: rgb(246, 248, 250);
            --ds-scroll-color: rgba(0, 0, 0, 0.08);
            --ds-shadow-input: 0 4px 10px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.04);
            --ds-shadow-newchat: 0 -2px 2px rgba(72, 104, 178, 0.04), 0 2px 2px rgba(106, 111, 117, 0.09), 0 1px 2px rgba(72, 104, 178, 0.08);
        }

        .ai-chat-overlay {
            padding: 0;
            background: var(--ds-bg-base);
            z-index: 1100 !important;
        }

        .ai-chat-shell {
            position: relative;
            width: 100vw;
            height: 100dvh;
            display: flex;
            flex-direction: row;
            background: var(--ds-bg-base);
            color: var(--ds-text-primary);
            overflow: hidden;
            transition: width 0.22s ease, height 0.22s ease, border-radius 0.22s ease;
        }

        @media (min-width: 768px) {
            .ai-chat-overlay.ai-chat-compact:not(.hidden) {
                background: transparent !important;
                backdrop-filter: none !important;
                -webkit-backdrop-filter: none !important;
                pointer-events: none;
                display: flex;
                justify-content: flex-end;
                align-items: flex-end;
                padding: 1.5rem;
            }
            .ai-chat-overlay.ai-chat-compact .ai-chat-shell {
                pointer-events: auto;
                width: 420px;
                max-width: calc(100vw - 2rem);
                height: min(640px, calc(100dvh - 3rem));
                border-radius: 18px;
                border: 1px solid var(--ds-border-l1);
                box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
            }
            .ai-chat-overlay.ai-chat-compact .ai-chat-sider {
                position: absolute;
                left: 0;
                top: 0;
                bottom: 0;
                width: 250px;
                transform: translateX(-100%);
                box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);
            }
            .ai-chat-overlay.ai-chat-compact .ai-chat-shell.mobile-sider-open .ai-chat-sider {
                transform: translateX(0);
            }
            .ai-chat-overlay.ai-chat-compact .ai-chat-shell.mobile-sider-open .ai-chat-sider-mask {
                display: block;
            }
            .ai-chat-overlay.ai-chat-compact .ai-chat-sider-open-btn {
                display: inline-flex !important;
            }
        }

        @media (max-width: 767px) {
            #aiToggleExpandBtn {
                display: none;
            }
        }

        /* Left History Sidebar (Desktop fixed, Mobile drawer) */
        .ai-chat-sider {
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            box-sizing: border-box;
            width: 261px;
            height: 100%;
            padding: 6px 12px 10px;
            border-right: 1px solid var(--ds-border-l1);
            background: var(--ds-sider-bg);
            transition: width 0.2s ease, padding 0.2s ease, transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
            overflow: hidden;
            z-index: 40;
        }

        .ai-chat-shell.sider-collapsed .ai-chat-sider {
            width: 0;
            padding-left: 0;
            padding-right: 0;
            border-right-color: transparent;
        }

        .ai-chat-sider-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            height: 48px;
            margin-bottom: 12px;
            padding: 10px 2px 6px 6px;
            box-sizing: border-box;
            flex-shrink: 0;
        }

        .ai-chat-sider-title {
            font-size: 18px;
            line-height: 22px;
            font-weight: 600;
            color: var(--primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        #aiBrandGrokSvg,
        #aiBrandGrokSvg * {
            animation: none !important;
            transition: none !important;
        }

        /* Smooth theme transition without page reload */
        html.theme-switching,
        html.theme-switching body,
        html.theme-switching .card,
        html.theme-switching .modal-content,
        html.theme-switching nav,
        html.theme-switching .ai-chat-shell,
        html.theme-switching .ai-chat-sider,
        html.theme-switching .ai-chat-header,
        html.theme-switching .ai-chat-input-box,
        html.theme-switching .auth-page-overlay,
        html.theme-switching .auth-card {
            transition: background-color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                        color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                        border-color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                        box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1) !important;
        }

        /* History & Answer Details Redesign */
        html.details-page-open,
        body.details-page-open {
            overflow: hidden !important;
            height: 100vh !important;
        }

        .rq-history-card {
            padding: 16px 18px;
            border-radius: 14px;
            background: var(--surface-highlight);
            border: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            gap: 12px;
            transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
        }

        .rq-history-card:hover {
            border-color: rgba(var(--primary-rgb), 0.35);
            box-shadow: 0 8px 24px -16px rgba(0, 0, 0, 0.25);
        }

        .rq-history-top {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
        }

        .rq-history-title-row {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .rq-history-quiz-name {
            font-size: 15px;
            font-weight: 600;
            color: var(--text-primary);
            line-height: 1.35;
        }

        .rq-history-score-pill {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 2px 9px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 600;
            font-variant-numeric: tabular-nums;
        }

        .rq-history-meta {
            margin-top: 4px;
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .rq-history-del-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 30px;
            height: 30px;
            border-radius: 8px;
            border: 1px solid transparent;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            flex-shrink: 0;
            transition: all 0.18s ease;
        }

        .rq-history-del-btn:hover {
            color: var(--error-color);
            background: rgba(239, 68, 68, 0.1);
            border-color: rgba(239, 68, 68, 0.25);
        }

        .rq-details-page {
            position: fixed;
            inset: 0;
            z-index: 900;
            background: var(--background);
            overflow-y: auto;
            scrollbar-gutter: stable;
        }

        .rq-details-topbar {
            position: sticky;
            top: 0;
            z-index: 20;
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            background: rgba(15, 17, 23, 0.82);
            border-bottom: 1px solid var(--border-color);
        }

        [data-theme="light"] .rq-details-topbar {
            background: rgba(250, 250, 252, 0.86);
        }

        .rq-details-topbar-inner {
            max-width: 860px;
            margin: 0 auto;
            padding: 12px 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            flex-wrap: wrap;
        }

        .rq-details-filters {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px;
            border-radius: 10px;
            background: var(--surface-highlight);
            border: 1px solid var(--border-color);
        }

        .rq-filter-pill {
            padding: 5px 11px;
            border-radius: 7px;
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all 0.18s ease;
        }

        .rq-filter-pill.active {
            background: var(--primary);
            color: #ffffff;
        }

        .rq-details-body {
            max-width: 860px;
            margin: 0 auto;
            padding: 20px 16px 64px;
        }

        .rq-details-summary {
            padding: 18px 20px;
            border-radius: 16px;
            background: var(--surface);
            border: 1px solid var(--border-color);
            margin-bottom: 18px;
        }

        .rq-details-progress-track {
            height: 5px;
            width: 100%;
            border-radius: 999px;
            background: var(--surface-highlight);
            overflow: hidden;
            margin: 12px 0 14px;
        }

        .rq-details-progress-fill {
            height: 100%;
            border-radius: 999px;
            background: var(--primary);
            transition: width 0.35s ease;
        }

        .rq-details-nav-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .rq-details-nav-dot {
            min-width: 28px;
            height: 26px;
            padding: 0 6px;
            border-radius: 7px;
            font-size: 11.5px;
            font-weight: 600;
            font-variant-numeric: tabular-nums;
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: transform 0.15s ease, opacity 0.15s ease;
        }

        .rq-details-nav-dot:hover {
            transform: translateY(-1px);
        }

        .rq-details-nav-dot.is-correct {
            background: rgba(34, 197, 94, 0.12);
            border-color: rgba(34, 197, 94, 0.3);
            color: var(--success-color);
        }

        .rq-details-nav-dot.is-incorrect {
            background: rgba(239, 68, 68, 0.12);
            border-color: rgba(239, 68, 68, 0.32);
            color: var(--error-color);
        }

        .rq-detail-q-card {
            padding: 18px 20px;
            border-radius: 16px;
            background: var(--surface);
            border: 1px solid var(--border-color);
            margin-bottom: 14px;
        }

        .rq-detail-q-card.is-incorrect {
            border-color: rgba(239, 68, 68, 0.28);
        }

        .rq-detail-ans-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 14px;
            padding-top: 14px;
            border-top: 1px solid var(--border-color);
        }

        @media (max-width: 640px) {
            .rq-detail-ans-grid {
                grid-template-columns: 1fr;
            }
            .rq-details-topbar-inner {
                padding: 10px 12px;
            }
        }

        /* Unified Modern Dialog System (Alert / Confirm / Prompt) */
        .rq-dialog-overlay {
            position: fixed;
            inset: 0;
            z-index: 1200;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px;
            background: rgba(9, 12, 18, 0.52);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            opacity: 0;
            transition: opacity 0.18s ease;
        }

        [data-theme="light"] .rq-dialog-overlay {
            background: rgba(15, 23, 42, 0.28);
        }

        .rq-dialog-overlay.open {
            opacity: 1;
        }

        .rq-dialog-card {
            width: min(392px, calc(100vw - 32px));
            border-radius: 18px;
            padding: 22px;
            background: var(--surface);
            border: 1px solid var(--border-color);
            box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.36);
            transform: translateY(8px) scale(0.97);
            transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
        }

        [data-theme="light"] .rq-dialog-card {
            box-shadow: 0 24px 48px -16px rgba(15, 23, 42, 0.16);
        }

        .rq-dialog-overlay.open .rq-dialog-card {
            transform: translateY(0) scale(1);
        }

        .rq-dialog-head {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 8px;
        }

        .rq-dialog-icon {
            width: 38px;
            height: 38px;
            border-radius: 11px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            background: rgba(var(--primary-rgb), 0.12);
            color: var(--primary);
        }

        .rq-dialog-icon.is-danger {
            background: rgba(239, 68, 68, 0.12);
            color: var(--error-color);
        }

        .rq-dialog-title {
            font-size: 16px;
            font-weight: 700;
            color: var(--text-primary);
            line-height: 1.3;
            margin: 0;
        }

        .rq-dialog-body {
            font-size: 13.5px;
            line-height: 1.6;
            color: var(--text-secondary);
            padding-left: 50px;
            word-break: break-word;
        }

        .rq-dialog-input {
            width: 100%;
            margin-top: 12px;
            padding: 10px 12px;
            border-radius: 11px;
            border: 1px solid var(--border-color);
            background: var(--surface-highlight);
            color: var(--text-primary);
            font-size: 14px;
            outline: none;
            transition: border-color 0.18s ease, box-shadow 0.18s ease;
        }

        .rq-dialog-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.16);
        }

        .rq-dialog-error {
            margin-top: 6px;
            font-size: 12px;
            color: var(--error-color);
            min-height: 16px;
        }

        .rq-dialog-actions {
            margin-top: 18px;
            padding-top: 14px;
            border-top: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 8px;
        }

        .rq-dialog-actions .btn {
            min-height: 38px;
            padding: 0 16px;
            border-radius: 10px;
            font-size: 13.5px;
            font-weight: 600;
        }

        .rq-dialog-card .btn-primary {
            background: var(--primary) !important;
            color: #ffffff !important;
            border-color: var(--primary) !important;
        }

        .rq-dialog-card .rq-dialog-btn-danger {
            background: var(--error-color) !important;
            color: #ffffff !important;
            border-color: var(--error-color) !important;
        }

        .rq-dialog-card .rq-dialog-btn-danger:hover {
            filter: brightness(1.06);
        }

        @media (max-width: 480px) {
            .rq-dialog-overlay {
                align-items: flex-end;
                padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
            }
            .rq-dialog-card {
                width: 100%;
                border-radius: 20px;
                padding: 20px 18px;
                transform: translateY(20px);
            }
            .rq-dialog-body {
                padding-left: 0;
                margin-top: 4px;
            }
            .rq-dialog-actions {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 10px;
            }
            .rq-dialog-actions.single-action {
                grid-template-columns: 1fr;
            }
            .rq-dialog-actions .btn {
                width: 100%;
                min-height: 42px;
            }
        }

        /* Import Section Polish */
        .rq-inline-code {
            display: inline-block;
            padding: 1px 6px;
            border-radius: 5px;
            font-size: 11.5px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            background: rgba(var(--primary-rgb), 0.12);
            color: var(--primary);
            margin: 1px 2px;
        }

        .rq-slim-scroll {
            scrollbar-width: thin;
            scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
        }

        .rq-slim-scroll::-webkit-scrollbar {
            width: 5px;
            height: 5px;
        }

        .rq-slim-scroll::-webkit-scrollbar-track {
            background: transparent;
        }

        .rq-slim-scroll::-webkit-scrollbar-thumb {
            background: rgba(148, 163, 184, 0.24);
            border-radius: 999px;
        }

        .rq-slim-scroll::-webkit-scrollbar-thumb:hover {
            background: rgba(148, 163, 184, 0.42);
        }

        .rq-import-textarea {
            width: 100%;
            min-height: 360px;
            padding: 2.25rem 1rem 1rem;
            border-radius: 14px;
            border: 1px solid var(--border-color);
            background: var(--surface-highlight);
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.65;
            resize: vertical;
            outline: none;
            transition: border-color 0.18s ease, box-shadow 0.18s ease;
        }

        .rq-import-textarea:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.14);
        }

        @media (max-width: 1023px) {
            .rq-import-textarea {
                min-height: 240px;
            }
        }

        .ai-chat-new-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            flex-shrink: 0;
            width: 100%;
            height: 40px;
            padding: 0 16px;
            border-radius: 100px;
            border: 1px solid transparent;
            background: var(--ds-sider-btn-bg);
            color: var(--ds-text-primary);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            user-select: none;
            box-shadow: var(--ds-shadow-newchat);
            transition: box-shadow 0.25s ease, opacity 0.2s ease;
            white-space: nowrap;
        }

        .ai-chat-new-btn:hover {
            opacity: 0.92;
        }

        .ai-chat-sider-list {
            flex: 1;
            min-height: 0;
            margin: 18px -2px 0;
            padding: 0 2px;
            overflow-y: auto;
            scrollbar-color: var(--ds-scroll-color) transparent;
        }

        .ai-chat-sider-empty {
            padding: 28px 12px;
            text-align: center;
            font-size: 12px;
            line-height: 18px;
            color: var(--ds-text-caption);
        }

        .ai-chat-sider-section {
            position: relative;
            margin-top: 14px;
        }

        .ai-chat-sider-section:first-child {
            margin-top: 0;
        }

        .ai-chat-sider-section-header {
            position: sticky;
            top: 0;
            z-index: 2;
            padding: 4px 10px;
            font-size: 12px;
            line-height: 18px;
            font-weight: 500;
            color: var(--ds-text-tertiary);
            background: var(--ds-sider-bg);
            user-select: none;
        }

        .ai-chat-session-item {
            position: relative;
            display: flex;
            align-items: center;
            box-sizing: border-box;
            height: 40px;
            padding: 0 6px 0 10px;
            border-radius: 12px;
            font-size: 14px;
            line-height: 22px;
            color: var(--ds-text-primary);
            cursor: pointer;
            transition: background-color 0.15s ease;
        }

        .ai-chat-session-item:hover {
            background: var(--ds-sider-hover);
        }

        .ai-chat-session-item.active {
            background: var(--ds-sider-active);
        }

        .ai-chat-session-title {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            line-height: 20px;
        }

        .ai-chat-session-actions {
            display: none;
            align-items: center;
            gap: 2px;
            flex-shrink: 0;
            margin-left: 4px;
        }

        .ai-chat-session-item:hover .ai-chat-session-actions,
        .ai-chat-session-item.active .ai-chat-session-actions {
            display: flex;
        }

        .ai-chat-session-act-btn {
            width: 26px;
            height: 26px;
            border: none;
            border-radius: 7px;
            background: transparent;
            color: var(--ds-text-tertiary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .ai-chat-session-act-btn:hover {
            background: var(--ds-hover-bg);
            color: var(--ds-text-primary);
        }

        .ai-chat-sider-footer {
            flex-shrink: 0;
            padding: 10px 8px 4px;
            border-top: 1px solid var(--ds-border-l1);
            font-size: 11px;
            line-height: 16px;
            color: var(--ds-text-caption);
            display: flex;
            align-items: center;
            gap: 6px;
            white-space: nowrap;
        }

        .ai-chat-sider-mask {
            display: none;
            position: absolute;
            inset: 0;
            z-index: 35;
            background: rgba(0, 0, 0, 0.45);
        }

        /* Main Right Container */
        .ai-chat-main-wrap {
            flex: 1;
            min-width: 0;
            height: 100%;
            display: flex;
            flex-direction: column;
            background: var(--ds-bg-base);
        }

        .ai-chat-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            height: 56px;
            padding: 8px 16px;
            box-sizing: border-box;
            flex-shrink: 0;
            background: var(--ds-bg-base);
        }

        .ai-chat-brand {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
        }

        .ai-chat-brand-icon {
            width: 30px;
            height: 30px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            flex-shrink: 0;
            overflow: visible;
        }

        .ai-chat-brand-icon svg {
            width: 30px;
            height: 30px;
            overflow: visible;
        }

        .ai-chat-msg-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            width: 100%;
        }

        .ai-chat-msg-avatar {
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            flex-shrink: 0;
            margin-top: 2px;
            overflow: visible;
        }

        .ai-chat-msg-avatar svg {
            width: 28px;
            height: 28px;
            overflow: visible;
        }

        .ai-chat-brand-copy {
            min-width: 0;
        }

        .ai-chat-brand-copy h3 {
            margin: 0;
            font-size: 14px;
            line-height: 22px;
            font-weight: 600;
            color: var(--ds-text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .ai-chat-header-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-shrink: 0;
        }

        .ai-chat-icon-btn {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            border: none;
            background: transparent;
            color: var(--ds-text-secondary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s ease, color 0.2s ease;
        }

        .ai-chat-icon-btn:hover {
            background: var(--ds-hover-bg);
            color: var(--ds-text-primary);
        }

        .ai-chat-sider-open-btn {
            display: none;
        }

        .ai-chat-shell.sider-collapsed .ai-chat-sider-open-btn {
            display: inline-flex;
        }

        .ai-chat-main {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overscroll-behavior-y: contain;
            scrollbar-gutter: stable both-edges;
            scrollbar-color: var(--ds-scroll-color) transparent;
            padding: 0 24px;
        }

        .ai-chat-thread {
            width: min(100%, 752px);
            margin: 0 auto;
            padding: 16px 0 32px;
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .ai-chat-empty {
            width: min(100%, 752px);
            margin: 0 auto;
            min-height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 24px 0 40px;
            box-sizing: border-box;
            text-align: center;
        }

        .ai-chat-empty-card {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .ai-chat-empty-logo {
            width: 68px;
            height: 68px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            box-shadow: none;
            margin-bottom: 18px;
            overflow: visible;
        }

        .ai-chat-empty-logo svg {
            width: 68px;
            height: 68px;
            overflow: visible;
        }

        .ai-chat-empty-card h4 {
            margin: 0;
            font-size: 24px;
            line-height: 32px;
            font-weight: 600;
            color: var(--ds-text-primary);
        }

        .ai-chat-empty-card p {
            margin: 10px 0 0;
            max-width: 520px;
            font-size: 14px;
            line-height: 22px;
            color: var(--ds-text-tertiary);
        }

        .ai-chat-empty-grid {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
            margin-top: 22px;
            max-width: 640px;
        }

        .ai-chat-empty-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 14px;
            border-radius: 100px;
            border: 1px solid var(--ds-border-l2);
            background: transparent;
            color: var(--ds-text-secondary);
            font-size: 13px;
            line-height: 20px;
            cursor: pointer;
            transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
        }

        .ai-chat-empty-pill:hover {
            background: var(--ds-hover-bg);
            color: var(--ds-text-primary);
        }

        .ai-chat-message {
            display: flex;
            flex-direction: column;
            width: 100%;
        }

        .ai-chat-message.user {
            align-items: flex-end;
        }

        .ai-chat-message.assistant {
            align-items: flex-start;
        }

        .ai-chat-bubble-wrap {
            width: 100%;
            min-width: 0;
            display: flex;
            flex-direction: column;
        }

        .ai-chat-message.user .ai-chat-bubble-wrap {
            align-items: flex-end;
        }

        .ai-chat-bubble {
            font-size: 16px;
            line-height: 28px;
            color: var(--ds-text-primary);
            overflow-wrap: anywhere;
            word-break: break-word;
        }

        .ai-chat-message.user .ai-chat-bubble {
            max-width: min(calc(100% - 72px), 620px);
            box-sizing: border-box;
            padding: 10px 16px;
            border-radius: 22px;
            line-height: 24px;
            background: var(--ds-bubble-user);
            color: var(--ds-text-primary);
            white-space: pre-wrap;
        }

        .ai-chat-message.assistant .ai-chat-bubble {
            width: 100%;
            padding: 2px 0;
            background: transparent;
            border: none;
            box-shadow: none;
        }

        .ai-chat-bubble img {
            display: block;
            max-width: min(100%, 260px);
            border-radius: 14px;
            margin-top: 10px;
            border: 1px solid var(--ds-border-l2);
        }

        .ai-chat-bubble .prose {
            max-width: none;
            color: var(--ds-text-primary);
            font-size: 15px;
            line-height: 1.62;
        }

        .ai-chat-bubble .prose p {
            margin: 6px 0;
        }

        .ai-chat-bubble .prose .ai-md-gap {
            height: 7px;
        }

        .ai-chat-bubble .prose h1,
        .ai-chat-bubble .prose h2,
        .ai-chat-bubble .prose h3,
        .ai-chat-bubble .prose h4 {
            margin: 10px 0 4px;
            line-height: 1.4;
        }

        .ai-chat-bubble .prose ul,
        .ai-chat-bubble .prose ol {
            margin: 6px 0;
            padding-left: 1.35rem;
        }

        .ai-chat-bubble .prose li {
            margin: 2px 0;
        }

        .ai-chat-bubble .katex-display {
            margin: 8px 0;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 2px 0;
        }

        /* DeepSeek-style Collapsible Thinking Block */
        .ds-think-block {
            margin-bottom: 10px;
        }

        .ds-think-summary {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            line-height: 22px;
            color: var(--ds-text-tertiary);
            cursor: pointer;
            user-select: none;
            list-style: none;
            padding: 2px 0;
            transition: color 0.18s ease;
        }

        .ds-think-summary::-webkit-details-marker {
            display: none;
        }

        .ds-think-summary:hover {
            color: var(--ds-text-secondary);
        }

        .ds-think-chevron {
            display: inline-block;
            font-size: 11px;
            transition: transform 0.18s ease;
        }

        .ds-think-block[open] > .ds-think-summary .ds-think-chevron {
            transform: rotate(90deg);
        }

        .ds-think-summary.is-thinking .ds-think-title {
            color: transparent;
            background: linear-gradient(90deg, var(--ds-text-tertiary) 0%, var(--ds-text-tertiary) 40%, var(--ds-text-primary) 50%, var(--ds-text-tertiary) 60%, var(--ds-text-tertiary) 100%) 0 0 / 300% 100%;
            background-clip: text;
            -webkit-background-clip: text;
            animation: dsThinkShimmer 2s ease-out infinite;
        }

        @keyframes dsThinkShimmer {
            from { background-position: 100% 0; }
            to { background-position: 0 0; }
        }

        .ds-think-body {
            margin-top: 4px;
            padding: 2px 0 2px 12px;
            border-left: 2px solid var(--ds-border-l2);
            font-size: 13.5px;
            line-height: 1.55;
            color: var(--ds-text-tertiary);
        }

        .ds-think-body .prose {
            font-size: 13.5px;
            line-height: 1.55;
            color: var(--ds-text-tertiary);
        }

        .ds-think-body .prose strong {
            color: var(--ds-text-secondary);
        }

        .ai-chat-bubble .prose > *:first-child {
            margin-top: 0;
        }

        .ai-chat-bubble .prose > *:last-child {
            margin-bottom: 0;
        }

        .ai-chat-bubble .prose strong {
            color: var(--ds-text-primary);
            font-weight: 600;
        }

        .ai-chat-bubble .prose pre {
            background: var(--ds-code-bg);
            border: 1px solid var(--ds-border-l1);
            border-radius: 12px;
            padding: 12px 14px;
            overflow-x: auto;
        }

        .ai-chat-bubble .prose code:not(pre code) {
            background: var(--ds-code-bg);
            border: 1px solid var(--ds-border-l1);
            border-radius: 6px;
            padding: 0.12em 0.4em;
            font-size: 0.88em;
            color: var(--ds-text-primary);
        }

        .ai-chat-bubble .prose table {
            width: 100%;
            border-collapse: collapse;
            margin: 10px 0;
            font-size: 0.9em;
            border: 1px solid var(--ds-border-l2);
            border-radius: 8px;
            overflow: hidden;
        }

        .ai-chat-bubble .prose th,
        .ai-chat-bubble .prose td {
            border: 1px solid var(--ds-border-l1);
            padding: 7px 10px;
            text-align: left;
            color: var(--ds-text-primary);
        }

        .ai-chat-bubble .prose th {
            background: var(--ds-code-bg);
            font-weight: 600;
        }

        .ai-chat-bubble .prose blockquote {
            margin: 10px 0;
            padding: 6px 12px;
            border-left: 3px solid var(--ds-brand);
            background: var(--ds-code-bg);
            color: var(--ds-text-secondary);
            border-radius: 0 8px 8px 0;
        }

        .ai-chat-bubble .prose hr {
            border: none;
            border-top: 1px solid var(--ds-border-l2);
            margin: 12px 0;
        }

        .ai-chat-sider-footer {
            padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        }

        @supports (padding: env(safe-area-inset-bottom)) {
            body {
                padding-bottom: env(safe-area-inset-bottom, 0px);
            }
            #floatingAiBtn {
                margin-bottom: env(safe-area-inset-bottom, 0px);
            }
        }

        .ai-chat-msg-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-top: 6px;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .ai-chat-message:hover .ai-chat-msg-actions,
        .ai-chat-message:focus-within .ai-chat-msg-actions {
            opacity: 1;
        }

        .ai-chat-action-btn {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            height: 28px;
            padding: 0 8px;
            border: none;
            border-radius: 8px;
            background: transparent;
            color: var(--ds-text-tertiary);
            font-size: 12px;
            cursor: pointer;
            transition: background-color 0.2s ease, color 0.2s ease;
        }

        .ai-chat-action-btn:hover {
            background: var(--ds-hover-bg);
            color: var(--ds-text-primary);
        }

        .ai-chat-loading {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            height: 34px;
        }

        .ai-chat-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background-color: var(--ds-text-tertiary);
            animation: aiChatDotFade 0.9s linear infinite;
        }

        .ai-chat-dot:nth-child(2) {
            animation-delay: 0.15s;
        }

        .ai-chat-dot:nth-child(3) {
            animation-delay: 0.3s;
        }

        @keyframes aiChatDotFade {
            0%, 100% { opacity: 0.25; }
            33%, 66% { opacity: 1; }
        }

        .ai-chat-composer {
            position: sticky;
            bottom: 0;
            z-index: 10;
            flex-shrink: 0;
            width: 100%;
            box-sizing: border-box;
            padding: 0 16px calc(6px + env(safe-area-inset-bottom, 0px));
            background: linear-gradient(
                to bottom,
                transparent 0%,
                transparent 28%,
                var(--ds-bg-base) 28%,
                var(--ds-bg-base) 100%
            );
        }

        .ai-chat-composer-inner {
            width: min(100%, 776px);
            margin: 0 auto;
        }

        .ai-chat-composer-box {
            display: flex;
            flex-direction: column;
            box-sizing: border-box;
            width: 100%;
            border-radius: 24px;
            border: 1px solid var(--ds-border-l2);
            background: var(--ds-bg-elevated);
            box-shadow: var(--ds-shadow-input);
            overflow: hidden;
            transition: border-color 0.2s ease;
        }

        .ai-chat-composer-box:focus-within {
            border-color: color-mix(in srgb, var(--ds-brand) 50%, var(--ds-border-l2));
        }

        .ai-chat-image-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin: 12px 12px 0;
            padding: 8px 10px;
            border-radius: 14px;
            background: var(--ds-hover-bg);
            border: 1px solid var(--ds-border-l1);
        }

        .ai-chat-image-row img {
            width: 48px;
            height: 48px;
            object-fit: cover;
            border-radius: 10px;
            border: 1px solid var(--ds-border-l2);
            flex-shrink: 0;
        }

        .ai-chat-image-meta {
            min-width: 0;
            flex: 1;
        }

        .ai-chat-image-meta strong {
            display: block;
            font-size: 13px;
            color: var(--ds-text-primary);
        }

        .ai-chat-image-meta span {
            display: block;
            margin-top: 2px;
            font-size: 12px;
            color: var(--ds-text-tertiary);
        }

        .ai-chat-input {
            display: block;
            width: 100%;
            box-sizing: border-box;
            min-height: 52px;
            max-height: 200px;
            resize: none;
            border: none;
            background: transparent;
            color: var(--ds-text-primary);
            caret-color: var(--ds-brand);
            font-family: inherit;
            font-size: 16px;
            line-height: 24px;
            padding: 12px 16px 4px;
            overflow-y: auto;
        }

        .ai-chat-input::placeholder {
            color: var(--ds-text-caption);
        }

        .ai-chat-input:focus {
            outline: none;
        }

        .ai-chat-composer-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 8px 12px 10px;
        }

        .ai-chat-composer-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
        }

        .ai-chat-pill-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            height: 34px;
            padding: 0 12px;
            border-radius: 18px;
            border: 1px solid var(--ds-border-l2);
            background: transparent;
            color: var(--ds-text-primary);
            font-size: 13px;
            line-height: 20px;
            font-weight: 500;
            white-space: nowrap;
            cursor: pointer;
            transition: background-color 0.2s ease, border-color 0.2s ease;
        }

        .ai-chat-pill-btn:hover {
            background: var(--ds-hover-bg);
        }

        .ai-chat-pill-btn.is-active {
            border-color: var(--ds-brand);
            background: rgba(77, 107, 254, 0.14);
            color: var(--ds-brand);
        }

        .ai-chat-pill-btn.is-recording {
            border-color: var(--ds-brand);
            background: rgba(77, 107, 254, 0.22);
            color: var(--ds-brand);
            box-shadow: 0 0 0 0 rgba(77, 107, 254, 0.55);
            animation: aiMicPulse 1.3s ease-out infinite;
        }

        @keyframes aiMicPulse {
            0% { box-shadow: 0 0 0 0 rgba(77, 107, 254, 0.55); }
            70% { box-shadow: 0 0 0 8px rgba(77, 107, 254, 0); }
            100% { box-shadow: 0 0 0 0 rgba(77, 107, 254, 0); }
        }

        .ai-voice-timer {
            font-size: 12px;
            color: var(--ds-text-secondary);
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .ai-chat-icon-pill {
            width: 34px;
            height: 34px;
            padding: 0;
            border-radius: 50%;
            border: 1px solid transparent;
            background: transparent;
            color: var(--ds-text-secondary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
            flex-shrink: 0;
        }

        .ai-chat-icon-pill:hover {
            background: var(--ds-hover-bg);
            color: var(--ds-text-primary);
        }

        .ai-chat-icon-pill.is-recording {
            background: var(--ds-brand);
            color: #ffffff;
            animation: aiMicPulse 1.3s ease-out infinite;
        }

        .ai-chat-overlay.ai-chat-compact .ai-chat-pill-btn {
            width: 32px;
            height: 32px;
            padding: 0;
        }

        .ai-chat-overlay.ai-chat-compact .ai-chat-pill-label {
            display: none;
        }

        .ai-chat-overlay.ai-chat-compact .ai-chat-composer-actions {
            display: flex;
            flex-wrap: nowrap;
            gap: 6px;
        }

        .ai-chat-send {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            border: none;
            background: var(--ds-brand);
            color: #ffffff;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background-color 0.2s ease, opacity 0.2s ease;
            flex-shrink: 0;
        }

        .ai-chat-send:hover:not(:disabled) {
            background: var(--ds-brand-hover);
        }

        .ai-chat-send:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .ai-chat-send.is-streaming {
            background: var(--ds-text-primary);
            color: var(--ds-bg-base);
        }

        .ai-chat-footnote {
            padding: 6px 0 2px;
            font-size: 11px;
            line-height: 16px;
            text-align: center;
            color: var(--ds-text-caption);
            user-select: none;
        }

        @media (hover: none) {
            .ai-chat-msg-actions,
            .ai-chat-session-actions {
                opacity: 1;
                display: flex;
            }
        }

        @media (max-width: 767px) {
            .ai-chat-sider {
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                width: 288px !important;
                max-width: calc(100vw - 48px);
                padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
                transform: translateX(-100%);
                box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
            }

            .ai-chat-shell.mobile-sider-open .ai-chat-sider {
                transform: translateX(0);
            }

            .ai-chat-shell.mobile-sider-open .ai-chat-sider-mask {
                display: block;
            }

            .ai-chat-sider-open-btn {
                display: inline-flex !important;
            }

            .ai-chat-session-item {
                height: 44px;
                border-radius: 14px;
                font-size: 15px;
            }

            .ai-chat-header {
                height: 52px;
                padding: 6px 12px;
            }

            .ai-chat-main {
                scrollbar-gutter: auto;
                padding: 0 14px;
            }

            .ai-chat-thread {
                padding: 10px 0 24px;
                gap: 16px;
            }

            .ai-chat-empty {
                padding: 16px 4px 24px;
            }

            .ai-chat-empty-card h4 {
                font-size: 20px;
                line-height: 28px;
                font-weight: 500;
            }

            .ai-chat-empty-grid {
                margin-top: 16px;
                gap: 8px;
            }

            .ai-chat-empty-pill {
                padding: 7px 12px;
                font-size: 12px;
            }

            .ai-chat-message.user .ai-chat-bubble {
                max-width: calc(100% - 44px);
                font-size: 15px;
                line-height: 22px;
            }

            .ai-chat-message.assistant .ai-chat-bubble,
            .ai-chat-bubble .prose {
                font-size: 15px;
                line-height: 26px;
            }

            .ai-chat-composer {
                padding: 0 10px calc(6px + env(safe-area-inset-bottom, 0px));
            }

            .ai-chat-composer-box {
                border-radius: 22px;
            }

            .ai-chat-input {
                min-height: 44px;
                max-height: 160px;
                padding: 10px 14px 2px;
            }

            .ai-chat-composer-footer {
                padding: 6px 10px 8px;
            }
        }

        @media (max-width: 399px) {
            .ai-chat-pill-label {
                display: none;
            }

            .ai-chat-pill-btn {
                width: 34px;
                padding: 0;
            }
        }

        .export-doc {
            font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
            color: #0f172a;
            background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
            min-height: 100%;
            padding: 32px;
        }

        .export-doc__frame {
            max-width: 880px;
            margin: 0 auto;
        }

        .export-doc__hero {
            border-radius: 28px;
            padding: 28px 30px;
            background: linear-gradient(135deg, #111827, #1d4ed8 58%, #3b82f6);
            color: #f8fafc;
            box-shadow: 0 24px 60px rgba(37, 99, 235, 0.18);
        }

        .export-doc__eyebrow {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            border-radius: 999px;
            background: rgba(255,255,255,0.12);
            font-size: 12px;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        .export-doc__title {
            margin: 14px 0 0;
            font-size: 30px;
            line-height: 1.15;
            font-weight: 900;
        }

        .export-doc__subtitle {
            margin: 12px 0 0;
            font-size: 14px;
            line-height: 1.75;
            color: rgba(248,250,252,0.82);
        }

        .export-doc__list {
            margin-top: 22px;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .export-doc__card {
            border-radius: 24px;
            background: rgba(255,255,255,0.96);
            border: 1px solid rgba(148,163,184,0.18);
            box-shadow: 0 18px 40px rgba(15,23,42,0.08);
            overflow: hidden;
        }

        .export-doc__card-head {
            display: flex;
            justify-content: space-between;
            gap: 16px;
            padding: 20px 22px 12px;
        }

        .export-doc__index {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            border-radius: 999px;
            background: rgba(var(--primary-rgb),0.1);
            color: #1d4ed8;
            font-size: 12px;
            font-weight: 800;
        }

        .export-doc__type {
            font-size: 12px;
            font-weight: 700;
            color: #64748b;
            white-space: nowrap;
        }

        .export-doc__question {
            padding: 0 22px 16px;
            font-size: 17px;
            line-height: 1.75;
            font-weight: 700;
            color: #0f172a;
        }

        .export-doc__options {
            padding: 0 22px 6px;
            display: grid;
            gap: 10px;
        }

        .export-doc__option {
            border-radius: 16px;
            padding: 12px 14px;
            background: #f8fafc;
            border: 1px solid rgba(148,163,184,0.18);
            font-size: 14px;
            line-height: 1.65;
        }

        .export-doc__answers {
            display: grid;
            gap: 12px;
            padding: 16px 22px 22px;
        }

        .export-doc__answer {
            border-radius: 18px;
            padding: 14px 16px;
            border: 1px solid rgba(148,163,184,0.18);
            background: #fff;
        }

        .export-doc__answer--correct {
            background: rgba(34,197,94,0.08);
            border-color: rgba(34,197,94,0.22);
        }

        .export-doc__answer--user {
            background: rgba(var(--primary-rgb),0.06);
            border-color: rgba(var(--primary-rgb),0.18);
        }

        .export-doc__answer-label {
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            color: #64748b;
            margin-bottom: 8px;
        }

        .export-doc__answer-value {
            font-size: 14px;
            line-height: 1.75;
            color: #0f172a;
            white-space: pre-wrap;
            overflow-wrap: anywhere;
        }

        /* ====== Full-Page Auth View ====== */
        .auth-page-overlay {
            position: fixed;
            inset: 0;
            z-index: 90;
            background:
                radial-gradient(ellipse 75% 55% at 18% 12%, rgba(var(--primary-rgb), 0.11), transparent 60%),
                radial-gradient(ellipse 65% 50% at 85% 88%, rgba(var(--accent-rgb), 0.08), transparent 58%),
                var(--background);
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            display: flex;
            flex-direction: column;
            animation: fadeIn 0.2s ease-out;
        }

        .auth-page-overlay.hidden {
            display: none !important;
        }

        .auth-topbar {
            width: 100%;
            max-width: 1080px;
            margin: 0 auto;
            padding: 18px 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            flex-shrink: 0;
        }

        .auth-topbar-brand {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            font-weight: 700;
            font-size: 15px;
            color: var(--text-primary);
            letter-spacing: -0.01em;
        }

        .auth-topbar-brand img {
            width: 26px;
            height: 26px;
            border-radius: 7px;
        }

        .auth-back-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 7px 14px;
            border-radius: 999px;
            border: 1px solid var(--border-color);
            background: var(--surface);
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: color 0.18s, border-color 0.18s, transform 0.15s;
        }

        .auth-back-btn:hover {
            color: var(--text-primary);
            border-color: var(--border-hover);
            transform: translateY(-1px);
        }

        html.auth-page-open,
        body.auth-page-open {
            overflow: hidden !important;
            height: 100vh !important;
        }

        .auth-page-main {
            flex: 1;
            width: 100%;
            max-width: 1180px;
            margin: 0 auto;
            padding: 8px 28px 28px;
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(0, 560px);
            gap: 48px;
            align-items: center;
        }

        .auth-hero {
            display: flex;
            flex-direction: column;
            gap: 28px;
        }

        .auth-hero-pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            width: fit-content;
            padding: 5px 12px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 600;
            color: var(--primary);
            background: rgba(var(--primary-rgb), 0.10);
            border: 1px solid rgba(var(--primary-rgb), 0.22);
        }

        .auth-hero-title {
            font-size: 2.1rem;
            line-height: 1.24;
            font-weight: 800;
            letter-spacing: -0.025em;
            color: var(--text-primary);
        }

        .auth-hero-desc {
            font-size: 15px;
            line-height: 1.7;
            color: var(--text-secondary);
            max-width: 440px;
        }

        .auth-feature-list {
            display: flex;
            flex-direction: column;
            gap: 16px;
            padding-top: 8px;
            border-top: 1px solid var(--border-color);
        }

        .auth-feature-item {
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }

        .auth-feature-icon {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            background: rgba(var(--primary-rgb), 0.10);
            color: var(--primary);
            font-size: 15px;
        }

        .auth-feature-item strong {
            display: block;
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .auth-feature-item span {
            display: block;
            font-size: 12.5px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .auth-card {
            background: var(--surface);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 26px 32px;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
        }

        body[data-theme='light'] .auth-card,
        html[data-initial-theme='light'] .auth-card {
            box-shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
        }

        .auth-card-head {
            margin-bottom: 16px;
        }

        .auth-title {
            font-size: 1.35rem;
            line-height: 1.3;
            font-weight: 800;
            color: var(--text-primary);
        }

        .auth-subtitle {
            margin-top: 4px;
            font-size: 13px;
            color: var(--text-secondary);
        }

        .auth-mode-switch {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 4px;
            margin-bottom: 16px;
            padding: 4px;
            border-radius: 12px;
            background: var(--surface-highlight);
            border: 1px solid var(--border-color);
        }

        .auth-mode-btn {
            border: none;
            background: transparent;
            color: var(--text-secondary);
            border-radius: 9px;
            padding: 9px 12px;
            text-align: center;
            cursor: pointer;
            transition: background 0.18s, color 0.18s, box-shadow 0.18s;
        }

        .auth-mode-btn strong {
            font-size: 13.5px;
            font-weight: 600;
            color: inherit;
        }

        .auth-mode-btn span {
            display: none;
        }

        .auth-mode-btn.active {
            background: var(--surface);
            color: var(--text-primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
        }

        .auth-panel {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .auth-keys-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }

        .auth-stepper {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 12px;
        }

        .auth-stepper-meta {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 12px;
            line-height: 1.2;
        }

        .auth-stepper-label {
            font-weight: 600;
            color: var(--text-secondary);
        }

        .auth-stepper-count {
            font-variant-numeric: tabular-nums;
            font-weight: 600;
            color: var(--text-secondary);
            opacity: 0.78;
        }

        .auth-stepper-bars {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 6px;
        }

        .auth-step {
            height: 3px;
            border-radius: 999px;
            background: var(--border-color);
            transition: background-color 0.25s ease, opacity 0.25s ease;
        }

        .auth-step.done {
            background: rgba(var(--primary-rgb), 0.45);
        }

        .auth-step.active {
            background: var(--primary);
        }

        .auth-step-panel.hidden {
            display: none;
        }

        .auth-section {
            display: flex;
            flex-direction: column;
            gap: 14px;
        }

        .auth-section-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

        .auth-section-title {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .auth-section-meta {
            font-size: 12px;
            color: var(--text-secondary);
        }

        .auth-field {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .auth-label {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            font-size: 12.5px;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .auth-label small {
            font-size: 11px;
            font-weight: 400;
            opacity: 0.85;
        }

        .auth-input {
            width: 100%;
            padding: 11px 14px;
            border: 1px solid var(--border-color);
            border-radius: 11px;
            background-color: var(--background);
            color: var(--text-primary);
            font-size: 14px;
            transition: border-color 0.18s ease, box-shadow 0.18s ease;
        }

        .auth-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.16);
        }

        .auth-inline {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 8px;
            align-items: center;
        }

        .auth-secondary-btn {
            white-space: nowrap;
            background: var(--surface-highlight);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            border-radius: 11px;
        }

        .auth-secondary-btn:hover:not(:disabled) {
            border-color: var(--border-hover);
        }

        .auth-tip,
        .auth-warning {
            padding: 10px 12px;
            border-radius: 10px;
            font-size: 12px;
            line-height: 1.55;
        }

        .auth-tip {
            background: var(--surface-highlight);
            color: var(--text-secondary);
            border: 1px solid var(--border-color);
        }

        .auth-warning {
            background: rgba(239, 68, 68, 0.10);
            color: #fca5a5;
            border: 1px solid rgba(239, 68, 68, 0.25);
        }

        body[data-theme='light'] .auth-warning,
        html[data-initial-theme='light'] .auth-warning {
            background: #fef2f2;
            color: #b91c1c;
            border-color: #fecaca;
        }

        .auth-submit {
            min-height: 44px;
            font-size: 14.5px;
            border-radius: 11px;
        }

        .auth-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 4px;
        }

        .auth-actions .btn {
            flex: 1 1 140px;
        }

        .auth-footer-note {
            text-align: center;
            font-size: 13px;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        .auth-inline-link {
            color: var(--primary);
            font-weight: 600;
            text-decoration: none;
        }

        .auth-inline-link:hover {
            text-decoration: underline;
        }

        .auth-brand-footer {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-top: 18px;
            padding-top: 14px;
            border-top: 1px solid var(--border-color);
            color: var(--text-secondary);
            font-size: 12px;
        }

        .auth-brand-footer img {
            width: 16px;
            height: 16px;
            border-radius: 4px;
        }

        @media (max-width: 900px) {
            .auth-topbar {
                padding: 14px 16px;
            }
            .auth-page-main {
                grid-template-columns: 1fr;
                max-width: 520px;
                gap: 16px;
                padding: 4px 16px 28px;
                align-items: start;
            }
            .auth-hero {
                display: none;
            }
            .auth-card {
                padding: 22px 18px;
                border-radius: 16px;
            }
            .auth-keys-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 440px) {
            .auth-inline {
                grid-template-columns: 1fr;
            }
            .auth-secondary-btn {
                width: 100%;
            }
        }

        .auth-message {
            min-height: 1.5rem;
            margin-top: 1rem;
            text-align: center;
            font-size: 0.86rem;
            font-weight: 600;
        }

        /* Toast notification animation */
        @keyframes fadeInUp {
            from { opacity: 0; transform: translateX(-50%) translateY(20px); }
            to { opacity: 1; transform: translateX(-50%) translateY(0); }
        }

        /* Theme toggle button */
        .theme-toggle {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--surface-highlight);
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .theme-toggle:hover {
            background: var(--glass-bg-hover);
            border-color: var(--border-hover);
        }

        /* Responsive */
        @media (max-width: 768px) {
            .progress-grid {
                grid-template-columns: repeat(5, 1fr);
            }

            .bento-grid {
                grid-template-columns: 1fr !important;
            }

            /* Mobile button optimizations */
            .btn {
                padding: 0.6rem 0.8rem;
                font-size: 0.875rem;
            }

            .btn-sm {
                padding: 0.4rem 0.6rem;
                font-size: 0.75rem;
            }

            /* Nav buttons on mobile */
            #authHeader .btn {
                padding: 0.4rem 0.6rem;
            }

            /* Floating buttons on mobile */
            #floatingButtonsContainer {
                right: 1rem;
                bottom: 1rem;
            }

            #floatingAiBtn {
                width: 48px;
                height: 48px;
            }

            /* Modal optimizations */
            .modal-content {
                margin: 1rem;
                max-height: 70vh;
                width: calc(100% - 2rem);
                max-width: min(480px, calc(100% - 2rem));
            }

            .ai-chat-shell {
                width: 100vw;
                height: 100dvh;
                border: none;
            }

            .ai-chat-header {
                padding: 0.85rem 0.95rem;
            }

            .ai-chat-empty-grid {
                grid-template-columns: 1fr;
            }

            .ai-chat-bubble-wrap {
                max-width: calc(100% - 3rem);
            }

            .ai-chat-composer {
                padding: 0 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
            }

            .ai-chat-composer-box {
                padding: 0.55rem 0.6rem;
                border-radius: 1.15rem;
            }

            .ai-chat-composer-actions .ai-chat-icon-btn,
            .ai-chat-send {
                width: 2.85rem;
                height: 2.85rem;
            }

            .ai-chat-input {
                min-height: 2.7rem;
                max-height: 6.5rem;
                padding: 0.62rem 0.05rem;
            }

            .export-doc {
                padding: 18px;
            }

            .export-doc__hero {
                padding: 20px 18px;
                border-radius: 22px;
            }

            .export-doc__title {
                font-size: 24px;
            }

            .export-doc__card-head,
            .export-doc__question,
            .export-doc__options,
            .export-doc__answers {
                padding-left: 16px;
                padding-right: 16px;
            }

            .auth-shell {
                padding: 0;
            }

            .auth-shell-inner,
            .auth-header {
                padding: 1rem;
            }

            .auth-inline {
                grid-template-columns: 1fr;
            }

            .auth-secondary-btn {
                width: 100%;
            }

            /* Quiz card list view on mobile */
            .list-view .quiz-card {
                padding: 0.75rem 1rem !important;
            }

            /* Dashboard responsive */
            #dashboardSection .grid {
                gap: 1rem;
            }

            /* Import section buttons */
            #importSection .flex-wrap {
                gap: 0.5rem;
            }

            #importSection .btn {
                flex: 1 1 auto;
                min-width: fit-content;
            }

            /* Practice mode buttons */
            #practiceSection .flex-wrap {
                gap: 0.5rem;
            }

            /* Question cards */
            .question-card {
                padding: 1rem;
            }

            /* Token stats modal mobile optimization */
            #helpModal .modal-content {
                max-width: 100%;
                padding: 1.25rem;
            }

            #tokenStatsGrid {
                grid-template-columns: 1fr !important;
                gap: 0.75rem !important;
            }
        }

        /* Desktop: Token stats grid 3 columns */
        @media (min-width: 768px) {
            #tokenStatsGrid {
                grid-template-columns: repeat(3, 1fr) !important;
            }

            #helpModal .text-2xl {
                font-size: 1.75rem !important;
            }

            #helpModal h3 {
                font-size: 1.25rem;
            }

            #helpModal h4 {
                font-size: 1rem;
            }

            #helpModal .p-4 {
                padding: 0.875rem !important;
            }

            /* Stats breakdown mobile */
            #statsModelBreakdown .flex {
                flex-direction: column;
                gap: 0.25rem;
                text-align: left;
            }

            #statsModelBreakdown .flex span:last-child {
                font-size: 0.75rem;
            }
        }

        @media (max-width: 480px) {

            /* Extra small screens */
            .btn {
                padding: 0.5rem 0.6rem;
                font-size: 0.8rem;
            }

            #dailyGoalCard {
                padding: 1rem;
            }

            #dailyGoalCard .text-4xl {
                font-size: 2rem;
            }

            /* Hide some text on very small screens */
            .xs-hide-text {
                display: none;
            }
        }

        /* Quiz Library List View - Enhanced layout */
        .list-view .quiz-card {
            flex-direction: row !important;
            align-items: center !important;
            justify-content: flex-start !important;
            min-height: auto !important;
            padding: 0.875rem 1.25rem !important;
            gap: 1rem;
            text-align: left !important;
        }

        /* Header area - contains icon only in list view, shrink to minimum */
        .list-view .quiz-card .quiz-card-header {
            flex: none !important;
            flex-shrink: 0 !important;
            flex-grow: 0 !important;
            margin-bottom: 0 !important;
            justify-content: flex-start !important;
            width: auto !important;
        }

        /* Hide action buttons in list view header */
        .list-view .quiz-card .quiz-card-actions {
            display: none !important;
        }

        /* Content area - takes remaining space, LEFT aligned */
        .list-view .quiz-card .flex-grow {
            flex: 1 !important;
            text-align: left !important;
            display: block !important;
        }

        /* Force title left aligned */
        .list-view .quiz-card .flex-grow h3 {
            text-align: left !important;
            margin-bottom: 0.125rem !important;
        }

        /* Force description left aligned */
        .list-view .quiz-card .flex-grow p {
            text-align: left !important;
            margin-bottom: 0.25rem !important;
        }

        /* Tags and stats row - left aligned */
        .list-view .quiz-card .flex-grow>.flex {
            justify-content: flex-start !important;
        }

        /* All text elements left aligned */
        .list-view .quiz-card .flex-grow h3,
        .list-view .quiz-card .flex-grow p,
        .list-view .quiz-card .flex-grow span,
        .list-view .quiz-card .flex-grow div {
            text-align: left !important;
        }

        /* Footer - hide in list view */
        .list-view .quiz-card>div:last-child:not(.flex-grow):not(.quiz-card-header) {
            display: none !important;
        }

        /* Quiz card footer specifically */
        .list-view .quiz-card>.border-t {
            display: none !important;
        }

        /* Action buttons show on hover in list view */
        .list-view .quiz-card:hover .quiz-card-actions {
            display: flex !important;
            position: absolute;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
        }

        /* Make card relative for absolute positioning of actions */
        .list-view .quiz-card {
            position: relative;
        }

        /* Accuracy badge in list view - show at the right side, smaller */
        .list-view .quiz-card .quiz-card-accuracy {
            position: absolute !important;
            top: 42px !important;
            right: 50px !important;
            transform: translate(50%, -50%) !important;
            font-size: 1.75rem !important;
            opacity: 0.8;
        }

        /* Light mode scrollbar for html element as well */
        html[data-theme='light'],
        body[data-theme='light'] * {
            scrollbar-color: rgba(100, 116, 139, 0.26) transparent;
        }

        html[data-theme='light']::-webkit-scrollbar,
        body[data-theme='light'] *::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        html[data-theme='light']::-webkit-scrollbar-track,
        body[data-theme='light'] *::-webkit-scrollbar-track {
            background: transparent;
        }

        html[data-theme='light']::-webkit-scrollbar-thumb,
        body[data-theme='light'] *::-webkit-scrollbar-thumb {
            background: rgba(100, 116, 139, 0.24);
            border-radius: 9999px;
            border: 1px solid transparent;
            background-clip: padding-box;
        }

        html[data-theme='light']::-webkit-scrollbar-thumb:hover,
        body[data-theme='light'] *::-webkit-scrollbar-thumb:hover {
            background: rgba(100, 116, 139, 0.42);
            background-clip: padding-box;
        }

        /* KaTeX */
        .katex-display {
            margin: 1rem 0;
            overflow-x: auto;
        }

        .katex {
            font-size: 1.1em;
        }

        /* ============ Animations ============ */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        @keyframes slideInRight {
            from {
                opacity: 0;
                transform: translateX(30px);
            }

            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        @keyframes pulse-soft {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.7;
            }
        }

        @keyframes float {

            0%,
            100% {
                transform: translateY(0);
            }

            50% {
                transform: translateY(-5px);
            }
        }

        .animate-fade-in-up {
            animation: fadeInUp 0.5s ease-out forwards;
        }

        .animate-fade-in {
            animation: fadeIn 0.4s ease-out forwards;
        }

        .animate-slide-in-right {
            animation: slideInRight 0.4s ease-out forwards;
        }

        .animate-pulse-soft {
            animation: pulse-soft 2s ease-in-out infinite;
        }

        .animate-float {
            animation: float 3s ease-in-out infinite;
        }

        /* Staggered animation for cards */
        .quiz-card {
            opacity: 0;
            animation: fadeInUp 0.5s ease-out forwards;
        }

        .quiz-card:nth-child(1) {
            animation-delay: 0.05s;
        }

        .quiz-card:nth-child(2) {
            animation-delay: 0.1s;
        }

        .quiz-card:nth-child(3) {
            animation-delay: 0.15s;
        }

        .quiz-card:nth-child(4) {
            animation-delay: 0.2s;
        }

        .quiz-card:nth-child(5) {
            animation-delay: 0.25s;
        }

        .quiz-card:nth-child(6) {
            animation-delay: 0.3s;
        }

        .quiz-card:nth-child(7) {
            animation-delay: 0.35s;
        }

        .quiz-card:nth-child(8) {
            animation-delay: 0.4s;
        }

        /* Card decorative backgrounds */
        .quiz-card::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 100px;
            height: 100px;
            border-radius: 0 16px 0 60%;
            opacity: 0.12;
            transition: all 0.4s ease;
            pointer-events: none;
        }

        .quiz-card[data-source='cloud']::before,
        .quiz-card[data-source='cloud-private']::before {
            background: linear-gradient(135deg, var(--primary), var(--accent));
        }

        .quiz-card[data-source='local']::before {
            background: linear-gradient(135deg, #64748b, #94a3b8);
        }

        .quiz-card:hover::before {
            opacity: 0.25;
            width: 120px;
            height: 120px;
        }

        /* Accuracy watermark styling and animation */
        .quiz-card-accuracy {
            position: absolute;
            top: 30px;
            right: 45px;
            transform: translate(50%, -50%);
            transition: all 0.4s ease;
        }

        .quiz-card:hover .quiz-card-accuracy {
            opacity: 1;
        }

        .quiz-card:hover .accuracy-inner {
            transform: scale(1.2);
        }

        @media (min-width: 640px) {
            .quiz-card-accuracy {
                top: 48px;
            }
        }
        .accuracy-inner {
            display: inline-block;
            transition: transform 0.4s ease;
        }

        /* Card decoration icons - more visible */
        .card-deco-icon {
            position: absolute;
            top: 12px;
            right: 55px;
            font-size: 1.8rem;
            opacity: 0.4;
            transition: all 0.3s ease;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
        }

        .quiz-card:hover .card-deco-icon {
            opacity: 0.6;
            transform: scale(1.2) rotate(10deg);
        }

        /* Question card animations */
        .question-card {
            animation: fadeInUp 0.4s ease-out forwards;
        }

        /* Button click effect */
        .btn:active {
            transform: scale(0.97);
        }

        /* Floating AI问 Grok Bot (Strictly Black & White 2-color, no outer circle) */
        #floatingAiBtn {
            width: 56px;
            height: 56px;
            padding: 0;
            border-radius: 50%;
            background: transparent;
            border: none;
            box-shadow: none;
            transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
            overflow: visible;
            position: relative;
            cursor: pointer;
        }

        body[data-theme='light'] #floatingAiBtn,
        html[data-initial-theme='light'] #floatingAiBtn {
            background: transparent;
            border: none;
            box-shadow: none;
        }

        #floatingAiBtn:hover {
            transform: scale(1.08);
        }

        #floatingAiBtn svg {
            width: 56px;
            height: 56px;
            overflow: visible;
            pointer-events: none;
            filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.28));
        }

        .floating-grok-badge {
            position: absolute;
            bottom: -5px;
            left: 50%;
            transform: translateX(-50%);
            padding: 1px 7px;
            border-radius: 999px;
            font-size: 10px;
            line-height: 14px;
            font-weight: 600;
            letter-spacing: 0.02em;
            white-space: nowrap;
            background: rgba(39, 39, 42, 0.94);
            color: #f9fafb;
            border: 1px solid rgba(255, 255, 255, 0.16);
            backdrop-filter: blur(8px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s ease;
            z-index: 3;
        }

        body[data-theme='light'] .floating-grok-badge,
        html[data-initial-theme='light'] .floating-grok-badge {
            background: rgba(255, 255, 255, 0.95);
            color: #18181b;
            border-color: rgba(0, 0, 0, 0.1);
        }

        #floatingAiBtn:hover .floating-grok-badge,
        #floatingAiBtn.has-mood-badge .floating-grok-badge {
            opacity: 1;
        }

        @keyframes floatingQuizBreath {
            0%, 100% {
                box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.28), 0 8px 24px rgba(0, 0, 0, 0.22);
            }
            50% {
                box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0), 0 8px 24px rgba(0, 0, 0, 0.22);
            }
        }

        #floatingAiBtn.is-quiz-active {
            animation: floatingQuizBreath 2.8s ease-in-out infinite;
        }

        /* 防止手机厂商/浏览器强制深色模式对 Grok Bot SVG 进行二次反色 */
        html[data-initial-theme='dark'],
        body:not([data-theme='light']) {
            color-scheme: dark;
        }

        html[data-initial-theme='light'],
        body[data-theme='light'] {
            color-scheme: light;
        }

        #floatingAiBtn,
        #floatingGrokSvg,
        #aiBrandGrokSvg,
        #aiEmptyGrokSvg,
        .ai-chat-msg-avatar,
        .ai-chat-msg-avatar svg {
            forced-color-adjust: none;
            -webkit-filter: none;
            filter: none;
        }

        body:not([data-theme='light']) #floatingAiBtn,
        body:not([data-theme='light']) #floatingGrokSvg,
        body:not([data-theme='light']) #aiBrandGrokSvg,
        body:not([data-theme='light']) #aiEmptyGrokSvg,
        body:not([data-theme='light']) .ai-chat-msg-avatar {
            color-scheme: only dark;
        }

        body[data-theme='light'] #floatingAiBtn,
        body[data-theme='light'] #floatingGrokSvg,
        body[data-theme='light'] #aiBrandGrokSvg,
        body[data-theme='light'] #aiEmptyGrokSvg,
        body[data-theme='light'] .ai-chat-msg-avatar {
            color-scheme: only light;
        }

        @media (max-width: 768px) {
            #floatingAiBtn {
                width: 48px;
                height: 48px;
            }

            #floatingAiBtn svg {
                width: 48px;
                height: 48px;
            }
        }

        #floatingAiBtn:hover {
            animation: none;
            transform: scale(1.1);
        }

        /* Level Up Animation */
        @keyframes levelUpBounce {

            0%,
            100% {
                transform: scale(1);
            }

            25% {
                transform: scale(1.2);
            }

            50% {
                transform: scale(0.95);
            }

            75% {
                transform: scale(1.1);
            }
        }

        @keyframes confettiFloat {
            0% {
                transform: translateY(0) rotate(0deg);
                opacity: 1;
            }

            100% {
                transform: translateY(-150px) rotate(720deg);
                opacity: 0;
            }
        }

        @keyframes starPulse {

            0%,
            100% {
                transform: scale(1);
                opacity: 0.8;
            }

            50% {
                transform: scale(1.3);
                opacity: 1;
            }
        }


        /* ====== Multi-Color Theme System (Default + 5 Curated Dark/Light Themes) ====== */
        /* 1. 苍翠竹绿 (Bamboo Jade) */
        html[data-color-theme="bamboo"] {
            --primary: #059669;
            --primary-hover: #10b981;
            --primary-rgb: 16, 185, 129;
            --accent: #14b8a6;
            --accent-rgb: 20, 184, 166;
            --ds-brand: #059669;
            --ds-brand-hover: #10b981;
            --ds-brand-text: #34d399;
            --ds-bubble-user: rgba(16, 185, 129, 0.16);
            --ds-sider-active: rgba(16, 185, 129, 0.22);
            --gh-hm-pill-active-bg: #059669;
        }
        html[data-color-theme="bamboo"] body[data-theme='light'],
        html[data-color-theme="bamboo"][data-initial-theme='light'] {
            --primary: #0f766e;
            --primary-hover: #0d9488;
            --primary-rgb: 15, 118, 110;
            --accent: #059669;
            --accent-rgb: 5, 150, 105;
            --ds-brand: #0f766e;
            --ds-brand-hover: #0d9488;
            --ds-brand-text: #0f766e;
            --ds-bubble-user: #e6f4f1;
            --ds-sider-active: #ccebe4;
            --gh-hm-pill-active-bg: #0f766e;
        }

        /* 2. 松烟钛灰 (Graphite Monochrome) */
        html[data-color-theme="graphite"] {
            --primary: #52525b;
            --primary-hover: #71717a;
            --primary-rgb: 161, 161, 170;
            --accent: #a1a1aa;
            --accent-rgb: 161, 161, 170;
            --ds-brand: #52525b;
            --ds-brand-hover: #71717a;
            --ds-brand-text: #e4e4e7;
            --ds-bubble-user: rgba(161, 161, 170, 0.18);
            --ds-sider-active: rgba(161, 161, 170, 0.24);
            --gh-hm-pill-active-bg: #52525b;
        }
        html[data-color-theme="graphite"] body[data-theme='light'],
        html[data-color-theme="graphite"][data-initial-theme='light'] {
            --primary: #27272a;
            --primary-hover: #3f3f46;
            --primary-rgb: 39, 39, 42;
            --accent: #52525b;
            --accent-rgb: 82, 82, 91;
            --ds-brand: #27272a;
            --ds-brand-hover: #3f3f46;
            --ds-brand-text: #27272a;
            --ds-bubble-user: #f4f4f5;
            --ds-sider-active: #e4e4e7;
            --gh-hm-pill-active-bg: #27272a;
        }

        /* 3. 琥珀流金 (Amber Gold) */
        html[data-color-theme="amber"] {
            --primary: #d97706;
            --primary-hover: #f59e0b;
            --primary-rgb: 245, 158, 11;
            --accent: #fbbf24;
            --accent-rgb: 251, 191, 36;
            --ds-brand: #d97706;
            --ds-brand-hover: #f59e0b;
            --ds-brand-text: #fbbf24;
            --ds-bubble-user: rgba(245, 158, 11, 0.16);
            --ds-sider-active: rgba(245, 158, 11, 0.22);
            --gh-hm-pill-active-bg: #d97706;
        }
        html[data-color-theme="amber"] body[data-theme='light'],
        html[data-color-theme="amber"][data-initial-theme='light'] {
            --primary: #b45309;
            --primary-hover: #d97706;
            --primary-rgb: 180, 83, 9;
            --accent: #d97706;
            --accent-rgb: 217, 119, 6;
            --ds-brand: #b45309;
            --ds-brand-hover: #d97706;
            --ds-brand-text: #b45309;
            --ds-bubble-user: #fef3c7;
            --ds-sider-active: #fde68a;
            --gh-hm-pill-active-bg: #b45309;
        }

        /* 4. 绯樱朱砂 (Silk Rose) */
        html[data-color-theme="rose"] {
            --primary: #e11d48;
            --primary-hover: #f43f5e;
            --primary-rgb: 244, 63, 94;
            --accent: #fb7185;
            --accent-rgb: 251, 113, 133;
            --ds-brand: #e11d48;
            --ds-brand-hover: #f43f5e;
            --ds-brand-text: #fda4af;
            --ds-bubble-user: rgba(244, 63, 94, 0.16);
            --ds-sider-active: rgba(244, 63, 94, 0.22);
            --gh-hm-pill-active-bg: #e11d48;
        }
        html[data-color-theme="rose"] body[data-theme='light'],
        html[data-color-theme="rose"][data-initial-theme='light'] {
            --primary: #be123c;
            --primary-hover: #e11d48;
            --primary-rgb: 190, 18, 60;
            --accent: #e11d48;
            --accent-rgb: 225, 29, 72;
            --ds-brand: #be123c;
            --ds-brand-hover: #e11d48;
            --ds-brand-text: #be123c;
            --ds-bubble-user: #ffeef2;
            --ds-sider-active: #ffd6df;
            --gh-hm-pill-active-bg: #be123c;
        }

        /* 5. 曜石玄青 (Obsidian Ink Cyan) */
        html[data-color-theme="ink"] {
            --primary: #0284c7;
            --primary-hover: #0ea5e9;
            --primary-rgb: 56, 189, 248;
            --accent: #38bdf8;
            --accent-rgb: 56, 189, 248;
            --ds-brand: #0284c7;
            --ds-brand-hover: #0ea5e9;
            --ds-brand-text: #7dd3fc;
            --ds-bubble-user: rgba(56, 189, 248, 0.16);
            --ds-sider-active: rgba(56, 189, 248, 0.22);
            --gh-hm-pill-active-bg: #0284c7;
        }
        html[data-color-theme="ink"] body[data-theme='light'],
        html[data-color-theme="ink"][data-initial-theme='light'] {
            --primary: #0f4c81;
            --primary-hover: #0369a1;
            --primary-rgb: 15, 76, 129;
            --accent: #0369a1;
            --accent-rgb: 3, 105, 161;
            --ds-brand: #0f4c81;
            --ds-brand-hover: #0369a1;
            --ds-brand-text: #0f4c81;
            --ds-bubble-user: #e8f3fc;
            --ds-sider-active: #cfe5f8;
            --gh-hm-pill-active-bg: #0f4c81;
        }

        /* Theme Selector Cards inside User Settings Modal */
        .theme-swatch-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 8px;
        }
        @media (max-width: 520px) {
            .theme-swatch-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }
        .theme-swatch-card {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-radius: 10px;
            border: 1.5px solid var(--border-color);
            background: var(--surface-highlight);
            cursor: pointer;
            text-align: left;
            transition: border-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
        }
        .theme-swatch-card:hover {
            border-color: var(--primary);
            transform: translateY(-1px);
        }
        .theme-swatch-card.active {
            border-color: var(--primary);
            box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.22);
            background: rgba(var(--primary-rgb), 0.10);
        }
        .theme-swatch-dot {
            width: 22px;
            height: 22px;
            border-radius: 9999px;
            flex-shrink: 0;
            border: 1.5px solid rgba(255, 255, 255, 0.35);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
        }
        .theme-swatch-meta {
            min-width: 0;
            flex: 1;
        }
        .theme-swatch-name {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .theme-swatch-sub {
            font-size: 10px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* GitHub-style Heatmap Modal */
        :root {
            --gh-hm-0: #161b22;
            --gh-hm-1: #0e4429;
            --gh-hm-2: #006d32;
            --gh-hm-3: #26a641;
            --gh-hm-4: #39d353;
            --gh-hm-border: rgba(255, 255, 255, 0.06);
            --gh-hm-card-bg: rgba(13, 17, 23, 0.72);
            --gh-hm-card-border: rgba(240, 246, 252, 0.12);
            --gh-hm-pill-active-bg: #1f6feb;
            --gh-hm-pill-active-fg: #ffffff;
        }

        body[data-theme='light'],
        html[data-initial-theme='light'] {
            --gh-hm-0: #ebedf0;
            --gh-hm-1: #9be9a8;
            --gh-hm-2: #40c463;
            --gh-hm-3: #30a14e;
            --gh-hm-4: #216e39;
            --gh-hm-border: rgba(27, 31, 35, 0.06);
            --gh-hm-card-bg: #ffffff;
            --gh-hm-card-border: #d0d7de;
            --gh-hm-pill-active-bg: #0969da;
            --gh-hm-pill-active-fg: #ffffff;
        }

        .gh-hm-modal-content {
            max-width: 880px !important;
            width: min(95vw, 880px) !important;
            padding: 20px 22px !important;
        }

        .gh-hm-header {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding-right: 28px;
            margin-bottom: 12px;
        }

        .gh-hm-years {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .gh-hm-year-btn {
            font-size: 12px;
            font-weight: 500;
            padding: 4px 10px;
            border-radius: 6px;
            border: 1px solid var(--gh-hm-card-border);
            color: var(--text-secondary);
            background: transparent;
            cursor: pointer;
            transition: background 0.15s, color 0.15s, border-color 0.15s;
        }

        .gh-hm-year-btn:hover {
            color: var(--text-primary);
            border-color: rgba(128, 128, 128, 0.4);
        }

        .gh-hm-year-btn.active {
            background: var(--gh-hm-pill-active-bg);
            color: var(--gh-hm-pill-active-fg);
            border-color: transparent;
        }

        .gh-hm-stats {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 8px;
            margin-bottom: 12px;
        }

        .gh-hm-stat-item {
            padding: 8px 10px;
            border-radius: 8px;
            border: 1px solid var(--gh-hm-card-border);
            background: var(--gh-hm-card-bg);
        }

        .gh-hm-stat-val {
            font-size: 16px;
            font-weight: 700;
            line-height: 1.2;
            color: var(--text-primary);
        }

        .gh-hm-stat-label {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .gh-hm-card {
            border: 1px solid var(--gh-hm-card-border);
            border-radius: 8px;
            background: var(--gh-hm-card-bg);
            padding: 14px 16px 12px;
        }

        .gh-hm-scroll {
            overflow-x: auto;
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;
            padding-bottom: 4px;
        }

        .gh-hm-graph {
            display: inline-flex;
            flex-direction: column;
            min-width: max-content;
            user-select: none;
        }

        .gh-hm-months {
            display: flex;
            align-items: center;
            height: 16px;
            margin-left: 28px;
            margin-bottom: 4px;
            position: relative;
            font-size: 11px;
            color: var(--text-secondary);
        }

        .gh-hm-month-label {
            position: absolute;
            top: 0;
            white-space: nowrap;
            line-height: 16px;
        }

        .gh-hm-body {
            display: flex;
            align-items: flex-start;
            gap: 6px;
        }

        .gh-hm-weekdays {
            display: grid;
            grid-template-rows: repeat(7, 11px);
            gap: 3px;
            width: 22px;
            font-size: 10px;
            line-height: 11px;
            color: var(--text-secondary);
            text-align: right;
            flex-shrink: 0;
        }

        .gh-hm-weeks {
            display: flex;
            gap: 3px;
        }

        .gh-hm-week {
            display: grid;
            grid-template-rows: repeat(7, 11px);
            gap: 3px;
        }

        .gh-hm-cell {
            width: 11px;
            height: 11px;
            border-radius: 2px;
            background: var(--gh-hm-0);
            outline: 1px solid var(--gh-hm-border);
            outline-offset: -1px;
            cursor: pointer;
            transition: transform 0.1s ease;
        }

        .gh-hm-cell[data-level="1"] { background: var(--gh-hm-1); }
        .gh-hm-cell[data-level="2"] { background: var(--gh-hm-2); }
        .gh-hm-cell[data-level="3"] { background: var(--gh-hm-3); }
        .gh-hm-cell[data-level="4"] { background: var(--gh-hm-4); }

        .gh-hm-cell:hover:not(.is-empty):not(.is-future) {
            transform: scale(1.22);
            z-index: 2;
        }

        .gh-hm-cell.is-today {
            box-shadow: 0 0 0 1.5px #2f81f7;
        }

        .gh-hm-cell.is-selected {
            box-shadow: 0 0 0 1.5px var(--text-primary);
        }

        .gh-hm-cell.is-empty {
            background: transparent !important;
            outline: none !important;
            cursor: default;
            pointer-events: none;
        }

        .gh-hm-cell.is-future {
            opacity: 0.25;
            cursor: default;
        }

        .gh-hm-footer {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-top: 10px;
            font-size: 11px;
            color: var(--text-secondary);
        }

        .gh-hm-legend {
            display: inline-flex;
            align-items: center;
            gap: 3px;
        }

        .gh-hm-legend .gh-hm-cell {
            cursor: default;
        }

        .gh-hm-tooltip {
            position: fixed;
            z-index: 10050;
            pointer-events: none;
            background: #24292f;
            color: #ffffff;
            font-size: 12px;
            line-height: 1.35;
            padding: 5px 9px;
            border-radius: 6px;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
            white-space: nowrap;
            transform: translate(-50%, -100%);
        }

        @media (max-width: 640px) {
            .gh-hm-modal-content {
                padding: 16px 14px !important;
            }
            .gh-hm-stats {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
            .gh-hm-card {
                padding: 12px 10px 10px;
            }
        }

        #levelUpOverlay {
            position: fixed;
            top: max(16px, env(safe-area-inset-top, 0px) + 12px);
            left: 50%;
            transform: translateX(-50%);
            z-index: 9999;
            width: min(92vw, 500px);
            pointer-events: none;
            animation: fadeIn 0.25s ease-out;
        }

        #levelUpOverlay .level-up-card {
            width: 100%;
            border-radius: 18px;
            padding: 0.85rem 0.95rem 0.85rem 0.85rem;
            color: var(--text-primary);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            animation: slideDownFade 0.32s ease-out;
            position: relative;
            overflow: hidden;
            pointer-events: auto;
        }

        body:not([data-theme='light']) #levelUpOverlay .level-up-card {
            color: var(--text-primary);
            background:
                radial-gradient(circle at 86% 20%, rgba(var(--primary-rgb), 0.22), transparent 36%),
                radial-gradient(circle at 14% 88%, rgba(var(--primary-rgb), 0.12), transparent 36%),
                rgba(24, 24, 27, 0.92);
            border: 1px solid rgba(var(--primary-rgb), 0.32);
            box-shadow:
                0 20px 44px rgba(0, 0, 0, 0.45),
                0 0 28px rgba(var(--primary-rgb), 0.14);
        }

        body[data-theme='light'] #levelUpOverlay .level-up-card {
            color: var(--text-primary);
            background:
                radial-gradient(circle at 86% 20%, rgba(var(--primary-rgb), 0.14), transparent 36%),
                radial-gradient(circle at 14% 88%, rgba(var(--primary-rgb), 0.08), transparent 36%),
                rgba(255, 255, 255, 0.94);
            border: 1px solid rgba(var(--primary-rgb), 0.22);
            box-shadow:
                0 18px 40px rgba(15, 23, 42, 0.12),
                0 0 20px rgba(var(--primary-rgb), 0.08);
        }

        #levelUpOverlay .level-up-shell {
            display: flex;
            align-items: center;
            gap: 0.85rem;
        }

        #levelUpOverlay .level-badge {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            border-radius: 14px;
            color: #ffffff;
            flex-shrink: 0;
            border: 1px solid rgba(255, 255, 255, 0.22);
            box-shadow:
                inset 0 1px 0 rgba(255, 255, 255, 0.3),
                0 8px 20px rgba(var(--primary-rgb), 0.24);
        }

        #levelUpOverlay .level-badge svg {
            width: 22px;
            height: 22px;
            stroke: currentColor;
            stroke-width: 2.3;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        #levelUpOverlay .level-up-copy {
            display: flex;
            flex-direction: column;
            gap: 0.28rem;
            min-width: 0;
            flex: 1;
        }

        #levelUpOverlay .level-up-eyebrow {
            display: none;
        }

        #levelUpOverlay h2 {
            margin: 0;
            font-size: clamp(1rem, 2.5vw, 1.2rem);
            line-height: 1.15;
            letter-spacing: -0.03em;
            font-weight: 800;
            color: var(--text-primary);
        }

        #levelUpOverlay .level-up-subtitle {
            margin: 0;
            color: var(--text-secondary);
            font-size: 0.84rem;
            line-height: 1.25;
            font-weight: 500;
        }

        #levelUpOverlay .level-up-stats {
            display: none;
        }

        #levelUpOverlay .level-up-footnote {
            display: none;
        }

        #levelUpOverlay .btn-celebrate {
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 9999px;
            background: transparent;
            color: var(--text-secondary);
            border: none;
            cursor: pointer;
            flex-shrink: 0;
            transition: color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
        }

        #levelUpOverlay .btn-celebrate svg {
            width: 15px;
            height: 15px;
            stroke: currentColor;
            stroke-width: 2.1;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        #levelUpOverlay .btn-celebrate:hover {
            background: var(--surface-highlight);
            color: var(--text-primary);
            box-shadow: none;
        }

        #levelUpOverlay .level-up-accent {
            color: var(--primary);
            font-weight: 800;
        }

        #levelUpOverlay .level-up-sparkle {
            position: absolute;
            color: rgba(var(--primary-rgb), 0.55);
            pointer-events: none;
            user-select: none;
        }

        #levelUpOverlay .level-up-sparkle svg {
            width: 10px;
            height: 10px;
            fill: currentColor;
            display: block;
        }

        #levelUpOverlay .level-up-sparkle.left {
            left: 76px;
            top: 16px;
        }

        #levelUpOverlay .level-up-sparkle.right {
            right: 62px;
            top: 26px;
        }

        #levelUpOverlay .level-up-sparkle.right svg {
            width: 8px;
            height: 8px;
        }

        @keyframes slideDownFade {
            from {
                opacity: 0;
                transform: translateY(-12px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Toggle Switch */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 48px;
            height: 26px;
            flex-shrink: 0;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--surface-highlight);
            border-radius: 26px;
            transition: 0.3s;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background-color: var(--text-secondary);
            border-radius: 50%;
            transition: 0.3s;
        }

        .toggle-switch input:checked+.toggle-slider {
            background-color: var(--primary);
        }

        .toggle-switch input:checked+.toggle-slider:before {
            transform: translateX(22px);
            background-color: white;
        }

        /* Mobile responsive for new features */
        @media (max-width: 640px) {

            /* Level up overlay - smaller on mobile */
                    #levelUpOverlay {
                top: max(10px, env(safe-area-inset-top, 0px) + 8px);
                width: min(94vw, 500px);
            }

            #levelUpOverlay .level-up-card {
                border-radius: 16px;
                padding: 0.76rem 0.82rem 0.76rem 0.76rem;
            }

            #levelUpOverlay .level-badge {
                width: 46px;
                height: 46px;
                border-radius: 14px;
            }

            #levelUpOverlay h2 {
                font-size: 0.98rem;
            }

            #levelUpOverlay .level-up-subtitle {
                font-size: 0.8rem;
            }

            /* Quiz card accuracy watermark - smaller on mobile */
            .quiz-card-accuracy {
                font-size: 4.5rem !important;
            }

            .quiz-card-accuracy span:last-child {
                font-size: 1.75rem !important;
            }
        }


        @media (max-width: 639px) {
            /* Button grid for import section */
            .mobile-btn-grid {
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
                gap: 0.5rem !important;
            }
            .mobile-btn-grid .btn {
                width: 100% !important;
                margin: 0 !important;
                justify-content: center !important;
                padding: 0.75rem 0.5rem !important;
            }
            .mobile-btn-grid .btn-sm {
                padding: 0.75rem 0.5rem !important;
            }
        }
        /* ============================================
         * Handwriting Canvas Modal
         * ============================================ */
        .handwrite-modal {
            position: fixed;
            inset: 0;
            z-index: 200;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(8px);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1rem;
            animation: fadeIn 0.2s ease-out;
        }

        .handwrite-modal-content {
            background: var(--surface);
            border-radius: 16px;
            padding: 1rem;
            width: 100%;
            max-width: 1000px;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            border: 1px solid var(--border-color);
            box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
        }

        .handwrite-modal-content.fullscreen {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            max-width: 100%;
            max-height: 100%;
            width: 100%;
            height: 100%;
            border-radius: 0;
            padding: 0.5rem;
            margin: 0;
        }

        .handwrite-modal:has(.fullscreen) {
            padding: 0;
        }

        .handwrite-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 0.75rem;
        }

        /* Question display area */
        .handwrite-question-area {
            margin-bottom: 0.5rem;
        }

        .handwrite-question-toggle {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.75rem;
            background: var(--surface-highlight);
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.875rem;
            color: var(--text-secondary);
            transition: all 0.2s ease;
        }

        .handwrite-question-toggle:hover {
            background: var(--glass-bg-hover);
        }

        .handwrite-question-toggle .toggle-icon {
            margin-left: auto;
            transition: transform 0.2s ease;
        }

        .handwrite-question-toggle.expanded .toggle-icon {
            transform: rotate(180deg);
        }

        .handwrite-question-content {
            margin-top: 0.5rem;
            padding: 0.75rem;
            background: var(--surface-highlight);
            border-radius: 8px;
            max-height: 150px;
            overflow-y: auto;
            scrollbar-gutter: stable;
            font-size: 0.9rem;
            line-height: 1.6;
        }

        /* Canvas wrapper - scrollable container */
        .handwrite-canvas-wrapper {
            flex: 1;
            position: relative;
            border-radius: 8px;
            border: 2px solid var(--border-color);
            background: #f0f0f0;
            overflow-y: auto;
            scrollbar-gutter: stable;
            overflow-x: hidden;
            max-height: 60vh;
        }

        body[data-theme='dark'] .handwrite-canvas-wrapper {
            background: #2a2a2a;
        }

        .handwrite-canvas-container {
            width: 100%;
            min-height: 500px;
            touch-action: none;
            position: relative;
        }

        .handwrite-canvas {
            display: block;
        }

        /* Canvas area with scroll controls */
        .handwrite-canvas-area {
            flex: 1;
            display: flex;
            gap: 0.5rem;
            min-height: 0;
        }

        /* Scroll control buttons */
        .handwrite-scroll-controls {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            justify-content: center;
        }

        .handwrite-scroll-btn {
            width: 40px;
            height: 60px;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            background: var(--surface-highlight);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .handwrite-scroll-btn:hover {
            background: var(--glass-bg-hover);
            color: var(--text-primary);
        }

        .handwrite-scroll-btn:active {
            background: var(--primary);
            color: white;
            transform: scale(0.95);
        }

        @media (max-width: 768px) {
            .handwrite-scroll-btn {
                width: 36px;
                height: 50px;
            }
        }

        /* Zoom indicator */
        .handwrite-zoom-indicator {
            position: absolute;
            bottom: 10px;
            left: 10px;
            padding: 4px 8px;
            background: rgba(0, 0, 0, 0.6);
            color: white;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 600;
            opacity: 0.6;
            pointer-events: none;
            transition: opacity 0.3s ease;
            z-index: 10;
        }

        /* Hint text */
        .handwrite-hint {
            position: absolute;
            bottom: 10px;
            right: 10px;
            padding: 4px 8px;
            background: rgba(0, 0, 0, 0.5);
            color: white;
            border-radius: 4px;
            font-size: 0.7rem;
            opacity: 0.5;
            pointer-events: none;
            z-index: 10;
        }

        @media (max-width: 768px) {
            .handwrite-hint {
                display: none;
            }
        }

        /* 深色模式画布背景 */
        .handwrite-canvas {
            width: 100%;
            height: 100%;
            cursor: crosshair;
            background: #ffffff;
        }

        /* 浅色模式 - 保持白色背景 */
        body[data-theme='light'] .handwrite-canvas {
            background: #ffffff;
        }

        /* 橡皮擦光标 */
        .handwrite-canvas.eraser-mode {
            cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3C/svg%3E") 12 12, auto;
        }

        .handwrite-toolbar {
            display: flex;
            gap: 0.5rem;
            padding: 0.75rem 0;
            flex-wrap: wrap;
            align-items: center;
        }

        .handwrite-tools {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
            flex: 1;
        }

        .handwrite-actions {
            display: flex;
            gap: 0.5rem;
        }

        .handwrite-tool-btn {
            padding: 0.5rem 0.75rem;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            background: var(--surface-highlight);
            color: var(--text-primary);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 0.25rem;
            transition: all 0.2s ease;
            font-size: 0.875rem;
        }

        .handwrite-tool-btn:hover {
            background: var(--glass-bg-hover);
            border-color: var(--border-hover);
        }

        .handwrite-tool-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .handwrite-tool-btn.danger {
            color: var(--error);
            border-color: var(--error);
        }

        .handwrite-tool-btn.danger:hover {
            background: var(--error);
            color: white;
        }

        .handwrite-tool-btn.success {
            background: var(--success);
            color: white;
            border-color: var(--success);
        }

        .handwrite-tool-btn.success:hover {
            background: #059669;
        }

        /* 笔画粗细选择器 */
        .stroke-width-selector {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0 0.5rem;
        }

        .stroke-width-selector input[type="range"] {
            width: 80px;
            height: 6px;
            background: var(--surface-highlight);
            border-radius: 3px;
            outline: none;
            cursor: pointer;
        }

        .stroke-width-selector input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            background: var(--primary);
            border-radius: 50%;
            cursor: pointer;
        }

        /* 颜色选择器 */
        .color-picker-wrapper {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .color-picker-wrapper input[type="color"] {
            -webkit-appearance: none;
            appearance: none;
            width: 32px;
            height: 32px;
            border: 2px solid var(--border-color);
            border-radius: 8px;
            cursor: pointer;
            padding: 0;
            background: none;
        }

        .color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
            padding: 2px;
        }

        .color-picker-wrapper input[type="color"]::-webkit-color-swatch {
            border-radius: 4px;
            border: none;
        }

        /* 移动端适配 */
        @media (max-width: 768px) {
            .handwrite-modal {
                padding: 0.5rem;
            }

            .handwrite-modal-content {
                padding: 0.75rem;
                max-height: 95vh;
            }

            .handwrite-modal-content.fullscreen {
                padding: 0.25rem;
            }

            .handwrite-canvas-container {
                min-height: 250px;
            }

            .handwrite-toolbar {
                padding: 0.5rem 0;
                gap: 0.375rem;
            }

            .handwrite-tool-btn {
                padding: 0.4rem 0.6rem;
                font-size: 0.8rem;
            }

            .handwrite-tool-btn .btn-text {
                display: none;
            }

            .stroke-width-selector {
                padding: 0 0.25rem;
            }

            .stroke-width-selector input[type="range"] {
                width: 60px;
            }

            /* 短答题按钮移动端适配 */
            .short-answer-container .flex.items-center.gap-2 {
                flex-wrap: wrap;
            }

            .short-answer-camera-btn,
            .short-answer-upload-btn,
            .short-answer-handwrite-btn {
                flex: 1;
                min-width: 80px;
                justify-content: center;
            }

            .short-answer-img-hint {
                width: 100%;
                text-align: center;
                margin-top: 0.25rem;
            }

            /* 填空题输入框移动端适配 - 缩小尺寸 */
            .fill-in-blank-input {
                width: 70px !important;
                padding: 0.25rem 0.5rem !important;
                margin: 0.2rem 0.15rem !important;
                font-size: 0.85rem !important;
            }
        }

        @media (max-width: 480px) {
            .handwrite-header h3 {
                font-size: 1rem;
            }

            .handwrite-tools {
                width: 100%;
                justify-content: space-between;
            }

            .handwrite-actions {
                width: 100%;
                justify-content: flex-end;
            }
        }
    
/* Export menu styles */
.quiz-export-menu {
    z-index: 1000;
    animation: exportMenuFadeIn 0.15s ease-out;
}
@keyframes exportMenuFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.quiz-export-menu .export-option-btn:hover {
    background-color: var(--surface-highlight) !important;
}
.quiz-export-menu .export-option-btn:active {
    opacity: 0.6 !important;
}

/* 首屏优先：让题库列表在接口返回前保持稳定的可感知布局。 */
#appBootProgress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 10000;
    height: 3px;
    background: transparent;
    pointer-events: none;
    opacity: 1;
    transition: opacity .35s ease;
}
#appBootProgress::before {
    content: '';
    display: block;
    width: var(--boot-progress, 18%);
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 55%, transparent);
    transition: width .35s ease;
}
#appBootProgress.ready { opacity: 0; }
#appBootStatus {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
    font-size: .75rem;
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
}
#appBootStatus.ready { opacity: 0; transform: translate(-50%, -6px); }
.quiz-library-skeleton {
    min-height: 180px;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: linear-gradient(110deg, var(--surface) 8%, var(--surface-highlight) 18%, var(--surface) 33%);
    background-size: 200% 100%;
    animation: quizSkeletonShimmer 1.25s linear infinite;
}
@keyframes quizSkeletonShimmer { to { background-position-x: -200%; } }
@media (prefers-reduced-motion: reduce) {
    #appBootProgress::before, .quiz-library-skeleton { animation: none; transition: none; }
}

