/* ========== BINGO ALEVEL 全域主题系统 v3 ========== */
/* 6套主题全部确保高对比度: body渐变浅色底 + 深色文字 + 白色卡片 */

/* ---------- 经典紫 (明亮模式) ---------- */
:root,
[data-theme="default"] {
    --theme-bg: linear-gradient(135deg, #f0ecfc 0%, #e8e0f8 50%, #f5f0ff 100%);
    --theme-bg-solid: #f0ecfc;
    --theme-body-text: #2c2048;
    --theme-body-text-shadow: none;
    --theme-accent: #7c5ce7;
    --theme-accent-2: #9b7cf0;
    --theme-surface: #ffffff;
    --theme-surface-hover: #f8f6fe;
    --theme-surface-alt: rgba(255,255,255,0.94);
    --theme-text: #1a1a2e;
    --theme-text-secondary: #4a4a6a;
    --theme-text-muted: #6e6e8a;
    --gray: #5a5a78;
    --text-secondary: #4a4a6a;
    --primary-color: #7c5ce7;
    --text-color: #1a1a2e;
    --card-bg: #ffffff;
    --bg-primary: #ffffff;
    --theme-border: #e0dcf0;
    --theme-navbar-bg: rgba(255,255,255,0.95);
    --theme-navbar-text: #2c2048;
    --theme-input-bg: #ffffff;
    --theme-input-text: #1a1a2e;
    --theme-input-border: #d8d4ec;
    --theme-btn-primary: #7c5ce7;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: #d8d4ec;
    --theme-btn-outline-text: #5a4a8a;
    --theme-shadow: 0 2px 12px rgba(124,92,231,0.10);
    --theme-picker-bg: #ffffff;
    --theme-picker-text: #2c2048;
    --theme-flash-success: #d4edda;
    --theme-flash-error: #f8d7da;
    --theme-stat-value: #7c5ce7;
}

/* ---------- 海洋蓝 (明亮模式) ---------- */
[data-theme="ocean"] {
    --theme-bg: linear-gradient(135deg, #e8f4fd 0%, #d4ecfa 50%, #ecf5fd 100%);
    --theme-bg-solid: #e8f4fd;
    --theme-body-text: #1a3050;
    --theme-body-text-shadow: none;
    --theme-accent: #2193b0;
    --theme-accent-2: #4ab8d8;
    --theme-surface: #ffffff;
    --theme-surface-hover: #f0f8fc;
    --theme-surface-alt: rgba(255,255,255,0.94);
    --theme-text: #1a2838;
    --theme-text-secondary: #445a70;
    --theme-text-muted: #5a6e84;
    --gray: #445a70;
    --text-secondary: #445a70;
    --primary-color: #2193b0;
    --text-color: #1a2838;
    --card-bg: #ffffff;
    --bg-primary: #ffffff;
    --theme-border: #c8dde8;
    --theme-navbar-bg: rgba(255,255,255,0.95);
    --theme-navbar-text: #1a3050;
    --theme-input-bg: #ffffff;
    --theme-input-text: #1a2838;
    --theme-input-border: #b4d0e0;
    --theme-btn-primary: #2193b0;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: #b4d0e0;
    --theme-btn-outline-text: #2b6a82;
    --theme-shadow: 0 2px 12px rgba(33,147,176,0.10);
    --theme-picker-bg: #ffffff;
    --theme-picker-text: #1a3050;
    --theme-flash-success: #d4edda;
    --theme-flash-error: #f8d7da;
    --theme-stat-value: #2193b0;
}

/* ---------- 落日橙 (明亮模式) ---------- */
[data-theme="sunset"] {
    --theme-bg: linear-gradient(135deg, #fef5f0 0%, #fde8dd 50%, #fef0ea 100%);
    --theme-bg-solid: #fef5f0;
    --theme-body-text: #3d2020;
    --theme-body-text-shadow: none;
    --theme-accent: #e85d3e;
    --theme-accent-2: #f09070;
    --theme-surface: #ffffff;
    --theme-surface-hover: #fef5f2;
    --theme-surface-alt: rgba(255,255,255,0.94);
    --theme-text: #2a1a18;
    --theme-text-secondary: #5a4040;
    --theme-text-muted: #705050;
    --gray: #5a4040;
    --text-secondary: #5a4040;
    --primary-color: #e85d3e;
    --text-color: #2a1a18;
    --card-bg: #ffffff;
    --bg-primary: #ffffff;
    --theme-border: #e8d0c8;
    --theme-navbar-bg: rgba(255,255,255,0.95);
    --theme-navbar-text: #3d2020;
    --theme-input-bg: #ffffff;
    --theme-input-text: #2a1a18;
    --theme-input-border: #e0c0b8;
    --theme-btn-primary: #e85d3e;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: #e0c0b8;
    --theme-btn-outline-text: #8b3a2a;
    --theme-shadow: 0 2px 12px rgba(232,93,62,0.10);
    --theme-picker-bg: #ffffff;
    --theme-picker-text: #3d2020;
    --theme-flash-success: #d4edda;
    --theme-flash-error: #f8d7da;
    --theme-stat-value: #e85d3e;
}

/* ---------- 樱花粉 (明亮模式) ---------- */
[data-theme="sakura"] {
    --theme-bg: linear-gradient(135deg, #fdf0f6 0%, #fce4f0 50%, #fef5fa 100%);
    --theme-bg-solid: #fdf0f6;
    --theme-body-text: #3d1a2e;
    --theme-body-text-shadow: none;
    --theme-accent: #ec6ead;
    --theme-accent-2: #f08cc8;
    --theme-surface: #ffffff;
    --theme-surface-hover: #fdf5f9;
    --theme-surface-alt: rgba(255,255,255,0.94);
    --theme-text: #2a1a24;
    --theme-text-secondary: #5a3a4e;
    --theme-text-muted: #6a4a5e;
    --gray: #5a3a4e;
    --text-secondary: #5a3a4e;
    --primary-color: #ec6ead;
    --text-color: #2a1a24;
    --card-bg: #ffffff;
    --bg-primary: #ffffff;
    --theme-border: #f0d4e4;
    --theme-navbar-bg: rgba(255,255,255,0.95);
    --theme-navbar-text: #3d1a2e;
    --theme-input-bg: #ffffff;
    --theme-input-text: #2a1a24;
    --theme-input-border: #e8c4d8;
    --theme-btn-primary: #ec6ead;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: #e8c4d8;
    --theme-btn-outline-text: #8b3a6e;
    --theme-shadow: 0 2px 12px rgba(236,110,173,0.10);
    --theme-picker-bg: #ffffff;
    --theme-picker-text: #3d1a2e;
    --theme-flash-success: #d4edda;
    --theme-flash-error: #f8d7da;
    --theme-stat-value: #ec6ead;
}

/* ---------- 森林绿 (明亮模式) ---------- */
[data-theme="forest"] {
    --theme-bg: linear-gradient(135deg, #e8f5e9 0%, #dcf0e0 50%, #f0faf2 100%);
    --theme-bg-solid: #e8f5e9;
    --theme-body-text: #1a2e1a;
    --theme-body-text-shadow: none;
    --theme-accent: #38a169;
    --theme-accent-2: #68d391;
    --theme-surface: #ffffff;
    --theme-surface-hover: #f0faf2;
    --theme-surface-alt: rgba(255,255,255,0.94);
    --theme-text: #1a2818;
    --theme-text-secondary: #3a5a38;
    --theme-text-muted: #4a6a48;
    --gray: #3a5a38;
    --text-secondary: #3a5a38;
    --primary-color: #38a169;
    --text-color: #1a2818;
    --card-bg: #ffffff;
    --bg-primary: #ffffff;
    --theme-border: #c8e8c8;
    --theme-navbar-bg: rgba(255,255,255,0.95);
    --theme-navbar-text: #1a2e1a;
    --theme-input-bg: #ffffff;
    --theme-input-text: #1a2818;
    --theme-input-border: #b8d8b8;
    --theme-btn-primary: #38a169;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: #b8d8b8;
    --theme-btn-outline-text: #2a6a2a;
    --theme-shadow: 0 2px 12px rgba(56,161,105,0.10);
    --theme-picker-bg: #ffffff;
    --theme-picker-text: #1a2e1a;
    --theme-flash-success: #c6f6d5;
    --theme-flash-error: #f8d7da;
    --theme-stat-value: #38a169;
}

/* ---------- 暗夜黑 (深色模式) ---------- */
[data-theme="dark"] {
    --theme-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1e1e38 100%);
    --theme-bg-solid: #1a1a2e;
    --theme-body-text: #e8ecf2;
    --theme-body-text-shadow: none;
    --theme-accent: #5b9fe8;
    --theme-accent-2: #7eb8f0;
    --theme-surface: #252538;
    --theme-surface-hover: #2e2e44;
    --theme-surface-alt: #1e1e32;
    --theme-text: #e0e4ec;
    --theme-text-secondary: #a0a8b8;
    --theme-text-muted: #6e7688;
    --gray: #788298;
    --text-secondary: #a0a8b8;
    --primary-color: #5b9fe8;
    --text-color: #e0e4ec;
    --card-bg: #252538;
    --bg-primary: #1a1a2e;
    --theme-border: rgba(255,255,255,0.10);
    --theme-navbar-bg: rgba(26,26,46,0.95);
    --theme-navbar-text: #e0e4ec;
    --theme-input-bg: rgba(255,255,255,0.06);
    --theme-input-text: #e0e4ec;
    --theme-input-border: rgba(255,255,255,0.12);
    --theme-btn-primary: #5b9fe8;
    --theme-btn-primary-text: #ffffff;
    --theme-btn-outline: rgba(91,159,232,0.25);
    --theme-btn-outline-text: #a8c8f0;
    --theme-shadow: 0 2px 16px rgba(0,0,0,0.50);
    --theme-picker-bg: #252538;
    --theme-picker-text: #e0e4ec;
    --theme-flash-success: rgba(72,187,120,0.15);
    --theme-flash-error: rgba(231,76,60,0.15);
    --theme-stat-value: #5b9fe8;
}


/* ========== 全局 UI 应用 ========== */

/* 背景 + 身体文字（渐变背景上的文字色，独立于卡片内文字） */
body {
    background: var(--theme-bg) !important;
    background-attachment: fixed !important;
    color: var(--theme-body-text, var(--theme-text));
}

/* 首页 Hero 区域：文字着色 + 阴影增强可读性 */
.hero-title, .hero-subtitle, .hero-badge, .hero-badge span,
.hero-stats .stat-number, .hero-stats .stat-label {
    text-shadow: var(--theme-body-text-shadow, none);
}
.hero-title {
    color: var(--theme-body-text, #fff) !important;
}
.hero-subtitle {
    color: var(--theme-body-text, var(--gray)) !important;
}
.hero-stats .stat-number {
    color: var(--theme-body-text, var(--theme-text)) !important;
}
.hero-stats .stat-label {
    color: var(--theme-body-text, var(--gray)) !important;
    opacity: 0.80;
}

/* ========== 侧边栏导航（学习/管理页面） ========== */
.navbar, nav.navbar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 220px !important;
    height: 100vh !important;
    min-height: 100vh !important;
    padding: 20px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    background: var(--theme-surface) !important;
    border-right: 1px solid var(--theme-border) !important;
    border-bottom: none !important;
    z-index: 100 !important;
    overflow-y: auto !important;
}
.nav-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    gap: 0 !important;
}
.nav-logo { 
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    flex-shrink: 0 !important;
    padding: 4px 8px 16px !important;
    border-bottom: 1px solid var(--theme-border) !important;
    margin-bottom: 16px !important;
}
.nav-links {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    align-items: stretch !important;
    flex: 1 !important;
}
.nav-links a, .nav-link {
    color: var(--theme-navbar-text) !important;
    font-weight: 500 !important;
    font-size: 0.88rem !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    text-decoration: none !important;
    display: block !important;
    transition: all 0.2s !important;
}
.nav-links a:hover, .nav-link:hover {
    background: var(--theme-surface-hover) !important;
    color: var(--theme-accent) !important;
    opacity: 1 !important;
}
.nav-links a.active, .nav-link.active {
    background: var(--theme-accent) !important;
    color: #fff !important;
    font-weight: 600 !important;
}
.nav-logo, .nav-logo span {
    color: var(--theme-accent) !important;
}
.nav-logo i {
    width: 42px !important;
    height: 42px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, var(--theme-accent), #48bb78) !important;
    color: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.35rem !important;
    flex-shrink: 0 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
}
.nav-logo span {
    font-size: 1.12rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.3px !important;
}
/* 首页顶部导航 Logo 保持小尺寸 */
body.home .nav-logo i {
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
    background: none !important;
    color: var(--theme-accent) !important;
    font-size: 1.2rem !important;
    box-shadow: none !important;
}
body.home .nav-logo span {
    font-size: 1rem !important;
    font-weight: 700 !important;
}
.nav-auth {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding-top: 16px !important;
    border-top: 1px solid var(--theme-border) !important;
    margin-top: 16px !important;
}
.nav-auth .user-name {
    color: var(--theme-navbar-text);
    font-size: 0.85rem !important;
    padding: 0 8px !important;
    word-break: break-all !important;
}

/* 首页保持顶部导航 */
body.home .navbar, body.home nav.navbar {
    position: sticky !important;
    left: auto !important;
    top: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 16px !important;
    flex-direction: row !important;
    align-items: center !important;
    border-right: none !important;
    border-bottom: 1px solid var(--theme-border) !important;
    overflow: visible !important;
}
body.home .nav-container {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: auto !important;
}
body.home .nav-logo { border-bottom: none !important; margin-bottom: 0 !important; padding: 0 !important; }
body.home .nav-links { flex-direction: row !important; gap: 20px !important; flex: none !important; }
body.home .nav-links a, body.home .nav-link { padding: 4px 0 !important; display: inline !important; }
body.home .nav-auth { flex-direction: row !important; align-items: center !important; gap: 8px !important; border-top: none !important; margin-top: 0 !important; padding-top: 0 !important; }

/* 侧边栏时内容区留出左侧空间 */
body:not(.home) main,
body:not(.home) .dashboard-main,
body:not(.home) .topics-page,
body:not(.home) .notes-page,
body:not(.home) .exercises-page,
body:not(.home) .topic-detail,
body:not(.home) .page {
    margin-left: 220px !important;
}
body:not(.home) .exam-layout {
    margin-left: 220px !important;
    width: calc(100% - 220px) !important;
}

/* 全局主题选择器保底 */
.theme-picker-btn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: var(--theme-surface) !important;
    border: 2px solid var(--theme-border) !important;
    cursor: pointer !important;
    font-size: 1.2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
}
.theme-picker-panel {
    position: fixed !important;
    bottom: 70px !important;
    right: 20px !important;
    z-index: 99998 !important;
    background: var(--theme-surface) !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 12px !important;
    padding: 16px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4) !important;
    display: none !important;
}
.theme-picker-panel.open { display: block !important; }

/* ========== AI 学习助手 ========== */
.ai-assistant-btn {
    position: fixed !important;
    bottom: 70px !important;
    right: 20px !important;
    z-index: 99997 !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: var(--theme-accent) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3) !important;
    transition: transform 0.2s !important;
}
.ai-assistant-btn:hover { transform: scale(1.08) !important; }
.ai-assistant-panel {
    position: fixed !important;
    bottom: 126px !important;
    right: 20px !important;
    z-index: 99996 !important;
    width: 300px !important;
    max-height: 480px !important;
    background: var(--theme-surface) !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35) !important;
    display: none !important;
    overflow: hidden !important;
}
.ai-assistant-panel.open { display: block !important; }
.ai-header {
    display: flex !important; justify-content: space-between !important; align-items: center !important;
    padding: 12px 16px !important; border-bottom: 1px solid var(--theme-border) !important;
    background: var(--theme-surface-hover) !important;
}
.ai-title { display: flex !important; align-items: center !important; gap: 8px !important; font-weight: 700 !important; font-size: 0.9rem !important; color: var(--theme-accent) !important; }
.ai-close { background: none !important; border: none !important; font-size: 1.4rem !important; color: var(--theme-text-muted) !important; cursor: pointer !important; line-height: 1 !important; }
.ai-body { padding: 16px !important; overflow-y: auto !important; }
.ai-tip { font-size: 0.8rem !important; color: var(--theme-text-muted) !important; margin-bottom: 12px !important; }
.ai-games { display: flex !important; flex-direction: column !important; gap: 8px !important; }
.ai-game-card {
    display: flex !important; align-items: center !important; gap: 10px !important;
    padding: 12px 14px !important; border: 1px solid var(--theme-border) !important;
    border-radius: 10px !important; background: var(--theme-surface) !important;
    cursor: pointer !important; color: var(--theme-text) !important;
    font-size: 0.88rem !important; font-weight: 500 !important; transition: all 0.2s !important;
}
.ai-game-card:hover { border-color: var(--theme-accent) !important; background: var(--theme-surface-hover) !important; }
.ai-game-icon { font-size: 1.4rem !important; }
.ai-game-box { text-align: center !important; }
.ai-game-head { font-size: 0.85rem !important; font-weight: 700 !important; margin-bottom: 14px !important; color: var(--theme-text) !important; display: flex !important; justify-content: space-between !important; }
.ai-binary { font-size: 1.3rem !important; font-weight: 800 !important; color: var(--theme-accent) !important; margin-bottom: 6px !important; }
.ai-sub { font-size: 0.75rem !important; color: var(--theme-text-muted) !important; font-weight: 400 !important; }
.ai-ask { font-size: 0.82rem !important; color: var(--theme-text-muted) !important; margin: 8px 0 !important; }
.ai-input {
    width: 100% !important; padding: 8px 12px !important; border-radius: 8px !important;
    border: 1px solid var(--theme-border) !important; background: var(--theme-input-bg) !important;
    color: var(--theme-input-text) !important; font-size: 0.9rem !important; margin-bottom: 10px !important; text-align: center !important;
}
.ai-btn {
    display: inline-block !important; padding: 8px 20px !important; border-radius: 8px !important;
    border: none !important; background: var(--theme-accent) !important; color: #fff !important;
    cursor: pointer !important; font-size: 0.85rem !important; font-weight: 600 !important; margin: 4px !important;
}
.ai-btn-ghost { background: transparent !important; border: 1px solid var(--theme-border) !important; color: var(--theme-text) !important; }
.ai-options { display: flex !important; gap: 10px !important; justify-content: center !important; margin: 10px 0 !important; }
.ai-opt {
    width: 56px !important; height: 56px !important; border-radius: 12px !important;
    border: 2px solid var(--theme-border) !important; background: var(--theme-surface) !important;
    color: var(--theme-text) !important; font-size: 1.4rem !important; font-weight: 700 !important;
    cursor: pointer !important; transition: all 0.2s !important;
}
.ai-opt:hover { border-color: var(--theme-accent) !important; background: var(--theme-surface-hover) !important; }
.ai-quiz-options { flex-direction: column !important; }
.ai-quiz-opt { width: 100% !important; height: auto !important; padding: 10px !important; font-size: 0.85rem !important; text-align: left !important; }
.ai-result { font-size: 1.1rem !important; font-weight: 700 !important; margin: 10px 0 !important; }

