/* ══════════════════════════════════════════════════════════════
   Synth Creator — Melodic Step Sequencer Styles
   ══════════════════════════════════════════════════════════════ */

.synth-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Controls Bar ── */
.synth-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.synth-controls .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.synth-bpm {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.synth-bpm input[type="number"] {
    width: 4rem;
    padding: 0.3rem 0.4rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
    font-family: var(--font-mono);
}

.synth-octave,
.synth-scale {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.synth-octave select {
    padding: 0.3rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
}

.synth-controls-spacer {
    flex: 1;
}

/* ── Progress Bar ── */
.synth-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: -0.5rem;
}

.synth-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.05s linear;
    width: 0%;
}

/* ── Two-Column Layout: Grid + Synth Panel ── */
.synth-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1rem;
}

/* Minimap injected by JS must span the full row above the grid */
.synth-body > .grid-minimap {
    grid-column: 1 / -1;
}

/* Flex row: vminimap + grid-wrapper */
.synth-body > .grid-area-row {
    grid-column: 1;
    display: flex;
    min-width: 0;
}
.synth-body > .grid-area-row > .synth-grid-wrapper {
    flex: 1;
    min-width: 0;
}

/* Fallback if no wrapper yet */
.synth-body > .synth-grid-wrapper {
    grid-column: 1;
}

.synth-body > .synth-panel {
    grid-column: 2;
}

@media (max-width: 900px) {
    .synth-body {
        grid-template-columns: 1fr;
    }
    .synth-body > .synth-panel {
        grid-column: 1;
    }
}

/* ── Grid ── */
.synth-grid-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.synth-grid {
    display: grid;
    min-width: 600px;
    padding: 0.25rem;
}

/* Step numbers */
.synth-step-num {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    text-align: center;
    padding: 0.2rem 0;
    user-select: none;
}

.synth-step-num.synth-marker {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Note label */
.synth-note-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.1s;
    white-space: nowrap;
    min-height: 20px;
}

.synth-note-label:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.synth-note-label.sharp-note {
    color: var(--text-dim);
    font-size: 0.6rem;
}

.synth-note-label.root-note {
    color: var(--accent);
    font-weight: 700;
}

.synth-note-label.in-scale-note {
    color: #a5b4fc;
    font-weight: 600;
}

/* Grid cells */
.synth-cell {
    width: 100%;
    min-height: 20px;
    max-height: 28px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.08s;
    background: var(--bg);
}

.synth-cell:hover {
    border-color: var(--border-hover);
    background: rgba(99, 102, 241, 0.08);
}

.synth-cell.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 4px rgba(99, 102, 241, 0.4);
}

.synth-cell.sharp-row {
    background: rgba(0, 0, 0, 0.15);
}

.synth-cell.sharp-row:hover {
    background: rgba(99, 102, 241, 0.12);
}

.synth-cell.sharp-row.active {
    background: var(--accent);
}

/* ── In-scale & Root row highlighting (after base+sharp so these win) ── */
.synth-cell.in-scale-row,
.synth-cell.sharp-row.in-scale-row {
    background: rgba(99, 102, 241, 0.13);
    border-color: rgba(99, 102, 241, 0.28);
}

.synth-cell.in-scale-row:hover,
.synth-cell.sharp-row.in-scale-row:hover {
    background: rgba(99, 102, 241, 0.22);
}

.synth-cell.root-row,
.synth-cell.sharp-row.root-row {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(99, 102, 241, 0.4);
}

.synth-cell.root-row:hover,
.synth-cell.sharp-row.root-row:hover {
    background: rgba(99, 102, 241, 0.32);
}

.synth-cell.in-scale-row.active,
.synth-cell.root-row.active {
    background: var(--accent);
    border-color: var(--accent);
}

.synth-cell.beat-group-start {
    margin-left: 2px;
}

.synth-cell.step-playing {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.synth-cell.active.step-playing {
    filter: brightness(1.3);
    transform: scale(1.08);
}

/* C note row separator */
.synth-note-label.c-note {
    border-top: 1px solid var(--border-hover);
}

/* ── Synth Panel ── */
.synth-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.synth-panel h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text);
}

.synth-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.synth-panel-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin: 0;
}

/* Waveform selector */
.synth-waveform-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.synth-wave-btn {
    padding: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.synth-wave-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.synth-wave-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Knob/Slider rows */
.synth-param-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.synth-param-row label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 55px;
    flex-shrink: 0;
}

.synth-param-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    min-width: 0;
}

.synth-param-row .param-value {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    min-width: 32px;
    text-align: right;
}

/* Sound presets */
.synth-preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
}

.synth-preset-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.synth-preset-btn:hover {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
}

.synth-preset-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Pattern Presets ── */
.synth-patterns {
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.synth-patterns h3 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.synth-patterns h3 .hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.synth-genre-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.synth-genre-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.synth-genre-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.synth-genre-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.synth-pattern-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.synth-pattern-btn {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.synth-pattern-btn:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.synth-pattern-btn .sp-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.synth-pattern-btn .sp-genre {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .synth-controls {
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .synth-grid-wrapper {
        max-height: 400px;
    }
    .synth-cell {
        min-height: 16px;
    }
}
