:root {
    --color-brand: #00f2ff;
    --color-active: #ff00cc;
    --color-bg: #000511;
    --color-panel: rgba(255, 255, 255, 0.05);
    --color-border: rgba(0, 242, 255, 0.3);
}

* { box-sizing: border-box; }

body { 
    background: var(--color-bg); 
    color: var(--color-brand); 
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0; 
    padding: 0;
    background-image: radial-gradient(circle at 50% 50%, #001122 0%, var(--color-bg) 100%);
    height: 100vh; 
    overflow: hidden;
    display: flex; 
    justify-content: center; 
    align-items: center;
}

/* --- Layout State Machine --- */

#app-container {
    display: flex;
    width: 100%; height: 100%;
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 1. Landing Mode */
#app-container.landing-mode {
    justify-content: center; 
    align-items: center; 
    padding: 0;
}

#app-container.landing-mode #sidebar {
    width: 100%; 
    max-width: 600px;
    height: auto; 
    border: none; 
    background: transparent; 
    box-shadow: none;
    align-items: center; 
    text-align: center;
}

#app-container.landing-mode #graph-wrapper {
    flex: 0; width: 0; opacity: 0; padding: 0; border: none; margin: 0;
}

/* 2. Dashboard Mode */
#app-container.dashboard-mode {
    padding: 20px; 
    gap: 20px;
}

#app-container.dashboard-mode #sidebar {
    flex: 0 0 320px;
    max-width: 400px;
    min-width: 280px;
    height: 100%;
    overflow-y: auto;
    
    background: var(--color-panel); 
    backdrop-filter: blur(15px);
    border: 2px solid var(--color-border); 
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.1);
    padding: 20px;
    text-align: left; 
    align-items: stretch;

    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

#app-container.dashboard-mode #graph-wrapper {
    flex: 1; 
    opacity: 1; 
    border: 1px solid var(--color-border);
}

/* Utilities for Mode Switching */
.dashboard-only { display: none !important; }
.landing-mode .landing-only { display: block; }
#app-container.dashboard-mode .landing-only { display: none !important; }
#app-container.dashboard-mode .dashboard-only { display: block !important; }

/* --- Sidebar Components --- */

#sidebar {
    display: flex; flex-direction: column; gap: 15px;
    transition: all 0.6s ease;
}

/* Custom Scrollbar (Webkit) */
#app-container.dashboard-mode #sidebar::-webkit-scrollbar { width: 6px; }
#app-container.dashboard-mode #sidebar::-webkit-scrollbar-track { 
    background: rgba(0,0,0,0.2); margin: 10px 0; border-radius: 3px; 
}
#app-container.dashboard-mode #sidebar::-webkit-scrollbar-thumb { 
    background: rgba(0, 242, 255, 0.3); border-radius: 3px; 
}
#app-container.dashboard-mode #sidebar::-webkit-scrollbar-thumb:hover { 
    background: var(--color-brand); 
}

header h3 { 
    margin: 0; color: #fff; letter-spacing: 3px; 
    font-size: 32px; text-shadow: 0 0 15px var(--color-brand); 
}

header .subtitle { 
    font-size: 12px; color: var(--color-active); font-weight: bold; 
    text-transform: uppercase; letter-spacing: 2px; 
}

.input-group { display: flex; flex-direction: column; width: 100%; }

textarea { 
    background: rgba(0, 0, 0, 0.6); color: #fff; 
    border: 1px solid var(--color-brand); border-radius: 12px; padding: 15px; 
    font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; resize: none;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    transition: all 0.3s; width: 100%; min-height: 200px;
}
textarea:focus { outline: none; border-color: #fff; box-shadow: 0 0 15px var(--color-brand); }

/* --- Controls --- */

.control-row { 
    display: flex; align-items: center; justify-content: space-between; gap: 10px; 
    background: rgba(0,0,0,0.2); padding: 10px; 
    border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); 
}

