/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    padding: 0 20px;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 40px;
}

/* 标题区 */
#header {
    text-align: center;
    padding: 30px 0 10px;
}

#header h1 {
    font-size: 2rem;
    color: #2563eb;
    margin-bottom: 4px;
}

#header .subtitle {
    color: #6b7280;
    font-size: 0.95rem;
}

/* 按钮 */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #d1d5db;
}

/* 开始界面 */
.start-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 30px;
}

.start-card h2 {
    margin-bottom: 16px;
    color: #1f2937;
}

.start-card p {
    color: #6b7280;
    margin-bottom: 10px;
}

.start-card .btn {
    margin-top: 20px;
    padding: 12px 40px;
    font-size: 1.1rem;
}

/* 练习区 */
#practice-screen {
    margin-top: 20px;
}

#question-info {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.question-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

#progress {
    font-weight: 600;
    color: #374151;
}

.badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-easy {
    background: #d1fae5;
    color: #065f46;
}

.badge-medium {
    background: #fef3c7;
    color: #92400e;
}

.question-desc {
    font-size: 1.05rem;
    color: #1f2937;
    line-height: 1.7;
}

/* 表结构面板 */
#table-schema {
    background: white;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#table-schema summary {
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 500;
    color: #4b5563;
    user-select: none;
}

#table-schema summary:hover {
    color: #2563eb;
}

#schema-content {
    padding: 0 20px 16px;
}

#schema-content h4 {
    margin: 12px 0 8px;
    color: #374151;
}

.sample-label {
    margin: 12px 0 6px;
    font-size: 0.9rem;
    color: #6b7280;
}

/* 编辑器区 */
#editor-container {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    background: white;
}

#editor-container .cm-editor {
    min-height: 200px;
}

#editor-container .cm-editor.cm-focused {
    outline: none;
}

/* 操作区 */
#actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

#attempts-info {
    margin-left: auto;
    color: #6b7280;
    font-size: 0.9rem;
}

/* 反馈区 */
#feedback {
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.feedback-correct {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
}

.feedback-correct #feedback-header {
    color: #065f46;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.feedback-wrong {
    background: #fef2f2;
    border: 1px solid #fca5a5;
}

.feedback-wrong #feedback-header {
    color: #991b1b;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* AI 分析 */
.ai-analysis {
    background: #eff6ff;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 10px 0;
}

.ai-analysis strong {
    color: #1e40af;
}

.ai-analysis p {
    margin-top: 6px;
    color: #1f2937;
    white-space: pre-wrap;
}

/* 结果和答案区 */
.result-section,
.answer-section {
    margin-top: 12px;
}

.answer-section pre {
    background: #f3f4f6;
    padding: 10px 14px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 6px 0;
}

/* 表格 */
.schema-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.schema-table th,
.schema-table td,
.data-table th,
.data-table td {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.schema-table th,
.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.data-table td {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
}

.truncated {
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 4px;
}

/* 下一题按钮 */
#next-btn {
    width: 100%;
    padding: 12px;
    font-size: 1.05rem;
}

/* 总结页 */
#summary-screen {
    margin-top: 20px;
}

#summary-screen h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #1f2937;
}

.score-display {
    text-align: center;
    margin-bottom: 24px;
}

.score-num {
    font-size: 3rem;
    font-weight: 700;
    color: #2563eb;
}

.score-total {
    font-size: 1.8rem;
    color: #9ca3af;
}

.result-details {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

.result-item:last-child {
    border-bottom: none;
}

.icon-correct {
    color: #059669;
    font-weight: 700;
    font-size: 1.2rem;
}

.icon-wrong {
    color: #dc2626;
    font-weight: 700;
    font-size: 1.2rem;
}

.result-title {
    flex: 1;
    color: #374151;
}

.attempts-label {
    color: #9ca3af;
    font-size: 0.85rem;
}

.suggestion-box {
    background: #eff6ff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.suggestion-box strong {
    color: #1e40af;
}

.suggestion-box p {
    margin-top: 8px;
    color: #1f2937;
    white-space: pre-wrap;
}

#restart-btn {
    display: block;
    margin: 0 auto;
    padding: 12px 40px;
    font-size: 1.05rem;
}

/* Loading */
.loading-text {
    color: #6b7280;
    font-style: italic;
}

.error-text {
    color: #dc2626;
}
