/* ═══════════════════════════════════════════════════════════
   Flux – Crimson Dark Studio Theme
   Layout / module map: see ../DESIGN.md
   Reuse: .right-block + __head, .left-section-sim, .curves-tabs, :root tokens
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  /* Surfaces – very deep warm-dark */
  --bg:           #09090b;
  --panel-bg:     #111113;
  --panel-elev:   #18181b;
  --panel-hover:  #1f1f22;
  --panel-active: #242428;

  /* Borders */
  --border:       rgba(255, 255, 255, 0.06);
  --border-mid:   rgba(255, 255, 255, 0.09);
  --border-hi:    rgba(255, 255, 255, 0.12);

  /* Text */
  --text:         #ece8f0;
  --text-dim:     #9490a0;
  --muted:        #5e5a6e;
  --dim:          #3a3648;

  /* Muted Sage accent palette */
  --sage-primary: #5a9e82;
  --sage-dim:     #5a9e8228;
  --sage-border:  #5a9e8238;
  --sage-dark:    #3c7d62;
  --sage-light:   #80b89e;

  /* Accent aliases used by existing UI components */
  --accent:       var(--sage-primary);
  --accent-hi:    var(--sage-light);
  --accent-soft:  var(--sage-dim);
  --accent-glow:  var(--sage-border);
  --accent-mid:   var(--sage-border);

  /* Secondary accent – warm amber */
  --accent-2:     #f0994a;
  --accent-2-soft: rgba(240, 153, 74, 0.12);

  /* Semantic */
  --orange:       #f0894a;
  --orange-dim:   rgba(240, 137, 74, 0.13);
  --green:        #3ecf82;
  --green-dim:    rgba(62, 207, 130, 0.12);
  --red:          #e8384b;
  --red-dim:      rgba(232, 56, 75, 0.14);
  --purple:       #c084fc;
  --purple-dim:   rgba(192, 132, 252, 0.12);
  --blue:         #60a8fa;
  --blue-dim:     rgba(96, 168, 250, 0.12);
  --teal:         #2dd4bf;
  --teal-dim:     rgba(45, 212, 191, 0.12);

  /* Control chrome tuned to Muted Sage accents */
  --ctl-track:      rgba(255, 255, 255, 0.09);
  --ctl-track-dim:  rgba(255, 255, 255, 0.05);
  --ctl-fill:       var(--sage-dim);
  --ctl-fill-hi:    var(--sage-border);
  --ctl-thumb:      var(--sage-primary);
  --ctl-thumb-hi:   var(--sage-light);
  --ctl-thumb-ring: rgba(255, 255, 255, 0.12);

  /* Sizing */
  --radius:       5px;
  --radius-md:    7px;
  --radius-lg:    9px;
  --radius-xl:    13px;

  /* Typography */
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Layout */
  --panel-w:      288px;
  --right-w:      310px;
  --header-h:     44px;
}

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

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── App grid ── */
#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr var(--right-w);
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: #09090b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  gap: 0.75rem;
  position: relative;
  z-index: 10;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.app-header__export {
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.app-brand { display: flex; align-items: center; gap: 0.5rem; }

.flux-mark {
  display: flex;
  color: var(--accent);
  flex-shrink: 0;
}

.app-brand__name {
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #e8e8ed;
  line-height: 1;
}

.app-brand__line {
  width: 1px;
  height: 0.8rem;
  background: rgba(255,255,255,0.12);
}

.app-brand__sub {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ══════════════════════════════════════
   PANELS
══════════════════════════════════════ */
.panel {
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#panel-right {
  border-left: 1px solid var(--border);
  border-right: none;
  background: var(--panel-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Scrollable bodies */
.panel-left__body,
.panel-right__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
/* Tabbed right column: keep tab bar fixed; scroll inside the active tab */
.panel-right__body:has(.right-stack--tabbed) {
  overflow: hidden;
}

.panel-left__body { padding: 0; }

.left-section-sim { border-top: 1px solid var(--border); }

/* ── Right panel blocks ── */
.right-stack {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* Browser-style tabs: one full-height page per mode */
.right-stack--tabbed {
  overflow: hidden;
}
.right-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem 0.4rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  z-index: 1;
}
button.right-tabs__tab {
  font: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.3rem 0.38rem;
  margin: 0;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
button.right-tabs__tab:hover {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
}
button.right-tabs__tab[aria-selected="true"] {
  color: #e8e8ed;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}
button.right-tabs__tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft, rgba(120, 180, 200, 0.35));
}
/* [hidden] alone is overridden by our display:flex; must win or all tabs stay visible. */
.right-tab-panel[hidden] {
  display: none !important;
}
.right-tab-panel:not([hidden]) {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Fill tab: outliner, keyframes, forces, life each own a scroll region */
.right-tab-panel .right-block--outliner {
  flex: 1 1 0;
  min-height: 0;
  border-bottom: none;
  overflow: hidden;
}
.right-tab-panel .outliner-list {
  max-height: none;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}
.right-tab-panel .right-block--keyframes {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  border-bottom: none;
  overflow: hidden;
}
.right-tab-panel .forces-panel,
.right-tab-panel .right-block--forces {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.right-tab-panel .force-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}
.right-tab-panel .right-block--life {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.right-tab-panel .curves-tabs {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.right-tab-panel .curves-tab-panel.curves-tab-panel--active {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.right-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.right-block--forces {
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.right-block--outliner {
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.outliner-toolbar {
  display: flex;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.14);
}

.outliner-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.45rem 0.55rem 0.55rem;
  max-height: 13rem;
  overflow-y: auto;
}

.outliner-row {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) minmax(75px, 1fr);
  align-items: center;
  gap: 0.35rem;
}

.outliner-row__pick {
  justify-content: flex-start;
  min-width: 0;
}

.outliner-row__name.timeline-meta__inp {
  width: 100%;
  min-width: 0;
}

.outliner-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.28rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.outliner-item--active {
  border-color: var(--sage-border);
  box-shadow: inset 0 0 0 1px var(--sage-border);
  background: var(--sage-dim);
}

.outliner-item__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.outliner-item__pick {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  padding: 0;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outliner-item__meta {
  font-size: 0.66rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* —— Keyframes panel —— */
.right-block--keyframes {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}

.right-block--keyframes .keyframes-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.keyframes-scope {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sage, #7a9);
  padding: 0.1rem 0.2rem;
}

.keyframes-empty {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 0.2rem 0;
}

.keyframes-group {
  border: 1px solid var(--border);
  border-radius: var(--radius, 4px);
  background: rgba(0,0,0,0.12);
  overflow: visible;
}

.keyframes-group__summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.4rem 0.45rem;
  background: rgba(255,255,255,0.03);
}

.keyframes-group__summary::-webkit-details-marker {
  display: none;
}

.keyframes-group__body {
  padding: 0.3rem 0.35rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.keyframes-channel {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.45rem;
}

.keyframes-channel:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.keyframes-channel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.keyframes-channel__label {
  flex: 1 1 8rem;
  font-size: 0.7rem;
  min-width: 0;
}

.keyframes-channel__meta {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.keyframes-channel__track-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

.keyframes-subhint {
  font-size: 0.6rem;
  color: var(--muted);
  margin: 0;
}

.keyframes-select,
.keyframes-select--sm {
  font-size: 0.65rem;
  max-width: 10rem;
  background: var(--panel-elev, #1a1d24);
  color: var(--text);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 0.1rem 0.25rem;
}

.keyframes-keys {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.64rem;
}

.keyframes-keys__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.1fr auto;
  gap: 0.25rem;
  align-items: center;
}

.keyframes-keys__row--head {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.1rem 0;
}

.keyframes-keys__val-snap {
  font-size: 0.63rem;
  color: var(--text-dim);
  line-height: 1.25;
  padding: 0.1rem 0.15rem;
  min-width: 0;
}

.keyframes-keys__inp {
  width: 100%;
  min-width: 0;
  font-size: 0.64rem;
  font-family: var(--font-mono);
  background: var(--panel-elev, #1a1d24);
  border: 1px solid var(--border-mid);
  color: var(--text);
  border-radius: 3px;
  padding: 0.1rem 0.25rem;
}

.keyframes-force {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.keyframes-force__title {
  font-size: 0.64rem;
  color: var(--text-dim);
  font-weight: 600;
}

.right-block--life {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.right-block__head {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  padding: 0.55rem 0.7rem 0.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
}

.right-block__title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--text-dim);
}

.right-block__eyebrow {
  font-size: 0.63rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.right-block__eyebrow kbd {
  display: inline-block;
  font-size: 0.9em;
  font-family: var(--font-mono);
  padding: 0.08em 0.4em;
  border: 1px solid var(--border-mid);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: rgba(0,0,0,0.2);
  color: var(--text-dim);
}

.right-block__hint {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  padding: 0.4rem 0.7rem 0.55rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
}

/* ══════════════════════════════════════
   FORCES PANEL (right)
══════════════════════════════════════ */
.forces-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.forces-panel__head {
  display: flex;
  flex-direction: column;
  gap: 0.06rem;
  padding: 0.55rem 0.7rem 0.4rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.forces-panel__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.forces-panel__eyebrow {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

/* ══════════════════════════════════════
   LIFE CURVES TABS
══════════════════════════════════════ */
.curves-tabs {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.curves-tabs__bar {
  display: flex;
  gap: 0.2rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

button.curves-tab {
  font: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  flex: 1;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

button.curves-tab:hover {
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
}

button.curves-tab--active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}
/* Color sub-tab: dot when this ramp has shot keyframes and another life tab is active */
button.curves-tab--shot-keys:not(.curves-tab--active) {
  padding-right: 0.8rem;
}
button.curves-tab--shot-keys:not(.curves-tab--active)::after {
  content: '';
  position: absolute;
  right: 0.3rem;
  top: 50%;
  margin-top: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sage, #6b9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
button.curves-tab--shot-keys {
  position: relative;
}

.curves-tab-panel {
  display: block;
  padding: 0.5rem 0.55rem 0.6rem;
  min-height: 0;
  flex: 0 0 auto;
}

.curves-tab-panel[hidden] { display: none; }

.life-curve__shot-head {
  display: flex;
  justify-content: flex-end;
  margin: 0.1rem 0 0.35rem;
}

.life-curve__shot-banner {
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.62rem;
  line-height: 1.35;
  border-radius: var(--radius);
  border: 1px solid rgba(90, 140, 115, 0.45);
  background: rgba(60, 90, 75, 0.25);
  color: var(--text-dim, #a8a8b0);
}

.life-curve__shot-banner--at-key {
  background: rgba(100, 180, 150, 0.1);
  border-color: var(--sage-border, #3d5c4a);
  color: var(--text, #e8e8ed);
}

/* ══════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════ */
.panel-left__body,
.panel-right__body,
.preset-dd__menu,
.modal-inner {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.panel-left__body::-webkit-scrollbar,
.panel-right__body::-webkit-scrollbar,
.preset-dd__menu::-webkit-scrollbar,
.modal-inner::-webkit-scrollbar { width: 3px; }

.panel-left__body::-webkit-scrollbar-track,
.panel-right__body::-webkit-scrollbar-track,
.preset-dd__menu::-webkit-scrollbar-track,
.modal-inner::-webkit-scrollbar-track { background: transparent; }

.panel-left__body::-webkit-scrollbar-thumb,
.panel-right__body::-webkit-scrollbar-thumb,
.preset-dd__menu::-webkit-scrollbar-thumb,
.modal-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

.panel-left__body::-webkit-scrollbar-thumb:hover,
.panel-right__body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ══════════════════════════════════════
   SECTION CHROME (left collapsibles)
══════════════════════════════════════ */
.prop-section {
  border-bottom: 1px solid var(--border);
}

.prop-section summary,
.prop-section__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  height: 34px;
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  list-style: none;
  /* has a left accent bar */
  background: rgba(0,0,0,0.25);
  border-left: 2px solid transparent;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.prop-section summary::before {
  content: '▶';
  font-size: 0.48rem;
  color: var(--accent);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.prop-section[open] summary::before { transform: rotate(90deg); }

.prop-section[open] > summary {
  border-left-color: var(--accent);
  color: var(--text);
}

.prop-section summary:hover,
.prop-section__head:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-left-color: rgba(255, 255, 255, 0.12);
}

.prop-section__body { padding: 0.3rem 0 0.45rem; }

/* Left column: Simulation + grouped <details> */
.sim-properties.prop-section--stack {
  border: none;
  display: flex;
  flex-direction: column;
}

.sim-section-heading {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.45rem 0.75rem 0.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.prop-subsection {
  border-bottom: 1px solid var(--border);
}

.prop-subsection > summary.prop-subsection__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.12s, color 0.12s;
}

.prop-subsection > summary.prop-subsection__summary::-webkit-details-marker {
  display: none;
}

.prop-subsection > summary.prop-subsection__summary::before {
  content: '▸';
  font-size: 0.55rem;
  color: var(--muted);
  transition: transform 0.15s;
}

.prop-subsection[open] > summary.prop-subsection__summary::before {
  transform: rotate(90deg);
}

.prop-subsection > summary.prop-subsection__summary:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.prop-subsection__body {
  padding: 0.12rem 0 0.35rem;
}

.sim-properties > .prop-hint {
  margin: 0;
  border-top: 1px solid var(--border);
}

.prop-subhint {
  margin: 0 0.75rem 0.35rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dim, #889);
  max-width: 32rem;
}

/* ══════════════════════════════════════
   PROPERTY ROWS
══════════════════════════════════════ */
.prop-row {
  display: grid;
  /* Wider label column so "Emitter radius" etc. never clips */
  grid-template-columns: 48% 1fr;
  align-items: center;
  min-height: 34px;
  padding: 0 0.75rem;
  gap: 0.55rem;
  transition: background 0.12s;
}

.prop-row--hidden {
  display: none !important;
}

/* Keyframe diamond (Blender-style) + optional third column */
.prop-row--with-kf {
  grid-template-columns: 1.1rem minmax(0, 45%) 1fr;
  align-items: center;
  gap: 0.4rem 0.5rem;
}
.prop-kf-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}
.prop-kf {
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  margin: 0;
  line-height: 1;
  font-size: 0.55rem;
  color: var(--text-dim, #88a0a0);
  background: var(--panel-elev, #1a1d24);
  border: 1px solid var(--border-mid);
  border-radius: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.prop-kf:hover {
  color: var(--sage, #6b9);
  border-color: var(--sage-border, #3d5c4a);
}
.prop-kf--on {
  color: var(--sage, #7fc);
  background: rgba(100, 180, 150, 0.12);
  border-color: var(--sage-border, #3d5c4a);
}
.prop-vec-emit {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.15rem;
}
.prop-vec-emit__label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
}
.prop-vec-emit__row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 0.3rem 0.35rem;
  align-items: center;
}
/* Match .prop-row number fields (vec3 is not a child of .prop-row, so it needs its own block) */
.prop-vec-emit__row input[type="number"] {
  min-width: 0;
  height: 28px;
  width: 100%;
  padding: 0 0.45rem;
  font-size: 0.78rem;
  font: inherit;
  font-family: var(--font-mono);
  text-align: right;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
}
.prop-vec-emit__row input[type="number"]:hover {
  border-color: var(--border-hi);
  background: var(--panel-hover);
}
.prop-vec-emit__row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-active);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ══════════════════════════════════════
   VELOCITY DIRECTION PICKER (checkboxes)
══════════════════════════════════════ */
.prop-vel-dir {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.15rem;
}
.prop-vel-dir__label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}
.prop-vel-dir__checks {
  display: flex;
  gap: 1rem;
}
.prop-vel-dir__cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.prop-vel-dir__check-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.04em;
}
.prop-vel-dir__check-label:hover {
  color: var(--text);
}
.prop-vel-dir__invert-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.74rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.prop-vel-dir__invert-label:hover {
  color: var(--text-dim);
}

.prop-row.prop-row--check {
  grid-template-columns: 1fr;
  padding: 0.4rem 0.75rem;
}
.prop-row--check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  white-space: normal;
}
.prop-row--check input[type="checkbox"] {
  flex-shrink: 0;
}

.prop-row--adv-limits {
  margin-top: 0.18rem;
}

.prop-spawn-help {
  padding: 0.2rem 0.75rem 0.45rem;
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1.42;
}

.prop-spawn-help--adv {
  color: var(--text-dim);
  padding-top: 0;
}

.prop-row:hover {
  background: rgba(255,255,255,0.022);
}

.prop-row label {
  font-size: 0.8rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  font-weight: 500;
  line-height: 1.2;
  /* ensure label is vertically centered nicely */
  padding: 0.1rem 0;
}

/* ── Plain number input (non-slider rows) — must not match slider or seed controls ── */
.prop-row:not(.prop-row--slider):not(.prop-row--seed) > input[type="number"] {
  height: 28px;
  width: 100%;
  padding: 0 0.5rem;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: right;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s;
}

.prop-row:not(.prop-row--slider):not(.prop-row--seed) > input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-active);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ══════════════════════════════════════
   CUSTOM SELECT (Shape dropdown etc.)
══════════════════════════════════════ */
.prop-row select {
  height: 28px;
  width: 100%;
  padding: 0 2rem 0 0.55rem;   /* right pad to make room for chevron */
  background: var(--panel-elev)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8799' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E")
    no-repeat right 0.55rem center;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, background-color 0.14s, box-shadow 0.14s;
}

.prop-row select:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: var(--panel-hover);
}

.prop-row select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--panel-active);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ══════════════════════════════════════
   SLIDERS
══════════════════════════════════════ */
.prop-row--slider {
  /* Give slider rows a bit more vertical room */
  min-height: 38px;
  padding: 0.25rem 0.75rem;
  /* Slider rows: label on top left, controls below on next line */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
}

.prop-row--slider label {
  /* Label sits on its own line, full width */
  font-size: 0.77rem;
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  padding: 0;
}

.prop-row__control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

/* ── Range input ── */
.prop-row--slider input[type="range"] {
  flex: 1 1 0;
  min-width: 0;
  height: 20px;        /* tall hit-target */
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: box-shadow 0.12s;
}

/* Webkit track — neutral fill, no brand red on the rail */
.prop-row--slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    var(--ctl-fill) 0%,
    var(--ctl-fill) var(--pct, 0%),
    var(--ctl-track) var(--pct, 0%),
    var(--ctl-track) 100%
  );
}

.prop-row--slider input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: var(--ctl-track);
}

.prop-row--slider input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--ctl-fill);
}

/* Thumb: neutral; accent only on focus-visible */
.prop-row--slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ctl-thumb);
  border: 1px solid var(--ctl-thumb-ring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  margin-top: -4.5px;
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.12s ease, background 0.12s;
}

.prop-row--slider input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.05);
  background: var(--ctl-thumb-hi);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 1px 4px rgba(0, 0, 0, 0.4);
}

.prop-row--slider input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.02);
  cursor: grabbing;
}

.prop-row--slider input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ctl-thumb);
  border: 1px solid var(--ctl-thumb-ring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: transform 0.1s, background 0.12s, box-shadow 0.12s;
}

.prop-row--slider input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.05);
  background: var(--ctl-thumb-hi);
}

.prop-row--slider input[type="range"]:focus {
  outline: none;
}

.prop-row--slider input[type="range"]:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-radius: 4px;
}

/* Number field next to slider */
.prop-row--slider input[type="number"] {
  flex: 0 0 3.8rem;
  width: 3.8rem;
  min-width: 3.8rem;
  height: 26px;
  padding: 0 0.38rem;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.prop-row--slider input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.prop-hint {
  padding: 0.4rem 0.75rem 0.55rem;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  margin-top: 0.15rem;
}

/* ── Seed row ── */
.prop-row--seed {
  /* Override grid layout from .prop-row — use flex instead */
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0.28rem 0.75rem;
  gap: 0.55rem;
}

.prop-row--seed > label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
  cursor: default;
}

/* Flex container holding: [Randomize btn] [seed number] */
.seed-ctrl {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

/* Primary Randomize button */
.btn--seed-rand {
  flex: 1;
  gap: 0.3rem;
  padding: 0.32rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius);
  white-space: nowrap;
  /* inherits btn--primary gradient */
  transition: all 0.16s ease;
}

.btn--seed-rand svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.btn--seed-rand:hover svg {
  transform: rotate(180deg);
}

/* Flash animation on click */
@keyframes seedFlash {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  60%  { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
}

.btn--seed-rand--flash {
  animation: seedFlash 0.3s ease-out forwards;
}

/* Compact seed number input */
.seed-ctrl input[type="number"] {
  flex: 0 0 5.5rem;
  width: 5.5rem;
  height: 26px;
  padding: 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  text-align: right;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, color 0.14s, box-shadow 0.14s;
}

.seed-ctrl input[type="number"]:hover {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.seed-ctrl input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* hide number input spin arrows — globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] { -moz-appearance: textfield; }

/* ══════════════════════════════════════
   LIBRARY / PRESET SECTION
══════════════════════════════════════ */
.left-section {
  padding: 0.65rem 0.6rem 0.5rem;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.left-section__head {
  padding: 0 0.05rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.04rem;
}

/* Preset: current label + “load preset” (no default built-in) */
.preset-block__head {
  padding: 0 0.05rem 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.preset-block__title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.preset-block__current-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.4rem;
  margin-bottom: 0.4rem;
}

.preset-block__ic {
  display: flex;
  align-items: center;
  color: var(--accent);
  flex-shrink: 0;
  width: 1.1rem;
  justify-content: center;
}
.preset-block__ic:empty { display: none; }

.preset-block__ic svg { display: block; width: 20px; height: 20px; }

.preset-block__name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-block__actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.preset-block__load { width: 100%; justify-content: center; }

/* Load preset modal (card grid + I/O) */
.load-preset-modal { max-width: 42rem; }
.load-preset-modal__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.2rem;
}
.load-preset-modal__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.load-preset-modal__io-dd { position: relative; flex-shrink: 0; }
.load-preset-modal__io-dd summary { list-style: none; }
.load-preset-modal__io-dd summary::-webkit-details-marker { display: none; }
.load-preset-modal__io-trigger {
  list-style: none;
  user-select: none;
}
.load-preset-modal__io-chev {
  display: inline-flex;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.load-preset-modal__io-chev svg { width: 14px; height: 14px; }
.load-preset-modal__io-dd[open] .load-preset-modal__io-chev { transform: rotate(180deg); }
.load-preset-modal__io-file {
  position: absolute;
  width: 0; height: 0;
  opacity: 0;
  pointer-events: none;
}
.load-preset-modal__io-menu {
  position: absolute;
  z-index: 5;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 10.5rem;
  padding: 0.2rem;
  background: #12141a;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
.load-preset-modal__io-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.42rem 0.55rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm, 3px);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.1s;
}
.load-preset-modal__io-item:hover,
.load-preset-modal__io-item:focus {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}
.load-preset-modal__hint {
  margin: 0 0 0.8rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}
.load-preset-modal__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.2rem, 1fr));
  gap: 0.55rem;
  max-height: 22rem;
  overflow-y: auto;
  margin: 0 0 0.5rem;
  padding: 0.1rem 0.05rem 0.25rem 0.05rem;
}
.load-preset-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.load-preset-card:hover,
.load-preset-card:focus {
  border-color: var(--border-mid);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  outline: none;
}
.load-preset-card:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.load-preset-card--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--sage-border);
}
.load-preset-card__art {
  position: relative;
  width: 100%;
  aspect-ratio: 20 / 11;
  background: #1a1d25;
  overflow: hidden;
}
.load-preset-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  vertical-align: top;
}
.load-preset-card__badge {
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
  padding: 0.2rem 0.35rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.6);
  color: #a8e0ff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.load-preset-card__body {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem 0.5rem;
}
.load-preset-card__ic { display: flex; flex-shrink: 0; color: var(--accent); }
.load-preset-card__ic svg { display: block; width: 18px; height: 18px; }
.load-preset-card__name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.load-preset-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
  margin: 0 -0.1rem 0 0;
}

