@import url('css/modal-shared.css');

/* Colormap-based accent colors (updated via JS when colormap changes).
   Defaults match 'inferno' colormap — the app default. */
:root {
    --accent-color: #808080;
    --accent-rgb: 128, 128, 128;
    --accent-glow: rgba(128, 128, 128, 0.25);
    --accent-border: rgba(128, 128, 128, 0.2);
    --accent-soft: rgba(128, 128, 128, 0.12);
    --accent-bg: linear-gradient(135deg, #252a40, #161a28);
    --page-bg: #2b2b3a;
}

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

/* Recording button pulse animation */
@keyframes recording-pulse {
    0%, 100% {
        filter: brightness(1.2);
    }
    50% {
        filter: brightness(0.85);
    }
}

html {
    overflow-x: hidden;
    background: var(--page-bg, #2b2b3a);
}

/* Mobile warning overlay - JS controls visibility on load */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 20% 80%, rgba(80, 15, 10, 0.35) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(70, 15, 10, 0.25) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 50%, rgba(40, 8, 5, 0.4) 0%, transparent 70%),
                linear-gradient(135deg, #000000 0%, #0a0205 30%, #050205 60%, #000000 100%);
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    overflow: hidden;
}

/* Floating particles */
.mobile-overlay-particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleDrift linear infinite;
}

.p1 { width: 5px; height: 5px; background: rgba(255, 120, 80, 0.7); top: 15%; left: 10%; animation-duration: 18s; animation-delay: 0s; }
.p2 { width: 3px; height: 3px; background: rgba(200, 80, 120, 0.6); top: 70%; left: 85%; animation-duration: 22s; animation-delay: -4s; }
.p3 { width: 6px; height: 6px; background: rgba(255, 90, 60, 0.5); top: 40%; left: 50%; animation-duration: 25s; animation-delay: -8s; }
.p4 { width: 3px; height: 3px; background: rgba(180, 100, 160, 0.6); top: 85%; left: 30%; animation-duration: 20s; animation-delay: -2s; }
.p5 { width: 5px; height: 5px; background: rgba(255, 150, 100, 0.5); top: 25%; left: 75%; animation-duration: 24s; animation-delay: -10s; }
.p6 { width: 3px; height: 3px; background: rgba(220, 70, 90, 0.6); top: 55%; left: 15%; animation-duration: 19s; animation-delay: -6s; }
.p7 { width: 5px; height: 5px; background: rgba(160, 80, 140, 0.5); top: 10%; left: 60%; animation-duration: 23s; animation-delay: -14s; }
.p8 { width: 3px; height: 3px; background: rgba(255, 100, 70, 0.7); top: 65%; left: 45%; animation-duration: 21s; animation-delay: -12s; }
.p9 { width: 4px; height: 4px; background: rgba(240, 90, 80, 0.6); top: 30%; left: 90%; animation-duration: 20s; animation-delay: -3s; }
.p10 { width: 5px; height: 5px; background: rgba(180, 60, 100, 0.5); top: 90%; left: 60%; animation-duration: 26s; animation-delay: -7s; }
.p11 { width: 3px; height: 3px; background: rgba(255, 130, 90, 0.6); top: 50%; left: 5%; animation-duration: 17s; animation-delay: -11s; }
.p12 { width: 5px; height: 5px; background: rgba(200, 70, 110, 0.5); top: 5%; left: 40%; animation-duration: 23s; animation-delay: -16s; }
.p13 { width: 3px; height: 3px; background: rgba(255, 110, 60, 0.7); top: 75%; left: 70%; animation-duration: 19s; animation-delay: -5s; }
.p14 { width: 5px; height: 5px; background: rgba(170, 90, 130, 0.5); top: 45%; left: 25%; animation-duration: 22s; animation-delay: -9s; }

@keyframes particleDrift {
    0% { transform: translate(0, 0); opacity: 0; }
    10% { opacity: 1; }
    50% { opacity: 0.6; }
    90% { opacity: 1; }
    100% { transform: translate(calc(40vw * var(--dx, 1)), calc(30vh * var(--dy, -1))); opacity: 0; }
}

.p1 { --dx: 1; --dy: -1; }
.p2 { --dx: -1; --dy: 1; }
.p3 { --dx: -0.5; --dy: -0.8; }
.p4 { --dx: 1; --dy: -0.6; }
.p5 { --dx: -0.8; --dy: 1; }
.p6 { --dx: 0.7; --dy: 0.9; }
.p7 { --dx: -1; --dy: -0.5; }
.p8 { --dx: 0.6; --dy: -1; }
.p9 { --dx: -0.9; --dy: -0.7; }
.p10 { --dx: 0.4; --dy: -1; }
.p11 { --dx: 1; --dy: 0.5; }
.p12 { --dx: -0.6; --dy: 1; }
.p13 { --dx: -0.8; --dy: -0.4; }
.p14 { --dx: 0.9; --dy: 0.7; }

.mobile-overlay-title {
    color: #fff;
    font-size: 1.5em;
    font-weight: bold;
    margin: 0 0 30px 0;
    opacity: 0.88;
    text-align: center;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

.mobile-overlay-content {
    text-align: center;
    max-width: 360px;
    position: relative;
    z-index: 1;
}

.mobile-overlay-content h2 {
    color: #ccc;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 14px 0;
}

.mobile-overlay-btn {
    margin-top: 28px;
    padding: 14px 36px;
    font-size: 16px;
    font-weight: 600;
    color: #aaa;
    background: transparent;
    border: 1px solid #666;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.1s, border-color 0.1s;
}

.mobile-overlay-btn:hover:not(:disabled) {
    color: #ddd;
    border-color: #999;
    background: linear-gradient(135deg, rgba(120, 30, 20, 0.6) 0%, rgba(80, 15, 10, 0.6) 100%);
    transform: none;
    box-shadow: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--page-bg, #2b2b3a);
    min-height: 100vh;
    padding: 10px 40px 20px 40px;
    overflow-x: hidden;
    overflow-y: scroll;
}

body::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

.container {
    max-width: 1700px;
    margin: 0 auto;
    padding-bottom: 20px;
}

h1 {
    color: white;
    text-align: center;
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 20px rgba(102, 126, 234, 0.6), 0 0 50px rgba(118, 75, 162, 0.4), 0 0 80px rgba(102, 126, 234, 0.3), 0 0 120px rgba(118, 75, 162, 0.2);
}

h2 {
    color: #4a4a6a;
    text-shadow: 1px 1px 3px rgba(180, 180, 220, 0.6), 0 0 2px rgba(255, 255, 255, 0.7);
    font-weight: 700;
}

.panel {
    background: linear-gradient(135deg, rgba(250, 250, 255, 0.95) 0%, rgba(230, 225, 245, 0.95) 100%);
    border-radius: 5px;
    padding: 20px;
    margin-bottom: 8px;
    box-shadow:
        0 10px 20px rgba(40, 30, 80, 0.35),
        0 6px 12px rgba(40, 30, 80, 0.25),
        0 3px 6px rgba(102, 126, 234, 0.15),
        0 1px 3px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.2);
    position: relative;
    isolation: isolate;
}

/* Glow effect on visualization panel only */
.panel-visualization {
    overflow: visible; /* Allow glow to extend beyond panel */
    /* Glow is applied via JavaScript (box-shadow controlled dynamically) */
    z-index: 0; /* Lowest z-index - glow appears behind everything */
    position: relative; /* Ensure z-index works */
}


/* Panel: Simulate panel */
.panel-simulate {
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
    z-index: 10; /* Above visualization panel glow */
}

/* Panel: Cache panel */
.panel-cache {
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
    z-index: 10; /* Above visualization panel glow */
}

/* Panel: Volcano/Station selection panel - Medium-light grey (#9a9a9a) */
.panel-selection {
    padding-top: 8px;
    padding-bottom: 8px;
    background: 
        repeating-linear-gradient(0deg, 
            transparent, 
            transparent 2px, 
            rgba(154, 154, 154, 0.15) 2px, 
            rgba(154, 154, 154, 0.15) 4px
        ),
        repeating-linear-gradient(90deg, 
            transparent, 
            transparent 15px, 
            rgba(150, 150, 150, 0.18) 15px, 
            rgba(150, 150, 150, 0.18) 18px
        ),
        radial-gradient(ellipse at top, rgba(200, 200, 200, 0.4) 0%, rgba(180, 180, 180, 0.2) 15%, rgba(160, 160, 160, 0.1) 30%, transparent 60%),
        linear-gradient(180deg, 
            rgba(170, 170, 170, 0.98) 0%,
            rgba(160, 160, 160, 0.95) 15%,
            rgba(154, 154, 154, 0.95) 35%,
            rgba(150, 150, 150, 0.95) 50%,
            rgba(145, 145, 145, 0.95) 70%,
            rgba(140, 140, 140, 0.95) 85%,
            rgba(135, 135, 135, 0.95) 100%
        ) !important;
    box-shadow: 
        0 10px 20px rgba(60, 60, 60, 0.3),
        0 6px 12px rgba(70, 70, 70, 0.25),
        0 3px 6px rgba(80, 80, 80, 0.2),
        0 1px 3px rgba(0, 0, 0, 0.15),
        inset 0 3px 6px rgba(255, 255, 255, 0.6),
        inset 0 -4px 8px rgba(40, 40, 40, 0.35),
        inset 0 0 35px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        inset 0 -1px 0 rgba(90, 90, 90, 0.3) !important;
    border: 1px solid rgba(170, 170, 170, 0.6) !important;
    border-top: 1px solid rgba(220, 220, 220, 0.6) !important;
    border-bottom: 1px solid rgba(130, 130, 130, 0.5) !important;
    position: relative;
    z-index: 10; /* Above visualization panel glow */
}

.panel-selection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(200, 200, 200, 0.4) 0%,
        rgba(180, 180, 180, 0.3) 10%,
        rgba(170, 170, 170, 0.2) 20%,
        rgba(160, 160, 160, 0.12) 35%,
        rgba(150, 150, 150, 0.06) 48%,
        transparent 52%,
        transparent 58%,
        rgba(120, 120, 120, 0.1) 75%,
        rgba(100, 100, 100, 0.2) 90%,
        rgba(80, 80, 80, 0.3) 100%
    );
    pointer-events: none;
    border-radius: 5px;
}

.panel-selection label {
    font-size: 18px;
}

.panel-selection select,
.panel-selection input {
    font-size: 16px;
}

/* Panel: View Options - dark like visualization area */
.panel-view-options {
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
    z-index: 10;
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(80, 80, 100, 0.1) 2px,
            rgba(80, 80, 100, 0.1) 4px
        ),
        linear-gradient(135deg,
            rgba(35, 35, 50, 0.95) 0%,
            rgba(30, 30, 45, 0.95) 50%,
            rgba(25, 25, 40, 0.95) 100%
        ) !important;
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.3),
        0 3px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(100, 100, 140, 0.25) !important;
}

/* Panel: Playback controls panel - Lighter grey (#a8a8a8) with healthy gradient */
.panel-playback {
    background: 
        repeating-linear-gradient(0deg, 
            transparent, 
            transparent 2px, 
            rgba(168, 168, 168, 0.15) 2px, 
            rgba(168, 168, 168, 0.15) 4px
        ),
        repeating-linear-gradient(90deg, 
            transparent, 
            transparent 3px, 
            rgba(165, 165, 165, 0.18) 3px, 
            rgba(165, 165, 165, 0.18) 6px
        ),
        radial-gradient(ellipse at top, rgba(210, 210, 210, 0.4) 0%, rgba(190, 190, 190, 0.25) 15%, rgba(175, 175, 175, 0.12) 30%, transparent 60%),
        linear-gradient(135deg, 
            rgba(200, 200, 200, 0.95) 0%, 
            rgba(190, 190, 190, 0.95) 15%,
            rgba(180, 180, 180, 0.95) 30%,
            rgba(175, 175, 175, 0.95) 45%,
            rgba(170, 170, 170, 0.95) 60%,
            rgba(165, 165, 165, 0.95) 75%,
            rgba(160, 160, 160, 0.95) 90%,
            rgba(155, 155, 155, 0.95) 100%
        ) !important;
    box-shadow: 
        0 10px 20px rgba(50, 50, 50, 0.35),
        0 6px 12px rgba(60, 60, 60, 0.3),
        0 3px 6px rgba(70, 70, 70, 0.25),
        0 1px 3px rgba(0, 0, 0, 0.2),
        inset 0 3px 6px rgba(240, 240, 240, 0.5),
        inset 0 -4px 8px rgba(30, 30, 30, 0.4),
        inset 0 0 30px rgba(230, 230, 230, 0.15),
        inset 0 1px 0 rgba(245, 245, 245, 0.6),
        inset 0 -1px 0 rgba(100, 100, 100, 0.3) !important;
    border: 1px solid rgba(180, 180, 180, 0.6) !important;
    border-top: 1px solid rgba(230, 230, 230, 0.6) !important;
    border-bottom: 1px solid rgba(140, 140, 140, 0.5) !important;
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
    z-index: 10; /* Above visualization panel glow */
}

