/* === SprachlernApp — CSS === */

:root {
    --green-dark: #1B5E20;
    --green: #2E7D32;
    --green-light: #4CAF50;
    --green-pale: #81C784;
    --amber: #FF8F00;
    --amber-light: #FFB74D;
    --red: #D32F2F;
    --bg: #FAFAFA;
    --white: #FFFFFF;
    --gray-50: #F5F5F5;
    --gray-100: #EEEEEE;
    --gray-200: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-600: #757575;
    --gray-800: #424242;
    --text: #212121;
    --text-light: #757575;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* === Loading / Overlays === */
.loading-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--white); gap: 1rem;
}
.loading-overlay[hidden] { display: none; }
.loading-spinner {
    width: 40px; height: 40px; border: 4px solid var(--gray-200);
    border-top-color: var(--green); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.server-error-icon { font-size: 3rem; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; border: none; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 600; transition: all 0.2s;
}
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--gray-100); color: var(--text); }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-warning.active { background: var(--green); }
.header-actions { display: flex; gap: 0.5rem; }
.btn-full { width: 100%; }
.btn-large { padding: 1rem; font-size: 1.1rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-link { background: none; border: none; color: var(--green); font-size: 0.9rem; padding: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.75rem; border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm); outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--green); }
.form-error { color: var(--red); font-size: 0.85rem; padding: 0.5rem 0; }
.form-error[hidden] { display: none; }
.form-success { color: var(--green); font-size: 0.85rem; padding: 0.5rem 0; }
.form-success[hidden] { display: none; }

/* === Auth Page (index.html) === */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-container { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-logo { width: 60px; height: 60px; margin-bottom: 0.5rem; }
.auth-brand h1 { font-size: 1.8rem; }
.accent { color: var(--green); }
.auth-tagline { color: var(--text-light); font-size: 0.95rem; }
.auth-card { background: var(--white); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.auth-tabs { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--gray-100); }
.auth-tab {
    flex: 1; padding: 0.75rem; background: none; border: none;
    font-size: 1rem; font-weight: 600; color: var(--gray-400);
    border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.auth-tab.active { color: var(--green); border-bottom-color: var(--green); }
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-footer { text-align: center; color: var(--text-light); font-size: 0.8rem; margin-top: 1.5rem; }
.recovery-title { margin-bottom: 0.5rem; }
.recovery-desc { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: var(--white); border-radius: var(--radius); padding: 2rem; max-width: 420px; width: 100%; text-align: center; }
.modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.modal-warning { background: #FFF3E0; border-radius: var(--radius-sm); padding: 1rem; margin: 1rem 0; font-size: 0.9rem; text-align: left; }
.recovery-codes-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 1rem 0; font-family: monospace; font-size: 1.1rem; }

/* === App Layout (app.html) === */
.app-header {
    position: sticky; top: 0; z-index: 100; background: var(--white);
    border-bottom: 1px solid var(--gray-200); box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.header-inner { display: flex; align-items: center; padding: 0.5rem 1rem; max-width: 800px; margin: 0 auto; }
.header-brand { display: flex; align-items: center; gap: 0.5rem; }
.header-logo { width: 28px; height: 28px; }
.header-title { font-size: 1.1rem; font-weight: 700; }
.header-nav { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    background: none; border: none; padding: 0.4rem 0.75rem; border-radius: var(--radius-sm);
    color: var(--gray-400); font-size: 0.7rem; transition: all 0.2s;
}
.nav-btn.active { color: var(--green); background: rgba(76,175,80,0.1); }
.nav-icon { font-size: 1.2rem; }
.nav-label { font-weight: 600; }
.header-logout { background: none; border: none; padding: 0.4rem; margin-left: 0.5rem; font-size: 1.2rem; }

.app-main { max-width: 800px; margin: 0 auto; }
.app-section { display: none; animation: fade-in 0.3s; }
.app-section.active { display: block; }
.section-inner { padding: 1.5rem 1rem; }
.section-title { font-size: 1.3rem; margin-bottom: 1rem; }

/* === Home === */
.greeting { font-size: 1.5rem; margin-bottom: 1rem; }
.language-pair-card {
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    background: var(--white); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
    box-shadow: var(--shadow); position: relative;
}
.lp-native, .lp-target { font-size: 1.2rem; font-weight: 700; }
.lp-arrow { color: var(--green); font-size: 1.5rem; }
.cefr-badge {
    background: var(--green); color: white; padding: 0.2rem 0.6rem;
    border-radius: 1rem; font-size: 0.75rem; font-weight: 700;
}
.cefr-badge-large { font-size: 1.2rem; padding: 0.4rem 1rem; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--white); border-radius: var(--radius); padding: 1rem;
    text-align: center; box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--green-dark); }
.stat-label { font-size: 0.75rem; color: var(--text-light); }

/* === Conversation === */
.conversation-container { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.conversation-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100);
}
.conv-title { font-weight: 700; }
.conv-pair-chooser { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; max-width: 24rem; }
.conv-pair-label { font-size: 0.7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; }
.conv-pair-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-100);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: #fff;
    max-width: 100%;
}
.conv-pair-select:disabled { opacity: 0.7; cursor: not-allowed; }
.conv-subtitle { padding: 0.5rem 1rem; color: var(--text-light); font-size: 0.85rem; border-bottom: 1px solid var(--gray-100); }

