/* ═══════════════════════════════════════════════════════════════
   CW SDR — Morse Code Practice Platform
   Skeuomorphic Radio Transceiver Design
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    /* Chassis */
    --chassis-bg: #1a1a1a;
    --chassis-border: #2a2a2a;
    --chassis-highlight: #333;
    --chassis-shadow: #0a0a0a;

    /* Screen/Panel */
    --screen-bg: #060b14;
    --screen-surface: #0a1020;
    --screen-border: #1a2535;

    /* Accent Colors */
    --accent: #00ff88;
    --accent-dim: #00cc6a;
    --accent-glow: rgba(0, 255, 136, 0.4);
    --signal-orange: #ff6b35;
    --tx-red: #ff4444;
    --rx-green: #00ff88;
    --warning-yellow: #ffcc00;

    /* Text */
    --text-primary: #e5e7eb;
    --text-muted: #6b7280;
    --text-dim: #4a5568;

    /* Knob */
    --knob-size: 56px;

    /* Fonts */
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-ui: 'Inter', -apple-system, sans-serif;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    background: #0a0a0a;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════════ */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #060b14;
    z-index: 1000;
}

/* Animated radio wave background */
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.wave {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 136, 0.08);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: wave-pulse 4s ease-out infinite;
}

.wave1 { width: 400px; height: 400px; animation-delay: 0s; }
.wave2 { width: 600px; height: 600px; animation-delay: 1s; }
.wave3 { width: 800px; height: 800px; animation-delay: 2s; }

@keyframes wave-pulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.login-card {
    position: relative;
    z-index: 1;
    background: rgba(13, 20, 32, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 255, 136, 0.05);
}

.login-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.login-card h1 {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.login-domain {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    margin-bottom: 32px;
}

.login-label {
    display: block;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(6, 11, 20, 0.8);
    border: 1px solid #1e2a3a;
    border-radius: 8px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.login-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.2);
}

.login-input.error {
    border-color: var(--tx-red);
    animation: shake 0.3s ease;
}

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

.login-btn {
    width: 100%;
    padding: 14px 24px;
    margin-top: 16px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(0, 255, 136, 0.05));
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.login-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.25), rgba(0, 255, 136, 0.1));
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(1px);
}

.btn-icon {
    margin-right: 8px;
}

.login-info {
    margin-top: 24px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════
   FREQUENCY TOOLTIP
   ═══════════════════════════════════════════════════════════════ */
.freq-tooltip {
    display: none;
    position: fixed;
    top: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--screen-border);
    pointer-events: none;
    z-index: 500;
    transform: translateX(-50%);
}

/* ═══════════════════════════════════════════════════════════════
   RADIO CHASSIS
   ═══════════════════════════════════════════════════════════════ */
.radio-chassis {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    margin: 0 auto;
    background: var(--chassis-bg);
    background-image:
        linear-gradient(180deg, #222 0%, #1a1a1a 3%, #1a1a1a 97%, #111 100%),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255,255,255,0.01) 2px, rgba(255,255,255,0.01) 4px);
    border: 1px solid var(--chassis-border);
    border-top: 2px solid #444;
    border-bottom: 2px solid #111;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ── Header ────────────────────────────────────────────────── */
.radio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: linear-gradient(180deg, #252525, #1e1e1e);
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}

.header-version {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header-callsign {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--warning-yellow);
    background: rgba(255, 204, 0, 0.08);
    padding: 2px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 204, 0, 0.2);
}

/* ── Band Selector ─────────────────────────────────────────── */
.band-selector {
    display: flex;
    gap: 3px;
}

.band-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    background: #252525;
    color: var(--text-muted);
    border: 1px solid #333;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}

.band-btn:hover {
    background: #2d2d2d;
    color: var(--text-primary);
}

.band-btn.active {
    background: linear-gradient(180deg, #1a3a2a, #0d2618);
    color: var(--accent);
    border-color: rgba(0, 255, 136, 0.3);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.15), inset 0 1px 0 rgba(0, 255, 136, 0.1);
    text-shadow: 0 0 6px var(--accent-glow);
}

.band-btn:active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    transform: translateY(1px);
}

