:root {
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-input: #334155;
    --border-subtle: #475569;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #06b6d4;
    --piano: #c084fc;
    --piano-hover: #a855f7;
    --guitar: #f59e0b;
    --guitar-hover: #d97706;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius-lg: 12px;
    --radius-sm: 6px;
    --header-height: 60px;
    --transport-height: 80px;
    --grid-col-def: 80px repeat(16, 1fr);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    padding-bottom: 120px;
    min-height: 100vh;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-std {
    height: 38px;
    padding: 0 16px;
    min-width: 80px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--border-subtle);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

.btn-accent {
    background: var(--accent);
    color: #000;
}

.btn-piano {
    background: var(--piano);
    color: #000;
}

.btn-piano:hover {
    background: var(--piano-hover);
}

.btn-guitar {
    background: var(--guitar);
    color: #000;
}

.btn-guitar:hover {
    background: var(--guitar-hover);
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.8rem;
    height: 24px;
}

/* Workspace */
.workspace {
    max-width: 1000px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 1.5rem;
}

.panel-header {
    margin-bottom: 1rem;
}

.flex-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.grow {
    flex: 1;
    min-width: 200px;
}

/* Piano panel styling */
.piano-panel {
    border-color: rgba(192, 132, 252, 0.3);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(88, 28, 135, 0.15) 100%);
}

.guitar-panel {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(180, 83, 9, 0.15) 100%);
}



/* Inputs */
.input-group,
.knob-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

input[type="text"],
input[type="number"],
.select-input {
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 0 10px;
    height: 38px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
}

input:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

input[type="range"] {
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}

.piano-panel input[type="range"] {
    accent-color: var(--piano);
}

.guitar-panel input[type="range"] {
    accent-color: var(--guitar);
}

/* Tabs */
.segmented-control {
    display: flex;
    background: var(--bg-panel);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    max-width: 450px;
    margin: 0 auto;
}

.segment-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    white-space: nowrap;
}

.segment-btn.active {
    background: var(--bg-input);
    color: var(--text-main);
}

.segment-btn:hover:not(.active) {
    color: var(--text-main);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Control row */
.control-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.action-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* Grid scroll area */
.grid-scroll-area {
    overflow-x: auto;
    padding-bottom: 10px;
}

/* Measures container */
.measures {
    display: flex;
    gap: 15px;
    min-height: 70px;
}

.measure {
    background: var(--bg-input);
    padding: 10px;
    border-radius: var(--radius-sm);
    display: flex;
    gap: 5px;
    border: 1px solid var(--border-subtle);
}

/* Note inputs - BASS */
.note {
    display: flex;
}

.note input {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    color: var(--accent);
    border-radius: var(--radius-sm);
    padding: 0;
}

.note input:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

.note input.highlight {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

/* Chord note inputs - PIANO */
.note.chord-note input {
    width: 4.5rem;
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--piano);
    border-color: rgba(192, 132, 252, 0.4);
}

.note.chord-note input:focus {
    outline: 2px solid var(--piano);
}

.note.chord-note input.highlight {
    background: var(--piano);
    color: #000;
    box-shadow: 0 0 15px rgba(192, 132, 252, 0.5);
}

.note.chord-note input::placeholder {
    color: rgba(192, 132, 252, 0.3);
}

/* Guitar note inputs */
.note.guitar-note input {
    width: 4.5rem;
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--guitar);
    border-color: rgba(245, 158, 11, 0.4);
}

.note.guitar-note input:focus {
    outline: 2px solid var(--guitar);
}

.note.guitar-note input.highlight {
    background: var(--guitar);
    color: #000;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.note.guitar-note input::placeholder {
    color: rgba(245, 158, 11, 0.3);
}

/* Helper text */
.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 10px;
}

/* Drum Sequencer */
.sequencer-container {
    background: #0b0f19;
    border-radius: var(--radius-sm);
    padding: 15px;
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
}

.sequencer-grid-header,
.drum-row {
    display: grid;
    grid-template-columns: var(--grid-col-def);
    column-gap: 4px;
    align-items: center;
    min-width: 700px;
}

.sequencer-grid-header {
    margin-bottom: 8px;
}

.sequencer-grid-header span {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.drum-row {
    margin-bottom: 6px;
}

.row-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    padding-right: 10px;
    text-align: right;
}

.step {
    aspect-ratio: 1;
    background: #262626;
    border-radius: 2px;
}

.step input {
    appearance: none;
    width: 100%;
    height: 100%;
    cursor: pointer;
    background: transparent;
    display: block;
    border: none;
    border-radius: 2px;
}

.step input:checked {
    background: var(--primary);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.step.playing-step {
    outline: 2px solid white;
}

/* Pattern manager */
.pattern-manager {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pattern-chips {
    display: flex;
    gap: 5px;
}

.p-chip {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
}

.p-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Presets */
.presets-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
}

.chip:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

/* Transport */
.transport-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: var(--transport-height);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 1.5rem;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 15px;
}

.transport-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    flex: 1;
}

.controls-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.play-main-btn {
    background: var(--primary);
    color: white;
    border: none;
    height: 48px;
    padding: 0 2rem;
    border-radius: 24px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease;
}

.play-main-btn:hover {
    background: var(--primary-hover);
}

.play-main-btn:active {
    transform: scale(0.96);
}

.play-main-btn.playing {
    background: var(--danger);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.app-version {
    font-size: 0.75rem;
    color: var(--border-subtle);
    font-family: 'JetBrains Mono';
    margin-left: auto;
}

/* Tempo */
.tempo-control {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tempo-control input {
    width: 70px;
}

.tap-btn {
    background: var(--accent);
    color: #000;
    border: none;
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.toggle-btn {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 50px;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Count-in */
.count-in-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 40px rgba(6, 182, 212, 0.5);
    z-index: 500;
    pointer-events: none;
    font-family: 'JetBrains Mono', monospace;
}

.count-in-display.hidden {
    display: none;
}

.count-in-display.pulse {
    animation: countPulse 0.2s ease-out;
}

@keyframes countPulse {
    0% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-panel);
    width: 95%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.track-list-container {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.track-link {
    display: block;
    padding: 15px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    text-decoration: none;
    text-align: center;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Mobile */
@media (max-width: 600px) {
    body {
        padding-bottom: 200px;
    }

    .transport-dock {
        padding: 10px 1rem;
        justify-content: center;
    }

    .transport-inner {
        justify-content: center;
        width: 100%;
    }

    .play-main-btn {
        width: 100%;
        justify-content: center;
    }

    .app-version {
        display: none;
    }

    .action-group {
        width: 100%;
        margin-top: 10px;
    }

    .action-group .btn {
        flex: 1;
    }
}