/* ── Preset dropdown (legacy, unused) ── */
.preset-dd {
  position: relative;
  z-index: 3;
}

.preset-dd__trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.48rem 0.6rem;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.preset-dd__trigger:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--panel-hover);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.preset-dd.is-open .preset-dd__trigger {
  border-color: var(--accent);
  background: var(--panel-hover);
  box-shadow: 0 0 0 1px var(--border-hi);
}

.preset-dd__icon {
  display: flex;
  align-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.preset-dd__icon svg,
.preset-dd__opt-icon svg { display: block; }

.preset-dd__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-dd__chev {
  display: flex;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.preset-dd.is-open .preset-dd__chev { transform: rotate(180deg); }

.preset-dd__menu[hidden] { display: none; }

.preset-dd__menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0; right: 0;
  padding: 0.2rem;
  background: #100e14;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  box-shadow:
    0 12px 40px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  max-height: 13rem;
  overflow-y: auto;
  z-index: 20;
  animation: ddOpen 0.13s ease;
}

@keyframes ddOpen {
  from { opacity: 0; transform: translateY(-5px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.preset-dd__option {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  width: 100%;
  padding: 0.42rem 0.52rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.11s, color 0.11s;
}

.preset-dd__option:hover,
.preset-dd__option:focus {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.preset-dd__option.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 600;
}

.preset-dd__opt-icon { display: flex; color: var(--accent); flex-shrink: 0; }
.preset-dd__opt-label { flex: 1; min-width: 0; }

/* Preset I/O */
.preset-io {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0 0;
}

.preset-io__file {
  position: absolute;
  width: 0; height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  padding: 0.42rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn svg { flex-shrink: 0; width: 15px; height: 15px; }

.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Primary — Muted Sage */
.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--sage-dark) 100%);
  color: #f3fbf7;
  border: 1px solid var(--sage-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.btn--primary:hover {
  background: linear-gradient(180deg, var(--sage-light) 0%, var(--accent) 100%);
  border-color: var(--sage-light);
}

.btn--primary:active {
  background: var(--sage-dark);
  border-color: var(--accent);
}

/* Ghost */
.btn--ghost {
  background: rgba(255,255,255,0.03);
  border-color: var(--sage-border);
  color: var(--sage-light);
}

.btn--ghost:hover {
  border-color: var(--accent);
  background: var(--sage-dim);
  color: var(--text);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--small {
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
}

.btn--full { width: 100%; }

/* Icon button (×) */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.13s;
}

.btn-icon:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ══════════════════════════════════════
   VIEWPORT
══════════════════════════════════════ */
#viewport-wrap {
  position: relative;
  min-height: 0;
  background: #060607;
  overflow: hidden;
}

#viewport-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── HUD ── */
/* Viewport custom context menu (canvas only) */
.vp-ctx {
  position: fixed;
  z-index: 1000;
  min-width: 11rem;
  padding: 0.2rem 0;
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.vp-ctx__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.75rem;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.vp-ctx__item:hover,
.vp-ctx__item:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.view-hud {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

/* Shared layout for viewport HUD (help + status / telemetry) */
.view-hud--stack {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: min(32rem, 88vw);
}

.view-hud--tl {
  top: 0.6rem;
  left: 0.6rem;
}

/* Optional: keep bottom anchor above timeline (unused by default) */
.view-hud--bl {
  bottom: 2.85rem;
  left: 0.6rem;
}

.vp-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.38);
  user-select: none;
  pointer-events: none;
}

.vp-status__mono {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.48);
  letter-spacing: 0.02em;
}

.vp-status__bridge {
  color: rgba(140, 200, 180, 0.72);
}

.vp-status__state {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.vp-status__perf {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vp-status__perf--good {
  color: #84d8a5;
}

.vp-status__perf--stressed {
  color: #e7c86e;
}

.vp-status__perf--overloaded {
  color: #ec8b8b;
}

/* ══════════════════════════════════════
   TIMELINE
══════════════════════════════════════ */
.timeline-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.38rem 0.6rem;
  background: linear-gradient(180deg,
    rgba(7, 6, 10, 0) 0%,
    rgba(7, 6, 10, 0.9) 30%,
    rgba(7, 6, 10, 0.98) 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: auto;
}

.timeline-play { min-width: 2.2rem; }

.timeline-jump {
  padding-left: 0.32rem;
  padding-right: 0.32rem;
  min-width: 2rem;
  font-size: 0.7rem;
  color: var(--sage-light);
}

.timeline-infinite {
  min-width: 2.1rem;
  padding-left: 0.32rem;
  padding-right: 0.32rem;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sage-light);
  transition: all 0.14s;
}

.timeline-infinite:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--sage-dim);
}

.timeline-infinite--on {
  background: var(--sage-dim);
  border-color: var(--sage-border);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--sage-border);
}

