/* --- CORE THEME DNA (From Specs) --- */
:root {
    --background: #0D0D0D;
    --primary: #A67B5B;   /* Brown */
    --highlight: #C89F7B; /* Gold */
    --secondary: #555555; /* Grey */
    --gold-glow: 0 0 15px rgba(200, 159, 123, 0.5);
    --sattva-glow: #FDFBF7;
    --mystic2: #00FF7F;
    --danger: #FF4444;
    --electric: #00ffff; /* NEW: Electric Cyan (for Time/Motion & Icon) */
    --alt-green: #00cc00;     /* Terminal Green */
    --alt-sec: #444444;   /* Dim Grey */
    --icon-gold: #ffaa00;   /* Gold */
}

/* --- UNIVERSAL RESET --- */
* {
    box-sizing: border-box;
}

/* --- THE CANVAS (Aligned with Gita/Japa) --- */
body {
    background-color: var(--background);
    color: var(--primary);
    font-family: 'Source Code Pro', monospace;
    font-size: 14px;
    margin: 0;
    
    /* YOUR STANDARD SETTINGS */
    height: 100vh;
    padding: 0.75rem; 
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden; /* Prevents scrollbars on the main page */
}

/* --- THE GRID (Aligned with Gita/Japa) --- */
.ide-container {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    
    /* EXACT DIMENSIONS FROM GITA APP */
    width: 100%;
    max-width: 1300px;
    height: 100%; 
    max-height: 803px;
    gap: 0.75rem;
    
    margin: 0 auto;
    align-self: center;
}

/* --- COLUMNS (Invisible Wrappers) --- */
/* These must fill the grid height */
.ide-main, .ide-sidebar-right, .ide-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;       /* Fill the Grid */
    min-height: 0;      /* Critical: allows shrinking if window is small */
    border: none !important;
    background: none !important;
}

/* --- MODULES (The Visible Boxes) --- */
.module, .right-module {
    border: 1px dashed var(--primary);
    background-color: var(--background);
    
    /* FLEX SETUP */
    display: flex;
    flex-direction: column;
    min-height: 0;      /* Allows flex shrinking */
    position: relative;
}

/* --- EXPANSION UTILITY --- */
/* Used on "Kirtan Curve" and "Log" modules to fill empty space */
.flex-grow {
    flex: 1; 
}

/* --- CONTENT SCROLLING --- */
/* Only the inside of the module scrolls */
.module-content, .right-module-content {
    flex: 1;            /* Fill the module */
    overflow-y: auto;   /* Scrollbar appears here if needed */
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.9em;
}

/* Header stays fixed at top */
.module-header, .right-module-header {
    flex-shrink: 0; 
    /* ... rest of your header styles ... */
    margin: 0.8rem;
    margin-bottom: 0 !important;
    padding-bottom: 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--secondary);
    color: var(--secondary);
    font-weight: 500;
    font-size: 0.8em;
}

/* --- TALA FILE TREE (Vertical List) --- */
.file-tree {
    display: block;
    overflow-y: auto;
    height: 100%;       /* Fill the module height */
    
    list-style: none;
    padding: 0.8rem 0 0.8rem 0 !important; /* top, right, botom, left */

    margin: 0;
    margin-top: 0 !important;
    
}

.file-item {    
    display: block;
    margin: 0 1rem; /* 1. Push content away from the edges (The "Float") */
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    
    /* The Terminal Look */
    border-bottom: 1px dashed var(--secondary); 
    
    font-size: 0.9em;
    color: var(--soft-white); /* Default Dim */
    transition: all 0.2s;
}

/* Hover Effect */
.file-item:hover {
    color: var(--mystic2); /* Text glows green */
    background-color: rgba(0, 255, 127, 0.05); /* Faint green terminal wash */
}

/* The Active State (Selected Rhythm) */
.file-item.active {
    background-color: transparent;
    color: var(--highlight);
    font-weight: bold;
    background-color: rgba(200, 159, 123, 0.1); /* Brighter than hover (0.05) */
    /* background-color: rgba(0, 255, 65, 0.1);  Subtle green bg */
    
    /* The Visual Marker */
    border-left: 3px solid var(--highlight); 
    padding-left: calc(1rem - 3px); /* Prevent text jump */
    
    text-shadow: 0 0 10px rgba(200, 159, 123, 0.4);
}

