@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;700&display=swap');

:root {
  --bg-0: #07171f;
  --bg-1: #0d2730;
  --bg-2: #173944;
  --panel: rgba(8, 22, 29, 0.88);
  --panel-strong: rgba(8, 22, 29, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.06);
  --border: rgba(160, 211, 225, 0.16);
  --border-strong: rgba(160, 211, 225, 0.26);
  --text: #eef5f3;
  --text-soft: rgba(238, 245, 243, 0.72);
  --text-muted: rgba(238, 245, 243, 0.52);
  --accent: #7ed8b5;
  --accent-strong: #d9ff73;
  --danger: #ff8575;
  --warn: #ffd37b;
  --control-panel-width: 19.25rem;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --sans: "Space Grotesk", "Trebuchet MS", sans-serif;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(126, 216, 181, 0.17), transparent 28%),
    radial-gradient(circle at top right, rgba(217, 255, 115, 0.1), transparent 22%),
    linear-gradient(140deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
  color: var(--text);
  font-family: var(--sans);
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: var(--mono);
}

.demo-app {
  height: 100dvh;
  min-height: 100dvh;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: hidden;
}

.demo-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  flex: 0 0 auto;
  min-height: 0;
}

.brand-block {
  min-width: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.3vw, 2.2rem);
  line-height: 1;
}

.header-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 0.05rem;
}

.header-actions > * {
  flex: 0 0 auto;
}

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.45rem;
  padding: 0.58rem 0.82rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
  box-shadow: var(--shadow);
}

.dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 0.22rem rgba(255, 255, 255, 0.07);
}

.dot.green {
  background: var(--accent);
  box-shadow: 0 0 0 0.22rem rgba(126, 216, 181, 0.18);
}

.dot.yellow {
  background: var(--warn);
  box-shadow: 0 0 0 0.22rem rgba(255, 211, 123, 0.18);
}

.dot.red {
  background: var(--danger);
  box-shadow: 0 0 0 0.22rem rgba(255, 133, 117, 0.18);
}

.button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 0.95rem;
  padding: 0.68rem 0.86rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.1);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.button-primary {
  background: linear-gradient(135deg, rgba(126, 216, 181, 0.24), rgba(217, 255, 115, 0.16));
  border-color: rgba(217, 255, 115, 0.22);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.03);
}

.button-upload {
  position: relative;
  overflow: hidden;
}

.button-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.demo-layout {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(17.8rem, var(--control-panel-width), 42rem);
  gap: 0.8rem;
  align-items: stretch;
}

.stage-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.8rem;
}

.stage-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  border-radius: 1.35rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(5, 14, 18, 0.32);
  box-shadow: var(--shadow);
}

.stage-viewport {
  position: absolute;
  inset: 0;
}

.viewport-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  pointer-events: none;
}

.placeholder-panel {
  max-width: 26rem;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.1rem;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  text-align: center;
}

.placeholder-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.placeholder-copy {
  color: var(--text-soft);
  line-height: 1.45;
}

