/* Shared Panel Styles */
.panel-header {
    padding: 15px 15px 10px 15px;
    background: rgba(10, 10, 10, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
}

.panel-header .logo-header {
    display: flex;
    flex-direction: column;
    gap: 35px; /* Reduced from 55px - save 20px */
    padding: 15px; /* Reduced from 20px - save 10px total (5px top + 5px bottom) */
    min-height: 110px; /* Reduced from 150px - total 40px saved */
    background: rgba(10, 10, 10, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative; /* For absolute positioning of mic button */
    overflow: visible;
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-right: 80px; /* room for close button + concentric rings */
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* ============================================================================
   Audio enable button — palette-responsive + state-legible (muriel redesign).
   Color MEANS something here (polish rule 25): the old build was Tailwind green
   #22c55e/#16a34a in BOTH the off AND on states, so you couldn't tell from
   color whether audio was on, and the loud neon-glow lived on the ACTIVE state
   (emphasis backwards — rule 23). Now:
     OFF (Enable)  = loud palette-accent CTA — the one thing a new user must do.
     PENDING       = breathing accent glow ("working"), label stays full-opacity.
     ACTIVE        = recedes to a quiet outlined chip + a live "listening" pulse
                     dot, so it stops competing with the visuals.
     DENIED        = neutral surface + red cue (an error, not a green invite).
   All color rides --pd-accent-* tokens, so it tracks the live canvas palette and
   stays >=8:1 via the contrast-paired --pd-accent-fill / --pd-accent-on.
   ============================================================================ */
.enable-audio-button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 11px 20px !important;
    background: var(--pd-accent-fill, #00e1ff) !important;
    color: var(--pd-accent-on, #001418) !important;
    border: none !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    font-size: 15px !important;
    min-width: 200px !important;
    justify-content: center !important;
    /* Shadow-over-border (rule 3): depth + a soft accent halo so OFF reads as the
       focal CTA (rule 23) without a hard border. */
    box-shadow: 0 2px 6px rgba(0,0,0,0.35),
                0 0 18px rgba(var(--pd-accent-rgb), 0.30) !important;
    transition-property: background-color, color, box-shadow, scale !important; /* rule 16 — no transition:all */
    transition-duration: 220ms !important;
    transition-timing-function: ease-out !important;
    letter-spacing: 0.3px !important;
}
.enable-audio-button:active { scale: 0.96 !important; }   /* tactile press — rule 14 */

/* Mic icon inline in the enable-audio button — inherits the on-fill label color */
.audio-btn-mic-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--pd-accent-on, #001418);
    transition: color 0.22s ease;
}
.audio-btn-mic-icon svg {
    width: 100%;
    height: 100%;
}

/* Hover (OFF) — gated for touch (rule 20); brighten the halo, no hue shift */
@media (hover: hover) and (pointer: fine) {
    .enable-audio-button:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.42),
                    0 0 26px rgba(var(--pd-accent-rgb), 0.45) !important;
    }
}

/* PENDING — breathing accent glow signals work without dimming the label text */
.enable-audio-button.pending {
    cursor: progress !important;
    animation: audioBtnPending 1.1s ease-in-out infinite;
}
@keyframes audioBtnPending {
    0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 10px rgba(var(--pd-accent-rgb), .22); }
    50%      { box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 0 28px rgba(var(--pd-accent-rgb), .60); }
}

/* ACTIVE — recede to a quiet outlined status chip + a live "listening" pulse.
   The loud filled pill becomes calm confirmation that stops shouting over the viz. */
.enable-audio-button.active {
    background: transparent !important;
    color: var(--pd-accent-text) !important;
    border: 1.5px solid rgba(var(--pd-accent-rgb), 0.55) !important;
    box-shadow: none !important;
    animation: none;
}
.enable-audio-button.active .audio-btn-mic-icon { color: var(--pd-accent-text); }
.enable-audio-button.active::after {
    content: "";
    width: 8px; height: 8px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--pd-accent-text);
    box-shadow: 0 0 8px rgba(var(--pd-accent-rgb), 0.85);
    animation: audioLivePulse 1.4s ease-in-out infinite;   /* heartbeat = live capture */
}
@keyframes audioLivePulse {
    0%, 100% { transform: scale(0.65); opacity: 0.5; }
    50%      { transform: scale(1);    opacity: 1;   }
}

/* DENIED — keyed off the mic icon's denied state via :has() (sidesteps the JS
   label-reset that otherwise reverts the text). Neutral surface + red cue. */