/* ── Main Body ─────────────────────────────────────────────── */
.radio-body {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}

/* Left Panel (S-Meter + VFO) */
.left-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a2a;
    background: linear-gradient(180deg, #181818, #151515);
}

.panel-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 6px 10px 2px;
}

/* S-Meter */
.smeter-panel {
    padding: 8px;
    border-bottom: 1px solid #222;
}

.smeter-panel canvas {
    width: 100%;
    height: 50px;
    background: #0a0a0a;
    border-radius: 4px;
    border: 1px solid #222;
}

.smeter-scale {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-dim);
    padding: 2px 4px 0;
}

/* VFO Panel */
.vfo-panel {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: ns-resize;
}

.vfo-indicators {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.led-indicator {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: var(--text-dim);
    transition: all 0.15s;
}

.led-indicator.rx-led.on {
    color: var(--rx-green);
    background: rgba(0, 255, 136, 0.1);
    border-color: rgba(0, 255, 136, 0.3);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.led-indicator.tx-led.on {
    color: var(--tx-red);
    background: rgba(255, 68, 68, 0.15);
    border-color: rgba(255, 68, 68, 0.4);
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.4);
    animation: tx-blink 0.3s infinite alternate;
}

@keyframes tx-blink {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

.vfo-frequency {
    display: flex;
    align-items: baseline;
    gap: 1px;
    user-select: none;
}

.vfo-digit {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 2rem;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow), 0 0 30px rgba(0, 255, 136, 0.2);
    letter-spacing: 0.05em;
    transition: text-shadow 0.1s;
}

.vfo-dot {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--accent-dim);
    margin: 0 1px;
}

.vfo-unit {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 6px;
    align-self: center;
}

.vfo-step {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.step-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 3px 8px;
    background: #252525;
    color: var(--text-muted);
    border: 1px solid #333;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.step-btn:hover {
    background: #2d2d2d;
    color: var(--text-primary);
}

.step-btn:active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.step-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--signal-orange);
    min-width: 60px;
    text-align: center;
}

/* Tune ◄ ► Buttons (large, touch-friendly) */
.vfo-tune-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

.tune-btn {
    font-size: 1.1rem;
    padding: 8px 14px;
    background: linear-gradient(180deg, #2a2a2a, #1e1e1e);
    color: var(--accent);
    border: 1px solid rgba(0, 255, 136, 0.25);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
    user-select: none;
    -webkit-user-select: none;
    /* Large touch target */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tune-btn:hover {
    background: linear-gradient(180deg, #1a3a2a, #0d2618);
    border-color: rgba(0, 255, 136, 0.5);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

.tune-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.tune-label {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    flex: 1;
    text-align: center;
}

/* ── Display Panel (Spectrum + Waterfall) ──────────────────── */
.display-panel {
    flex: 1;
    position: relative;
    background: var(--screen-bg);
    border: 1px solid #1a2030;
    overflow: hidden;
}

.display-panel canvas {
    display: block;
    width: 100%;
}

#waterfall-bookmarks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.waterfall-bookmark {
    position: absolute;
    top: 2px;
    padding: 2px 6px;
    background: #0f0;
    color: #000;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 4px;
    pointer-events: auto;
    cursor: pointer;
    transform: translateX(-50%);
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    user-select: none;
    white-space: nowrap;
    transition: filter 0.2s;
}

.waterfall-bookmark::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px 4px 0;
    border-style: solid;
    border-color: inherit;
    /* color will be inherited from the background color via JS or specific CSS if needed, but for now we use a small triangle. Actually, let's just make it green or inherit the border-top-color in JS */
}

.waterfall-bookmark:hover {
    filter: brightness(1.2);
}

#spectrum-canvas {
    height: 80px;
    border-bottom: 1px solid #1a2535;
}

#waterfall-canvas {
    height: calc(100% - 80px);
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 10;
}

