:root {
    --bg-gradient-start: #fff8f0;
    --bg-gradient-mid: #ffeedd;
    --bg-gradient-end: #fde2c8;
    --primary: #d35400;
    --primary-light: rgba(211, 84, 0, 0.15);
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 8px rgba(211, 84, 0, 0.12);
    --card-radius: 12px;
    --correct: #27ae60;
    --incorrect: #e74c3c;
    --font-main: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --border-color: #e0e0e0;
    --border-light: #eee;
    --bg-muted: #f0f0f0;
}

[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-mid: #16213e;
    --bg-gradient-end: #0f3460;
    --primary: #e67e22;
    --primary-light: rgba(230, 126, 34, 0.2);
    --text-dark: #ecf0f1;
    --text-muted: #95a5a6;
    --card-bg: #1e2a3a;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --correct: #2ecc71;
    --incorrect: #e74c3c;
    --border-color: #2c3e50;
    --border-light: #2c3e50;
    --bg-muted: #253345;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: linear-gradient(160deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
    color: var(--text-dark);
    min-height: 100vh;
}

.navbar {
    background: var(--card-bg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    line-height: 1;
}
.hamburger-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.navbar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.5px;
}
.navbar-logo .uno, .navbar-logo .daily { color: var(--primary); }
.navbar-logo .dos { color: var(--text-dark); }

.navbar-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    list-style: none;
}
.navbar-links a {
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}
.navbar-links a:hover, .navbar-links a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.streak-nav-badge {
    background: rgba(230, 126, 34, 0.15);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 12px;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}
.settings-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.settings-overlay.open {
    display: flex;
}
.settings-modal {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 440px;
    padding: 2rem;
    margin: 1rem;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.settings-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
}
.settings-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    line-height: 1;
}
.settings-close:hover {
    color: var(--incorrect);
    background: rgba(231, 76, 60, 0.1);
}
.settings-section {
    margin-bottom: 1.5rem;
}
.settings-section:last-child {
    margin-bottom: 0;
}
.settings-label {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}
.settings-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.settings-select {
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    color: var(--text-dark);
    background: var(--card-bg);
    cursor: pointer;
    font-weight: 600;
}
.settings-select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-danger {
    background: var(--incorrect);
    color: white;
}
.btn-danger:hover {
    background: #c0392b;
}

.container { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }

.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(211,84,0,0.18);
}

.drill-section-title {
    font-size: 1.3rem; font-weight: 700; color: var(--text-dark); margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem; border-bottom: 2px solid var(--primary-light);
}
.drill-section-title:first-of-type { margin-top: 0; }

.lesson-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.lesson-card {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 1rem 1.25rem; text-decoration: none; color: var(--text-dark); transition: transform 0.2s; display: block;
}
.lesson-card:hover { transform: translateY(-2px); }
.lesson-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.lesson-card-count { font-size: 0.85rem; color: var(--text-muted); }
.lesson-card-preview { font-size: 0.9rem; color: var(--text-muted); }
.lesson-card-numbers { border-left: 3px solid #2980b9; }

.best-score {
    margin-top: 0.5rem; font-size: 0.85rem; font-weight: 700; color: var(--correct);
}
.best-score:empty { display: none; }

.study-word-list {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 1.5rem; overflow-x: auto;
}
.study-table { width: 100%; border-collapse: collapse; }
.study-table th {
    text-align: left; padding: 0.6rem 1rem; border-bottom: 2px solid var(--primary);
    color: var(--primary); font-weight: 700; font-size: 0.9rem;
}
.study-table td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-light); }
.study-table tr:hover { background: var(--primary-light); }

.icon-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}
.icon-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 2rem 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-dark);
    transition: transform 0.2s, box-shadow 0.2s;
}
.icon-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(211,84,0,0.2);
}
.icon-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.icon-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--primary); }
.icon-card p { font-size: 0.85rem; color: var(--text-muted); }

