/* songcode — stem mode.
 *
 * The second workspace on the stage: the song as stems, lanes and notes.
 * Built from the design system in styles.css (surfaces, text tiers, one
 * accent for primary actions and live state, neutral selection). The only
 * colors added here are the four stem roles the system does not name.
 *
 *   1. stage head     3. popovers        5. inspector     7. small screens
 *   2. tracks         4. note editor     6. skeleton
 */

:root {
  --stem-snare: #ff7a45;
  --stem-sub: #5e8bff;
  --stem-stab: #da8fff;
  --stem-fx: #9fb0b8;
}

/* ————————————————————————————— 1. stage head ————————————————————————————— */

.stage-head {
  display: flex;
  align-items: center;
  flex: none;
  gap: 10px;
  height: 44px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}
.stage-switch { flex: none; width: 132px; }
.stage-switch button { min-height: 26px; padding: 3px 6px; font-size: 12.5px; }
.stage-tools { display: flex; align-items: center; flex: 1; gap: 6px; min-width: 0; }
.stage-tools .btn { height: 28px; border-radius: var(--r-sm); }
.stage-tools .btn-icon { width: 28px; }
.sx-flip .icon { transform: scaleX(-1); }
.sx-spacer { flex: 1; }

.shell.view-stems #player { display: none; }