/* 卡片 —— 覆盖所有白色/浅色卡片 */
.card, .stat-card, .stat-card-modern,
.student-card, .auth-card, .auth-container .auth-card,
.note-card, .paper-card, .question-card,
.form-container, .review-container,
.exam-container .paper-panel,
.appointment-card, .booking-card,
.notification-card, .topic-card,
.dashboard-card, .progress-card,
.student-detail-card, .papers-container .paper-item,
.filter-card, .settings-card,
.feature-card {
    background: var(--theme-surface) !important;
    color: var(--theme-text);
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow);
}

/* 卡片 hover */
.student-card:hover, .question-card:hover,
.card:hover, .note-card:hover, .paper-card:hover,
.feature-card:hover {
    background: var(--theme-surface-hover) !important;
}

/* 页面标题和段落（卡片内） */
h1, h2, h3, h4, h5, h6 {
    color: var(--theme-text);
}
.page-title, .auth-header h1, .auth-header p {
    color: var(--theme-text);
}
p, td, th, li {
    color: var(--theme-text);
}
.text-muted, .stat-label, .stat-label-modern, label {
    color: var(--theme-text-secondary);
}
.stat-value, .stat-value-modern {
    color: var(--theme-stat-value);
}
.auth-header p {
    color: var(--theme-text-secondary);
}
.feature-card p {
    color: var(--gray);
}