.enable-audio-button:has(.audio-btn-mic-icon.denied) {
    background: rgba(20, 20, 26, 0.92) !important;
    color: #ffd9d9 !important;                              /* ~15:1 on the dark fill */
    border: 1.5px solid rgba(244, 68, 68, 0.65) !important;
    box-shadow: none !important;
    animation: none;
}
.audio-btn-mic-icon.denied { color: #ff6b6b; }

/* Parameter Value Bars */
.param-value-bar-container {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.param-value-bar {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22d3ee, #a855f7);
    border-radius: 2px;
    transition: width 0.1s ease-out;
    width: 0%;
}

.param-value {
    color: #e0f2fe;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    opacity: 0.9;
    min-width: 40px;
    text-align: right;
}

/* EQ meter rows - UNIFIED SCALING */
#selector .tab-content[data-tab="audio"] #eq-meters {
    --eq-scale: 1.0; /* Base scale - all sizing explicit */
}

#selector .tab-content[data-tab="audio"] #eq-meters .meter {
    display: grid;
    grid-template-columns: 80px 1fr 60px;
    gap: 10px;
    align-items: center;
    margin: 8px 0;
    min-height: 32px; /* Consistent row height */
}

/* Mobile responsive for EQ meters - 45% LARGER */
@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] #eq-meters { --eq-scale: 1.45; }
    #selector .tab-content[data-tab="audio"] #eq-meters .meter {
        grid-template-columns: 100px 1fr 70px; /* Proportionally larger */
        gap: 12px;
        margin: 12px 0;
        min-height: 50px; /* 44px+ touch target */
    }
    
    #selector .tab-content[data-tab="audio"] #eq-meters .label { letter-spacing: 0.4px; }
    
    #selector .tab-content[data-tab="audio"] #eq-meters .value {
        background: rgba(255,255,255,0.12);
        border: 1px solid rgba(255,255,255,0.16);
        border-radius: 6px;
        padding: 6px 10px;
        line-height: 1;
        min-width: 64px;
    }
    
    /* Make analysis sections single column on mobile */
    #selector .tab-content[data-tab="audio"] .musical-analysis-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* Force equal width for all analysis sections on mobile */
    #selector .tab-content[data-tab="audio"] .musical-analysis-grid > .analysis-section {
        width: 100%;
        max-width: 100%;
    }
    
    /* Larger touch targets for buttons and controls */
    #selector .tab-content[data-tab="audio"] button {
        min-height: 44px;
        font-size: 16px;
        padding: 10px 16px;
    }
    
    /* Align slices grid with mobile reduction to 16 */
    #selector .tab-content[data-tab="audio"] #eq-meters .stack {
        grid-template-columns: repeat(16, 1fr);
    }
    
    /* Better spacing for mobile */
    #selector .tab-content[data-tab="audio"] .analysis-section {
        padding: 14px;
        margin: 10px 0;
    }
    
    #selector .tab-content[data-tab="audio"] .analysis-label {
        font-size: 15px !important;
    }
}

#selector .tab-content[data-tab="audio"] #eq-meters .label {
    color: #e0f2fe;
    font-weight: 600;
    font-size: 13px; /* Fixed desktop size */
    text-transform: uppercase;
    opacity: 0.9;
}

@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] #eq-meters .label {
        font-size: 16px; /* 23% larger on mobile */
    }
}

#selector .tab-content[data-tab="audio"] #eq-meters .value {
    color: #cbd5e1;
    font-weight: 600;
    font-size: 13px; /* Fixed desktop size */
    text-align: right;
}

@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] #eq-meters .value {
        font-size: 16px; /* 23% larger on mobile */
    }
}

#selector .tab-content[data-tab="audio"] #eq-meters .stack-wrap {
    position: relative;
    height: 12px !important; /* ENFORCED: Standardized pill bar height */
    min-height: 12px !important;
    max-height: 12px !important;
}

@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] #eq-meters .stack-wrap {
        height: 16px !important; /* 33% larger on mobile */
        min-height: 16px !important;
        max-height: 16px !important;
    }
}

#selector .tab-content[data-tab="audio"] #eq-meters .stack {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(40, 1fr);
    align-items: end;
    gap: 2px;
}

#selector .tab-content[data-tab="audio"] #eq-meters .stack .slice {
    height: 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
}

#selector .tab-content[data-tab="audio"] #eq-meters .raphael-host {
    position: absolute;
    inset: 0;
    pointer-events: none;
    height: 12px !important;
    min-height: 12px !important;
    max-height: 12px !important;
    min-width: 240px;
}

/* CSS meter tracks handle their own positioning via inline styles */
#selector .tab-content[data-tab="audio"] #eq-meters .meter-track {
    height: 12px !important;
    min-height: 12px !important;
    max-height: 12px !important;
    min-width: 240px;
    overflow: hidden;
}

/* Canvas viz containers for BPM/Bass */
#selector .tab-content[data-tab="audio"] #eq-meters .viz-host {
    position: relative;
    height: 84px !important;
    min-height: 84px !important;
    max-height: 84px !important;
    overflow: hidden;
}

/* Timeline host - Canvas graph container */
#selector .tab-content[data-tab="audio"] #eq-meters .timeline-host {
    overflow: hidden;
}

@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] #eq-meters .raphael-host,
    #selector .tab-content[data-tab="audio"] #eq-meters .meter-track {
        height: 16px !important;
        min-height: 16px !important;
        max-height: 16px !important;
    }
}

