/* Lightscline discovery UI — compact density with purple brand accent.
   Surfaces via color ladder + hairlines. Purple used sparingly (CTA, active, focus). */

:root {
  /* Brand */
  --ls-ink: #0a0614;
  --ls-brand: #7c3aed;
  --ls-brand-hover: #8b5cf6;
  --ls-brand-soft: #a78bfa;
  --ls-brand-dim: rgba(124, 58, 237, 0.14);
  --ls-brand-glow: rgba(124, 58, 237, 0.35);
  --ls-lav: #c4b5fd;
  --ls-muted: #b7a8c9;

  /* Product surface ladder (near-black + lift, not pure #000) */
  --chrome: #12101a;
  --chrome-elev: #17151f;
  --editor: #0e0c14;
  --surface: #16141e;
  --surface-hover: #1c1a26;
  --hover: rgba(255, 255, 255, 0.04);
  --hover-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --fg: #eeeef0;
  --fg-sec: rgba(238, 238, 240, 0.55);
  --fg-ter: rgba(238, 238, 240, 0.35);
  --plot-bg: #0a0614;

  --star: #f5c542;
  --teal: #22d3ee;
  --danger: #ef4444;

  --font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --demo-pad: 24px;
  --radius-window: 10px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --control-h: 28px;
  --icon: 15px;
  --trans: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease), opacity 0.15s var(--ease);
}

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

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ls-muted);
  background:
    radial-gradient(900px 480px at 18% -8%, rgba(108, 16, 184, 0.28), transparent 60%),
    radial-gradient(700px 420px at 92% 8%, rgba(124, 58, 237, 0.16), transparent 55%),
    var(--ls-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.icon {
  width: var(--icon);
  height: var(--icon);
  flex-shrink: 0;
  display: block;
}

/* —— Marketing —— */
.site-frame {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.site-copy {
  max-width: 540px;
}

.site-copy .eyebrow {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ls-lav);
  font-weight: 500;
}

.site-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  line-height: 1.1;
  font-weight: 600;
  color: #f4ecff;
  letter-spacing: -0.03em;
}

.site-copy .lede {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ls-muted);
  max-width: 42ch;
}

.stage-wrap {
  margin: 0;
  width: 100%;
}

.stage-wrap figcaption {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(183, 168, 201, 0.65);
}

/* —— Stage —— */
.stage {
  position: relative;
  width: 100%;
  height: min(860px, 82vh);
  min-height: 720px;
  border-radius: 6px;
  overflow: hidden;
  background: #12081f;
  box-shadow: inset 0 0 0 1px rgba(196, 181, 253, 0.12);
}

.stage-wallpaper {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(160deg, #160a2a 0%, #0a0614 50%, #140828 100%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(124, 58, 237, 0.22), transparent),
    url("https://lightscline.com/signal-terrain.png") center 40% / cover no-repeat;
  opacity: 0.8;
}

.stage-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(10, 6, 20, 0.35), rgba(10, 6, 20, 0.55)),
    linear-gradient(90deg, rgba(10, 6, 20, 0.4), transparent 28%, transparent 72%, rgba(10, 6, 20, 0.4));
  pointer-events: none;
}

/* —— Window —— */
.window {
  position: absolute;
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-window);
  background: var(--chrome);
  color: var(--fg);
  font-family: var(--font-ui);
  box-shadow:
    0 0 0 1px rgba(196, 181, 253, 0.14),
    0 24px 64px rgba(0, 0, 0, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.35);
  will-change: left, top, width, height;
}

.window.is-dragging,
.window.is-resizing {
  user-select: none;
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.35),
    0 28px 72px rgba(0, 0, 0, 0.55);
}

.desk {
  /* JS owns left/top/width/height after init */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.window.enter-anim {
  animation: window-enter 0.2s var(--ease) both;
}

@keyframes window-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* —— Titlebar —— */
.titlebar {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--chrome);
  user-select: none;
  cursor: grab;
  touch-action: none;
}

.titlebar:active,
.window.is-dragging .titlebar {
  cursor: grabbing;
}

.dots {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 54px;
}

.dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s var(--ease);
}

.window:hover .dots span:nth-child(1) {
  background: #ff5f57;
}
.window:hover .dots span:nth-child(2) {
  background: #febc2e;
}
.window:hover .dots span:nth-child(3) {
  background: #28c840;
}

.title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-sec);
  letter-spacing: -0.01em;
  pointer-events: none;
}