.level-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.flashcard-container { display: flex; justify-content: center; margin: 2rem 0; }
.flashcard { width: 400px; height: 280px; perspective: 1000px; cursor: pointer; }
.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.6s; transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden;
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem;
}
.flashcard-back { transform: rotateY(180deg); }
.flashcard-word { font-size: 2rem; font-weight: 700; font-family: var(--font-serif); color: var(--text-dark); }
.flashcard-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.flashcard-example { font-size: 0.9rem; color: var(--text-muted); margin-top: 1rem; font-style: italic; text-align: center; }
.flashcard-controls { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; align-items: center; }

.btn {
    display: inline-block; padding: 0.6rem 1.2rem; border: none; border-radius: 8px;
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s, transform 0.1s; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #bf4b00; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.mode-selector { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.mode-btn {
    padding: 0.5rem 1rem; border: 2px solid var(--primary); border-radius: 8px;
    background: transparent; color: var(--primary); font-weight: 600;
    cursor: pointer; transition: background 0.2s, color 0.2s; font-size: 0.9rem;
}
.mode-btn.active { background: var(--primary); color: white; }

.quiz-question { text-align: center; margin: 2rem 0; }
.quiz-prompt { font-size: 1.8rem; font-weight: 700; font-family: var(--font-serif); color: var(--text-dark); margin-bottom: 0.5rem; }
.quiz-instruction { font-size: 0.9rem; color: var(--text-muted); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 600px; margin: 1.5rem auto; }
.quiz-option {
    background: var(--card-bg); border: 2px solid var(--border-color); border-radius: var(--card-radius);
    padding: 1.2rem; font-size: 1.1rem; font-weight: 600; cursor: pointer;
    transition: border-color 0.2s, background 0.2s; text-align: center;
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.correct { border-color: var(--correct); background: rgba(39,174,96,0.15); }
.quiz-option.incorrect { border-color: var(--incorrect); background: rgba(231,76,60,0.15); }
.quiz-score { text-align: center; font-size: 1.1rem; color: var(--text-dark); margin: 1rem 0; }
.quiz-score strong { color: var(--primary); }

.conj-hint-table {
    max-width: 400px; margin: 0 auto; border-collapse: collapse; width: 100%;
}
.conj-hint-table th, .conj-hint-table td {
    padding: 0.5rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color);
}
.conj-hint-table th { font-weight: 700; color: var(--primary); border-bottom: 2px solid var(--primary); }
.conj-hint-table td:first-child { color: var(--text-muted); font-weight: 600; }

.dictionary-search { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.dictionary-search input {
    flex: 1; padding: 0.75rem 1rem; border: 2px solid var(--border-color);
    border-radius: 8px; font-size: 1rem; min-width: 200px;
}
.dictionary-search input:focus { outline: none; border-color: var(--primary); }

.word-list { list-style: none; }
.word-item {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 1rem 1.5rem; margin-bottom: 0.75rem;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: transform 0.2s; text-decoration: none; color: var(--text-dark);
}
.word-item:hover { transform: translateX(4px); }
.word-item .word-spanish { font-weight: 700; font-size: 1.1rem; }
.word-item .word-english { color: var(--text-muted); font-size: 0.95rem; }
.word-item .word-pos { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

.conjugation-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.conjugation-table th, .conjugation-table td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-light); }
.conjugation-table th { color: var(--primary); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }

.reading-list { display: grid; gap: 1rem; }
.reading-card {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 1.5rem; text-decoration: none; color: var(--text-dark); transition: transform 0.2s; display: block;
}
.reading-card:hover { transform: translateY(-2px); }
.reading-card h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.reading-card .reading-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem; }

.reading-content {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 2rem; line-height: 1.8; font-size: 1.1rem;
}
.reading-content .translation { color: var(--text-muted); border-top: 2px solid var(--border-light); padding-top: 1.5rem; margin-top: 1.5rem; }
.reading-source { font-size: 0.85rem; color: var(--text-muted); margin-top: 1rem; font-style: italic; }

.reading-paragraph { margin-bottom: 1.25rem; }

.reading-sentence-block { display: inline; }

.speak-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
    opacity: 0.4;
    transition: opacity 0.2s;
    vertical-align: middle;
}
.speak-btn:hover { opacity: 1; }

