:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #d69e2e;
    --accent-hover: #b7791f;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --success: #48bb78;
    --danger: #f56565;
    --shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
    --shadow-hover: 0 20px 60px -15px rgba(0,0,0,0.15);
}

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

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hero {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 60px 20px 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.3;
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 10px;
    position: relative;
    word-break: break-word;
}

.hero .subtitle {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    opacity: 0.9;
    font-weight: 300;
    position: relative;
    max-width: 700px;
    margin: 0 auto;
}

.hero .lang-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 15px;
    margin-top: 25px;
    position: relative;
}

.badge {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: -30px auto 0;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 8px;
    gap: 6px;
    overflow: hidden;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    flex: 1 1 auto;
    min-width: 90px;
    padding: 14px 10px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-align: center;
}

.main-container {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

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

.nav-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(26, 54, 93, 0.3);
}

.section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 30px;
}

.section-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 40px;
}

.flashcard {
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    cursor: pointer;
    transition: transform 0.6s, box-shadow 0.3s;
    transform-style: preserve-3d;
    position: relative;
}

.flashcard:hover {
    box-shadow: var(--shadow-hover);
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    backface-visibility: hidden;
    text-align: center;
    width: 100%;
}

.flashcard-back {
    position: absolute;
    transform: rotateY(180deg);
    padding: 40px;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.flashcard-lang {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 15px;
}

.flashcard-word {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.flashcard-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 20px;
}

.flashcard-translation {
    font-size: 1.3rem;
    color: var(--text);
    line-height: 1.6;
}

.flashcard-translation .lang-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-top: 15px;
    margin-bottom: 5px;
}

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 54, 93, 0.3);
}

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

.btn-accent:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.progress-container {
    max-width: 600px;
    margin: 0 auto 30px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.vocab-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 4px solid var(--accent);
    min-width: 0;
}

.vocab-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.vocab-card .swahili {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.vocab-card .translations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vocab-card .translation-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.vocab-card .lang-tag {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.lang-tag.fr { background: #fef3c7; color: #92400e; }
.lang-tag.en { background: #dbeafe; color: #1e40af; }
.lang-tag.zh { background: #fce7f3; color: #a21caf; }

.vocab-card .translation-text {
    font-size: 0.95rem;
    color: var(--text);
    font-style: italic;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.vocab-card .translation-text.en-text {
    font-style: normal;
}

.quiz-container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

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

.quiz-question {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--primary);
    text-align: center;
    margin-bottom: 30px;
}

.quiz-question .question-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 10px;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.quiz-option {
    padding: 18px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: white;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
}

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

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

.quiz-option.wrong {
    border-color: var(--danger);
    background: #fff5f5;
    color: var(--danger);
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.quiz-feedback {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: 500;
    display: none;
}

.quiz-feedback.show {
    display: block;
}

.quiz-feedback.correct {
    background: #f0fff4;
    color: #276749;
}

.quiz-feedback.wrong {
    background: #fff5f5;
    color: #c53030;
}

.quiz-score {
    text-align: center;
    font-size: 1.2rem;
    margin-top: 20px;
    color: var(--text-light);
}

.search-bar {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 30px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 16px 24px 16px 50px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26, 54, 93, 0.1);
}

.search-bar svg {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-tab {
    flex: 1 1 140px;
    min-width: 0;
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.filter-tab:hover, .filter-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Full-width heading that groups filter/section chips by department */
.filter-group-label {
    flex: 1 1 100%;
    width: 100%;
    margin: 8px 2px 2px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

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

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

.stat-card .number {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: var(--primary);
    font-weight: 700;
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

.section-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

.section-chip {
    flex: 1 1 130px;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.section-chip:hover, .section-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1 1 180px;
    min-width: 0;
    padding: 10px 18px;
    border-radius: 12px;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

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

.mode-btn:hover:not(.active) {
    background: var(--bg);
}

/* Departments / learning areas */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.dept-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--primary);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.dept-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.dept-card.dept-soon {
    border-top-color: #cbd5e0;
    opacity: 0.85;
}

.dept-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.dept-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 700;
}

.dept-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: #f0fff4;
    color: var(--success);
    white-space: nowrap;
}

.dept-badge.soon {
    background: #edf2f7;
    color: var(--text-light);
}

.dept-tagline {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 10px;
}

.dept-desc {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.dept-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.dept-topic {
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--bg);
    border: 1px solid #e2e8f0;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dept-topic:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.dept-meta {
    margin-top: auto;
    font-size: 0.82rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Grammar */
.grammar-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.grammar-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-light);
}

.grammar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.grammar-intro {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 14px;
}

.grammar-notes {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grammar-notes li {
    position: relative;
    padding-left: 22px;
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.6;
}

.grammar-notes li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.grammar-table-wrap {
    margin-top: 18px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.grammar-table-caption {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 360px;
}

.grammar-table th,
.grammar-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid #edf2f7;
}

.grammar-table th {
    background: var(--bg);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grammar-table tbody tr:hover {
    background: #f7fafc;
}

.grammar-table td:first-child {
    font-weight: 600;
    color: var(--primary-light);
    white-space: nowrap;
}

@media (max-width: 1024px) {
    .hero {
        padding: 50px 18px 70px;
    }

    .flashcard {
        min-height: 300px;
        padding: 32px 24px;
    }

    .quiz-card {
        padding: 32px 24px;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero .subtitle {
        font-size: 1rem;
    }

    .nav-container,
    .main-container {
        padding: 0 12px;
    }

    .flashcard-container {
        max-width: 100%;
    }

    .flashcard {
        min-height: 280px;
        padding: 28px 18px;
        border-radius: 20px;
    }

    .flashcard-word {
        font-size: 1.8rem;
    }

    .flashcard-translation {
        font-size: 1rem;
    }

    .quiz-options {
        grid-template-columns: 1fr;
    }

    .quiz-question {
        font-size: 1.5rem;
    }

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

    .vocab-card {
        padding: 20px;
    }

    .vocab-card .translation-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .vocab-card .translation-text {
        overflow-wrap: anywhere;
    }

    .search-bar {
        margin-bottom: 22px;
    }

    .search-bar input {
        padding: 14px 18px 14px 46px;
        font-size: 0.95rem;
    }

    .filter-tabs,
    .mode-toggle,
    .section-selector,
    .flashcard-controls {
        gap: 8px;
    }

    .nav-tab {
        min-width: 120px;
        padding: 12px 14px;
        font-size: 0.8rem;
    }

    .mode-btn,
    .filter-tab,
    .section-chip {
        width: 100%;
        text-align: center;
    }

    .btn {
        padding: 12px 18px;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 44px 14px 58px;
    }

    .nav-tab {
        flex: 1 1 calc(50% - 6px);
        max-width: calc(50% - 6px);
        font-size: 0.75rem;
        padding: 11px 8px;
    }

    .section-header h2 {
        font-size: 1.7rem;
    }

    .quiz-card {
        padding: 24px 16px;
        border-radius: 18px;
    }

    .stat-card {
        padding: 20px 16px;
    }

    .stat-card .number {
        font-size: 2rem;
    }

    .badge {
        font-size: 0.8rem;
        padding: 7px 12px;
    }
}