.titlebar-actions {
  width: 96px;
  display: flex;
  justify-content: flex-end;
}

.ghost-btn {
  opacity: 0;
  background: transparent;
  border: 0;
  color: var(--fg-sec);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--trans);
}

.window:hover .ghost-btn {
  opacity: 1;
}

.ghost-btn:hover {
  background: var(--hover-strong);
  color: var(--fg);
}

.desk-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--editor);
}

/* —— Resize —— */
[data-resize-handle] {
  position: absolute;
  z-index: 30;
  touch-action: none;
}
.resize-n { inset-inline: 10px; top: 0; height: 6px; cursor: ns-resize; }
.resize-s { inset-inline: 10px; bottom: 0; height: 6px; cursor: ns-resize; }
.resize-e { inset-block: 10px; right: 0; width: 6px; cursor: ew-resize; }
.resize-w { inset-block: 10px; left: 0; width: 6px; cursor: ew-resize; }
.resize-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.resize-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.resize-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.resize-se { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; }

.demo-reset {
  position: absolute;
  right: calc(var(--demo-pad) + 6px);
  bottom: calc(var(--demo-pad) + 6px);
  z-index: 40;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(23, 21, 31, 0.92);
  color: var(--fg-sec);
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: var(--trans);
}

.demo-reset[hidden] {
  display: none !important;
}

.demo-reset:hover {
  color: var(--ls-brand-soft);
  border-color: rgba(124, 58, 237, 0.45);
  background: var(--chrome-elev);
}

/* —— App bar —— */
.app-bar {
  flex-shrink: 0;
  height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--chrome-elev);
}

.app-bar-left,
.app-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: var(--control-h);
}

.app-bar-right {
  justify-content: flex-end;
  gap: 2px;
}

.app-bar-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* One toolbar rhythm: Add Panel / Help / Cluster / icon buttons = --control-h */
.btn-primary {
  height: var(--control-h);
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--ls-brand);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn-primary:hover {
  background: var(--ls-brand-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  height: var(--control-h);
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-sec);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--trans);
}

.btn-ghost:hover {
  background: var(--hover-strong);
  color: var(--fg);
}

.btn-ghost:active {
  background: var(--hover);
}

.version-pill {
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(124, 58, 237, 0.32);
  background: var(--ls-brand-dim);
  color: var(--ls-brand-soft);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-sizing: border-box;
}

.version-pill em {
  font-style: normal;
  opacity: 0.7;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: var(--control-h);
  height: var(--control-h);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-ter);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
  transition: var(--trans);
}

.icon-btn:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

.icon-btn:active {
  background: var(--hover);
}

.icon-btn.sm {
  width: 24px;
  height: 24px;
}

/* —— Workspace —— */
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  width: 208px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--chrome-elev);
  padding: 12px 10px 14px;
  gap: 18px;
  overflow: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 2px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-ter);
  font-weight: 500;
}

.sidebar-head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-sheet-close {
  display: none;
}

.sidebar-open-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.section-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-ter);
  font-weight: 500;
  margin-bottom: 6px;
  padding: 0 6px;
}

.label-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.label-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px 0 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-sec);
  font: inherit;
  font-size: 13px;
  font-weight: 450;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
  transition: var(--trans);
}

.label-item .accent {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: transparent;
  flex-shrink: 0;
  margin-left: 4px;
  transition: background 0.15s var(--ease);
}

.label-item .star {
  color: var(--star);
  width: 13px;
  height: 13px;
}

.label-item[data-accent="star"] .accent { background: var(--star); }
.label-item[data-accent="impulse"] .accent { background: var(--ls-brand-soft); }
.label-item[data-accent="c0"] .accent,
.label-item[data-accent="c1"] .accent,
.label-item[data-accent="c2"] .accent,
.label-item[data-accent="c3"] .accent,
.label-item[data-accent="c4"] .accent { background: var(--teal); }

.label-item:hover {
  background: var(--hover);
  color: var(--fg);
}

.label-item.is-active {
  background: var(--ls-brand-dim);
  color: var(--fg);
}

.label-item.is-active .accent {
  background: var(--ls-brand-soft);
}

.label-item[data-accent="star"].is-active .accent {
  background: var(--star);
}

.video-section {
  margin-top: auto;
  padding: 10px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(124, 58, 237, 0.2);
  background: rgba(124, 58, 237, 0.06);
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  padding: 2px 2px 10px;
  border-radius: var(--r-sm);
  transition: var(--trans);
}