.reading-sentence {
    cursor: pointer; border-radius: 4px; padding: 2px 4px; transition: background-color 0.2s;
}
.reading-sentence:hover { background-color: #fde2c8; }
.reading-sentence-active { background-color: #fde2c8; }

.sentence-translation {
    display: block; color: #2980b9; font-size: 0.92em; padding: 2px 4px; margin: 2px 0 4px 0;
}

.page-header { text-align: center; margin-bottom: 2rem; }
.page-header h1 { font-size: 2rem; font-weight: 800; color: var(--text-dark); }
.page-header p { color: var(--text-muted); margin-top: 0.5rem; }

.detail-card {
    background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
    padding: 2rem; max-width: 600px; margin: 0 auto;
}
.detail-word { font-size: 2.5rem; font-weight: 700; font-family: var(--font-serif); color: var(--text-dark); }
.detail-translation { font-size: 1.3rem; color: var(--primary); margin-top: 0.3rem; }
.detail-meta { display: flex; gap: 1rem; margin-top: 0.75rem; align-items: center; }
.detail-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-light); }
.detail-section h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); margin-bottom: 0.75rem; }

@media (max-width: 768px) {
    .navbar { padding: 0.75rem 1rem; height: auto; }
    .hamburger-btn { display: block; }
    .navbar-right { order: 2; }
    .navbar-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 0;
        order: 3;
    }
    .navbar-links.open { display: flex; }
    .navbar-links li { width: 100%; }
    .navbar-links a {
        display: block;
        padding: 0.75rem 1rem;
        border-radius: 0;
    }
    .flashcard { width: 100%; max-width: 400px; }
    .quiz-options { grid-template-columns: 1fr; }
    .icon-cards { grid-template-columns: 1fr 1fr; }
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
}

.sentence-answer-area {
    min-height: 60px;
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: var(--card-radius);
    padding: 1rem;
    margin: 1.5rem auto;
    max-width: 700px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.sentence-word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-width: 700px;
    margin: 1rem auto;
}

.sentence-word {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}
.sentence-word:hover {
    background: var(--primary-light);
}
.sentence-word:active {
    transform: scale(0.95);
}
.sentence-word-placed {
    background: var(--primary);
    color: white;
}
.sentence-word-placed:hover {
    background: #bf4b00;
}

.sentence-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.sentence-feedback {
    text-align: center;
    padding: 1rem;
    border-radius: var(--card-radius);
    max-width: 700px;
    margin: 1rem auto;
    font-weight: 600;
    font-size: 1.1rem;
}
.sentence-feedback-correct {
    background: rgba(39, 174, 96, 0.15);
    color: var(--correct);
}
.sentence-feedback-incorrect {
    background: rgba(231, 76, 60, 0.15);
    color: var(--incorrect);
}

/* ============ LESSON WIZARD ============ */

.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 1rem 0;
}
.wizard-step {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-muted);
    transition: all 0.3s;
    white-space: nowrap;
}
.wizard-step.active {
    background: var(--primary);
    color: white;
}
.wizard-step.completed {
    background: var(--correct);
    color: white;
}
.wizard-step-line {
    width: 2rem;
    height: 2px;
    background: var(--border-color);
    transition: background 0.3s;
}
.wizard-step-line.completed {
    background: var(--correct);
}

.review-badge {
    display: inline-block;
    background: rgba(41, 128, 185, 0.15);
    color: #2980b9;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
}

.streak-badge {
    display: inline-block;
    background: rgba(211, 84, 0, 0.15);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    transition: transform 0.2s;
}
.streak-badge:not(.streak-break) {
    animation: streakPulse 0.3s ease;
}
.streak-break {
    animation: streakShake 0.3s ease;
}
@keyframes streakPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@keyframes streakShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.lesson-complete-check {
    color: var(--correct);
    font-weight: 700;
    font-size: 0.85rem;
}

.lesson-card-next {
    border: 2px solid var(--primary);
}

/* ============ DASHBOARD ============ */

.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dash-stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    text-align: center;
}
.dash-stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}
.dash-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.4rem;
}
.dash-stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.dash-level-row {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
}
.dash-level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.progress-bar {
    background: var(--bg-muted);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    display: flex;
}
.progress-fill {
    height: 100%;
    transition: width 0.5s;
}

@media (max-width: 768px) {
    .wizard-step { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
    .wizard-step-line { width: 1rem; }
}