.panel-playback::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(220, 220, 220, 0.4) 0%,
        rgba(210, 210, 210, 0.3) 12%,
        rgba(200, 200, 200, 0.2) 25%,
        rgba(190, 190, 190, 0.12) 40%,
        rgba(180, 180, 180, 0.06) 48%,
        transparent 52%,
        transparent 58%,
        rgba(150, 150, 150, 0.1) 75%,
        rgba(130, 130, 130, 0.2) 90%,
        rgba(110, 110, 110, 0.3) 100%
    );
    pointer-events: none;
    border-radius: 5px;
}

.panel-playback label {
    font-size: 15px;
}

.panel-playback select,
.panel-playback input {
    font-size: 15px;
}

.panel-playback h2 {
    font-size: calc(1.5em + 1px);
}

/* Panel: Waveform/Spectrogram visualization panel */
.panel-visualization {
    background: var(--accent-bg);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    padding-top: 12px;
    padding-right: 40px;
    padding-bottom: 15px;
    min-height: 0;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

/* Panel: Metrics panel */
.panel-metrics {
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
    z-index: 10; /* Above visualization panel glow */
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* Recent searches row container - shrink before wrap */
.controls-row-1 {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

/* Push component selector to the right */
#componentSelectorContainer {
    margin-left: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-weight: 700;
    font-size: 14px;
    color: #333;
}

input {
    padding: 6px 10px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 6px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    opacity: 0.9;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background: #353545;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 24px 4px 8px;
    font-size: 13px;
    font-family: inherit;
    line-height: 18px;
    height: 28px;
    box-sizing: border-box;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='4' viewBox='0 0 8 4' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0L4 4L8 0' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to bottom, transparent 5px, rgba(102, 126, 234, 0.5) 5px, rgba(102, 126, 234, 0.5) 8px, transparent 8px);
    height: 16px;
    cursor: pointer;
    padding: 0;
    border: none;
    outline: none;
    border-radius: 4px;
}

/* Fixed width for slider value displays to prevent layout shifts */
#speedValue {
    display: inline-block;
    width: 2.8em;
    text-align: left;
}

#volumeValue {
    display: inline-block;
    width: 2.2em;
    text-align: left;
}

/* Webkit (Chrome, Safari, Edge) - Track */
input[type="range"]::-webkit-slider-track {
    background: rgba(102, 126, 234, 0.5);
    height: 3px;
    border-radius: 2px;
    border: none;
}

/* Webkit - Thumb */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 18px;
    width: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    margin-top: -7.5px;
    position: relative;
    top: 2px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.45);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: linear-gradient(135deg, #7a8ef0 0%, #8a5fb5 100%);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.55);
}

/* Speed slider glow effect for tutorial - animate FILTER on parent */
#playbackSpeed.speed-slider-glow {
    animation: speedSliderKnobPulse 1s ease-in-out infinite !important;
}

/* Make the knob brighter so the glow is more visible */
#playbackSpeed.speed-slider-glow::-webkit-slider-thumb {
    background: #8a9ff5 !important;
}

#playbackSpeed.speed-slider-glow::-moz-range-thumb {
    background: #8a9ff5 !important;
}

/* Volume slider glow effect */
#volumeSlider.volume-slider-glow {
    animation: volumeSliderKnobPulse 1.2s ease-in-out infinite !important;
    transition: opacity 1.5s ease-out, filter 1.5s ease-out;
}

#volumeSlider.volume-slider-glow.fading-in {
    opacity: 0;
    animation: none;
}

#volumeSlider.volume-slider-glow.fading-out {
    animation: none;
    opacity: 0;
    transition: opacity 1.5s ease-out, filter 1.5s ease-out;
}

/* Add glow to the track (bar) */
#volumeSlider.volume-slider-glow::-webkit-slider-track {
    background: rgba(102, 126, 234, 0.5) !important;
    box-shadow: 0 0 5px rgba(102, 126, 234, 1), 0 0 10px rgba(118, 75, 162, 0.85) !important;
}

#volumeSlider.volume-slider-glow::-moz-range-track {
    background: rgba(102, 126, 234, 0.5) !important;
    box-shadow: 0 0 5px rgba(102, 126, 234, 1), 0 0 10px rgba(118, 75, 162, 0.85) !important;
}

/* Make the knob brighter so the glow is more visible */
#volumeSlider.volume-slider-glow::-webkit-slider-thumb {
    background: #8a9ff5 !important;
    box-shadow: 0 0 6px rgba(102, 126, 234, 1), 0 0 12px rgba(118, 75, 162, 0.9) !important;
}

#volumeSlider.volume-slider-glow::-moz-range-thumb {
    background: #8a9ff5 !important;
    box-shadow: 0 0 6px rgba(102, 126, 234, 1), 0 0 12px rgba(118, 75, 162, 0.9) !important;
}

#volumeLabel.volume-label-glow {
    text-shadow: 0 0 15px rgba(102, 126, 234, 1), 0 0 30px rgba(118, 75, 162, 0.9), 0 0 45px rgba(102, 126, 234, 0.7);
    animation: volumeLabelPulse 0.7s ease-in-out infinite !important;
    transition: text-shadow 0.5s ease-out, opacity 0.5s ease-out;
}

#volumeLabel.volume-label-glow.fading-in {
    opacity: 0;
    text-shadow: 0 0 0px rgba(102, 126, 234, 0);
    animation: none;
}

#volumeLabel.volume-label-glow.fading-out {
    animation: none;
    text-shadow: 0 0 0px rgba(102, 126, 234, 0);
}

@keyframes speedSliderKnobPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.8))
                drop-shadow(0 0 16px rgba(118, 75, 162, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(138, 159, 245, 1))
                drop-shadow(0 0 32px rgba(102, 126, 234, 0.9))
                drop-shadow(0 0 48px rgba(118, 75, 162, 0.7));
    }
}

@keyframes volumeSliderKnobPulse {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(102, 126, 234, 0.9))
                drop-shadow(0 0 8px rgba(118, 75, 162, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 6px rgba(138, 159, 245, 1))
                drop-shadow(0 0 12px rgba(102, 126, 234, 0.95))
                drop-shadow(0 0 18px rgba(118, 75, 162, 0.85));
    }
}

@keyframes volumeLabelPulse {
    0%, 100% {
        text-shadow: 0 0 20px rgba(138, 159, 245, 1),
                     0 0 40px rgba(102, 126, 234, 1),
                     0 0 60px rgba(118, 75, 162, 0.9),
                     0 0 80px rgba(102, 126, 234, 0.7);
    }
    50% {
        text-shadow: 0 0 35px rgba(170, 185, 255, 1),
                     0 0 70px rgba(138, 159, 245, 1),
                     0 0 105px rgba(102, 126, 234, 1),
                     0 0 140px rgba(118, 75, 162, 0.9),
                     0 0 175px rgba(102, 126, 234, 0.7);
    }
}

/* Speed value glow effect for tutorial */
#speedValue.speed-value-glow,
#speedLabel.speed-value-glow {
    animation: speedValuePulse 1s ease-in-out infinite !important;
    color: #8a9ff5 !important;
}

@keyframes speedValuePulse {
    0%, 100% {
        text-shadow: 0 0 8px rgba(102, 126, 234, 0.8),
                      0 0 16px rgba(118, 75, 162, 0.6);
    }
    50% {
        text-shadow: 0 0 16px rgba(138, 159, 245, 1),
                      0 0 32px rgba(102, 126, 234, 0.9),
                      0 0 48px rgba(118, 75, 162, 0.7);
    }
}

/* Pause button glow effect for tutorial - more intense but tighter */
#playPauseBtn.pause-button-glow {
    animation: pauseButtonPulse 1.5s ease-in-out infinite !important;
    filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.8))
            drop-shadow(0 0 10px rgba(118, 75, 162, 0.6));
}

@keyframes pauseButtonPulse {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.8))
                drop-shadow(0 0 10px rgba(118, 75, 162, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(138, 159, 245, 1))
                drop-shadow(0 0 24px rgba(102, 126, 234, 0.9));
    }
}

/* Firefox - Track */
input[type="range"]::-moz-range-track {
    background: rgba(102, 126, 234, 0.5);
    height: 3px;
    border-radius: 2px;
    border: none;
}

/* Firefox - Thumb */
input[type="range"]::-moz-range-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 18px;
    width: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb:hover {
    background: linear-gradient(135deg, #7a8ef0 0%, #8a5fb5 100%);
}



button {
    border: none;
    cursor: pointer;
    font-family: inherit;
    background: transparent;
    color: inherit;
    padding: 0;
}

.btn-action {
    padding: 9px 18px;
    font-size: 16px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    height: 38px;
    line-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.btn-action:hover:not(:disabled) {
    transform: var(--btn-lift, translateY(-1px));
    box-shadow: 0 5px 12px rgba(102, 126, 234, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, #7a8ef0 0%, #8a5fb5 100%);
}

#startBtn:not(:disabled):not(.streaming):not(.fetched) {
    animation: pulseBright 1.8s ease-in-out infinite;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.2);
}

#startBtn.streaming {
    background: linear-gradient(135deg, #8a9ff5 0%, #9b6bc9 100%) !important;
    animation: pulseVibrant 1.2s ease-in-out infinite;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 1), 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    transform: scale(1.02);
}

@keyframes pulseVibrant {
    0%, 100% {
        filter: brightness(1);
        box-shadow: 0 5px 15px rgba(102, 126, 234, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        filter: brightness(1.2);
        box-shadow: 0 8px 20px rgba(138, 159, 245, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

@keyframes pulseBrightness {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(0.85);
    }
}

@keyframes pulsePlayButton {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3), 0 0 0 6px rgba(102, 126, 234, 0);
    }
}

@keyframes pulseResumeDarken {
    0%, 100% {
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3), inset 0 0 0 0 rgba(60, 40, 100, 0);
    }
    50% {
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3), inset 0 0 100px 50px rgba(60, 40, 100, 0.4);
    }
}

@keyframes pulseBright {
    0%, 100% {
        filter: brightness(1);
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 10px rgba(102, 126, 234, 0.3);
    }
    50% {
        filter: brightness(1.35);
        box-shadow: 0 5px 12px rgba(102, 126, 234, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 20px rgba(138, 159, 245, 0.6);
    }
}

button.pulse-play {
    animation: pulsePlayButton 2s ease-in-out infinite;
}

button.pulse-resume {
    animation: pulseResumeDarken 1.8s ease-in-out infinite;
    color: #ffffff !important;
}

/* Attention-grabbing glow for shared session "ready to play" state */
/* Synced with waveformPulse (1.2s) for visual harmony */
button.pulse-attention {
    animation: pulseAttentionGlow 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 5px rgba(74, 155, 106, 0.8))
            drop-shadow(0 0 10px rgba(45, 112, 72, 0.6));
}

@keyframes pulseAttentionGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(74, 155, 106, 0.8))
                drop-shadow(0 0 10px rgba(45, 112, 72, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(90, 180, 120, 1))
                drop-shadow(0 0 24px rgba(74, 155, 106, 0.9));
    }
}