.section-toggle:hover {
  color: var(--ls-brand-soft);
}

.section-toggle .film {
  color: var(--ls-brand-soft);
  opacity: 0.9;
}

.section-toggle .chev {
  margin-left: auto;
  color: var(--fg-ter);
  transition: transform 0.15s var(--ease);
}

.section-toggle[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}

.video-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-fields[hidden] {
  display: none;
}

/* —— Controls + Radix-style Select —— */
.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-sec);
  font-weight: 500;
  letter-spacing: -0.01em;
  min-width: 0;
}

.field-label {
  color: var(--fg-ter);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.video-fields .field {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
}

.rs-input {
  height: var(--control-h);
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 0 9px;
  outline: none;
  transition: var(--trans);
}

.rs-input:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

.rs-input:focus {
  border-color: rgba(124, 58, 237, 0.55);
  box-shadow: 0 0 0 2px var(--ls-brand-dim);
}

/* Trigger — Radix SelectTrigger look */
.rs-select {
  position: relative;
  display: inline-flex;
  min-width: 0;
  width: 100%;
}

.video-fields .rs-select {
  width: 100%;
}

.panel-tools .rs-select {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
}

.panel-tools .rs-trigger {
  height: 26px;
  padding: 0 6px 0 8px;
  gap: 4px;
  font-size: 11.5px;
}

.panel-tools .rs-select[data-role="transform"] {
  width: 68px;
}

.panel-tools .rs-select[data-role="band"] {
  /* Fit "2001,2500" / "4501,5000" without ellipsis in 3-col */
  width: 96px;
}

.rs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: var(--control-h);
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  outline: none;
  transition: var(--trans);
}

.rs-trigger:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.rs-trigger:focus-visible,
.rs-select.is-open .rs-trigger {
  border-color: rgba(124, 58, 237, 0.55);
  box-shadow: 0 0 0 2px var(--ls-brand-dim);
}

.rs-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rs-chevron {
  width: 12px;
  height: 12px;
  color: var(--fg-ter);
  flex-shrink: 0;
  transition: transform 0.15s var(--ease), color 0.15s var(--ease);
}

.rs-select.is-open .rs-chevron {
  transform: rotate(180deg);
  color: var(--ls-brand-soft);
}

/* Content — Radix SelectContent / DropdownMenu (density matches trigger) */
.rs-content {
  margin: 0;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1824;
  color: var(--fg);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
  animation: rs-in 0.1s var(--ease) both;
  transform-origin: top center;
  max-height: min(220px, 40vh);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  box-sizing: border-box;
}

.rs-content[hidden] {
  display: none !important;
}

@keyframes rs-in {
  from {
    opacity: 0;
    transform: translateY(-3px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.rs-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--control-h);
  height: var(--control-h);
  padding: 0 8px 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: background 0.1s var(--ease);
}

.rs-item:hover,
.rs-item:focus-visible {
  background: var(--hover-strong);
}

.rs-item[data-state="checked"] {
  background: var(--ls-brand-dim);
  color: var(--fg);
}

.rs-item[data-state="checked"]:hover,
.rs-item[data-state="checked"]:focus-visible {
  background: rgba(124, 58, 237, 0.22);
}

.rs-item-indicator {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ls-brand-soft);
}

.rs-item[data-state="unchecked"] .rs-check {
  opacity: 0;
}

.rs-item[data-state="checked"] .rs-check {
  opacity: 1;
}

.rs-check {
  width: 12px;
  height: 12px;
}

.rs-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Panel selects — menu matches the 26px / 11.5px trigger */
.rs-content.rs-sm {
  padding: 2px;
  border-radius: 5px;
}

.rs-content.rs-sm .rs-item {
  min-height: 26px;
  height: 26px;
  padding: 0 6px 0 4px;
  gap: 4px;
  font-size: 11.5px;
  border-radius: 3px;
}

.rs-content.rs-sm .rs-item-indicator {
  width: 12px;
  height: 12px;
}

.rs-content.rs-sm .rs-check {
  width: 11px;
  height: 11px;
}

/* —— Panels —— */
.panel-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 14px;
  background: var(--editor);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  align-content: start;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  /* forwards (not both): avoid opacity:0 during staggered delay after remount */
  animation: panel-in 0.2s var(--ease) forwards;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  container-type: inline-size;
  container-name: ls-panel;
}