.sx-pos {
  flex: none;
  min-width: 34px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* a labelled value: the label is quiet, the value is the control */
.sx-chip {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 4px;
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease);
}
.sx-chip:hover { background: var(--surface-3); }
.sx-chip input, .sx-chip select {
  height: 22px;
  padding: 0 4px;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.sx-chip select { padding-right: 4px; cursor: pointer; field-sizing: content; }
.sx-chip select:hover { background: transparent; }
.sx-chip select:disabled { color: var(--text-3); cursor: default; }
.sx-chip input[type='number'] { width: 40px; border: 0; appearance: textfield; -moz-appearance: textfield; }
.sx-chip input[type='number']::-webkit-inner-spin-button { display: none; }
.sx-chip input:focus-visible, .sx-chip select:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
/* a value songcode worked out, not one the person set */
.sx-chip.auto input, .sx-chip.auto select { color: var(--text-2); }

/* ————————————————————————————— 2. tracks ————————————————————————————— */

.sx {
  --sx-head-w: 280px;
  --sx-lane-h: 46px;
  --sx-editor-h: 46%;
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  user-select: none;
  -webkit-user-select: none;
}
.sx .btn { height: 28px; padding: 0 10px; border-radius: var(--r-sm); font-size: 12.5px; }
.sx .btn-icon { width: 28px; padding: 0; }

.sx-tracks {
  position: relative;
  flex: 1 1 0;
  min-height: 96px;
  overflow-x: hidden;
  overflow-y: auto;
}
.sx-ruler-row, .sx-track, .sx-add-row {
  display: grid;
  grid-template-columns: var(--sx-head-w) minmax(0, 1fr);
}
/* the timeline: click or drag the ruler to move through the song */
.sx-ruler-row {
  --sx-ruler-h: 26px;
  position: sticky;
  z-index: 6;
  top: 0;
  height: var(--sx-ruler-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface-1);
}
/* a song with sections carries their names above the bar numbers */
.sx-ruler-row.form { --sx-ruler-h: 42px; }
.sx-ruler-label {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 12px;
  border-right: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11px;
}
.sx-mini.sx-zoom { opacity: 1; font-size: 14px; line-height: 1; }
.sx-mini.sx-zoom:disabled { opacity: 0.3; cursor: default; }
.sx-mini.sx-zoom:disabled:hover { background: transparent; color: var(--text-3); }
.sx-ruler { position: relative; overflow: hidden; cursor: pointer; touch-action: none; }
.sx-ruler:focus-visible { box-shadow: inset 0 0 0 1px var(--accent-line); }
.sx-ticks span {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: center;
  height: 25px;
  padding-left: 5px;
  border-left: 1px solid var(--line-strong);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 10px;
  pointer-events: none;
}
.sx-ticks span.cont { border-left-color: transparent; }
.sx-ticks span.beat { height: 5px; padding: 0; border-left-color: var(--line); }
.sx-ticks span.beat.named { height: 25px; padding-left: 5px; opacity: 0.7; }
.sx-ticks span.section {
  top: 0;
  bottom: auto;
  display: block;
  height: 16px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* zoomed in: the part of the song the lanes are showing, and a handle on it */
.sx-window {
  position: absolute;
  z-index: 2;
  bottom: 0;
  min-width: 12px;
  height: 3px;
  border-radius: 3px;
  background: var(--text-3);
  cursor: grab;
  touch-action: none;
  transition: background var(--dur-1) var(--ease), height var(--dur-1) var(--ease);
}
.sx-window::before { content: ''; position: absolute; inset: -6px 0 0; }
.sx-window:hover, .sx-window.dragging { height: 4px; background: var(--text-2); }
.sx-window.dragging { cursor: grabbing; }

.sx-track {
  --c: var(--stem-lead);
  height: var(--sx-lane-h);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.sx-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 10px 0 12px;
  border-right: 1px solid var(--line);
  background: var(--surface-1);
  transition: background var(--dur-1) var(--ease);
}
.sx-track:hover .sx-head { background: var(--surface-2); }
.sx-track.selected .sx-head { background: var(--surface-3); box-shadow: inset 2px 0 0 var(--c); }
.sx-track.selected .sx-lane { background: rgba(255, 255, 255, 0.035); }
.sx-dot { flex: none; width: 8px; height: 8px; border-radius: 3px; background: var(--c); }
.sx-name { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.2; }
.sx-name b, .sx-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-name b { font-size: 13px; font-weight: 500; }
.sx-name small { color: var(--text-3); font-size: 11px; }
.sx-name small.bad { color: var(--danger); }

.sx-mini, .sx-ms {
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.sx-mini { background: transparent; color: var(--text-3); opacity: 0; }
.sx-mini .icon { width: 14px; height: 14px; }
.sx-track:hover .sx-mini, .sx-track.selected .sx-mini, .sx-mini:focus-visible { opacity: 1; }
.sx-mini:hover { background: var(--surface-4); color: var(--text); }
.sx-ms { background: var(--surface-2); color: var(--text-3); font-size: 11px; font-weight: 600; }
.sx-track:hover .sx-ms, .sx-track.selected .sx-ms { background: var(--surface-4); }
.sx-ms:hover { color: var(--text); }
.sx-ms.mute.on { background: var(--warn); color: #1a1000; }
.sx-ms.solo.on { background: var(--text); color: #0a0a0c; }

.sx input[type='range'].sx-gain { --fill-color: var(--c); flex: none; width: 56px; height: 16px; }
.sx-gain::-webkit-slider-runnable-track { height: 3px; }
.sx-gain::-webkit-slider-thumb { width: 10px; height: 10px; margin-top: -3.5px; }
.sx-gain::-moz-range-track, .sx-gain::-moz-range-progress { height: 3px; }
.sx-gain::-moz-range-thumb { width: 10px; height: 10px; }
.sx-meter {
  display: flex;
  align-items: flex-end;
  flex: none;
  width: 3px;
  height: 26px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}
.sx-meter i { display: block; width: 100%; height: 0; background: var(--c); transition: height 0.06s linear; }

.sx-lane { position: relative; min-width: 0; overflow: hidden; }
.sx-lane canvas { display: block; width: 100%; height: 100%; }
.sx-track.muted .sx-lane canvas { opacity: 0.28; }
.sx-track.muted .sx-name b { color: var(--text-3); }
.sx-track.busy .sx-lane::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--c) 22%, transparent) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: sx-shimmer 1.1s linear infinite;
}
@keyframes sx-shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }

.sx-add-row { height: 44px; }
.sx-add-cell { display: flex; align-items: center; padding: 0 10px; }
.sx .sx-add { color: var(--text-2); }

/* The playhead is always there: neutral at rest, the accent while it plays.
   It hangs off the sticky ruler row, so it stays put when the lanes scroll. */
.sx-playhead, .sx-ghost, .sx-rollhead {
  position: absolute;
  top: 0;
  width: 1px;
  margin-left: -0.5px;
  background: var(--text);
  pointer-events: none;
  will-change: transform;
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.sx-playhead, .sx-ghost { z-index: 7; left: var(--sx-head-w); height: var(--sx-view-h, 100%); }
.sx-playhead i {
  position: absolute;
  top: 0;
  left: -5px;
  width: 11px;
  height: 12px;
  border-radius: 2px;
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%);
}
.sx-ghost { background: var(--text-3); opacity: 0; transition: opacity var(--dur-1) var(--ease); }
.sx-ruler:hover ~ .sx-ghost { opacity: 0.6; }
.sx.scrubbing .sx-ghost, .sx-playhead.off, .sx-ghost.off { visibility: hidden; }
.sx.scrubbing .sx-ruler, .sx.scrubbing .sx-rr { cursor: grabbing; }
.sx-rollhead { bottom: 0; opacity: 0.7; }
.sx.playing .sx-playhead, .sx.playing .sx-rollhead { background: var(--accent); opacity: 1; }
.sx.playing .sx-playhead { box-shadow: 0 0 6px var(--accent-line); }

/* an empty song */
.sx-empty {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--surface-0);
  text-align: center;
}
.sx-empty h3 { margin: 0; color: var(--text-3); font-family: var(--font-mono); font-size: 13px; font-weight: 400; }
.sx-empty p { max-width: 400px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.sx-empty .sx-or { color: var(--text-3); font-size: 12px; }
.sx-empty .sx-roles { justify-content: center; max-width: 480px; }
.sx-empty .btn-primary { height: 36px; padding: 0 16px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600; }

/* ————————————————————————————— 3. popovers ————————————————————————————— */

.sx-pop {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 304px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(34, 34, 38, 0.86);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: var(--shadow-pop);
  animation: menu-in var(--dur-2) var(--ease);
}
.sx-pop h4 { margin: 0; color: var(--text-2); font-size: 12px; font-weight: 500; }
.sx-pop textarea {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 13px;
  line-height: 1.45;
  resize: none;
}
.sx-pop .btn { height: 28px; padding: 0 12px; border-radius: var(--r-sm); font-size: 12.5px; }
.sx-pop .btn:not(.btn-primary) { background: rgba(255, 255, 255, 0.08); }
.sx-pop-actions { display: flex; justify-content: flex-end; gap: 6px; }

.sx-roles { display: flex; flex-wrap: wrap; gap: 5px; }
.sx-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.sx-role i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.sx-role:hover { background: rgba(255, 255, 255, 0.13); color: var(--text); }
.sx-role.on { background: var(--text); color: #0a0a0c; }
.sx-empty .sx-role { background: var(--surface-2); }
.sx-empty .sx-role:hover { background: var(--surface-3); }

.sx-menu { gap: 0; width: 208px; padding: 5px; }
.sx-menu button {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: background var(--dur-1) var(--ease);
}
.sx-menu button:hover:not(:disabled), .sx-menu button:focus-visible { background: rgba(255, 255, 255, 0.09); box-shadow: none; }
.sx-menu button:disabled { opacity: 0.4; cursor: default; }
.sx-menu button.danger { color: var(--danger); }
.sx-menu hr { width: auto; height: 1px; margin: 5px 10px; border: 0; background: var(--line-strong); }

/* ————————————————————————————— 4. note editor ————————————————————————————— */

.sx-split {
  position: relative;
  z-index: 9;
  flex: none;
  height: 1px;
  background: var(--line-strong);
  cursor: row-resize;
  touch-action: none;
}
.sx-split::before { content: ''; position: absolute; inset: -4px 0; }
.sx-split::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 3px;
  border-radius: 3px;
  background: var(--text-3);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.sx-split:hover::after { opacity: 1; }
.sx-split.dragging::after { opacity: 1; background: var(--accent); }

.sx-editor {
  display: grid;
  flex: none;
  grid-template-columns: minmax(0, 1fr) 280px;
  height: var(--sx-editor-h);
  min-height: 150px;
  background: var(--surface-1);
}
.sx-editor.none { display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 12.5px; }
.sx-rollwrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.sx-rolltools {
  display: flex;
  align-items: center;
  flex: none;
  gap: 6px;
  height: 40px;
  padding: 0 8px 0 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}
.sx-rolltools b { margin-right: 2px; color: var(--text); font-size: 13px; font-weight: 600; }
.sx-rolltools .sx-chip { height: 26px; }
.sx-rolltools .btn { height: 26px; }
.sx-rolltools .btn-icon { width: 26px; font-size: 15px; }
.sx .sx-toggle { color: var(--text-2); }
.sx .sx-toggle.on { background: var(--text); color: #0a0a0c; }
.sx-badge { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 11px; }
.sx-hint { overflow: hidden; margin-right: 4px; text-overflow: ellipsis; }

.sx-roll {
  --step: 22px;
  --row: 14px;
  --keys: 52px;
  --vel: 54px;
  --ruler: 18px;
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface-0);
}
.sx-roll:focus-visible { box-shadow: inset 0 0 0 1px var(--accent-line); }
.sx-roll-inner { position: relative; }
/* the clip's ruler: bars and beats, and a place to click to hear from there */
.sx-rr-row {
  position: sticky;
  z-index: 6;
  top: 0;
  display: flex;
  height: var(--ruler);
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-1);
}
.sx-rr-corner {
  position: sticky;
  z-index: 2;
  left: 0;
  flex: none;
  width: var(--keys);
  border-right: 1px solid var(--line-strong);
  background: var(--surface-2);
}
.sx-rr { position: relative; flex: none; overflow: hidden; cursor: pointer; touch-action: none; }
.sx-rr span {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding-left: 4px;
  border-left: 1px solid var(--line-strong);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  pointer-events: none;
}
.sx-rr span.beat { top: auto; height: 100%; border-left-color: var(--line); color: var(--text-3); }
.sx-keys {
  position: sticky;
  z-index: 4;
  left: 0;
  width: var(--keys);
  border-right: 1px solid var(--line-strong);
  background: var(--surface-2);
}
.sx-key {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--row);
  padding-right: 6px;
  border-bottom: 1px solid transparent;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
}
.sx-key.black { background: var(--surface-0); }
.sx-key.c { border-bottom-color: var(--line-strong); color: var(--text-2); }
.sx-key.root { color: var(--text); }
.sx-key:hover { background: var(--surface-4); color: var(--text); }
.sx-key.drum { border-bottom-color: var(--line); background: var(--surface-1); color: var(--text-2); font-size: 11px; }