/* ═══════════════════════════════════════════════════════════════
   CONTROL PANEL
   ═══════════════════════════════════════════════════════════════ */
.control-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #1e1e1e, #1a1a1a);
    border-top: 1px solid #2a2a2a;
    flex-shrink: 0;
}

/* ── Knobs ──────────────────────────────────────────────────── */
.knobs-row {
    display: flex;
    gap: 16px;
}

.knob-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.knob-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.knob {
    width: var(--knob-size);
    height: var(--knob-size);
    border-radius: 50%;
    background: conic-gradient(from 0deg, #555, #888, #666, #444, #777, #555);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 2px 3px rgba(255, 255, 255, 0.12),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: grab;
    transition: box-shadow 0.15s;
    user-select: none;
}

.knob:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.6),
        0 0 8px rgba(0, 255, 136, 0.1),
        inset 0 2px 3px rgba(255, 255, 255, 0.15),
        inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

.knob:active {
    cursor: grabbing;
}

.knob::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, #555, #333);
    transform: translate(-50%, -50%);
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.1);
}

.knob-indicator {
    position: absolute;
    top: 6px;
    left: 50%;
    width: 2px;
    height: 10px;
    background: #fff;
    border-radius: 1px;
    transform-origin: bottom center;
    transform: translateX(-50%);
    box-shadow: 0 0 4px rgba(255,255,255,0.5);
}

.knob-value {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--signal-orange);
    text-align: center;
}

/* ── CW Key ────────────────────────────────────────────────── */
.key-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0 12px;
}

.tx-led-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tx-led-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #331111;
    border: 1px solid #442222;
    transition: all 0.1s;
}

.tx-led-dot.on {
    background: var(--tx-red);
    border-color: #ff6666;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.6), 0 0 24px rgba(255, 68, 68, 0.3);
}

.tx-led-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-dim);
}

.cw-key-btn {
    width: 120px;
    height: 48px;
    background: linear-gradient(180deg, #333, #252525);
    border: 2px solid #444;
    border-bottom: 3px solid #222;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.05s;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
    user-select: none;
    -webkit-user-select: none;
}

.cw-key-btn:hover {
    background: linear-gradient(180deg, #3a3a3a, #2d2d2d);
}

.cw-key-btn.active {
    background: linear-gradient(180deg, #2a1515, #331a1a);
    border-color: var(--tx-red);
    color: var(--tx-red);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.3), inset 0 2px 4px rgba(0,0,0,0.4);
    transform: translateY(2px);
    border-bottom-width: 1px;
}

.key-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

.key-hint {
    font-size: 0.55rem;
    color: var(--text-dim);
}

/* ── Mini Decoder ──────────────────────────────────────────── */
.mini-decoder {
    flex: 1;
    min-width: 200px;
    background: var(--screen-bg);
    border: 1px solid var(--screen-border);
    border-radius: 4px;
    overflow: hidden;
}

.mini-decoder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--screen-border);
}

.decoder-lang-select {
    display: flex;
    gap: 2px;
}

.decoder-lang-btn {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    padding: 2px 8px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid #1a2535;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s;
}

.decoder-lang-btn.active {
    color: var(--accent);
    background: rgba(0, 255, 136, 0.08);
    border-color: rgba(0, 255, 136, 0.3);
}

.mini-decoder-output {
    padding: 6px 8px;
    height: 60px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    line-height: 1.4;
}

.decode-placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.mini-decode-line {
    margin-bottom: 2px;
}

.decode-callsign {
    color: var(--warning-yellow);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════════════════════════ */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: #111;
    border-top: 1px solid #222;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
}

.status-label {
    color: var(--text-dim);
    white-space: nowrap;
}

.online-users-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.online-user {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 1px 6px;
    border-radius: 3px;
    transition: background 0.15s;
}