/* 表单 */
input, textarea, select {
    background: var(--theme-input-bg) !important;
    color: var(--theme-input-text) !important;
    border-color: var(--theme-input-border) !important;
}
input::placeholder, textarea::placeholder {
    color: var(--theme-text-muted);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--theme-accent) !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* 按钮 */
.btn-primary, .btn.btn-primary, button.btn-primary {
    background: var(--theme-btn-primary) !important;
    color: var(--theme-btn-primary-text) !important;
    border-color: var(--theme-btn-primary) !important;
}
.btn-primary:hover {
    filter: brightness(1.12);
}

.btn-outline, .btn.btn-outline, button.btn-outline,
.btn-small.btn-outline {
    background: transparent !important;
    color: var(--theme-btn-outline-text) !important;
    border: 1px solid var(--theme-btn-outline) !important;
}
.btn-outline:hover, .btn-small.btn-outline:hover {
    background: var(--theme-surface-hover) !important;
}

.btn-success, .btn.btn-success {
    background: #38a169 !important;
    color: #ffffff !important;
}

.btn-secondary, button.btn-secondary {
    background: var(--theme-text-muted) !important;
    color: var(--theme-btn-primary-text) !important;
}

.btn-icon {
    color: var(--theme-text-secondary);
}
.btn-icon:hover {
    color: var(--theme-text);
}

