/* P616 — the phone's Stems view (src/studio/phone/stems-view.ts; frame "B · Lanes · screen"). Six 40px lanes, 4px
   apart (60px, 6px apart while the video is Hidden: the room is there), 16px gutters: the stem icon (tap: solo, hold:
   name), the stem's waveform and the speaker (tap: its Volume, L & R and Mute popover); then one MIX row that scrolls
   sideways. Each lane's colour is --psv-c (its --st-stem-*); --psv-at on the root
   is the clock's place in the song, for every lane's played part, and --psv-f the same as 0–1 for the one playhead;
   --psv-fill is a split's percent, filling every lane's stand-in wave. */

.psv {
  /* The bare icons' cut-outs show the page through them. */
  --psv-tile: var(--st-bg);
  --psv-grey: var(--st-line-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  /* A tap or a long press never selects or highlights words on the lanes and their labels (P676). */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.psv__lanes { position: relative; display: flex; flex-direction: column; gap: 4px; transition: gap 200ms ease; }
/* The playhead: one 1.5px line through every lane and the gaps between them, over the waveforms' span (each card's
   36px icon + 4px gap + 1px border + 8px inset on either side, so 49px in from each edge): at 0:00 on the waveform's
   left edge, at the end on its right; --psv-f is the clock, 0–1. */
.psv__head {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(49px + (100% - 98px) * var(--psv-f, 0));
  /* The laptop mixer's playhead (mixer.css .mixer-playhead): a 1px line in --st-playhead, a small accent triangle on top. */
  width: 1px;
  background: var(--st-playhead);
  pointer-events: none;
}
/* A 32px invisible strip round the line to grab it with a finger (the icon and speaker columns keep their own taps). */
.psv__head::after { content: ''; position: absolute; inset: 0 -16px; pointer-events: auto; touch-action: none; }
/* Held: the triangle grows and the line thickens, as the seek bar's thumb does; the tooltip names the section and time. */
.psv__head::before { transition: scale 120ms ease-out; transform-origin: 50% 0; }
.psv__lanes[data-dragging] .psv__head::before { scale: 1.8; }
.psv__lanes[data-dragging] .psv__head { box-shadow: 0 0 0 1px var(--st-playhead); }
.psv__tip {
  position: absolute;
  top: 12px;
  left: 50%;
  translate: -50% 0;
  z-index: 1;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--st-text-strong);
  color: var(--st-bg);
  font: 600 11px/1.2 var(--st-font-mono);
  white-space: nowrap;
  pointer-events: none;
}
.psv__tip[hidden] { display: none; }
.psv__head::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -4px;
  width: 9px;
  height: 6px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: var(--st-accent);
}

.psv-lane {
  display: grid;
  /* Tight sides for wider waves (the user: "reduce the margin on left and right"); icon and speaker keep a 44px tap area. */
  grid-template-columns: 36px 1fr 36px;
  gap: 4px;
  height: 40px;
  transition: height 200ms ease, opacity 160ms ease;
}
/* The video Hidden (phone-song/video.ts sets the mode on the shell): taller lanes, not too tall. */
.st-shell[data-phone-video='hidden'] .psv__lanes { gap: 6px; }
.st-shell[data-phone-video='hidden'] .psv-lane { height: 60px; }
.st-shell[data-phone-video='hidden'] .psv-lane__glyph { width: 32px; height: 32px; }
/* The icon's and the speaker's 44px tap area reaches into the side padding and the gaps. */
.psv-lane__icon::after, .psv-lane__mute::after { content: ''; position: absolute; inset: -4px; }
.psv-lane__mute { position: relative; }
.psv-lane[data-dim] { opacity: 0.55; }

/* The bare stem icon, no tile and no ring (the user's call): tap solos, read from the lanes' colours; hold shows the name. */
.psv-lane__icon {
  position: relative;
  display: grid;
  place-items: center;
  align-self: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--psv-c);
  transition: color 160ms ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
.psv-lane__glyph { width: 28px; height: 28px; transition: width 200ms ease, height 200ms ease; }
.psv-cut { fill: var(--psv-tile, var(--st-surface)); }
.psv-lane__icon:focus { outline: none; }
.psv-lane__icon:focus-visible { outline: 2px solid var(--psv-c); outline-offset: 2px; }
.psv-lane[data-dim] .psv-lane__icon { color: var(--st-text-faint); }
.psv-lane__name {
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  color: #18181b;
  font: 600 12px/1.2 var(--st-font);
  white-space: nowrap;
  pointer-events: none;
}
.psv-lane__name[hidden] { display: none; }

/* The waveform card: the stem's colour all along, full up to the playhead and at 40% after; grey only when silent.
   Thin 2px bars, one every 4px (stems-view.ts sizes the count to the width), as the laptop mixer's lanes. */
