/* Buttons, panels, dialogs, lists. */

.btn {
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #eafff2;
}
.btn-primary:hover { background: var(--accent); color: #06220f; }
.btn-danger { background: #7f1d1d; border-color: #7f1d1d; color: #fee; }
.btn-danger:hover { background: var(--danger); }
.btn-icon { padding: 4px 8px; }
.btn-toggle.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #eafff2;
}

.tb-sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 0 4px;
}

.tb-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.tb-field input[type="number"] { width: 58px; }
.inp-name {
  width: 140px;
  background: transparent;
  border-color: transparent;
  font-weight: 600;
}
.inp-name:hover, .inp-name:focus { background: var(--bg-2); border-color: var(--line); }

.save-dot { color: var(--accent); font-size: 10px; margin-left: 2px; transition: color 0.3s; }
.save-dot.dirty { color: var(--text-dim); }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg.seg-wrap { flex-wrap: wrap; }
.seg-wrap .seg-btn { flex: 1 0 20%; border-top: 1px solid var(--line); margin-top: -1px; }
.seg-btn { padding: 4px 10px; background: var(--bg-2); color: var(--text-dim); border-right: 1px solid var(--line); }
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--accent-dim); color: #eafff2; }
.seg-btn:hover:not(.active) { background: var(--bg-3); }

/* dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.dropdown-menu[hidden] { display: none; }
.dropdown-menu button { padding: 7px 12px; text-align: left; }
.dropdown-menu button:hover { background: var(--bg-3); }

/* context menu (ruler right-click) */
.ctx-menu {
  position: fixed;
  z-index: 100;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.ctx-menu button { padding: 7px 12px; text-align: left; }
.ctx-menu button:hover { background: var(--bg-3); }

/* panels */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

/* track list */
.track-list { list-style: none; }
.track-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.track-row.active { background: var(--bg-2); box-shadow: inset 2px 0 0 var(--accent); }
.track-color { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.track-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-row .btn-icon { padding: 1px 5px; font-size: 11px; color: var(--text-dim); }
.track-row .btn-icon.on { color: var(--accent); }
/* M / C / S markers. Defined once and unscoped, so the same control looks
   the same wherever it appears - solo used to be green in the Mixer and
   yellow in the tracks panel. */
.role-btn {
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  padding: 0 5px;
}
.role-btn.on { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-3); }
.role-btn.chords.on { color: var(--track-4); border-color: var(--track-4); }
/* solo is a temporary override you want to notice and undo, so it gets the
   warning colour rather than the "this is on and fine" accent */
.role-btn.solo.on { color: var(--warn); border-color: var(--warn); }
.track-row select { max-width: 74px; font-size: 11px; }
.track-role-chip {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--text-dim);
}
.track-role-chip.chords { color: var(--track-4); }

/* track reordering + colour picker */
.track-list.reordering .track-row { cursor: grabbing; }
/* where the dragged row will land - drawn on the row it will sit after */
.track-row.drop-target { box-shadow: inset 0 -2px 0 var(--accent); }
.track-list.reordering .track-row { user-select: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid transparent;
}
.swatch.on { border-color: var(--text); }

/* recent projects */
.recent-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.recent-item:hover { background: var(--bg-2); border-color: var(--line-strong); }
.recent-name { flex: 1; font-weight: 600; }
.recent-meta { color: var(--text-dim); font-size: 12px; }
.mode-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--accent);
}
.recent-empty { color: var(--text-dim); padding: 10px 0; }
.demo-item { border-style: dashed; }
.demo-chip {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--text-dim);
}
.demo-open { color: var(--text-dim); display: flex; align-items: center; }

/* tools sidebar: one boxed card per tool, so it is obvious where a tool
   starts and what belongs to it */
.tools-empty { color: var(--text-dim); font-size: 12px; padding: 14px 12px; line-height: 1.5; }
#tools-list { display: flex; flex-direction: column; gap: 8px; padding: 8px; }

.tool-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-1);
  overflow: hidden;
}
.tool-card.open { border-color: var(--line-strong); }

.tool-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 9px;
  color: var(--text);
  font-weight: 600;
  text-align: left;
}
.tool-card-head:hover { background: var(--bg-2); }
.tool-card-name { flex: none; }
.tool-caret { color: var(--text-dim); font-size: 10px; }

/* the status indicator is drawn for collapsed cards too - a closed card
   still has to say whether its tool is in play */
.tool-status {
  margin-left: auto;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-status.on { color: var(--accent); }
.tool-status.on::before { content: "● "; font-size: 8px; vertical-align: middle; }

.tool-card-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 10px;
  flex-direction: column;
  gap: 10px;
}
.tool-card.open .tool-card-body { display: flex; }

