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

:root {
    --primary: #0f766e;
    --primary-light: #14b8a6;
    --primary-dark: #115e59;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --accent: #f97316;
    --surface: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.22) 0%, transparent 45%),
        radial-gradient(circle at 80% 20%, rgba(249, 115, 22, 0.18) 0%, transparent 36%),
        #eef2f7;
    min-height: 100vh;
    padding: 20px;
    color: var(--gray-800);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid rgba(15, 118, 110, 0.12);
}

header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.92;
    font-size: 14px;
}

header::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    right: -40px;
    top: -60px;
}

.tabs-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 8px 10px;
}

.tabs {
    display: flex;
    flex: 1;
    min-width: 0;
    background: transparent;
    border-bottom: none;
}

.download-nav-btn {
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: 8px;
    padding: 0 14px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.download-nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #ffffff;
}

.tab {
    flex: 1;
    padding: 15px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-500);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary);
    background: var(--gray-100);
}

.tab.active {
    color: var(--primary);
    background: white;
    border-bottom: 2px solid var(--accent);
}

.panel {
    display: none;
    padding: 20px;
}

.panel.active {
    display: block;
}

/* 上传区域 */
.upload-area {
    max-width: 500px;
    margin: 0 auto;
}

.upload-box {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.upload-box:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.upload-box input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder .icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.upload-placeholder p {
    color: var(--gray-500);
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.subject-select {
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-select label {
    font-weight: 500;
}

.subject-select select,
.filter-bar select {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.btn-primary,
.btn-secondary,
.btn-danger {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    margin-top: 15px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* 分析结果 */
.analysis-result {
    margin-top: 30px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.analysis-result h3 {
    margin-bottom: 20px;
    color: var(--primary);
}

.result-section {
    margin-bottom: 20px;
}

.result-section h4 {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.result-section p {
    line-height: 1.6;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: var(--primary-light);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-buttons button {
    flex: 1;
}

/* 错题列表 */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-bar input {
    flex: 2;
    padding: 10px 15px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.question-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.question-card:hover {
    background: var(--gray-100);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.question-subject {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.question-date {
    color: var(--gray-400);
    font-size: 12px;
}

.question-preview {
    color: var(--gray-600);
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.question-knowledge {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.question-knowledge .tag {
    font-size: 11px;
    padding: 4px 8px;
    background: var(--gray-200);
    color: var(--gray-600);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 15px;
}

/* 练习模式 */
.practice-source-picker {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 14px;
}

.practice-source-picker label {
    display: block;
    font-size: 13px;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-weight: 500;
}

.practice-source-picker select {
    width: 100%;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    background: white;
}

.practice-source-preview {
    margin-top: 8px;
    color: var(--gray-600);
    font-size: 13px;
    line-height: 1.5;
}

.practice-intro {
    text-align: center;
    padding: 20px;
}

.practice-intro h3 {
    margin-bottom: 10px;
}

.practice-intro p {
    color: var(--gray-500);
    margin-bottom: 10px;
}

.practice-tip {
    font-size: 13px;
    color: var(--warning);
}

.practice-type-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.practice-type-btn {
    flex: 1;
    min-width: 150px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 15px 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.practice-type-btn:hover {
    border-color: var(--primary);
    background: white;
}

.practice-type-btn.active {
    border-color: var(--primary);
    background: white;
    box-shadow: var(--shadow);
}

.practice-type-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    border-color: var(--gray-200);
    background: var(--gray-50);
    box-shadow: none;
}

.practice-type-btn:disabled:hover {
    border-color: var(--gray-200);
    background: var(--gray-50);
}

.practice-type-btn .icon {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}

.practice-type-btn .label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
    display: block;
}

.practice-type-btn .desc {
    font-size: 11px;
    color: var(--gray-500);
    display: block;
    margin-top: 3px;
}

.practice-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

.loading-progress {
    color: var(--primary);
    font-weight: 500;
}

.practice-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.option-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.option-card:hover {
    border-color: var(--primary);
    background: white;
    box-shadow: var(--shadow);
}

.option-card .icon {
    font-size: 36px;
    display: block;
    margin-bottom: 10px;
}

.option-card h4 {
    font-size: 15px;
    margin-bottom: 5px;
}

.option-card p {
    font-size: 12px;
    color: var(--gray-500);
}

.practice-area {
    max-width: 600px;
    margin: 0 auto;
}

.practice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.practice-type {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.practice-progress {
    color: var(--gray-500);
    font-size: 14px;
}

.practice-question {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    line-height: 1.8;
    min-height: 150px;
}

.practice-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.practice-generate-actions {
    margin-top: 0;
    margin-bottom: 16px;
}

.practice-feedback {
    margin-top: 20px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 4px solid var(--success);
}

.practice-feedback.incorrect {
    border-left-color: var(--danger);
}

.practice-meta {
    margin-bottom: 12px;
    color: var(--gray-600);
    font-size: 13px;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 10px 12px;
}

.practice-hint {
    margin: -10px 0 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    padding: 10px 12px;
    color: #9a3412;
    font-size: 14px;
}

.practice-summary {
    background: #f0fdfa;
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: 12px;
    padding: 16px;
}

.practice-question-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.practice-question-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 14px 14px 8px;
}

.practice-question-index {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-dark);
    background: #ffffff;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    padding: 4px 10px;
    margin-bottom: 8px;
}

.practice-question-text {
    line-height: 1.75;
    color: var(--gray-800);
}

.practice-note {
    margin-top: 14px;
    color: var(--gray-500);
    font-size: 13px;
}

.practice-summary h4 {
    margin-bottom: 8px;
    color: var(--primary-dark);
}

.practice-summary p {
    margin: 4px 0;
}

.feedback-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--gray-500);
}

.diagram-container {
    margin: 12px auto;
    padding: 4px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
}

.diagram-container svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* 统计 */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
}

.knowledge-distribution,
.recent-activity {
    margin-bottom: 30px;
}

.knowledge-distribution h3,
.recent-activity h3 {
    margin-bottom: 15px;
    font-size: 16px;
}

.distribution-chart {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
}

.distribution-item {
    margin-bottom: 15px;
}

.distribution-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
}

.distribution-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.distribution-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

.loading-detail {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.activity-list {
    background: var(--gray-50);
    border-radius: var(--radius);
}

.activity-item {
    padding: 15px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.activity-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 14px;
    font-weight: 500;
}

.activity-time {
    font-size: 12px;
    color: var(--gray-400);
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
}

.close-btn:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 20px;
}

.modal-body img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 15px;
}

.modal-body .result-section {
    margin-bottom: 15px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
}

.download-group {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    background: var(--gray-50);
}

.download-group:last-child {
    margin-bottom: 0;
}

.download-group h4 {
    font-size: 16px;
    margin-bottom: 6px;
}

.download-group p {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 10px;
}

.download-actions {
    display: flex;
    gap: 10px;
}

.download-actions .btn-secondary {
    width: auto;
    margin-top: 0;
    padding: 10px 14px;
    font-size: 14px;
}

.download-mode-tip {
    margin-bottom: 12px;
    color: var(--gray-600);
    font-size: 14px;
}

.download-mode-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-mode-actions .btn-secondary {
    width: 100%;
    margin-top: 0;
    text-align: left;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%) translateY(20px);
    background: #0f172a;
    color: white;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s;
    z-index: 1200;
    box-shadow: var(--shadow);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #065f46;
}

.toast.warning {
    background: #9a3412;
}

.toast.error {
    background: #991b1b;
}

/* 响应式 */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .tabs-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .tabs {
        overflow-x: auto;
    }
    
    .tab {
        padding: 12px 15px;
        white-space: nowrap;
    }
    
    .practice-options {
        grid-template-columns: 1fr;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .action-buttons {
        flex-direction: column;
    }

    .download-actions {
        flex-direction: column;
    }
}

/* 加载动画 */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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