.sx-grid {
  position: absolute;
  top: var(--ruler);
  left: var(--keys);
  background-image:
    linear-gradient(to right, var(--line-strong) 1px, transparent 1px),
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: calc(var(--step) * 16) 100%, calc(var(--step) * 4) 100%, var(--step) 100%;
  cursor: crosshair;
  touch-action: none;
}
.sx-rowbg { position: absolute; right: 0; left: 0; height: var(--row); pointer-events: none; }
.sx-rowbg.out { background: rgba(0, 0, 0, 0.34); }
.sx-rowbg.c { border-bottom: 1px solid var(--line-strong); }
.sx-rowbg.root { background: rgba(255, 255, 255, 0.045); }
.sx-rowbg.drum { border-bottom: 1px solid var(--line); }
.sx-note {
  position: absolute;
  height: calc(var(--row) - 1px);
  border-radius: 3px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  opacity: var(--o, 1);
  cursor: grab;
  touch-action: none;
}
.sx-note.sel { box-shadow: inset 0 0 0 1.5px #fff, 0 0 0 1px rgba(0, 0, 0, 0.6); opacity: 1; }
.sx-note::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.sx-roll.drums .sx-note::after, .sx-roll.readonly .sx-note::after { display: none; }
.sx-roll.readonly .sx-note { cursor: default; }
.sx-roll.readonly .sx-grid { cursor: default; }
.sx-marquee {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.sx-rollhead { z-index: 3; left: 0; }

.sx-vel {
  position: sticky;
  z-index: 5;
  bottom: 0;
  display: flex;
  height: var(--vel);
  border-top: 1px solid var(--line-strong);
  background: var(--surface-1);
}
.sx-vel-label {
  position: sticky;
  z-index: 2;
  left: 0;
  display: flex;
  align-items: center;
  flex: none;
  justify-content: flex-end;
  width: var(--keys);
  padding-right: 6px;
  border-right: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10px;
}
.sx-vel-lane { position: relative; flex: none; cursor: ns-resize; touch-action: none; }
.sx-velbar {
  position: absolute;
  bottom: 0;
  width: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--c);
  opacity: 0.7;
  pointer-events: none;
}
.sx-velbar.sel { background: #fff; opacity: 1; }

/* ————————————————————————————— 5. inspector ————————————————————————————— */

.sx-insp {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
}
.sx-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}
.sx-label span { color: var(--text-3); font-weight: 400; }
.sx-insp .sx-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 6px; }
.sx-insp input[type='text'], .sx-insp select, .sx-insp textarea {
  width: 100%;
  user-select: text;
  -webkit-user-select: text;
}
.sx-insp textarea { display: block; padding: 8px 10px; font-size: 13px; line-height: 1.45; resize: none; }
.sx-insp textarea.code {
  min-height: 104px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  resize: vertical;
}
.sx-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.sx-err, .sx-note-line { margin-top: 6px; font-size: 12px; line-height: 1.45; }
.sx-err { color: var(--danger); user-select: text; -webkit-user-select: text; }
.sx-note-line { color: var(--text-3); }
.sx-pan { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; gap: 8px; }
.sx-pan input { width: 100%; }
.sx-pan output { color: var(--text-2); font-family: var(--font-mono); font-size: 11.5px; text-align: right; }

