/* ==========================================================================
   错题集生成 App - 核心样式表 (style.css)
   ========================================================================== */

/* 1. 全局变量与设计系统 */
:root {
    /* 默认亮色模式变量 */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --danger-gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.6);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    
    /* 手机外框 */
    --phone-width: 412px;
    --phone-height: 892px;
    
    /* 学科颜色 */
    --color-math: #0284c7;
    --color-chinese: #ea580c;
    --color-english: #16a34a;
}

/* 暗色模式变量 */
[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);
}

/* 2. 基础重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: #111827; /* 桌面端底色，衬托拟真手机 */
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* 3. 桌面端手机外壳包装 */
.phone-frame-wrapper {
    position: relative;
    padding: 12px;
    background: #1f2937;
    border-radius: 48px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 
                inset 0 2px 4px rgba(255, 255, 255, 0.1);
    border: 4px solid #374151;
}

.phone-container {
    width: var(--phone-width);
    height: var(--phone-height);
    background-color: var(--bg-app);
    border-radius: 36px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
}

/* 4. App 顶部导航 */
.app-header {
    height: 72px;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo-text span {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-top: -2px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-input);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: transform 0.2s, background-color 0.2s;
}

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

/* 5. 视图管理器 */
.app-main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 20px;
    /* 隐藏滚动条 */
    scrollbar-width: none; 
}
.app-main-content::-webkit-scrollbar {
    display: none;
}

.app-view {
    display: none;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    padding: 20px 20px 80px 20px;
}

.app-view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* 6. 首页 (Dashboard) 样式 */
.welcome-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    padding: 24px;
    color: #ffffff;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.welcome-card::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    right: -30px;
    top: -30px;
}

.welcome-text h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.welcome-text p {
    font-size: 0.85rem;
    opacity: 0.85;
    line-height: 1.4;
    margin-bottom: 20px;
}

.quick-action-hero {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-action-hero:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

/* 看板与进度条 */
.stats-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-card.total .stat-icon {
    background-color: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}

.stat-card.pending .stat-icon {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-info .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    display: block;
}

.stat-info .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.subject-breakdown-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.subject-breakdown-card h5 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.subject-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subject-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
}

.subject-name {
    width: 40px;
    font-weight: 500;
}

