/* ========================================
   家庭学习乐园 - 样式表
   平板/手机优先，色彩明亮，触控友好
   ======================================== */

:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #F0F4FF;
    --card-bg: #FFFFFF;
    --text: #1F2937;
    --text-light: #6B7280;
    --border: #E5E7EB;
    --radius: 16px;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* === 页面切换 === */
.page { display: none; }
.page.active { display: block; }

/* === 登录页 === */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-container h1 {
    color: white;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: rgba(255,255,255,0.8);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

#login-form, #register-form {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}

#login-form input, #register-form input, #register-form select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 12px;
    transition: border-color 0.2s;
    outline: none;
}

#login-form input:focus, #register-form input:focus, #register-form select:focus {
    border-color: var(--primary);
}

.grade-select label, .avatar-select label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.avatar-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.avatar-opt {
    font-size: 1.8rem;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.avatar-opt:hover { transform: scale(1.1); }
.avatar-opt.selected {
    border-color: var(--primary);
    background: rgba(79,70,229,0.1);
}

.error-msg {
    color: #FCA5A5;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.5em;
}

/* === 按钮 === */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: #F3F4F6;
    color: var(--text);
}
.btn-secondary:hover { background: #E5E7EB; }

/* === 顶部栏 === */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar {
    font-size: 1.8rem;
}

.user-name {
    font-weight: 600;
    font-size: 1rem;
}

.score-badge {
    background: #FEF3C7;
    color: #92400E;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: #F3F4F6;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}
.icon-btn:active { transform: scale(0.95); }

/* === 底部导航 === */
.bottom-nav {
    display: flex;
    background: white;
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.75rem;
    transition: color 0.2s;
}

.nav-item .nav-icon { font-size: 1.4rem; }
.nav-item.active { color: var(--primary); }

/* === 内容区 === */
.content {
    padding: 16px 16px 100px 16px;
    max-width: 768px;
    margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* === 科目网格 === */
.section {
    margin-bottom: 24px;
}

.section h2 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--text);
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.subject-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}

.subject-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.subject-card:active { transform: scale(0.97); }

.subject-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.subject-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}

.subject-count {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* === 章节列表 === */
.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
}

