/* ═══════════════════════════════════════════════════════════════════════════
   V4 COMPONENTS — Reusable tool components (below-fold, async-loaded)
   Contains: Visualizer, Volume, WPM, Options, Presets, Reference Chart,
             Tap Input, Buttons, Decoder, Settings, Flash, Toast
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   SIGNAL VISUALIZER
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-visualizer {
    margin-bottom: var(--v4-space-6);
    background: var(--v4-bg-elevated);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
    overflow: hidden;
}

.v4-visualizer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--v4-space-3) var(--v4-space-4);
    background: var(--v4-bg-surface);
    border-bottom: 1px solid var(--v4-border-dim);
}

.v4-visualizer-title {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    color: var(--v4-text-secondary);
}

.v4-scope-icon {
    width: 8px;
    height: 8px;
    background: var(--v4-accent-green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--v4-accent-green);
}

.v4-visualizer-controls {
    display: flex;
    gap: var(--v4-space-1);
}

.v4-viz-btn {
    padding: var(--v4-space-1) var(--v4-space-3);
    color: var(--v4-text-muted);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 500;
    letter-spacing: var(--v4-tracking-wide);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-viz-btn:hover {
    color: var(--v4-text-secondary);
}

.v4-viz-btn.active {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
    border-color: var(--v4-border-dim);
}

/* Collapse Button (P1: Collapsible visualizer) */
.v4-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: var(--v4-space-2);
    padding: 0;
    color: var(--v4-text-muted);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-collapse-btn:hover {
    color: var(--v4-primary);
    border-color: var(--v4-border-base);
}

.v4-collapse-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.v4-collapsible.collapsed .v4-collapse-btn svg {
    transform: rotate(180deg);
}

/* Collapsible body */
.v4-visualizer-body {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 200px;
}

.v4-collapsible.collapsed .v4-visualizer-body {
    max-height: 0;
    opacity: 0;
}

.v4-collapsible.collapsed .v4-visualizer-header {
    border-bottom-color: transparent;
}

.v4-visualizer-screen {
    position: relative;
    height: 150px;
    background: var(--v4-bg-darkest);
    overflow: hidden;
}

.v4-screen-glow {
    position: absolute;
    inset: 0;
    background: var(--v4-screen-glow);
    pointer-events: none;
}

.v4-screen-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        var(--v4-scanline-color) 2px,
        var(--v4-scanline-color) 4px
    );
    pointer-events: none;
    opacity: 0.5;
}

.v4-screen-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(var(--v4-border-dim) 1px, transparent 1px),
        linear-gradient(90deg, var(--v4-border-dim) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0.3;
}

.v4-visualizer-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.v4-signal-display {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--v4-space-4);
}

.v4-signal-display.active {
    display: flex;
}

.v4-signal-dots {
    display: flex;
    flex-wrap: wrap;
    gap: var(--v4-space-2);
    justify-content: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
   VOLUME - Compact, inline with player
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-media-volume {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
}

.v4-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    border-radius: var(--v4-radius-full);
    outline: none;
    cursor: pointer;
    /* Filled track effect using gradient - JS updates --volume-fill */
    --volume-fill: 80%;
    background: linear-gradient(
        to right,
        var(--v4-primary) 0%,
        var(--v4-primary) var(--volume-fill),
        var(--v4-bg-surface) var(--volume-fill),
        var(--v4-bg-surface) 100%
    );
}

/* Firefox needs separate track styling */
.v4-volume-slider::-moz-range-track {
    height: 6px;
    border-radius: var(--v4-radius-full);
    background: var(--v4-bg-surface);
}

.v4-volume-slider::-moz-range-progress {
    height: 6px;
    border-radius: var(--v4-radius-full);
    background: var(--v4-primary);
}

.v4-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--v4-primary);
    border: 2px solid var(--v4-bg-elevated);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.v4-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.v4-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--v4-primary);
    border: 2px solid var(--v4-bg-elevated);
    border-radius: 50%;
    cursor: pointer;
}