.online-user:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.user-callsign {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--warning-yellow);
    font-size: 0.7rem;
}

.user-freq {
    font-family: var(--font-mono);
    color: var(--text-dim);
    font-size: 0.6rem;
}

.user-band {
    font-family: var(--font-mono);
    color: var(--accent-dim);
    font-size: 0.55rem;
}

.status-right {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   FULL DECODER PANEL (below radio)
   ═══════════════════════════════════════════════════════════════ */
.decoder-panel {
    height: 200px;
    background: var(--screen-bg);
    border: 1px solid var(--screen-border);
    border-top: none;
    display: flex;
    flex-direction: column;
}

.decoder-panel.collapsed {
    height: 32px;
    overflow: hidden;
}

.decoder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: linear-gradient(180deg, #111825, #0d1420);
    border-bottom: 1px solid var(--screen-border);
    flex-shrink: 0;
}

.decoder-toggle-btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
}

.decoder-toggle-btn:hover {
    text-shadow: 0 0 8px var(--accent-glow);
}

.decoder-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.decoder-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.decoder-checkbox input {
    accent-color: var(--accent);
}

.decoder-clear-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 3px 10px;
    background: rgba(255, 68, 68, 0.1);
    color: var(--tx-red);
    border: 1px solid rgba(255, 68, 68, 0.2);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.decoder-clear-btn:hover {
    background: rgba(255, 68, 68, 0.2);
}

.decoder-output {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    line-height: 1.5;
}

.decode-block {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.decode-header {
    color: var(--warning-yellow);
    font-weight: 700;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.decode-text {
    color: var(--accent);
    word-break: break-all;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* Mobile backdrop */
.chat-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900;
}
.chat-backdrop.show { display: block; }

/* Floating toggle button */
.chat-float-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d2618, #1a3a2a);
    border: 1px solid rgba(0, 255, 136, 0.4);
    color: var(--accent);
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 12px rgba(0, 255, 136, 0.15);
    z-index: 950;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5), 0 0 20px rgba(0, 255, 136, 0.25);
}
.chat-float-btn.pulse {
    animation: chat-pulse 1s ease;
}
@keyframes chat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6); }
    70%  { box-shadow: 0 0 0 12px rgba(0, 255, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); }
}