/* --- UI COMPONENTS --- */
.terminal-select, .tiny-input {
    background: transparent;
    border: 1px dashed var(--secondary);
    color: var(--highlight);
    font-family: inherit;
    padding: 0.5rem;
    cursor: pointer;
    text-transform: uppercase;
}
.terminal-select:focus, .tiny-input:focus { outline: none; border-color: var(--highlight); }

.terminal-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 2px;
    background: var(--secondary);
    outline: none;
    margin: 10px 0;
}
.terminal-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px; height: 10px;
    background: var(--highlight);
    cursor: pointer;
    box-shadow: var(--gold-glow);
}

/* --- BRACKET BUTTONS (HTML Version) --- */
.terminal-btn {
    background: transparent;
    border: none;           /* Remove the box */
    color: var(--highlight); /* Gold text */
    font-family: inherit;
    font-size: 1em;
    cursor: pointer;
    padding: 2px 4px;             /* added some padding for bg highlight */
    transition: color 0.2s;
}

/* HOVER: Gold Block / Black Text */
.terminal-btn:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* Danger/Active State */
.terminal-btn.danger-zone {
    color: var(--danger);
}
/* HOVER: Red Block / White Text */
.terminal-btn.danger-zone:hover {
    background-color: #d9534f; /* Red */
    color: #fff !important;    /* White */
    text-shadow: none;
}

.button-row {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Keep them vertically centered */
    gap: 0.5rem;         /* Space between the two buttons */
    width: 100%;
    margin-top: 5px; /* Spacing from slider */
}

/* The Tap Button (The "1" in 3:1) */
#btn-tap {
    flex: 1;              /* 1 part width */
    color: var(--secondary); /* Greyed out (Low priority) */
    font-weight: normal;
    text-align: center;
    border: none;         /* Ensure no border */
    background: none;     /* Ensure no background */
    box-shadow: none !important; /* Remove any glow */
}

#btn-tap:hover {
    background-color: var(--highlight);
    color: var(--background);
    border-radius: 2px;
}

/* --- THE PRIMARY BUTTON (Init Engine) --- */
.terminal-btn.glow {
    flex: 3;              /* 3 parts width */
    
    /* VISUAL POP (No Borders) */
    color: var(--highlight);
    font-weight: 700;     /* Bold */
    font-size: 1.1em;     /* Slightly larger */
    text-align: center;
    border: none;
    background: none;
    
    /* THE "BREATH" ANIMATION */
    animation: textBreath 3s infinite ease-in-out;
}

/* Hover: Stop animation, go full brightness */
.terminal-btn.glow:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* --- DRUT BUTTON (Specific Override) --- */
#btn-drut {
    /* Stop stretching full width */
    align-self: flex-start; 
    
    /* Formatting */
    margin-top: 0;       /* Push it down from the main controls */
    font-size: 0.85em;      /* Make it slightly more discreet */

    padding: 6px 10px;   /* Increases clickable area */
    /* OPTICAL ALIGNMENT */
    /* Since padding pushes text right, we pull the button left 
       so the text still visually aligns with the slider above. */
    /* margin-left: -10px; - added below with init btn*/
}

/* --- DRUT MODE ACTIVE (Latched On) --- */
.terminal-btn.danger-zone.active {
    background-color: var(--danger);
    color: #fff !important;       /* High contrast white text */
    text-shadow: none;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.4); /* Red "Warning" Glow */
}

/* --- DRUT MODE (The "Green Light" Turbo Style) --- */
#btn-drut {
    /* Use your Mystic Green variable */
    color: var(--mystic2); 
    border-color: var(--mystic2);
}

/* Hover State */
#btn-drut:hover {
    background-color: rgba(0, 255, 127, 0.2); /* Low opacity green bg */
    color: #fff !important;
    text-shadow: 0 0 8px var(--mystic2);
    border-radius: 2px;
}

/* Active (Latched) State */
#btn-drut.active {
    background-color: var(--mystic2);
    border-color: var(--mystic2);
    color: #000 !important; /* Black text on neon green looks very "Terminal" */
    text-shadow: none;
    box-shadow: 0 0 20px var(--mystic2); /* Strong Green Glow */
}