/* ═══════════════════════════════════════════════════════════════════════════
   WPM CONTROL - Prominent, HAM Radio Operator need
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-media-wpm {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--v4-space-1);
    padding: var(--v4-space-2) var(--v4-space-3);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
}

.v4-wpm-down,
.v4-wpm-up {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--v4-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
}

.v4-wpm-down:hover,
.v4-wpm-up:hover {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
}

.v4-wpm-display {
    min-width: 2.5ch;  /* Stable width for 2-digit numbers (5-50) */
    font-family: var(--v4-font-display);
    font-size: var(--v4-text-xl);
    font-weight: 700;
    color: var(--v4-primary);
    text-align: center;
    line-height: 1;
}

.v4-wpm-label {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-wide);
    color: var(--v4-text-muted);
    text-transform: uppercase;
}

/* P2: Quick WPM Presets - Labeled speed buttons */
.v4-wpm-presets {
    display: flex;
    gap: var(--v4-space-1);
    padding: var(--v4-space-1);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
}

.v4-wpm-preset {
    padding: var(--v4-space-1) var(--v4-space-2);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 500;
    color: var(--v4-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.v4-wpm-preset:hover {
    color: var(--v4-text-primary);
    background: var(--v4-bg-elevated);
}

.v4-wpm-preset.active {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
    border-color: var(--v4-primary-dim);
}

.hidden { display: none !important; }


/* ═══════════════════════════════════════════════════════════════════════════
   OPTIONS BAR - Two-tier hierarchy: Output Mode (primary) + Actions (secondary)
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-options-bar {
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-3);
    margin-bottom: var(--v4-space-4);
    padding: var(--v4-space-3);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRIMARY ROW: Output Mode Toggle (Sound / Flash / Vibrate)
   ───────────────────────────────────────────────────────────────────────────── */
.v4-output-row {
    display: flex;
    justify-content: center;
    width: 100%;
}

.v4-output-toggle {
    display: inline-flex;
    gap: var(--v4-space-1);
    padding: var(--v4-space-1);
    background: var(--v4-bg-base);
    border-radius: var(--v4-radius-md);
}

.v4-toggle-btn {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    padding: var(--v4-space-2) var(--v4-space-4);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 500;
    color: var(--v4-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-toggle-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.v4-toggle-btn:hover {
    color: var(--v4-text-secondary);
    background: var(--v4-bg-surface);
}

.v4-toggle-btn.active {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
    box-shadow: inset 0 0 0 1px var(--v4-primary-dim);
}

/* ─────────────────────────────────────────────────────────────────────────────
   SECONDARY ROW: Actions (Export buttons left, Settings right)
   ───────────────────────────────────────────────────────────────────────────── */
.v4-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--v4-space-3);
    border-top: 1px solid var(--v4-border-dim);
}

.v4-export-group {
    display: flex;
    gap: var(--v4-space-2);
}

/* Override for export action buttons - need icon + text */
.v4-export-group .v4-action-btn {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    width: auto;
    height: auto;
    padding: var(--v4-space-2) var(--v4-space-3);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 500;
    color: var(--v4-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-export-group .v4-action-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.v4-export-group .v4-action-btn:hover {
    color: var(--v4-text-primary);
    background: var(--v4-bg-elevated);
    border-color: var(--v4-border-dim);
}

.v4-export-group .v4-action-btn:active {
    transform: scale(0.96);
}

/* Settings button - icon + text, matches action buttons */
.v4-settings-btn {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    padding: var(--v4-space-2) var(--v4-space-3);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 500;
    color: var(--v4-text-muted);
    background: var(--v4-bg-base);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-settings-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.v4-settings-btn:hover {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
    border-color: var(--v4-primary);
}
}

/* Remove pulse after user has opened settings */
.v4-settings-btn.visited::after {
    display: none;
}

/* Old control panel - deprecated */
.v4-control-panel { display: none; }
.v4-output-modes, .v4-volume-controls, .v4-volume-slider-wrap { display: none; }
.v4-output-btn, .v4-export-btn { display: none; }


/* ═══════════════════════════════════════════════════════════════════════════
   PRESETS
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-presets {
    margin-bottom: var(--v4-space-6);
    padding: var(--v4-space-4);
    background: var(--v4-bg-elevated);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
}

.v4-presets-label {
    margin-bottom: var(--v4-space-3);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    color: var(--v4-text-muted);
}

.v4-presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--v4-space-2);
}

.v4-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--v4-space-1);
    padding: var(--v4-space-3);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.v4-preset-btn:hover {
    border-color: var(--v4-border-base);
}

/* SOS Emergency Styling - Red highlight, same size as others */
.v4-preset-btn.v4-preset-sos {
    border: 2px solid #dc2626;
    background: rgba(220, 38, 38, 0.08);
}

.v4-preset-btn.v4-preset-sos:hover {
    background: rgba(220, 38, 38, 0.15);
    border-color: #ef4444;
}

.v4-preset-btn.v4-preset-sos .v4-preset-name {
    color: #dc2626;
}

.v4-preset-btn.v4-preset-sos .v4-preset-morse {
    color: #dc2626;
    opacity: 0.8;
}

.v4-preset-name {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 600;
    color: var(--v4-text-primary);
}

.v4-preset-morse {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    color: var(--v4-primary);
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}


/* ═══════════════════════════════════════════════════════════════════════════
   REFERENCE CHART
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-reference {
    background: var(--v4-bg-elevated);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
    overflow: hidden;
}

.v4-reference-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--v4-space-3);
    padding: var(--v4-space-3) var(--v4-space-4);
    background: var(--v4-bg-surface);
    border-bottom: 1px solid var(--v4-border-dim);
}

.v4-reference-title {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    color: var(--v4-text-secondary);
}

.v4-ref-icon {
    width: 8px;
    height: 8px;
    background: var(--v4-primary);
    border-radius: 50%;
    box-shadow: var(--v4-glow-text);
}

.v4-reference-tabs {
    display: flex;
    gap: var(--v4-space-1);
}

.v4-ref-tab {
    padding: var(--v4-space-1) var(--v4-space-3);
    color: var(--v4-text-muted);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 500;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--v4-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-ref-tab:hover {
    color: var(--v4-text-secondary);
}

.v4-ref-tab.active {
    color: var(--v4-primary);
    background: var(--v4-primary-subtle);
    border-color: var(--v4-border-dim);
}

.v4-reference-body {
    padding: var(--v4-space-4);
}

.v4-ref-content {
    display: none;
}

.v4-ref-content.active {
    display: block;
}

.v4-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--v4-space-2);
}

.v4-ref-grid.v4-ref-prosigns {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.v4-ref-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--v4-space-2);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-ref-item:hover {
    border-color: var(--v4-border-base);
    background: var(--v4-primary-subtle);
}

.v4-ref-char {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-lg);
    font-weight: 700;
    color: var(--v4-text-primary);
}

.v4-ref-morse {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 500;
    color: var(--v4-primary);
    text-shadow: var(--v4-glow-text);
}

.v4-ref-desc {
    margin-top: var(--v4-space-1);
    font-size: var(--v4-text-xs);
    color: var(--v4-text-muted);
}

.v4-prosign.v4-prosign-sos {
    border-color: var(--v4-accent-red);
    background: rgba(255, 51, 51, 0.05);
}

.v4-prosign.v4-prosign-sos:hover {
    background: rgba(255, 51, 51, 0.1);
}


/* ═══════════════════════════════════════════════════════════════════════════
   TAP INPUT MODE
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-tap-section {
    padding: var(--v4-space-6) 0;
}

.v4-tap-header {
    text-align: center;
    margin-bottom: var(--v4-space-6);
}

.v4-section-title {
    font-family: var(--v4-font-display);
    font-size: var(--v4-text-xl);
    font-weight: 700;
    letter-spacing: var(--v4-tracking-wider);
    color: var(--v4-primary);
    text-shadow: var(--v4-glow-text);
    margin-bottom: var(--v4-space-2);
}

.v4-section-desc {
    color: var(--v4-text-muted);
    font-size: var(--v4-text-md);
}

.v4-tap-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--v4-space-6);
}

.v4-tap-pad {
    position: relative;
    aspect-ratio: 1;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--v4-bg-elevated);
    border: 3px solid var(--v4-border-base);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
}

.v4-tap-pad:hover {
    border-color: var(--v4-primary);
}

.v4-tap-pad:active {
    background: var(--v4-primary-subtle);
    border-color: var(--v4-primary);
    box-shadow: var(--v4-glow-strong);
}

.v4-tap-ripple {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.v4-tap-instructions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--v4-space-2);
    text-align: center;
}

.v4-tap-instructions svg {
    width: 48px;
    height: 48px;
    color: var(--v4-primary);
    opacity: 0.5;
}

.v4-tap-instructions span {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-wider);
    color: var(--v4-text-secondary);
}

.v4-tap-hint {
    font-size: var(--v4-text-xs) !important;
    color: var(--v4-text-muted) !important;
    font-weight: 400 !important;
}

.v4-tap-output {
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-4);
}

.v4-tap-current,
.v4-tap-decoded {
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-2);
    padding: var(--v4-space-4);
    background: var(--v4-bg-elevated);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
}

.v4-tap-label {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    color: var(--v4-text-muted);
}

.v4-tap-morse {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-2xl);
    font-weight: 500;
    color: var(--v4-primary);
    text-shadow: var(--v4-glow-text);
    min-height: 48px;
}

.v4-tap-text {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xl);
    font-weight: 600;
    color: var(--v4-text-primary);
    min-height: 36px;
}

.v4-tap-actions {
    display: flex;
    gap: var(--v4-space-2);
    margin-top: auto;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--v4-space-2);
    padding: var(--v4-space-3) var(--v4-space-5);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-wide);
    border-radius: var(--v4-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-btn-primary {
    color: var(--v4-bg-darkest);
    background: var(--v4-primary);
    border: 1px solid var(--v4-primary);
}

.v4-btn-primary:hover {
    background: var(--v4-primary-bright);
    border-color: var(--v4-primary-bright);
    box-shadow: var(--v4-glow-primary);
}

.v4-btn-secondary {
    color: var(--v4-text-secondary);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-base);
}

.v4-btn-secondary:hover {
    color: var(--v4-primary);
    border-color: var(--v4-primary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   DECODER MODE
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-decoder-section {
    padding: var(--v4-space-6) 0;
}

.v4-decoder-header {
    text-align: center;
    margin-bottom: var(--v4-space-6);
}

.v4-decoder-container {
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-6);
}

.v4-decoder-controls {
    display: flex;
    justify-content: center;
    gap: var(--v4-space-4);
}

.v4-decoder-btn {
    display: flex;
    align-items: center;
    gap: var(--v4-space-3);
    padding: var(--v4-space-4) var(--v4-space-6);
    color: var(--v4-text-secondary);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-wide);
    background: var(--v4-bg-elevated);
    border: 2px solid var(--v4-border-base);
    border-radius: var(--v4-radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.v4-decoder-btn svg {
    width: 24px;
    height: 24px;
}

.v4-decoder-btn:hover {
    color: var(--v4-primary);
    border-color: var(--v4-primary);
    box-shadow: var(--v4-glow-primary);
}

.v4-decoder-btn.active {
    color: var(--v4-accent-red);
    border-color: var(--v4-accent-red);
    animation: decoder-pulse 1s ease-in-out infinite;
}

@keyframes decoder-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 51, 51, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(255, 51, 51, 0); }
}

.v4-decoder-display {
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-4);
}

.v4-decoder-waveform {
    position: relative;
    height: 200px;
    background: var(--v4-bg-darkest);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
    overflow: hidden;
}

.v4-decoder-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.v4-decoder-output {
    padding: var(--v4-space-4);
    background: var(--v4-bg-elevated);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-lg);
}

.v4-decoder-label {
    display: block;
    margin-bottom: var(--v4-space-2);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    color: var(--v4-text-muted);
}

.v4-decoder-text {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xl);
    font-weight: 600;
    color: var(--v4-text-primary);
    min-height: 36px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.v4-settings-overlay.active {
    opacity: 1;
    visibility: visible;
}

.v4-settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    background: var(--v4-bg-panel);
    border-left: 1px solid var(--v4-border-base);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.v4-settings-panel.active {
    transform: translateX(0);
}

.v4-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--v4-space-4) var(--v4-space-6);
    border-bottom: 1px solid var(--v4-border-dim);
}

.v4-settings-title {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
    font-family: var(--v4-font-display);
    font-size: var(--v4-text-md);
    font-weight: 700;
    letter-spacing: var(--v4-tracking-wider);
    color: var(--v4-primary);
    text-shadow: var(--v4-glow-text);
}

.v4-settings-title svg {
    width: 20px;
    height: 20px;
}

.v4-settings-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--v4-text-muted);
    background: transparent;
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.v4-settings-close svg {
    width: 18px;
    height: 18px;
}

.v4-settings-close:hover {
    color: var(--v4-primary);
    border-color: var(--v4-border-base);
}

.v4-settings-body {
    flex: 1;
    padding: var(--v4-space-4) var(--v4-space-6);
    overflow-y: auto;
}

.v4-settings-group {
    margin-bottom: var(--v4-space-6);
}

.v4-settings-group-title {
    margin-bottom: var(--v4-space-3);
    padding-bottom: var(--v4-space-2);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-xs);
    font-weight: 600;
    letter-spacing: var(--v4-tracking-widest);
    text-transform: uppercase;
    color: var(--v4-text-muted);
    border-bottom: 1px solid var(--v4-border-dim);
}

.v4-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--v4-space-4);
    margin-bottom: var(--v4-space-3);
}

.v4-setting-row > label {
    flex-shrink: 0;
    font-size: var(--v4-text-sm);
    color: var(--v4-text-secondary);
}

.v4-setting-control {
    display: flex;
    align-items: center;
    gap: var(--v4-space-2);
}

/* Range Input */
.v4-range {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-full);
    outline: none;
    cursor: pointer;
}

.v4-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--v4-primary);
    border: 2px solid var(--v4-bg-elevated);
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

.v4-range::-webkit-slider-thumb:hover {
    box-shadow: var(--v4-glow-primary);
}

.v4-range-value {
    min-width: 32px;
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    font-weight: 600;
    color: var(--v4-primary);
    text-align: right;
}

/* Select Input */
.v4-select {
    min-width: 150px;
    padding: var(--v4-space-2) var(--v4-space-3);
    color: var(--v4-text-primary);
    font-family: var(--v4-font-body);
    font-size: var(--v4-text-sm);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.v4-select:hover,
.v4-select:focus {
    border-color: var(--v4-border-base);
}

/* Text Input */
.v4-input {
    padding: var(--v4-space-2) var(--v4-space-3);
    color: var(--v4-text-primary);
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-md);
    outline: none;
    transition: border-color 0.15s ease;
}

.v4-input:hover,
.v4-input:focus {
    border-color: var(--v4-border-base);
}

.v4-input-char {
    width: 50px;
    text-align: center;
}

/* Toggle Switch */
.v4-toggle {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.v4-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.v4-toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--v4-bg-surface);
    border: 1px solid var(--v4-border-dim);
    border-radius: var(--v4-radius-full);
    transition: all 0.2s ease;
}

.v4-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--v4-text-muted);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.v4-toggle input:checked + .v4-toggle-track {
    background: var(--v4-primary-subtle);
    border-color: var(--v4-border-base);
}