.timeline-frame-group {
  display: inline-flex;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  flex-shrink: 0;
  min-width: 4rem;
}

.timeline-frame-cur {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.timeline-frame-cur--warn { color: var(--orange); }

.timeline-frame-slash {
  font-size: 0.68rem;
  color: var(--dim);
}

.timeline-frame-end {
  font-size: 0.73rem;
  color: var(--muted);
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.timeline-meta__field {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  font-size: 0.65rem;
  color: var(--dim);
  font-family: var(--font-mono);
}

.timeline-meta__lbl { flex-shrink: 0; }

.timeline-meta__inp {
  width: 3rem;
  padding: 0.12rem 0.26rem;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  transition: border-color 0.14s;
}

.timeline-meta__inp:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.timeline-scrub-wrap {
  flex: 1 1 120px;
  min-width: 60px;
  display: flex;
  align-items: center;
}

/* Timeline scrub slider */
input.timeline-scrub[type="range"] {
  width: 100%;
  height: 18px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input.timeline-scrub[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--pct, 0%),
    rgba(255,255,255,0.1) var(--pct, 0%),
    rgba(255,255,255,0.1) 100%
  );
}

input.timeline-scrub[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
}

input.timeline-scrub[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--accent);
}

input.timeline-scrub[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.4);
  margin-top: -4px;
  cursor: grab;
  transition: transform 0.1s, box-shadow 0.12s;
}

