:root {
    --bg: #0c0d14;
    --bg2: #11121a;
    --bg3: #181920;
    --card: #1c1d26;
    --card2: #22232e;
    --border: #2a2b38;
    --border2: #35364a;
    --primary: #5b8ee8;
    --primary-dark: #4878d4;
    --primary-glow: rgba(91,142,232,0.14);
    --secondary: #8b6ce0;
    --accent: #e0a030;
    --accent-glow: rgba(224,160,48,0.14);
    --text: #e2e2e6;
    --text-muted: #8888a0;
    --text-dim: #55555f;
    --success: #2e9e54;
    --success-glow: rgba(46,158,84,0.12);
    --danger: #c43b48;
    --danger-glow: rgba(196,59,72,0.12);
    --warning: #c8902a;
    --info: #4a80d4;
    --radius: 7px;
    --radius-sm: 5px;
    --shadow: 0 2px 10px rgba(0,0,0,0.35);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
    --font: 'Inter', sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

*, *::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;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    position: relative;
    isolation: isolate;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 15% 20%, rgba(91,142,232,0.07) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 85% 80%, rgba(139,108,224,0.06) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 60% 10%, rgba(224,160,48,0.04) 0%, transparent 50%);
    background-color: var(--bg);
    animation: bgShift 18s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0%   {
        background:
            radial-gradient(ellipse 80% 60% at 15% 20%, rgba(91,142,232,0.07) 0%, transparent 60%),
            radial-gradient(ellipse 60% 50% at 85% 80%, rgba(139,108,224,0.06) 0%, transparent 55%),
            radial-gradient(ellipse 50% 40% at 60% 10%, rgba(224,160,48,0.04) 0%, transparent 50%),
            var(--bg);
    }
    33%  {
        background:
            radial-gradient(ellipse 70% 55% at 70% 30%, rgba(91,142,232,0.08) 0%, transparent 60%),
            radial-gradient(ellipse 65% 45% at 20% 75%, rgba(139,108,224,0.06) 0%, transparent 55%),
            radial-gradient(ellipse 45% 50% at 80% 60%, rgba(224,160,48,0.05) 0%, transparent 50%),
            var(--bg);
    }
    66%  {
        background:
            radial-gradient(ellipse 75% 50% at 40% 70%, rgba(91,142,232,0.06) 0%, transparent 60%),
            radial-gradient(ellipse 55% 60% at 75% 15%, rgba(139,108,224,0.07) 0%, transparent 55%),
            radial-gradient(ellipse 60% 40% at 25% 45%, rgba(224,160,48,0.04) 0%, transparent 50%),
            var(--bg);
    }
    100% {
        background:
            radial-gradient(ellipse 80% 55% at 55% 85%, rgba(91,142,232,0.07) 0%, transparent 60%),
            radial-gradient(ellipse 60% 50% at 10% 35%, rgba(139,108,224,0.06) 0%, transparent 55%),
            radial-gradient(ellipse 50% 45% at 70% 50%, rgba(224,160,48,0.05) 0%, transparent 50%),
            var(--bg);
    }
}

/* ── NAVBAR ────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    letter-spacing: -0.3px;
}
.brand-dot { color: var(--primary); font-size: 1.5rem; line-height: 1; }
.brand-dash { color: var(--primary); font-size: 1rem; margin-right: 0.3rem; }
.brand-fr { color: var(--primary); margin-left: 1px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg3); }
.nav-callsign {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--primary);
    background: var(--bg3);
    border: 1px solid var(--border2);
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.04em;
}
.btn-nav-register {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 600 !important;
    padding: 0.4rem 1rem !important;
}
.btn-nav-register:hover { background: var(--primary-dark) !important; }
.btn-nav-logout { color: var(--danger) !important; }
.btn-nav-logout:hover { background: var(--danger-glow) !important; }

.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: 0.3s;
}

/* ── MAIN ────────────────────────────────────── */
.main-content { flex: 1; }

