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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f4f8;
    color: #333;
    min-height: 100vh;
}

#app {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

/* ===== Home Page ===== */
.home {
    padding-top: 40px;
}

.home-header {
    text-align: center;
    margin-bottom: 40px;
}

.home-header .logo {
    font-size: 64px;
    margin-bottom: 8px;
}

.home-header h1 {
    font-size: 36px;
    color: #2c3e50;
    font-weight: 800;
}

.home-header .subtitle {
    color: #7f8c8d;
    font-size: 16px;
    margin-top: 4px;
}

.subject-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.subject-card {
    background: white;
    border-radius: 20px;
    padding: 28px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    border-left: 6px solid var(--card-color);
    display: flex;
    align-items: center;
    gap: 20px;
}

.subject-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.subject-card:active {
    transform: scale(0.98);
}

.card-icon {
    font-size: 48px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 16px;
}

.card-name {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
}

.card-count {
    font-size: 14px;
    color: #95a5a6;
    margin-top: 2px;
}

/* ===== Quiz Page ===== */
.quiz {
    padding-top: 16px;
}

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

.back-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #7f8c8d;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #e8e8e8;
}

.quiz-subject {
    flex: 1;
    font-size: 20px;
    font-weight: 700;
}

.quiz-progress-text {
    font-size: 14px;
    color: #95a5a6;
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.question-area {
    animation: fadeIn 0.3s ease;
}

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

.question-number {
    display: inline-block;
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.question-text {
    font-size: 20px;
    line-height: 1.6;
    font-weight: 600;
    margin-bottom: 24px;
    color: #2c3e50;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.option {
    background: white;
    border: 2px solid #e8e8e8;
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.option:hover:not(.correct):not(.wrong) {
    border-color: #b0b0b0;
    transform: translateX(4px);
}

.option.selected {
    border-color: #3498db;
    background: #ebf5fb;
}

.option.correct {
    border-color: #27ae60;
    background: #eafaf1;
    animation: pulseCorrect 0.4s ease;
}

.option.wrong {
    border-color: #e74c3c;
    background: #fdedec;
    animation: shake 0.4s ease;
}

@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.option-label {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.option.correct .option-label {
    background: #27ae60;
    color: white;
}

.option.wrong .option-label {
    background: #e74c3c;
    color: white;
}

.option-text {
    flex: 1;
    font-size: 17px;
    line-height: 1.5;
}

.option-badge {
    font-size: 20px;
    font-weight: 700;
}

.correct-badge { color: #27ae60; }
.wrong-badge { color: #e74c3c; }

.explanation {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    animation: fadeIn 0.3s ease;
}

.explanation-correct {
    border: 2px solid #27ae60;
    background: #f0faf4;
}

.explanation-wrong {
    border: 2px solid #e74c3c;
    background: #fef5f5;
}

.explanation-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.explanation-text {
    font-size: 15px;
    line-height: 1.6;
    color: #555;
}

.quiz-actions {
    text-align: center;
    margin-bottom: 32px;
}

.btn {
    border: none;
    border-radius: 16px;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.btn:active {
    transform: scale(0.97);
}

.btn-confirm {
    background: #3498db;
    color: white;
}

.btn-confirm.disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-next {
    color: white;
    padding: 16px 48px;
}

.btn-back-home {
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 16px 48px;
}

/* ===== Result Page ===== */
.result-area {
    animation: fadeIn 0.4s ease;
}

.result-card {
    background: white;
    border-radius: 24px;
    padding: 36px 24px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.result-icon {
    font-size: 64px;
    margin-bottom: 8px;
}

.result-title {
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 16px;
}

.result-score {
    font-size: 48px;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 4px;
}

.result-pct {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
}

.result-bar-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.result-bar {
    height: 16px;
    background: #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.result-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.8s ease;
}

.result-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #7f8c8d;
}

.wrong-section {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}

.wrong-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #e74c3c;
}

.wrong-item {
    padding: 16px;
    border-left: 4px solid #e74c3c;
    background: #fef5f5;
    border-radius: 0 12px 12px 0;
    margin-bottom: 12px;
}

.wrong-q {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.wrong-detail {
    display: flex;
    gap: 16px;
    font-size: 14px;
    margin-bottom: 8px;
}

.wrong-answer {
    color: #e74c3c;
    font-weight: 600;
}

.correct-answer {
    color: #27ae60;
    font-weight: 600;
}

.wrong-exp {
    font-size: 14px;
    color: #7f8c8d;
    line-height: 1.5;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-bottom: 40px;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    #app { padding: 12px; }
    .home-header h1 { font-size: 28px; }
    .subject-card { padding: 20px 16px; }
    .card-icon { font-size: 36px; width: 48px; height: 48px; }
    .card-name { font-size: 20px; }
    .question-text { font-size: 18px; }
    .option { padding: 14px 16px; }
    .option-text { font-size: 15px; }
    .result-score { font-size: 40px; }
}

/* ===== Home Footer ===== */
.home-footer {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.knowledge-entry, .wrong-summary {
    background: white;
    border-radius: 16px;
    padding: 18px 24px;
    cursor: pointer;
    font-weight: 700;
    font-size: 17px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    text-align: center;
}

.knowledge-entry {
    background: #f0f4ff;
    border: 2px solid #d0d8ff;
    color: #4a6ad9;
}

.knowledge-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74,106,217,0.15);
}

.knowledge-links {
    display: flex;
    gap: 8px;
}

.knowledge-link {
    flex: 1;
    display: block;
    text-align: center;
    text-decoration: none;
    border-radius: 12px;
    padding: 14px 8px;
    font-weight: 700;
    font-size: 15px;
    border: 2px solid;
    transition: all 0.25s ease;
}

.knowledge-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.wrong-summary {
    background: #fff5f5;
    border: 2px solid #ffd0d0;
    color: #d94a4a;
}

.wrong-summary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(217,74,74,0.15);
}

/* ===== Knowledge Page ===== */
.knowledge-page {
    padding-top: 12px;
    padding-bottom: 40px;
}

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

.knowledge-title {
    font-size: 20px;
    font-weight: 700;
}

.knowledge-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.knowledge-tab {
    flex: 1;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 12px;
    padding: 10px 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
}

.knowledge-tab:hover {
    transform: translateY(-2px);
}

.knowledge-tab.active {
    border-color: var(--tab-color, #4A90D9);
    background: var(--tab-color, #4A90D9);
    color: white;
}

.knowledge-content {
    background: white;
    border-radius: 16px;
    padding: 24px 20px;
    min-height: 50vh;
    overflow-y: visible;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    line-height: 1.8;
    font-size: 15px;
}

.knowledge-content h1 {
    font-size: 22px;
    color: #2c3e50;
    margin: 20px 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.knowledge-content h2 {
    font-size: 18px;
    color: #34495e;
    margin: 16px 0 8px;
    padding-left: 8px;
    border-left: 4px solid #4A90D9;
}

.knowledge-content h3 {
    font-size: 16px;
    color: #555;
    margin: 12px 0 6px;
}

.knowledge-content p {
    margin: 6px 0;
}

.knowledge-content ul, .knowledge-content ol {
    margin: 6px 0;
    padding-left: 24px;
}

.knowledge-content li {
    margin: 4px 0;
}

.knowledge-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}

.knowledge-content th, .knowledge-content td {
    border: 1px solid #ddd;
    padding: 8px 10px;
    text-align: left;
}

.knowledge-content th {
    background: #f8f9fa;
    font-weight: 700;
}

.knowledge-content tr:nth-child(even) {
    background: #fafafa;
}

.knowledge-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.knowledge-content strong {
    color: #2c3e50;
}

.knowledge-content a {
    color: #4A90D9;
    text-decoration: none;
}

.knowledge-content hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 16px 0;
}

/* ===== Stats Bar ===== */
.stats-bar {
    display: flex;
    gap: 10px;
    margin: 16px 0 20px;
}

.stat-item {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 14px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-study {
    background: #e8f4fd;
}

.stat-quiz {
    background: #fef0e8;
}

.stat-total {
    background: #e8fcf0;
}

.stat-info {
    min-width: 0;
}

.stat-label {
    font-size: 11px;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin-top: 2px;
}

/* ===== Progress Section ===== */
.progress-section {
    background: white;
    border-radius: 20px;
    padding: 20px 20px 12px;
    margin-top: 20px;
    margin-bottom: 40px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}

.progress-title {
    font-size: 15px;
    font-weight: 700;
    color: #555;
    margin-bottom: 14px;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.progress-subj-name {
    width: 64px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

.progress-bar-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar-bg {
    flex: 1;
    height: 10px;
    background: #e8e8e8;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    display: block;
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-num {
    font-size: 12px;
    color: #999;
    font-weight: 600;
    width: 44px;
    text-align: right;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .stats-bar { gap: 6px; }
    .stat-item { padding: 10px 8px; gap: 6px; }
    .stat-icon { width: 30px; height: 30px; font-size: 16px; }
    .stat-value { font-size: 14px; }
}
