:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #ffffff;
  --dim: #999999;
  --line: #ffffff;
  --accent: #ff2d2d;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: none;
  display: flex;
  flex-direction: column;
}

header {
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
}

.tag {
  color: var(--dim);
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.daw-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  border-left: 2px solid var(--line);
  border-right: 2px solid var(--line);
  overflow: hidden;
}

.tabs {
  flex: 0 0 auto;
  display: flex;
  border-bottom: 2px solid var(--line);
}

.tab-btn {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-right: 1px solid var(--line);
  padding: 0.9rem 0.5rem;
  min-height: 44px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.tab-btn:last-child { border-right: none; }
.tab-btn:hover { background: rgba(255, 255, 255, 0.1); }
.tab-btn.active { background: var(--fg); color: var(--bg); }

.controls {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
}

.tab-pane h3 {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 1.25rem 0 0.5rem;
}

.tab-pane h3:first-child { margin-top: 0; }

.hidden { display: none !important; }

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.add-menu { position: relative; }

.add-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  background: var(--bg);
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.add-menu-list .menu-item {
  display: block;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  text-align: left;
  font-family: inherit;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.add-menu-list .menu-item:last-child { border-bottom: none; }
.add-menu-list .menu-item:hover { background: var(--fg); color: var(--bg); }

.zoom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#empty-hint, #mix-empty-hint {
  color: var(--dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#multitrack {
  min-height: 60px;
  border: 1px solid var(--line);
  overflow-x: auto;
  margin: 0.75rem 0;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.track-row:last-child { border-bottom: none; }

.track-group { border-bottom: 1px solid var(--line); }
.track-group:last-child { border-bottom: none; }
.track-group .track-row { border-bottom: none; padding-left: 0.5rem; }

.clip-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0 0 0.6rem 1.25rem;
}

.clip-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: var(--dim);
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
}

.clip-row.active { color: var(--fg); border-color: var(--accent); }
.clip-index { font-weight: 700; min-width: 1.5rem; }
.clip-pos { flex: 1; }
.clip-row button { min-height: 30px; padding: 0.25rem 0.5rem; font-size: 0.65rem; }

.track-name {
  font-weight: 700;
  min-width: 100px;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.track-dur { color: var(--dim); font-size: 0.8rem; }

.vol-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.detail-header h3 { margin: 0; }

.hint {
  color: var(--dim);
  font-size: 0.75rem;
  margin-top: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#detail-waveform {
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
}

.effects-rack {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

#edit-history {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#edit-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}

#edit-history li.muted, .muted { color: var(--dim); text-transform: none; }

.export-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button {
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--line);
  padding: 0.6rem 1rem;
  min-height: 44px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover { background: var(--fg); color: var(--bg); }

button.secondary {
  border: 1px solid var(--line);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  min-height: 38px;
  padding: 0.45rem 0.8rem;
}

button.secondary.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

button.secondary.active:hover {
  background: var(--bg);
  color: var(--accent);
}

#record-btn.recording {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  animation: rec-pulse 1s step-start infinite;
}

#record-btn.recording:hover {
  background: var(--bg);
  color: var(--accent);
}

@keyframes rec-pulse {
  50% { opacity: 0.55; }
}

input[type="text"] {
  background: var(--bg);
  border: 2px solid var(--line);
  color: var(--fg);
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  flex: 1;
  font-family: inherit;
  font-size: 1rem;
}

input[type="text"]::placeholder { color: var(--dim); }

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

.ai-bar {
  flex: 0 0 auto;
  border-top: 2px solid var(--line);
  padding: 0.75rem 1rem;
}

#chat-log {
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.msg {
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  max-width: 90%;
  line-height: 1.4;
  font-size: 0.8rem;
}
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg.system {
  align-self: center;
  color: var(--dim);
  font-size: 0.7rem;
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#chat-form { display: flex; gap: 0.5rem; }
#chat-input { flex: 1; }

@media (max-width: 640px) {
  header .tag { display: none; }
  header { padding: 0.6rem 0.75rem; }
  .daw-shell { border-left: none; border-right: none; }
  .controls { padding: 0.75rem; }
  .tab-btn { font-size: 0.68rem; padding: 0.8rem 0.25rem; letter-spacing: 0.06em; }
  .track-name { min-width: 76px; font-size: 0.78rem; }
  .effects-rack button { flex: 1 1 calc(50% - 0.5rem); }
  #chat-log { max-height: 100px; }
  .ai-bar { padding: 0.6rem 0.75rem; }
}
