:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-border: #e6eaf1;
    --text: #172033;
    --muted: #78839a;
    --sidebar: #151d2b;
    --sidebar-soft: #202b3e;
    --accent: #4068f2;
    --accent-soft: #e9eeff;
    --success: #18a66a;
    --danger: #dc4f63;
    --shadow: 0 10px 26px rgba(33, 48, 83, .07);
    --radius: 15px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
    width: 238px;
    position: fixed;
    inset: 0 auto 0 0;
    padding: 22px 16px;
    background: var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
    background: var(--accent); font-weight: 800; font-size: 22px;
}
.brand strong { display: block; font-size: 13px; letter-spacing: .08em; }
.brand span { display: block; margin-top: 2px; font-size: 10px; color: #8fa0bd; letter-spacing: .12em; }

nav { display: grid; gap: 6px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px;
    border-radius: 10px; color: #aebbd0; text-decoration: none; font-size: 14px;
}
.nav-item:hover, .nav-item.active { color: #fff; background: var(--sidebar-soft); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-card {
    margin-top: auto; padding: 15px; border-radius: 12px; background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.07);
}
.sidebar-card small { display: block; color: #8090ab; font-size: 10px; letter-spacing: .12em; }
.sidebar-card strong { display: block; margin: 8px 0 4px; font-size: 13px; }
.sidebar-card span { font-size: 11px; color: #8fa0bd; }

.main-content { margin-left: 238px; width: calc(100% - 238px); padding: 24px 28px 40px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { margin: 3px 0 0; font-size: 25px; }
.eyebrow { font-size: 10px; letter-spacing: .13em; font-weight: 800; color: var(--accent); }
.top-actions, .button-row { display: flex; gap: 9px; flex-wrap: wrap; }

.button {
    border: 0; border-radius: 9px; min-height: 38px; padding: 0 15px; font-weight: 700; font-size: 13px;
}
.button.primary { background: var(--accent); color: #fff; }
.button.secondary { background: #eef2f8; color: #38445b; }
.button:hover { filter: brightness(.98); transform: translateY(-1px); }
.button.full { width: 100%; margin-top: 10px; }

.panel {
    background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px;
}

.transport {
    display: grid; grid-template-columns: auto 110px 240px minmax(200px, 1fr) auto; align-items: end;
    gap: 18px; margin-bottom: 18px;
}
.transport-buttons { display: flex; gap: 7px; }
.transport-button {
    width: 42px; height: 42px; border: 0; border-radius: 10px; background: #edf1f8; color: #26324a; font-weight: 800;
}
.transport-button.play { background: var(--accent); color: #fff; }
.transport label, .sound-panel label { display: grid; gap: 7px; }
.transport label > span, .sound-panel label > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.transport input[type="number"], .transport input[type="text"] {
    height: 42px; border: 1px solid var(--panel-border); border-radius: 9px; padding: 0 11px; color: var(--text); background: #fbfcfe;
}
.transport-status { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; color: var(--muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 99px; background: #aab4c6; }
.status-dot.active { background: var(--success); box-shadow: 0 0 0 5px rgba(24,166,106,.12); }

.range-with-value { display: grid; grid-template-columns: 1fr 48px; gap: 10px; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
output { color: var(--text); font-size: 12px; font-weight: 700; text-align: right; }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-heading h2 { margin: 3px 0 0; font-size: 18px; }
.section-heading.compact { margin-bottom: 16px; }

.quick-actions { margin-bottom: 18px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.quick-card {
    text-align: left; border: 1px solid var(--panel-border); border-radius: 12px; background: #fbfcff; padding: 14px;
    min-height: 78px;
}
.quick-card:hover { border-color: #b8c6ff; background: var(--accent-soft); }
.quick-card strong, .quick-card span { display: block; }
.quick-card strong { font-size: 13px; color: var(--text); }
.quick-card span { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.sequencer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 18px; margin-bottom: 18px; }
.sequencer-panel { min-width: 0; overflow-x: auto; }
.legend { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 7px; }
.legend span { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.sequencer { min-width: 940px; }
.seq-row {
    display: grid; grid-template-columns: 118px repeat(32, minmax(20px, 1fr)); gap: 4px; align-items: center; margin-bottom: 7px;
}
.track-label {
    height: 30px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between;
    border-radius: 8px; background: #f0f3f8; color: #34405a; font-size: 12px; font-weight: 800; border: 1px solid transparent;
}
.track-label.selected { background: var(--accent-soft); color: var(--accent); border-color: #c6d1ff; }
.track-label small { color: #98a3b5; font-size: 9px; font-weight: 700; }
.step {
    min-width: 20px; height: 30px; border: 0; border-radius: 6px; background: #edf1f6; color: transparent;
    position: relative;
}
.step.bar-start { box-shadow: inset 2px 0 0 #d1d8e3; }
.step.active { background: var(--accent); box-shadow: inset 0 -4px 0 rgba(0,0,0,.14); }
.step.playhead::after {
    content: ""; position: absolute; inset: -3px; border: 2px solid #1b2538; border-radius: 8px; pointer-events: none;
}
.step.active.playhead::after { border-color: #91a6ff; }

.sound-panel { align-self: start; }
.control-stack { display: grid; gap: 16px; }
.upload-box { margin-top: 20px; padding: 14px; border-radius: 11px; background: #f7f9fc; border: 1px dashed #cfd7e4; }
.upload-box strong { display: block; font-size: 13px; }
.upload-box p { margin: 6px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.upload-box input { width: 100%; font-size: 11px; }
.sample-meta { margin-top: 12px; color: var(--muted); font-size: 11px; }

.bottom-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.muted { color: var(--muted); line-height: 1.55; font-size: 12px; }
textarea {
    width: 100%; min-height: 175px; resize: vertical; border: 1px solid var(--panel-border); border-radius: 10px;
    padding: 13px; background: #0f1724; color: #cfe0ff; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.button-row { margin-top: 12px; }
.message { min-height: 18px; margin-top: 11px; font-size: 12px; color: var(--muted); }
.message.success { color: var(--success); }
.message.error { color: var(--danger); }
.save-options { display: grid; gap: 9px; }
.save-option {
    display: block; width: 100%; text-align: left; border: 1px solid var(--panel-border); border-radius: 10px; background: #fbfcff; padding: 13px;
    position: relative;
}
.save-option strong, .save-option span { display: block; }
.save-option strong { color: var(--text); font-size: 12px; }
.save-option span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.save-option:hover { border-color: #bdc9fb; }
.file-option input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

@media (max-width: 1180px) {
    .transport { grid-template-columns: auto 100px 200px 1fr; }
    .transport-status { display: none; }
    .quick-grid { grid-template-columns: repeat(2, 1fr); }
    .sequencer-layout { grid-template-columns: 1fr; }
    .sound-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
    .sound-panel .section-heading { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: 100%; min-height: auto; }
    .app-shell { display: block; }
    .sidebar nav, .sidebar-card { display: none; }
    .brand { padding-bottom: 0; }
    .main-content { margin-left: 0; width: 100%; padding: 18px 12px 32px; }
    .topbar { align-items: flex-start; gap: 10px; }
    .top-actions { justify-content: flex-end; }
    .transport { grid-template-columns: 1fr 1fr; }
    .transport-buttons, .project-name-field { grid-column: 1 / -1; }
    .quick-grid, .bottom-grid { grid-template-columns: 1fr; }
    .sound-panel { display: block; }
}