.control-stack { align-items: stretch; gap: 1rem; }
.flex-row { display: flex; justify-content: space-between; align-items: center; }
.small-gap { gap: 0.5rem; justify-content: flex-start; }
.tiny-input { width: 40px; text-align: center; }

/* --- BPM READOUT (Tight & Bright) --- */
.bpm-display {
    display: block;
    width: 100%;
    text-align: center;
    
    /* Typography */
    font-size: 3rem;    /* Slightly larger for impact */
    font-weight: 500;
    color: var(--sattva-glow);
    text-shadow: 0 0 10px rgba(200, 159, 123, 0.3); /* Subtle Gold Glow */
    
    /* Spacing Fixes (The Crunch) */
    line-height: 0.85;    /* Very tight line height */
    margin-top: 0.2rem;   /* Small gap from header */
    margin-bottom: 0;/* Tight to the slider */
}

/* The "BPM" text next to the number */
.bpm-display .unit {
    font-size: 0.8rem;
    color: var(--secondary);
    vertical-align: super; /* Lifts it up to the top of the number */
    margin-left: 3px;
    letter-spacing: 1px;
}

/* --- MOBILE SYSTEM ALERT (No Border, Red Text) --- */
.mobile-audio-warning {
    display: none; 
    
    /* Layout */
    margin-top: 1px;
    margin-bottom: 4px;
    
    /* Terminal Styling */
    font-family: var(--font-mono);
    font-size: 0.65rem; 
    letter-spacing: 1.5px;
    
    /* The "Critical Error" Red */
    color: #ff5f5f;       
    text-shadow: 0 0 5px rgba(255, 95, 95, 0.4);
    
    text-align: center;
    
    /* Subtle Pulse */
    animation: alertPulse 3s infinite ease-in-out;
}

@keyframes alertPulse {
    0%   { opacity: 0.7; }
    50%  { opacity: 1.0; text-shadow: 0 0 10px rgba(255, 95, 95, 0.6); }
    100% { opacity: 0.7; }
}

/* --- TOGGLE SWITCHES (Positive) --- */
.toggle-btn {
    color: var(--soft-white); /* Default: Dim/Waiting */
    transition: all 0.2s;
    min-width: 80px;         /* Prevents layout jump when text changes */
    text-align: right;       /* Aligns neatly against the right edge */
}

/* THE "ON" STATE */
.toggle-btn.active {
    color: var(--highlight); /* Gold */
    text-shadow: 0 0 10px rgba(200, 159, 123, 0.6); /* Soft Gold Glow */
    font-weight: bold;
}

/* HOVER ON ACTIVE STATE (Invert Colors) */
.toggle-btn.active:hover {
    background-color: var(--highlight); /* Gold Background */
    color: var(--background);           /* Black Text */
    text-shadow: none;                 /* Remove the glow so text is crisp */
    border-radius: 2px;
    
    /* Optional: Ensure cursor looks interactive */
    cursor: pointer;
}

/* --- TERMINAL INPUT GROUPS (The [-] 0 [+] Style) --- */

/* Wrapper to align items nicely */
.input-group-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

/* The Number Input Itself */
.terminal-num-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--highlight); /* Gold Underline */
    color: var(--highlight);
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9rem;
    text-align: center;
    width: 30px; /* Width for 2 digits */
    padding: 0;
    -moz-appearance: textfield; /* Firefox fix */
}

/* Hide default browser spinners (Chrome/Safari/Edge) */
.terminal-num-input::-webkit-outer-spin-button,
.terminal-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* focus state */
.terminal-num-input:focus {
    outline: none;
    border-bottom-style: solid;
    box-shadow: 0 1px 0 var(--highlight);
}

/* The [-] and [+] Buttons */
.terminal-arrow-btn {
    background: transparent;
    border: none;
    color: var(--soft-white); /* Grey by default */
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 4px;
    transition: all 0.2s;
}

/* Hover: Highlight Background, Dark Text */
.terminal-arrow-btn:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* --- RESET BUTTON STYLING --- */
#btn-stop {
    /* Subtle default state */
    border-color: var(--secondary);
    color: var(--soft-white);
    opacity: 0.8;
}