.version-tag {
    display: inline-block;
    background: #EDE9FE;
    color: var(--primary-dark);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 16px;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chapter-item {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chapter-item:hover {
    background: #F8F7FF;
    transform: translateX(4px);
}

.chapter-item:active { transform: scale(0.99); }

.chapter-num {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chapter-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.chapter-arrow {
    color: var(--text-light);
    font-size: 1.2rem;
}

/* === 答题页面 === */
.loading-box {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-box .hint {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 8px;
}

.quiz-progress {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 600;
}

.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.question-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.question-type.choice { background: #DBEAFE; color: #1D4ED8; }
.question-type.judge { background: #FEF3C7; color: #92400E; }
.question-type.short { background: #D1FAE5; color: #065F46; }

.question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text);
}

.options-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.option-btn {
    background: white;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover { border-color: var(--primary-light); background: #F8F7FF; }
.option-btn.selected { border-color: var(--primary); background: #EDE9FE; }
.option-btn.correct { border-color: var(--success); background: #D1FAE5; }
.option-btn.wrong { border-color: var(--danger); background: #FEE2E2; }

.option-btn input[type="radio"] {
    display: none;
}

.feedback {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 1.1rem;
}

.feedback.correct { background: #D1FAE5; color: #065F46; }
.feedback.wrong { background: #FEE2E2; color: #991B1B; }

.explanation {
    background: #F0F4FF;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.6;
    font-size: 0.95rem;
}

.explanation::before {
    content: "💡 解析：";
    font-weight: 600;
}

.quiz-actions {
    display: flex;
    gap: 12px;
}

/* 判断题选项 */
.judge-options {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.judge-btn {
    flex: 1;
    background: white;
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.judge-btn:hover { border-color: var(--primary-light); }
.judge-btn.selected { border-color: var(--primary); background: #EDE9FE; }
.judge-btn.correct { border-color: var(--success); background: #D1FAE5; }
.judge-btn.wrong { border-color: var(--danger); background: #FEE2E2; }

/* 简答题输入 */
.short-answer-input {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    margin-bottom: 16px;
    font-family: inherit;
}

.short-answer-input:focus { border-color: var(--primary); }

/* === 结果页 === */
.result-container {
    text-align: center;
    padding: 40px 20px;
}

.result-emoji {
    font-size: 4rem;
    margin-bottom: 16px;
}

.result-score {
    margin: 20px 0;
}

.score-num {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
}

.result-details {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 24px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

/* === 错题本 === */
.wrong-subject-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.wrong-subject-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.wrong-subject-tab.active {
    border-color: var(--primary);
    background: #EDE9FE;
    color: var(--primary-dark);
}

.wrong-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wrong-item {
    background: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.wrong-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wrong-item-chapter {
    font-size: 0.8rem;
    color: var(--text-light);
}

.wrong-item-question {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.wrong-item-answers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.wrong-item-answers .user-ans {
    color: var(--danger);
}

.wrong-item-answers .correct-ans {
    color: var(--success);
}

.wrong-item-explanation {
    margin-top: 10px;
    padding: 10px;
    background: #F0F4FF;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.5;
}

.master-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--success);
    background: white;
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.master-btn:hover { background: #D1FAE5; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* === 排行榜 === */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.leaderboard-item.me {
    border: 2px solid var(--primary);
    background: #F8F7FF;
}

.rank-num {
    font-size: 1.4rem;
    font-weight: 800;
    width: 40px;
    text-align: center;
}

.rank-num.gold { color: #F59E0B; }
.rank-num.silver { color: #9CA3AF; }
.rank-num.bronze { color: #D97706; }

.rank-avatar { font-size: 1.8rem; }

.rank-info {
    flex: 1;
}

.rank-name {
    font-weight: 600;
    font-size: 1rem;
}

.rank-streak {
    font-size: 0.8rem;
    color: var(--text-light);
}

.rank-score {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}

/* === 统计卡片 === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* === 个人页面 === */
.profile-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.profile-avatar { font-size: 3.5rem; margin-bottom: 8px; }
.profile-card h2 { font-size: 1.4rem; margin-bottom: 4px; }
.profile-card p { opacity: 0.8; font-size: 0.9rem; }

.profile-actions {
    margin-top: 20px;
    max-width: 300px;
}

/* === 系统状态提示 === */
.system-status {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 200;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-dot.online { background: #D1FAE5; color: #065F46; }
.status-dot.offline { background: #FEE2E2; color: #991B1B; }

/* === 响应式 === */
@media (min-width: 768px) {
    .subject-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .content {
        padding: 24px 32px 100px;
    }
}

/* === 动画 === */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ============================================================ */
/* 单元头部 */
/* ============================================================ */
.unit-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-top: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}
.unit-num {
    width: 26px;
    height: 26px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.unit-lesson-count {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: normal;
}

/* ============================================================ */
/* 预习页面 */
/* ============================================================ */
.study-content {
    padding: 16px;
    background: white;
    border-radius: 12px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.study-body {
    font-size: 0.95rem;
    line-height: 1.8;
    color: #1f2937;
}
.study-body h3 {
    font-size: 1.1rem;
    margin: 16px 0 8px 0;
    color: #4F46E5;
    border-bottom: 2px solid #EEF2FF;
    padding-bottom: 4px;
}
.study-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #4F46E5;
    margin: 16px 0 6px 0;
    padding: 6px 10px;
    background: #EEF2FF;
    border-radius: 6px;
    display: inline-block;
}
.study-body li {
    margin: 4px 0 4px 20px;
    list-style: disc;
}
.study-body br { display: block; margin: 4px 0; }
.source-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.source-tag.cached { background: #D1FAE5; color: #065F46; }
.source-tag.ai { background: #DBEAFE; color: #1E40AF; }

.study-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 0;
}
.btn-large {
    font-size: 1.05rem !important;
    padding: 14px 24px !important;
}

/* 单元头部 */
.unit-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; margin-top: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; border-radius: 10px;
    font-weight: 600; font-size: 0.95rem;
}
.unit-num {
    width: 26px; height: 26px; background: rgba(255,255,255,0.3);
    border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-size: 0.8rem; flex-shrink: 0;
}
.unit-lesson-count { margin-left: auto; font-size: 0.75rem; opacity: 0.8; font-weight: normal; }

/* 预习页面 */
.study-content { padding: 16px; background: white; border-radius: 12px; margin: 12px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.study-body { font-size: 0.95rem; line-height: 1.8; color: #1f2937; }
.study-body h3 { font-size: 1.1rem; margin: 16px 0 8px 0; color: #4F46E5; border-bottom: 2px solid #EEF2FF; padding-bottom: 4px; }
.study-section-title { font-size: 1rem; font-weight: 700; color: #4F46E5; margin: 16px 0 6px 0; padding: 6px 10px; background: #EEF2FF; border-radius: 6px; display: inline-block; }
.study-body li { margin: 4px 0 4px 20px; list-style: disc; }
.source-tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.7rem; font-weight: 600; margin-bottom: 8px; }
.source-tag.cached { background: #D1FAE5; color: #065F46; }
.source-tag.ai { background: #DBEAFE; color: #1E40AF; }
.study-actions { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; }
.btn-large { font-size: 1.05rem !important; padding: 14px 24px !important; }
/* ============================================================
   年级选择弹窗
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s;
}
.modal-content {
    background: white; border-radius: 16px; width: 90%; max-width: 400px;
    max-height: 80vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #F3F4F6;
}
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 20px; color: #9CA3AF;
    cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-close:active { background: #F3F4F6; }
.modal-body { padding: 16px 20px; }
.grade-group { margin-bottom: 20px; }
.grade-group h4 { margin: 0 0 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; }
.grade-options { display: flex; flex-wrap: wrap; gap: 10px; }
.grade-option-btn {
    padding: 10px 18px; border-radius: 10px;
    border: 2px solid #E5E7EB; background: white;
    font-size: 14px; cursor: pointer; transition: all 0.2s;
    color: #374151;
}
.grade-option-btn:active { transform: scale(0.95); }
.grade-option-btn.current {
    border-color: #6366F1; background: #EEF2FF; color: #6366F1; font-weight: 600;
}
.icon-btn-book {
    font-size: 18px !important;
}

/* ============================================================
   课文原文区域
   ============================================================ */
.original-text-block {
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    border-radius: 12px; padding: 20px; margin: 0 16px 16px 16px;
    border-left: 4px solid #F59E0B;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}
.original-text-block .ot-title {
    font-size: 15px; font-weight: 600; color: #92400E;
    margin-bottom: 14px; display: flex; align-items: center; gap: 6px;
}
.original-text-block .ot-content {
    font-size: 15px; line-height: 2; color: #78350F;
    white-space: pre-wrap;
    font-family: "楷体", "KaiTi", "STKaiti", serif;
    text-align: justify;
}


/* ==================== AI问答面板 ==================== */
#ask-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102,126,234,0.4);
  z-index: 999;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ask-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102,126,234,0.6);
}
#ask-btn.active {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.ask-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 998;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.ask-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
}
.ask-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ask-close:hover {
  background: rgba(255,255,255,0.3);
}

.ask-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fc;
}

.ask-msg {
  margin-bottom: 12px;
  display: flex;
}
.ask-msg.user {
  justify-content: flex-end;
}
.ask-msg.ai {
  justify-content: flex-start;
}

.ask-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.ask-msg.user .ask-bubble {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-bottom-right-radius: 4px;
}
.ask-msg.ai .ask-bubble {
  background: white;
  color: #333;
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
}
.ask-bubble.loading {
  color: #999;
  font-style: italic;
}
.ask-bubble h2, .ask-bubble h3, .ask-bubble h4 {
  margin: 8px 0 4px;
  font-size: 14px;
}
.ask-bubble ul {
  margin: 4px 0;
  padding-left: 18px;
}
.ask-bubble li {
  margin: 2px 0;
}
.ask-bubble code {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}
.ask-bubble strong {
  color: #333;
}

.ask-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid #eee;
  background: white;
  gap: 8px;
  align-items: flex-end;
}
.ask-input-area textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 80px;
}
.ask-input-area textarea:focus {
  border-color: #667eea;
}
#ask-send {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.2s;
}
#ask-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#ask-send:hover:not(:disabled) {
  opacity: 0.9;
}

@media (max-width: 480px) {
  .ask-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
    height: 60vh;
  }
  #ask-btn {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 22px;
  }
}


/* ==================== 🎨 动漫风界面升级 ==================== */

/* 全局背景 */
body {
  background: linear-gradient(135deg, #e0e7ff 0%, #fce7f3 50%, #e0f2fe 100%) !important;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 登录页 */
.login-container {
  background: rgba(255,255,255,0.95) !important;
  border-radius: 24px !important;
  box-shadow: 0 20px 60px rgba(102,126,234,0.15), 0 0 0 1px rgba(255,255,255,0.8) inset !important;
  backdrop-filter: blur(10px);
  border: none !important;
}

.login-logo {
  font-size: 52px !important;
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

.login-container h1 {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

/* 主按钮 */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: none !important;
  border-radius: 14px !important;
  font-weight: 600 !important;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
  box-shadow: 0 4px 15px rgba(102,126,234,0.3) !important;
}
.btn-primary:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(102,126,234,0.4) !important;
}
.btn-primary:active {
  transform: translateY(0) !important;
}

.btn-secondary {
  background: linear-gradient(135deg, #f0e6ff, #e0d4f5) !important;
  border: 2px solid #d0c0e8 !important;
  border-radius: 14px !important;
  color: #6b4fa0 !important;
  font-weight: 600 !important;
  transition: all 0.2s !important;
}
.btn-secondary:hover {
  background: linear-gradient(135deg, #e8d8ff, #d8c8f0) !important;
  transform: translateY(-1px) !important;
}

/* 输入框 */
input[type="text"], input[type="password"], textarea, select {
  border: 2px solid #e0d8f0 !important;
  border-radius: 12px !important;
  padding: 10px 14px !important;
  transition: all 0.3s !important;
  background: rgba(255,255,255,0.9) !important;
}
input:focus, textarea:focus, select:focus {
  border-color: #667eea !important;
  box-shadow: 0 0 0 4px rgba(102,126,234,0.1) !important;
  outline: none !important;
}

/* 顶部栏 */
.top-bar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  box-shadow: 0 4px 20px rgba(102,126,234,0.25) !important;
  border-radius: 0 0 20px 20px !important;
}

.score-badge {
  background: rgba(255,255,255,0.2) !important;
  border-radius: 20px !important;
  padding: 4px 12px !important;
}

.icon-btn {
  border-radius: 12px !important;
  transition: all 0.2s !important;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.2) !important;
  transform: scale(1.05) !important;
}

/* 底部导航 */
.bottom-nav {
  background: rgba(255,255,255,0.98) !important;
  box-shadow: 0 -4px 20px rgba(102,126,234,0.08) !important;
  border-radius: 20px 20px 0 0 !important;
  padding: 6px 4px !important;
}

.nav-item {
  border-radius: 14px !important;
  transition: all 0.3s !important;
  padding: 8px 8px !important;
}
.nav-item.active {
  background: linear-gradient(135deg, #667eea15, #764ba215) !important;
  color: #764ba2 !important;
}
.nav-icon {
  font-size: 22px !important;
}

/* 科目卡片 */
.subject-card, .subject-grid button, #subject-grid button {
  border-radius: 18px !important;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
  box-shadow: 0 4px 12px rgba(102,126,234,0.06) !important;
  border: 2px solid rgba(102,126,234,0.1) !important;
  position: relative;
  overflow: hidden;
}
.subject-card:hover, .subject-grid button:hover, #subject-grid button:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 8px 24px rgba(102,126,234,0.15) !important;
  border-color: rgba(102,126,234,0.3) !important;
}

/* 章节列表 */
.chapter-btn {
  border-radius: 14px !important;
  transition: all 0.3s !important;
  background: linear-gradient(145deg, #ffffff, #f8f4ff) !important;
  border: 2px solid #e8e0f0 !important;
  text-align: left !important;
}
.chapter-btn:hover {
  border-color: #667eea !important;
  box-shadow: 0 4px 16px rgba(102,126,234,0.12) !important;
  transform: translateX(4px) !important;
}

/* 题目卡片 */
.question-card {
  border-radius: 20px !important;
  background: linear-gradient(145deg, #ffffff, #faf8ff) !important;
  box-shadow: 0 8px 24px rgba(102,126,234,0.08) !important;
  border: 2px solid #e8e0f0 !important;
  padding: 20px !important;
}

/* 选项按钮 */
.option-btn, .options-area button {
  border-radius: 14px !important;
  transition: all 0.2s !important;
  border: 2px solid #e0d8f0 !important;
  background: white !important;
  padding: 10px 16px !important;
  margin: 6px 0 !important;
}
.option-btn:hover, .options-area button:hover {
  border-color: #667eea !important;
  background: #f8f4ff !important;
}

/* 结果页 */
.result-container {
  border-radius: 24px !important;
  background: rgba(255,255,255,0.98) !important;
  box-shadow: 0 12px 40px rgba(102,126,234,0.12) !important;
  padding: 32px !important;
}
.score-num {
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 48px !important;
  font-weight: 800 !important;
}

/* 错题本 */
.wrong-card, .wrong-list > div {
  border-radius: 16px !important;
  border: 2px solid #e8e0f0 !important;
  transition: all 0.2s !important;
  margin-bottom: 12px !important;
}
.wrong-card:hover, .wrong-list > div:hover {
  box-shadow: 0 4px 16px rgba(102,126,234,0.1) !important;
}

/* 排行榜 */
.leaderboard-item, .leaderboard-list > div {
  border-radius: 14px !important;
  transition: all 0.2s !important;
  margin-bottom: 8px !important;
}

/* 个人资料卡片 */
.profile-card {
  border-radius: 24px !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  box-shadow: 0 8px 30px rgba(102,126,234,0.3) !important;
}

/* 弹窗 */
.modal-content {
  border-radius: 20px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important;
}

/* 年级选择 */
.grade-option-btn {
  border-radius: 12px !important;
  transition: all 0.2s !important;
  border: 2px solid #e0d8f0 !important;
}
.grade-option-btn:hover {
  border-color: #667eea !important;
  background: #f8f4ff !important;
  transform: scale(1.05) !important;
}

/* 课文原文区域 */
.original-text-block {
  border-radius: 16px !important;
  background: linear-gradient(145deg, #fffef5, #fff9e6) !important;
  border: 2px solid #f0e6c0 !important;
  font-family: "楷体", "KaiTi", "STKaiti", serif !important;
  padding: 20px !important;
}

/* 学习内容区域 */
.study-content {
  border-radius: 16px !important;
  background: rgba(255,255,255,0.98) !important;
  box-shadow: 0 4px 16px rgba(102,126,234,0.06) !important;
  border: 2px solid #e8e0f0 !important;
  padding: 20px !important;
}

/* AI问答面板升级 */
.ask-panel {
  border-radius: 20px !important;
  box-shadow: 0 12px 40px rgba(102,126,234,0.2) !important;
  border: 1px solid rgba(102,126,234,0.15) !important;
}
.ask-header {
  border-radius: 20px 20px 0 0 !important;
}
.ask-bubble {
  border-radius: 16px !important;
}
.ask-msg.user .ask-bubble {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  border-bottom-right-radius: 6px !important;
}
.ask-msg.ai .ask-bubble {
  border-bottom-left-radius: 6px !important;
}

/* AI问答按钮 */
#ask-btn {
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: none !important;
  font-size: 28px !important;
  cursor: pointer !important;
  box-shadow: 0 6px 20px rgba(102,126,234,0.4) !important;
  z-index: 999 !important;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ask-btn:hover {
  transform: scale(1.1) rotate(5deg) !important;
  box-shadow: 0 8px 30px rgba(102,126,234,0.5) !important;
}

/* 语音输入按钮 */
#ask-voice {
  background: linear-gradient(135deg, #a8edea, #fed6e3) !important;
  border: none !important;
  border-radius: 10px !important;
  width: 40px !important;
  height: 40px !important;
  font-size: 18px !important;
  cursor: pointer !important;
  transition: all 0.3s !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}
#ask-voice:hover {
  transform: scale(1.1) !important;
}
#ask-voice.listening {
  background: linear-gradient(135deg, #f5576c, #ff6b6b) !important;
  animation: micPulse 1.5s infinite !important;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,87,108,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(245,87,108,0); }
}

/* 朗读按钮 */
.read-aloud-btn {
  background: linear-gradient(135deg, #a8edea, #fed6e3) !important;
  border: none !important;
  border-radius: 20px !important;
  padding: 6px 16px !important;
  font-size: 13px !important;
  cursor: pointer !important;
  margin-bottom: 10px !important;
  transition: all 0.2s !important;
}
.read-aloud-btn:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 4px 12px rgba(168,237,234,0.4) !important;
}

/* 可点击发音的单词 */
.speak-word {
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: all 0.2s;
  color: #667eea;
  font-weight: 500;
}
.speak-word:hover {
  background: rgba(102,126,234,0.1);
  text-decoration: underline;
}

/* section 标题 */
.section h2, .section-header h2 {
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700 !important;
}

/* 头像选择 */
.avatar-opt {
  border-radius: 50% !important;
  transition: all 0.2s !important;
  border: 3px solid transparent !important;
  cursor: pointer;
}
.avatar-opt:hover {
  transform: scale(1.2) !important;
}
.avatar-opt.selected {
  border-color: #667eea !important;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.2) !important;
}

/* 加载动画 */
.spinner {
  border: 3px solid #e0d8f0 !important;
  border-top-color: #667eea !important;
}

/* 空状态 */
.empty-state {
  border-radius: 20px !important;
  background: rgba(255,255,255,0.9) !important;
  padding: 40px 20px !important;
}

/* 统计卡片 */
.stats-grid > div, .stats-cards > div {
  border-radius: 16px !important;
  background: rgba(255,255,255,0.95) !important;
  border: 2px solid #e8e0f0 !important;
  transition: all 0.2s !important;
}
.stats-grid > div:hover, .stats-cards > div:hover {
  border-color: #667eea30 !important;
  box-shadow: 0 4px 12px rgba(102,126,234,0.08) !important;
}

/* 版本标签 */
.version-tag {
  border-radius: 8px !important;
  background: linear-gradient(135deg, #667eea15, #764ba215) !important;
  color: #764ba2 !important;
  padding: 4px 12px !important;
}

/* 移动端优化 */
@media (max-width: 480px) {
  .login-container {
    border-radius: 20px;
    margin: 12px;
  }
  .ask-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
    height: 55vh;
  }
  #ask-btn {
    width: 50px !important;
    height: 50px !important;
    bottom: 16px !important;
    right: 16px !important;
    font-size: 24px !important;
  }
}


/* === 课文原文标题和作者 === */
.original-title {
    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 8px;
    color: #2c3e50;
}
.original-author {
    font-size: 0.95em;
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 20px;
}
/* 拖动时降低透明度 */
#ask-btn:active {
    opacity: 0.7;
}


/* === 生字发音按钮 === */
.speak-char {
  display: inline-block;
  cursor: pointer;
  color: #e74c3c;
  font-weight: bold;
  font-size: 1.1em;
  padding: 0 2px;
  border-bottom: 2px dashed #e74c3c;
  transition: all 0.2s;
}
.speak-char:hover {
  background: #fde8e8;
  border-radius: 4px;
  transform: scale(1.15);
}
.speak-char:active {
  transform: scale(0.95);
}

/* === 朗读按钮增强 === */
.read-aloud-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  margin: 8px auto;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
  transition: all 0.3s;
}
.read-aloud-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102,126,234,0.5);
}
.read-aloud-btn.speaking {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 右上角年级文字显示 */
.grade-badge-text {
  font-size: 13px;
  font-weight: 600;
  color: #667eea;
  white-space: nowrap;
}
.icon-btn-book {
  min-width: auto;
  padding: 6px 10px;
}


/* 记忆模块 */
.memory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 0;
}
.memory-card {
  border-radius: 16px;
  padding: 20px 16px;
  color: white;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.memory-card:active { transform: scale(0.97); }
.memory-card-icon { font-size: 2rem; margin-bottom: 8px; }
.memory-card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.memory-card-desc { font-size: 0.75rem; opacity: 0.85; }

/* 错题本分组 */
.wrong-subject-group { margin-bottom: 8px; }
.wrong-subject-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1F2937;
  padding: 12px 0 8px;
  border-bottom: 2px solid #E5E7EB;
  margin-bottom: 8px;
}
.wrong-count { font-size: 0.85rem; color: #9CA3AF; font-weight: 400; }
.wrong-chapter-group {
  margin-bottom: 8px;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  overflow: hidden;
}
.wrong-chapter-title {
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4B5563;
  background: #F9FAFB;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wrong-chapter-title::before { content: '▶'; font-size: 0.7rem; transition: transform 0.2s; }
details[open] > .wrong-chapter-title::before { transform: rotate(90deg); }
.wrong-chapter-title:hover { background: #F3F4F6; }

/* ==================== 记忆训练模块 - 大按钮样式 ==================== */

.memory-step-container {
    padding: 20px;
    min-height: 80vh;
}

.memory-back-btn {
    display: inline-block;
    padding: 12px 20px;
    font-size: 1.1rem;
    color: #6B7280;
    background: #F3F4F6;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 20px;
}

.memory-back-btn:hover {
    background: #E5E7EB;
}

.memory-step-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1F2937;
    text-align: center;
    margin-bottom: 10px;
}

.memory-step-subtitle {
    font-size: 1.1rem;
    color: #6B7280;
    text-align: center;
    margin-bottom: 30px;
}

.memory-coming-soon {
    text-align: center;
    font-size: 1.2rem;
    color: #9CA3AF;
    padding: 60px 20px;
}

.memory-error {
    text-align: center;
    color: #EF4444;
    padding: 40px;
}

/* 大按钮网格 */
.memory-option-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.memory-big-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    min-height: 140px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.memory-big-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.memory-big-btn.wrong-btn {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.memory-big-btn .btn-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.memory-big-btn .btn-text {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.memory-big-btn .btn-desc {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 单元选择 */
.memory-unit-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.memory-unit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px 15px;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.memory-unit-btn:hover {
    border-color: #667eea;
    background: #F5F3FF;
}

.memory-unit-btn .unit-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1F2937;
}

.memory-unit-btn .unit-count {
    font-size: 0.9rem;
    color: #6B7280;
    margin-top: 5px;
}

/* 练习方式选择 */
.memory-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    max-width: 450px;
    margin: 0 auto;
}

.memory-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px 15px;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.memory-mode-btn:hover {
    border-color: #667eea;
    background: #F5F3FF;
}

.memory-mode-btn .mode-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.memory-mode-btn .mode-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1F2937;
    margin-bottom: 5px;
}

.memory-mode-btn .mode-desc {
    font-size: 0.85rem;
    color: #6B7280;
}

/* 练习界面 */
.memory-practice-container {
    padding: 15px;
    min-height: 80vh;
}

.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #F9FAFB;
    border-radius: 12px;
    margin-bottom: 20px;
}

.practice-progress {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4B5563;
}

.practice-score {
    font-size: 1.1rem;
    color: #10B981;
    font-weight: 600;
}

.practice-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

/* 听写模式 */
.play-sound-btn {
    padding: 20px 40px;
    font-size: 1.3rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    margin: 20px 0;
    transition: transform 0.2s;
}

.play-sound-btn:hover {
    transform: scale(1.05);
}

.play-sound-btn.small {
    padding: 12px 20px;
    font-size: 1rem;
    margin: 10px 0;
}

.dictation-input {
    width: 100%;
    max-width: 300px;
    padding: 18px 20px;
    font-size: 1.3rem;
    text-align: center;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    margin: 20px 0;
}

.dictation-input:focus {
    outline: none;
    border-color: #667eea;
}

.submit-btn {
    padding: 16px 50px;
    font-size: 1.2rem;
    background: #10B981;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 15px;
}

.submit-btn:hover {
    background: #059669;
}

/* 填字母模式 */
.word-meaning {
    font-size: 1.4rem;
    color: #1F2937;
    text-align: center;
    margin: 15px 0;
    font-weight: 500;
}

    font-size: 2.5rem;
    font-weight: 700;
    color: #1F2937;
    text-align: center;
    margin: 20px 0;
}

.question-meaning {
    font-size: 1.8rem;
    color: #1F2937;
    text-align: center;
    margin: 20px 0;
    font-weight: 500;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
}

.option-btn {
    padding: 25px 30px;
    font-size: 1.2rem;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: #667eea;
    background: #F5F3FF;
}

.option-btn.en-option {
    font-size: 1.3rem;
    font-weight: 500;
    text-align: center;
}

/* 翻卡模式 */
.flashcard-mode {
    padding: 10px;
}

.flashcard-hint {
    text-align: center;
    font-size: 1rem;
    color: #6B7280;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.flashcard-wrapper {
    width: 280px;
    height: 350px;
    perspective: 1000px;
    margin: 0 auto 20px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard-inner.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.flashcard-front {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.flashcard-back {
    background: white;
    border: 3px solid #667eea;
    transform: rotateY(180deg);
}

.fc-word {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.fc-phonetic {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.fc-sound-btn {
    padding: 12px 25px;
    font-size: 1rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 30px;
    cursor: pointer;
}

.flashcard-back .fc-sound-btn {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.fc-word-small {
    font-size: 1.5rem;
    color: #667eea;
    margin-bottom: 15px;
    font-weight: 600;
}

.fc-meaning {
    font-size: 1.6rem;
    color: #1F2937;
    text-align: center;
    margin-bottom: 15px;
}

.fc-example {
    font-size: 1rem;
    color: #6B7280;
    font-style: italic;
    text-align: center;
}

.flashcard-actions {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.fc-btn {
    padding: 20px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
}

.fc-btn-red {
    background: #FEE2E2;
    color: #DC2626;
}

.fc-btn-green {
    background: #D1FAE5;
    color: #059669;
}

/* 反馈 */
.feedback-correct {
    text-align: center;
    padding: 20px;
    font-size: 1.5rem;
    color: #059669;
    background: #D1FAE5;
    border-radius: 12px;
    margin-top: 20px;
    animation: slideIn 0.3s;
}

.feedback-wrong {
    text-align: center;
    padding: 20px;
    font-size: 1.5rem;
    color: #DC2626;
    background: #FEE2E2;
    border-radius: 12px;
    margin-top: 20px;
    animation: slideIn 0.3s;
}

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

/* 结果页面 */
.memory-result-container {
    text-align: center;
    padding: 40px 20px;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.result-emoji {
    font-size: 5rem;
    margin-bottom: 20px;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 10px;
}

.result-message {
    font-size: 1.2rem;
    color: #6B7280;
    margin-bottom: 30px;
}

.result-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    font-size: 1rem;
    color: #6B7280;
    margin-top: 5px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.result-btn {
    padding: 18px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    background: #F3F4F6;
    color: #4B5563;
}

.result-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}


/* ====== 填字母模式 - 新版格子布局 ====== */
.letter-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin: 28px 0;
}

.letter-box {
    width: 44px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Courier New', 'Consolas', monospace;
    text-transform: lowercase;
    transition: all 0.15s ease;
}

.letter-given {
    background: #F9FAFB;
    color: #6B7280;
    border-bottom: 3px solid #D1D5DB;
    border-radius: 4px;
}

.letter-blank {
    background: transparent;
    border-bottom: 3px solid #CBD5E1;
    border-radius: 4px;
    padding: 0;
    position: relative;
}

.letter-input-inner {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Courier New', 'Consolas', monospace;
    text-align: center;
    text-transform: lowercase;
    color: #1E293B;
    outline: none;
    caret-color: transparent;
}

.letter-input-inner:focus {
    background: transparent;
    border-radius: 0;
    outline: none;
}

/* ====== 练习模式返回按钮 ====== */
.practice-back-btn {
    cursor: pointer;
    color: #667eea;
    font-size: 1rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.practice-back-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.practice-back-btn:active {
    background: rgba(102, 126, 234, 0.2);
}

/* 练习header三栏布局 */
.practice-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

/* ==================== 虚拟键盘 ==================== */
.virtual-keyboard {
    width: 100%;
    max-width: 500px;
    margin: 12px auto;
    padding: 8px;
    background: #F3F4F6;
    border-radius: 12px;
    user-select: none;
    -webkit-user-select: none;
}
.vk-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}
.vk-row:last-child { margin-bottom: 0; }
.vk-key {
    min-width: 36px;
    height: 50px;
    border: none;
    border-radius: 10px;
    background: #FFFFFF;
    color: #1F2937;
    font-size: 1.15rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    padding: 0 5px;
    -webkit-tap-highlight-color: transparent;
}
.vk-key:active {
    background: #3B82F6;
    color: white;
    transform: scale(0.92);
}
.vk-key.vk-special {
    background: #E5E7EB;
    color: #EF4444;
    font-size: 1.2rem;
    min-width: 42px;
}
.vk-key.vk-special:active {
    background: #EF4444;
    color: white;
}
.letter-input-inner.active-blank {
    border-bottom: 3px solid #3B82F6 !important;
    background: rgba(59, 130, 246, 0.06) !important;
}
.letter-blank:has(.active-blank) {
    border-bottom-color: #3B82F6;
    animation: blankPulse 1.5s ease-in-out infinite;
}
@keyframes blankPulse {
    0%, 100% { border-bottom-color: #3B82F6; }
    50% { border-bottom-color: #93C5FD; }
}
.letter-input-inner.filled {
    color: #1E293B;
    font-weight: 700;
    font-size: 1.6rem;
    font-family: 'Courier New', 'Consolas', monospace;
    text-transform: lowercase;
}

/* Dictation input with virtual keyboard */
.dictation-input[readonly] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}
.dictation-input.vk-active {
    border-color: #3B82F6;
    background: rgba(59, 130, 246, 0.04);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============ 需求8：点哪读哪 - 可点击文本样式 ============ */
.tts-clickable {
    cursor: pointer;
    border-bottom: 1px dashed #93C5FD;
    transition: all 0.2s ease;
    padding: 0 1px;
    border-radius: 2px;
    display: inline;
}
.tts-clickable:hover {
    background: rgba(59, 130, 246, 0.1);
    border-bottom-style: solid;
    border-bottom-color: #3B82F6;
}
.tts-clickable:active {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(0.98);
}
/* 播放中状态 */
.tts-clickable.speaking {
    background: rgba(59, 130, 246, 0.15);
    border-bottom: 2px solid #3B82F6;
    animation: ttsPulse 1s ease-in-out infinite;
}
@keyframes ttsPulse {
    0%, 100% { border-bottom-color: #3B82F6; }
    50% { border-bottom-color: #93C5FD; }
}
/* 需求5：错题进度提示 */
.wrong-streak-info {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-left: 4px;
}
/* 需求7：教材来源标签 */
.source-tag[style*="DBEAFE"] {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 8px;
}


/* ==================== 智能出题样式 ==================== */
/* === 智能出题 - 美化样式 === */
.sq-wrapper { padding: 16px; max-width: 500px; margin: 0 auto; }
.sq-header-area { text-align: center; margin-bottom: 20px; }
.sq-header-area h3 { font-size: 1.4em; margin-bottom: 6px; color: #1F2937; }
.sq-desc { color: #6B7280; font-size: 0.9em; }

.sq-step-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #F3F4F6;
}
.sq-step-label {
    font-size: 15px;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sq-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: white;
    font-size: 13px;
    font-weight: 700;
}

/* 科目卡片网格 */
.sq-subject-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.sq-card {
    background: #FAFAFA;
    border: 2px solid #E5E7EB;
    border-radius: 14px;
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.sq-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--card-color, #6366F1);
    opacity: 0.5;
    border-radius: 14px 14px 0 0;
}
.sq-card:active { transform: scale(0.96); }
.sq-card.active {
    border-color: var(--card-color, #6366F1);
    background: color-mix(in srgb, var(--card-color, #6366F1) 8%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--card-color, #6366F1) 15%, transparent);
}
.sq-card.active::before { opacity: 1; height: 5px; }
.sq-card-icon { font-size: 28px; margin-bottom: 6px; }
.sq-card-name { font-size: 14px; font-weight: 700; color: #1F2937; margin-bottom: 3px; }
.sq-card-hint { font-size: 10px; color: #9CA3AF; line-height: 1.3; }

/* 范围选择 */
.sq-range-row { display: flex; gap: 10px; }
.sq-range-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    background: #FAFAFA;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #4B5563;
    transition: all 0.2s;
}
.sq-range-btn.active {
    border-color: #6366F1;
    background: #EEF2FF;
    color: #4338CA;
}
.sq-range-icon { font-size: 18px; }

/* 单元列表 */
.sq-unit-list { max-height: 200px; overflow-y: auto; margin-top: 10px; border-radius: 10px; border: 1px solid #F3F4F6; }
.sq-unit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
    border-bottom: 1px solid #F9FAFB;
}
.sq-unit-item:last-child { border-bottom: none; }
.sq-unit-item:hover { background: #F9FAFB; }
.sq-unit-item.selected { background: #EEF2FF; color: #4338CA; }
.sq-unit-item input { accent-color: #6366F1; }

/* 题目数量 */
.sq-count-row { display: flex; gap: 8px; }
.sq-count-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    background: #FAFAFA;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    color: #4B5563;
    transition: all 0.2s;
}
.sq-count-btn.active {
    border-color: #10B981;
    background: #ECFDF5;
    color: #059669;
}
.sq-tip { font-size: 12px; color: #9CA3AF; margin-top: 10px; text-align: center; }

/* 开始按钮 */
.sq-start-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}
.sq-start-btn:active { transform: scale(0.97); }

/* 加载动画 */
.sq-loading-wrap { text-align: center; padding: 60px 20px; }
.sq-loading-icon { font-size: 60px; margin-bottom: 20px; animation: sq-bounce 1.5s infinite; }
@keyframes sq-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}
.sq-loading-bar {
    width: 200px;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    margin: 0 auto 20px;
    overflow: hidden;
}
.sq-loading-fill {
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, #6366F1, #A78BFA, #6366F1);
    border-radius: 3px;
    animation: sq-progress 2s ease-in-out infinite;
}
@keyframes sq-progress {
    0% { width: 10%; margin-left: 0; }
    50% { width: 40%; margin-left: 30%; }
    100% { width: 10%; margin-left: 90%; }
}
.sq-loading-title { font-size: 18px; font-weight: 700; color: #1F2937; margin-bottom: 8px; }
.sq-loading-hint { font-size: 15px; color: #6366F1; font-weight: 600; margin-bottom: 4px; }
.sq-loading-sub { font-size: 12px; color: #9CA3AF; }

/* 失败提示 */
.sq-fail { text-align: center; padding: 60px 20px; }
.sq-fail-icon { font-size: 50px; margin-bottom: 16px; }
.sq-fail p { font-size: 16px; color: #6B7280; margin-bottom: 20px; }
    padding: 2px 6px; opacity: 0.6; transition: opacity 0.2s;
}
.tts-btn:hover { opacity: 1; }
.tts-btn:active { transform: scale(1.2); }
