/* 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 按钮 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}
.btn-primary { background: #667eea; color: white; }
.btn-primary:hover { background: #5a6fd6; }
.btn-success { background: #48bb78; color: white; }
.btn-success:hover { background: #38a169; }
.btn-outline { background: transparent; border: 2px solid #667eea; color: #667eea; }
.btn-outline:hover { background: #667eea; color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* 认证页面 */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; color: #333; }
.auth-link { text-align: center; margin-top: 1.5rem; color: #666; }
.auth-link a { color: #667eea; text-decoration: none; }

/* 表单 */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.error-msg { color: #e53e3e; font-size: 0.9rem; margin-bottom: 1rem; }
.success-msg { color: #38a169; font-size: 0.9rem; margin-bottom: 1rem; }

/* Dashboard */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.dashboard-header h1 { color: #333; }
.user-info { display: flex; align-items: center; gap: 1rem; }
.user-info span { font-weight: 500; }

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: center;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}
.stat-label { color: #666; font-size: 0.9rem; margin-top: 0.3rem; }

/* 阶段标签 */
.phase-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.phase-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.phase-tab:hover { background: #f0f0f0; }
.phase-tab.active { background: #667eea; color: white; }

/* 课程网格 */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.course-card {
    background: white;
    padding: 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #ddd;
}
.course-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.course-card.已完成 { border-left-color: #48bb78; }
.course-card.进行中 { border-left-color: #ed8936; }
.course-day { font-size: 0.85rem; color: #666; }
.course-phase { font-size: 0.75rem; color: #999; margin: 0.3rem 0; }
.course-title { font-weight: 600; margin: 0.3rem 0; }
.course-status { font-size: 0.8rem; color: #48bb78; }

/* 导航链接 */
.nav-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.nav-link {
    padding: 1rem 2rem;
    background: white;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.nav-link:hover { background: #667eea; color: white; }

/* ============================================ */
/* 学习页面                                      */
/* ============================================ */
.study-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}
.study-header {
    margin-bottom: 2rem;
}
.back-link { color: #667eea; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.study-info { margin: 1rem 0; }
.day-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}
.phase-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    background: #e2e8f0;
    color: #4a5568;
}

/* 学习内容区 */
.content-section, .homework-section, .notes-section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.content-section h2, .homework-section h2, .notes-section h2 {
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #eef2f7;
    font-size: 1.3rem;
    color: #2d3748;
}

/* ============================================ */
/* Markdown 内容排版（核心优化）                   */
/* ============================================ */
.content-block {
    line-height: 1.9;
    font-size: 16px !important;
    color: #374151;
}

/* ====== 强制所有元素统一字体大小，绝对不允许缩小 ====== */
.content-block * {
    font-size: inherit !important;
    line-height: inherit !important;
}
/* 标题恢复自身大小 */
.content-block h1 { font-size: 24px !important; }
.content-block h2 { font-size: 21px !important; }
.content-block h3 { font-size: 18px !important; }
.content-block h4 { font-size: 17px !important; }
/* 代码块 */
.content-block pre { font-size: 14px !important; line-height: 1.7 !important; }
.content-block pre code { font-size: 14px !important; }
.content-block code { font-size: 14px !important; }
/* 表格 */
.content-block table { font-size: 15px !important; }
.content-block th { font-size: 14px !important; }
/* 引用块/提示框 - 强制和正文一样大 */
.content-block blockquote,
.content-block blockquote *,
.content-block blockquote blockquote,
.content-block blockquote blockquote *,
.content-block blockquote blockquote blockquote,
.content-block blockquote blockquote blockquote * {
    font-size: 16px !important;
    line-height: 1.9 !important;
}
/* md-quote */
.content-block .md-quote,
.content-block .md-quote * {
    font-size: 16px !important;
    line-height: 1.9 !important;
}
/* p标签 */
.content-block p {
    font-size: 16px !important;
    line-height: 1.9 !important;
}
/* td标签 */
.content-block td {
    font-size: 15px !important;
    line-height: 1.8 !important;
}

/* --- 段落 --- */
.content-block p {
    margin-bottom: 1rem;
    line-height: 1.9;
}

/* --- 二级标题 (##) --- */
.content-block h2 {
    font-weight: 700;
    color: #1a202c;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #667eea;
    line-height: 1.4;
}

/* --- 三级标题 (###) --- */
.content-block h3 {
    font-weight: 600;
    color: #2d3748;
    margin: 1.5rem 0 0.8rem 0;
    line-height: 1.4;
}

/* --- 四级标题 (####) --- */
.content-block h4 {
    font-weight: 600;
    color: #4a5568;
    margin: 1.2rem 0 0.6rem 0;
}

/* --- 加粗 --- */
.content-block strong {
    color: #1a202c;
    font-weight: 600;
}

/* --- 行内代码 --- */
.content-block code {
    background: #edf2f7;
    color: #c53030;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    word-break: break-word;
}

/* --- 代码块 --- */
.content-block pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.2rem 0;
    line-height: 1.7;
    border: 1px solid #334155;
    position: relative;
}
.content-block pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* --- 表格 --- */
.content-block table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.content-block thead th {
    background: #4a5568;
    color: white;
    padding: 0.7rem 0.8rem;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.content-block tbody td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}
.content-block tbody tr:nth-child(even) {
    background: #f7fafc;
}
.content-block tbody tr:hover {
    background: #edf2f7;
}

/* --- 无序列表 --- */
.content-block ul {
    margin: 0.8rem 0;
    padding-left: 1.5rem;
}
.content-block ul li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
    position: relative;
}
.content-block ul li::marker {
    color: #667eea;
    font-size: 1.1em;
}

/* --- 有序列表 --- */
.content-block ol {
    margin: 0.8rem 0;
    padding-left: 1.5rem;
    counter-reset: list-counter;
}
.content-block ol li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
    padding-left: 0.3rem;
}
.content-block ol li::marker {
    color: #667eea;
    font-weight: 600;
}

/* --- 引用块 (>) — 已转换为 .md-quote div，避免嵌套缩小 --- */
.content-block blockquote {
    margin: 1rem 0;
    padding: 0.8rem 1.2rem;
    border-left: 4px solid #667eea;
    background: #f0f4ff;
    border-radius: 0 8px 8px 0;
    color: #4a5568;
    font-size: 1.02rem;
    line-height: 1.9;
}
.content-block blockquote p {
    margin-bottom: 0.3rem;
}

/* md-quote: 替代blockquote的引用样式，字体不会缩小 */
.content-block .md-quote {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    border-left: 4px solid #667eea;
    background: #f0f4ff;
    border-radius: 0 8px 8px 0;
    color: #4a5568;
    font-size: 1.02rem;
    line-height: 1.9;
}
.content-block .md-quote table {
    background: transparent;
    box-shadow: none;
    margin: 0.6rem 0;
}
.content-block .md-quote strong {
    color: #2d3748;
}
.content-block .md-quote code {
    background: rgba(102,126,234,0.1);
    color: #5a67d8;
}
.content-block .md-quote p {
    margin-bottom: 0.3rem;
    color: #4a5568;
}

/* --- 分割线 (---) --- */
.content-block hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e0, transparent);
    margin: 1.5rem 0;
}

/* --- 强调/警告文字 --- */
.content-block .tip {
    display: block;
    margin: 0.8rem 0;
    padding: 0.7rem 1rem;
    background: #ebf8ff;
    border-left: 4px solid #4299e1;
    border-radius: 0 6px 6px 0;
    font-size: 0.95rem;
    color: #2b6cb0;
}
.content-block .warning {
    display: block;
    margin: 0.8rem 0;
    padding: 0.7rem 1rem;
    background: #fff5f5;
    border-left: 4px solid #fc8181;
    border-radius: 0 6px 6px 0;
    font-size: 0.95rem;
    color: #c53030;
}

/* 作业 */
.homework-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s;
}
.homework-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.hw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}
.hw-number { font-weight: 600; color: #2d3748; }
.hw-type {
    padding: 0.25rem 0.7rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}
.hw-type.sql { background: #ebf8ff; color: #2b6cb0; }
.hw-type.theory { background: #f0fff4; color: #276749; }
.hw-question {
    margin-bottom: 0.6rem;
    line-height: 1.7;
    color: #374151;
}
.hw-hint {
    font-size: 0.9rem;
    color: #718096;
    font-style: italic;
    padding: 0.4rem 0.8rem;
    background: #f7fafc;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

/* SQL编辑器 */
.sql-editor textarea, .theory-answer textarea {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    margin: 0.5rem 0;
    transition: border-color 0.2s;
    line-height: 1.6;
}
.sql-editor textarea:focus, .theory-answer textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.sql-result {
    margin-top: 0.5rem;
    padding: 0.8rem;
    background: #f7fafc;
    border-radius: 8px;
    min-height: 50px;
    border: 1px solid #e2e8f0;
}
.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}
.result-table th, .result-table td {
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.7rem;
    text-align: left;
}
.result-table th { background: #edf2f7; font-weight: 600; }
.reference-answer {
    margin-top: 0.8rem;
    padding: 1rem;
    background: #fffff0;
    border-left: 4px solid #ed8936;
    border-radius: 0 8px 8px 0;
    line-height: 1.7;
}

/* 笔记 */
.notes-editor textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}
.notes-editor textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* 学习页脚 */
.study-footer {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.study-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.study-time input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.footer-actions {
    display: flex;
    gap: 0.5rem;
}

/* 加载状态 */
.loading { color: #718096; font-style: italic; }

/* ============================================ */
/* 命令速查面板                                    */
/* ============================================ */
.command-quick-ref {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}
.command-quick-ref h2 {
    color: white !important;
    border-bottom-color: rgba(255,255,255,0.3) !important;
}
.quick-ref-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.quick-ref-tag {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    color: white;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}
.quick-ref-tag:hover {
    background: rgba(255,255,255,0.35);
    transform: translateY(-1px);
}
.quick-ref-content p {
    color: rgba(255,255,255,0.9) !important;
}

/* ============================================ */
/* 答案反馈面板                                    */
/* ============================================ */
.feedback-panel {
    margin-top: 1rem;
    padding: 1.2rem;
    border-radius: 10px;
    border-left: 5px solid;
}
.feedback-correct {
    background: #f0fff4;
    border-left-color: #48bb78;
}
.feedback-wrong {
    background: #fff5f5;
    border-left-color: #fc8181;
}
.feedback-theory {
    background: #fffff0;
    border-left-color: #ecc94b;
}
.feedback-status {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}
.feedback-correct .feedback-status { color: #276749; }
.feedback-wrong .feedback-status { color: #c53030; }
.feedback-theory .feedback-status { color: #975a16; }

.feedback-answer {
    margin: 0.8rem 0;
    padding: 0.8rem 1rem;
    background: rgba(255,255,255,0.7);
    border-radius: 6px;
    line-height: 1.7;
}
.feedback-answer code {
    display: block;
    margin-top: 0.3rem;
    padding: 0.6rem 0.8rem;
    background: #2d3748;
    color: #68d391;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.feedback-explanation {
    margin: 0.8rem 0;
    padding: 0.8rem 1rem;
    background: rgba(255,255,255,0.7);
    border-radius: 6px;
    line-height: 1.8;
    color: #4a5568;
}

.feedback-result {
    margin: 0.8rem 0;
}
.feedback-result strong {
    display: block;
    margin-bottom: 0.5rem;
}

/* 模块选择器 */
.module-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.module-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.2rem;
    background: white;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.module-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.module-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
}
.module-icon {
    font-size: 2rem;
}
.module-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #2d3748;
}
.module-progress {
    font-size: 0.85rem;
    color: #667eea;
    font-weight: 500;
    background: rgba(102,126,234,0.1);
    padding: 0.2rem 0.8rem;
    border-radius: 10px;
}

/* 响应式 */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .course-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .study-footer { flex-direction: column; gap: 1rem; }
    .footer-actions { width: 100%; justify-content: center; }
    .content-section, .homework-section, .notes-section { padding: 1.2rem; }
    .content-block { font-size: 16px !important; }
    .content-block h2 { font-size: 19px !important; }
    .content-block pre { font-size: 13px !important; }
}

/* ============================================ */
/* 讨论区样式                                      */
/* ============================================ */
.discussion-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.discussion-section h2 {
    font-size: 1.2rem;
    color: #2d3748;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #667eea;
}
.discussion-input {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.discussion-input textarea {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}
.discussion-input textarea:focus {
    outline: none;
    border-color: #667eea;
}
.question-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.question-item {
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}
.question-q {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.q-icon { font-size: 1.1rem; }
.q-text { flex: 1; color: #2d3748; font-weight: 500; line-height: 1.6; }
.q-time { font-size: 0.8rem; color: #a0aec0; white-space: nowrap; }
.question-a {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.8rem;
    background: #f0f4ff;
    border-radius: 6px;
    margin-top: 0.3rem;
}
.a-icon { font-size: 1.1rem; }
.a-text { flex: 1; color: #4a5568; line-height: 1.8; font-size: 0.95rem; }
.question-pending {
    padding: 0.5rem 0.8rem;
    color: #a0aec0;
    font-size: 0.9rem;
    font-style: italic;
}