.progress-track {
    flex: 1;
    height: 8px;
    background-color: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    width: 0; /* 动态修改 */
    transition: width 0.8s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.subject-bar-row.math .progress-fill { background-color: var(--color-math); }
.subject-bar-row.chinese .progress-fill { background-color: var(--color-chinese); }
.subject-bar-row.english .progress-fill { background-color: var(--color-english); }

.subject-count {
    width: 30px;
    text-align: right;
    color: var(--text-muted);
    font-weight: 600;
}

/* 最近录入错题列表 */
.recent-section {
    margin-top: 10px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.view-all-link {
    font-size: 0.8rem;
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
}

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

.mistake-mini-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.mistake-mini-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mini-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-thumb i {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.mini-details {
    flex: 1;
    min-width: 0;
}

.mini-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.mini-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mini-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.mini-tag.math { background-color: rgba(2, 132, 199, 0.1); color: var(--color-math); }
.mini-tag.chinese { background-color: rgba(234, 88, 12, 0.1); color: var(--color-chinese); }
.mini-tag.english { background-color: rgba(22, 163, 74, 0.1); color: var(--color-english); }

.mini-type {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mini-arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* 7. 错题库 (Library) 样式 */
.filter-sticky-bar {
    background-color: var(--bg-app);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 5;
    margin-bottom: 14px;
}

.search-box {
    position: relative;
    margin-bottom: 12px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    height: 42px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 14px 0 38px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-box input:focus {
    border-color: #4f46e5;
}

.filter-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 4px;
    scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    white-space: nowrap;
    padding: 6px 14px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.filter-pill.active {
    background: var(--primary-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

/* 批量操作条 */
.batch-ops-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.batch-select-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* 错题库网格卡片 */
.library-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.mistake-grid-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.mistake-grid-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-select-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
}

/* 自定义复选框 */
.custom-checkbox-container {
    display: block;
    position: relative;
    width: 20px;
    height: 20px;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    transition: all 0.2s;
}

[data-theme="dark"] .checkmark {
    background-color: rgba(30, 41, 59, 0.9);
    border-color: #475569;
}

.custom-checkbox-container input:checked ~ .checkmark {
    background: var(--accent-gradient);
    border-color: transparent;
    box-shadow: 0 2px 5px rgba(16, 185, 129, 0.4);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox-container .checkmark:after {
    left: 6px;
    top: 3px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.grid-card-img {
    height: 120px;
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.grid-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-card-img i {
    font-size: 2.2rem;
    color: var(--text-muted);
}

.grid-card-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.grid-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
    color: var(--text-main);
}

.grid-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subject-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.subject-badge.math { background-color: rgba(2, 132, 199, 0.1); color: var(--color-math); }
.subject-badge.chinese { background-color: rgba(234, 88, 12, 0.1); color: var(--color-chinese); }
.subject-badge.english { background-color: rgba(22, 163, 74, 0.1); color: var(--color-english); }

.grid-card-date {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* 8. 添加错题 (Add Mistake) 视图样式 */
.add-form-container {
    max-width: 100%;
}

.form-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 18px;
}

.photo-upload-zone {
    width: 100%;
    min-height: 180px;
    border: 2px dashed var(--border-color);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
    transition: border-color 0.2s, background-color 0.2s;
}

.photo-upload-zone:hover {
    border-color: #4f46e5;
    background-color: var(--bg-input);
}

.upload-placeholder {
    text-align: center;
    padding: 20px;
}

.upload-placeholder i {
    font-size: 2.2rem;
    color: #4f46e5;
    margin-bottom: 8px;
}

.upload-placeholder p {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.upload-placeholder span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.upload-preview-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    z-index: 2;
}

.upload-preview-container img {
    max-width: 100%;
    height: auto;
}

.image-overlay-controls {
    position: relative;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    background-color: var(--bg-input);
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.img-control-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.img-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.mistake-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-group input, 
.input-group select, 
.input-group textarea {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group textarea {
    resize: none;
    height: 70px;
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus {
    border-color: #4f46e5;
}

.form-row {
    display: flex;
    gap: 12px;
}

.input-group.half {
    flex: 1;
}

/* 标签选择与录入 */
.tag-input-wrapper {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selected-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-badge {
    background-color: var(--bg-input);
    color: var(--text-main);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tag-badge .remove-tag {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tag-badge .remove-tag:hover {
    color: #f43f5e;
}

.tag-input-row {
    display: flex;
}

.tag-input-row input {
    border: none !important;
    padding: 4px 0 !important;
    background: transparent !important;
    flex: 1;
}

.tag-input-row button {
    border: none;
    background: transparent;
    color: #4f46e5;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 6px;
}

.recommended-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.recommend-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
    background-color: var(--bg-input);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.recommend-tag:hover {
    background-color: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}

/* 难度星级 */
.difficulty-rating {
    display: flex;
    gap: 8px;
    font-size: 1.25rem;
    color: #e2e8f0;
}

.difficulty-rating i {
    cursor: pointer;
    transition: color 0.15s;
}

.difficulty-rating i.active,
.difficulty-rating i.hover {
    color: #f59e0b;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

/* 按钮风格 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background: var(--danger-gradient);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-md {
    padding: 10px 18px;
    font-size: 0.85rem;
}

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

form .btn {
    flex: 1;
    padding: 12px;
    font-size: 0.9rem;
}

/* 9. 底部导航栏 */
.app-nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background-color: var(--glass-bg);
    backdrop-filter: blur(15px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 16px;
    z-index: 10;
}

.nav-item {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: color 0.2s;
    font-size: 0.65rem;
    font-weight: 500;
    width: 60px;
}

.nav-item i {
    font-size: 1.15rem;
    transition: transform 0.2s;
}

.nav-item.active {
    color: #4f46e5;
}

.nav-item.active i {
    transform: translateY(-2px);
}

/* 中央凸起的加号按钮 */
.nav-item.add-btn {
    position: relative;
    top: -16px;
    width: 58px;
    height: 58px;
}

.plus-circle {
    width: 54px;
    height: 54px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s;
}

.plus-circle i {
    font-size: 1.4rem;
}

.nav-item.add-btn:hover .plus-circle {
    transform: scale(1.08) rotate(90deg);
}

/* 10. 弹窗 (Modal) 样式 */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: flex-end; /* 底部弹出卡片风格 */
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    width: 100%;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.15);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-subject {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.detail-subject.math { background-color: rgba(2, 132, 199, 0.1); color: var(--color-math); }
.detail-subject.chinese { background-color: rgba(234, 88, 12, 0.1); color: var(--color-chinese); }
.detail-subject.english { background-color: rgba(22, 163, 74, 0.1); color: var(--color-english); }

.detail-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.modal-close {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-image-box {
    width: 100%;
    max-height: 220px;
    background-color: var(--bg-input);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.detail-image-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.detail-info-section h3 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 12px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.detail-difficulty {
    font-size: 0.75rem;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.detail-difficulty #modal-difficulty-stars {
    color: #f59e0b;
}

.detail-solution-box {
    background-color: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.detail-solution-box h4 {
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: #4f46e5;
}

[data-theme="dark"] .detail-solution-box h4 {
    color: #a5b4fc;
}

.detail-solution-box p {
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.modal-footer button {
    flex: 1;
}

/* ==========================================================================
   11. 全屏打印预览面板 (App内部预览)
   ========================================================================== */
.print-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1e293b;
    z-index: 200;
    display: none;
    flex-direction: column;
}

.print-preview-overlay.active {
    display: flex;
}

.print-control-panel {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 16px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10;
}

.print-ctrl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.print-ctrl-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-preview-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
}

.print-settings {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 20px;
    align-items: center;
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    .print-settings {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-item label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
}

.setting-item input[type="text"] {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 12px;
    color: #f8fafc;
    outline: none;
    font-size: 0.8rem;
}

.setting-item.checkbox-item {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.setting-item.checkbox-item span {
    font-size: 0.8rem;
    font-weight: 500;
}

.print-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 纸张滚动预览容器 */
.print-paper-scroller {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    justify-content: center;
    background-color: #334155;
}

/* 拟真 A4 纸张规范 */
.a4-sheet {
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    background-color: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    box-sizing: border-box;
    color: #000000; /* 打印默认是黑字 */
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* A4 纸张内的试卷排版元素 */
.exam-header {
    text-align: center;
    margin-bottom: 24px;
    border-bottom: 2px solid #000000;
    padding-bottom: 12px;
}

.exam-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.exam-meta-line {
    font-size: 0.8rem;
    color: #555555;
    word-spacing: 15px;
}

.exam-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.print-question-card {
    page-break-inside: avoid; /* 避免打印切断题目 */
    display: flex;
    flex-direction: column;
    position: relative;
    border-bottom: 1px dashed #cccccc;
    padding: 8px 0;
    margin-bottom: 8px;
}

.print-q-meta {
    display: none !important; /* 不说是什么题目 */
}

.print-q-desc {
    display: none !important; /* 输出文档就是照片，不要有文字 */
}

.print-q-image {
    max-width: 100%;
    margin: 4px auto;
    border-radius: 4px;
    max-height: 240px;
    object-fit: contain;
}

.print-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(239, 68, 68, 0.85); /* Tailwind red-500 */
    color: #ffffff;
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.print-remove-btn:hover {
    background-color: rgb(220, 38, 38);
    transform: scale(1.1);
}

.print-answer-line-space {
    margin: 12px 0 6px 0;
    height: 70px;
    border-top: 1px dashed #bbbbbb;
    border-bottom: 1px dashed #bbbbbb;
    background-image: linear-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 100% 24px;
    position: relative;
}

.print-answer-line-space::before {
    content: '答题区';
    position: absolute;
    left: 10px;
    top: -8px;
    background-color: #ffffff;
    padding: 0 6px;
    font-size: 0.65rem;
    color: #888888;
}

.print-q-solution {
    background-color: #f8fafc;
    border-left: 3px solid #7c3aed;
    padding: 8px 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #334155;
    margin-top: 6px;
}

.print-q-solution strong {
    color: #7c3aed;
}

/* ==========================================================================
   12. 极简滑块组件
   ========================================================================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

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

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

/* ==========================================================================
   12.5 云端状态指示器
   ========================================================================== */
.cloud-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-input);
    color: var(--text-muted);
    transition: all 0.3s ease;
    margin-right: 8px;
}

.cloud-status.online {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.cloud-status.syncing {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    animation: cloudPulse 1.5s infinite;
}

.cloud-status.offline {
    background-color: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

@keyframes cloudPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* ==========================================================================
   12.8 图片编辑器与 AI 搜题高级样式
   ========================================================================== */
#editor-canvas {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    cursor: default;
    background-color: #f8fafc;
}

.eraser-brush-control {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.2s ease-out;
}

.eraser-brush-control .slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    flex: 1;
}

.eraser-brush-control input[type="range"] {
    flex: 0.8;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.eraser-brush-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

.solution-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-ai-solve {
    background: var(--accent-gradient);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.25);
    transition: all 0.2s ease;
}

.btn-ai-solve:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.35);
}

.btn-ai-solve:active {
    transform: translateY(1px);
}

.btn-ai-solve.loading {
    background: var(--primary-gradient);
    opacity: 0.85;
    pointer-events: none;
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

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

/* ==========================================================================
   13. 移动端直接适配 (隐藏手机外壳)
   ========================================================================== */
@media (max-width: 450px) {
    body {
        background-color: var(--bg-app);
    }
    .phone-frame-wrapper {
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        width: 100%;
        height: 100vh;
    }
    .phone-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
}

/* ==========================================================================
   14. 核心打印样式适配 (在打印时接管渲染)
   ========================================================================== */
@media print {
    /* 隐藏所有非打印页面和面板 */
    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    .phone-frame-wrapper, 
    .app-header, 
    .app-nav-bar, 
    .modal-overlay, 
    .print-control-panel,
    .print-preview-overlay {
        display: none !important;
    }

    /* 仅显示 A4 纸张排版区 */
    #print-preview-view {
        display: block !important;
        position: static !important;
        background: #ffffff !important;
        overflow: visible !important;
    }
    
    .print-paper-scroller {
        padding: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
        display: block !important;
    }

    .a4-sheet {
        box-shadow: none !important;
        padding: 15mm !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        overflow: visible !important;
    }

    .print-question-card {
        page-break-inside: avoid !important;
    }

    .print-remove-btn {
        display: none !important;
    }
}