/* Audio tab text readability */
#selector .tab-content[data-tab="audio"] .section-title {
    color: #e5f0ff;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* Control section headings (Core Params, Effects, Input, Performance) */
#selector .tab-content[data-tab="audio"] .control-section > h3 {
    font-size: 14px; /* Fixed desktop size */
}

@media (max-width: 768px) {
    #selector .tab-content[data-tab="audio"] .control-section > h3 {
        font-size: 18px; /* 29% larger on mobile */
    }
}

/* EQ Section Title - UNIFIED SIZING */
#eq-meters .eq-section-title {
    color: #7dd3fc; /* primary blue */
    font-size: 14px; /* Fixed desktop size */
    font-weight: 800;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(100, 150, 255, 0.22);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-shadow: 0 0 10px rgba(16,185,129,0.25); /* subtle green glow */
}

@media (max-width: 768px) {
    #eq-meters .eq-section-title {
        font-size: 18px; /* 29% larger on mobile */
    }
}

/* Beat Section - add top margin to prevent overlap with energy meter */
#eq-meters .beat-section {
    margin-top: 20px;
}

#eq-meters .beat-section .eq-section-title {
    margin-top: 0; /* Override default to prevent double spacing */
}

/* Musical Analysis Grid - 2x2 layout */
#eq-meters .musical-analysis-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* 2 columns */
    gap: 12px !important;
}

@media (max-width: 768px) {
    #eq-meters .musical-analysis-grid {
        grid-template-columns: 1fr !important; /* Mobile: single column */
        gap: 10px !important;
    }
}

/* Analysis sections (Harmonic/Melodic/Rhythm) */
#eq-meters .analysis-section {
    margin: 15px 0;
    padding: 8px 10px; /* Reduced from 12px */
    background: rgba(20, 30, 50, 0.3);
    border-radius: 8px;
    border-left: 3px solid rgba(100, 150, 255, 0.4);
    width: 100%; /* Force full width within grid cell */
    box-sizing: border-box;
}

#eq-meters .analysis-section .analysis-label {
    margin-bottom: 4px !important; /* Reduced from 8px */
    color: #7dd3fc;
    font-weight: 700;
    font-size: 13px; /* Fixed desktop size */
    text-shadow: 0 0 8px rgba(16,185,129,0.2);
}

@media (max-width: 768px) {
    #eq-meters .analysis-section .analysis-label {
        font-size: 16px; /* 23% larger on mobile */
    }
}

#eq-meters .analysis-section .analysis-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important; /* Consistent spacing */
}

/* Hide empty analysis divs to prevent wasted space */
#eq-meters .key-display:empty,
#eq-meters .key-confidence:empty,
#eq-meters .chord-display:empty,
#eq-meters .dissonance-level:empty,
#eq-meters .modal-brightness:empty,
#eq-meters .contour-display:empty,
#eq-meters .interval-type:empty,
#eq-meters .sequence-indicator:empty,
#eq-meters .phrase-position:empty {
    display: none;
}

#eq-meters .analysis-section .section-title {
    color: #7dd3fc;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#eq-meters .harmonic-metrics,
#eq-meters .melodic-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#eq-meters .metric-row {
    display: grid;
    grid-template-columns: 110px 1fr 64px; /* label | bar | value */
    align-items: center;
    gap: 10px;
}

/* Constrain the bar column so harmonic/melodic bars don't feel too wide */
#eq-meters .metric-row .stack-wrap {
    max-width: 240px; /* Slightly tighter on desktop */
}

@media (max-width: 768px) {
  #eq-meters .metric-row {
      grid-template-columns: 100px 1fr 70px; /* Adjusted for mobile */
      gap: 8px;
  }
  #eq-meters .metric-row .stack-wrap { 
      max-width: 180px; /* Much tighter on mobile to prevent cutoff */
  }
}

#eq-meters .metric-label {
    color: #94a3b8;
    font-size: 11px; /* Fixed desktop size */
    min-width: 85px;
    text-transform: capitalize;
}

@media (max-width: 768px) {
    #eq-meters .metric-label {
        font-size: 13px; /* 18% larger on mobile */
    }
}

#eq-meters .metric-value {
    color: #cbd5e1;
    font-size: 12px; /* Fixed desktop size */
    font-weight: 600;
    font-family: 'Courier New', monospace;
    min-width: 64px;
    text-align: right;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    #eq-meters .metric-value {
        font-size: 14px; /* 17% larger on mobile */
    }
}

/* Normalize Smoothing and Audio Reactivity Effects headings to EQ heading scale */
.smoothing-title,
#audio-reactivity-effects-title,
.reactivity-effects-title {
    color: #7dd3fc;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 14px; /* Fixed desktop size */
    text-shadow: 0 0 10px rgba(16,185,129,0.25);
}

