/* ==========================================================================
   Kickwerk — dark hardware-style UI
   ========================================================================== */

:root {
  --bg: #0c0d0f;
  --panel: #141619;
  --panel-2: #1b1e22;
  --lane: #101214;
  --line: #2a2e34;
  --line-soft: #1f2227;
  --text: #ece8e1;
  --muted: #9097a1;
  --dim: #7a808b;            /* ≥ 4.5 : 1 on panel / lane (WCAG AA for small text) */
  --accent: #ff7a2f;
  --accent-2: #ffb36b;
  --pitch: #4cc9ff;
  --amp: #a6e35f;
  --wave: #f3ebdf;
  --danger: #ff4d5e;
  --grid: #1c1f24;
  --grid-strong: #2a2f36;

  --radius: 10px;
  --radius-sm: 7px;
  --gap: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  --topbar-h: 56px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(255, 122, 47, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  display: grid;
  grid-template-rows: auto 1fr;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

/* author display rules (e.g. .btn { display: inline-flex }) must not resurrect [hidden] elements */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
canvas:focus-visible { outline-offset: -2px; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(var(--panel-2), #17191d);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;

  & svg { width: 14px; height: 14px; fill: currentColor; }
  &:hover { border-color: #3a3f47; }
  &:active { background: #121417; }
  &:disabled { opacity: 0.4; cursor: default; }
}
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-icon { width: 32px; padding: 0; font-size: 15px; }
.btn-sm.btn-icon { width: 26px; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.btn.toggle.is-forced { border-style: dashed; color: var(--accent-2); }
.btn.toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
  color: var(--accent-2);
}

.btn-play {
  height: 36px;
  padding: 0 16px;
  border-color: color-mix(in srgb, var(--accent) 60%, black);
  background: linear-gradient(#ff8a45, #f06b21);
  color: #1a0d05;
  font-weight: 650;
  &:hover { border-color: var(--accent-2); }
  &:active, &.is-hit { background: linear-gradient(#ffb36b, #ff8a45); }
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;

  & input[type="number"], & input[type="text"], & select {
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--lane);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }
  & input[type="number"] { width: 64px; }
  & :is(input, select):disabled { opacity: 0.4; cursor: default; }
  & input[type="text"] { width: 84px; }
  & select { font-family: var(--font); padding-right: 4px; }
}

.field-range input[type="range"] { width: 110px; accent-color: var(--accent); }

.check {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; cursor: pointer;
  & input { accent-color: var(--accent); margin: 0; }
}

.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--lane);

  & button {
    height: 26px;
    padding: 0 11px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    &:hover { color: var(--text); }
    &[aria-checked="true"] { background: var(--panel-2); color: var(--accent-2); box-shadow: 0 0 0 1px var(--line) inset; }
  }
}
.seg-sm button { height: 24px; padding: 0 9px; }

.hint { color: var(--dim); font-size: 11px; font-family: var(--mono); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 13, 15, 0.85);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--bg) 0 28%, var(--accent) 30% 100%);
  box-shadow: 0 0 18px -4px var(--accent);
}
.brand-name { font-weight: 800; letter-spacing: 0.14em; font-size: 14px; & b { color: var(--accent); font-weight: 800; } }

.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 1600px) { .brand-name { display: none; } }

.audio-status {
  display: inline-flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--lane); color: var(--muted);
  font-size: 11px; font-family: var(--mono); cursor: pointer;
  & .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
  &[data-state="running"] { cursor: default; & .dot { background: var(--amp); box-shadow: 0 0 8px var(--amp); } }
  &[data-state="suspended"] .dot { background: var(--accent); }
}

.monitor-slot .knob { --knob-size: 34px; flex-direction: row; gap: 6px; }
.monitor-slot .knob-label { order: 2; }
.monitor-slot .knob-value { order: 3; min-width: 52px; text-align: left; }

.meter { width: 90px; height: 14px; border-radius: 3px; background: var(--lane); border: 1px solid var(--line-soft); }

/* ---------- layout ---------- */

.app {
  display: grid;
  gap: var(--gap);
  padding: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "tl" "cy" "rk";
  min-width: 0;
}

.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 8px;
  flex-wrap: wrap;

  & h2 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  & .head-accent { color: var(--accent-2); letter-spacing: 0.02em; text-transform: none; margin-left: 4px; }
  & .head-meta { color: var(--dim); font-family: var(--mono); font-size: 11px; }
  & .head-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
}