.btn-action:disabled {
    background: linear-gradient(135deg, #666 0%, #555 100%) !important;
    cursor: not-allowed !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    opacity: 0.7 !important;
    color: #bbb !important;
    text-shadow: none !important;
    animation: none !important;
    transform: none !important;
    filter: grayscale(100%) !important;
    border-color: rgba(100, 100, 100, 0.3) !important;
}

#startBtn:disabled {
    background: linear-gradient(135deg, #666 0%, #555 100%) !important;
    cursor: not-allowed !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    opacity: 0.7 !important;
    color: #bbb !important;
    text-shadow: none !important;
    animation: none !important;
    transform: none !important;
    filter: grayscale(100%) !important;
}

button.secondary {
    background: linear-gradient(135deg, #5a6ab8 0%, #4a3a88 100%);
}

button.secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #6a7ac8 0%, #5a4a98 100%);
}

button.pause-active {
    background: linear-gradient(135deg, #c75a5a 0%, #8b3a3a 100%);
}

button.pause-active:hover:not(:disabled) {
    background: linear-gradient(135deg, #d76a6a 0%, #9b4a4a 100%);
}

button.play-active {
    background: linear-gradient(135deg, #4a9b6a 0%, #2d7048 100%);
}

button.play-active:hover:not(:disabled) {
    background: linear-gradient(135deg, #5aab7a 0%, #3d8058 100%);
}

/* Loop button OFF state - muted desaturated purple */
#loopBtn:not(.loop-active) {
    background: linear-gradient(135deg, #6b5a7a 0%, #4a3d5a 100%);
}

#loopBtn:not(.loop-active) {
    color: #bbb;
    transition: background 0.2s, box-shadow 0.2s;
}

#loopBtn:not(.loop-active):hover:not(:disabled) {
    background: linear-gradient(135deg, #666 0%, #555 100%);
    color: #ccc;
}

/* Loop button ON state - matches Fetch Data gradient */
.btn-action.loop-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 8px rgba(102, 126, 234, 0.4);
}

.btn-action.loop-active:hover:not(:disabled) {
    background: linear-gradient(135deg, #7690f0 0%, #8655b2 100%);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 12px rgba(102, 126, 234, 0.5);
}

.status {
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    font-weight: 500;
    min-height: 36px;
    max-height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid rgba(80, 80, 80, 0.9);
    position: relative;
    white-space: nowrap;
    min-width: 0; /* Allow flex item to shrink below content size */
    background: rgba(40, 40, 40, 0.85); /* Dark background like .status.info */
    color: #e0e0e0; /* Light text color */
    font-size: 16px; /* Default size, will auto-shrink via JS if overflows */
}

.status.info { background: rgba(40, 40, 40, 0.85); color: #e0e0e0; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif; border: 1px solid rgba(80, 80, 80, 0.9); }
.status.success { color: #4caf50; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif; }
.status.error { color: #ffcc99; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif; }

.status.loading {
    background: linear-gradient(
        90deg,
        rgb(90, 115, 210) 0%,
        rgb(130, 160, 240) 50%,
        rgb(90, 115, 210) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
    border-color: rgba(80, 80, 80, 0.9) !important;
    color: #1a1a3e !important;
    font-weight: 700 !important;
    position: relative;
    text-shadow: none;
    isolation: isolate; /* Creates new stacking context */
}

/* Ensure wrapped loading text stays above animated overlays */
.status.loading .status-message {
    position: relative;
    z-index: 10;
    display: block;
    width: 100%;
    color: inherit;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2), 0 0 12px rgba(255, 255, 255, 0.12);
}

.status.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.075) 30%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.075) 70%,
        transparent
    );
    animation: shimmerSweep 3s ease-in-out infinite, pulseBrighten 2s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

.status.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.175) 10px,
        rgba(255, 255, 255, 0.175) 20px
    );
    background-size: 28px 28px;
    animation: stripeMove 2.4s linear infinite, pulseBrighten 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes shimmer {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes pulseBackground {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes pulseBrighten {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.35);
    }
}

@keyframes shimmerSweep {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes stripeMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 28px 0;
    }
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 0;
}

.metric {
    background: linear-gradient(135deg, rgba(230, 235, 255, 0.6) 0%, rgba(220, 225, 250, 0.6) 100%);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 4px rgba(40, 30, 80, 0.15);
}

.metric-label {
    font-size: 12px;
    color: #5a5a8a;
    text-transform: uppercase;
    margin-bottom: 5px;
    font-weight: 600;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #3a3a6a;
}

canvas {
    width: 100%;
    display: block;
    border-radius: 3px;
    background: #000;
    box-shadow: inset 0 0 15px var(--accent-soft), 0 0 8px var(--accent-soft);
}

#minimap {
    position: relative;
    height: 135px;
    margin-bottom: 10px;
    background: #000000;
    border: 2px solid var(--accent-glow);
    box-shadow: none;
    transition: border-color 0.3s ease;
    contain: layout style paint;
    overflow: hidden;
}

#minimap-overlay {
    border-radius: 0; /* Overlay must not clip — viewport indicator draws its own rounded corners */
}

#spectrogram {
    height: var(--spec-height, clamp(250px, 62vh, 600px));
    background: #000000;
    margin-top: 40px;
    margin-bottom: 30px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    contain: layout style paint;
}

#spectrogram.spectrogram-glow {
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.25), 0 0 15px rgba(118, 75, 162, 0.15);
    animation: spectrogramPulse 1.2s ease-in-out infinite;
    transition: box-shadow 0.5s ease-out, opacity 0.5s ease-out;
}

#spectrogram.spectrogram-glow.fading-in {
    opacity: 0;
    box-shadow: 0 0 0px rgba(102, 126, 234, 0);
    animation: none;
}

#spectrogram.spectrogram-glow.fading-out {
    animation: none;
    box-shadow: 0 0 0px rgba(102, 126, 234, 0);
    opacity: 0.8;
}

/* Regions panel glow effect */
#trackedRegionsPanel.regions-panel-glow {
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.4), 0 0 30px rgba(118, 75, 162, 0.3);
    animation: spectrogramPulse 1.2s ease-in-out infinite;
    transition: box-shadow 0.5s ease-out, opacity 0.5s ease-out;
}

#trackedRegionsPanel.regions-panel-glow.fading-in {
    opacity: 0;
    box-shadow: 0 0 0px rgba(102, 126, 234, 0);
    animation: none;
}

#trackedRegionsPanel.regions-panel-glow.fading-out {
    animation: none;
    box-shadow: 0 0 0px rgba(102, 126, 234, 0);
}

/* Loop button glow effect - gentle pulsing glow */
#loopBtn.loop-button-glow {
    animation: loopButtonPulse 1.5s ease-in-out infinite !important;
    filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.8))
            drop-shadow(0 0 10px rgba(118, 75, 162, 0.6));
    transition: filter 0.5s ease-out, opacity 0.5s ease-out;
}

@keyframes loopButtonPulse {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.8))
                drop-shadow(0 0 10px rgba(118, 75, 162, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(138, 159, 245, 1))
                drop-shadow(0 0 24px rgba(102, 126, 234, 0.9));
    }
}

#loopBtn.loop-button-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
    animation: none;
}

#loopBtn.loop-button-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
}

/* Frequency scale dropdown glow effect - bigger and brighter pulse */
#frequencyScale.frequency-scale-glow {
    animation: frequencyScalePulse 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
            drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    transition: filter 0.5s ease-out, opacity 0.5s ease-out;
}

@keyframes frequencyScalePulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
                drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    }
    50% {
        filter: drop-shadow(0 0 18px rgba(138, 159, 245, 1))
                drop-shadow(0 0 35px rgba(102, 126, 234, 0.95));
    }
}

#frequencyScale.frequency-scale-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
    animation: none;
}

#frequencyScale.frequency-scale-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
}

/* Repetition dropdown glow effect */
select.repetition-dropdown-glow,
.feature-row select.repetition-dropdown-glow {
    animation: dropdownPulse 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
            drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    transition: filter 0.5s ease-out, opacity 0.5s ease-out;
    border-color: #8a9ff5 !important;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6) !important;
}

select.repetition-dropdown-glow.fading-in,
.feature-row select.repetition-dropdown-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
    animation: none;
}

select.repetition-dropdown-glow.fading-out,
.feature-row select.repetition-dropdown-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
}

/* Type dropdown glow effect */
select.type-dropdown-glow,
.feature-row select.type-dropdown-glow {
    animation: dropdownPulse 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
            drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    transition: filter 0.5s ease-out, opacity 0.5s ease-out;
    border-color: #8a9ff5 !important;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.6) !important;
}

select.type-dropdown-glow.fading-in,
.feature-row select.type-dropdown-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
    animation: none;
}

select.type-dropdown-glow.fading-out,
.feature-row select.type-dropdown-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
}

@keyframes dropdownPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
                drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    }
    50% {
        filter: drop-shadow(0 0 18px rgba(138, 159, 245, 1))
                drop-shadow(0 0 35px rgba(102, 126, 234, 0.95));
    }
}

/* Select feature button glow effect */
.select-freq-btn.select-feature-button-glow {
    animation: buttonPulse 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
            drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    transition: filter 0.5s ease-out, opacity 0.5s ease-out;
    border-color: #8a9ff5 !important;
}

.select-freq-btn.select-feature-button-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
    animation: none;
}

.select-freq-btn.select-feature-button-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(102, 126, 234, 0));
}

/* Add feature button glow effect - bigger glow */
button.add-feature-btn.add-feature-button-glow,
.add-feature-btn.add-feature-button-glow,
.add-feature-label.add-feature-button-glow {
    animation: addFeatureButtonPulse 1.2s ease-in-out infinite !important;
    filter: drop-shadow(0 0 15px rgba(100, 200, 100, 0.9))
            drop-shadow(0 0 30px rgba(100, 200, 100, 0.8))
            drop-shadow(0 0 45px rgba(100, 200, 100, 0.6)) !important;
    transition: filter 0.5s ease-out, opacity 0.5s ease-out !important;
    border-color: #64c864 !important;
    box-shadow: 0 0 20px rgba(100, 200, 100, 0.7) !important;
}

.add-feature-btn.add-feature-button-glow.fading-in,
.add-feature-label.add-feature-button-glow.fading-in {
    opacity: 0;
    filter: drop-shadow(0 0 0px rgba(100, 200, 100, 0));
    animation: none;
}

.add-feature-btn.add-feature-button-glow.fading-out,
.add-feature-label.add-feature-button-glow.fading-out {
    animation: none;
    filter: drop-shadow(0 0 0px rgba(100, 200, 100, 0));
}

@keyframes buttonPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.9))
                drop-shadow(0 0 16px rgba(118, 75, 162, 0.7));
    }
    50% {
        filter: drop-shadow(0 0 18px rgba(138, 159, 245, 1))
                drop-shadow(0 0 35px rgba(102, 126, 234, 0.95));
    }
}

@keyframes addFeatureButtonPulse {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(100, 200, 100, 0.9))
                drop-shadow(0 0 30px rgba(100, 200, 100, 0.8))
                drop-shadow(0 0 45px rgba(100, 200, 100, 0.6));
        box-shadow: 0 0 20px rgba(100, 200, 100, 0.7) !important;
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(100, 220, 100, 1))
                drop-shadow(0 0 50px rgba(100, 220, 100, 0.95))
                drop-shadow(0 0 75px rgba(100, 220, 100, 0.8));
        box-shadow: 0 0 35px rgba(100, 220, 100, 0.9) !important;
    }
}

@keyframes spectrogramPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(102, 126, 234, 0.4), 0 0 30px rgba(118, 75, 162, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5), 0 0 40px rgba(118, 75, 162, 0.4);
    }
}

#minimap-axis,
#spectrogram-axis {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    flex-basis: 60px !important;
    background: transparent !important;
    position: absolute;
    pointer-events: none;
    z-index: 10;
    /* Remove all shadow/glow effects */
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    border: none !important;
    outline: none !important;
    /* Hide initially to prevent flash - will be shown after positioning */
    opacity: 0;
    visibility: hidden;
}

#minimap-x-axis,
#spectrogram-x-axis {
    background: transparent !important;
    position: absolute;
    pointer-events: none;
    z-index: 10;
    /* Remove all shadow/glow effects */
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    border: none !important;
    outline: none !important;
}

#minimap-date {
    background: transparent !important;
    position: absolute;
    pointer-events: none;
    z-index: 10;
    /* Remove all shadow/glow effects */
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    border: none !important;
    outline: none !important;
}

#minimap-buttons {
    background: transparent !important;
    position: absolute;
    pointer-events: none;
    z-index: 6;
    /* Remove all shadow/glow effects */
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    border: none !important;
    outline: none !important;
    /* Hide initially to prevent flash - will be shown after positioning */
    opacity: 0;
    visibility: hidden;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
    accent-color: #cc3333;
}

input[type="checkbox"] {
    accent-color: #cc3333;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #333;
}


/* Header info button */
.header-info-btn {
    margin-bottom: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #aaa;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    align-self: center;
}

.header-info-btn:hover {
    border-color: #ddd;
    color: #ddd;
}

/* Modal styling */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    visibility: hidden;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    visibility: visible;
}

.modal-window {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 250ms ease-out;
}

.modal-window.modal-visible {
    opacity: 1;
}

/* Base modal styles (.modal-content, .modal-header, .modal-title, .modal-close,
   .modal-body, .modal-form-group, .modal-submit, .radio-choice) are in css/modal-shared.css */

.mood-scale-container {
    border-radius: 0;
    border: none;
    overflow: visible;
    margin-bottom: 8px;
}

.mood-scale-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    padding: 6px 6px;
    min-height: 32px;
    border-radius: 0;
    border: none;
    border-bottom: none;
}

.mood-scale-item:nth-child(odd) {
    background: transparent;
}

.mood-scale-item:nth-child(even) {
    background: transparent;
}

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

.mood-scale-label {
    font-weight: 700;
    color: #550000;
    font-size: 16px;
    text-align: right;
}

.mood-scale-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
}