.psv-lane__card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--st-line);
  border-radius: var(--st-radius-control);
  /* The stem's own colour behind its wave, as the laptop mixer's lanes (P676); fainter while silent. */
  background: color-mix(in srgb, var(--psv-c) 14%, var(--st-panel));
  touch-action: pan-y;
}
.psv-lane[data-silent] .psv-lane__card { background: color-mix(in srgb, var(--psv-c) 6%, var(--st-panel)); }
.psv-lane__wave { position: absolute; inset: 6px 8px; }
.psv-wave {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.psv-wave > i { width: 2px; min-height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--psv-c) 40%, transparent); transition: background-color 120ms ease; }
.psv-wave--played { clip-path: inset(0 calc(100% - var(--psv-at, 0%)) 0 0); }
.psv-wave--played > i { background: var(--psv-c); }
.psv-lane__vol {
  position: absolute;
  top: 3px;
  right: 6px;
  z-index: 1;
  color: var(--st-text-dim);
  font: 500 9px/1 var(--st-font-mono);
}
.psv-lane[data-silent] .psv-wave > i { background: var(--psv-grey); }
/* No real wave yet: the stem's stand-in, the same look loading, in line and splitting. Unfilled at 18%, the split's
   percent filled at 90%; with no percent (loading, in line) a soft shimmer sweeps across. The real wave fades in over it. */
.psv-stand { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; }
.psv-stand > i { width: 2px; min-height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--psv-c) 18%, transparent); }
.psv-stand--fill { clip-path: inset(0 calc(100% - var(--psv-fill, 0%)) 0 0); transition: clip-path 300ms ease-out; }
.psv-stand--fill > i { background: color-mix(in srgb, var(--psv-c) 90%, transparent); }
.psv:not([data-fill]) .psv-stand--fill { display: none; }
.psv-stand--out { animation: psv-out 200ms ease forwards; }
.psv-wave--in { animation: psv-in 200ms ease; }
@keyframes psv-in { from { opacity: 0; } }
@keyframes psv-out { to { opacity: 0; } }
.psv:not([data-fill]) .psv-lane[data-stand] .psv-lane__card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.06), transparent);
  transform: translateX(-100%);
  animation: psv-shimmer 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes psv-shimmer { to { transform: translateX(100%); } }
/* Loading, in line or splitting, nothing plays from the lanes yet: no playhead. */
.psv__lanes:has(.psv-lane[data-stand]) .psv__head { display: none; }

/* The speaker: muted, crossed out in the accent on an accent-soft tile. */
.psv-lane__mute {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--st-radius-control);
  background: transparent;
  /* Solid white while the stem plays (the user: "currently looks dim"); muted is the red crossed speaker below. */
  color: var(--st-text-strong);
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.psv-lane__speaker { width: 22px; height: 22px; stroke-width: 2.25; }
.psv-lane[data-muted] .psv-lane__mute { border-color: var(--st-accent); background: var(--st-accent-soft); color: var(--st-accent); }
.psv-lane__mute:disabled { opacity: 0.35; }
.psv-lane__mute[aria-expanded='true'] { border-color: var(--st-line-strong); }

/* A stem's popover under its speaker (stems-view.ts `openPop`): the Metronome card's look (phone-cues.css .ph-snd-*),
   its icon in the stem's colour. */
.psv-pop {
  --psv-tile: var(--st-surface-2);
  position: absolute;
  right: 16px;
  z-index: 5;
  width: min(300px, calc(100% - 32px));
  box-sizing: border-box;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
}
.psv-pop__icon { display: grid; flex: none; place-items: center; width: 28px; height: 28px; color: var(--psv-c); }
.psv-pop__glyph { width: 24px; height: 24px; }
/* The head's speaker (P676): the lane's speaker look; muted, the red crossed speaker. */
.psv-pop__mute {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--st-line-strong);
  border-radius: var(--st-radius-control);
  background: var(--st-surface);
  color: var(--st-text-strong);
}
.psv-pop__mute[aria-pressed='true'] { border-color: var(--st-accent); background: var(--st-accent-soft); color: var(--st-accent); }
.psv-pop .ph-snd-head__name { flex: 1; }
/* Volume with its percent, then the laptop's pan knob (mixer.css .mixer-track__pan) at the right. */
.psv-pop__levels { display: flex; align-items: flex-end; gap: 16px; padding-bottom: 4px; }
.psv-pop__volume { flex: 1; min-width: 0; }
.psv-pop__caption { display: flex; justify-content: space-between; color: var(--st-text-dim); font: 400 13px/16px var(--st-font); }
.psv-pop__pct { color: var(--st-text-strong); font: 600 12px/16px var(--st-font-mono); }
.psv-pop__volume .st-slider { --slider-color: var(--st-accent); }
.psv-pop__volume .st-slider__track { height: 28px; }

