/* ============================================
           CSS VARIABLES & ROOT STYLES
           ============================================ */
        :root {
            /* Case Colors */
            --nom: #3b82f6;
            --acc: #ef4444;
            --dat: #10b981;
            --gen: #8b5cf6;
            
            /* Gender Colors */
            --masc: #06b6d4;
            --fem: #ec4899;
            --neut: #f59e0b;
            --plural: #6366f1;
            
            /* UI Colors */
            --bg-primary: #0f172a;
            --bg-secondary: #1e293b;
            --bg-card: #334155;
            --text-primary: #f1f5f9;
            --text-secondary: #94a3b8;
            --accent: #f59e0b;
            --success: #22c55e;
            --error: #ef4444;
            --warning: #f59e0b;
            
            /* Spacing */
            --space-xs: 0.25rem;
            --space-sm: 0.5rem;
            --space-md: 1rem;
            --space-lg: 1.5rem;
            --space-xl: 2rem;
            --space-2xl: 3rem;
            
            /* Border Radius */
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
            --radius-xl: 1rem;
            
            /* Shadows */
            --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
        }

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

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

        /* ============================================
           NAVIGATION
           ============================================ */
        .chapter-nav {
            position: sticky;
            top: 0;
            background: var(--bg-secondary);
            padding: var(--space-md) var(--space-xl);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid var(--bg-card);
            z-index: 100;
            flex-wrap: wrap;
            gap: var(--space-sm);
        }

        .chapter-nav a {
            color: var(--text-primary);
            text-decoration: none;
            padding: var(--space-sm) var(--space-md);
            border-radius: var(--radius-md);
            transition: all 0.2s ease;
            font-weight: 500;
        }

        .chapter-nav a:hover {
            background: var(--bg-card);
            transform: translateY(-1px);
        }

        .chapter-nav .prev {
            border-left: 3px solid var(--nom);
        }

        .chapter-nav .next {
            border-right: 3px solid var(--gen);
        }

        .progress-bar {
            background: var(--bg-card);
            padding: var(--space-sm) var(--space-lg);
            border-radius: var(--radius-lg);
            font-size: 0.9rem;
            color: var(--text-secondary);
        }

        /* ============================================
           HEADER & HERO
           ============================================ */
        .hero {
            background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
            padding: var(--space-2xl);
            text-align: center;
            border-bottom: 1px solid var(--bg-card);
        }

        .chapter-badge {
            display: inline-block;
            background: linear-gradient(135deg, var(--nom), var(--gen));
            color: white;
            padding: var(--space-sm) var(--space-lg);
            border-radius: var(--radius-lg);
            font-size: 0.875rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: var(--space-md);
        }

        .hero h1 {
            font-size: clamp(1.75rem, 5vw, 2.5rem);
            margin-bottom: var(--space-sm);
            background: linear-gradient(90deg, var(--text-primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .hero .subtitle {
            color: var(--text-secondary);
            font-size: 1.1rem;
        }

        /* ============================================
           MAIN CONTAINER
           ============================================ */
        .container {
            max-width: 900px;
            margin: 0 auto;
            padding: var(--space-xl);
        }

        /* ============================================
           SECTION STYLES
           ============================================ */
        section {
            margin-bottom: var(--space-2xl);
        }

        h2 {
            font-size: 1.5rem;
            margin-bottom: var(--space-lg);
            padding-bottom: var(--space-sm);
            border-bottom: 2px solid var(--bg-card);
            display: flex;
            align-items: center;
            gap: var(--space-sm);
        }

        h2 .icon {
            font-size: 1.25rem;
        }

        h3 {
            font-size: 1.2rem;
            margin: var(--space-xl) 0 var(--space-md);
            color: var(--accent);
        }

        /* ============================================
           THEORY CARDS
           ============================================ */
        .theory-card {
            background: var(--bg-secondary);
            border-radius: var(--radius-lg);
            padding: var(--space-lg);
            margin-bottom: var(--space-lg);
            border-left: 4px solid var(--accent);
        }

        .theory-card.nom { border-left-color: var(--nom); }
        .theory-card.acc { border-left-color: var(--acc); }
        .theory-card.dat { border-left-color: var(--dat); }
        .theory-card.gen { border-left-color: var(--gen); }

        .theory-card h4 {
            color: var(--accent);
            margin-bottom: var(--space-md);
            font-size: 1.1rem;
        }

        .example-box {
            background: var(--bg-card);
            padding: var(--space-md);
            border-radius: var(--radius-md);
            margin: var(--space-md) 0;
            display: flex;
            align-items: center;
            gap: var(--space-md);
            flex-wrap: wrap;
        }

        .example-box .german {
            font-weight: 600;
            color: var(--text-primary);
        }

        .example-box .english {
            color: var(--text-secondary);
            font-style: italic;
        }

        .example-box .divider {
            color: var(--text-secondary);
        }

        /* ============================================
           POSSESSIVE OVERVIEW GRID
           ============================================ */
        .possessive-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: var(--space-md);
            margin: var(--space-lg) 0;
        }

        .possessive-item {
            background: var(--bg-card);
            padding: var(--space-md);
            border-radius: var(--radius-md);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .possessive-item .pronoun {
            color: var(--text-secondary);
            font-size: 0.875rem;
        }

        .possessive-item .arrow {
            color: var(--accent);
        }

        .possessive-item .possessive {
            font-weight: 600;
            font-size: 1.1rem;
            color: var(--text-primary);
        }

        /* ============================================
           TABLES
           ============================================ */
        .table-container {
            overflow-x: auto;
            margin: var(--space-lg) 0;
            border-radius: var(--radius-lg);
            background: var(--bg-secondary);
        }

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.95rem;
        }

        th, td {
            padding: var(--space-md);
            text-align: left;
            border-bottom: 1px solid var(--bg-card);
        }

        th {
            background: var(--bg-card);
            font-weight: 600;
            color: var(--accent);
        }

        tr:hover {
            background: rgba(255,255,255,0.02);
        }

        .case-header {
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.05em;
        }

        .masc { color: var(--masc); }
        .fem { color: var(--fem); }
        .neut { color: var(--neut); }
        .plural { color: var(--plural); }

        .ending {
            font-weight: 700;
            font-size: 1.1rem;
        }

        /* ============================================
           ENDINGS TABLE
           ============================================ */
        .endings-table {
            margin: var(--space-xl) 0;
        }

        .endings-table th {
            text-align: center;
        }

        .endings-table td {
            text-align: center;
        }

        .endings-table .ending-cell {
            font-weight: 700;
            font-size: 1.2rem;
            padding: var(--space-md) var(--space-lg);
        }

        /* ============================================
           SPECIAL NOTE BOX
           ============================================ */
        .note-box {
            background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
            border: 1px solid var(--accent);
            border-radius: var(--radius-lg);
            padding: var(--space-lg);
            margin: var(--space-lg) 0;
        }

        .note-box h4 {
            color: var(--accent);
            margin-bottom: var(--space-sm);
            display: flex;
            align-items: center;
            gap: var(--space-sm);
        }

        /* ============================================
           EXERCISE STYLES
           ============================================ */
        .exercise {
            background: var(--bg-secondary);
            border-radius: var(--radius-lg);
            padding: var(--space-xl);
            margin-bottom: var(--space-xl);
        }

        .exercise-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: var(--space-lg);
            flex-wrap: wrap;
            gap: var(--space-sm);
        }

        .exercise-title {
            font-size: 1.25rem;
            color: var(--text-primary);
        }

        .exercise-badge {
            background: var(--bg-card);
            padding: var(--space-xs) var(--space-md);
            border-radius: var(--radius-md);
            font-size: 0.875rem;
            color: var(--text-secondary);
        }

        /* ============================================
           MATCHING EXERCISE
           ============================================ */
        .matching-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: var(--space-xl);
            margin: var(--space-lg) 0;
        }

        @media (max-width: 600px) {
            .matching-container {
                grid-template-columns: 1fr;
            }
        }

        .matching-column {
            display: flex;
            flex-direction: column;
            gap: var(--space-sm);
        }

        .matching-item {
            background: var(--bg-card);
            padding: var(--space-md);
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all 0.2s ease;
            border: 2px solid transparent;
            display: flex;
            align-items: center;
            gap: var(--space-sm);
        }

        .matching-item:hover {
            background: var(--bg-primary);
            border-color: var(--accent);
        }

        .matching-item.selected {
            border-color: var(--accent);
            background: rgba(245, 158, 11, 0.1);
        }

        .matching-item.matched {
            border-color: var(--success);
            background: rgba(34, 197, 94, 0.1);
            cursor: default;
        }

        .matching-item.wrong {
            border-color: var(--error);
            background: rgba(239, 68, 68, 0.1);
            animation: shake 0.3s ease;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            75% { transform: translateX(5px); }
        }

        /* ============================================
           FILL-IN BLANK EXERCISE
           ============================================ */
        .fill-item {
            background: var(--bg-card);
            padding: var(--space-lg);
            border-radius: var(--radius-md);
            margin-bottom: var(--space-md);
        }

        .fill-item .number {
            display: inline-block;
            background: var(--accent);
            color: white;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            text-align: center;
            line-height: 24px;
            font-size: 0.875rem;
            font-weight: 600;
            margin-right: var(--space-sm);
        }

        .fill-sentence {
            margin: var(--space-md) 0;
            font-size: 1.05rem;
            line-height: 2;
        }

        .blank-input {
            display: inline-block;
            width: 80px;
            padding: var(--space-xs) var(--space-sm);
            border: 2px solid var(--bg-card);
            border-radius: var(--radius-sm);
            background: var(--bg-primary);
            color: var(--text-primary);
            font-size: 1rem;
            text-align: center;
            transition: all 0.2s ease;
        }

        .blank-input:focus {
            outline: none;
            border-color: var(--accent);
        }

        .blank-input.correct {
            border-color: var(--success);
            background: rgba(34, 197, 94, 0.1);
        }

        .blank-input.incorrect {
            border-color: var(--error);
            background: rgba(239, 68, 68, 0.1);
        }

        .fill-feedback {
            margin-top: var(--space-sm);
            font-size: 0.9rem;
            min-height: 1.5em;
        }

        .fill-feedback.correct {
            color: var(--success);
        }

        .fill-feedback.incorrect {
            color: var(--error);
        }

        /* ============================================
           ACCUSATIVE EXERCISE
           ============================================ */
        .accusative-item {
            background: var(--bg-card);
            padding: var(--space-lg);
            border-radius: var(--radius-md);
            margin-bottom: var(--space-md);
            border-left: 3px solid var(--acc);
        }

        .accusative-item .prompt {
            display: flex;
            align-items: center;
            gap: var(--space-md);
            flex-wrap: wrap;
            margin-bottom: var(--space-md);
        }

        .accusative-item .person {
            font-weight: 600;
            color: var(--text-primary);
        }

        .accusative-item .object {
            background: var(--bg-secondary);
            padding: var(--space-xs) var(--space-sm);
            border-radius: var(--radius-sm);
            font-size: 0.875rem;
        }

        .accusative-item .gender {
            font-size: 0.75rem;
            text-transform: uppercase;
            padding: 2px 6px;
            border-radius: var(--radius-sm);
        }

        .accusative-item .gender.m { background: var(--masc); color: white; }
        .accusative-item .gender.f { background: var(--fem); color: white; }
        .accusative-item .gender.nt { background: var(--neut); color: white; }
        .accusative-item .gender.pl { background: var(--plural); color: white; }

        .accusative-input {
            width: 100%;
            padding: var(--space-md);
            border: 2px solid var(--bg-card);
            border-radius: var(--radius-md);
            background: var(--bg-primary);
            color: var(--text-primary);
            font-size: 1rem;
            transition: all 0.2s ease;
        }

        .accusative-input:focus {
            outline: none;
            border-color: var(--acc);
        }

        .accusative-input.correct {
            border-color: var(--success);
            background: rgba(34, 197, 94, 0.1);
        }

        .accusative-input.incorrect {
            border-color: var(--error);
            background: rgba(239, 68, 68, 0.1);
        }

        /* ============================================
           TRANSLATION EXERCISE
           ============================================ */
        .translation-item {
            background: var(--bg-card);
            padding: var(--space-lg);
            border-radius: var(--radius-md);
            margin-bottom: var(--space-md);
        }

        .translation-item .english-prompt {
            font-size: 1.1rem;
            margin-bottom: var(--space-md);
            color: var(--text-secondary);
        }

        .translation-item .english-prompt .number {
            color: var(--accent);
            font-weight: 600;
        }

        .translation-input {
            width: 100%;
            padding: var(--space-md);
            border: 2px solid var(--bg-card);
            border-radius: var(--radius-md);
            background: var(--bg-primary);
            color: var(--text-primary);
            font-size: 1rem;
            transition: all 0.2s ease;
        }

        .translation-input:focus {
            outline: none;
            border-color: var(--accent);
        }

        .translation-input.correct {
            border-color: var(--success);
            background: rgba(34, 197, 94, 0.1);
        }

        .translation-input.incorrect {
            border-color: var(--error);
            background: rgba(239, 68, 68, 0.1);
        }

        .translation-answer {
            margin-top: var(--space-sm);
            padding: var(--space-sm);
            background: var(--bg-secondary);
            border-radius: var(--radius-sm);
            font-size: 0.9rem;
            display: none;
        }

        .translation-answer.show {
            display: block;
        }

        /* ============================================
           BUTTONS
           ============================================ */
        .btn {
            display: inline-flex;
            align-items: center;
            gap: var(--space-sm);
            padding: var(--space-sm) var(--space-lg);
            border: none;
            border-radius: var(--radius-md);
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--accent), #d97706);
            color: white;
        }

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

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

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

        .btn-check {
            background: linear-gradient(135deg, var(--success), #16a34a);
            color: white;
        }

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

        .btn-audio {
            background: transparent;
            border: 1px solid var(--accent);
            color: var(--accent);
            padding: var(--space-xs) var(--space-sm);
            font-size: 0.875rem;
        }

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

        .exercise-actions {
            display: flex;
            gap: var(--space-md);
            margin-top: var(--space-lg);
            flex-wrap: wrap;
        }

        /* ============================================
           CHECKLIST
           ============================================ */
        .checklist {
            background: var(--bg-secondary);
            border-radius: var(--radius-lg);
            padding: var(--space-xl);
        }

        .checklist-item {
            display: flex;
            align-items: flex-start;
            gap: var(--space-md);
            padding: var(--space-md) 0;
            border-bottom: 1px solid var(--bg-card);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .checklist-item:last-child {
            border-bottom: none;
        }

        .checklist-item:hover {
            background: rgba(255,255,255,0.02);
            margin: 0 calc(-1 * var(--space-md));
            padding-left: var(--space-md);
            padding-right: var(--space-md);
            border-radius: var(--radius-md);
        }

        .checklist-checkbox {
            width: 24px;
            height: 24px;
            border: 2px solid var(--bg-card);
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.2s ease;
        }

        .checklist-item.checked .checklist-checkbox {
            background: var(--success);
            border-color: var(--success);
        }

        .checklist-item.checked .checklist-checkbox::after {
            content: '✓';
            color: white;
            font-weight: bold;
        }

        .checklist-text {
            flex: 1;
        }

        .checklist-answer {
            margin-top: var(--space-sm);
            padding: var(--space-sm);
            background: var(--bg-card);
            border-radius: var(--radius-sm);
            font-size: 0.9rem;
            display: none;
        }

        .checklist-item.checked .checklist-answer {
            display: block;
        }

        /* ============================================
           CONNECTIVITY SECTION
           ============================================ */
        .connectivity {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: var(--space-lg);
            margin-top: var(--space-2xl);
        }

        @media (max-width: 600px) {
            .connectivity {
                grid-template-columns: 1fr;
            }
        }

        .connectivity > div {
            background: var(--bg-secondary);
            padding: var(--space-lg);
            border-radius: var(--radius-lg);
        }

        .connectivity .from-prev {
            border-left: 3px solid var(--nom);
        }

        .connectivity .to-next {
            border-right: 3px solid var(--gen);
        }

        .connectivity h4 {
            margin-bottom: var(--space-sm);
            font-size: 1rem;
        }

        .connectivity p {
            color: var(--text-secondary);
            font-size: 0.95rem;
        }

        /* ============================================
           STREAK COUNTER
           ============================================ */
        .streak-counter {
            position: fixed;
            bottom: var(--space-lg);
            right: var(--space-lg);
            background: linear-gradient(135deg, var(--accent), #d97706);
            color: white;
            padding: var(--space-sm) var(--space-md);
            border-radius: var(--radius-lg);
            font-weight: 600;
            box-shadow: var(--shadow-lg);
            display: flex;
            align-items: center;
            gap: var(--space-sm);
            z-index: 50;
        }

        .streak-counter .flame {
            font-size: 1.25rem;
        }

        /* ============================================
           PROGRESS INDICATOR
           ============================================ */
        .progress-indicator {
            position: fixed;
            top: 0;
            left: 0;
            height: 3px;
            background: linear-gradient(90deg, var(--nom), var(--acc), var(--dat), var(--gen));
            transition: width 0.3s ease;
            z-index: 101;
        }

        /* ============================================
           SCORE DISPLAY
           ============================================ */
        .score-display {
            background: var(--bg-card);
            padding: var(--space-sm) var(--space-md);
            border-radius: var(--radius-md);
            font-size: 0.875rem;
            color: var(--text-secondary);
        }

        .score-display .score {
            color: var(--success);
            font-weight: 600;
        }

        /* ============================================
           HINT BOX
           ============================================ */
        .hint-box {
            background: rgba(59, 130, 246, 0.1);
            border: 1px solid var(--nom);
            border-radius: var(--radius-md);
            padding: var(--space-md);
            margin: var(--space-md) 0;
            font-size: 0.9rem;
        }

        .hint-box strong {
            color: var(--nom);
        }

        /* ============================================
           FOOTER
           ============================================ */
        footer {
            background: var(--bg-secondary);
            padding: var(--space-xl);
            text-align: center;
            color: var(--text-secondary);
            font-size: 0.875rem;
            margin-top: var(--space-2xl);
        }

        /* ============================================
           RESPONSIVE
           ============================================ */
        @media (max-width: 768px) {
            .container {
                padding: var(--space-md);
            }

            .hero {
                padding: var(--space-xl) var(--space-md);
            }

            .chapter-nav {
                padding: var(--space-sm) var(--space-md);
            }

            .exercise {
                padding: var(--space-md);
            }

            .blank-input {
                width: 60px;
            }
        }

        /* ============================================
           UTILITY CLASSES
           ============================================ */
        .text-center { text-align: center; }
        .mb-0 { margin-bottom: 0; }
        .mt-lg { margin-top: var(--space-lg); }
