:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.navbar {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 28px;
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
}

.nav-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-item span {
    color: var(--primary-color);
    font-weight: 600;
}

.main-content {
    padding-top: 64px;
    min-height: 100vh;
}

.page {
    display: none;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.hero {
    text-align: center;
    padding: 40px 0;
}

.hero h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.quick-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 60px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.action-btn span {
    font-size: 20px;
}

.category-section h2 {
    font-size: 24px;
    margin-bottom: 24px;
    text-align: center;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    border: 2px solid transparent;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.category-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.category-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.category-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 16px 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.back-btn {
    padding: 8px 16px;
    border: none;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--border-color);
}

.quiz-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.quiz-category {
    padding: 6px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.quiz-progress {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.quiz-progress span {
    color: var(--primary-color);
}

.quiz-mode {
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.switch input {
    width: 44px;
    height: 24px;
    accent-color: var(--primary-color);
}

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.question-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.question-type {
    display: inline-block;
    padding: 4px 12px;
    background: #dbeafe;
    color: var(--primary-color);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}

.question-content {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.option-item:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.option-item.selected {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.option-item.correct {
    border-color: var(--success-color);
    background: #ecfdf5;
}

.option-item.wrong {
    border-color: var(--error-color);
    background: #fef2f2;
}

.option-label {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 50%;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.option-item.selected .option-label {
    background: var(--primary-color);
    color: white;
}

.option-item.correct .option-label {
    background: var(--success-color);
    color: white;
}

.option-item.wrong .option-label {
    background: var(--error-color);
    color: white;
}

.option-text {
    flex: 1;
    font-size: 16px;
    line-height: 1.6;
}

.answer-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.answer-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.answer-result.correct {
    background: #ecfdf5;
    color: var(--success-color);
}

.answer-result.wrong {
    background: #fef2f2;
    color: var(--error-color);
}

.answer-detail {
    display: flex;
    gap: 32px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.answer-detail .label {
    color: var(--text-secondary);
    font-size: 14px;
}

.answer-detail .value {
    font-weight: 600;
    font-size: 16px;
}

.correct-answer .value {
    color: var(--success-color);
}

.user-answer .value {
    color: var(--error-color);
}

.explanation {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 20px;
}

.explanation-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.explanation-content {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.explanation-source {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.ai-badge {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(135deg, #7c3aed, var(--primary-color));
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.quiz-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.btn-primary, .btn-secondary {
    padding: 12px 32px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

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

.page-header h2 {
    font-size: 24px;
}

.wrong-list {
    display: grid;
    gap: 16px;
}

.wrong-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid var(--error-color);
}

.wrong-item:hover {
    box-shadow: var(--shadow-lg);
}

.wrong-question {
    font-size: 16px;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wrong-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.stats-row .wide {
    grid-column: 1 / -1;
}

.stat-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-box-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.progress-ring {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
}

.progress-ring svg {
    transform: rotate(-90deg);
}

.progress-bg {
    fill: none;
    stroke: var(--bg-color);
    stroke-width: 10;
}

.progress-bar {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

.accuracy-display {
    text-align: center;
}

.accuracy-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.accuracy-bar {
    height: 12px;
    background: var(--bg-color);
    border-radius: 6px;
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #7c3aed);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.category-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.category-stat-item {
    text-align: center;
    padding: 20px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.category-stat-name {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.category-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.category-stat-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.recent-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-title {
    font-weight: 500;
}

.recent-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.recent-result {
    font-weight: 600;
}

.recent-result.correct {
    color: var(--success-color);
}

.recent-result.wrong {
    color: var(--error-color);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

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

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .category-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
    }

    .nav-menu {
        display: none;
    }

    .nav-stats {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        flex-direction: column;
        align-items: center;
    }

    .quiz-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .answer-detail {
        flex-direction: column;
        gap: 12px;
    }

    .quiz-actions {
        flex-wrap: wrap;
    }
}
