/* Nord Theme Palette */
:root {
    --bg: #2E3440; --bg-light: #3B4252; --bg-lighter: #434C5E;
    --text: #D8DEE9; --text-dim: #94A3B8;
    --primary: #88C0D0; --secondary: #81A1C1;
    --success: #A3BE8C; --error: #BF616A;
    --warning: #B48EAD; /* Nord Magenta */
    
    /* Layout */
    --sidebar-width: 320px;
    --transition-duration: 0.3s;
    --shadow-default: 0 10px 25px rgba(0,0,0,0.5);
}

body {
    margin: 0; overflow: hidden; background: var(--bg); color: var(--text);
    font-family: 'Fira Code', 'Roboto Mono', monospace; display: flex; height: 100vh;
}

/* Sidebar UI */
aside {
    width: var(--sidebar-width); background: var(--bg-light); 
    border-left: 1px solid var(--bg-lighter); z-index: 10;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
    transition: width var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex; flex-direction: column;
}

aside.collapsed { width: 0; }

.sidebar-inner {
    width: var(--sidebar-width); /* Fixed width content to prevent squashing */
    display: flex; flex-direction: column; height: 100%;
    overflow: hidden;
}

.panel-toggle {
    position: absolute;
    left: -24px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 64px;
    background: var(--bg-light);
    border: 1px solid var(--bg-lighter);
    border-right: none;
    border-radius: 4px 0 0 4px;
    color: var(--primary);
    font-family: inherit; font-weight: bold; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; z-index: 20;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}
.panel-toggle:hover { background: var(--bg-lighter); color: var(--text); }

aside.collapsed .panel-toggle {
    /* Flip arrow when collapsed? Or just leave as opener */
}

.header { padding: 20px; border-bottom: 1px solid var(--bg-lighter); }
h1 { margin: 0; font-size: 1.2rem; color: var(--primary); letter-spacing: -1px; }
.stats { font-size: 0.8rem; color: var(--secondary); margin-top: 5px; }

.controls { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 20px; }

.group { display: flex; flex-direction: column; gap: 10px; }
.label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-dim); font-weight: bold; }

.row { display: flex; gap: 10px; }

button, select, input[type="text"] {
    background: var(--bg-lighter); border: 1px solid transparent; color: var(--text);
    padding: 8px 12px; font-family: inherit; cursor: pointer; border-radius: 4px;
    transition: all 0.2s; flex: 1;
}
button:hover { border-color: var(--secondary); background: var(--bg); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { border-color: transparent; background: var(--bg-lighter); }
button.active { background: var(--warning); color: var(--bg); font-weight: bold; }
#btn-play { background: var(--primary); color: var(--bg); font-weight: bold; }
#btn-play:hover { opacity: 0.9; }
#btn-play.active { background: var(--warning); }

input[type="range"] { width: 100%; accent-color: var(--primary); cursor: ew-resize; }
input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
input[type="number"] { background: var(--bg-lighter); border: 1px solid transparent; color: var(--text); padding: 4px; font-family: inherit; border-radius: 4px; }
input[type="number"]:disabled { opacity: 0.4; }

/* Canvas Area */
main { flex: 1; position: relative; cursor: crosshair; overflow: hidden; order: -1; } /* Order -1 to be left of aside */
canvas { display: block; image-rendering: pixelated; }

.overlay-msg {
    position: absolute; bottom: 20px; right: 20px; 
    background: var(--bg-light); padding: 10px; border: 1px solid var(--primary);
    opacity: 0; transition: opacity 0.5s; pointer-events: none;
    z-index: 20;
}

.fps-overlay {
    position: absolute; bottom: 10px; left: 10px;
    background: rgba(46, 52, 64, 0.8); padding: 4px 8px;
    font-size: 0.7rem; color: var(--success); border-radius: 3px;
    font-family: 'Fira Code', monospace; pointer-events: none;
    z-index: 20;
}

/* Help Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(46, 52, 64, 0.9);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--bg-light); border: 1px solid var(--primary);
    padding: 30px; border-radius: 4px; max-width: 400px; width: 90%;
    box-shadow: var(--shadow-default);
}
.modal h2 { margin-top: 0; color: var(--primary); font-size: 1.4rem; }
.key-list { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.key-item { display: flex; justify-content: space-between; border-bottom: 1px solid var(--bg-lighter); padding-bottom: 5px; }
.key-bg { 
    background: var(--bg-lighter); padding: 2px 6px; border-radius: 3px; 
    font-size: 0.85rem; font-weight: bold; color: var(--success); border: 1px solid var(--text-dim);
}
.close-hint { text-align: center; font-size: 0.8rem; color: var(--text-dim); margin-top: 20px; }

/* Color Picker */
.color-picker {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.color-swatch {
    width: 28px; height: 28px; border-radius: 4px;
    border: 2px solid transparent; cursor: pointer;
    flex: 0 0 auto; padding: 0;
    transition: transform 0.1s, border-color 0.2s;
}
.color-swatch:hover { transform: scale(1.1); border-color: var(--text); }
.color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }

/* Footer Graph */
.footer-graph {
    padding: 10px 20px;
    border-top: 1px solid var(--bg-lighter);
    flex-shrink: 0;
}
.footer-graph canvas {
    width: 100%;
    height: 50px;
    border-radius: 4px;
    background: var(--bg);
}

/* Branding Footer */
.branding {
    padding: 10px 20px;
    border-top: 1px solid var(--bg-lighter);
    text-align: center;
    flex-shrink: 0;
}
.brand-title {
    font-size: 0.9rem; font-weight: bold;
    color: var(--primary); margin-bottom: 5px;
}
.brand-links {
    font-size: 0.7rem; margin-bottom: 5px;
}
.brand-links a {
    color: var(--secondary); text-decoration: none;
}
.brand-links a:hover { text-decoration: underline; }
.brand-links span { color: var(--text-dim); margin: 0 5px; }
.brand-copy {
    font-size: 0.6rem; color: var(--text-dim);
}