.timeline { grid-area: tl; }
.cycle { grid-area: cy; }
.rack { grid-area: rk; }

/* ---------- timeline lanes ---------- */

.lanes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px 8px;
  min-height: 0;
  flex: 1;
}

.lane {
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--lane);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  min-height: 0;

  & canvas { display: block; width: 100%; height: 100%; touch-action: none; }
}
.lane-overview { height: 150px; & canvas { cursor: grab; } }
.lane-morph { height: 44px; }
.lane-pitch { height: 190px; }
.lane-amp { height: 150px; }

.lane-tag {
  position: absolute;
  left: 18px;
  bottom: 6px;
  z-index: 1;
  pointer-events: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tag, var(--dim));
  opacity: 0.85;
}
.lane-overview .lane-tag { bottom: 4px; }
.lane-overview.is-spec .lane-tag { display: none; }

/* ---------- cycle editor ---------- */

.kf-tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.kf-tab {
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: auto 26px;
  gap: 3px;
  width: 88px;
  padding: 5px 7px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--lane);
  color: var(--muted);
  cursor: pointer;
  text-align: left;

  & .kf-tab-label { font-size: 11px; font-weight: 650; display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
  & .kf-tab-label small { font-weight: 400; color: var(--dim); font-family: var(--mono); font-size: 10px; }
  & canvas { width: 100%; height: 26px; display: block; }
  &:hover { border-color: #3a3f47; }
  &[aria-selected="true"] {
    border-color: var(--accent);
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 8%, var(--lane));
  }
}
.kf-tab-add { width: 36px; display: grid; place-items: center; font-size: 18px; grid-template-rows: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 8px;
  flex-wrap: wrap;
}
.toolbar #brush-field[hidden] { display: none; }

.cycle-stage {
  position: relative;
  margin: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--lane);
  border: 1px solid var(--line-soft);
  height: 260px;
  min-height: 0;
  & canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
}

.kf-props {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 4px;
  flex-wrap: wrap;
  & .btn-row { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
}

.ops {
  display: grid;
  gap: 6px;
  padding: 6px 12px 12px;
}

.op-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}
.op-title {
  width: 44px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.op {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--lane);

  & .btn { border: 0; border-right: 1px solid var(--line); border-radius: 6px 0 0 6px; }
  & input {
    width: 46px;
    height: 24px;
    padding: 0 4px 0 6px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    -moz-appearance: textfield;
    &::-webkit-inner-spin-button { opacity: 0.4; }
  }
  & i { font-style: normal; color: var(--dim); font-size: 11px; padding-right: 7px; }
}

/* ---------- rack ---------- */

.rack {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0;
}

.rack-group {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px 12px;
  flex-wrap: wrap;

  & h3 {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    margin: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
  }
}
.rack-master { border-left: 1px solid var(--line-soft); flex: 1; }
.rack-click, .rack-comp, .rack-eq { border-left: 1px solid var(--line-soft); }
.rack-break { flex-basis: 100%; height: 0; border-top: 1px solid var(--line-soft); }
.fx-collapse { align-self: center; margin: 0 12px 0 auto; & svg { transition: rotate 0.15s; } }
.rack.fx-collapsed {
  & .rack-sub .knobs, & .rack-sub .toggles, & .rack-eq .knobs, & .rack-comp .knobs, & #eq-slope { display: none; }
  & .rack-sub, & .rack-eq, & .rack-comp { padding-block: 6px; }
  & .rack-sub h3, & .rack-eq h3, & .rack-comp h3 { writing-mode: horizontal-tb; transform: none; }
  & .fx-collapse svg { rotate: -90deg; }
}
.click-sample { display: flex; align-items: center; gap: 6px; max-width: 190px; }
.click-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--dim); font-family: var(--mono); font-size: 10px;
}
.click-side { display: grid; gap: 6px; }
.key-widget {
  /* top-right, left of the value labels: both envelopes end low (pitch at the end note, amp at 0) */
  position: absolute; top: 6px; right: 52px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  & select {
    height: 24px; padding: 0 4px; border: 1px solid var(--line); border-radius: 6px;
    background: rgba(16, 18, 20, 0.9); color: var(--pitch); font-size: 11px; font-weight: 700;
  }
  & .btn { height: 24px; background: rgba(27, 30, 34, 0.9); }
  & #pitch-shape, &.amp-widget select { color: var(--muted); font-weight: 500; }
}
.amp-widget select { color: var(--amp); }
.key-dev { color: var(--dim); font-family: var(--mono); font-size: 10px; text-shadow: 0 0 4px var(--lane); }
.key-dev.is-off { color: var(--accent-2); }
.head-pitch { color: var(--pitch); opacity: 0.85; }

