* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --accent: #0ea5e9;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    padding: 24px;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* 头部 */
header {
    text-align: center;
    margin-bottom: 32px;
    padding: 20px 0;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* 主内容区 */
main {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}

/* 标签页 */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-subtle);
    padding: 4px;
    border-radius: var(--radius-md);
}

.tab {
    flex: 1;
    padding: 10px 20px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.tab:hover:not(.active) {
    color: var(--text-primary);
}

/* 年级选择器 */
.grade-selector {
    margin-bottom: 24px;
}

.grade-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grade-groups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grade-group {
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: var(--transition);
}

.group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.grade-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.grade-btn {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
}

.grade-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--bg-card);
}

.grade-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.grade-btn.active:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* 内容区域 */
.tab-content {
    margin-bottom: 20px;
}

.tab-content.hidden {
    display: none;
}

/* 文本输入 */
#essay-input {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.7;
    resize: vertical;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-primary);
    min-height: 160px;
}

#essay-input::placeholder {
    color: var(--text-muted);
}

#essay-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 图片上传 */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: var(--bg-subtle);
}

.upload-area:hover {
    border-color: var(--primary-light);
    background: var(--bg-card);
}

.upload-prompt svg {
    color: var(--text-muted);
    margin-bottom: 16px;
    transition: var(--transition);
}

.upload-area:hover .upload-prompt svg {
    color: var(--primary);
}

.upload-prompt p {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-weight: 500;
}

.hint {
    font-size: 13px;
    color: var(--text-muted);
}

#preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

/* 主按钮 */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 次要按钮 */
.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 加载动画 */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* 结果区域 */
.result-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.result-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 批注文本 */
.annotated-text {
    background: var(--bg-subtle);
    padding: 24px;
    border-radius: var(--radius-md);
    margin-bottom: 32px;
    line-height: 2;
    font-size: 15px;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.word-basic {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    font-weight: 500;
    color: #92400e;
}

.word-basic:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

/* 词汇清单 */
.vocab-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

.vocab-list h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vocab-item {
    background: var(--bg-subtle);
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border-left: 3px solid var(--primary);
    transition: var(--transition);
}

.vocab-item:hover {
    box-shadow: var(--shadow-sm);
    border-left-width: 4px;
}

.vocab-item:last-child {
    margin-bottom: 0;
}

.vocab-original {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.vocab-original strong {
    color: var(--text-primary);
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.vocab-reason {
    margin-top: 10px;
    font-size: 13px;
    color: var(--primary);
    font-style: normal;
    padding: 10px 14px;
    background: rgba(37, 99, 235, 0.05);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--primary-light);
}

.vocab-suggestions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.suggestion {
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.suggestion:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.suggestion-word {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.level-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.level-basic {
    background: #dcfce7;
    color: #166534;
}

.level-intermediate {
    background: #fef3c7;
    color: #92400e;
}

.level-advanced {
    background: #fce7f3;
    color: #9d174d;
}

.suggestion-explanation {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border-radius: 6px;
    line-height: 1.5;
}

.suggestion-example {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
}

/* 导出操作 */
.export-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* 底部 */
footer {
    text-align: center;
    color: var(--text-muted);
    margin-top: 32px;
    font-size: 13px;
    font-weight: 400;
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    main {
        padding: 24px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .grade-groups {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .grade-buttons {
        grid-template-columns: repeat(4, 1fr);
    }

    .tabs {
        flex-direction: column;
    }

    .export-actions {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .grade-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
}