.mood-scale-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    min-width: 0;
}

.mood-scale-option input[type="radio"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #007bff;
    margin: 0;
    margin-top: 4px;
}

.mood-scale-option label {
    font-size: 13px;
    font-weight: bold;
    color: #550000;
    text-align: center;
    cursor: pointer;
    margin: 0;
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.survey-scale-labels {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 6px;
}

.survey-scale-labels-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
    align-items: flex-end;
}

.survey-scale-labels-grid span {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #550000;
    -webkit-hyphens: manual;
    -moz-hyphens: manual;
    -ms-hyphens: manual;
    hyphens: manual;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.mood-survey-intro {
    font-size: 24px;
    font-weight: 700;
    color: #550000;
    margin-top: 8px;
    margin-bottom: 12px;
    text-align: center;
}

/* AWE-SF Modal - Wider for 7-point scale */
.awesf-modal .modal-content {
    max-width: 1200px;
    min-width: 900px;
    max-height: 85vh;
}

.awesf-modal .mood-scale-item {
    grid-template-columns: 250px 1fr;
    gap: 6px;
    padding: 6px 10px;
}

.awesf-modal .mood-scale-label {
    text-align: left;
}

.awesf-modal .mood-scale-options {
    grid-template-columns: repeat(7, 1fr);
    gap: 0px;
}

.awesf-modal .survey-scale-labels {
    grid-template-columns: 250px 1fr;
    gap: 6px;
}

.awesf-modal .survey-scale-labels-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 0px;
}

/* Activity Level Modal - 5-point scale */
.activity-level-modal .modal-content {
    max-width: 800px;
    min-width: 600px;
    max-height: 75vh;
}

.activity-level-modal .mood-scale-item {
    grid-template-columns: 1fr;
    gap: 0px;
    padding: 6px 10px;
}

.activity-level-modal .mood-scale-label {
    display: none;
}

.activity-level-modal .mood-scale-options {
    grid-template-columns: repeat(5, 1fr);
    gap: 0px;
    width: 100%;
}

.activity-level-modal .survey-scale-labels {
    grid-template-columns: 1fr;
    gap: 0px;
}

.activity-level-modal .survey-scale-labels-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0px;
}

.activity-level-modal .modal-header {
    border-bottom: none;
    margin-bottom: 12px;
    padding-bottom: 10px;
    position: relative;
    justify-content: flex-end;
}

.activity-level-modal .modal-title {
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    pointer-events: none;
    margin: 0;
}

.activity-level-modal .modal-close {
    display: none;
}

.awesf-modal .modal-header {
    border-bottom: none;
    margin-bottom: 12px;
    padding-bottom: 10px;
    position: relative;
    justify-content: flex-end;
}

.awesf-modal .modal-title {
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    pointer-events: none;
    margin: 0;
}

.awesf-modal .modal-close {
    display: none;
}

#preSurveyModal .modal-close {
    display: none;
}

#postSurveyModal .modal-close {
    display: none;
}

#participantModal .modal-close {
    display: none;
}

#participantModal .modal-content {
    max-width: 600px;
    min-width: 400px;
}

#musicalExperienceQuestionModal .modal-content {
    max-width: 950px;
    min-width: 600px;
}

#beginAnalysisModal .modal-content {
    max-width: 500px;
    min-width: 350px;
}

#welcomeBackModal .modal-content {
    max-width: 500px;
    min-width: 350px;
}

@media (max-width: 1200px) {
    .awesf-modal .modal-content {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 500px) {
    #participantModal .modal-content {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }

    #beginAnalysisModal .modal-content {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }

    #welcomeBackModal .modal-content {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }

    .activity-level-modal .modal-content {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }
}

/* ===== REGION TRACKER STYLES ===== */

/* Tracked Regions Panel */
#trackedRegionsPanel {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    padding-top: 15px;
    padding-bottom: 15px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#trackedRegionsPanel h2 {
    color: #e8e8ff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Scrollable container for region cards */
#regionsListContainer {
    height: 213px; /* Fixed height for ~2-3 region cards */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Space for scrollbar */
}

/* Custom scrollbar styling for regions container */
#regionsListContainer::-webkit-scrollbar {
    width: 8px;
}

#regionsListContainer::-webkit-scrollbar-track {
    background: rgba(128, 128, 128, 0.1);
    border-radius: 4px;
}

#regionsListContainer::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.4);
    border-radius: 4px;
}

#regionsListContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.6);
}

/* Firefox scrollbar */
#regionsListContainer {
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.4) rgba(128, 128, 128, 0.1);
}

/* Region list container */
/* No margin needed anymore since it's inside the scrollable container */

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 1em;
}

.empty-state p {
    opacity: 0.9;
    margin-top: 10px;
}

/* Region Card - Slightly darker */
.region-card {
    position: relative;
    background: linear-gradient(135deg, rgba(240, 240, 250, 0.95) 0%, rgba(220, 220, 240, 0.95) 100%);
    border-radius: 6px;
    margin-bottom: 6px;
    box-shadow:
        0 10px 20px rgba(40, 30, 80, 0.35),
        0 6px 12px rgba(40, 30, 80, 0.25),
        0 3px 6px rgba(102, 126, 234, 0.15),
        0 1px 3px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.2);
    overflow: visible;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease,
                margin 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.region-card:hover {
    box-shadow:
        0 12px 24px rgba(40, 30, 80, 0.4),
        0 8px 16px rgba(40, 30, 80, 0.3),
        0 4px 8px rgba(102, 126, 234, 0.2);
}

/* Active/Used Region Card - Highlighted */
.region-card.active {
    background: linear-gradient(135deg, rgba(245, 245, 255, 0.95) 0%, rgba(235, 235, 250, 0.95) 100%);
    border: 1px solid rgba(102, 126, 234, 0.5);
    box-shadow:
        0 10px 20px rgba(102, 126, 234, 0.4),
        0 6px 12px rgba(102, 126, 234, 0.3),
        0 3px 6px rgba(102, 126, 234, 0.2),
        0 1px 3px rgba(102, 126, 234, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 0 10px rgba(118, 75, 162, 0.2);
}

.region-card.active:hover {
    box-shadow:
        0 12px 24px rgba(102, 126, 234, 0.5),
        0 8px 16px rgba(102, 126, 234, 0.4),
        0 4px 8px rgba(102, 126, 234, 0.3),
        0 0 15px rgba(118, 75, 162, 0.3);
}

/* Region Header Bar - Metallic grey */
.region-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    background: linear-gradient(135deg, 
        rgba(200, 200, 200, 0.7) 0%,
        rgba(180, 180, 180, 0.7) 50%,
        rgba(170, 170, 170, 0.7) 100%
    );
    border-top: 1px solid rgba(240, 240, 240, 0.8);
    border-bottom: 1px solid rgba(140, 140, 140, 0.4);
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.6),
        inset 0 -1px 1px rgba(0, 0, 0, 0.1),
        0 1px 1px rgba(0, 0, 0, 0.1);
    transition: background 0.2s;
    font-size: 1em;
}

.region-header:hover {
    background: linear-gradient(135deg, 
        rgba(210, 210, 210, 0.8) 0%,
        rgba(190, 190, 190, 0.8) 50%,
        rgba(180, 180, 180, 0.8) 100%
    );
}

.region-header.expanded {
    background: linear-gradient(135deg, 
        rgba(220, 220, 220, 0.85) 0%,
        rgba(200, 200, 200, 0.85) 50%,
        rgba(190, 190, 190, 0.85) 100%
    );
    border-bottom-color: rgba(150, 150, 150, 0.5);
}

/* Active region header - slightly brighter metallic */
.region-card.active .region-header {
    background: linear-gradient(135deg, 
        rgba(230, 230, 230, 0.8) 0%,
        rgba(210, 210, 210, 0.8) 50%,
        rgba(200, 200, 200, 0.8) 100%
    );
    border-bottom-color: rgba(160, 160, 160, 0.5);
}

.region-card.active .region-header:hover {
    background: linear-gradient(135deg, 
        rgba(240, 240, 240, 0.85) 0%,
        rgba(220, 220, 220, 0.85) 50%,
        rgba(210, 210, 210, 0.85) 100%
    );
}

.region-card.active .region-header.expanded {
    background: linear-gradient(135deg, 
        rgba(235, 235, 235, 0.9) 0%,
        rgba(215, 215, 215, 0.9) 50%,
        rgba(205, 205, 205, 0.9) 100%
    );
    border-bottom-color: rgba(170, 170, 170, 0.6);
}

