/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3B5998;
    --primary-light: #4A6FB5;
    --primary-dark: #2D4373;
    --bg: #F8F9FA;
    --bg-card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --text-muted: #B2BEC3;
    --green: #27AE60;
    --green-light: #E8F8F0;
    --red: #E74C3C;
    --red-light: #FDE8E6;
    --gold: #F39C12;
    --gold-light: #FEF5E7;
    --border: #DFE6E9;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --transition: 0.2s ease;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

/* === Views === */
.view {
    display: none;
}

.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

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

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

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-light);
}

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

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

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

/* === Login === */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
}

.login-container h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

.login-form input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}

.login-form input:focus {
    border-color: var(--primary);
}

.error-text {
    color: var(--red);
    font-size: 13px;
    margin-top: 12px;
}

/* === Dashboard === */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dashboard-header h1 {
    font-size: 22px;
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.streak-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 20px;
    font-size: 16px;
}

.streak-fire {
    margin-right: 8px;
}

.review-banner {
    background: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.review-banner p {
    font-size: 14px;
    flex: 1;
}

.section-title {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exercise-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.exercise-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    cursor: pointer;
}

.exercise-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.exercise-card.completed {
    border-color: var(--green);
    background: var(--green-light);
}

.card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.exercise-card h3 {
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text);
}

.card-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.card-status {
    margin-bottom: 10px;
}

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

.exercise-card.completed .status-score {
    color: var(--green);
}

.card-start {
    width: 100%;
}

.exercise-card.completed .card-start {
    background: var(--green);
}

/* === Exercise View === */
.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.exercise-progress {
    font-weight: 600;
    color: var(--primary);
    font-size: 15px;
}

.exercise-timer {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.exercise-content {
    min-height: 400px;
}

/* Qualifier Spotting */
.exercise-prompt {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.exercise-prompt strong {
    color: var(--primary);
}

.word-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 24px;
    line-height: 1.8;
}

.word-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    user-select: none;
    background: var(--bg);
    text-transform: lowercase;
}

.word-pill:hover {
    background: #E8EDF3;
    border-color: var(--primary-light);
}

.word-pill.selected {
    background: #D6E4F0;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.word-pill.correct {
    background: var(--green-light);
    border-color: var(--green);
    color: var(--green);
    font-weight: 600;
}

.word-pill.incorrect {
    background: var(--red-light);
    border-color: var(--red);
    color: var(--red);
}

.word-pill.missed {
    background: var(--gold-light);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: 600;
    animation: pulse-gold 1.5s ease-in-out infinite;
}

.word-pill.disabled {
    cursor: default;
    opacity: 0.8;
}

@keyframes pulse-gold {
    0%, 100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(243, 156, 18, 0); }
}

/* Multiple Choice */
.mc-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.mc-option {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition);
    text-align: left;
}

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

.mc-option.selected {
    border-color: var(--primary);
    background: #D6E4F0;
    font-weight: 500;
}

.mc-option.correct {
    border-color: var(--green);
    background: var(--green-light);
}

.mc-option.incorrect {
    border-color: var(--red);
    background: var(--red-light);
}

.mc-option.disabled {
    cursor: default;
}

.mc-option.disabled:hover {
    border-color: var(--border);
    background: var(--bg-card);
}

.mc-option.correct.disabled:hover {
    border-color: var(--green);
    background: var(--green-light);
}

.mc-option.incorrect.disabled:hover {
    border-color: var(--red);
    background: var(--red-light);
}

/* Word Discrimination - Odd One Out */
.word-disc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.word-disc-option {
    padding: 20px;
    text-align: center;
    font-size: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.5px;
}

.word-disc-option:hover {
    border-color: var(--primary);
    background: #F0F4FF;
}

.word-disc-option.selected {
    border-color: var(--primary);
    background: #D6E4F0;
}

.word-disc-option.correct {
    border-color: var(--green);
    background: var(--green-light);
}

.word-disc-option.incorrect {
    border-color: var(--red);
    background: var(--red-light);
}

.word-disc-option.disabled {
    cursor: default;
}

/* Question text with highlighted qualifiers */
.question-text {
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 8px;
    color: var(--text);
}

.qualifier-highlight {
    background: var(--gold-light);
    border-bottom: 2px solid var(--gold);
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* Explanation box */
.explanation-box {
    background: #F0F4FF;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.explanation-box strong {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
}

/* Submit / Next buttons in exercise */
.exercise-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exercise-actions .btn {
    flex: 1;
}

/* === Confidence Modal === */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 340px;
    width: 90%;
    z-index: 1;
}

.modal-title {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text);
}

.confidence-buttons {
    display: flex;
    gap: 10px;
}

.btn-confidence {
    flex: 1;
    padding: 12px 8px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-confidence:hover {
    border-color: var(--primary);
    background: #F0F4FF;
}

.btn-confidence[data-confidence="low"] { color: var(--red); }
.btn-confidence[data-confidence="medium"] { color: var(--gold); }
.btn-confidence[data-confidence="high"] { color: var(--green); }

.btn-confidence[data-confidence="low"]:hover { border-color: var(--red); background: var(--red-light); }
.btn-confidence[data-confidence="medium"]:hover { border-color: var(--gold); background: var(--gold-light); }
.btn-confidence[data-confidence="high"]:hover { border-color: var(--green); background: var(--green-light); }

/* === Session Summary === */
.summary-container {
    text-align: center;
    padding: 40px 0;
}

.summary-container h2 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 24px;
}

.summary-score {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.summary-time {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.summary-confidence {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.summary-mistakes {
    text-align: left;
    margin: 0 auto 24px;
    max-width: 480px;
}

.summary-mistakes h3 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 10px;
}

.mistake-item {
    padding: 10px 14px;
    background: var(--red-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text);
}

/* === Progress View === */
.progress-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.progress-header h2 {
    font-size: 20px;
    color: var(--primary);
}

.progress-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.chart-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    height: 280px;
}

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

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

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

.analysis-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.analysis-section h3 {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 12px;
}

.analysis-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.analysis-bar-label {
    font-size: 13px;
    color: var(--text);
    width: 120px;
    flex-shrink: 0;
}

.analysis-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.analysis-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.analysis-bar-value {
    font-size: 13px;
    color: var(--text-light);
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.analysis-empty {
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
    text-align: center;
    padding: 12px;
}

/* === Responsive === */
@media (max-width: 480px) {
    #app {
        padding: 12px;
    }

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

    .dashboard-header h1 {
        font-size: 18px;
    }

    .word-pill {
        font-size: 16px;
        padding: 3px 8px;
    }

    .question-text {
        font-size: 16px;
    }

    .mc-option {
        font-size: 15px;
        padding: 12px 14px;
    }

    .word-disc-grid {
        grid-template-columns: 1fr 1fr;
    }

    .word-disc-option {
        font-size: 18px;
        padding: 16px;
    }

    .summary-score {
        font-size: 36px;
    }

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

/* === Utility === */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