.btn-link {
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: underline;
  padding: 0 2px;
}
.btn-link:hover { color: var(--text); }
/* A disabled one has to LOOK disabled - .btn:disabled does not apply here,
   so a greyed link was indistinguishable from a live one. */
.btn-link:disabled { opacity: 0.45; cursor: default; text-decoration: none; }
.btn-pair { display: flex; gap: 6px; }
.btn-pair .btn { flex: 1; }

/* mixer tool */
.mix-row { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mix-row:last-child { border-bottom: none; }
/* A track that cannot be heard right now - muted, or not the soloed one.
   The fade is applied to the LABEL AND CONTROLS, never to the whole row:
   opacity on the row also dimmed the colour dot, so a muted track's colour
   looked different here than in the tracks panel - same hue, paler, which
   reads as the wrong colour. Opacity creates a stacking context, so a child
   cannot opt back out; it has to not be applied in the first place. */
.mix-row.silenced .mix-name,
.mix-row.silenced .mix-ctl { opacity: 0.45; }
.mix-head { display: flex; align-items: center; gap: 6px; }
.mix-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mix-ctl { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.mix-ctl label { width: 30px; flex: none; }
.mix-ctl input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.mix-val { width: 38px; text-align: right; font-family: var(--font-mono); color: var(--text); }
.mix-val.hot { color: var(--warn); }

/* levels tool */
/* its labels are longer than the mixer's, which clipped "Smooth" */
#levels-body .mix-ctl label { width: 46px; }
.lv-legend { font-size: 10px; color: var(--text-dim); line-height: 1.4; }
.lv-readout {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lv-row { display: flex; align-items: baseline; gap: 6px; color: var(--text-dim); }
.lv-row span:first-child { width: 46px; flex: none; }
.lv-row b { font-family: var(--font-mono); font-size: 13px; min-width: 38px; }
.lv-row b.ok { color: var(--accent); }
.lv-row b.warm { color: var(--warn); }
.lv-row b.hot { color: var(--danger); }
.lv-note { color: var(--text-dim); font-size: 10px; margin-top: 2px; }
.lv-tracks { display: flex; flex-direction: column; gap: 2px; }
.lv-track { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }

/* envelope editor (instrument tool) */
.env-canvas {
  width: 100%;
  height: 90px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: block;
}
/* sliders grey out once a drawn shape has taken over - they cannot express
   it, and pretending otherwise would round the curve away on the next drag */
.harm-field.disabled { opacity: 0.45; pointer-events: none; }

/* arp panel */
.harm-info {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.harm-info.warn { border-left-color: var(--warn); }
.harm-chord-name { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--accent); }
.harm-info.warn .harm-chord-name { color: var(--warn); }
.harm-chord-src { color: var(--text-dim); font-size: 11px; }
.harm-chord-detail { flex-basis: 100%; color: var(--warn); font-size: 11px; line-height: 1.4; }
.harm-empty { color: var(--text-dim); font-size: 12px; padding: 10px 0; }
.harm-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.harm-field .seg { align-self: stretch; }
.harm-field .seg-btn { flex: 1; padding: 4px 4px; font-size: 11px; }
.harm-row { display: flex; align-items: center; gap: 8px; }
.harm-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper .val { min-width: 24px; text-align: center; color: var(--text); font-family: var(--font-mono); }
.harm-presets { display: flex; gap: 6px; align-items: center; }
.harm-presets select { flex: 1; min-width: 0; }
.harm-field select { max-width: 100%; }

/* 12-key pitch-class picker for custom chords */
.pc-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.pc-key {
  padding: 3px 0;
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-dim);
}
.pc-key.on { background: var(--accent-dim); border-color: var(--accent); color: #eafff2; }

/* a level pushed past unity - legal, limited, but worth seeing */
.hot { color: var(--warn); }

/* rendered mix level (export dialog) */
.level-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; }
.level-note:empty { display: none; }
.level-note.warn { color: var(--warn); }

/* status bar bits */
.st-item:empty { display: none; }
#st-save.warn { color: var(--warn); font-weight: 600; }
/* the clip indicator only exists while the mix is actually over - it must
   catch the eye without becoming permanent furniture in the status bar */
#st-clip {
  color: var(--warn);
  font-weight: 600;
  cursor: default;
}
#st-conflicts { color: var(--danger); cursor: pointer; }
#st-conflicts .stfix { text-decoration: underline; margin-left: 6px; }

/* dialogs */
dialog {
  /* the global reset zeroes margins, which breaks the UA's dialog centering */
  margin: auto;
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0;
  min-width: 380px;
  max-width: min(720px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg-form h2 { font-size: 15px; }
.dlg-hint { color: var(--text-dim); font-size: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; list-style: none; }
.dlg-warnings { color: var(--warn); font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.dlg-warnings:empty { display: none; }

.export-preview {
  max-height: 320px;
  overflow: auto;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
}

/* midi import table */
.midi-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.midi-table th, .midi-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.midi-table th { color: var(--text-dim); font-weight: 600; }

/* drag-over highlight */
body.dragging::after {
  content: "Drop .mid / .tune.json to import";
  position: fixed;
  inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent);
  background: rgba(16, 18, 20, 0.85);
  z-index: 200;
  pointer-events: none;
}

.track-hex { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; color: var(--text-dim); }
.track-hex input { width: 90px; font-family: var(--font-mono); }
.track-hex input.invalid { border-color: var(--danger); color: var(--danger); }

/* Small print under a control: says which knob to reach for, so the advice
   sits where the wrong choice would be made rather than in the README. */
.in-hint { font-size: 10px; color: var(--text-dim); line-height: 1.4; margin-top: 4px; }

/* Label, value and any inline action on one line. .harm-field is a column,
   so every child is its own flex item - without this the link landed on a
   line of its own, reading as another sentence of hint rather than a
   control sitting beside the number it acts on. */
.harm-caption { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

/* Additive drawbars: one vertical slider per partial, fundamental on the
   left. Vertical because that is what a drawbar looks like, and because
   eight horizontal sliders would be taller than the whole card. */
.drawbars { display: flex; gap: 6px; align-items: end; justify-content: space-between; }
.drawbar { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 9px; color: var(--text-dim); }
.drawbar input[type="range"] {
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: slider-vertical; /* older Chromium/Safari */
  width: 14px;
  height: 56px;
  accent-color: var(--accent);
}

/* Effects card: a bus is a stack of effects, so each one is a boxed group
   with its own params rather than a flat list of controls. */
.fx-chain { display: flex; flex-direction: column; gap: 6px; }
.fx-item { border: 1px solid var(--line); border-radius: 4px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.fx-param { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.fx-param input[type="range"] { flex: 1; accent-color: var(--accent); }
.fx-param select { flex: 1; }
.fx-param .mix-val { min-width: 46px; text-align: right; font-family: var(--font-mono); color: var(--text); }

/* Command palette: the table, made visible. */
#dlg-palette .dlg-form { min-width: 340px; gap: 8px; }
#palette-input { font-size: 14px; padding: 6px 8px; }
.palette-list { list-style: none; display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.palette-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.palette-item.on { background: var(--bg-3); }
.palette-item kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px;
}
.palette-empty { color: var(--text-dim); font-size: 12px; padding: 6px 8px; }

/* A collapsible group inside a tool card: same idea as the cards themselves,
   one level down, so a section you are not using costs one line. */
.in-details { border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; }
.in-details > summary {
  cursor: pointer; font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.in-details > summary::marker { color: var(--text-dim); }
.in-details[open] > summary { margin-bottom: 6px; }

/* Levels: the MEASURED output leads, the estimate is footnotes. It used to
   be the other way round - the estimate had the bordered panel and the real
   measurement a line of small print. */
.lv-output {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px;
}
.lv-out-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: var(--text-dim); }
.lv-mode { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.lv-out-peak { display: flex; align-items: baseline; gap: 6px; flex-wrap: nowrap; }
.lv-out-peak b { font-family: var(--font-mono); font-size: 17px; color: var(--text); white-space: nowrap; }
.lv-out-peak span { font-size: 10px; color: var(--text-dim); }
.lv-out-sub { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.lv-out-sub b { font-family: var(--font-mono); color: var(--text); }
.lv-output input[type="range"] { width: 100%; accent-color: var(--accent); }
.lv-output .btn { width: 100%; }
.lv-note { font-size: 10px; color: var(--text-dim); line-height: 1.4; }
/* the estimate, demoted */
.lv-readout b { font-size: 11px; }

/* Badges card. The pairing code is the thing you press, so it is shown large
   and as glyphs - "URDLAB" is only how it travels over the wire. */
.bg-code { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.bg-code-glyphs {
  font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.12em;
  color: var(--text); text-align: center; padding: 4px 0;
}
.bg-list { display: flex; flex-direction: column; gap: 6px; }
.bg-badge { border: 1px solid var(--line); border-radius: 4px; padding: 6px; }
.bg-badge.offline { opacity: 0.55; }
.bg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex: none; }
.bg-dot.on { background: var(--accent); }
.bg-name { flex: 1; }