/* Unread badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--tx-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #0a0a0a;
}

/* Slide-in panel (desktop: right side) */
.chat-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100vh;
    background: #0a0e17;
    border-left: 1px solid var(--screen-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.chat-panel.open {
    right: 0;
}

/* Chat header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(180deg, #111825, #0d1420);
    border-bottom: 1px solid var(--screen-border);
    flex-shrink: 0;
}
.chat-title {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
}
.chat-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s;
}
.chat-close-btn:hover { color: var(--tx-red); }

/* Message list */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-welcome {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 16px;
}

/* Message bubbles */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}
.chat-msg-self {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg-other {
    align-self: flex-start;
    align-items: flex-start;
}
.chat-callsign {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--warning-yellow);
    margin-bottom: 2px;
    padding-left: 4px;
}
.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}
.chat-msg-self .chat-bubble {
    background: linear-gradient(135deg, #0d2618, #1a3a2a);
    border: 1px solid rgba(0, 255, 136, 0.2);
    color: var(--accent);
    border-bottom-right-radius: 3px;
}
.chat-msg-other .chat-bubble {
    background: #141e30;
    border: 1px solid #1e2a3a;
    color: var(--text-primary);
    border-bottom-left-radius: 3px;
}
.chat-time {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
    padding: 0 4px;
}

/* Input row */
.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--screen-border);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    background: rgba(6, 11, 20, 0.8);
    border: 1px solid var(--screen-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input:focus {
    border-color: rgba(0, 255, 136, 0.4);
}
.chat-send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #0d2618, #1a3a2a);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.chat-send-btn:hover {
    background: linear-gradient(135deg, #1a3a2a, #0d4a28);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.2);
}

/* ── Mobile: Bottom Sheet ──────────────────────────────────── */
@media (max-width: 768px) {
    .chat-panel {
        top: auto;
        bottom: -80vh;
        right: 0;
        left: 0;
        width: 100%;
        height: 80vh;
        border-left: none;
        border-top: 1px solid var(--screen-border);
        border-radius: 16px 16px 0 0;
        transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
    }
    .chat-panel.open {
        right: 0;
        bottom: 0;
    }
    /* Removed .chat-float-btn mobile override since it's now absolute inside waterfall */
    
    /* Fix header overflowing on mobile */
    .radio-header {
        flex-wrap: wrap;
        padding: 6px 8px;
    }
    .header-center {
        order: 3;
        width: 100%;
        margin-top: 8px;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 4px;
    }
    .band-selector {
        width: max-content;
    }
    .header-right {
        gap: 8px;
    }
    .header-settings-btn {
        margin-left: 4px;
    }
    .header-logo {
        font-size: 0.85rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS MODAL
   ═══════════════════════════════════════════════════════════════ */
.header-settings-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 16px;
    transition: transform 0.2s, color 0.2s;
}
.header-settings-btn:hover {
    color: var(--accent);
    transform: rotate(45deg);
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 1050;
}
.modal-backdrop.show { display: block; }

.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: #0d1420;
    border: 1px solid var(--screen-border);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 0 1px rgba(0, 255, 136, 0.2);
    display: flex;
    flex-direction: column;
}
.settings-modal.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(180deg, #111825, #0a0e17);
    border-bottom: 1px solid var(--screen-border);
    border-radius: 8px 8px 0 0;
}
.settings-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}
.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}
.modal-close-btn:hover { color: var(--tx-red); }

.settings-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 70vh;
}
.settings-section {
    margin-bottom: 24px;
}
.settings-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid #1e2a3a;
    padding-bottom: 6px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.settings-row label {
    font-size: 0.85rem;
    color: var(--text-dim);
}
.settings-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: -4px;
    margin-bottom: 12px;
    line-height: 1.4;
}
.settings-value {
    font-family: var(--font-mono);
    color: var(--accent);
    min-width: 30px;
    text-align: right;
    font-size: 0.9rem;
}

/* Range Slider */
.wpm-slider {
    flex: 1;
    margin: 0 16px;
    appearance: none;
    height: 4px;
    background: #1e2a3a;
    border-radius: 2px;
    outline: none;
}
.wpm-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

/* Keybind Button */
.keybind-btn {
    background: #141e30;
    border: 1px solid #2a3b52;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 100px;
    transition: all 0.2s;
}
.keybind-btn:hover {
    border-color: rgba(0, 255, 136, 0.4);
}
.keybind-btn.waiting {
    background: rgba(255, 107, 53, 0.2);
    border-color: var(--signal-orange);
    color: var(--signal-orange);
    animation: blink 1s infinite;
}
@keyframes blink {
    50% { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR STYLING
   ═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0e17;
}

::-webkit-scrollbar-thumb {
    background: #2a3545;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a4555;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .left-panel {
        width: 180px;
    }
    .vfo-digit {
        font-size: 1.5rem;
    }
    .knobs-row {
        gap: 10px;
    }
    .knob {
        --knob-size: 46px;
        width: var(--knob-size);
        height: var(--knob-size);
    }
}

@media (max-width: 768px) {
    .radio-chassis {
        height: auto;
        min-height: auto;
    }
    .radio-body {
        flex-direction: column;
    }
    .left-panel {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid #2a2a2a;
    }
    .smeter-panel {
        flex: 1;
    }
    .vfo-panel {
        flex: 1;
    }
    .display-panel {
        height: 120px;
        flex: none;
    }
    .control-panel {
        flex-wrap: wrap;
    }
    .band-btn {
        font-size: 0.6rem;
        padding: 3px 5px;
    }
}