input[type="number"] {
    width: 70px; background: transparent; color: var(--color-active);
    border: none; border-bottom: 2px solid var(--color-active);
    text-align: right; font-size: 18px; font-weight: bold;
}
input[type="number"]:focus { outline: none; }

/* Range Slider */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]:focus { outline: none; }

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 16px; width: 16px;
    border-radius: 50%; background: var(--color-active);
    cursor: pointer; margin-top: -6px;
    box-shadow: 0 0 10px var(--color-active);
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px; cursor: pointer;
    background: rgba(0, 242, 255, 0.3); border-radius: 2px;
}
/* Firefox specific range styles omitted for brevity but should match above */

/* --- Buttons --- */

.btn-row { display: flex; gap: 10px; margin-top: 10px; width: 100%; }

button { 
    flex: 1; padding: 15px; cursor: pointer;
    background: linear-gradient(180deg, rgba(0, 242, 255, 0.1) 0%, rgba(0, 136, 255, 0.1) 100%);
    border: 1px solid var(--color-brand);
    color: var(--color-brand); font-weight: bold; border-radius: 12px; 
    text-transform: uppercase; transition: all 0.2s ease;
    font-size: 13px; letter-spacing: 1px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover { background: var(--color-brand); color: #000; box-shadow: 0 0 20px var(--color-brand); }
button.active { background: var(--color-active); border-color: var(--color-active); color: white; box-shadow: 0 0 30px var(--color-active); }

button:disabled {
    opacity: 0.3; cursor: not-allowed;
    background: transparent; box-shadow: none;
    border-color: #555; color: #888;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(0, 242, 255, 0.7); border-color: #fff; }
    70% { box-shadow: 0 0 0 15px rgba(0, 242, 255, 0); border-color: var(--color-brand); }
    100% { box-shadow: 0 0 0 0 rgba(0, 242, 255, 0); border-color: #fff; }
}

button.suggested {
    animation: pulse-glow 2s infinite;
    background: rgba(0, 242, 255, 0.2);
    color: #fff;
}

.btn-num { font-size: 14px; opacity: 0.8; font-weight: 900; }

/* --- Informational --- */

.instruction-box { color: #aaa; font-size: 13px; margin-bottom: 15px; text-align: center; }

.about-section {
    margin-top: 20px; text-align: left;
    border-top: 1px solid rgba(255,255,255,0.1); padding-top: 20px;
}
.about-section h4 { color: #fff; margin: 0 0 10px 0; }
.about-text { font-size: 12px; color: #aaa; line-height: 1.5; }

#errorLog { 
    display: none; margin-top: 10px; 
    color: #ffcccc; font-size: 11px; 
    background: rgba(255,0,0,0.3); padding: 10px; border-radius: 8px; 
}
.err-chord { font-weight: bold; font-family: monospace; color: #fff; }

/* --- Graph Visualization --- */

#graph-wrapper {
    position: relative; 
    background: rgba(0, 0, 0, 0.4); 
    border-radius: 20px; 
    overflow: hidden; 
    box-shadow: inset 0 0 50px #000;
    transition: all 0.6s ease;
    display: flex; justify-content: center; align-items: center;
}

#graph-wrapper.fullscreen {
    position: fixed; top: 0; left: 0; width: 100vw !important; height: 100vh !important;
    z-index: 9999; border-radius: 0; border: none;
    background: radial-gradient(circle at 50% 50%, #002244 0%, #000511 100%);
}

svg { width: 100%; height: 100%; display: block; }

#fs-btn {
    position: absolute; top: 20px; right: 20px;
    background: rgba(0,0,0,0.6); color: var(--color-brand);
    border: 1px solid var(--color-brand); border-radius: 8px;
    width: 40px; height: 40px; cursor: pointer; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
#fs-btn:hover { background: var(--color-brand); color: #000; }

.tooltip {
    position: absolute; pointer-events: none; opacity: 0; z-index: 10000;
    background: rgba(0, 10, 20, 0.95); border: 1px solid var(--color-brand); 
    border-radius: 6px; padding: 8px; color: #fff; font-size: 11px;
}