@media (max-width: 768px) {
    .smoothing-title,
    #audio-reactivity-effects-title,
    .reactivity-effects-title {
        font-size: 18px; /* 29% larger on mobile */
    }
}

/* Momentum bar */
#eq-meters .momentum-bar-container {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#eq-meters .momentum-bar {
    height: 100%;
    background: linear-gradient(90deg, #22d3ee, #a855f7);
    border-radius: 3px;
    transition: width 0.2s ease-out;
    width: 0%;
}

/* Pitch Analysis Section Styling */
#selector .tab-content[data-tab="audio"] .pitch-section {
    background: rgba(20, 20, 40, 0.6);
    border: 1px solid rgba(100, 100, 150, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
}

#selector .tab-content[data-tab="audio"] .pitch-section .pitch-label {
    color: #e5f0ff;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#selector .tab-content[data-tab="audio"] .pitch-frequency {
    color: #00e1ff;
    font-weight: bold;
    font-size: 16px;
}

#selector .tab-content[data-tab="audio"] .pitch-confidence-value {
    color: #88ccff;
    font-weight: 600;
}

#selector .tab-content[data-tab="audio"] .pitch-details {
    color: #cccccc;
    font-size: 13px;
}

/* Analysis Sections Base Styling */
#selector .tab-content[data-tab="audio"] .analysis-section {
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

/* Harmonic Section Styling */
#selector .tab-content[data-tab="audio"] .analysis-section.harmonic-section {
    background: rgba(40, 20, 40, 0.6);
    border: 1px solid rgba(150, 100, 150, 0.3);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#selector .tab-content[data-tab="audio"] .harmonic-section .analysis-label {
    color: #ff88cc;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .key-confidence,
#selector .tab-content[data-tab="audio"] .key-display {
    color: #ffaa44;
    font-weight: bold;
}

#selector .tab-content[data-tab="audio"] .dissonance-level {
    color: #ff6666;
    font-weight: 600;
}

/* Melodic Section Styling */
#selector .tab-content[data-tab="audio"] .analysis-section.melodic-section {
    background: rgba(20, 40, 40, 0.6);
    border: 1px solid rgba(100, 150, 150, 0.3);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Prevent individual text elements from overflowing */
#selector .tab-content[data-tab="audio"] .melodic-section #pitch-note,
#selector .tab-content[data-tab="audio"] .melodic-section #pitch-hz,
#selector .tab-content[data-tab="audio"] .melodic-section #melodic-momentum-val {
    overflow: hidden;
    text-overflow: ellipsis;
}

#selector .tab-content[data-tab="audio"] .melodic-section .analysis-label {
    color: #88ffcc;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .interval-type,
#selector .tab-content[data-tab="audio"] .contour-display {
    color: #44ffaa;
    font-weight: 600;
}

#selector .tab-content[data-tab="audio"] .sequence-indicator {
    color: #66ccff;
    font-weight: 600;
}

#selector .tab-content[data-tab="audio"] .phrase-position {
    color: #aaffcc;
    font-weight: 600;
}

/* Brightness Section Styling */
#selector .tab-content[data-tab="audio"] .analysis-section.brightness-section {
    background: rgba(40, 40, 20, 0.6);
    border: 1px solid rgba(150, 150, 100, 0.3);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#selector .tab-content[data-tab="audio"] .brightness-section .analysis-label {
    color: #ffff88;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .modal-brightness {
    color: #ffcc44;
    font-weight: 600;
}

/* Instrument Section Styling */
#selector .tab-content[data-tab="audio"] .analysis-section.instrument-section {
    background: rgba(40, 30, 20, 0.6);
    border: 1px solid rgba(150, 120, 100, 0.3);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#selector .tab-content[data-tab="audio"] .instrument-section .analysis-label {
    color: #ffaa66;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

/* Rhythm Section Styling */
#selector .tab-content[data-tab="audio"] .analysis-section.rhythm-section {
    background: rgba(20, 40, 30, 0.6);
    border: 1px solid rgba(100, 150, 120, 0.3);
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#selector .tab-content[data-tab="audio"] .rhythm-section .analysis-label {
    color: #88ffaa;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .harmonic-rhythm {
    color: #66ff88;
    font-weight: 600;
}

/* Camera (motion) Section Styling — match the colored uppercase title
   convention of the sibling sections instead of the near-white default. */
#selector .tab-content[data-tab="audio"] .motion-section .analysis-label {
    color: #7dd3fc;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

/* Speaker Section Styling */
#selector .tab-content[data-tab="audio"] .speaker-section .analysis-label {
    color: #c4b5fd;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
}

/* Input Controls Section Styling */
#selector .tab-content[data-tab="audio"] .input-controls-grid {
    background: rgba(40, 30, 20, 0.6);
    border: 1px solid rgba(150, 120, 100, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
}

#selector .tab-content[data-tab="audio"] .input-controls-grid .control-item {
    margin: 8px 0;
}

#selector .tab-content[data-tab="audio"] .control-label {
    color: #ffcc88;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .control-value {
    color: #ffaa66;
    font-weight: 600;
}