input.timeline-scrub[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 1px 4px rgba(0, 0, 0, 0.4);
}

input.timeline-scrub[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.04);
  cursor: grabbing;
}

input.timeline-scrub[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

input.timeline-scrub[type="range"]:focus { outline: none; }

.timeline-hint {
  font-size: 0.63rem;
  color: var(--dim);
  flex-shrink: 0;
  max-width: 8rem;
  text-align: right;
  margin-left: auto;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════
   FORCE ROWS (right panel)
══════════════════════════════════════ */
.force-list { display: flex; flex-direction: column; }

.force-row { border-bottom: 1px solid var(--border); }

.force-row summary {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0 0.6rem;
  min-height: 33px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: transparent;
  transition: background 0.11s;
}

.force-row summary:hover { background: rgba(255, 255, 255, 0.04); }

.force-row--disabled .force-badge {
  opacity: 0.65;
}

.force-row summary::before {
  content: '▶';
  font-size: 0.5rem;
  color: var(--accent);
  transition: transform 0.14s ease;
  flex-shrink: 0;
}

.force-row[open] summary::before { transform: rotate(90deg); }

.force-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}

.force-eye:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.force-eye:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sim on/off: affects the solver, not just the handle */
.force-pwr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--green, #3ecf82);
  cursor: pointer;
  transition: all 0.12s;
}