/* Hover State: Orange Fill, Black Text */
#btn-stop:hover {
    background-color: #ffaa00;       /* Fill with Orange */
    color: #000 !important;          /* Text becomes Black */
    border-color: #ffaa00; 
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5); /* Stronger Glow */
    border-radius: 2px;
    opacity: 1;
}

/* Active State (When clicked) */
#btn-stop:active {
    background-color: #ffaa00;
    color: #000;
}

/* --- BUTTON ROW ALIGNMENT (2:1 Split) --- */

/* 1. The Left-Side "Command" Buttons (Init & Drut) */
#btn-play, 
#btn-drut {
    flex: 2;                    /* Takes up 2/3rds of the row */
    text-align: left;           /* Left align the text */
    justify-content: flex-start; /* Force left alignment if flex is used */
    padding-left: 15px;         /* Add indent so text isn't glued to border */
    margin-left: -10px;
}

/* 2. The Right-Side "Utility" Buttons (Reset & Tap) */
#btn-stop, 
#btn-tap {
    flex: 1;                    /* Takes up 1/3rd of the row */
    text-align: left;         /* Keep these centered */
    justify-content: center;
}

/* --- UI UTILITIES --- */
.dashed-divider {
    width: 100%;
    height: 1px;
    border-bottom: 1px dashed var(--secondary);
    margin: 0 0;
    opacity: 1;
}

/* --- THE AVARTAN VISUALIZER --- */
.center-stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.chakra-wrapper {
    width: 350px;
    height: 350px;
    min-height: 350px;  /* ABSOLUTE MINIMUM SIZE - Prevents squishing */
    min-width: 350px;
    
    /* ANCHOR IT: 20px from top, Centered horizontally, 0px bottom */
    margin: 0 auto 0 auto; 
    
    position: relative;
    max-width: 90%;
    max-height: 90%;

    /* border: 2px solid #00FFFF !important;  CYAN: The Ring Box */
}

.chakra-ring {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    border: 1px dashed rgba(85, 85, 85, 0.3); /* Faint guide circle */
}

/* NODES */
.node {
    position: absolute;
    transform: translate(-50%, -50%); /* Center the node on its coordinate */
    transition: all 0.1s;
    background: var(--background);
    z-index: 2;
}

/* Node Types */
/* The Sam (Beat 1) - Diamond */
.node.type-sam {
    width: 24px; height: 24px;
    border: 3px solid var(--highlight);
    transform: translate(-50%, -50%) rotate(45deg); /* Diamond */
}
/* The Tali (Measure Start) - Square */
.node.type-tali {
    width: 18px; height: 18px;
    border: 3px solid var(--primary);
}
/* The Khali (Empty) - Circle Hollow */
.node.type-khali {
    width: 18px; height: 18px;
    border: 2px solid var(--soft-white);
    border-radius: 50%;
    opacity: 0.8;
}
/* Normal Beat - Small Dot */
.node.type-beat {
    width: 12px; height: 12px;
    background: var(--secondary);
    border-radius: 50%;
}

/* --- TYPE 4: MICRO NODE (The Ghost Beat) --- */
.node.type-micro {
    width: 6px;       
    height: 6px;
    background: #444;   /* Dark Grey (Visible against black, but subtle) */
    border-radius: 50%; /* vital: makes it a dot */
    border: none;       /* No border */
}

/* --- PHASE 3: COMBO NODES (Visual Polyphony) --- */

/* TYPE 5: DHA (Open Bass + Open Treble) */
/* Visual: Gold Ring, Hollow Center (Maximum Resonance) */
.node.type-dha {
    width: 18px; height: 18px;
    border: 3px solid var(--primary); /* Gold Bass */
    background: var(--background);    /* Hollow (Open Treble) */
    border-radius: 50%;
}

/* TYPE 6: DHIN (Open Bass + Closed Treble) */
/* Visual: Gold Ring, Solid Center (Resonant Bass, Muted High) */
.node.type-dhin {
    width: 16px; height: 16px;
    border: 3px solid var(--primary); /* Gold Bass */
    background: var(--secondary);     /* Solid Grey (Closed Treble) */
    border-radius: 50%;
}