.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-empty { text-align: center; margin: auto; color: var(--text-light); }
.chat-empty-icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* === Plasma Ball (v3 — real lightning bolts) === */
.voice-orb-container { display: flex; flex-direction: column; align-items: center; margin: auto; gap: 1.25rem; }
.voice-orb {
    width: 240px; height: 240px; border-radius: 50%;
    position: relative; display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 14px 40px rgba(80, 140, 220, 0.45));
}

/* Outer diffuse glow — cool cyan/blue galactic haze */
.orb-glow {
    position: absolute; inset: -50px; border-radius: 50%;
    background: radial-gradient(circle,
        rgba(120, 220, 255, 0.35) 0%,
        rgba(80, 140, 240, 0.22) 30%,
        rgba(220, 100, 180, 0.12) 55%,
        rgba(30, 30, 90, 0.08) 70%,
        transparent 85%);
    animation: plasma-glow 4.5s ease-in-out infinite;
    pointer-events: none;
    filter: blur(6px);
}

/* The galactic gas cloud — deep blue with cyan core and magenta filaments */
.orb-sphere {
    width: 100%; height: 100%; border-radius: 50%;
    position: relative;
    overflow: hidden;
    background:
        /* bright cyan-white hot centre */
        radial-gradient(circle at 50% 50%,
            rgba(230, 250, 255, 0.9) 0%,
            rgba(140, 220, 255, 0.7) 10%,
            rgba(70, 140, 230, 0.6) 22%,
            transparent 40%),
        /* warm magenta/pink gas swirl offset from centre */
        radial-gradient(ellipse 70% 55% at 62% 40%,
            rgba(255, 130, 200, 0.45) 0%,
            rgba(200, 80, 160, 0.28) 35%,
            transparent 65%),
        /* cold blue outer cloud */
        radial-gradient(circle at 50% 55%,
            rgba(40, 70, 160, 0.85) 0%,
            rgba(20, 30, 90, 0.95) 45%,
            rgba(6, 8, 28, 1) 90%);
    box-shadow:
        inset 0 -14px 40px rgba(0,0,0,0.8),
        inset 0 0 70px rgba(0,0,0,0.55),
        0 0 90px rgba(90, 160, 240, 0.5);
    transition: box-shadow 0.3s;
}

/* Bright energetic centre — pulsar-like white-cyan */
.orb-core {
    position: absolute;
    width: 22%; height: 22%;
    left: 39%; top: 39%;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255,255,255,1) 0%,
        rgba(200, 245, 255, 0.9) 25%,
        rgba(120, 200, 255, 0.6) 50%,
        rgba(80, 140, 230, 0.3) 75%,
        transparent 100%);
    filter: blur(3px);
    animation: plasma-core 2.4s ease-in-out infinite;
    box-shadow:
        0 0 30px rgba(180, 230, 255, 0.85),
        0 0 60px rgba(100, 180, 240, 0.5);
    pointer-events: none;
}