.btn-refresh {
    color: var(--theme-text-secondary);
}
.btn-refresh:hover {
    color: var(--theme-accent);
}

/* 搜索和筛选 */
.search-box, .search-filter, .filter-controls {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
}
.search-box i {
    color: var(--theme-text-muted);
}

/* 进度条 */
.progress-bar, .progress-fill {
    background: var(--theme-accent);
}

/* 通知/Flash消息 */
.flash-messages.flash-success, .alert-success,
.flash-message.flash-success, .flash-success {
    background: var(--theme-flash-success) !important;
    color: var(--theme-text);
}
.flash-messages.flash-error, .alert-error,
.flash-message.flash-error, .flash-error {
    background: var(--theme-flash-error) !important;
    color: var(--theme-text);
}

/* 模态框 */
.modal, .modal-content, .modal-container {
    background: var(--theme-surface) !important;
    color: var(--theme-text);
}
.modal-header h3, .modal-title {
    color: var(--theme-text);
}

/* 表格 */
table, thead, tbody {
    color: var(--theme-text);
}
thead {
    background: var(--theme-surface-hover);
}
th {
    color: var(--theme-text-secondary);
    border-bottom: 1px solid var(--theme-border);
}
td {
    border-bottom: 1px solid var(--theme-border);
}

/* 文件上传 */
.upload-area, .upload-zone {
    background: var(--theme-surface-hover);
    border: 2px dashed var(--theme-border);
}