/* TYPE 7: NAM (Closed Bass + Open Treble) */
/* Visual: Grey Ring, Hollow Center (Dry Bass, Ringing High) */
.node.type-nam {
    width: 14px; height: 14px;
    border: 2px solid var(--secondary); /* Grey Bass */
    background: var(--background);      /* Hollow (Open Treble) */
    border-radius: 50%;
}

/* TYPE 8: KAT (Closed Bass + Closed Treble) */
/* Visual: Solid Grey Dot (Full Stop) */
.node.type-kat {
    width: 12px; height: 12px;
    background: var(--secondary);       /* Solid Grey */
    border: 1px solid #333;             /* Subtle dark edge */
    border-radius: 50%;
}

/* ACTIVATION STATES (Animation) */
.node.active {
    background-color: var(--sattva-glow);
    border-color: var(--sattva-glow);
    box-shadow: 0 0 20px var(--sattva-glow), 0 0 40px var(--highlight);
    z-index: 10;
    transform: translate(-50%, -50%) scale(1.5);
}
/* If active is Sam, keep rotation */
.node.type-sam.active {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.3);
}

/* Micro Active State - Overrides the default .node.active giant glow */
.node.type-micro.active {
    background-color: var(--secondary); /* Light grey */
    box-shadow: 0 0 8px var(--secondary); /* Smaller, tighter glow */
    transform: translate(-50%, -50%) scale(2.0); /* Pop a bit bigger since it starts small */
    /* We don't want the green --sattva-glow here, so we override it */
}

.chakra-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
}

.beat-main {
    font-size: 5rem;
    color: var(--highlight);
    line-height: 1;
}
.beat-sub {
    font-size: 1.5rem;
    color: var(--soft-white);
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* --- COLUMN 2 SPLIT --- */
 .visualizer-module {
    height: 560px;      /* Enough space for the 400px Ring + Header */
    flex-shrink: 0;     /* Do not let this shrink; it is the star */

    /* Ensure these are set to keep layout stable */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Distributes Header, Ring, Text evenly */

    gap: 0;
    padding-bottom: 18px;
} 

/* --- MANTRA STRIP (The Ticker) --- */
.mantra-container {
    width: 100%;
    max-width: 350px;
    
    /* FLOAT IT: Centers the text in the remaining space below the ring */
    margin: 0 auto 0 auto; 
    
    display: grid;
    justify-items: center;
    align-items: center;
    gap: 4px 2px;

    /* border: 2px solid #FF00FF !important; */
}

/* Update the Main Strip to stack rows vertically */
#mantra-strip {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Space between the rows */
    align-items: center;
    width: 100%;
}

/* New Class for each Group/Line */
.mantra-row {
    display: flex;
    flex-direction: row;
    gap: 2px; /* Space between the words */
    justify-content: center;
    width: 100%;
}

.mantra-word {
    font-family: var(--font-mono);
    font-size: 0.85rem;     /* Slightly smaller to ensure fit */
    color: var(--soft-white);
    text-transform: uppercase;
    transition: all 0.1s ease;
    opacity: 0.8;
    font-weight: bold;
    padding: 4px 0;
    width: 100%;            /* Fill the grid cell */
    text-align: center;
    flex: 1; 
    min-width: 40px; /* Ensures short words don't collapse */
}

/* The Active Syllable */
.mantra-word.active {
    color: var(--highlight);
    font-weight: bold;
    opacity: 1;
    background-color: rgba(255, 170, 0, 0.1); /* Subtle highlight box */
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.2);
}

/* Optional: Underline the 'Sum' (Beat 1) */
.marker-sam {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: var(--surface-light);
}

/* --- SESSION PILOT (Split Layout) --- */
.pilot-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden; 
}

/* 1. MONITOR (Left Pane) */
.pilot-monitor {
    flex: 1; /* Takes 50% width */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0,0,0,0.15); 
    position: relative;
    padding: 10px;
}

/* The Big Timer */
#pilot-timer-display {
    font-family: var(--font-mono);
    font-size: 2.2rem; 
    color: var(--highlight);
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.2);
}

#pilot-status-text {
    font-size: 0.7rem;
    color: var(--soft-white);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