/* SVG with lightning bolts — each one flickers on and off with a stagger */
.orb-bolts {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    mix-blend-mode: screen;
}
.orb-bolt {
    opacity: 0;
    animation: plasma-flicker 3s ease-in-out infinite;
    will-change: opacity;
}
.orb-bolt path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.orb-bolt-main {
    stroke: rgba(230, 250, 255, 1);
    stroke-width: 1.6;
    filter: drop-shadow(0 0 3px rgba(190, 230, 255, 0.95)) drop-shadow(0 0 7px rgba(100, 170, 250, 0.8));
}
.orb-bolt-branch {
    stroke: rgba(200, 230, 255, 0.9);
    stroke-width: 1.1;
    filter: drop-shadow(0 0 2px rgba(170, 210, 255, 0.85)) drop-shadow(0 0 5px rgba(80, 150, 240, 0.6));
}
.orb-bolt-twig {
    stroke: rgba(190, 210, 255, 0.75);
    stroke-width: 0.7;
    filter: drop-shadow(0 0 1.5px rgba(160, 200, 250, 0.8));
}

/* Subtle glass reflection highlight */
.orb-highlight {
    position: absolute;
    top: 10%; left: 18%;
    width: 32%; height: 24%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 40% 35%,
        rgba(255,255,255,0.28) 0%,
        rgba(255,255,255,0.08) 40%,
        transparent 70%);
    pointer-events: none;
    filter: blur(2px);
}

.orb-status {
    font-size: 0.95rem; color: var(--text, #222); font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── State overrides ───────────────────────────────────────── */

/* Listening: orange/red plasma */
.orb-listening .orb-sphere {
    background: radial-gradient(circle at 50% 55%,
        rgba(255, 170, 80, 0.45) 0%,
        rgba(180, 60, 20, 0.85) 28%,
        rgba(60, 15, 5, 0.95) 60%,
        rgba(15, 4, 2, 1) 100%);
    box-shadow:
        inset 0 -14px 40px rgba(0,0,0,0.8),
        inset 0 0 70px rgba(0,0,0,0.55),
        0 0 100px rgba(255, 140, 60, 0.6);
}
.orb-listening .orb-core {
    background: radial-gradient(circle,
        rgba(255,255,255,1) 0%,
        rgba(255, 220, 180, 0.85) 30%,
        rgba(255, 130, 50, 0.55) 55%,
        transparent 80%);
    box-shadow: 0 0 30px rgba(255, 180, 90, 0.9);
    animation-duration: 1s;
}
.orb-listening .orb-bolt { animation-duration: 1.6s; }
.orb-listening .orb-bolt-main {
    stroke: rgba(255, 230, 180, 1);
    filter: drop-shadow(0 0 3px rgba(255, 210, 140, 0.95)) drop-shadow(0 0 7px rgba(255, 120, 40, 0.8));
}
.orb-listening .orb-bolt-branch {
    stroke: rgba(255, 200, 150, 0.85);
    filter: drop-shadow(0 0 2px rgba(255, 190, 120, 0.85)) drop-shadow(0 0 5px rgba(255, 100, 30, 0.6));
}
.orb-listening .orb-bolt-twig {
    stroke: rgba(255, 180, 120, 0.7);
    filter: drop-shadow(0 0 1.5px rgba(255, 170, 100, 0.8));
}
.orb-listening .orb-glow {
    background: radial-gradient(circle,
        rgba(255, 180, 80, 0.45) 0%,
        rgba(255, 120, 40, 0.2) 40%,
        transparent 80%);
}

/* Processing: bolts flicker fast */
.orb-processing .orb-bolt { animation-duration: 1.2s; }
.orb-processing .orb-core { animation-duration: 0.8s; }

/* Speaking: plasma goes wild */
.orb-speaking .orb-sphere {
    box-shadow:
        inset 0 -14px 40px rgba(0,0,0,0.8),
        inset 0 0 70px rgba(0,0,0,0.55),
        0 0 130px rgba(180, 120, 255, 0.8);
    animation: plasma-speak 0.4s ease-in-out infinite alternate;
}
.orb-speaking .orb-bolt { animation-duration: 0.7s; stroke-width: 2; }
.orb-speaking .orb-core { animation-duration: 0.5s; }
.orb-speaking .orb-glow { animation-duration: 0.6s; }

/* ── Animations ────────────────────────────────────────────── */

@keyframes plasma-core {
    0%, 100% { transform: scale(1);    opacity: 0.9; }
    50%      { transform: scale(1.22); opacity: 1;   }
}
@keyframes plasma-glow {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.1); }
}
@keyframes plasma-speak {
    from { transform: scale(1.01); }
    to   { transform: scale(1.04); }
}
/* Bolt flicker — smooth ramp in, sustain, ramp out. No transform jumps. */
@keyframes plasma-flicker {
    0%   { opacity: 0;    }
    6%   { opacity: 0.95; }
    12%  { opacity: 0.55; }
    18%  { opacity: 0.85; }
    28%  { opacity: 0.3;  }
    40%  { opacity: 0;    }
    100% { opacity: 0;    }
}