/* 下拉和标签 */
.student-badge, .badge {
    background: var(--theme-surface-hover);
    color: var(--theme-text-secondary);
}

/* 链接 */
a:not(.btn):not(.nav-link):not(.nav-links a):not(.btn-pdf-link) {
    color: var(--theme-accent);
}


/* ========== 终极兜底：直接覆盖所有常见的浅色/深色硬编码文字 ========== */
/* 这些规则在 CSS 文件最末尾，配合 !important 确保不会被任何页内样式覆盖 */

/* 渐变背景上的文字 → 用 body-text（已按主题优化对比度） */
.meta-item,
.meta-item span,
.meta-item i,
.meta-item-modern,
.meta-item-modern span,
.meta-item-modern i,
.welcome-content-improved h1,
.welcome-content-improved p,
.welcome-content-improved .welcome-subtitle,
.herosubtitle,
.welcome-subtitle,
.welcome-meta,
.daily-goal h3,
.daily-goal p,
.daily-goal-section p,
.daily-goal-section h3 {
    color: var(--theme-body-text, var(--theme-text)) !important;
}

/* 卡片内部的次要文字 */
.progress-label,
.stat-details,
.stat-label-modern,
.stat-card .stat-label,
.feature-desc,
.topic-meta,
.paper-meta,
.student-meta,
.note-meta span,
.notification-message,
.exam-mode-toggle span,
.paper-info span,
.dashboard-card p {
    color: var(--theme-text) !important;
}