.panel:nth-child(1) { animation-delay: 0.03s; }
.panel:nth-child(2) { animation-delay: 0.06s; }
.panel:nth-child(3) { animation-delay: 0.09s; }
.panel:nth-child(4) { animation-delay: 0.12s; }
.panel:nth-child(5) { animation-delay: 0.15s; }
.panel:nth-child(6) { animation-delay: 0.18s; }

.panel:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.panel.is-active {
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.12);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 0 10px;
  min-height: 22px;
}

.panel-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ls-brand-soft);
  font-weight: 600;
}

.panel-close {
  color: var(--fg-ter);
}

.panel-close:hover {
  color: #fecaca !important;
  background: rgba(239, 68, 68, 0.15) !important;
}

.panel-tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 2px;
  min-width: 0;
  overflow: hidden;
}

.panel-tools .field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

.panel-tools .field-label {
  font-size: 11px;
  flex-shrink: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.panel-tools .rs-input.index {
  width: 40px;
  min-width: 36px;
  height: 26px;
  text-align: center;
  padding: 0 4px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.3);
}

.panel-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 4px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-ter);
  font-variant-numeric: tabular-nums;
}

/* Tight panels: drop labels so Transform / Band / Index stay one row */
@container ls-panel (max-width: 380px) {
  .panel-tools {
    gap: 5px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .panel-tools .field-label {
    display: none;
  }

  .panel-tools .field {
    gap: 4px;
  }

  .panel-tools .rs-select[data-role="transform"] {
    width: 62px;
  }

  .panel-tools .rs-select[data-role="band"] {
    width: 96px;
  }

  .panel-tools .rs-trigger {
    padding: 0 4px 0 6px;
    gap: 2px;
    font-size: 11px;
  }

  .panel-tools .rs-input.index {
    width: 36px;
    min-width: 34px;
    padding: 0 2px;
  }
}

.copy-status {
  width: 22px;
  height: 22px;
}

.plot-wrap {
  flex: 1;
  min-height: 160px;
  margin: 0 6px 6px;
  border: 1px solid rgba(196, 181, 253, 0.08);
  border-radius: var(--r-md);
  background: var(--plot-bg);
  position: relative;
  overflow: hidden;
  /* Dense 3-col desktop: plot-like aspect without pancake frames */
  aspect-ratio: 5 / 3;
  max-height: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.plot-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity 0.12s var(--ease);
}

.plot-wrap canvas.is-switching {
  opacity: 0.4;
}

/* Image stack for MBARI spectrogram / plot frames (app.js) */
.plot-frames {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #0a0614;
  overflow: hidden;
}

.plot-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.plot-frame.is-front {
  opacity: 1;
  z-index: 1;
}

/* —— Sheet / narrow (window-driven) —— */
.window.is-sheet .sidebar-open-btn { display: grid; }
.window.is-sheet .btn-ghost { display: none; }
.window.is-sheet .app-bar-center { display: none; }
.window.is-sheet .app-bar { grid-template-columns: 1fr auto; }
.window.is-sheet .workspace { position: relative; }

.window.is-sheet .sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(280px, 84%);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  border-right: 1px solid var(--border-strong);
  box-shadow: none;
}