/* The Grey "Track" */
.pilot-progress-track {
    /* 1. Width & Centering */
    width: 80%;           /* Reduced from 100% */
    margin-left: auto;    /* Centers it horizontally */
    margin-right: auto;   /* Centers it horizontally */
    height: 6px;                  /* Thicker for better visibility */
    background-color: #333;       /* Dark Grey background */
    border: 1px solid #555;       /* Subtle border to define the empty bar */
    margin-top: 25px;             /* Push it down from the buttons */
    margin-bottom: 10px;           /* Lift it up off the bottom edge */
    position: relative;
    overflow: hidden;             /* Ensures the fill stays inside corners */
}

/* The Gold "Fill" */
#pilot-progress-fill {
    height: 100%;
    width: 0%;                    /* Starts empty */
    background-color: var(--mystic2);
    box-shadow: 0 0 10px var(--mystic2); /* Glowing tip */
    transition: width 1s linear;  /* Smooth movement every second */
}

/* 2. THE DIVIDER */
.pilot-divider {
    width: 1px;
    background: var(--border);
    opacity: 0.5;
}

/* 3. COMMANDER (Right Pane) */
.pilot-commander {
    flex: 1; /* Takes 50% width */
    display: flex;
    flex-direction: column;
    justify-content: space-evenly; 
    padding: 15px;
    gap: 10px;

    overflow-y: auto; 
    min-height: 0;
    
}

.pilot-control-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pilot-control-row label {
    font-size: 0.7rem;
    color: var(--soft-white);
    text-transform: uppercase;
}

/* Duration Inputs */
.duration-control {
    display: flex;
    align-items: center;
    gap: 6px; /* Space between [-] and Number */
}

/* Horizontal Row Utility */
.pilot-control-row.inline-row {
    flex-direction: row;            /* Side by Side */
    justify-content: space-between; /* Label Left, Controls Right */
    align-items: center;            /* Center Vertically */
}

.dur-btn {
    background: transparent;
    border: none;
    color: var(--soft-white);
    font-family: inherit;
    font-size: 1rem; /* Slightly larger for touch targets */
    cursor: pointer;
    padding: 0 4px;
    transition: all 0.2s;
}

.dur-btn:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

#pilot-duration-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--highlight);
    color: var(--highlight);
    font-family: 'Source Code Pro', monospace;
    font-size: 1rem;
    text-align: center;
    width: 40px; 
    padding: 8px 0 0 0;
    -moz-appearance: textfield;
}
#pilot-duration-input:focus {
    outline: none;
    border-bottom-style: solid;
}

#pilot-duration-input::-webkit-outer-spin-button,
#pilot-duration-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* The Master Button */
.pilot-master-btn {
    background: transparent;
    border: none;
    color: var(--highlight); 
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: none;
    
    /* UPDATED ALIGNMENT SETTINGS */
    width: auto;            /* Don't stretch to fill width */
    text-align: left;       /* Text aligns left */
    align-self: flex-start; /* Stick to the left side of the flex container */
    padding: 8px 0;        
    
    transition: color 0.2s ease;
}

/* Hover effects remain the same */
.pilot-master-btn:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* 1. The "Running" Look (Gold Text) */
.pilot-master-btn.active-state {
    color: var(--highlight);
    border-color: var(--highlight); /* Optional: Gold border when running */
    text-shadow: 0 0 5px rgba(255, 170, 0, 0.5);
}

/* 2. The Universal Hover (Invert Colors) */
/* We use !important to guarantee this overrides any specific state colors */
.pilot-master-btn:hover,
.pilot-master-btn.active-state:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* --- CUSTOM TERMINAL SELECT --- */
#pilot-preset-select {
    /* 1. Reset Browser Defaults */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* 2. Terminal Styling */
    background-color: rgba(0, 0, 0, 0.2); /* Slight background dim */
    color: var(--highlight);              /* Gold Text */
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-transform: uppercase;
    
    /* 3. The Border (Full box to define the click area) */
    border: 1px dashed var(--secondary); 
    border-radius: 0; /* Sharp corners */
    
    /* 4. Spacing */
    padding: 8px 10px;
    width: 100%;
    cursor: pointer;
    
    /* 5. Custom Arrow Icon (SVG Data URI) */
    /* This creates a small gold triangle on the right */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFD700%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    
    transition: all 0.2s ease;
}