.region-header:not(.expanded) {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.region-card .zoom-btn {
    width: 32px;
    height: 24px;
    border-radius: 4px;
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    margin-right: 6px;
    transition: all 0.2s;
}

.region-card .zoom-btn:hover {
    background: linear-gradient(135deg, #42A5F5 0%, #1976D2 100%);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.region-card .zoom-btn:active {
    transform: translateY(0px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 0 2px rgba(0, 0, 0, 0.2);
}

.region-card .zoom-btn.return-mode {
    background: linear-gradient(135deg, #ff8c00 0%, #ff6600 100%);
}

.region-card .zoom-btn.return-mode:hover {
    background: linear-gradient(135deg, #ff9d1a 0%, #ff7700 100%);
    box-shadow: 
        0 4px 8px rgba(255, 140, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.region-card .play-btn {
    width: 32px;
    height: 24px;
    border-radius: 4px;
    background: linear-gradient(135deg, #d32f3f 0%, #a01d2a 100%);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    color: white;
    font-size: 0.75em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
    min-height: auto;
    line-height: normal;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.region-card .play-btn:hover {
    background: linear-gradient(135deg, #e6394a 0%, #b01f2e 100%);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.region-card .play-btn:active {
    transform: translateY(0px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 0 2px rgba(0, 0, 0, 0.2);
}

.region-card .play-btn.playing {
    background: linear-gradient(145deg, #34ce57, #1e7e34);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.region-summary {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.9em;
    color: #333;
}

.region-label {
    font-weight: 700;
    color: #222;
    margin-right: 20px;
    font-size: 1em;
}

.region-card.active .region-label {
    color: #c82333;
    font-weight: 700;
    font-size: 1.05em;
}

.features-count-text {
    font-weight: 600;
    color: #222;
    margin-right: 30px;
    font-size: 1em;
}

.region-time-display {
    display: flex;
    align-items: center;
    gap: 30px;
    color: #222;
    font-size: 1.15em;
    font-weight: 600;
}

.region-description-preview {
    color: #444;
    font-size: 1em;
    font-style: italic;
    font-weight: 500;
    margin-left: 20px;
    max-width: 600px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-label {
    font-weight: 600;
    color: #444;
    margin-right: 4px;
    font-size: 1em;
}

.time-value {
    font-family: 'Monaco', 'Menlo', monospace;
    color: #222;
    font-size: 1em;
    font-weight: 600;
}

.collapse-icon {
    font-size: 1.2em;
    color: #c82333;
    margin-right: 20px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.collapse-icon:hover {
    color: #bd2130;
}

.region-header.expanded .collapse-icon {
    transform: rotate(180deg);
}

.delete-region-btn {
    background: linear-gradient(135deg, #c82333 0%, #a01d2a 100%);
    color: white;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.2s;
    margin-left: 20px;
    flex-shrink: 0;
    height: auto;
    line-height: normal;
    min-height: auto;
    box-shadow: 
        0 3px 6px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.delete-region-btn:hover {
    background: linear-gradient(135deg, #d32f3f 0%, #b01f2e 100%);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.delete-region-btn:active {
    transform: translateY(0px);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Delete Feature Button (inline with feature rows) */
.delete-feature-btn-inline {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) !important;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #dc3545 !important;
    border: none !important;
    color: white;
    font-size: 0.7em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none !important;
    padding: 0;
    line-height: 1;
    box-shadow: none !important;
}

.delete-feature-btn-inline:hover {
    background: #c82333 !important;
    transform: translateY(-50%) !important;
    box-shadow: none !important;
}

.delete-feature-btn-inline:active {
    transform: translateY(-50%) !important;
    box-shadow: none !important;
}

.delete-feature-btn-inline.disabled {
    background: #ccc !important;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none !important;
    transform: translateY(-50%) !important;
}

.delete-feature-btn-inline.disabled:hover {
    transform: translateY(-50%) !important;
    background: #ccc !important;
    box-shadow: none !important;
}

/* Add Feature Row */
.add-feature-row {
    background: transparent;
    padding: 1px 10px 1px 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    position: relative;
    min-height: 28px;
    margin-top: 2px;
}

.add-feature-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #5cb85c !important;
    border: none !important;
    color: white;
    font-size: 0.85em;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
    min-height: auto;
    box-shadow: none !important;
}

.add-feature-btn:hover {
    background: #4cae4c !important;
    transform: scale(1.15) !important;
    box-shadow: none !important;
}

.add-feature-btn:active {
    transform: scale(0.9) !important;
    box-shadow: none !important;
}

.add-feature-btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none !important;
}

.add-feature-btn:disabled:hover {
    transform: none !important;
    background: #ccc !important;
    box-shadow: none !important;
}

.add-feature-label {
    margin-left: 8px;
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.add-feature-label:hover {
    color: #333;
}

.add-feature-label.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.add-feature-label.disabled:hover {
    color: #666;
}

/* Region Details */
.region-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.region-card.active .region-details {
    background: rgba(255, 250, 250, 0.98);
}

.region-details.expanded {
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.details-content {
    padding: 9px 12px 3px 12px;
    font-size: 0.95em;
    color: #222;
}

/* Features List */
.features-list {
    display: flex;
    flex-direction: column;
    gap: 3pt;
}

.features-container {
    display: flex;
    flex-direction: column;
    gap: 3pt;
}

.feature-row {
    background: #e8e8e8;
    padding: 4px 10px 4px 120px;
    border-radius: 4px;
    border-left: 3px solid #c82333;
    display: grid;
    /* 2 columns: button + textarea (dropdowns are hidden) */
    grid-template-columns: 240px 1fr;
    gap: 8px;
    align-items: stretch;
    position: relative;
    min-height: 36px;
}

.feature-number {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: #222;
    font-size: 1em;
    width: 80px;
    text-align: left;
}

.feature-row:nth-child(odd) {
    background: #f5f5f5;
}

.feature-row:nth-child(even) {
    background: #d5d5d5;
}

.region-card.active .feature-row {
    border-left-color: #ff4444;
}

.region-card.active .feature-row:nth-child(odd) {
    background: #f8f8f8;
}

.region-card.active .feature-row:nth-child(even) {
    background: #e0e0e0;
}

.feature-row select,
.feature-row input[type="text"],
.feature-row textarea {
    padding: 4px 6px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    font-size: 0.95em !important;
    font-family: inherit !important;
    transition: border-color 0.2s !important;
    height: 28px !important;
    line-height: 1.2 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    opacity: 0.9 !important;
}

.feature-row select:focus,
.feature-row input[type="text"]:focus,
.feature-row textarea:focus {
    outline: none !important;
    border-color: #c82333 !important;
    box-shadow: none !important;
    background: white !important;
}

textarea.freq-input {
    resize: none;
    overflow-x: auto;
    overflow-y: hidden;
    height: 28px;
    line-height: 1.2;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

textarea.freq-input::-webkit-scrollbar {
    display: none;
}

.freq-input {
    width: 100%;
}

.freq-input.pulse {
    animation: pulseReceipt 0.6s ease-out;
}

.freq-input.pulse-long {
    animation: pulseReceipt 1.2s ease-out;
}

@keyframes pulseReceipt {
    0% {
        background-color: #fff;
        border-color: #c82333;
    }
    50% {
        background-color: #ffe8e8;
        border-color: #c82333;
        box-shadow: 0 0 10px rgba(200, 35, 51, 0.5);
    }
    100% {
        background-color: #fff;
        border-color: #e0e0e0;
    }
}

/* Select Button */
.select-freq-btn {
    padding: 6px 12px;
    border: 1px solid #c82333;
    border-radius: 4px;
    background: white;
    color: #c82333;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: auto;
    line-height: normal;
}

.select-freq-btn:hover {
    background: #c82333;
    color: white;
}

.select-freq-btn.active {
    background: #c82333 !important;
    color: white !important;
    border-color: #c82333 !important;
    animation: subtleGlow 1.2s ease-in-out infinite !important;
}

.select-freq-btn.pulse:not(.active) {
    animation: pulseButton 1.5s ease-in-out infinite;
}

.select-freq-btn.completed {
    background: white;
    color: #333;
    border-color: #ccc;
    font-weight: 500;
    font-style: normal;
}

.select-freq-btn.completed:hover {
    background: #f5f5f5;
    color: #666;
    border-color: #999;
}

.select-freq-btn.pulse {
    animation: simplePulse 0.25s ease-out !important;
}

.select-freq-btn.expand-shadow {
    animation: expandShadow 0.3s ease-out !important;
}

.select-freq-btn.disabled {
    background: #f5f5f5 !important;
    color: #555 !important;
    border-color: #ddd !important;
    cursor: not-allowed !important;
    opacity: 1;
}

.select-freq-btn.disabled:hover {
    background: #f5f5f5 !important;
    color: #555 !important;
    border-color: #ddd !important;
}

@keyframes expandShadow {
    0% {
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(200, 35, 51, 0.8), 0 0 0 6px rgba(200, 35, 51, 0.4);
    }
    100% {
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
}

@keyframes simplePulse {
    0% {
        background-color: #c82333 !important;
        color: white !important;
        border-color: #c82333 !important;
        box-shadow: 0 0 15px rgba(200, 35, 51, 0.5);
    }
    25% {
        background-color: #ff9999 !important;
        color: white !important;
        border-color: #ff5555 !important;
        box-shadow: 0 0 18px rgba(255, 70, 70, 0.6);
    }
    60% {
        background-color: #ffcccc !important;
        color: #c82333 !important;
        border-color: #ff7777 !important;
        box-shadow: 0 0 15px rgba(255, 100, 100, 0.4);
    }
    100% {
        background-color: white !important;
        color: #333 !important;
        border-color: #ccc !important;
        box-shadow: 0 0 0 rgba(255, 0, 0, 0);
    }
}

@keyframes subtleGlow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(200, 35, 51, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(200, 35, 51, 0.8);
    }
}

@keyframes waveformPulse {
    0%, 100% {
        border-color: rgba(80, 40, 40, 0.6);
        box-shadow: 0 0 0 rgba(200, 150, 150, 0);
    }
    50% {
        border-color: rgba(200, 100, 100, 0.8);
        box-shadow: 0 0 15px rgba(200, 120, 120, 0.4), 0 0 25px rgba(180, 100, 100, 0.3);
    }
}

#minimap.pulse {
    animation: waveformPulse 1.2s ease-in-out infinite !important;
    border-radius: 2px;
    border-width: 2px !important;
    border-style: solid !important;
}

/* Sticky status animations - zen parallax glide */
@keyframes slideDownGentle {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUpGentle {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.sticky-status-container {
    font-size: 15px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tutorial overlay */
.tutorial-click-me {
    font-size: 28px;
    font-weight: 900;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.tutorial-click-me.visible {
    opacity: 1;
    animation: tutorialGlow 1.2s ease-in-out infinite;
}

@keyframes tutorialGlow {
    0%, 100% {
        color: #cc5500;
        text-shadow: 
            0 0 10px rgba(204, 85, 0, 0.8),
            0 0 20px rgba(204, 85, 0, 0.6),
            0 0 30px rgba(204, 85, 0, 0.4),
            0 0 40px rgba(220, 110, 0, 0.3);
        filter: hue-rotate(0deg);
    }
    50% {
        color: #dd6600;
        text-shadow: 
            0 0 20px rgba(221, 102, 0, 0.9),
            0 0 30px rgba(221, 102, 0, 0.7),
            0 0 40px rgba(230, 130, 0, 0.6),
            0 0 50px rgba(230, 150, 0, 0.5);
        filter: hue-rotate(5deg);
    }
}

/* Volcano selector pulsing glow */
#volcano.pulse-glow {
    animation: volcanoPulseGlow 1.2s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes volcanoPulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 rgba(200, 100, 100, 0);
        border-color: rgba(80, 40, 40, 0.6);
    }
    50% {
        box-shadow: 0 0 15px rgba(200, 120, 120, 0.4), 0 0 25px rgba(180, 100, 100, 0.3);
        border-color: rgba(200, 100, 100, 0.8);
    }
}

/* Disabled slider styles */
input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes pulseButton {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        background: white;
        color: #c82333;
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
        background: #fff5f5;
        color: #c82333;
        border-color: #e85d5d;
        box-shadow: 0 0 8px rgba(200, 35, 51, 0.3);
    }
}

.frequency-display {
    grid-column: span 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    color: #999;
    font-style: italic;
    font-size: 0.85em;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    max-width: 160px;
    min-width: 120px;
}

.frequency-display.selected {
    color: #333;
    font-style: normal;
    font-weight: 500;
}

.frequency-display.pulse {
    animation: pulseFrequencyDisplay 0.8s ease-out;
}

.notes-field.pulse {
    animation: pulseNotesField 0.8s ease-out;
}

@keyframes pulseFrequencyDisplay {
    0% {
        background-color: white;
        border-color: #c82333;
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
    50% {
        background-color: #ffcccc;
        border-color: #ff0000;
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
    }
    100% {
        background-color: white;
        border-color: #c82333;
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
}

@keyframes pulseNotesField {
    0% {
        background-color: white;
        border-color: #e0e0e0;
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
    }
    50% {
        background-color: #fff5f5;
        border-color: #ffaaaa;
        box-shadow: 0 0 20px rgba(200, 35, 51, 0.8), 0 0 10px rgba(200, 35, 51, 0.5);
        transform: scale(1.005);
    }
    100% {
        background-color: white;
        border-color: #e0e0e0;
        box-shadow: 0 0 0 rgba(200, 35, 51, 0);
        transform: scale(1);
    }
}

/* Region Highlight on Waveform */
.region-highlight {
    position: absolute;
    top: 0;
    height: 135px;
    background: rgba(68, 136, 255, 0.2);
    border-left: 2px solid rgba(68, 136, 255, 0.6);
    border-right: 2px solid rgba(68, 136, 255, 0.6);
    pointer-events: none;
    transition: opacity 0.2s;
}

.region-highlight.active {
    background: rgba(68, 136, 255, 0.5);
    border-left-color: rgba(68, 136, 255, 0.9);
    border-right-color: rgba(68, 136, 255, 0.9);
}

/* Selection Box for Waveform and Spectrogram */
.selection-box {
    position: absolute;
    top: 0;
    background: rgba(255, 255, 0, 0.2);
    border-left: 2px solid rgba(255, 200, 0, 0.8);
    border-right: 2px solid rgba(255, 200, 0, 0.8);
    pointer-events: none;
}

/* TEST TRIANGLE */
.test-triangle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
    border-top: 150px solid #0056b3;
    z-index: 99999;
    cursor: pointer;
}

.test-triangle:hover {
    border-top: 150px solid orange;
}

/* Add Region Button */
.add-region-button {
    position: absolute;
    padding: 9px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    height: auto;
    display: inline-block;
    align-items: unset;
    justify-content: unset;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.4);
    z-index: 10000;
    white-space: nowrap;
    opacity: 0;
    transition: background 0.2s, box-shadow 0.2s;
}

.add-region-button:hover {
    background: #ff8c00;
    box-shadow: 0 4px 12px rgba(255, 140, 0, 0.6);
}

.add-region-button::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #0056b3;
    cursor: pointer;
}

.add-region-button:hover::after {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #b35900;
}

/* Complete Button — JS animate() handles grey↔blue, CSS just defines states */
#completeBtn {
    margin-left: auto;
    background: #0056b3 !important;
    border-color: #0056b3 !important;
    filter: grayscale(100%);
    opacity: 0.7;
    pointer-events: auto;
    cursor: not-allowed;
    white-space: nowrap;
    flex-shrink: 0;
}

#completeBtn.ready {
    pointer-events: auto;
    cursor: pointer;
    animation: subtle-sparkle 3s ease-in-out infinite;
    position: relative;
}

/* Participant ID text box - dark background theme */
#participantIdText {
    background: rgba(40, 40, 40, 0.4) !important;
    border: 1px solid rgba(100, 100, 100, 0.6) !important;
    color: #aaa !important;
}

#participantIdText:hover {
    background: rgba(80, 50, 50, 0.6) !important;
}

#participantIdValue {
    color: #bbb !important;
}

#completeBtn.ready:hover {
    background: #004085 !important;
    border-color: #004085 !important;
}

#completeBtn.ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    animation: sparkle-sweep 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes subtle-sparkle {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 0 4px rgba(0, 123, 255, 0.3);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 0 8px rgba(0, 123, 255, 0.5), 0 0 12px rgba(0, 123, 255, 0.2);
        filter: brightness(1.15);
    }
}

@keyframes sparkle-sweep {
    0% {
        transform: translateX(-40%);
        opacity: 0;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        transform: translateX(80%);
        opacity: 0;
    }
}

/* ===== MOBILE RESPONSIVE STYLES ===== */

/* Mobile: Wrap top header content */
/* Portrait phones + Landscape phones (detected by short height) */
@media (max-width: 768px), (max-height: 500px) {
    /* Fix white bars in landscape - reduce padding and ensure full width */
    html, body {
        overflow-x: hidden;
        overflow-y: auto !important; /* Allow vertical scrolling */
    }

    body {
        padding-top: 4px !important;
        padding-left: 10px;
        padding-right: 10px;
        padding-bottom: 10px !important;
        /* Safe area insets for notched devices */
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        min-height: 100vh;
        height: auto !important;
    }

    .container {
        max-width: 100%;
        overflow: visible;
    }

    .top-header-bar {
        flex-wrap: wrap !important;
        gap: 8px;
        align-items: center !important;
    }

    /* Title takes full width on mobile, centered */
    .top-header-bar > h1 {
        order: -1;
        flex: 1 0 100% !important;
        text-align: center;
        font-size: 1.2em !important;
        margin-bottom: 2px;
    }

    /* User info goes under title, centered */
    .top-header-bar > div:last-child {
        order: 0;
        flex: 1 0 100% !important;
        justify-content: center !important;
        margin-bottom: 4px;
    }

    /* Mode selector at the bottom */
    .top-header-bar > #modeSelectorContainer {
        order: 1;
        flex: 1 1 auto !important;
        justify-content: center;
    }

    /* Make controls panels wrap better */
    .controls {
        gap: 10px;
    }

    .controls-row-1 {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Override inline min-width on control groups to allow wrapping */
    .controls-row-1 > .control-group {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    /* Make dropdowns fit mobile width */
    .controls-row-1 select {
        width: auto !important;
        min-width: 100px !important;
        max-width: 100%;
    }

    /* Smaller padding on panels */
    .panel-selection,
    .panel-playback {
        padding: 8px 12px;
    }

    /* Minimap needs touch-action: none to capture horizontal drags for seeking */
    #minimap {
        min-height: 100px;
        touch-action: none; /* JS handles all touch - needed for horizontal seek/select */
    }

    /* Spectrogram: default to scroll, JS toggles to .touch-draw when zoomed in */
    #spectrogram {
        touch-action: pan-y;
    }
    #spectrogram.touch-draw {
        touch-action: none; /* Allow box drawing when zoomed into region */
    }

    /* Fix controls row - force ALL children to wrap */
    .panel-selection .controls,
    .panel-selection .controls > * {
        flex-wrap: wrap !important;
    }

    /* Date/time row needs to wrap too */
    .panel-selection .control-group[style*="width: 100%"] {
        flex-wrap: wrap !important;
    }

    /* All control groups in selection panel */
    .panel-selection .control-group {
        min-width: 0 !important;
        flex-wrap: wrap !important;
    }

    /* Make inputs and selects smaller on mobile */
    /* IMPORTANT: font-size must be 16px+ to prevent iOS Safari auto-zoom on focus */
    .panel-selection select,
    .panel-selection input[type="date"],
    .panel-selection input[type="text"] {
        width: auto !important;
        min-width: 80px !important;
        max-width: 150px !important;
        font-size: 16px !important;
        padding: 6px 8px !important;
    }

    /* All inputs/selects need 16px+ to prevent iOS zoom */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Fetch button should be visible */
    #startBtn {
        min-width: 100px !important;
        width: auto !important;
        margin-left: 0 !important;
        margin-top: 8px;
    }

    /* Allow vertical scrolling when touching any interactive element */
    button,
    select,
    input,
    label,
    .control-group,
    .panel,
    .controls,
    .region-card,
    [type="range"],
    #minimap-axis,
    #minimap-x-axis,
    #spectrogram-axis,
    #spectrogram-x-axis {
        touch-action: pan-y;
    }

    /* Wrap visualization panel controls (FFT, Color Map, Frequency Scale) */
    .panel-visualization > div {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Wrap playback panel controls */
    .panel-playback > div {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .panel-playback button {
        min-width: 100px !important;
        width: auto !important;
    }

    /* FFT / Color Map / Frequency Scale controls - wrap on mobile */
    .viz-controls {
        flex-wrap: wrap !important;
        gap: 8px !important;
        margin-left: 0 !important;
        justify-content: flex-start !important;
    }

    /* Download buttons - static row below regions on mobile */
    #downloadAudioContainer {
        position: static !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        margin-top: 12px !important;
        padding-top: 12px !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
    }

    #downloadAudioContainer button {
        white-space: normal !important;
        font-size: 12px !important;
        padding: 8px 12px !important;
        height: auto !important;
    }

    /* Share modal - compact for mobile */
    #shareModal > div {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    #shareModalBody {
        padding: 12px !important;
    }

    #shareFormView > div {
        margin-bottom: 10px !important;
    }

    #shareFormView label {
        margin-bottom: 4px !important;
        font-size: 12px !important;
    }

    #shareFormView input,
    #shareFormView textarea {
        padding: 8px 10px !important;
        /* font-size handled by global 16px rule to prevent iOS zoom */
    }

    #shareFormView textarea {
        min-height: 40px !important;
    }

    #thumbnailPreview {
        max-height: 150px !important;
        overflow: hidden !important;
    }

    #shareThumbnail {
        max-height: 150px !important;
        object-fit: contain !important;
    }

    #emojiPicker button {
        width: 28px !important;
        height: 28px !important;
        font-size: 16px !important;
    }
}