.hud-card {
  z-index: 3;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(4, 15, 20, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hud-card {
  position: absolute;
  padding: 0.82rem 0.95rem;
  min-width: 15rem;
}

.hud-top-left {
  top: 1rem;
  left: 1rem;
}

.model-info-card {
  position: static;
  z-index: auto;
  min-width: 0;
  max-width: none;
  width: 100%;
}

.log-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.log-panel-card {
  min-width: 0;
  padding: 0.72rem 0.82rem 0.78rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(4, 15, 20, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.playback-bar {
  display: block;
  padding: 0.72rem 0.82rem 0.78rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(4, 15, 20, 0.76);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hud-label {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud-value {
  margin-top: 0.2rem;
  font-size: 1.02rem;
  font-weight: 700;
}

.hud-meta {
  margin-top: 0.22rem;
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.35;
}

.playback-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
}

.playback-time-block {
  min-width: 7rem;
}

.playback-time {
  margin-top: 0.18rem;
  font-size: 0.98rem;
  font-weight: 700;
  font-family: var(--mono);
}

.playback-timeline-block {
  min-width: 0;
}

.playback-range {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.playback-range-label {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: nowrap;
}

.playback-scrubber {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  background: transparent;
}

.playback-scrubber:disabled {
  cursor: default;
  opacity: 0.42;
}

.playback-scrubber::-webkit-slider-runnable-track {
  height: 0.46rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.playback-scrubber::-moz-range-track {
  height: 0.46rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.playback-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.95rem;
  height: 0.95rem;
  margin-top: -0.245rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 255, 115, 0.4);
  background: linear-gradient(135deg, rgba(126, 216, 181, 0.95), rgba(217, 255, 115, 0.92));
  box-shadow: 0 0 0 0.18rem rgba(217, 255, 115, 0.12);
}

.playback-scrubber::-moz-range-thumb {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 255, 115, 0.4);
  background: linear-gradient(135deg, rgba(126, 216, 181, 0.95), rgba(217, 255, 115, 0.92));
  box-shadow: 0 0 0 0.18rem rgba(217, 255, 115, 0.12);
}

.playback-scrubber:disabled::-webkit-slider-thumb,
.playback-scrubber:disabled::-moz-range-thumb {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.22);
  box-shadow: none;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button-transport {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.48rem 0.72rem 0.48rem 0.62rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.button-transport::before {
  content: '';
  width: 1.35rem;
  height: 1.35rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1;
  box-shadow: inset 0 0 0 0.08rem rgba(255, 255, 255, 0.02);
}

.button-transport[data-mode="reset"]::before {
  content: '↺';
}

.button-transport[data-mode="play"]::before {
  content: '▶';
  padding-left: 0.08rem;
}

.button-transport[data-mode="pause"]::before {
  content: '||';
  font-size: 0.62rem;
  letter-spacing: -0.12em;
}

.button-transport[data-mode="replay"]::before {
  content: '↻';
}

.button-transport[data-mode="stop"]::before {
  content: '■';
  font-size: 0.66rem;
}

.button-transport[data-mode="download"]::before {
  content: '↓';
}

.button-transport[data-mode="camera"]::before {
  content: '◎';
}

.button-transport:hover:not(:disabled)::before {
  border-color: rgba(217, 255, 115, 0.34);
  background: rgba(217, 255, 115, 0.14);
}

.button-primary.button-transport::before {
  border-color: rgba(217, 255, 115, 0.28);
  background: rgba(217, 255, 115, 0.18);
}

.control-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 0.7rem;
  padding-right: 0.18rem;
  scrollbar-gutter: stable;
  position: relative;
  justify-self: stretch;
}

.control-panel.is-resizing {
  user-select: none;
}

.panel-resize-handle {
  position: absolute;
  top: 0.35rem;
  bottom: 0.35rem;
  left: -0.78rem;
  width: 0.92rem;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  z-index: 8;
}

.panel-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0.18rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(217, 255, 115, 0.12), rgba(126, 216, 181, 0.36), rgba(217, 255, 115, 0.12));
  box-shadow: 0 0 0 1px rgba(160, 211, 225, 0.12);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.panel-resize-handle:hover::before,
.control-panel.is-resizing .panel-resize-handle::before {
  background: linear-gradient(180deg, rgba(217, 255, 115, 0.26), rgba(126, 216, 181, 0.72), rgba(217, 255, 115, 0.26));
  box-shadow: 0 0 0 1px rgba(160, 211, 225, 0.3);
}

.sidebar-shell {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.global-model-panel {
  flex: 0 0 auto;
  padding: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: rgba(8, 22, 29, 0.76);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.model-panel-foldout {
  margin: 0.55rem 0 0;
}

.model-panel-foldout > summary {
  justify-content: flex-end;
  padding: 0.28rem 0.1rem 0;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.model-panel-foldout > .panel-foldout-body {
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.38rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: rgba(8, 22, 29, 0.76);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel-tab {
  border: 1px solid transparent;
  border-radius: 0.86rem;
  background: transparent;
  color: var(--text-soft);
  padding: 0.58rem 0.62rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.panel-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.panel-tab.is-active,
.panel-tab[aria-selected="true"] {
  border-color: rgba(217, 255, 115, 0.2);
  background: linear-gradient(135deg, rgba(126, 216, 181, 0.18), rgba(217, 255, 115, 0.08));
  color: var(--text);
}

.panel-tab-stack {
  flex: 0 0 auto;
  min-height: auto;
  position: relative;
  overflow: visible;
}

.mobile-tab-header {
  display: none;
}

.mobile-sidebar-close {
  white-space: nowrap;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 0.8rem;
  min-height: auto;
  height: auto;
  overflow: visible;
  padding-right: 0;
}

.tab-panel.is-active {
  display: flex;
}

.panel-section {
  padding: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.95rem;
}

.panel-foldout {
  margin: 0.65rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.panel-foldout summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.68rem 0.78rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.panel-foldout summary::-webkit-details-marker {
  display: none;
}

.panel-foldout summary::after {
  content: '+';
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 1rem;
}

.panel-foldout[open] summary::after {
  content: '-';
}

.panel-foldout-body {
  padding: 0 0.78rem 0.78rem;
}

.tool-panel-foldout {
  padding: 0;
  overflow: hidden;
}

.tool-panel-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.82rem;
  cursor: pointer;
}

.tool-panel-summary::-webkit-details-marker {
  display: none;
}

.tool-panel-summary h2 {
  margin: 0;
  font-size: 0.95rem;
}

.tool-panel-summary::after {
  content: '+';
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 1rem;
}

.tool-panel-foldout[open] .tool-panel-summary::after {
  content: '-';
}

.tool-panel-body {
  padding: 0 0.82rem 0.82rem;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.58rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font-size: 0.76rem;
  font-family: var(--mono);
}

.section-copy,
.field-help,
.empty-message {
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.4;
}

.section-copy + .section-copy {
  margin-top: 0.4rem;
}

.tool-settings-grid {
  margin-top: 0.65rem;
}

.tool-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.id-mapping-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.id-mapping-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
}

.id-mapping-title {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.id-mapping-meta {
  color: var(--text-soft);
  font-size: 0.74rem;
  line-height: 1.4;
  font-family: var(--mono);
}

.model-select-field {
  margin-top: 0.2rem;
}

.mini-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.mini-button {
  padding: 0.3rem 0.45rem;
  border-radius: 0.6rem;
  background: rgba(126, 216, 181, 0.1);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0.58rem 0.68rem;
}

.field.is-disabled {
  opacity: 0.58;
}

.field select {
  color-scheme: dark;
}

.field select option,
.field select optgroup {
  color: var(--text);
  background: #102a33;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.75rem;
  margin: 0.65rem 0;
}

.toggle-stack {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.preferences-panel .tool-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.preferences-panel .toggle-row {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.preferences-panel .toggle {
  display: flex;
  width: 100%;
}

.toggle {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.84rem;
  color: var(--text-soft);
}

.actuator-group + .actuator-group {
  margin-top: 0.75rem;
}

.coordinates-panel[open] {
  display: flex;
  flex-direction: column;
}

.coordinate-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.coordinate-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.coordinate-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(34vh, 18rem);
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-gutter: stable;
}

.coordinate-row {
  display: grid;
  gap: 0.42rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(160, 211, 225, 0.12);
}

.coordinate-row:first-child {
  padding-top: 0;
}

.coordinate-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.coordinate-row[data-selected="true"] .coordinate-name {
  color: var(--accent-2);
}

.coordinate-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
}

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

.coordinate-name:hover {
  color: var(--accent-2);
}

.coordinate-value-input {
  width: 5.4rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0.42rem 0.5rem;
  text-align: right;
}

.coordinate-lock {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--text-soft);
  font-size: 0.74rem;
  white-space: nowrap;
}

.coordinate-slider-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}

.coordinate-bound {
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.2;
  min-width: 2.9rem;
  text-align: center;
  font-family: var(--mono);
}

.coordinate-slider {
  width: 100%;
  min-width: 0;
}

.actuator-tab-section {
  min-height: 0;
}

.actuator-tab-section[open] {
  display: flex;
  flex-direction: column;
}

.actuator-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.actuator-muscle-modes {
  display: grid;
  gap: 0.45rem;
}

.actuator-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0;
}

.button-toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 0;
  padding: 0.42rem 0.5rem;
  border-radius: 0.72rem;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
}

.button-toolbar::before {
  content: '';
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 0.2rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 0.16rem rgba(255, 255, 255, 0.02);
}

.button-toolbar:hover:not(:disabled)::before {
  border-color: rgba(217, 255, 115, 0.4);
  background: rgba(217, 255, 115, 0.1);
}

.actuator-controls {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(46vh, 24rem);
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
  scrollbar-gutter: stable;
}

.actuator-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.actuator-group-header h3 {
  margin: 0;
  font-size: 0.9rem;
}

.actuator-row {
  display: grid;
  gap: 0.38rem;
  padding: 0.58rem 0.64rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  transition: border-color 120ms ease, background 120ms ease;
}

.actuator-row.active {
  border-color: rgba(217, 255, 115, 0.24);
  background: rgba(217, 255, 115, 0.08);
}

.actuator-row.compact {
  padding: 0.42rem 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(160, 211, 225, 0.12);
}

.actuator-row.compact.active {
  background: transparent;
  border-color: transparent;
  border-bottom-color: rgba(217, 255, 115, 0.3);
}

.actuator-row.compact:first-child {
  padding-top: 0;
}

.actuator-row.compact:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.actuator-meta {
  display: grid;
  gap: 0.2rem;
}

.actuator-summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
  color: var(--text-soft);
  font-size: 0.76rem;
  line-height: 1.35;
}

.actuator-summary-line .actuator-name {
  color: var(--text);
}

.actuator-summary-line .summary-sep {
  color: var(--text-muted);
  font-family: var(--mono);
}

.actuator-name {
  font-size: 0.82rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.actuator-type {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.actuator-detail {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.35;
}

.actuator-controls-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
}

.actuator-controls-row input[type="range"] {
  width: 100%;
}

.actuator-row.compact .actuator-controls-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.slider-bound {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  min-width: 2.35rem;
  text-align: center;
}

.actuator-value {
  min-width: 3rem;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.event-log {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-height: 4.75rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  font-family: var(--mono);
}

.event-log-compact {
  margin-top: 0.4rem;
  max-height: clamp(3.8rem, 9vh, 4.8rem);
  scrollbar-gutter: stable both-edges;
}

.event-log-tall {
  max-height: none;
  min-height: 12rem;
}

.log-entry {
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry.ok {
  color: var(--accent);
}

.log-entry.warn {
  color: var(--warn);
}

.log-entry.err {
  color: var(--danger);
}

.log-entry.muted {
  color: var(--text-muted);
}

.tab-panel[data-tab-panel="tools"] .panel-section {
  margin-bottom: 0.05rem;
}

@media (max-width: 1100px) {
  html,
  body {
    overflow: auto;
  }

  .demo-app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .demo-layout {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "model model"
      "stage control";
    align-items: start;
  }

  .control-panel {
    display: contents;
  }

  .panel-resize-handle {
    display: none;
  }

  .stage-column {
    order: 2;
    grid-area: stage;
  }

  .global-model-panel {
    grid-area: model;
  }

  .sidebar-shell {
    grid-area: control;
    position: sticky;
    top: 0.8rem;
    z-index: 5;
    display: grid;
    --mobile-tab-rail-width: 4.2rem;
    --mobile-tab-pane-width: clamp(16rem, 38vw, 21rem);
    grid-template-columns: var(--mobile-tab-rail-width);
    width: auto;
    max-height: calc(100dvh - 1.6rem);
    align-self: start;
    overflow: hidden;
  }

  .sidebar-shell.is-open {
    grid-template-columns: var(--mobile-tab-rail-width) var(--mobile-tab-pane-width);
  }

  .panel-tabs {
    width: auto;
    height: 100%;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 0.35rem;
  }

  .panel-tab {
    min-height: 4.9rem;
    padding: 0.55rem 0.32rem;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-align: center;
  }

  .panel-tab:hover {
    transform: rotate(180deg);
  }

  .panel-tab-stack {
    position: static;
    width: auto;
    min-height: 0;
    max-height: calc(100dvh - 1.6rem);
    overflow: hidden;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 1.1rem;
    background: rgba(8, 22, 29, 0.88);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
  }

  .sidebar-shell:not(.is-open) .panel-tab-stack {
    display: none;
  }

  .sidebar-shell.is-open .panel-tab-stack {
    display: flex;
    flex-direction: column;
  }

  .mobile-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.55rem;
    padding: 0.15rem 0.1rem 0;
  }

  .stage-shell {
    height: auto;
    min-height: 68vh;
  }

  .playback-main {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .playback-time-block {
    min-width: 0;
  }

  .playback-controls {
    flex-wrap: wrap;
  }

  .panel-tab-stack {
    overflow: hidden;
  }

  .tab-panel {
    height: 100%;
    min-height: 0;
    overflow: auto;
    padding-right: 0;
    padding-bottom: 0.4rem;
    -webkit-overflow-scrolling: touch;
  }

  .tab-panel.is-active {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .sidebar-shell .panel-section {
    min-height: 0;
  }

  .sidebar-shell .actuator-tab-section {
    min-height: 0;
  }

  .sidebar-shell .actuator-tab-section[open] {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .sidebar-shell .actuator-tab-section[open] .actuator-panel-body {
    min-height: 0;
  }

  .sidebar-shell .tab-panel[data-tab-panel="actuators"] {
    overflow: auto;
  }

  .sidebar-shell .tab-panel[data-tab-panel="actuators"] .actuator-controls {
    max-height: none;
    min-height: 0;
    overflow: visible;
    flex: 1 1 auto;
    padding-right: 0.15rem;
  }

  .sidebar-shell .tab-panel[data-tab-panel="actuators"] .coordinate-controls {
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

}

@media (max-width: 720px) {
  html,
  body {
    overflow: auto;
  }

  .demo-app {
    height: auto;
    min-height: 100vh;
    padding: 0.8rem;
    overflow: visible;
  }

  .demo-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.6rem;
  }

  .demo-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "model"
      "stage"
      "control";
    align-items: stretch;
  }

  .control-panel {
    grid-area: control;
    overflow: visible;
    padding-right: 0;
  }

  .panel-resize-handle {
    display: none;
  }

  .stage-column {
    grid-area: stage;
  }

  .global-model-panel {
    grid-area: model;
  }

  .header-actions {
    justify-content: flex-end;
    gap: 0.45rem;
  }

  .brand-block h1 {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
  }

  .engine-pill {
    min-height: 2.2rem;
    padding: 0.48rem 0.7rem;
    font-size: 0.82rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .hud-card {
    max-width: calc(100% - 2rem);
  }

  .actuator-toolbar {
    grid-template-columns: 1fr;
  }

  .coordinate-topline {
    grid-template-columns: minmax(0, 1fr);
  }

  .coordinate-value-input {
    width: 100%;
  }

  .coordinate-lock {
    justify-self: start;
  }

  .panel-tabs {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: auto;
  }

  .panel-tab {
    min-height: 0;
    font-size: 0.74rem;
    writing-mode: horizontal-tb;
    transform: none;
    padding: 0.58rem 0.45rem;
    text-align: center;
  }

  .panel-tab:hover {
    transform: translateY(-1px);
  }

  .sidebar-shell {
    position: static;
    top: auto;
    z-index: auto;
    display: flex;
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .sidebar-shell.is-open {
    grid-template-columns: 1fr;
  }

  .mobile-tab-header,
  .mobile-sidebar-close {
    display: none;
  }

  .panel-tab-stack,
  .sidebar-shell:not(.is-open) .panel-tab-stack,
  .sidebar-shell.is-open .panel-tab-stack {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }

  .tab-panel,
  .tab-panel.is-active {
    overflow: visible;
  }
}