.knobs { display: flex; gap: 10px; flex-wrap: wrap; }

.master-side { display: grid; gap: 8px; margin-left: auto; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }

.readouts {
  display: grid;
  gap: 2px;
  font-size: 11px;
  & div { display: flex; justify-content: space-between; gap: 12px; }
  & span { color: var(--dim); }
  & b { font-family: var(--mono); font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
}

/* ---------- knob ---------- */

.knob {
  --knob-size: 46px;
  --knob-color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 54px;
}
.knob-dial {
  width: var(--knob-size);
  height: var(--knob-size);
  cursor: ns-resize;
  touch-action: none;
  border-radius: 50%;
  & svg { width: 100%; height: 100%; display: block; overflow: visible; }
}
.knob-track { fill: none; stroke: #262a30; stroke-width: 4; stroke-linecap: round; }
.knob-arc { fill: none; stroke: var(--knob-color); stroke-width: 4; stroke-linecap: round; }
.knob-cap { fill: #1e2126; stroke: #30353c; stroke-width: 1; }
.knob-needle { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.knob-dial:hover .knob-cap, .knob-dial.is-dragging .knob-cap { fill: #24282e; }
.knob-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.knob-value {
  min-width: 56px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  cursor: text;
}
.knob-input {
  width: 58px;
  height: 20px;
  padding: 0 4px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--lane);
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}

/* ---------- file bar ---------- */

.filebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-group { display: inline-flex; gap: 4px; }
.drag-wav { cursor: grab; color: var(--accent-2); border-style: dashed; &:active { cursor: grabbing; } }
.ab-seg button { min-width: 30px; font-weight: 700; }
.ab-seg button:disabled { opacity: 0.35; cursor: default; }
.ab-seg button[data-v="ref"][aria-checked="true"] { color: var(--pitch); }
.name-input {
  width: 124px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  &:hover { border-color: var(--line); }
  &:focus { border-color: var(--accent); background: var(--lane); outline: none; }
}

.factory-select {
  width: 108px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--lane);
  color: var(--muted);
  font-size: 12px;
}

.midi-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim);
  transition: background-color 0.25s, box-shadow 0.25s;
}
#btn-midi.is-enabled .midi-dot { background: var(--pitch); }
#btn-midi .midi-dot.is-hit { background: var(--accent-2); box-shadow: 0 0 10px var(--accent); transition: none; }

.midi-pop { width: min(460px, calc(100vw - 32px)); }
.midi-status { margin: 10px 0; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.midi-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.midi-note { margin: 14px 0 0; line-height: 1.5; font-family: var(--font); }

.lib-pop { width: min(520px, calc(100vw - 32px)); }
.lib-note { margin: 8px 0 12px; font-family: var(--font); }
.lib-list {
  list-style: none; margin: 0 0 12px; padding: 0;
  max-height: 50vh; overflow: auto;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  & li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
  & li:last-child { border-bottom: 0; }
  & .lib-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  & .lib-date { color: var(--dim); font-family: var(--mono); font-size: 10px; }
  & .lib-empty { color: var(--dim); justify-content: center; padding: 16px; }
}
.lib-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- dialogs ---------- */

.dlg {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);

  &::backdrop { background: rgba(0, 0, 0, 0.55); }
  & header { padding: 14px 18px 4px; }
  & h2 { margin: 0; font-size: 15px; }
  & footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line-soft); }
}
.dlg-body { display: grid; gap: 12px; padding: 10px 18px 16px; }
.dlg-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.dlg-info {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--lane);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  &.is-warn { color: var(--accent-2); }
}
.field-wide { & input[type="text"] { flex: 1; width: auto; } & i { font-style: normal; color: var(--dim); } }
.field i { font-style: normal; color: var(--dim); }