/* Performance Section Styling */
#selector .tab-content[data-tab="audio"] .performance-grid {
    background: rgba(30, 40, 20, 0.6);
    border: 1px solid rgba(120, 150, 100, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
}

#selector .tab-content[data-tab="audio"] .performance-grid .perf-item {
    margin: 8px 0;
}

#selector .tab-content[data-tab="audio"] .perf-label {
    color: #ccff88;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
}

#selector .tab-content[data-tab="audio"] .perf-value {
    color: #88ff44;
    font-weight: bold;
}

#selector .tab-content[data-tab="audio"] .perf-display {
    color: #aaff66;
    font-weight: 600;
}

#selector .tab-content[data-tab="audio"] .freq-label,
#selector .tab-content[data-tab="audio"] .beat-label,
#selector .tab-content[data-tab="audio"] .effect-label,
#selector .tab-content[data-tab="audio"] .control-label,
#selector .tab-content[data-tab="audio"] .perf-label,
#selector .tab-content[data-tab="audio"] .analysis-label,
#selector .tab-content[data-tab="audio"] .pitch-label {
    color: rgba(230, 242, 255, 0.9);
}

#selector .tab-content[data-tab="audio"] .perf-value,
#selector .tab-content[data-tab="audio"] .perf-display,
#selector .tab-content[data-tab="audio"] .control-value,
#selector .tab-content[data-tab="audio"] .pitch-frequency,
#selector .tab-content[data-tab="audio"] .pitch-confidence-value,
#selector .tab-content[data-tab="audio"] .pitch-details,
#selector .tab-content[data-tab="audio"] .key-confidence,
#selector .tab-content[data-tab="audio"] .dissonance-level,
#selector .tab-content[data-tab="audio"] .interval-type,
#selector .tab-content[data-tab="audio"] .sequence-indicator,
#selector .tab-content[data-tab="audio"] .phrase-position,
#selector .tab-content[data-tab="audio"] .modal-brightness {
    color: rgba(216, 226, 239, 0.9);
}

#selector .tab-content[data-tab="audio"] #pitch-note-display {
    color: #f0f9ff;
}

/* Panel wordmark — green concentric ring borders */
.panel-title,
#selector .panel-title,
#enhanced-help-panel .panel-title {
    flex: 0 0 auto !important;
    position: relative !important;
    display: block !important;
    margin-right: auto !important;
    margin-top: -4px !important; /* optical alignment with audio button */
    height: 32px !important;
    white-space: nowrap !important;
    /* Reset any inherited text rendering on container */
    font-size: 0 !important;
    color: transparent !important;
    -webkit-text-stroke: 0 !important;
    text-shadow: none !important;
}

.panel-title .nb {
    font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif !important;
    font-weight: 900 !important;
    font-size: 30px !important;
    letter-spacing: -1px !important;
    line-height: 1.2 !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    paint-order: stroke fill !important;
}

/* Outermost rings get dark fill to preserve letter counters */
.panel-title .nb-r12,
.panel-title .nb-r11,
.panel-title .nb-r10,
.panel-title .nb-r9,
.panel-title .nb-r8 {
    -webkit-text-fill-color: rgba(10,10,10,0.9) !important;
}