/* 表单 placeholder 灰字 */
input::placeholder,
textarea::placeholder,
.form-input::placeholder {
    color: var(--theme-text-muted, #64748b) !important;
    opacity: 1 !important;
}

/* 统计数字（Stat 卡片内的大数字） */
.stat-card .stat-number,
.stat-card .stat-value,
.stat-value,
.stat-card-modern .stat-value-modern {
    color: var(--theme-accent) !important;
}

/* 白色文字下沉到暗色背景上的元素（按钮、标签等）→ 保持白色不变 */
.btn-primary,
.btn-primary span,
.btn-primary i,
.btn-success,
.btn-success span,
.btn-submit,
.tab-btn.active,
.tool-btn.active,
.mode-btn.active,
.paper-tab.active {
    /* 不覆盖 —— 这些是有深色背景的按钮/标签，白字是设计的 */
}

/* 特意白字的地方（深色背景徽章、暗色面板内文字） */
.student-badge,
.badge,
.daily-goal-section {
    /* 这些元素本身有暗色背景，白字合理 */
}


/* ========== 主题选择器 UI ========== */
.theme-picker-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--theme-surface);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    font-size: 1.3rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--theme-border);
    user-select: none;
}

.theme-picker-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.theme-picker-panel {
    position: fixed;
    right: 20px;
    bottom: 80px;
    background: var(--theme-picker-bg);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.30);
    z-index: 9999;
    width: 240px;
    display: none;
    border: 1px solid var(--theme-border);
}

