:root {
  color-scheme: dark;
  --bg: #0d0d0b;
  --panel: #171713;
  --panel-2: #202018;
  --panel-3: #10100d;
  --line: #3b3a31;
  --line-soft: #292820;
  --text: #f3f0e4;
  --muted: #aaa694;
  --accent: #ffe14a;
  --accent-2: #ff6b2c;
  --ok: #72d36f;
  --warn: #ffe14a;
  --bad: #ff5d5d;
  --cyan: #81d8d0;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

button, input, select { font: inherit; }

button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 9px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

input, select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #090908;
  color: var(--text);
  padding: 6px 8px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
}

summary {
  cursor: pointer;
  color: var(--text);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .02em;
  list-style: none;
  text-transform: uppercase;
}

summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; float: right; color: var(--accent); }
details[open] > summary::after { content: "-"; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 1.45rem; line-height: 1; text-transform: lowercase; }
h2 { margin: 0; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
h3 { margin: 0 0 7px; font-size: .72rem; color: var(--muted); text-transform: uppercase; }

.app {
  width: min(1780px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #11110e;
  padding: 8px 10px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font: .66rem var(--mono);
  text-transform: uppercase;
}

.lede,
.notice,
.hint { display: none; }

.status-stack {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  max-width: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-3);
  color: var(--muted);
  padding: 5px 8px;
  font: .76rem var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.dot.ok { background: var(--ok); }
.dot.err { background: var(--bad); }

.layout {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.section { padding: 9px; }
.stack { display: grid; gap: 8px; }
.fold > :not(summary) { margin-top: 8px; }

.inspector {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 76px);
  overflow: auto;
}

.inspector .section {
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
}

.inspector .section:last-child { border-bottom: 0; }

.check-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  min-height: 24px;
  text-transform: none;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

.check-row span {
  color: var(--text);
  overflow-wrap: anywhere;
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.row > input { width: min(240px, 100%); }

.inline-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.inline-label select { width: 68px; }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #11110e;
  font-weight: 900;
}

.primary:hover:not(:disabled) {
  border-color: var(--text);
  color: #11110e;
}

.drop {
  min-height: 64px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 3px;
  background: #0a0a08;
  color: var(--text);
  text-align: center;
}

.drop.drag {
  border-color: var(--accent);
  color: var(--accent);
}

.drop input { display: none; }

.daw-workspace {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) minmax(330px, .42fr);
  grid-auto-rows: min-content;
  gap: 8px;
  min-width: 0;
}

.transport-panel { grid-column: 1 / -1; }
.sample-panel { grid-column: 1; grid-row: 2; }
.arrangement-panel { grid-column: 1; grid-row: 3; }
.timeline-panel { grid-column: 1; grid-row: 4; }
.tree-panel { grid-column: 1; grid-row: 5; }
.log-panel { grid-column: 2; grid-row: 2 / span 4; align-self: stretch; }
.proposals-panel { display: none; }

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.transport-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(90px, 1fr));
  gap: 6px;
}

.meta-grid > div,
.activity-card,
.item {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--panel-3);
  padding: 7px;
}

.meta-grid span,
.activity-card span {
  display: block;
  color: var(--muted);
  font: .62rem var(--mono);
  text-transform: uppercase;
}

.meta-grid strong,
.activity-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font: .78rem var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.activity-card.live {
  border-color: var(--accent);
}

.activity-card.live strong,
.activity-card strong {
  color: var(--accent);
}

.mini-stat {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-3);
  color: var(--muted);
  padding: 5px 8px;
  font: .72rem var(--mono);
}

.bank-tabs {
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 4px;
  margin-bottom: 8px;
}

.bank-tab {
  display: inline-flex;
  justify-content: space-between;
  gap: 5px;
  min-height: 31px;
  padding-inline: 7px;
  font: .72rem var(--mono);
}