.sx-status .sx-keys-hint { margin-left: auto; color: var(--text-3); white-space: nowrap; }

/* ————————————————————————————— 6. skeleton ————————————————————————————— */

/* What a stem looks like before it is written. Bones come from the design
   system (.skel, .skel-sweep in styles.css). A sweep layer may hold nothing
   but bones, so the panel backgrounds and rules are drawn under it. */

/* rows for the stems still to come: the head column and the row rules are
   backgrounds here, the bones sit in one layer on top */
.sx-skel {
  background:
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--sx-lane-h) - 1px), var(--line) calc(var(--sx-lane-h) - 1px) var(--sx-lane-h)),
    linear-gradient(var(--line), var(--line)) calc(var(--sx-head-w) - 1px) 0 / 1px 100% no-repeat,
    linear-gradient(var(--surface-1), var(--surface-1)) 0 0 / var(--sx-head-w) 100% no-repeat,
    var(--surface-0);
  animation: fadein var(--dur-3) var(--ease);
}
.sx-skel-row {
  display: grid;
  grid-template-columns: var(--sx-head-w) minmax(0, 1fr);
  height: var(--sx-lane-h);
}
.sx-skel-head { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 0 10px 0 12px; }
.sx-skel-dot { width: 8px; height: 8px; border-radius: 3px; }
.sx-skel-name { display: flex; flex: 1; flex-direction: column; gap: 7px; min-width: 0; }
.sx-skel-name .skel { max-width: 100%; height: 8px; }
.sx-skel-name .skel.dim { height: 6px; }
/* the header controls, in the places the real ones take */
.sx-skel-meter { width: 3px; height: 26px; margin-left: 28px; border-radius: 2px; --skel: var(--surface-2); }
.sx-skel-ms { width: 22px; height: 22px; border-radius: 6px; --skel: var(--surface-2); }
.sx-skel-gain { width: 56px; height: 3px; border-radius: 3px; }
.sx-skel-lane, .sx-ghost-lane { position: relative; min-width: 0; overflow: hidden; }
.sx-skel-lane .skel, .sx-ghost-lane .skel { --skel: var(--surface-4); position: absolute; min-width: 2px; border-radius: 1px; }
/* one stem being added: its name and role are known, so the notes take its color */
.sx-ghost-lane .skel { background: color-mix(in srgb, var(--c) 34%, transparent); }