/* Message Bubbles */
.chat-bubble { max-width: 80%; padding: 0.75rem 1rem; border-radius: var(--radius); animation: msg-slide-in 0.3s; }
.chat-bubble.user { align-self: flex-end; background: var(--green); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.ai { align-self: flex-start; background: var(--white); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }

.correction-card {
    align-self: flex-start; max-width: 80%; background: #FFF8E1; border-left: 3px solid var(--amber);
    padding: 0.5rem 0.75rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem; animation: msg-slide-in 0.3s;
}
.correction-label { font-weight: 700; color: var(--amber); font-size: 0.75rem; margin-bottom: 0.25rem; }

.vocab-hints { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.vocab-tag {
    background: rgba(76,175,80,0.1); color: var(--green-dark); padding: 0.15rem 0.5rem;
    border-radius: 1rem; font-size: 0.75rem;
}

/* Typing Indicator */
.typing-indicator { padding: 0.5rem 1rem; }
.typing-indicator[hidden] { display: none; }
.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dots span {
    width: 8px; height: 8px; background: var(--gray-400); border-radius: 50%;
    animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Chat Input */
.chat-input-bar {
    display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--gray-100); background: var(--white);
}
.chat-input-bar[hidden] { display: none; }
.chat-input {
    flex: 1; resize: none; padding: 0.75rem; border: 2px solid var(--gray-200); min-height: 48px;
    border-radius: var(--radius-sm); outline: none; max-height: 100px;
}
.chat-input:focus { border-color: var(--green); }
.chat-send-btn { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 1.2rem; }

/* Toggle Switch */
.toggle-container { display: flex; align-items: center; gap: 0.75rem; margin: 1rem auto; }
.toggle-switch {
    position: relative; width: 56px; height: 30px; background: var(--gray-200);
    border-radius: 15px; border: none; transition: background 0.3s; flex-shrink: 0;
}
.toggle-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
    background: white; border-radius: 50%; transition: transform 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.active { background: var(--green); }
.toggle-switch.active::after { transform: translateX(26px); }
.toggle-label { font-size: 0.85rem; color: var(--text-light); }

/* Topic Swiper */
.topic-swiper {
    display: flex; gap: 0.5rem; overflow-x: auto;
    padding: 0.75rem 1rem;
    margin: 0.5rem 1rem 1.5rem 1rem;
    border: 1px solid var(--gray-100);
    border-radius: 1.25rem;
    background: #fff;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}
.topic-swiper::-webkit-scrollbar { display: none; }
.topic-chip {
    flex-shrink: 0; padding: 0.5rem 1rem; border-radius: 2rem;
    background: var(--gray-100); border: 2px solid transparent;
    font-size: 0.85rem; font-weight: 500; white-space: nowrap; transition: all 0.2s;
    cursor: pointer;
}
.topic-chip:hover { background: #eceff1; }
.topic-chip.active { background: rgba(76,175,80,0.15); border-color: var(--green); color: var(--green-dark); }

/* Home — Language Pair Tiles */
.pair-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}
.pair-tile {
    background: var(--white, #fff);
    border: 1px solid var(--gray-100);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-height: 200px;
}
.pair-tile-header {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.pair-direction {
    display: flex; align-items: center; gap: 0.4rem;
    font-weight: 600; font-size: 0.95rem;
    flex-wrap: wrap;
}
.pair-flag { font-size: 1.1rem; }
.pair-arrow { color: var(--text-light); margin: 0 0.2rem; }
.pair-stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem;
}
.pair-stat {
    text-align: center;
    background: var(--gray-100, #f4f5f7);
    border-radius: 0.6rem;
    padding: 0.5rem 0.25rem;
}
.pair-stat-icon { font-size: 1.1rem; }
.pair-stat-value { font-size: 1.1rem; font-weight: 700; margin-top: 0.1rem; }
.pair-stat-label { font-size: 0.7rem; color: var(--text-light); }
.pair-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: auto; }
.pair-actions .btn { flex: 1; }
.pair-delete { color: var(--text-light); padding: 0.4rem 0.5rem; }
.pair-delete:hover { color: var(--red); }

.pair-tile-add {
    border: 2px dashed var(--gray-100);
    background: transparent;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.5rem;
    min-height: 200px;
    color: var(--text-light);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pair-tile-add:hover { border-color: var(--green); color: var(--green-dark); background: rgba(76,175,80,0.05); }
.pair-add-plus { font-size: 2.5rem; font-weight: 300; line-height: 1; }
.pair-add-label { font-size: 0.9rem; }

.modal-subtitle { color: var(--text-light); margin-bottom: 1rem; font-size: 0.9rem; }
.section-subtitle-muted { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1rem; }
.section-subtitle-muted a { color: var(--green); }
.progress-pair-list { display: flex; flex-direction: column; gap: 1rem; }
.progress-pair-card { background: var(--white, #fff); border: 1px solid var(--gray-100); border-radius: 1rem; padding: 1.25rem; box-shadow: var(--shadow); }
.progress-pair-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.progress-pair-title { font-weight: 700; font-size: 1.05rem; }
.progress-pair-title .pair-arrow { color: var(--text-light); margin: 0 0.3rem; }

/* Curriculum details */
.curriculum-details { margin-top: 1rem; border-top: 1px solid var(--gray-100); padding-top: 0.75rem; }
.curriculum-details summary {
    list-style: none; cursor: pointer;
    font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.25rem 0;
}
.curriculum-details summary::-webkit-details-marker { display: none; }
.curriculum-details[open] summary .settings-card-chevron { transform: rotate(180deg); }

.topic-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.35rem; }
.topic-item { background: var(--gray-100, #f4f5f7); border-radius: 0.6rem; padding: 0.5rem 0.75rem; transition: background 0.15s; }
.topic-item:hover { background: #eceff1; }
.topic-item-done { background: rgba(76,175,80,0.12); }
.topic-item-done .topic-title { text-decoration: line-through; color: var(--text-light); }
.topic-label { display: flex; align-items: flex-start; gap: 0.6rem; cursor: pointer; }
.topic-check { margin-top: 0.2rem; accent-color: var(--green, #4caf50); width: 16px; height: 16px; flex-shrink: 0; }
.topic-body { display: flex; flex-direction: column; gap: 0.15rem; }
.topic-title { font-weight: 500; }
.topic-skills { font-size: 0.78rem; color: var(--text-light); }
.topic-stats-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.topic-stat { font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 1rem; background: #eceff1; color: var(--text, #222); }
.topic-stat-time { background: #e3f2fd; color: #1565c0; }
.topic-stat-error-ok { background: rgba(76,175,80,0.15); color: var(--green-dark, #2e7d32); }
.topic-stat-error-bad { background: rgba(244,67,54,0.12); color: #c62828; }
.topic-blocked { font-size: 0.75rem; color: #b26a00; margin-top: 0.25rem; display: block; }
.topic-ready { font-size: 0.75rem; color: var(--green-dark, #2e7d32); margin-top: 0.25rem; display: block; font-weight: 600; }
.topic-item-locked .topic-label { cursor: not-allowed; }
.topic-item-locked { opacity: 0.92; }

/* Skills (Hören / Sprechen / Lesen / Schreiben) */
.skills-wrap { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--gray-100); }
.skills-heading { font-size: 0.9rem; font-weight: 700; margin: 0 0 0.5rem; }
.skill-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.skill-row-primary .skill-label { font-weight: 600; }
.skill-label { display: flex; align-items: center; gap: 0.4rem; min-width: 9rem; font-size: 0.9rem; }
.skill-icon { font-size: 1rem; }
.skill-primary-flag { color: var(--amber, #ff9800); margin-left: 0.2rem; font-size: 0.8rem; }
.skill-bar-wrap { flex: 1; display: flex; align-items: center; gap: 0.6rem; }
.skill-bar-track { flex: 1; height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.skill-bar-fill { height: 100%; border-radius: 4px; transition: width 0.25s; }
.skill-bar-fill.skill-good { background: linear-gradient(90deg, #66bb6a, var(--green, #4caf50)); }
.skill-bar-fill.skill-mid  { background: linear-gradient(90deg, #ffd54f, #ffb300); }
.skill-bar-fill.skill-weak { background: linear-gradient(90deg, #ef9a9a, #e53935); }
.skill-bar-number { min-width: 4.5rem; text-align: right; font-size: 0.8rem; color: var(--text-light); }

.topic-chip-done { background: rgba(76,175,80,0.2) !important; color: var(--green-dark, #2e7d32) !important; }
.topic-swiper-empty { color: var(--text-light); font-size: 0.85rem; padding: 0.25rem 0.75rem; }

.summary-suggestion {
    background: rgba(76,175,80,0.08);
    border: 1px solid rgba(76,175,80,0.25);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.summary-suggestion p { margin: 0 0 0.5rem; }
.summary-suggestion .btn + .btn { margin-top: 0.5rem; }

.exam-banner {
    padding: 0.8rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    line-height: 1.4;
}
.exam-banner strong { font-size: 0.95rem; }
.exam-banner-ready  { background: rgba(76,175,80,0.1); border: 1px solid rgba(76,175,80,0.35); color: var(--green-dark, #2e7d32); }
.exam-banner-retry  { background: rgba(244,67,54,0.08); border: 1px solid rgba(244,67,54,0.3); color: #c62828; }
.exam-banner-hint   { background: rgba(33,150,243,0.08); border: 1px solid rgba(33,150,243,0.3); color: #0d47a1; }
.exam-banner .btn { align-self: flex-start; }
.empty-state { color: var(--text-light); text-align: center; padding: 2rem 1rem; }
.progress-loading { color: var(--text-light); text-align: center; padding: 1rem; }
.settings-hint { color: var(--text-light); font-size: 0.85rem; margin: 0.5rem 0 1rem; }
.settings-hint-small { color: var(--text-light); font-size: 0.78rem; margin: 0.15rem 0 0; }
.settings-toggle-block { margin: 0.75rem 0 1rem; }
.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.settings-toggle-label { font-weight: 600; margin: 0; }
.settings-checkbox { width: 20px; height: 20px; flex-shrink: 0; margin-top: 0.15rem; accent-color: var(--green, #4caf50); }
.form-hint { color: var(--text-light); font-size: 0.8rem; margin-top: 0.25rem; }
.lang-btn small { opacity: 0.7; font-weight: 400; }

/* Collapsible settings cards */
.settings-card-collapsible { padding: 0; }
.settings-card-summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600;
}
.settings-card-summary::-webkit-details-marker { display: none; }
.settings-card-chevron { transition: transform 0.2s; font-size: 1rem; }
.settings-card-collapsible[open] .settings-card-chevron { transform: rotate(180deg); }
.settings-card-body { padding: 0.25rem 1.25rem 1.25rem; }
.settings-card-collapsible[open] .settings-card-summary { border-bottom: 1px solid var(--gray-100); margin-bottom: 0.5rem; }

/* Footer with legal links (visible on every page) */
.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light);
    border-top: 1px solid var(--gray-100);
    background: transparent;
}
.app-footer a { color: var(--text-light); text-decoration: none; }
.app-footer a:hover { color: var(--green); text-decoration: underline; }
.footer-sep { margin: 0 0.5rem; opacity: 0.5; }

/* Legal page */
.legal-main { padding: 2rem 1rem; }
.legal-container { max-width: 780px; margin: 0 auto; background: var(--white, #fff); padding: 2rem; border-radius: 1rem; box-shadow: var(--shadow); }
.legal-nav { display: flex; gap: 0.5rem; margin: 1rem 0 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--gray-100); }
.legal-nav-link { padding: 0.5rem 1rem; background: var(--gray-100); border-radius: 2rem; font-size: 0.9rem; color: var(--text); text-decoration: none; }
.legal-nav-link:hover { background: rgba(76,175,80,0.15); color: var(--green-dark); }
.legal-section { margin-top: 2.5rem; scroll-margin-top: 1rem; }
.legal-section h1 { margin-bottom: 0.5rem; }
.legal-section h2 { margin-top: 1.5rem; margin-bottom: 0.5rem; font-size: 1.05rem; }
.legal-section p, .legal-section li { line-height: 1.6; }
.legal-placeholder { background: #fff8e1; border: 1px solid #ffe082; color: #795548; padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.9rem; }

.goodbye-container { text-align: center; }
.goodbye-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.goodbye-container h1 { margin-bottom: 1rem; }
.goodbye-container p { line-height: 1.6; margin-bottom: 1rem; color: var(--text-light); }
.goodbye-container .btn { margin-top: 1rem; display: inline-block; }
.form-label { display: block; margin: 0.75rem 0 0.35rem; font-weight: 600; font-size: 0.85rem; color: var(--text-light); }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.modal-actions .btn { flex: 1; }

/* Clickable words + tooltip */
.clickable-word {
    cursor: pointer;
    border-bottom: 1px dotted rgba(76,175,80,0.4);
    transition: background 0.15s;
}
.clickable-word:hover { background: rgba(76,175,80,0.15); border-radius: 3px; }
.word-tooltip {
    position: absolute;
    z-index: 9999;
    background: var(--text, #222);
    color: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    max-width: 240px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    pointer-events: auto;
    line-height: 1.35;
}

/* === Progress === */
.progress-level-card {
    background: var(--white); border-radius: var(--radius); padding: 1.5rem;
    box-shadow: var(--shadow); margin-bottom: 1rem;
}
.progress-level-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.progress-level-label { font-weight: 600; }
.progress-bar-container { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.5s; }
.progress-bar-label { font-size: 0.8rem; color: var(--text-light); margin-top: 0.3rem; }

/* === Settings === */
.settings-card { background: var(--white); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.settings-card-title { font-size: 1rem; margin-bottom: 1rem; }
.settings-card-danger { border: 2px solid #FFCDD2; }
.settings-info { color: var(--text-light); margin-bottom: 1rem; }

/* === Onboarding === */
.onboarding-overlay {
    position: fixed; inset: 0; z-index: 800; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.onboarding-overlay[hidden] { display: none; }
.onboarding-card { background: var(--white); border-radius: var(--radius); padding: 2rem; max-width: 440px; width: 100%; }
.onboarding-steps { display: flex; justify-content: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.onboarding-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray-200); transition: background 0.3s; }
.onboarding-dot.active { background: var(--green); }
.onboarding-step { display: none; }
.onboarding-step.active { display: block; }
.onboarding-step h2 { margin-bottom: 0.5rem; }
.onboarding-step p { color: var(--text-light); margin-bottom: 1rem; }

.language-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.lang-btn {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
    background: var(--white); font-size: 1rem; transition: all 0.2s;
}
.lang-btn.selected { border-color: var(--green); background: rgba(76,175,80,0.05); }
.lang-btn.disabled { opacity: 0.3; pointer-events: none; }
.lang-flag { font-size: 1.5rem; }

.cefr-grid { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.cefr-btn {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
    background: var(--white); text-align: left; transition: all 0.2s;
}
.cefr-btn.selected { border-color: var(--green); background: rgba(76,175,80,0.05); }
.cefr-level { font-weight: 700; font-size: 1.1rem; color: var(--green-dark); min-width: 2rem; }
.cefr-desc { font-size: 0.85rem; color: var(--text-light); }

/* === Summary Stats === */
.summary-stats { display: flex; justify-content: center; gap: 2rem; margin: 1.5rem 0; }
.summary-stat { text-align: center; }
.summary-stat-value { display: block; font-size: 2rem; font-weight: 700; color: var(--green-dark); }
.summary-stat-label { font-size: 0.85rem; color: var(--text-light); }

/* === Animations === */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes msg-slide-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* === Chat Options Bar === */
.chat-options-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 1rem; border-top: 1px solid var(--gray-100); background: var(--gray-50);
}
.chat-options-bar[hidden] { display: none; }
.text-input-row { display: flex; gap: 0.5rem; width: 100%; }
.explanation-lang-select {
    padding: 0.3rem 0.5rem; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 0.8rem; background: var(--white);
}

/* === Language History (Progress) === */
.section-subtitle { font-size: 1rem; margin: 1.5rem 0 0.75rem; color: var(--gray-600); }
.language-history { display: flex; flex-direction: column; gap: 0.5rem; }
.lang-history-card {
    display: flex; align-items: center; gap: 1rem; padding: 1rem;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.lang-history-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lang-history-flag { font-size: 2rem; }
.lang-history-info { flex: 1; }
.lang-history-name { font-weight: 700; font-size: 1rem; }
.lang-history-meta { font-size: 0.8rem; color: var(--text-light); }
.lang-history-badge { flex-shrink: 0; }

.modal-card-wide { max-width: 500px; }
.lang-detail-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.lang-detail-stat { text-align: center; }
.lang-detail-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--green-dark); }
.lang-detail-label { font-size: 0.75rem; color: var(--text-light); }

.lang-detail-timeline { margin: 1rem 0; padding-left: 1.5rem; border-left: 3px solid var(--green-pale); }
.timeline-item { position: relative; padding: 0.5rem 0 0.5rem 1rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.65rem; top: 0.75rem;
    width: 12px; height: 12px; border-radius: 50%; background: var(--green);
}
.timeline-item.future::before { background: var(--gray-200); }
.timeline-level { font-weight: 700; }
.timeline-date { font-size: 0.8rem; color: var(--text-light); }

/* === Mobile (bottom nav) === */
@media (max-width: 767px) {
    .app-header .header-inner { flex-wrap: wrap; }
    .header-nav {
        order: 3; width: 100%; position: fixed; bottom: 0; left: 0;
        background: var(--white); border-top: 1px solid var(--gray-200);
        justify-content: space-around; padding: 0.25rem 0; z-index: 100;
    }
    /* Leave room for the fixed bottom nav — otherwise the footer hides behind it */
    .app-main { padding-bottom: 0; }
    .app-footer { margin-bottom: 60px; padding: 1rem; font-size: 0.75rem; }
    .conversation-container { height: calc(100vh - 56px - 56px); }
    .voice-orb { width: 180px; height: 180px; }
}

@media (min-width: 768px) {
    .voice-orb { width: 220px; height: 220px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