.force-pwr:hover {
  color: #5ee8a0;
  background: rgba(255,255,255,0.07);
}

.force-pwr--off {
  color: var(--dim);
  opacity: 0.7;
}
.force-pwr--off:hover {
  color: var(--muted);
  opacity: 1;
}

.force-pwr svg { display: block; }

.force-eye svg { display: block; }
.force-eye--off { color: var(--dim); opacity: 0.55; }
.force-eye--off:hover { opacity: 1; color: var(--muted); }

/* Force type badges: neutral chip, type color = dot only */
.force-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 8px;
  border-radius: 99px;
  flex-shrink: 0;
  border: 1px solid var(--border-mid);
  background: var(--panel-elev);
  color: var(--text-dim);
}

.force-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.force-badge__dot--gravity    { background: #6eb6ff; }
.force-badge__dot--wind       { background: #4ade80; }
.force-badge__dot--turbulence { background: #f87171; }
.force-badge__dot--attractor  { background: #f0a060; }
.force-badge__dot--vortex     { background: #c4a3ff; }
.force-badge__dot--drag       { background: #b1bac8; }
.force-badge__dot--collider   { background: #facc15; }
.force-badge__dot--curlWind   { background: #2dd4bf; }
.force-badge__dot--animatedWind { background: #22c55e; }
.force-badge__dot--linearImpulse { background: #fb7185; }

.force-row__fields { padding: 0 0 0.3rem; }
.force-row__hidden { display: none !important; }

/* Forces add bar: label + select + Add + short hint (same chevron as sim Shape) */
.forces-add {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.42rem 0.5rem 0.45rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.14);
}

.forces-add__label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
  line-height: 1.2;
}

.forces-add__row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
}

.forces-type-dd,
.forces-add select {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 1.75rem 0 0.5rem; /* chevron on the right */
  background: var(--panel-elev)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8799' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E")
    no-repeat right 0.5rem center;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.14s, background-color 0.14s, box-shadow 0.14s;
}

.forces-type-dd:hover,
.forces-add select:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: var(--panel-hover);
}
.forces-type-dd:focus,
.forces-add select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--panel-active);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.forces-type-dd:disabled,
.forces-add select:disabled { opacity: 0.5; cursor: not-allowed; }

.forces-add__btn { flex-shrink: 0; white-space: nowrap; }

.forces-type-hint {
  margin: 0;
  font-size: 0.64rem;
  line-height: 1.4;
  color: var(--text-dim);
  opacity: 0.95;
}

.forces-type-hint--empty {
  display: none;
}

.forces-apply {
  padding: 0.32rem 0.5rem 0.4rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
}

.forces-apply__btn {
  color: var(--text-dim);
  border-color: var(--border-mid);
  font-size: 0.7rem;
  font-weight: 600;
}

.forces-apply__btn:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

/* ══════════════════════════════════════
   CURVE EDITOR CANVAS
══════════════════════════════════════ */
.curve-editor {
  display: block;
  width: 100%;
  height: 122px;
  max-width: 100%;
  background: linear-gradient(180deg, #0e0e10 0%, #0a0a0c 100%);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  cursor: crosshair;
  touch-action: none;
  vertical-align: top;
}

/* Color-over-life: ramp + dock (native color picker opens from the well, not a screen corner) */
.curve-panel-curve--color {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}
.curve-ramp-frame {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.curve-ramp-frame__ruler {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 0.1rem;
  user-select: none;
}
.curve-ramp-frame__ruler span:nth-child(2) {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
  font-size: 0.6rem;
}
.curve-editor--color {
  height: 86px;
  min-height: 64px;
  background: #0a0a0c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 10px rgba(0, 0, 0, 0.45);
  cursor: default;
  border-radius: 8px;
}
.curve-ramp-dock {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.1rem 0.05rem 0.15rem;
  min-width: 0;
}
.curve-ramp-dock__hint {
  margin: 0;
  font-size: 0.64rem;
  line-height: 1.4;
  color: var(--muted);
}
.curve-ramp-dock__row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
}
.curve-ramp-dock__swatch {
  flex: 0 0 3.1rem;
  min-width: 2.75rem;
  align-self: stretch;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-elev, #1a1d24);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
input[type='color'].curve-ramp__color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 100%;
  min-height: 2.5rem;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: none;
  border-radius: var(--radius);
}
input[type='color'].curve-ramp__color-input::-webkit-color-swatch-wrapper {
  padding: 3px;
}
input[type='color'].curve-ramp__color-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
input[type='color'].curve-ramp__color-input::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}
.curve-ramp-dock__meta {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
}
.curve-ramp-dock__k-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.curve-ramp-dock__hex {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text, #e8e8ed);
  letter-spacing: 0.02em;
  word-break: break-all;
}

/* Editable list of color stops (age 0–1) — two-way with ramp */
.color-stops {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  margin-top: 0.1rem;
}
.color-stops__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}
button.color-stops__shot-key--on {
  color: var(--sage, #6b9);
  border-color: var(--sage-border, #3d5c4a);
  background: rgba(100, 180, 150, 0.1);
}
/* Timeline shot keys: summary strip above the stops table */
.color-stops__shot-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 0.62rem;
  line-height: 1.4;
  margin: 0.1rem 0 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  background: rgba(60, 90, 75, 0.25);
  border: 1px solid rgba(90, 140, 115, 0.45);
  color: var(--text-dim, #a8a8b0);
}
.color-stops__shot-banner--at-key {
  background: rgba(100, 180, 150, 0.1);
  border-color: var(--sage-border, #3d5c4a);
  color: var(--text, #e8e8ed);
}
.color-stops__shot-banner__icon {
  flex-shrink: 0;
  font-size: 0.72rem;
  line-height: 1.15;
  color: var(--sage, #6b9);
}
.color-stops__shot-banner__text {
  min-width: 0;
}
.color-stops__count {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.color-stops__note {
  margin: 0;
  font-size: 0.6rem;
  line-height: 1.4;
  color: var(--muted);
}
.color-stops__table-wrap {
  max-height: 14rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
}
.color-stops__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}
.color-stops__table th {
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.32rem 0.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.color-stops__th-num { width: 1.5rem; text-align: center; }
.color-stops__th-t { min-width: 3.2rem; }
.color-stops__th-kf { width: 1.6rem; text-align: center; }
.color-stops__th-del { width: 1.8rem; }
.color-stops__table td {
  padding: 0.22rem 0.3rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.color-stops__table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}
.color-stops__num {
  text-align: center;
  font-family: var(--font-mono, monospace);
  color: var(--muted);
  font-size: 0.68rem;
}
.color-stops__inp-t {
  width: 100%;
  min-width: 0;
  max-width: 4.2rem;
  height: 26px;
  padding: 0 0.25rem;
  font-size: 0.7rem;
  font-family: var(--font-mono, monospace);
  text-align: right;
  background: var(--panel-elev, #1a1d24);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
}
.color-stops__inp-t:read-only {
  opacity: 0.65;
  cursor: not-allowed;
}
.color-stops__color-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
input[type='color'].color-stops__inp-color {
  -webkit-appearance: none;
  appearance: none;
  width: 1.9rem;
  height: 1.5rem;
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  background: none;
}
input[type='color'].color-stops__inp-color::-webkit-color-swatch-wrapper {
  padding: 1px;
}
input[type='color'].color-stops__inp-color::-webkit-color-swatch,
input[type='color'].color-stops__inp-color::-moz-color-swatch {
  border: none;
  border-radius: 2px;
}
.color-stops__hex-mini {
  font-family: var(--font-mono, monospace);
  font-size: 0.62rem;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-stops__kf-na {
  text-align: center;
  color: var(--muted);
  user-select: none;
}
.color-stops__btn-x {
  min-width: 1.4rem;
  padding: 0.12rem 0.28rem;
  line-height: 1;
  font-size: 0.9rem;
}

.curve-colorbar {
  height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-mid);
  margin: 0 0 0.5rem;
}

/* ══════════════════════════════════════
   EXPORT MODAL
══════════════════════════════════════ */
#export-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  padding: 1rem;
  animation: mFade 0.16s ease;
}

@keyframes mFade { from { opacity: 0; } to { opacity: 1; } }

.modal-inner {
  background: #121214;
  border: 1px solid var(--border-mid);
  border-top: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.4rem 1.2rem;
  min-width: 330px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 28px 70px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: mSlide 0.18s ease;
}

@keyframes mSlide {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-inner h2 {
  margin: 0 0 1rem;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.confirm-modal__text {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.confirm-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.error-msg {
  color: #ff8090;
  font-size: 0.73rem;
  margin: 0.3rem 0 0;
  padding: 0.32rem 0.5rem;
  background: var(--red-dim);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 100, 100, 0.2);
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem 0.6rem;
  margin: 0.3rem 0 0.55rem;
  align-items: center;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.77rem;
  transition: color 0.11s;
}

.check-row label:hover { color: var(--text); }

/* Modal form */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  margin-bottom: 0.5rem;
}

.form-row label {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-weight: 500;
}

.form-row input[type="number"],
.form-row select,
.form-row input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--panel-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.form-row input[type="number"]:focus,
.form-row select:focus,
.form-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Section text */
.section-title {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0;
}

.section-hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.35;
}

/* ══════════════════════════════════════
   FORCE PROP ROWS (inside force items)
══════════════════════════════════════ */
.fprop-row {
  display: grid;
  grid-template-columns: 44% 1fr;
  align-items: center;
  min-height: 25px;
  padding: 0.05rem 0.55rem 0.05rem 1.38rem;
  gap: 0.38rem;
  transition: background 0.1s;
}

.fprop-row:hover { background: rgba(255, 255, 255, 0.03); }

.fprop-row label {
  font-size: 0.73rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.fprop-row input[type="number"] {
  height: 21px;
  width: 100%;
  padding: 0 0.34rem;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.13s, box-shadow 0.13s;
}

.fprop-row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.fprop-row select {
  height: 21px;
  width: 100%;
  padding: 0 1.4rem 0 0.34rem;
  background: var(--panel-elev)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8799' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E")
    no-repeat right 0.35rem center;
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 0.73rem;
  appearance: none;
  -webkit-appearance: none;
}

.fprop-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Keyframe ◆ column: must override 2-col .fprop-row (rules above use same specificity; source order wins). */
.fprop-row.fprop-row--with-kf {
  grid-template-columns: 1.1rem minmax(0, 38%) 1fr;
  align-items: center;
  gap: 0.38rem 0.45rem;
}

/* Position etc.: one ◆ per axis in a single row [◆x][x][◆y][y][◆z][z] */
.fprop-vec__inputs.fprop-vec__inputs--with-kf {
  grid-template-columns: 1.05rem 1fr 1.05rem 1fr 1.05rem 1fr;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

.fprop-vec__inputs.fprop-vec__inputs--with-kf .force-kf-wrap,
.fprop-vec__inputs.fprop-vec__inputs--with-kf .prop-kf-wrap {
  align-self: center;
}

/* Vec3 inputs */
.fprop-vec {
  padding: 0 0.5rem 0 1.33rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 0.1rem;
}

.fprop-vec__label {
  font-size: 0.71rem;
  color: var(--dim);
  padding: 2px 0 2px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.fprop-vec__inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 3px;
}

.fprop-vec__inputs input[type="number"] {
  height: 21px;
  width: 100%;
  padding: 0 0.3rem;
  background: var(--panel-elev);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-align: right;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.13s;
}

.fprop-vec__inputs input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ── Legacy button ── */
button.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(180deg, var(--accent) 0%, var(--sage-dark) 100%);
  color: #f3fbf7;
  border: 1px solid var(--sage-border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.4rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  transition: all 0.16s ease;
}

button.btn-primary:hover {
  background: linear-gradient(180deg, var(--sage-light) 0%, var(--accent) 100%);
  border-color: var(--sage-light);
}

button.btn-primary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

/* ══════════════════════════════════════
   CHECKBOX — themed (native controls look white on some OS themes)
══════════════════════════════════════ */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  border-radius: 3px;
  border: 1px solid var(--border-mid);
  background: var(--panel-elev);
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
input[type="checkbox"]:hover:not(:checked) {
  border-color: var(--border-hi);
  background: var(--panel-hover);
}
input[type="checkbox"]:checked:hover {
  background-color: var(--accent-hi);
  border-color: var(--accent-hi);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2L5.2 8.8l4.3-4.3' fill='none' stroke='%230a0a0c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.7rem 0.7rem;
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}
input[type="checkbox"]:checked {
  /* SVG tick — do not use ::after on input (not supported in Firefox) */
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2L5.2 8.8l4.3-4.3' fill='none' stroke='%230a0a0c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.7rem 0.7rem;
  border-color: var(--accent-hi);
}
input[type="checkbox"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ══════════════════════════════════════
   OPTION ELEMENTS
══════════════════════════════════════ */
option {
  background: #120f17;
  color: var(--text);
}

/* ══════════════════════════════════════
   SELECTION
══════════════════════════════════════ */
::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 960px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto auto 1fr;
  }
  .panel, #panel-right {
    border: none;
    border-bottom: 1px solid var(--border);
  }
  #panel-right { grid-row: 4; }
}