.choices {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;

  & legend { padding: 0 0 6px; color: var(--muted); font-size: 12px; }
  & label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--lane);
    cursor: pointer;
    &:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--lane)); }
    &:has(input:disabled) { opacity: 0.45; cursor: default; }
  }
  & input { accent-color: var(--accent); margin: 2px 0 0; }
  & span { display: grid; gap: 1px; }
  & small { color: var(--dim); font-size: 11px; }
}

.drop-hint {
  position: fixed;
  inset: 12px;
  z-index: 50;
  display: none;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: rgba(12, 13, 15, 0.82);
  color: var(--text);
  font-size: 15px;
  pointer-events: none;
  & b { color: var(--accent-2); }
}
body.is-dragging .drop-hint { display: grid; }

/* ---------- help / toast ---------- */

.help {
  width: min(760px, calc(100vw - 32px));
  padding: 16px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);

  &::backdrop { background: rgba(0, 0, 0, 0.5); }
  & header { display: flex; justify-content: space-between; align-items: center; }
  & h2 { margin: 0; font-size: 15px; }
  & h3 { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-2); }
  & dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 12px; }
  & dt { font-family: var(--mono); color: var(--text); }
  & dd { margin: 0; color: var(--muted); }
}
.help-cols { display: grid; gap: 8px 28px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  translate: -50% 12px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 22, 25, 0.96);
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, translate 0.18s;
  &.is-visible { opacity: 1; translate: -50% 0; }
}

.compat-banner {
  padding: 8px 16px;
  background: #3a1d12;
  border-bottom: 1px solid var(--accent);
  color: var(--accent-2);
  font-size: 12px;
}

/* ---------- guided tour ---------- */

.tour-spot {
  position: fixed; z-index: 60; pointer-events: none;
  border: 2px solid var(--accent); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(5, 5, 6, 0.62), 0 0 24px -4px var(--accent);
  transition: left 0.18s, top 0.18s, width 0.18s, height 0.18s;
}
.tour-card {
  position: fixed; z-index: 61; width: min(340px, calc(100vw - 24px));
  padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
  outline: none;
  & h2 { margin: 2px 0 6px; font-size: 14px; }
  & p { margin: 0 0 12px; color: var(--muted); line-height: 1.5; }
  & .tour-step { color: var(--accent-2); font-family: var(--mono); font-size: 10px; }
}
.tour-actions { display: flex; gap: 6px; align-items: center; & .tour-gap { flex: 1; } }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .brand, .meter { display: none; }
  .rack-master, .rack-click, .rack-comp, .rack-eq { border-left: 0; border-top: 1px solid var(--line-soft); }
  .master-side { margin-left: 0; }
  .kf-props .btn-row { margin-left: 0; }
  .card-head .head-tools { margin-left: 0; }
  .card-head .head-pitch { flex-basis: 100%; }
  .key-widget { right: 8px; gap: 4px; }
  .key-widget .key-dev { display: none; }
  #pitch-shape, .amp-widget select { max-width: 84px; }
  .rack-group { padding-inline: 10px; }
}

@media (min-width: 1100px) {
  .app {
    grid-template-columns: minmax(0, 1.55fr) minmax(420px, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "tl cy" "rk rk";
  }
}

/* Desktop with enough height: fill the viewport, lanes and cycle stretch. The
   editors never get squeezed below 520 px — if the rack wraps into more rows
   (narrower desktops / tablets), the page scrolls instead. */
@media (min-width: 1100px) and (min-height: 760px) {
  .app { min-height: 0; grid-template-rows: minmax(520px, 1fr) auto; }
  .timeline, .cycle { min-height: 0; }
  .lane-overview { height: auto; flex: 1.15 1 0; min-height: 90px; }
  .lane-morph { flex: 0 0 44px; }
  .lane-pitch { height: auto; flex: 1.25 1 0; min-height: 100px; }
  .lane-amp { height: auto; flex: 1 1 0; min-height: 90px; }
  .cycle-stage { height: auto; flex: 1 1 0; min-height: 160px; }
}

/* Touch screens: bigger targets. */
@media (pointer: coarse) {
  .btn { height: 36px; }
  .btn-sm { height: 32px; }
  .seg button { height: 32px; }
  .knob { --knob-size: 54px; }
  .lane-morph { height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
