:root {
    --bg-color: #1a1a1a;
    --key-white: #f0f0f0;
    --key-black: #2c2c2c;
    --key-active: #ff0055;
    --key-striking: #ff88aa;
    --text-color: #cccccc;
    --circle-stroke: #444;
    --circle-active: #ff0055;
    --circle-text: #fff;
    --polygon-fill: rgba(255, 0, 85, 0.3);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#visualizer-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#circle-of-fifths, #tonnetz, #effects-canvas {
    position: absolute;
}

#circle-of-fifths { right: 50px; top: 50px; width: 300px; height: 300px; }
#tonnetz { left: 50px; top: 50px; width: 400px; height: 300px; overflow: hidden; }
#effects-canvas { top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

#piano-container {
    height: 150px;
    width: 100%;
    display: flex;
    justify-content: center;
    position: relative;
    background-color: #111;
    padding-top: 10px;
}

#piano-drag-handle {
    position: absolute; top: 0; left: 0; width: 100%; height: 10px;
    background: transparent; cursor: row-resize; z-index: 10;
}
#piano-drag-handle:hover { background: rgba(255, 255, 255, 0.1); }

.resize-handle {
    position: absolute; bottom: 0; right: 0; width: 15px; height: 15px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #444 50%);
    border-radius: 0 0 5px 0; z-index: 20;
}
.resize-handle:hover { background: linear-gradient(135deg, transparent 50%, #ff0055 50%); }

.key {
    position: relative; border: 1px solid #000; border-radius: 0 0 5px 5px; cursor: pointer;
    transition: background-color 0.05s ease;
}
.key.white { background-color: var(--key-white); width: 2.2%; height: 100%; z-index: 1; }
.key.black { background-color: var(--key-black); width: 1.2%; height: 60%; position: absolute; z-index: 2; }
.key.active { background-color: var(--key-active) !important; box-shadow: 0 0 15px var(--key-active); }
.key.striking { background-color: var(--key-striking) !important; box-shadow: 0 0 25px var(--key-striking), 0 0 10px white; z-index: 3; }
.key.hint-highlight { background-color: #555 !important; border: 2px solid #aaa !important; }
.key.hint-highlight.white { background-color: #e0e0e0 !important; border: 2px solid #888 !important; }
.key.hint-highlight.black { background-color: #444 !important; border: 2px solid #aaa !important; }
.key.active.hint-highlight { background-color: var(--key-active) !important; border-color: #fff !important; }

#status-bar { position: absolute; top: 10px; left: 10px; font-size: 0.8rem; opacity: 0.7; }

/* === Settings Panel & Tabs === */
#settings-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid #333;
    border-radius: 8px;
    width: 600px; /* Wider for tabs */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    transition: width 0.3s ease;
}

#settings-panel.minimized {
    width: auto;
    border: none;
    background: transparent;
    box-shadow: none;
}

.settings-header {
    padding: 10px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#settings-toggle {
    cursor: pointer;
    background: #333;
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
}
#settings-toggle:hover { background-color: #444; }

.settings-content {
    display: none;
    flex: 1;
    overflow: hidden; /* Manage scroll inside main */
}
#settings-panel:not(.minimized) .settings-content {
    display: block;
}

/* Tab Layout */
.settings-layout {
    display: flex;
    height: 60vh; /* Fixed height for scrollable content */
}

.settings-sidebar {
    width: 140px;
    background: rgba(255, 255, 255, 0.05);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #aaa;
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-left: 3px solid var(--key-active);
}

.settings-main {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Scrollbar for settings */
.settings-main::-webkit-scrollbar { width: 6px; }
.settings-main::-webkit-scrollbar-track { background: #222; }
.settings-main::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }

.tab-content { display: none; animation: fadeIn 0.2s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.tab-content h3 {
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    margin-bottom: 15px;
    color: #fff;
}

.sub-group {
    background: rgba(255,255,255,0.03);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #333;
}
.sub-group h4 { margin: 0 0 10px 0; font-size: 0.95rem; color: #ddd; }

.hint-text { font-size: 0.75rem; color: #888; font-style: italic; margin-top: 5px; }

/* Reusing existing item styles but tweaking */
.setting-item { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; font-size: 0.9rem; }
.setting-item label { color: #ccc; }
.setting-item-row { margin-bottom: 8px; display: flex; flex-direction: column; font-size: 0.9rem; }
.input-pair { display: flex; gap: 8px; align-items: center; }
.input-pair input[type="range"] { flex: 1; }

.metronome-controls { display: flex; flex-direction: column; gap: 10px; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 5px; }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.emoji-option {
    cursor: pointer; text-align: center; padding: 5px;
    border: 1px solid #444; border-radius: 4px; font-size: 1.2rem;
}
.emoji-option:hover { border-color: #888; }
.emoji-option.selected { background-color: var(--key-active); border-color: var(--key-active); }

/* SVG Styles */
.cof-circle { fill: none; stroke: var(--circle-stroke); stroke-width: 2; }
.cof-note-bg { fill: var(--bg-color); stroke: var(--circle-stroke); stroke-width: 2; transition: fill 0.1s; }
.cof-note-text { fill: var(--text-color); font-size: 14px; font-weight: bold; text-anchor: middle; dominant-baseline: central; }
.cof-note.active .cof-note-bg { fill: var(--circle-active); stroke: var(--circle-active); }
.cof-note.active .cof-note-text { fill: #fff; }
.cof-note.striking .cof-note-bg { fill: var(--key-striking); stroke: #fff; stroke-width: 3; }
.cof-note.hint-highlight .cof-note-bg { stroke: var(--key-active); stroke-dasharray: 4; }
.cof-chord-shape { fill: var(--polygon-fill); stroke: var(--circle-active); stroke-width: 1; pointer-events: none; }

.tonnetz-line { stroke: var(--circle-stroke); stroke-width: 1; opacity: 0.5; }
.tonnetz-node-bg { fill: var(--bg-color); stroke: var(--circle-stroke); stroke-width: 1.5; transition: fill 0.1s; }
.tonnetz-node-text { fill: var(--text-color); font-size: 12px; font-weight: bold; text-anchor: middle; dominant-baseline: central; user-select: none; }
.tonnetz-node.active .tonnetz-node-bg { fill: var(--key-active); stroke: var(--key-active); }
.tonnetz-node.active .tonnetz-node-text { fill: #fff; }
.tonnetz-node.striking .tonnetz-node-bg { fill: var(--key-striking); stroke: #fff; stroke-width: 3; }
.tonnetz-node.hint-highlight .tonnetz-node-bg { stroke: var(--key-active); stroke-dasharray: 3; }
.tonnetz-chord-shape { fill: var(--polygon-fill); stroke: var(--key-active); stroke-width: 1; pointer-events: none; }