.theme-picker-panel.open {
    display: block;
    animation: themePanelIn 0.2s ease-out;
}

@keyframes themePanelIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.theme-picker-panel h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--theme-picker-text);
    font-family: 'Inter', -apple-system, sans-serif;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 4px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.15s;
    background: none;
}

.theme-option:hover {
    background: var(--theme-surface-hover);
}

.theme-option.active {
    border-color: var(--theme-accent);
    background: var(--theme-surface-hover);
}

.theme-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.theme-name {
    font-size: 0.75rem;
    color: var(--theme-picker-text);
    font-family: 'Inter', -apple-system, sans-serif;
}
/* ========== 移动端响应式 ========== */
@media (max-width: 768px) {
    .nav-container { flex-wrap: wrap; gap: 8px; }
    .nav-links { flex-wrap: wrap; gap: 4px; }
    /* 侧边栏回退为顶部导航 */
    body:not(.home) .navbar, body:not(.home) nav.navbar {
        position: sticky !important;
        left: auto !important; top: 0 !important; bottom: auto !important;
        width: 100% !important; height: auto !important; min-height: auto !important;
        padding: 10px 12px !important;
        flex-direction: row !important; align-items: center !important;
        border-right: none !important; border-bottom: 1px solid var(--theme-border) !important;
    }
    body:not(.home) .nav-container { flex-direction: row !important; align-items: center !important; }
    body:not(.home) .nav-logo { border-bottom: none !important; margin-bottom: 0 !important; padding: 0 !important; }
    body:not(.home) .nav-links { flex-direction: row !important; gap: 8px !important; flex-wrap: wrap !important; }
    body:not(.home) .nav-links a, body:not(.home) .nav-link { padding: 4px 10px !important; }
    body:not(.home) .nav-auth { flex-direction: row !important; border-top: none !important; margin-top: 0 !important; padding-top: 0 !important; }
    body:not(.home) main, body:not(.home) .page, body:not(.home) .dashboard-main,
    body:not(.home) .topics-page, body:not(.home) .notes-page,
    body:not(.home) .exercises-page, body:not(.home) .topic-detail { margin-left: 0 !important; }
    body:not(.home) .exam-layout { margin-left: 0 !important; width: 100% !important; }
    .nav-links a, .nav-link { font-size: 0.75rem; padding: 4px 8px; }
    .exam-container { flex-direction: column !important; }
    .paper-panel, .code-panel { width: 100% !important; min-width: unset !important; }
    .topic-content-grid { grid-template-columns: 1fr !important; }
    .exercises-list .exercise-item { padding: 12px; }
    .hero-stats { flex-direction: column; gap: 1rem; }
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .auth-card, .auth-container { width: 90% !important; max-width: 400px; margin: 0 auto; }
    .admin-layout { padding: 12px; }
    .pdf-viewer iframe { height: 400px !important; }
    .stat-card { padding: 12px; }
    .stat-card h3 { font-size: 1.2rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    .btn { padding: 6px 14px; font-size: 0.85rem; }
    .toolbar { flex-direction: column; }
    .toolbar select { width: 100%; }
    .theme-picker-btn { right: 10px; bottom: 10px; width: 40px; height: 40px; }
    .theme-picker-panel { right: 10px; bottom: 60px; width: 200px; }
}
/* ========== 全局文本对比度保障 ========== */
[data-theme] .btn-xs.view, [data-theme] .btn-sm.view, [data-theme] .btn.view {
    color: #fff !important;
}
[data-theme] .btn-outline, [data-theme] .btn-sm.btn-outline, [data-theme] .btn-xs.btn-outline {
    color: var(--theme-text);
    border-color: var(--theme-border);
}
[data-theme] .btn-xs.ans {
    color: #48bb78 !important;
    border-color: #48bb78 !important;
}
[data-theme] .pc-session, [data-theme] .pc-title {
    color: var(--theme-text);
}
[data-theme] .page .subtitle, [data-theme] .page p {
    color: var(--theme-text-secondary);
}
