:root {
    --megaparsec-design-width: 1920px;
    --megaparsec-design-height: 1080px;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

body {
    position: relative;
}

#app {
    position: absolute;
    width: var(--megaparsec-design-width);
    height: var(--megaparsec-design-height);
    min-height: var(--megaparsec-design-height);
    overflow: hidden;
}

/* Freeze the approved 1920 x 1080 composition before the outer transform. */
#app header {
    min-height: 76px;
    padding: 12px 20px;
    gap: 16px;
    flex-wrap: nowrap;
}

#app h1 {
    font-size: 1.55rem;
    letter-spacing: 3px;
}

#app h1 .version {
    font-size: 0.95rem;
}

#app header .transport {
    gap: 18px;
}

#app header .transport-btn {
    width: 46px;
    height: 46px;
    font-size: 1.05rem;
}

#app header .tempo-control input[type="number"] {
    width: 72px;
    min-height: 36px;
    font-size: 1rem;
}

#app header .swing-control input[type="range"] {
    width: 82px;
    height: 7px;
}

#app header .midi-section {
    gap: 8px;
}

#app header .midi-io,
#app header .midi-sync {
    gap: 4px;
}

#app main#parts-container {
    grid-template-columns: repeat(2, 1fr);
}

#app .part {
    padding: 12px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

/* Controls are the primary surface; the waveform is a compact monitor. */
#app .part-header {
    min-height: 46px;
    padding-bottom: 10px;
}

#app .part-label {
    font-size: 1.28rem;
}

#app .preset-select,
#app .preset-save-btn,
#app .midi-ch select,
#app .midi-bus-out select,
#app .mute-btn,
#app .solo-btn {
    font-size: 1rem;
}

#app .preset-select {
    min-width: 140px;
    max-width: 160px;
    height: 34px;
    padding: 5px 9px;
}

#app .preset-save-btn,
#app .mute-btn,
#app .solo-btn {
    min-height: 34px;
}

#app .preset-save-btn {
    padding: 5px 11px;
}

#app .part-controls label {
    font-size: 0.82rem;
}

#app .part-controls select {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 0.94rem;
}

#app .mute-btn,
#app .solo-btn {
    width: 34px;
    height: 34px;
}

#app .osc-waveform-row {
    flex: 0 0 162px;
    min-height: 162px;
    gap: 14px;
}

#app .osc-section {
    flex: 0 1 42%;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    column-gap: 18px;
    row-gap: 14px;
    align-content: center;
}

#app .waveform-display {
    flex: 1 1 56%;
    min-width: 280px;
    min-height: 0;
}

#app .osc,
#app .part-pitch-control {
    gap: 8px;
}

#app .osc label,
#app .part-pitch-control label {
    flex-basis: 52px;
    font-size: 0.96rem;
}

#app .osc select,
#app .part-pitch-control input {
    height: 36px;
    min-width: 92px;
    padding: 6px 9px;
    font-size: 1rem;
}

#app .filter-section,
#app .env-section {
    min-height: 50px;
    gap: 14px;
    flex-wrap: nowrap;
}

#app .knob-group {
    min-width: 0;
    gap: 8px;
}

#app .knob-group label {
    min-width: 58px;
    font-size: 1rem;
}

#app .knob-group input[type="range"] {
    max-width: none;
    height: 7px;
}

#app .gate-section {
    width: 100%;
    padding: 10px 12px;
}

#app .gate-header {
    min-height: 28px;
    margin-bottom: 7px;
}

#app .gate-header span,
#app .gate-toggle-btn,
#app .gate-rand-btn,
#app .gate-reset-btn,
#app .part-steps,
#app .part-rate {
    font-size: 0.9rem;
}

#app .gate-toggle-btn,
#app .gate-rand-btn,
#app .gate-reset-btn,
#app .part-steps,
#app .part-rate {
    min-height: 26px;
    padding: 4px 8px;
}

#app .gate-sequencer {
    gap: 2px;
}

#app .gate-step {
    height: 24px;
}

#app .output-section {
    grid-column: 1 / -1;
    min-height: 36px;
    padding: 4px 0 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    background: transparent;
    border: 0;
    box-shadow: none;
}

#app .output-section .knob-group {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 8px;
}

#app .output-section .knob-group label {
    min-width: 0;
    font-size: 0.96rem;
}

#app .output-section .knob-group input[type="range"] {
    width: 100%;
}

#app header .tempo-control label,
#app header .swing-control label,
#app header .midi-io label,
#app header .midi-sync label,
#app header .midi-ch label,
#app header .midi-bus-out label {
    font-size: 0.76rem;
}

#app header .midi-section select,
#app header .midi-ch select,
#app header .midi-bus-out select {
    min-height: 32px;
    padding: 4px 7px;
    font-size: 0.82rem;
    max-width: 92px;
}

#app header .midi-sync select {
    max-width: 64px;
}

#app header .midi-learn-btn {
    min-width: 96px;
    height: 38px;
    padding: 0 12px;
    font-size: 0.82rem;
}

#app header .fullscreen-btn {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
}

#app footer {
    padding: 10px 20px;
}