.panel-title .nb-ring {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* Alternating glow/dark rings — thin dark separators between bright bands.
   The bright bands track the SECONDARY palette accent (--pd-accent2-rgb) so the halo
   stays two-tone against the magenta-ish primary-accent letter fill (nb-outline). The
   dark→bright ramp (a glow emanating from the letter) is preserved via color-mix toward
   black; only the hue is now dynamic. Was a hardcoded neon-green ramp. */
.panel-title .nb-r12 { -webkit-text-stroke: 20px rgba(0,0,0,0.8) !important; }
.panel-title .nb-r11 { -webkit-text-stroke: 19px color-mix(in srgb, rgb(var(--pd-accent2-rgb)) 33%, #000) !important; }
.panel-title .nb-r10 { -webkit-text-stroke: 16px rgb(0,10,0) !important; }
.panel-title .nb-r9  { -webkit-text-stroke: 15px color-mix(in srgb, rgb(var(--pd-accent2-rgb)) 48%, #000) !important; }
.panel-title .nb-r8  { -webkit-text-stroke: 12px rgb(0,15,0) !important; }
.panel-title .nb-r7  { -webkit-text-stroke: 11px color-mix(in srgb, rgb(var(--pd-accent2-rgb)) 64%, #000) !important; }
.panel-title .nb-r6  { -webkit-text-stroke: 8px rgb(0,20,0) !important; }
.panel-title .nb-r5  { -webkit-text-stroke: 7px color-mix(in srgb, rgb(var(--pd-accent2-rgb)) 79%, #000) !important; }
.panel-title .nb-r4  { -webkit-text-stroke: 5px rgb(0,25,0) !important; }
.panel-title .nb-r3  { -webkit-text-stroke: 4px color-mix(in srgb, rgb(var(--pd-accent2-rgb)) 91%, #000) !important; }
.panel-title .nb-r2  { -webkit-text-stroke: 3px rgb(0,30,0) !important; }
.panel-title .nb-r1  { -webkit-text-stroke: 2px rgb(var(--pd-accent2-rgb)) !important; }

.panel-title .nb-outline {
    position: relative !important;
    z-index: 10 !important;
    -webkit-text-stroke: 0 !important;
    -webkit-text-fill-color: var(--pd-accent-text) !important;
    text-shadow: none !important;
}

/* Kill legacy rotated shadow pseudos */
.panel-title::before,
#selector .panel-title::before,
#enhanced-help-panel .panel-title::before {
    content: none !important;
}

.panel-title::after,
#selector .panel-title::after,
#enhanced-help-panel .panel-title::after {
    content: none !important;
}

.svg-mic-button {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(var(--pd-accent-rgb), 0.4);
    border-radius: 50%;
    cursor: pointer;
    padding: 6px;
    box-sizing: content-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    /* Absolutely centered in header, aligned with close button */
    position: absolute;
    left: 50%;
    top: 15px; /* Same as close button */
    transform: translateX(-50%);
    z-index: 200; /* Above audio button, below close button (10100) */
    box-shadow: 0 0 15px rgba(var(--pd-accent-rgb), 0.3),
                inset 0 0 20px rgba(var(--pd-accent-rgb), 0.08);
    transition: all 0.3s ease;
}

/* Concentric circles for mic button - larger radius */
.svg-mic-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px; /* Larger - extends beyond button */
    height: 70px;
    margin: -35px 0 0 -35px;
    border-radius: 50%;
    border: 6px solid rgba(var(--pd-accent-rgb), 0.8); /* Bright green outer ring */
    box-sizing: border-box;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: -1;
}

.svg-mic-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px; /* Middle ring */
    height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: 50%;
    border: 3px solid rgba(var(--pd-accent-rgb), 0.4); /* Mid-opacity middle ring */
    box-sizing: border-box;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: -1;
}

.svg-mic-button svg {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.svg-mic-button.active { 
    box-shadow: 0 0 20px rgba(var(--pd-accent-rgb), 0.6),
                inset 0 0 30px rgba(var(--pd-accent-rgb), 0.15);
}

.svg-mic-button.active::before {
    border-color: rgba(var(--pd-accent-rgb), 0.9); /* Match primary green */
}

.svg-mic-button.active svg { fill: rgb(var(--pd-accent-rgb)); } /* Match primary green */
.svg-mic-button.disabled svg { fill: rgb(var(--pd-accent-rgb)); opacity: 0.5; cursor: pointer; } /* Dimmed green when disabled */
.svg-mic-button.denied svg { fill: #ff4444; }

.floating-close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 20;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 20px;
    line-height: 1;
    text-shadow: none;
}

.floating-close-button:hover {
    background: rgba(255,0,0,0.7);
}


/* Main Panel Layout */
#selector, #enhanced-help-panel {
    display: flex;
    flex-direction: column;
    position: relative; /* Anchor for the close button */
}

/* REMOVED - Duplicate .panel-header, using the one at top of file */

/* REMOVED - Duplicate .panel-title definition, using the one above with rotation effects */
.floating-close-button, .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10100 !important; /* Ensure always on top - above mic button (50), panels, everything */
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    pointer-events: auto; /* Ensure button is clickable */
    -webkit-tap-highlight-color: transparent; /* reduce mobile tap flash */
    touch-action: manipulation; /* hint to browsers */
}

.floating-close-button:hover, .close-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* Fullscreen backdrop used when panels are open */
.ui-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 900; /* below #selector (1000) and help panel (9999), above canvas */
}

/* REMOVED - Old tab style, now using outline style below */

.content-area {
    flex-grow: 1;
    overflow-y: auto;
    position: relative; /* ensure children position relative to panel */
    min-height: 0; /* Allow flex item to shrink below content size */
    max-height: calc(90vh - 120px); /* Account for header and tabs */
}

/* Tab Widget Styles */
.tab-container {
    display: flex;
    flex-direction: row; /* Default to horizontal tabs */
    /* Darker glass tab-band: a reliable dark backing so the outlined tab text
       stays legible over the (intentionally) transparent panel + busy canvas.
       The content area below stays transparent — only this strip darkens. */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px;
    gap: 6px;
    position: sticky; /* Keep tabs visible while scrolling */
    top: 0; /* Below header */
    z-index: 15; /* Above content */
}

.vertical-tabs {
    flex-direction: column; /* Modifier for vertical tabs */
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-bottom: 3px solid transparent;
    color: transparent !important; /* Force transparent */
    -webkit-text-stroke-width: 1px !important;
    -webkit-text-stroke-color: rgba(255, 255, 255, 0.9) !important; /* was 0.4 — washed out against the transparent panel */
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-size: 22px;
    font-weight: 700;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.3s ease;
    position: relative;
    margin: 0 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); /* dark halo so the light outline separates from the busy canvas (was a white glow that did nothing on a bright backdrop) */
}

.tab-button:hover {
    background: rgba(var(--pd-accent-rgb), 0.12);
    -webkit-text-stroke-color: rgba(255, 255, 255, 1);
    border-bottom-color: rgba(var(--pd-accent-rgb), 0.5);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 12px rgba(var(--pd-accent-rgb), 0.3);
}

.tab-button.active {
    background: rgba(var(--pd-accent-rgb), 0.12) !important; /* More subtle, with !important */
    color: transparent !important;
    -webkit-text-stroke-width: 1.5px !important;
    -webkit-text-stroke-color: var(--pd-accent-text) !important;
    border-bottom: 3px solid rgb(var(--pd-accent-rgb)) !important;
    box-shadow: 0 -2px 8px rgba(var(--pd-accent-rgb), 0.3),
                inset 0 1px 0 rgba(var(--pd-accent-rgb), 0.2) !important;
    text-shadow: 0 0 15px rgba(var(--pd-accent-rgb), 0.6),
                 0 0 25px rgba(var(--pd-accent-rgb), 0.3) !important;
    letter-spacing: 2px !important;
}

.tab-content {
    display: none;
    padding: 15px;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

/* Help sub-tabs — smaller than top-level tabs to fit 5 across */
.help-sub-tabs {
    gap: 4px !important;
    padding: 4px !important;
}
.help-sub-tabs .tab-button {
    font-size: 13px !important;
    padding: 8px 10px !important;
    letter-spacing: 0.8px !important;
    -webkit-text-stroke-width: 0.8px !important;
}
.help-sub-tabs .tab-button.active {
    -webkit-text-stroke-width: 1.2px !important;
    letter-spacing: 1px !important;
}
@media (max-width: 768px) {
    .help-sub-tabs .tab-button {
        font-size: 15px !important;
        padding: 10px 8px !important;
    }
}

/* Ensure Audio tab acts as a proper container for EQ */
#selector .tab-content[data-tab="audio"] {
    position: relative;
}

/* Contain EQ meters within the Audio tab and give them a visible panel look */
#selector .tab-content[data-tab="audio"] #eq-meters {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.28);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden; /* clip any absolutely positioned children */
    max-width: 100%;
    display: block;
    min-width: 280px;
}

/* Optional: prevent any accidental EQ containers outside Audio tab from showing */
#eq-meters:not(#selector .tab-content[data-tab="audio"] #eq-meters) {
    display: none !important;
}

/* Reset problematic layout on EQ internals so they stay inside the container */
#selector .tab-content[data-tab="audio"] #eq-meters, 
#selector .tab-content[data-tab="audio"] #eq-meters * {
    float: none;
}

#selector .tab-content[data-tab="audio"] #eq-meters .meter,
#selector .tab-content[data-tab="audio"] #eq-meters .history-host,
#selector .tab-content[data-tab="audio"] #eq-meters [id^="raphael-"],
#selector .tab-content[data-tab="audio"] #eq-meters #bpm-raph,
#selector .tab-content[data-tab="audio"] #eq-meters #bass-raph,
#selector .tab-content[data-tab="audio"] #eq-meters #bpm-viz,
#selector .tab-content[data-tab="audio"] #eq-meters #bass-viz,
#selector .tab-content[data-tab="audio"] #eq-meters [id$="-raph"] {
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

/* Ensure any grid or flex inside does not exceed container */
#selector .tab-content[data-tab="audio"] #eq-meters .stack-wrap,
#selector .tab-content[data-tab="audio"] #eq-meters .stack,
#selector .tab-content[data-tab="audio"] #eq-meters .raphael-host,
#selector .tab-content[data-tab="audio"] #eq-meters .meter-track,
#selector .tab-content[data-tab="audio"] #eq-meters .viz-host {
    max-width: 100%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Help Panel Command Button Styles */
.command-list-button {
    display: inline-block;
    min-width: 30px;
    padding: 4px 8px;
    background: rgba(var(--pd-accent-rgb), 0.1);
    border: 2px solid rgba(var(--pd-accent-rgb), 0.3);
    border-radius: 4px;
    font-weight: normal;
    text-align: center;
    color: var(--pd-accent-text);
    font-family: monospace;
    transition: all 0.2s;
    outline: none;
    cursor: pointer;
}

.command-list-button:hover, .command-list-button:focus {
    background: rgba(var(--pd-accent-rgb), 0.2);
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(var(--pd-accent-rgb), 0.3);
}

.command-list-button:active {
    background: rgba(var(--pd-accent-rgb), 0.4);
    transform: scale(0.95);
}

.command-list-button.active {
    background: rgba(var(--pd-accent2-rgb), 0.25) !important;
    border: 2px solid var(--pd-accent2) !important;
    font-weight: bold !important;
    box-shadow: 0 0 12px var(--pd-accent2-glow) !important;
}

.command-list-button[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ===== Help Panel Command List Styles ===== */
.help-commands-list { padding: 8px 12px; display: flex; flex-direction: column; gap: 12px; }
.help-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    margin: 2px 0;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
}
.help-key {
    display: inline-block;
    min-width: 60px;
    padding: 10px 18px;
    background: rgba(var(--pd-accent-rgb), 0.1);
    border: 2px solid rgba(var(--pd-accent-rgb), 0.3);
    border-radius: 4px;
    font-weight: bold;
    font-size: 22px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    color: var(--pd-accent-text);
}
.help-key:hover, .help-key:focus { background: rgba(var(--pd-accent3-rgb), 0.2); border-color: var(--pd-accent3-border); transform: scale(1.05); box-shadow: 0 0 10px var(--pd-accent3-glow); }
.help-key:active { background: rgba(var(--pd-accent2-rgb), 0.4); transform: scale(0.95); }
/* `.help-key.active` deleted — superseded by help-panel.css's scoped opaque rule. */

.help-command-name { color: var(--pd-accent-text); font-weight: 600; font-size: 22px; padding: 10px 18px; background: rgba(var(--pd-accent-rgb), 0.05); border: 1px solid rgba(var(--pd-accent-rgb), 0.2); border-radius: 4px; }
.help-command-name.active { color: var(--pd-accent2-text); border-color: var(--pd-accent2); box-shadow: 0 0 8px var(--pd-accent2-glow); background: rgba(var(--pd-accent2-rgb), 0.15); }
.help-desc { color: #cfe6ec; opacity: 0.85; font-size: 1.1em; }

.help-state-button {
    background: rgba(var(--pd-accent-rgb), 0.1);
    border: 2px solid rgba(var(--pd-accent-rgb), 0.3);
    border-radius: 4px;
    color: var(--pd-accent-text);
    font-size: 22px;
    font-weight: bold;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
    min-width: 80px;
    text-align: center;
}
.help-state-button:hover { background: rgba(var(--pd-accent3-rgb), 0.2); border-color: var(--pd-accent3-border); transform: scale(1.05); }
.help-state-button:active { transform: scale(0.96); }
/* `.help-state-button.active` deleted — superseded by help-panel.css's scoped opaque rule. */

/* ═══════════════════════════════════════════════════════════════
   MOBILE: Single-column layout, larger fonts, better touch targets
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* --- Header --- */
    .panel-header {
        padding: 12px 12px 8px 12px;
    }
    .header-top-row {
        flex-direction: column;
        align-items: stretch;
        padding-right: 50px; /* less padding needed when stacked */
        gap: 10px;
    }
    .enable-audio-button {
        width: 100% !important;
        justify-content: center !important;
        font-size: 17px !important;
        padding: 12px 16px !important;
    }

    /* --- Top-level tabs --- */
    .tab-container:not(.help-sub-tabs) {
        gap: 4px;
        padding: 4px;
    }
    .tab-container:not(.help-sub-tabs) .tab-button {
        font-size: 18px !important;
        padding: 14px 12px !important;
    }

    /* --- Help sub-tabs --- */
    .help-sub-tabs {
        flex-wrap: wrap !important;
    }
    .help-sub-tabs .tab-button {
        font-size: 14px !important;
        padding: 10px 12px !important;
        flex: 0 1 auto !important;
    }

    /* --- Control sections: single column --- */
    #eq-meters .control-section [style*="grid-template-columns: repeat(3"],
    #eq-meters .control-section [style*="grid-template-columns: repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Beat grid — single column on mobile */
    #eq-meters .beat-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- Font size bumps (50% increase from desktop) --- */
    #eq-meters .control-section .eq-text-sm,
    #eq-meters .control-section .param-value,
    #eq-meters .control-section label span {
        font-size: 15px !important;
    }

    #eq-meters .control-section h3 {
        font-size: 20px !important;
    }

    /* Input sliders: taller for thumb targeting */
    #eq-meters .control-section input[type="range"] {
        height: 10px !important;
    }

    /* Checkboxes/toggles bigger */
    #eq-meters .control-section input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
    }

    /* Performance grid: 3 cols on mobile (was 5) */
    #eq-meters .control-section .perf-item {
        font-size: 14px !important;
    }

    /* Help content — larger text */
    .tab-content[data-tab="help"] {
        font-size: 16px;
    }
    .command-list-button {
        font-size: 16px !important;
        padding: 6px 10px !important;
        min-width: 36px !important;
    }

    /* More tab — larger text */
    .tab-content[data-tab="more"] {
        font-size: 16px;
    }
    .tab-content[data-tab="more"] h4 {
        font-size: 20px !important;
    }
    .tab-content[data-tab="more"] p,
    .tab-content[data-tab="more"] li {
        font-size: 16px !important;
    }

    /* Content area padding */
    .tab-content {
        padding: 12px !important;
    }
}