/* Hide repetition and type dropdowns in feature rows (keep only comment box) */
.feature-row select[id^="repetition-"],
.feature-row select[id^="type-"] {
    display: none !important;
}

/* Mobile tap hint animation */
@keyframes pulse-hint {
    0%, 100% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* ─── Hamburger Button & Settings Drawer ─── */
.hamburger-btn {
    display: none; /* shown by Advanced mode */
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 1100;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s, left 0.25s ease;
}
.hamburger-btn:hover {
    color: #ddd;
    background: rgba(255, 255, 255, 0.08);
}

.settings-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100%;
    background: #1e1e1e;
    border-right: 1px solid #444;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    font-size: 13px;
    color: #ddd;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.settings-drawer:hover {
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.settings-drawer::-webkit-scrollbar {
    width: 5px;
}
.settings-drawer::-webkit-scrollbar-track {
    background: transparent;
}
.settings-drawer::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}
.settings-drawer:hover::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
}
.settings-drawer.open { transform: translateX(0); }

.container {
    transition: margin-left 0.25s ease;
}
body.drawer-open {
    overflow: hidden;
}
body.drawer-open .container {
    margin-left: 260px;
}
body.drawer-open .hamburger-btn {
    left: 260px;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #333;
}
.drawer-title {
    font-size: 16px;
    font-weight: 600;
    color: #eee;
}
.drawer-close {
    font-size: 22px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
    user-select: none;
}
.drawer-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.drawer-section {
    padding: 16px 16px;
    border-bottom: 1px solid #444;
}
.drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.drawer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
}

/* Slider rows: keep value box snug to the range bar */
.drawer-row.drawer-slider-row {
    justify-content: flex-start;
    gap: 4px;
}
.drawer-row.drawer-slider-row input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}
.drawer-slider-value {
    min-width: 34px;
    text-align: right;
    font-size: 12px;
    color: #aaa;
    margin-left: 0;
    font-variant-numeric: tabular-nums;
}
.drawer-label {
    font-size: 13px;
    font-weight: 500;
    color: #bbb;
    cursor: pointer;
    user-select: none;
}
.drawer-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #80d0ff;
}
/* After CustomSelect upgrades a <select>, hide the native element */
select.csel-native {
    display: none;
}

/* ─── Custom Dropdown (csel) ─── */
.csel {
    position: relative;
    display: inline-block;
    min-width: 70px;
}
.csel-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #353545;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 8px;
    color: #d8d8d8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    user-select: none;
    min-height: 28px;
}
.csel-label {
    overflow: hidden;
    text-overflow: ellipsis;
}
.csel-trigger:hover {
    border-color: #777;
    background: #3e3e50;
}
.csel-trigger:focus-visible {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.csel.open .csel-trigger {
    border-color: var(--accent-color);
}
.csel-arrow {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #888;
    transition: transform 0.15s;
}
.csel.open .csel-arrow {
    transform: rotate(180deg);
}
.csel-menu {
    position: fixed;
    max-height: 280px;
    overflow-y: auto;
    background: #2c2c3c;
    border: 1px solid var(--accent-border);
    border-radius: 5px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    z-index: 99999;
    padding: 4px 0;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
.csel-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.csel-option {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    color: #bbb;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    white-space: nowrap;
    border-left: 2px solid transparent;
}
.csel-option:hover,
.csel-option.highlighted {
    background: var(--accent-soft);
    color: #ddd;
}
.csel-option.selected {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
}
.csel-option.selected.highlighted {
    background: rgba(var(--accent-rgb), 0.15);
}
.csel-group-label {
    padding: 6px 10px 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #666;
    pointer-events: none;
    user-select: none;
}
.csel-group-label:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid #333;
    padding-top: 8px;
}
.csel-menu::-webkit-scrollbar {
    width: 6px;
}
.csel-menu::-webkit-scrollbar-track {
    background: transparent;
}
.csel-menu::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* ─── Number Spinner ─── */
.drawer-spinner {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #555;
    border-radius: 4px;
    overflow: hidden;
    background: #2a2a2a;
}
.spinner-btn {
    width: 26px;
    height: 28px;
    background: #3a3a3a;
    color: #aaa;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    line-height: 1;
    border-radius: 0;
}
.spinner-btn:hover {
    background: #4a4a4a;
    color: #ddd;
}
.spinner-btn:active {
    background: #555;
}
.spinner-value {
    width: 52px;
    height: 28px;
    background: #2a2a2a;
    color: #ddd;
    border: none;
    border-left: 1px solid #444;
    border-right: 1px solid #444;
    font-size: 13px;
    font-family: monospace;
    text-align: center;
    padding: 0;
    outline: none;
}
.spinner-value:focus {
    background: #333;
}

/* ─── EMIC / Study Buttons ─── */
.emic-btn-group,
.study-btn-group {
    display: flex;
    gap: 4px;
    align-items: center;
}
.emic-btn-group label,
.study-btn-group label {
    font-size: var(--panel-label-size, 15px);
    font-weight: 600;
    color: #444;
    margin-right: 4px;
    white-space: nowrap;
}
.emic-btn,
.study-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #555;
    background: rgba(60, 60, 60, 0.9);
    color: #ccc;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    height: 38px;
    line-height: 20px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.emic-btn:hover:not(:disabled),
.study-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(102, 126, 234, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, #7a8ef0 0%, #8a5fb5 100%);
    color: #fff;
}
.emic-btn.active,
.study-btn.active {
    background: rgba(102, 126, 234, 0.8);
    border-color: rgba(102, 126, 234, 0.9);
    color: #fff;
}

/* ─── Panel Gear Icons & Popovers ─── */
.panel-gear {
    position: absolute;
    z-index: 30;
    display: none; /* shown + positioned via JS in EMIC mode */
}

.gear-btn {
    color: rgba(255, 255, 255, 0.45);
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
    user-select: none;
}

.gear-btn:hover {
    color: rgba(255, 255, 255, 0.85);
}

.gear-popover {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background: rgba(30, 30, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px 14px;
    min-width: 240px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 31;
}

.gear-popover.open {
    display: block;
}

.gear-popover-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    text-align: center;
    user-select: none;
}

.gear-popover-row + .gear-popover-title {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.gear-popover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.gear-popover-row:last-child {
    margin-bottom: 0;
}

.gear-label {
    font-size: 13px;
    font-weight: 600;
    color: #ccc;
    white-space: nowrap;
    user-select: none;
    min-width: 62px;
    text-align: right;
}

.gear-select {
    padding: 3px 6px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #555;
    background: #3c3c3c;
    color: #ddd;
    color-scheme: dark;
    cursor: pointer;
    flex: 1;
}
.gear-select:focus,
.gear-select:focus-visible {
    outline: none !important;
    border-color: #555 !important;
    box-shadow: none !important;
    background: #3c3c3c;
    color: #ddd;
    -webkit-focus-ring-color: transparent;
}
.gear-select option {
    background: #3c3c3c;
    color: #ddd;
}

.gear-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #80d0ff;
}

/* ── Feature Info Popup (windowed mode) ── */
.feature-popup {
    position: fixed;
    z-index: 2000;
    background: #2b2b3a;
    border: 1.5px solid rgba(128, 128, 128, 0.45);
    border-radius: 8px;
    padding: 14px 16px;
    min-width: 475px;
    max-width: 575px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 24px rgba(128, 128, 128, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #ddd;
    animation: featurePopupFadeIn 150ms ease-out;
}
/* Pinned popup: smooth position tracking + off-screen hide */
.feature-popup {
    transition: opacity 250ms ease;
}
.feature-popup--off-screen {
    opacity: 0;
    pointer-events: none;
}

@keyframes featurePopupFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.feature-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -14px -16px 10px -16px;
    padding: 8px 12px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.25);
    cursor: grab;
    user-select: none;
}
.feature-popup-header:active {
    cursor: grabbing;
}
.feature-popup--pinned .feature-popup-header,
.feature-popup--pinned .feature-popup-header:active {
    cursor: default;
}
.feature-popup-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
}
.feature-popup-play {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: 0;
    outline: 0;
    box-shadow: none;
    color: #3a9070;
    font-size: 21px;
    cursor: pointer;
    width: 26px;
    height: 26px;
    padding: 0;
    margin-left: 4px;
    line-height: 26px;
    text-align: center;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s, transform 0.15s;
}
.feature-popup-play:focus,
.feature-popup-play:focus-visible {
    outline: 0;
    box-shadow: none;
}
.feature-popup-play:hover {
    color: #4cb88a;
    transform: none;
}
.feature-popup-play:active {
    transform: none;
}
.feature-popup-isolate {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    outline: 0;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 2px 7px;
    margin-left: 6px;
    border-radius: 3px;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.feature-popup-isolate:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.25);
}
.feature-popup-isolate.active {
    background: rgba(58, 144, 112, 0.35);
    color: #4cb88a;
    border-color: rgba(76, 184, 138, 0.5);
}
.feature-popup-isolate.active:hover {
    background: rgba(58, 144, 112, 0.45);
}
.feature-popup-close {
    background: none;
    border: none;
    color: rgba(210, 210, 210, 0.75);
    font-size: 24px;
    font-weight: 300;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: color 150ms;
}
.feature-popup-close:hover {
    color: rgba(255, 255, 255, 0.9);
    background: none !important;
    box-shadow: none !important;
    transform: none !important;
}
.feature-popup-delete {
    background: none;
    border: none;
    color: rgba(210, 210, 210, 0.75);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: color 150ms, background-color 150ms;
}
.feature-popup-delete:hover {
    color: #fff !important;
    background: #d03030 !important;
    box-shadow: none !important;
    transform: none !important;
}
.feature-popup-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.feature-popup-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.feature-popup-field label {
    font-size: 9px;
    text-transform: uppercase;
    color: rgba(160, 170, 180, 0.8);
    letter-spacing: 0.5px;
}
.feature-popup-field input {
    background: rgba(128, 128, 128, 0.06);
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    padding: 5px 8px;
    font-size: 13px;
    font-family: 'SF Mono', 'Consolas', monospace;
    outline: none;
    transition: border-color 150ms, color 150ms, background 150ms;
}
.feature-popup-field input:focus {
    border-color: #808080;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(128, 128, 128, 0.08);
}
.feature-popup-notes {
    width: 100%;
    min-height: 100px;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 4px;
    color: #eee;
    padding: 8px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: vertical;
    outline: none;
    transition: border-color 150ms;
    box-sizing: border-box;
}
.feature-popup-notes:focus {
    border-color: #808080;
}
.feature-popup-notes::placeholder {
    color: #666;
    font-style: italic;
}
.feature-popup-save {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms;
}
.feature-popup-save:hover:not(:disabled) {
    background: linear-gradient(135deg, #7a8ef0 0%, #8a5fb5 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    filter: none;
}
.feature-popup-save:disabled {
    background: rgba(128, 128, 128, 0.12);
    color: #666;
    cursor: default;
    filter: none;
}

/* ── Confidence pills ── */
.feature-popup-confidence {
    margin-bottom: 10px;
}
.feature-popup-confidence-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #ddd;
    margin-bottom: 8px;
}
.feature-popup-pills {
    display: flex;
    gap: 8px;
}
.feature-popup-pill {
    padding: 6px 0;
    min-width: 80px;
    border: 1.5px solid rgba(128, 128, 128, 0.35);
    border-radius: 20px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 150ms, border-color 150ms, color 150ms;
}
.feature-popup-pill:hover {
    border-color: rgba(128, 128, 128, 0.6);
    color: rgba(255, 255, 255, 0.85);
}
.feature-popup-pill.active {
    background: rgba(110, 110, 110, 0.55);
    border-color: rgba(160, 160, 160, 0.5);
    color: #fff;
}