/* Hover State */
#pilot-preset-select:hover {
    border-color: var(--highlight);
    background-color: rgba(255, 170, 0, 0.05); /* Tiny glow */
}

/* Focus State (When clicked) */
#pilot-preset-select:focus {
    outline: none;
    border-style: solid; /* Turn dashed to solid when active */
    border-color: var(--highlight);
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.1);
}

/* Style the Dropdown Options (Dark background for the list) */
#pilot-preset-select option {
    background-color: #000; 
    color: var(--highlight);
    font-family: var(--font-main); /* Sans-serif for readability in list */
    padding: 10px;
}

/* --- MOBILE SPLIT (Stack them) --- */
@media (max-width: 768px) {
    .pilot-container {
        flex-direction: column; /* Stack Top/Bottom */
        min-height: 280px;      /* Ensure enough height */
    }
    
    .pilot-monitor {
        padding: 20px 0; 
        border-bottom: 1px dashed var(--border);
    }
    
    .pilot-divider { display: none; } /* Hide vertical line */
}


@keyframes textBreath {
    0% {
        text-shadow: 0 0 0 rgba(200, 159, 123, 0);
        opacity: 0.8;
    }
    50% {
        /* Soft Gold Glow */
        text-shadow: 0 0 15px rgba(200, 159, 123, 0.6);
        opacity: 1;
    }
    100% {
        text-shadow: 0 0 0 rgba(200, 159, 123, 0);
        opacity: 0.8;
    }
}

/* --- LAYOUT UTILITY: Prevent Crushing --- */
.no-shrink {
    flex-shrink: 0;        /* Never let this element get smaller */
    height: auto;          /* Or set a fixed height if needed */
    min-height: min-content; /* Ensure all controls are visible */
}

/* Force the List Module to contain its scrollbar */
.scroll-module {
    flex: 1;               /* Grow to fill available space */
    min-height: 0;         /* CRITICAL: Allows flex child to shrink below content size */
    display: flex; 
    flex-direction: column;
}

/* --- SYSTEM LINKS (Imported Style) --- */
.feedback-link {
    display: block;
    padding: 0 0;
    color: var(--highlight);
    text-decoration: none;
    font-family: 'Space Mono', monospace; /* or your variable var(--font-mono) */
    transition: color 0.2s ease;
    border-bottom: 1px solid transparent; /* Prevents layout jump on hover if you add borders later */
}

.feedback-link:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* Secondary Link (Bugs) - slightly dimmer or different color */
.feedback-link.link-secondary {
    color: var(--secondary);
    font-size: 0.9em;
    opacity: 0.7;   
}
.feedback-link.link-secondary:hover {
    background-color: var(--mystic2); 
    color: #000000; 
        
    /* The Structure */
    border-radius: 2px;
    text-decoration: none;
        
    /* Optional: A subtle glow to make it feel like a light source */
    box-shadow: 0 0 10px rgba(0, 255, 127, 0.5);
    border-color: var(--mystic2);
    cursor: pointer;
}

/* --- SYSTEM ID MODULE (ASCII LOGO) --- */

/* 1. Container Fixed Height */
#system-id-module {
    flex: 0 0 auto;
    min-height: 14em; 
    max-height: 14em;
    cursor: pointer;
    transition: border-color 0.3s;
}

/* 2. Content Alignment (Center Horizontal, Top Vertical) */
.system-id-link .module-content {
    display: flex;
    justify-content: center; /* Center Horizontal */
    align-items: flex-start; /* Align Top */
    padding-top: 0;
    
    flex-grow: 1;
    height: 100%;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
}

/* --- Graphic Logo Alignment & Glow --- */
        .sys-logo-img {
            max-width: 85%;       
            max-height: 10em;     
            width: auto;
            height: auto;
            display: block;
            
            /* --- THE STATIC GLOW --- */
            /* This creates a soft, ambient light behind the transparent pixels */
            filter: drop-shadow(0 0 5px var(--primary));
            
            /* NOTE: If using var(--primary) makes the glow too intense or solid, 
            swap it for a custom rgba value to lower the opacity, like this:
            filter: drop-shadow(0 0 15px rgba(166, 123, 91, 0.4)); */
        }