/* ── FOOTER ──────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 1.75rem 2rem;
    color: var(--text-dim);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}
.footer-morse { font-family: var(--mono); color: var(--text-dim); margin-top: 0.4rem; letter-spacing: 0.12em; }

/* ── HERO ────────────────────────────────────── */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5rem 2rem 4rem;
    min-height: 78vh;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.hero h1 {
    font-size: clamp(2rem, 5.5vw, 3.8rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    letter-spacing: -1px;
}
.hero h1 .highlight { color: var(--primary); }
.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 500px;
    margin-bottom: 2.5rem;
}
.hero-morse-preview {
    font-family: var(--mono);
    font-size: 1.8rem;
    color: var(--accent);
    letter-spacing: 0.25em;
    margin-bottom: 2.5rem;
    opacity: 0.85;
}
.hero-cta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}
.hero-features {
    display: flex;
    gap: 2.5rem;
    margin-top: 3.5rem;
    flex-wrap: wrap;
    justify-content: center;
}
.hero-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}
.hero-feature .icon { font-size: 1.75rem; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    border: none;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    background: var(--card2);
    color: var(--text);
    border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--bg3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b03040; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── CARDS ───────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 1rem; }

/* ── FORMS ───────────────────────────────────── */
.form-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 2rem;
}
.form-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.form-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
.form-box .form-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.92rem;
    padding: 0.65rem 0.9rem;
    transition: border-color 0.15s;
    outline: none;
}
.form-control:focus { border-color: var(--primary); }
.form-submit { width: 100%; margin-top: 1.4rem; justify-content: center; }
.form-link { text-align: center; margin-top: 1.4rem; color: var(--text-muted); font-size: 0.88rem; }
.form-link a { color: var(--primary); text-decoration: none; font-weight: 500; }
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 1.1rem;
    border: 1px solid;
}
.alert-error { background: var(--danger-glow); border-color: var(--danger); color: #e08888; }
.alert-success { background: var(--success-glow); border-color: var(--success); color: #7ecfa0; }
.callsign-reveal {
    font-family: var(--mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    padding: 1.25rem;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    margin: 1rem 0;
    letter-spacing: 0.12em;
}
.callsign-note { font-size: 0.8rem; color: var(--text-dim); text-align: center; margin-top: 0.5rem; }

/* ── DASHBOARD ──────────────────────────────── */
.dashboard-page { padding: 2rem; max-width: 1100px; margin: 0 auto; }
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.dashboard-header h1 { font-size: 1.6rem; font-weight: 700; }
.dashboard-header h1 span { color: var(--primary); font-family: var(--mono); }
.stats-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2.25rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.4rem;
    flex: 1;
    min-width: 130px;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

.lessons-section h2 { font-size: 0.75rem; font-weight: 600; margin-bottom: 1.25rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; }

.lesson-path {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}
.lesson-row {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}
.lesson-row:nth-child(odd) { flex-direction: row; }
.lesson-row:nth-child(even) { flex-direction: row-reverse; }

.lesson-bubbles {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s, background 0.2s;
    position: relative;
    border: 2px solid transparent;
    text-align: center;
    margin: 0 auto;
}
.bubble.locked {
    background: var(--bg3);
    border-color: var(--border);
    color: var(--text-dim);
    cursor: not-allowed;
    opacity: 0.45;
}
.bubble.available {
    background: var(--card2);
    border-color: var(--primary);
    color: var(--text);
}
.bubble.available:hover { transform: scale(1.06); }
.bubble.completed {
    background: var(--bg3);
    border-color: var(--success);
    color: var(--text);
}
.bubble.completed:hover { transform: scale(1.04); }
.bubble.defi {
    border-radius: 10px;
    width: 88px;
    height: 88px;
    background: var(--card2);
}
.bubble.defi.available { border-color: var(--accent); }
.bubble.defi.completed { border-color: var(--accent); }
.bubble-icon { font-size: 1.3rem; line-height: 1; }
.bubble-label { font-size: 0.62rem; font-weight: 600; margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.2; }
.bubble-score {
    position: absolute;
    bottom: -7px;
    background: var(--success);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.path-connector {
    width: 100%;
    height: 2px;
    background: var(--border);
    margin: 0.15rem 0;
}

/* ── LEARN PAGE ──────────────────────────────── */
.learn-page { max-width: 800px; margin: 0 auto; padding: 2rem; }
.learn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.learn-title { font-size: 1.4rem; font-weight: 700; }
.learn-subtitle { color: var(--text-muted); font-size: 0.88rem; }
.phase-indicator {
    display: flex;
    gap: 0.4rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem;
    margin-bottom: 1.75rem;
}
.phase-tab {
    flex: 1;
    text-align: center;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
    color: var(--text-muted);
}
.phase-tab.active { background: var(--primary); color: #fff; }
.phase-tab.done { background: var(--success-glow); color: var(--success); }

/* Morse correspondences table */
.morse-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    padding: 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.morse-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.65rem 0.4rem;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: border-color 0.15s;
}
.morse-item.new-char { border-color: var(--primary); background: var(--primary-glow); }
.morse-item .letter { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.morse-item .code { font-family: var(--mono); font-size: 1rem; color: var(--accent); margin-top: 0.25rem; letter-spacing: 0.1em; }

/* Progress bar */
.progress-bar-wrap {
    background: var(--bg3);
    border-radius: 3px;
    height: 6px;
    margin-bottom: 1.75rem;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.progress-label { text-align: right; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.35rem; }

/* Quiz area */
.quiz-area {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
}

/* Reception quiz — play button */
.play-btn {
    padding: .3rem .75rem;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
}
.play-btn:hover { background: var(--card2); color: var(--text); }
.play-btn.playing { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Auto-validation bar */
.auto-val-wrap { height: 4px; background: var(--border); border-radius: 2px; margin: .65rem auto; max-width: 300px; overflow: hidden; display: none; }
.auto-val-bar  { height: 100%; background: var(--accent); border-radius: 2px; width: 100%; transition: width linear; }

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    width: 100%;
    max-width: 340px;
}
.choice-btn {
    padding: 0.9rem;
    font-size: 1.7rem;
    font-weight: 700;
    background: var(--card2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: var(--font);
}
.choice-btn:hover { border-color: var(--primary); background: var(--primary-glow); }
.choice-btn.correct { border-color: var(--success); background: var(--success-glow); color: var(--success); }
.choice-btn.wrong { border-color: var(--danger); background: var(--danger-glow); color: var(--danger); }
.choice-btn:disabled { cursor: default; }

/* Sending quiz */
.send-target {
    font-size: 5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.send-target .target-morse { font-family: var(--mono); font-size: 1.4rem; color: var(--accent); margin-top: 0.25rem; }
.morse-input-display {
    font-family: var(--mono);
    font-size: 1.9rem;
    color: var(--accent);
    min-height: 3rem;
    letter-spacing: 0.15em;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.4rem;
    min-width: 200px;
}
.decoded-display {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-muted);
    font-family: var(--mono);
    min-height: 2.25rem;
}

/* Key area */
.key-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}
.key-type-toggle {
    display: flex;
    gap: 0.3rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}
.key-type-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: none;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.key-type-btn.active { background: var(--primary); color: #fff; }
.straight-key-btn {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--card2);
    border: 3px solid var(--border2);
    color: var(--text);
    font-size: 2.2rem;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
}
.straight-key-btn:active, .straight-key-btn.pressed {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: scale(0.94);
}
.paddle-keys {
    display: flex;
    gap: 1.4rem;
    align-items: center;
}
.paddle-btn {
    width: 96px;
    height: 114px;
    border-radius: var(--radius);
    border: 2px solid var(--border2);
    background: var(--card2);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, transform 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    user-select: none;
    -webkit-user-select: none;
}
.paddle-btn .paddle-symbol { font-size: 1.6rem; font-family: var(--mono); }
.paddle-btn .paddle-hint { font-size: 0.68rem; color: var(--text-dim); font-family: var(--mono); }
.paddle-btn:active, .paddle-btn.pressed {
    transform: scale(0.94);
    border-color: var(--primary);
    background: var(--bg3);
}
.paddle-btn.dash-btn:active, .paddle-btn.dash-btn.pressed {
    border-color: var(--accent);
}
.key-hint { font-size: 0.76rem; color: var(--text-dim); font-family: var(--mono); }

/* Feedback overlay */
.feedback-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5rem;
    border-radius: var(--radius);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
}
.feedback-overlay.show { opacity: 1; pointer-events: all; }
.feedback-overlay.correct { background: rgba(46,158,84,0.12); }
.feedback-overlay.wrong { background: rgba(196,59,72,0.12); }

/* Score screen */
.score-screen {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid;
    margin: 1rem auto;
}
.score-circle.pass { border-color: var(--success); background: var(--success-glow); color: var(--success); }
.score-circle.fail { border-color: var(--danger); background: var(--danger-glow); color: var(--danger); }
.score-circle .score-pct { font-size: 2rem; font-weight: 700; line-height: 1; }
.score-circle .score-sub { font-size: 0.72rem; opacity: 0.75; }
.defi-lives {
    display: flex;
    gap: 0.5rem;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}
.life { transition: opacity 0.3s, filter 0.3s; }
.life.lost { opacity: 0.18; filter: grayscale(1); }

/* ── TRAINING PAGE ───────────────────────────── */
.train-page { max-width: 900px; margin: 0 auto; padding: 2rem; }
.train-header { margin-bottom: 1.75rem; }
.train-header h1 { font-size: 1.6rem; font-weight: 700; }
.train-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem;
}
.train-tab {
    flex: 1;
    text-align: center;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    border: none;
    background: none;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.train-tab.active { background: var(--primary); color: #fff; }
.train-panel { display: none; }
.train-panel.active { display: block; }
.reception-display {
    text-align: center;
    padding: 2.5rem 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.reception-morse { font-family: var(--mono); font-size: 2.2rem; color: var(--accent); letter-spacing: 0.2em; margin: 1.25rem 0; min-height: 3.5rem; }
.reception-answer { font-size: 1rem; margin-bottom: 1rem; }
.reception-answer input {
    font-family: var(--mono);
    font-size: 1.4rem;
    text-align: center;
    text-transform: uppercase;
    width: 100px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.5rem;
    outline: none;
}
.reception-answer input:focus { border-color: var(--primary); }
.sending-display {
    text-align: center;
    padding: 1.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.char-select-area { margin-bottom: 1.25rem; }
.char-select-area label { font-size: 0.82rem; color: var(--text-muted); display: block; margin-bottom: 0.4rem; }
.char-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.char-chip {
    font-family: var(--mono);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    border: 1px solid var(--border);
    background: var(--bg3);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    color: var(--text-muted);
}
.char-chip.selected { border-color: var(--primary); background: var(--primary-glow); color: var(--primary); }
.speed-control { display: flex; align-items: center; gap: 1rem; font-size: 0.88rem; margin-bottom: 1rem; }
.speed-control input[type=range] { flex: 1; accent-color: var(--primary); }

/* ── CHAT PAGE ───────────────────────────────── */
.chat-page { display: flex; height: calc(100vh - 60px); }
.chat-sidebar {
    width: 210px;
    flex-shrink: 0;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
}
.chat-sidebar h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 0.65rem; }
.online-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.online-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
}
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.chat-msg { display: flex; flex-direction: column; gap: 0.2rem; max-width: 80%; }
.chat-msg.own { align-self: flex-end; align-items: flex-end; }
.msg-header { display: flex; align-items: center; gap: 0.45rem; font-size: 0.75rem; color: var(--text-dim); }
.msg-callsign { font-family: var(--mono); font-weight: 600; color: var(--primary); }
.msg-time { font-family: var(--mono); }
.msg-bubble {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px 8px 8px 3px;
    padding: 0.65rem 0.9rem;
    max-width: 100%;
}
.chat-msg.own .msg-bubble {
    background: var(--primary-glow);
    border-color: rgba(74,128,212,0.25);
    border-radius: 8px 8px 3px 8px;
}
.msg-text { font-size: 0.92rem; word-break: break-word; }
.msg-morse { font-family: var(--mono); font-size: 0.73rem; color: var(--accent); margin-top: 0.2rem; letter-spacing: 0.08em; opacity: 0.65; }

.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.9rem 1.4rem;
    background: var(--bg2);
}
.chat-input-modes {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}
.mode-btn {
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mode-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.chat-text-input { display: flex; gap: 0.65rem; align-items: flex-end; }
.chat-text-input textarea {
    flex: 1;
    resize: none;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.92rem;
    padding: 0.65rem 0.9rem;
    outline: none;
    min-height: 42px;
    max-height: 120px;
    transition: border-color 0.15s;
}
.chat-text-input textarea:focus { border-color: var(--primary); }

.chat-morse-input { display: flex; flex-direction: column; gap: 0.65rem; }
.morse-compose-display {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-family: var(--mono);
    min-height: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.compose-decoded { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.compose-morse { font-size: 0.72rem; color: var(--accent); letter-spacing: 0.1em; }
.chat-key-row { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }
.chat-key-row .key-type-toggle { margin: 0; }

/* ── CHAT MORSE COMPOSE (chat.php inline styles) ── */
.chat-morse-compose {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem .9rem;
    margin-bottom: .55rem;
    min-height: 2.75rem;
}
.compose-display {
    font-family: var(--mono);
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: .1em;
    min-height: 1.4rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .15rem;
}
.compose-cursor { animation: blink 1s step-end infinite; color: var(--text-dim); }
@keyframes blink { 50% { opacity: 0; } }
.compose-morse-live { letter-spacing: .1em; }
.compose-transcription {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-top: .15rem;
    letter-spacing: .04em;
    min-height: 1rem;
}
.msg-morse-main {
    font-family: var(--mono);
    font-size: .92rem;
    letter-spacing: .09em;
    color: var(--accent);
    word-break: break-all;
}
.msg-transcription {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .25rem;
    font-style: italic;
}

/* ── SETTINGS FAB ───────────────────────────── */
.settings-fab {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--card2); border: 1px solid var(--border2);
    color: var(--text-muted); font-size: 1.1rem; cursor: pointer;
    z-index: 300; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
.settings-fab:hover { border-color: var(--primary); color: var(--primary); }
.settings-panel {
    position: fixed; bottom: 5rem; right: 1.5rem;
    background: var(--card); border: 1px solid var(--border2);
    border-radius: var(--radius); padding: 1.1rem 1.35rem;
    width: 272px; z-index: 299; box-shadow: var(--shadow-lg);
}
.settings-panel-title { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .9rem; }
.settings-row { margin-bottom: .8rem; }
.settings-row label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-muted); margin-bottom: .25rem; }
.settings-val { color: var(--primary); font-family: var(--mono); }
.settings-row input[type=range] { width: 100%; accent-color: var(--primary); }

/* ── UTILITIES ──────────────────────────────── */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.mono { font-family: var(--mono); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .flex-wrap { flex-wrap: wrap; }
.section-title { font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); font-weight: 600; margin-bottom: 1rem; }
.w-full { width: 100%; }
.start-btn-area { text-align: center; padding: 2rem; }

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .nav-links { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg2); border-bottom: 1px solid var(--border); padding: 1rem; gap: 0.2rem; }
    .nav-links.open { display: flex; }
    .nav-links a, .nav-callsign { width: 100%; }
    .nav-hamburger { display: flex; }
    .lesson-bubbles { grid-template-columns: repeat(3, 1fr); }
    .bubble { width: 72px; height: 72px; }
    .chat-page { flex-direction: column; height: auto; min-height: calc(100vh - 60px); }
    .chat-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .choices-grid { grid-template-columns: repeat(2, 1fr); }
    .send-target { font-size: 3.8rem; }
}
@media (max-width: 480px) {
    .lesson-bubbles { grid-template-columns: repeat(2, 1fr); }
    .form-box { padding: 1.4rem; }
}