/* ── Expandable details ── */
.feature-popup-details {
    margin-top: 6px;
    margin-bottom: 2px;
}
.feature-popup-details summary {
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    user-select: none;
    padding: 4px 0;
    list-style: none;
}
.feature-popup-details summary::before {
    content: '▶ ';
    font-size: 9px;
    display: inline-block;
    transition: transform 200ms ease;
}
.feature-popup-details[open] summary::before {
    transform: rotate(90deg);
}
.feature-popup-details summary::-webkit-details-marker {
    display: none;
}
.feature-popup-details .feature-popup-details-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 250ms ease, opacity 250ms ease;
    opacity: 0;
}
.feature-popup-details[open] .feature-popup-details-content {
    grid-template-rows: 1fr;
    opacity: 1;
}
.feature-popup-details .feature-popup-details-inner {
    overflow: hidden;
}
.feature-popup-details[open] .feature-popup-row {
    margin-top: 8px;
}

/* Header buttons wrapper */
.feature-popup-header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Gear button – matches canvas .gear-btn style */
.feature-popup-gear {
    color: rgba(210, 210, 210, 0.75);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.feature-popup-gear:hover {
    color: #808080;
}

/* Settings panel – slides open/closed */
.feature-popup-settings {
    margin: -4px -16px 10px -16px;
    padding: 0 12px;
    background: rgba(128, 128, 128, 0.06);
    border-bottom: 1px solid rgba(128, 128, 128, 0.12);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 250ms ease, padding 250ms ease, opacity 200ms ease;
}
.feature-popup-settings.open {
    max-height: 160px;
    padding: 8px 12px;
    opacity: 1;
}
.feature-popup-settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}
.feature-popup-settings-row:last-child {
    margin-bottom: 0;
}
.feature-popup-settings-label {
    font-size: 10px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.5px;
    min-width: 42px;
}
.feature-popup-settings-options {
    display: flex;
    gap: 4px;
}
.feature-popup-settings-options button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 150ms;
    height: auto;
    line-height: 1.3;
    min-width: 0;
    box-shadow: none;
    font-weight: 400;
    text-shadow: none;
}
.feature-popup-settings-options button:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}
.feature-popup-settings-options button.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(128, 128, 128, 0.35);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* ── Dark on Light variant ── */
.feature-popup--dark-on-light {
    background: #f4f3f7;
    border-color: rgba(128, 128, 128, 0.35);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 20px rgba(128, 128, 128, 0.1);
    color: #222;
}
.feature-popup--dark-on-light .feature-popup-header {
    background: rgba(128, 128, 128, 0.12);
    border-bottom-color: rgba(128, 128, 128, 0.15);
}
.feature-popup--dark-on-light .feature-popup-title {
    color: #808080;
    filter: brightness(0.75);
}
.feature-popup--dark-on-light .feature-popup-close,
.feature-popup--dark-on-light .feature-popup-gear,
.feature-popup--dark-on-light .feature-popup-delete {
    color: rgba(128, 128, 128, 0.45);
}
.feature-popup--dark-on-light .feature-popup-close:hover,
.feature-popup--dark-on-light .feature-popup-gear:hover {
    color: rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.1) !important;
}
.feature-popup--dark-on-light .feature-popup-delete:hover {
    color: #fff !important;
    background: #d03030 !important;
    box-shadow: none !important;
    transform: none !important;
}
.feature-popup--dark-on-light .feature-popup-settings {
    background: rgba(128, 128, 128, 0.06);
    border-bottom-color: rgba(128, 128, 128, 0.1);
}
.feature-popup--dark-on-light .feature-popup-settings-label {
    color: rgba(128, 128, 128, 0.55);
}
.feature-popup--dark-on-light .feature-popup-settings-options button {
    background: rgba(128, 128, 128, 0.06);
    border-color: rgba(128, 128, 128, 0.15);
    color: rgba(0, 0, 0, 0.45);
}
.feature-popup--dark-on-light .feature-popup-settings-options button:hover {
    color: rgba(0, 0, 0, 0.7);
    background: rgba(128, 128, 128, 0.1);
}
.feature-popup--dark-on-light .feature-popup-settings-options button.active {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.3);
    color: #808080;
    filter: brightness(0.75);
}
.feature-popup--dark-on-light .feature-popup-field label {
    color: rgba(128, 128, 128, 0.6);
}
.feature-popup--dark-on-light .feature-popup-field input {
    background: rgba(128, 128, 128, 0.05);
    border-color: rgba(128, 128, 128, 0.15);
    color: rgba(0, 0, 0, 0.45);
}
.feature-popup--dark-on-light .feature-popup-field input:focus {
    color: rgba(0, 0, 0, 0.7);
    border-color: #808080;
    background: rgba(128, 128, 128, 0.08);
}
.feature-popup--dark-on-light .feature-popup-notes {
    background: #fff;
    border-color: rgba(128, 128, 128, 0.2);
    color: #222;
}
.feature-popup--dark-on-light .feature-popup-notes:focus {
    border-color: #808080;
}
.feature-popup--dark-on-light .feature-popup-notes::placeholder {
    color: rgba(0, 0, 0, 0.35);
}
.feature-popup--dark-on-light .feature-popup-confidence-label {
    color: #333;
}
.feature-popup--dark-on-light .feature-popup-pill {
    border-color: rgba(0, 0, 0, 0.2);
    color: rgba(0, 0, 0, 0.5);
}
.feature-popup--dark-on-light .feature-popup-pill:hover {
    border-color: rgba(0, 0, 0, 0.35);
    color: rgba(0, 0, 0, 0.7);
}
.feature-popup--dark-on-light .feature-popup-pill.active {
    background: rgba(110, 110, 110, 0.55);
    border-color: rgba(160, 160, 160, 0.5);
    color: #fff;
}
.feature-popup--dark-on-light .feature-popup-details summary {
    color: rgba(0, 0, 0, 0.4);
}
.feature-popup--dark-on-light .feature-popup-save {
    filter: brightness(0.85);
}
.feature-popup--dark-on-light .feature-popup-save:hover:not(:disabled) {
    filter: brightness(0.95);
}
.feature-popup--dark-on-light .feature-popup-save:disabled {
    background: rgba(128, 128, 128, 0.12);
    color: rgba(0, 0, 0, 0.3);
    filter: none;
}

/* ── Match Colormap variant (light on dark) ── */
.feature-popup--match-colormap {
    background: var(--page-bg, #2b2b3a);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.45);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 24px var(--accent-glow, rgba(128,128,128,0.2));
}
.feature-popup--match-colormap .feature-popup-header {
    background: rgba(var(--accent-rgb, 128,128,128), 0.2);
    border-bottom-color: rgba(var(--accent-rgb, 128,128,128), 0.25);
}
.feature-popup--match-colormap .feature-popup-title {
    color: var(--accent-color);
}
.feature-popup--match-colormap .feature-popup-close,
.feature-popup--match-colormap .feature-popup-gear,
.feature-popup--match-colormap .feature-popup-delete {
    color: rgba(var(--accent-rgb, 128,128,128), 0.5);
}
.feature-popup--match-colormap .feature-popup-close:hover,
.feature-popup--match-colormap .feature-popup-gear:hover {
    color: var(--accent-color);
}
.feature-popup--match-colormap .feature-popup-delete:hover {
    color: #fff !important;
    background: #d03030 !important;
    box-shadow: none !important;
    transform: none !important;
}
.feature-popup--match-colormap .feature-popup-settings {
    background: rgba(var(--accent-rgb, 128,128,128), 0.06);
    border-bottom-color: rgba(var(--accent-rgb, 128,128,128), 0.12);
}
.feature-popup--match-colormap .feature-popup-settings-options button.active {
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.35);
    color: rgba(255, 255, 255, 0.9);
}
.feature-popup--match-colormap .feature-popup-confidence-label {
    color: rgba(255, 255, 255, 0.85);
}
.feature-popup--match-colormap .feature-popup-pill {
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.35);
    color: rgba(255, 255, 255, 0.5);
}
.feature-popup--match-colormap .feature-popup-pill:hover {
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.6);
}
.feature-popup--match-colormap .feature-popup-pill.active {
    background: var(--accent-color);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.5);
    color: #fff;
}
.feature-popup--match-colormap .feature-popup-details summary {
    color: rgba(var(--accent-rgb, 128,128,128), 0.5);
}
.feature-popup--match-colormap .feature-popup-save {
    background: var(--accent-color);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.4);
}
.feature-popup--match-colormap .feature-popup-save:hover:not(:disabled) {
    background: var(--accent-color);
    filter: brightness(1.15);
}
.feature-popup--match-colormap .feature-popup-save:disabled {
    background: var(--accent-soft);
}
.feature-popup--match-colormap .feature-popup-field label {
    color: rgba(var(--accent-rgb, 128,128,128), 0.65);
}
.feature-popup--match-colormap .feature-popup-field input {
    background: rgba(var(--accent-rgb, 128,128,128), 0.06);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.15);
}
.feature-popup--match-colormap .feature-popup-field input:focus {
    border-color: var(--accent-color);
    background: rgba(var(--accent-rgb, 128,128,128), 0.08);
}
.feature-popup--match-colormap .feature-popup-notes {
    background: rgba(var(--accent-rgb, 128,128,128), 0.08);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.2);
}
.feature-popup--match-colormap .feature-popup-notes:focus {
    border-color: var(--accent-color);
}