/* --- MOBILE RESPONSIVENESS (Stack & Order) --- */
@media (max-width: 768px) {

    html {
        height: auto !important;
        overflow-y: auto !important;
    }
    
    /* 1. THE CANVAS */
    body {
        padding: 0.2rem !important;
        height: auto !important;
        overflow-x: hidden;
    }

    /* 2. THE CONTAINER (Vertical Stack) */
    .ide-container {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        max-height: none !important;
        min-height: 100vh !important;
        align-items: center !important; /* Forces modules to the center */
        overflow: visible !important;
        padding: 0 !important;
        gap: 0.75rem;
    }

    /* 3. THE UNWRAP TRICK (Dissolve Columns) */
    /* UPDATED: Using your exact column classes */
    .ide-sidebar, 
    .ide-main, 
    .ide-sidebar-right {
        display: contents !important;
    }

    /* 4. ORDERING (0-7) */
    
    /* 0) Select (Top) */
    #mod-select { order: 0; }
    
    /* 1) Visualizer (Main Attraction) */
    #mod-visualizer { order: 1; }
    
    /* 2) Tempo */
    #mod-tempo { order: 2; }
    
    /* 3) Curve */
    #mod-curve { order: 3; }
    
    /* 4) Session Pilot */
    #mod-pilot { order: 4; }

    /* 5) Audio Core */
    #mod-audio { order: 5; }
    
    /* 6) System Links */
    #system-links-module { order: 6; }
    
    /* 7) System ID (Logo) */
    #system-id-module { order: 7; }

    /* 5. MODULE RESET (Full Width & Borders) */
    .module, 
    .right-module,
    .visualizer-module, /* Catch the visualizer class */
    .system-id-link {
        /* Force full width */
        width: 98% !important;
        /* 2. CENTER IT: */
        margin-left: auto !important;
        margin-right: auto !important;


        min-width: 0 !important;
        max-width: none !important;
        /* Reset heights so they grow naturally */
        height: auto !important;
        min-height: auto !important;
        flex: none !important;
        flex-grow: 0 !important;
        margin: 0 !important;
        padding: 0 !important;

        /* Ensure padding doesn't break width */
        box-sizing: border-box !important;
        
        /* STRICT REQUEST: FULL BORDERS (Primary Dashed) */
        border: 1px dashed var(--primary) !important;       
        border-radius: 0 !important;
    }

    /* --- SIDEBAR COLLAPSE LOGIC (Tala Select) --- */

    /* 1. Show the Toggle Button */
    #mobile-toggle-btn {
        display: inline !important;
        cursor: pointer;
        color: var(--secondary);
    }

    /* 2. Hide the list by default */
    #tala-list {
        display: none;
        /* Your exact scroll settings: */
        max-height: 40vh; 
        overflow-y: auto;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    /* 3. Show the list when 'mobile-open' */
    #mod-select.mobile-open #tala-list {
        display: block;
        animation: accordionFade 0.3s ease-out;
    }

    /* 4. Active Open State: Gold Border */
    #mod-select.mobile-open {
        border: 1px dashed var(--highlight) !important;
        box-shadow: 0 0 10px rgba(200, 159, 123, 0.1);
        transition: border-color 0.3s ease;
    }

    /* 5. Make header clickable */
    #mod-select .module-header {
        display: flex; /* Ensure it's a flex container */
        justify-content: space-between; /* Pushes Title left and Button right */
        align-items: center;
        cursor: pointer;
    }

    /* Animation */
    @keyframes accordionFade {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Add space inside the bottom border */
    #mod-select {
        padding-bottom: 0.8rem !important;
    }

    .chakra-wrapper {
        width: 80vw;
        height: 80vw;
        margin: 2rem 0;
    }

    /* --- VISUALIZER PADDING FIX --- */
    .visualizer-module {
        /* This overrides the "padding: 0" reset above */
        padding-bottom: 30px !important; 
    }    

    /* Add breathing room for the Logo on mobile */
    #system-id-module .module-content {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .mobile-audio-warning {
        display: block;
    }
}
    
    