/* the note editor before the first stem lands */
.sx-skel-editor { position: relative; }
.sx-skel-roll {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) 51px 0 / 1px 100% no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 0 / 52px 100% no-repeat,
    var(--surface-0);
}
.sx-skel-roll::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 54px;
  border-top: 1px solid var(--line-strong);
  background: linear-gradient(var(--line-strong), var(--line-strong)) 51px 0 / 1px 100% no-repeat, var(--surface-1);
}
.sx-skel-editor > .sx-skel-bones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
}
.sx-skel-rollcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sx-skel-tools { display: flex; align-items: center; flex: none; gap: 6px; height: 40px; padding: 0 12px; overflow: hidden; }
.sx-skel-grid, .sx-skel-vel { position: relative; margin-left: 52px; overflow: hidden; }
.sx-skel-grid { flex: 1; min-height: 0; }
.sx-skel-grid .skel { position: absolute; height: 13px; border-radius: 3px; }
.sx-skel-vel { flex: none; height: 54px; }
.sx-skel-vel .skel { position: absolute; bottom: 0; width: 4px; border-radius: 2px 2px 0 0; }
.sx-skel-insp { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 12px; overflow: hidden; }
.sx-skel-insp .sx-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 6px; }
.sx-skel-label { height: 8px; margin: 4px 0 10px; }
.sx-skel-field { border-radius: var(--r-sm); --skel: var(--surface-2); }