.v4-toggle input:checked + .v4-toggle-track::after {
    transform: translateX(20px);
    background: var(--v4-primary);
}

/* Settings Footer */
.v4-settings-footer {
    display: flex;
    gap: var(--v4-space-3);
    padding: var(--v4-space-4) var(--v4-space-6);
    border-top: 1px solid var(--v4-border-dim);
}

.v4-settings-footer .v4-btn {
    flex: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   FLASH OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--v4-primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s ease;
}

.v4-flash-overlay.active {
    opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
.v4-toast-container {
    position: fixed;
    bottom: var(--v4-space-6);
    right: var(--v4-space-6);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--v4-space-2);
}

.v4-toast {
    display: flex;
    align-items: center;
    gap: var(--v4-space-3);
    padding: var(--v4-space-3) var(--v4-space-4);
    background: var(--v4-bg-panel);
    border: 1px solid var(--v4-border-base);
    border-radius: var(--v4-radius-md);
    box-shadow: var(--v4-glow-primary);
    animation: toast-in 0.3s ease;
}

.v4-toast-success { border-color: var(--v4-accent-green); }
.v4-toast-error { border-color: var(--v4-accent-red); }

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

.v4-toast-text {
    font-family: var(--v4-font-mono);
    font-size: var(--v4-text-sm);
    color: var(--v4-text-primary);
}