/* ── Match Colormap + Dark on Light combo ── */
.feature-popup--match-colormap.feature-popup--dark-on-light {
    background: #f4f3f7;
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.35);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 20px rgba(var(--accent-rgb, 128,128,128), 0.1);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-header {
    background: rgba(var(--accent-rgb, 128,128,128), 0.12);
    border-bottom-color: rgba(var(--accent-rgb, 128,128,128), 0.15);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-title {
    color: var(--accent-color);
    filter: brightness(0.75);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-close,
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-gear,
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-delete {
    color: rgba(var(--accent-rgb, 128,128,128), 0.45);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-close:hover,
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-gear:hover {
    color: var(--accent-color);
    filter: brightness(0.75);
    background: rgba(0, 0, 0, 0.1) !important;
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-delete:hover {
    color: #fff !important;
    background: #d03030 !important;
    box-shadow: none !important;
    transform: none !important;
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-settings {
    background: rgba(var(--accent-rgb, 128,128,128), 0.06);
    border-bottom-color: rgba(var(--accent-rgb, 128,128,128), 0.1);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-settings-label {
    color: rgba(var(--accent-rgb, 128,128,128), 0.55);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-settings-options button {
    background: rgba(var(--accent-rgb, 128,128,128), 0.06);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.15);
    color: rgba(0, 0, 0, 0.45);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-settings-options button:hover {
    color: rgba(0, 0, 0, 0.7);
    background: rgba(var(--accent-rgb, 128,128,128), 0.1);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-settings-options button.active {
    background: rgba(var(--accent-rgb, 128,128,128), 0.15);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.3);
    color: var(--accent-color);
    filter: brightness(0.75);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-field label {
    color: rgba(var(--accent-rgb, 128,128,128), 0.6);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-field input {
    background: rgba(var(--accent-rgb, 128,128,128), 0.05);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.15);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-field input:focus {
    border-color: var(--accent-color);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-notes {
    background: #fff;
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.2);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-notes:focus {
    border-color: var(--accent-color);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-confidence-label {
    color: rgba(0, 0, 0, 0.7);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-pill {
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.25);
    color: rgba(0, 0, 0, 0.45);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-pill:hover {
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.45);
    color: rgba(0, 0, 0, 0.7);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-pill.active {
    background: var(--accent-color);
    border-color: rgba(var(--accent-rgb, 128,128,128), 0.5);
    color: #fff;
    filter: brightness(0.85);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-details summary {
    color: rgba(var(--accent-rgb, 128,128,128), 0.45);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-save {
    background: var(--accent-color);
    filter: brightness(0.85);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-save:hover:not(:disabled) {
    filter: brightness(0.95);
}
.feature-popup--match-colormap.feature-popup--dark-on-light .feature-popup-save:disabled {
    background: rgba(var(--accent-rgb, 128,128,128), 0.12);
    color: rgba(0, 0, 0, 0.3);
    filter: none;
}

/* Radio choice styles are in css/modal-shared.css */

/* ============================================================
   Quick Fill Buttons (survey modals)
   ============================================================ */
.quick-fill-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #999;
    background: white;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.quick-fill-btn:hover {
    background: #f5f5f5;
}

/* ============================================================
   Modal Cancel / Exit Buttons
   ============================================================ */
.modal-cancel,
.modal-exit {
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-cancel {
    background: #6c757d;
    border: 2px solid #6c757d;
}
.modal-cancel:hover {
    background: #5a6268;
    border-color: #5a6268;
}
.modal-exit {
    background: #dc3545;
    border: 2px solid #dc3545;
}
.modal-exit:hover {
    background: #c82333;
    border-color: #c82333;
}

/* Confirm dialog button pair (e.g. "Ready to finish?") */
.confirm-btn {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.confirm-btn-back {
    background: linear-gradient(180deg, #d07070 0%, #b85555 100%);
    box-shadow: 0 2px 8px rgba(180, 80, 80, 0.35);
}
.confirm-btn-back:hover {
    background: linear-gradient(180deg, #da7e7e 0%, #c56060 100%);
    box-shadow: 0 4px 12px rgba(180, 80, 80, 0.45);
}
.confirm-btn-proceed {
    background: linear-gradient(180deg, #2196F3 0%, #1976D2 100%);
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.35);
}
.confirm-btn-proceed:hover {
    background: linear-gradient(180deg, #42a5f5 0%, #1e88e5 100%);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.45);
}

/* Complete button (playback bar) */
.complete-btn {
    background: linear-gradient(180deg, #2196F3 0%, #1976D2 100%);
    color: white;
    font-weight: 700;
    padding: 8px 18px;
    font-size: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    margin-left: auto;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.35);
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.complete-btn:hover {
    background: linear-gradient(180deg, #42a5f5 0%, #1e88e5 100%);
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.45);
    transform: scale(1.03);
}

/* ============================================================
   Participant ID Text (top bar clickable badge)
   ============================================================ */
#participantIdText {
    font-size: 13px;
    color: #aaa;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(100, 100, 100, 0.6);
    background: rgba(40, 40, 40, 0.4);
    transition: background-color 0.2s;
    display: inline-block;
}

/* ============================================================
   Audio Record / Download Buttons
   ============================================================ */
.audio-btn {
    padding: 4px 14px;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    height: 28px;
}
.audio-btn:hover {
    transform: translateY(-1px);
}
.audio-btn-record,
.audio-btn-download {
    background: rgba(var(--accent-rgb, 128,128,128), 0.35);
    border: 1px solid rgba(var(--accent-rgb, 128,128,128), 0.4);
}
.audio-btn-record:hover,
.audio-btn-download:hover {
    background: rgba(var(--accent-rgb, 128,128,128), 0.5);
    box-shadow: 0 3px 8px rgba(var(--accent-rgb, 128,128,128), 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ============================================================
   Data Viewer Panel (localhost dev mode)
   ============================================================ */
#dataViewerPanel {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, rgba(30,35,60,0.95), rgba(20,25,45,0.95));
    border: 1px solid rgba(100,120,200,0.3);
    border-radius: 8px;
    color: #ddd;
    font-family: system-ui, sans-serif;
}
.dv-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.dv-bar .dv-title {
    font-weight: 700;
    font-size: 15px;
    color: #8af;
}
.dv-bar label {
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
}
.dv-bar .dv-field {
    display: flex;
    align-items: center;
    gap: 6px;
}
#dvUserSelect { min-width: 180px; }
#dvSessionSelect { min-width: 280px; }
#dvStatusText {
    font-size: 12px;
    color: #aaa;
    font-style: italic;
}
#dvDataDisplay {
    max-height: 200px;
    overflow-y: auto;
}

/* ============================================================
   Bottom Controls Bar (below spectrogram)
   ============================================================ */
.controls-bar-bottom {
    display: flex;
    align-items: center;
    gap: 12px 30px;
    margin-top: 8px;
    padding: 4px 0 0 8px;
    flex-wrap: wrap;
}
.controls-bar-bottom label {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    user-select: none;
    color: #e8e8ff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* ============================================================
   Viz Controls (right side of bottom bar)
   ============================================================ */
.viz-controls {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
    flex-wrap: wrap;
}

/* ============================================================
   Oscilloscope Panel
   ============================================================ */
#oscilloscope-panel {
    display: block;
    pointer-events: none;
}
.oscilloscope-enclosure {
    position: relative;
    border-radius: 5px;
    padding: 4px;
    background: linear-gradient(135deg, rgba(40, 40, 70, 0.85) 0%, rgba(25, 25, 55, 0.8) 100%);
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.2), inset 0 0 20px rgba(80, 90, 130, 0.5);
}
#oscilloscope {
    display: block;
    width: 106px;
    height: 28px;
    border-radius: 2px;
    background: rgba(3, 3, 8, 0.98);
}
#oscilloscope-frost {
    position: absolute;
    top: 0;
    left: 0;
    width: 106px;
    height: 28px;
    border-radius: 2px;
    pointer-events: none;
    opacity: 0.5;
}

/* ============================================================
   EMIC Study Page Overrides (emic_study.html)
   ============================================================ */

/* EMIC-specific CSS custom properties */
.emic-page, .study-page {
    --axis-label-font-size: 14px;
    --axis-label-color: #bbb;
    --axis-tick-color: #666;
    --panel-label-size: 15px;
}

/* Admin-only buttons: hidden unless admin unlocked (data-admin set by early script) */
.admin-only { display: none; }
html[data-admin] .admin-only { display: flex; animation: adminFadeIn 0.6s ease; }
html[data-admin] button.admin-only { display: inline-block; }
@keyframes adminFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Study pages: Fetch Data panel is never shown (dev-only, use Solar Portal) */
.emic-page #emicControlsPanel,
.study-page #studyControlsPanel { display: none !important; }

/* Study pages: hide advanced-only elements before JS loads (prevents flash in production mode) */
/* Scoped to study pages so Solar Portal is unaffected */
html:not([data-advanced]) .emic-page #stretchGroup,
html:not([data-advanced]) .emic-page #speedGroup,
html:not([data-advanced]) .emic-page .panel-gear,
html:not([data-advanced]) .emic-page #hamburgerBtn,
html:not([data-advanced]) .emic-page #questionnairesPanel,
html:not([data-advanced]) .emic-page #componentSelectorContainer,
html:not([data-advanced]) .emic-page #detrendContainer,
html:not([data-advanced]) .study-page #stretchGroup,
html:not([data-advanced]) .study-page #speedGroup,
html:not([data-advanced]) .study-page .panel-gear,
html:not([data-advanced]) .study-page #hamburgerBtn,
html:not([data-advanced]) .study-page #questionnairesPanel,
html:not([data-advanced]) .study-page #componentSelectorContainer,
html:not([data-advanced]) .study-page #detrendContainer,
html:not([data-advanced]) .study-page .dev-control {
    display: none !important;
}
html:not([data-advanced]) .emic-page .spectrogram-controls,
html:not([data-advanced]) .study-page .spectrogram-controls {
    visibility: hidden;
    pointer-events: none;
}

/* Solar Portal: no settings drawer */
.solar-portal #hamburgerBtn { display: none; }

/* EMIC: taller spectrogram, shorter minimap */
/* --spec-height is set dynamically by fitSpectrogram() in both HTML pages */
.emic-page #minimap, .study-page #minimap { height: 121px; }

/* EMIC Study header */
.emic-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 6px;
    margin-top: 0;
    position: relative;
    z-index: 1001;
}
.emic-header h1 {
    margin: 0;
    font-size: 1.5em;
    opacity: 0.88;
    color: #fff;
}
.emic-header .subtitle {
    font-size: 0.55em;
    opacity: 0.6;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

/* EMIC participant bar */
.emic-participant-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}
.emic-participant-bar label {
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    white-space: nowrap;
}
.emic-participant-bar input {
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #555;
    background: rgba(60, 60, 60, 0.9);
    color: #ddd;
    width: 120px;
}

/* EMIC / Study controls bar */
.emic-controls-bar,
.study-controls-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0 4px;
    flex-wrap: wrap;
    min-height: 38px;
}
.emic-placeholder-note {
    font-size: 11px;
    color: #666;
    font-style: italic;
    padding: 0 8px;
}

/* EMIC modal overrides — dimensions come from study config via the renderer */

/* Playback bar: let flex-wrap handle overflow, not hidden scrolling */
.panel-playback > div {
    overflow-x: visible;
}

/* Questionnaires panel: thin dark scrollbar */
#questionnairesPanel > div {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
#questionnairesPanel > div::-webkit-scrollbar {
    height: 3px;
}
#questionnairesPanel > div::-webkit-scrollbar-track {
    background: transparent;
}
#questionnairesPanel > div::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* Study page viz-controls — compact styling override */
.emic-page .viz-controls, .study-page .viz-controls {
    gap: 10px !important;
}
.emic-page .viz-controls label, .study-page .viz-controls label {
    font-size: 12px !important;
    opacity: 0.8;
}
.emic-page .viz-controls select, .study-page .viz-controls select {
    font-size: 12px !important;
    padding: 2px 6px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: #e0e0e8;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 3px;
}