/* a stem being rewritten: its notes stay until the new ones land, under the
   same light as its lane */
.sx-editor.busy .sx-rollwrap { position: relative; }
.sx-editor.busy .sx-rollwrap::after {
  content: '';
  position: absolute;
  z-index: 6;
  inset: 40px 0 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--c) 14%, transparent) 50%, transparent 80%);
  background-size: 220% 100%;
  pointer-events: none;
  animation: sx-shimmer 1.1s linear infinite;
}

/* ————————————————————————————— 7. small screens ————————————————————————————— */

@media (max-width: 1280px) {
  .sx { --sx-head-w: 232px; }
  .sx-editor { grid-template-columns: minmax(0, 1fr) 244px; }
  .sx-skel-editor > .sx-skel-bones { grid-template-columns: minmax(0, 1fr) 244px; }
  .sx input[type='range'].sx-gain { width: 40px; }
  .sx-skel-gain { width: 40px; }
  .sx-status .sx-keys-hint { display: none; }
}
@media (max-width: 760px) {
  .stage-head { overflow-x: auto; scrollbar-width: none; }
  .stage-tools { flex: none; }
  .sx { --sx-head-w: 132px; --sx-editor-h: 52%; }
  .sx-gain, .sx-meter, .sx-mini { display: none; }
  .sx-skel-gain, .sx-skel-meter { display: none; }
  .sx-editor.sx-skel-editor { grid-template-rows: 260px minmax(0, 1fr); overflow: hidden; }
  .sx-skel-editor > .sx-skel-bones { grid-template-columns: minmax(0, 1fr); grid-template-rows: 260px minmax(0, 1fr); }
  .sx-mini.sx-zoom { display: grid; width: 28px; height: 28px; }
  .sx-ruler-label { padding: 0 4px 0 10px; }
  .sx-editor { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .sx-rollwrap { min-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sx-chip input, .sx-chip select, .sx-insp input[type='text'], .sx-insp select { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sx-track.busy .sx-lane::after { animation: none; }
  .sx-editor.busy .sx-rollwrap::after { display: none; }
}
