:root {
    /* Modula Color Palette */
    --bg-color: #101010;
    --ui-color: #181818;
    --panel-color: #202020;
    --surface-color: #282828;
    --text-color: #E0E0E0;
    --text-color-muted: #888888;

    /* Accent: Lime Green (Subtractive/Classic) */
    --accent-color: #39FF14;
    --accent-color-glow: rgba(57, 255, 20, 0.4);

    --display-bg: #050805;

    --shadow-dark: rgba(0, 0, 0, 0.6);
    --shadow-light: rgba(255, 255, 255, 0.06);

    /* Fonts */
    --font-ui: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-color: var(--bg-color);
    font-family: var(--font-ui);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

/* Main Container */
.synth-container {
    width: 800px;
    padding: 24px;
    background-color: var(--ui-color);
    border-radius: 20px;
    border: 1px solid var(--shadow-light);
    box-shadow: 0 10px 30px var(--shadow-dark);
    transition: box-shadow 0.3s ease;
}

.main-controls-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    /* height: 100%; Removed to prevent stretching */
}

/* Brand Link */
.brand-link {
    text-decoration: none;
    color: inherit;
}

.brand {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--text-color-muted);
    background-color: var(--panel-color);
    padding: 0.8rem 0.6rem;
    border-radius: 12px;
    text-align: center;
    font-family: var(--font-code);
    font-weight: 500;
    letter-spacing: 4px;
    font-size: 14px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--shadow-light);
    transition: color 0.2s ease;
}

.brand-subtitle {
    font-weight: 400;
    opacity: 0.5;
    font-size: 0.8em;
    margin-top: 8px;
    display: inline-block;
}

.brand-link:hover .brand {
    color: var(--accent-color);
}

/* Fader */
.fader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.fader-container {
    position: relative;
    width: 24px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fader-track {
    width: 6px;
    height: 100%;
    background-color: var(--bg-color);
    border-radius: 3px;
    box-shadow: inset 0 0 5px var(--shadow-dark);
}

.fader-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 24px;
    background: transparent;
    cursor: pointer;
    position: absolute;
    transform: rotate(-90deg);
}

.fader-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 16px;
    background: var(--surface-color);
    border-radius: 4px;
    border: 1px solid var(--shadow-light);
    box-shadow: 0 2px 5px var(--shadow-dark);
    transition: background-color 0.2s;
}

.fader-slider:hover::-webkit-slider-thumb {
    background-color: var(--accent-color);
}

.fader-label {
    font-family: var(--font-code);
    font-size: 10px;
    color: var(--text-color-muted);
}

/* Control Panel */
.right-column .control-panel {
    background-color: var(--panel-color);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    box-sizing: border-box;
}

/* Display */
.display {
    background-color: var(--display-bg);
    border-radius: 12px;
    height: 72px;
    padding: 0;
    box-shadow: inset 0 0 8px var(--shadow-dark);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--shadow-light);
    display: flex;
    flex-direction: column;
}

.display-top-line,
.display-bottom-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
    font-family: var(--font-code);
    font-size: 10px;
    font-weight: 500;
    color: var(--accent-color);
    z-index: 2;
    position: relative;
}

.display-top-line {
    border-bottom: 1px solid rgba(57, 255, 20, 0.1);
}

.display-bottom-line {
    border-top: 1px solid rgba(57, 255, 20, 0.1);
}

.display-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#display-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Knobs */
.knobs-container {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    justify-content: space-between;
    /* Better spread */
}

.knob-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* More space between knob and label */
    flex: 1;
    /* Distribute evenly */
}

.knob-label {
    font-family: var(--font-code);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-color-muted);
    transition: color 0.3s ease;
}

.knob {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(145deg, #303030, #222222);
    position: relative;
    cursor: ns-resize;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.4), inset 0 2px 2px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.knob::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border-radius: 50%;
    background: var(--surface-color);
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3);
}

.knob::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 12px;
    border-radius: 2px;
    background-color: var(--accent-color);
    box-shadow: 0 0 5px var(--accent-color-glow);
    top: 8px;
    left: calc(50% - 2px);
    transform-origin: 50% 24px;
    transform: rotate(calc(var(--value, 0) * 270deg - 135deg));
    transition: transform 0.1s linear, background-color 0.3s ease, box-shadow 0.3s ease;
}

.knob:active::after {
    background-color: #fff;
}

/* Button Grid */
.unified-button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.control-btn {
    height: 48px;
    border: 1px solid var(--shadow-light);
    border-radius: 8px;
    background-color: var(--surface-color);
    box-shadow: 0 3px 6px var(--shadow-dark);
    cursor: pointer;
    transition: all 0.1s ease-in-out;
    color: var(--text-color-muted);
    font-weight: 700;
    font-family: var(--font-code);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px var(--shadow-dark);
}

.control-btn.active {
    background-color: var(--accent-color);
    color: var(--display-bg);
    box-shadow: 0 0 12px var(--accent-color-glow);
    border-color: var(--accent-color);
}

.control-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.control-btn i {
    font-size: 20px;
}

/* Keyboard */
.keyboard-container {
    display: flex;
    position: relative;
    height: 160px;
    margin-top: 16px;
    padding: 12px;
    background-color: var(--panel-color);
    border-radius: 16px;
    border: 1px solid var(--shadow-light);
}

.key {
    cursor: pointer;
    transition: all 0.05s ease-in-out;
}

/* Naturals (Inverted: Black/Dark Wood) */
.key.natural {
    background: linear-gradient(180deg, #3a3d44, #2a2d34);
    border-bottom: 4px solid #101010;
    box-shadow: 0 2px 5px var(--shadow-dark);
    height: 100%;
    z-index: 1;
    border-radius: 0 0 4px 4px;
    box-sizing: border-box;
    flex: 1;
}

.key.natural:active,
.key.natural.active {
    background: #1a1a1a;
    border-bottom-width: 2px;
    transform: translateY(2px);
    box-shadow: 0 0 15px var(--accent-color-glow);
    border-color: var(--accent-color);
}

/* Sharps (Inverted: White/Bone) */
.key.sharp {
    background: linear-gradient(180deg, #e0e0e0, #c0c0c0);
    height: 60%;
    border-bottom: 4px solid #888;
    z-index: 2;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    border-radius: 0 0 4px 4px;
    position: absolute;
    width: 24px;
}

.key.sharp:active,
.key.sharp.active {
    background: #fff;
    border-bottom-width: 2px;
    transform: translateY(2px);
    box-shadow: 0 0 15px var(--accent-color-glow);
    border-color: var(--accent-color);
}