/* MIX (P676): one track like the Stems · Lead · Lyrics tabs (phone-song.css .ph-tabs), then Reset as an icon; small
   enough (12px words) that every preset and Reset fit a 375px phone without scrolling. Narrower still, it scrolls. */
/* Pinned to the foot of the scrolling tab, so the presets show however short the screen (Safari's toolbars); the lanes scroll under it. */
.psv-mix { position: sticky; bottom: 0; z-index: 2; margin: 0 -8px; padding-block: 8px; background: var(--st-bg); container-type: inline-size; }
.psv-mix__scroll {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.psv-mix__scroll::-webkit-scrollbar { display: none; }
.psv-mix__label { flex: none; color: var(--st-text-faint); font: 600 10px/1 var(--st-font); letter-spacing: 0.04em; }
.psv-mix__track {
  display: flex;
  flex: 1 0 auto;
  align-items: center;
  gap: 1px;
  height: 32px;
  box-sizing: border-box;
  padding: 1px;
  border: 1px solid var(--st-line);
  border-radius: 999px;
  background: var(--st-surface);
}
.psv-pill {
  /* Equal shares of whatever width is free; never narrower than its word (narrower rows scroll). */
  flex: 1 1 0;
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--st-text-dim);
  font: 500 11px/1 var(--st-font);
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease;
}
.psv-pill[aria-pressed='true'] { background: var(--st-text-strong); box-shadow: 0 1px 4px rgb(0 0 0 / 0.25); color: var(--st-bg); font-weight: 600; }
.psv-pill--reset { flex: none; min-width: 0; width: 32px; height: 32px; padding: 0; border: 1px solid var(--st-line); color: var(--st-text-dim); }
.psv-pill__icon { width: 16px; height: 16px; }
/* A big phone (430px Pro Max, Plus): taller segments and 12px words; the row still fits without scrolling. */
@container (min-width: 400px) {
  .psv-mix__scroll { gap: 6px; padding: 0 8px; }
  .psv-mix__track { height: 36px; padding: 2px; }
  .psv-pill { height: 30px; padding: 0 6px; font-size: 12px; }
  .psv-pill--reset { width: 36px; height: 36px; padding: 0; }
}
/* More room (a phone on its side, a narrow window): roomier still, capped so the segments don't stretch thin. */
@container (min-width: 520px) {
  .psv-mix__scroll { gap: 10px; padding: 0 12px; }
  .psv-mix__label { font-size: 11px; letter-spacing: 0.06em; }
  .psv-mix__track { max-width: 640px; height: 40px; padding: 3px; gap: 2px; }
  .psv-pill { height: 32px; padding: 0 14px; font-size: 13px; }
  .psv-pill--reset { width: 40px; height: 40px; padding: 0; }
  .psv-pill__icon { width: 18px; height: 18px; }
}

/* No stems yet. */
.psv-none {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border: 1px solid var(--st-line);
  border-radius: var(--st-radius-card);
  background: var(--st-surface);
  text-align: center;
}
.psv-none__title { margin: 0; color: var(--st-text); font: 600 15px/1.3 var(--st-font); }
.psv-none__line { margin: 0; color: var(--st-text-dim); font: 400 13px/1.4 var(--st-font); }
.psv-none__icon--dim { color: var(--st-text-dim); }
.psv-none__foot { margin: 0; color: var(--st-text-dim); font: 400 12px/1.4 var(--st-font); text-align: center; }
.psv-none__cloud { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--st-text-dim); font: 400 12px/1.4 var(--st-font); }
.psv-none__cloud::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--st-ok); }
.psv-none__cloud[data-tone='busy']::before { background: var(--st-warn); }

@media (prefers-reduced-motion: reduce) {
  .psv-lane,
  .psv__lanes,
  .psv-lane__icon,
  .psv-lane__glyph,
  .psv-wave > i,
  .psv-stand--fill,
  .psv-lane__mute { transition: none; }
  .psv-wave--in { animation: none; }
  .psv-stand--out { display: none; }
  .psv:not([data-fill]) .psv-lane[data-stand] .psv-lane__card::after { content: none; animation: none; }
}
/* A silent lane's stand-in is grey too, as its real wave will be (grey only when silent). */
.psv-lane[data-silent] .psv-stand > i { background: color-mix(in srgb, var(--psv-grey) 18%, transparent); }
/* The split's status row once stems land (phone-song/index.ts collapseAway): its height, then none, fading, taking the
   view's 10px gap with it, so the lanes glide up instead of jumping. */
.psv-gone { overflow: hidden; transition: height 200ms ease, opacity 200ms ease, margin-bottom 200ms ease; }
.psv-gone--on { height: 0 !important; opacity: 0; margin-bottom: -12px; }
@media (prefers-reduced-motion: reduce) { .psv-gone { display: none; } }