.window.is-sheet .sidebar-overlay {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(6, 4, 14, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.window.is-sheet.sidebar-open .sidebar {
  transform: translateX(0);
  pointer-events: auto;
  box-shadow: 16px 0 48px rgba(0, 0, 0, 0.5);
}

.window.is-sheet.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.window.is-sheet .sidebar-sheet-close { display: grid; }
.window.is-sheet #sidebarCollapseBtn { display: none; }

/* Sheet: labels usually don't fit in half-width panels */
.window.is-sheet .panel-tools .field-label {
  display: none;
}

.window.is-sheet .panel-tools {
  gap: 6px;
}

.window.is-sheet .panel-scroll {
  padding: 6px;
}

.window.is-sheet .panel-grid {
  gap: 8px;
}

/* Embed / mobile: maximize usable panel width inside the stage */
html.ls-embed .stage {
  border-radius: 0;
}

@media (max-width: 768px) {
  html.ls-embed .window.is-sheet .panel-scroll,
  html.ls-embed .panel-scroll {
    padding: 4px;
  }

  html.ls-embed .window.is-sheet .panel-grid,
  html.ls-embed .panel-grid {
    gap: 6px;
  }
}

/* Keep 2-col until phone-sized window */
.window.is-narrow .panel-grid {
  grid-template-columns: 1fr;
}

.window.is-narrow .panel-tools .field-label {
  display: none;
}

.window.is-narrow .panel-tools {
  gap: 6px;
}

.window.is-narrow .plot-wrap {
  min-height: 200px;
  aspect-ratio: auto;
}

/* —— Responsive (viewport / phone page chrome) —— */
@media (max-width: 720px) {
  .site-frame {
    padding: 20px 14px 36px;
    gap: 16px;
  }

  .site-copy h1 {
    font-size: 1.65rem;
    letter-spacing: -0.03em;
  }

  .site-copy .lede {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .stage {
    min-height: 560px;
    height: min(720px, 82vh);
    border-radius: 12px;
  }

  .app-bar {
    grid-template-columns: 1fr auto;
    height: 44px;
    padding: 0 10px;
  }

  .app-bar-center {
    display: none;
  }

  .btn-ghost {
    display: none;
  }

  .sidebar-open-btn {
    display: grid;
  }

  .workspace {
    position: relative;
  }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(288px, 88%);
    max-height: none;
    z-index: 50;
    border-right: 1px solid var(--border-strong);
    border-bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    padding: 14px 12px 16px;
  }

  .sidebar-overlay {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(6, 4, 14, 0.58);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
  }

  .window.sidebar-open .sidebar {
    transform: translateX(0);
    pointer-events: auto;
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.5);
  }

  .window.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-sheet-close {
    display: grid;
  }

  #sidebarCollapseBtn {
    display: none;
  }

  .panel-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .panel-scroll {
    padding: 4px;
  }

  .panel-tools {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .panel-tools .field-label {
    display: none;
  }

  .note {
    font-size: 10px;
    letter-spacing: 0.06em;
  }
}

@media (max-width: 500px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .version-pill {
    display: none;
  }

  .titlebar .title {
    font-size: 11px;
  }

  .panel {
    min-height: 260px;
  }

  .plot-wrap {
    min-height: 200px;
  }

  .label-item {
    height: 34px;
  }
}

/* —— Autoplay tour cursor + captions —— */
.tour-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ls-lav);
  opacity: 0.85;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}

.tour-hint.is-paused {
  color: #f5c542;
  opacity: 1;
}

/* Top-layer via popover=manual — escapes all page stacking contexts.
   Override UA popover centering; we position with transform. */
.demo-cursor {
  position: fixed;
  inset: unset;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  width: 30px;
  height: 36px;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
  transition: opacity 0.2s var(--ease);
  color-scheme: only light;
}

.demo-cursor:popover-open,
.demo-cursor.is-active {
  opacity: 1;
  display: block;
}

.demo-cursor.is-clicking .demo-cursor-svg {
  transform: scale(0.92);
  transform-origin: 2px 3px;
}

.demo-cursor-svg {
  display: block;
  position: relative;
  z-index: 1;
  transition: transform 0.07s cubic-bezier(0.22, 1, 0.36, 1);
}

.demo-cursor-ring {
  position: absolute;
  left: -2px;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(124, 58, 237, 0.85);
  background: rgba(124, 58, 237, 0.18);
  opacity: 0;
  transform: translate(-35%, -35%) scale(0.35);
  pointer-events: none;
}

.demo-cursor.is-ring .demo-cursor-ring {
  animation: cursor-ring 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cursor-ring {
  0% {
    opacity: 0.9;
    transform: translate(-35%, -35%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-35%, -35%) scale(1.75);
  }
}

.demo-caption {
  position: fixed;
  inset: unset;
  margin: 0;
  max-width: 240px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #f4f0ff;
  background: rgba(18, 12, 32, 0.88);
  border: 1px solid rgba(167, 139, 250, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.16s var(--ease);
}

.demo-caption:popover-open,
.demo-caption.is-visible {
  opacity: 1;
  display: block;
}

body.tour-playing .window.desk {
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.18),
    0 28px 80px rgba(0, 0, 0, 0.45),
    0 0 60px rgba(124, 58, 237, 0.12);
}

/* Mobile: keep the tour — slightly smaller cursor, still top-layer */
@media (max-width: 720px) {
  .demo-cursor {
    width: 26px;
    height: 31px;
  }

  .demo-cursor-svg {
    width: 26px;
    height: 31px;
  }

  .demo-caption {
    max-width: min(200px, 70vw);
    font-size: 10px;
    padding: 5px 8px;
  }

  .tour-hint {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-cursor,
  .demo-caption {
    transition: none !important;
  }
}