.bank-tab.active {
  border-color: var(--accent);
  background: #2a2713;
  color: var(--accent);
}

.bank-tab span { color: var(--muted); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  max-height: min(44vh, 520px);
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: #0f0f0c;
}

th, td {
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 7px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1d1d17;
  color: var(--muted);
  font: .64rem var(--mono);
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #242113;
}

.slot-pill {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #090908;
  color: var(--accent);
  padding: 3px 6px;
  font: .72rem var(--mono);
}

.assign-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  vertical-align: middle;
}

.assign-dot.active {
  border-color: var(--accent);
  background: var(--accent);
}

.action-row {
  display: inline-flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.action-row button {
  min-height: 26px;
  padding: 3px 7px;
  font-size: .7rem;
}

.wave {
  display: grid;
  grid-template-columns: repeat(32, 3px);
  gap: 2px;
  align-items: center;
  height: 30px;
}

.wave span {
  display: block;
  width: 3px;
  min-height: 2px;
  background: var(--accent);
}

audio {
  width: 172px;
  height: 28px;
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(58px, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.pad-cell {
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 64px;
  border-radius: 3px;
  text-align: left;
}

.pad-cell span {
  color: var(--accent);
  font: .68rem var(--mono);
}

.pad-cell strong {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pad-cell.assigned {
  border-color: var(--accent);
  background: #2a2713;
}

.pad-cell.assigned strong { color: var(--text); }

.context-menu {
  position: fixed;
  z-index: 10;
  display: grid;
  min-width: 174px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #10100d;
  box-shadow: 0 18px 36px rgba(0,0,0,.42);
  padding: 4px;
}

.context-menu[hidden] { display: none; }

.context-menu button {
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.context-menu button:hover {
  border-color: var(--line);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.item-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.item .sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.32;
}

.timeline-viewport {
  position: relative;
  min-height: 168px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.045) 0, rgba(255,255,255,.045) 1px, transparent 1px, transparent 8.333%),
    #090908;
  cursor: crosshair;
}

.timeline-ruler {
  position: relative;
  height: 22px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font: .62rem var(--mono);
}

.timeline-ruler span {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  min-height: 46px;
  border-bottom: 1px solid var(--line-soft);
}

.timeline-row:last-child { border-bottom: 0; }

.timeline-lane-label {
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
  padding: 0 8px;
  font-size: .68rem;
  text-transform: uppercase;
}

.timeline-track {
  position: relative;
  min-width: 0;
  padding: 6px;
}

.timeline-empty {
  color: var(--muted);
  font-size: .72rem;
}

.timeline-clip {
  position: absolute;
  top: 8px;
  bottom: 8px;
  overflow: hidden;
  border-color: var(--line);
  background: #2a2713;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-clip.playing {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-clip.project {
  border-color: var(--cyan);
  background: #10201e;
}

.timeline-clip.midi {
  min-width: 34px;
  border-color: var(--accent-2);
  background: #2a1711;
  font-size: .68rem;
}

.timeline-clip.midi.out {
  border-color: var(--accent);
  background: #2a2713;
}

.timeline-playhead {
  position: absolute;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
}

.log {
  height: calc(100vh - 190px);
  min-height: 420px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: #050504;
  color: #d8d4c5;
  padding: 9px;
  font: .72rem/1.42 var(--mono);
  white-space: pre-wrap;
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.action-ok { color: var(--ok); }
.action-locked { color: var(--warn); }

@media (max-width: 1320px) {
  .layout,
  .daw-workspace {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
    max-height: none;
  }

  .transport-panel,
  .sample-panel,
  .arrangement-panel,
  .timeline-panel,
  .tree-panel,
  .log-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .meta-grid,
  .activity-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .log {
    height: 320px;
    min-height: 260px;
  }
}

@media (max-width: 760px) {
  .app { padding: 6px; }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-stack {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .meta-grid,
  .activity-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }

  .bank-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .pad-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }
}
