/*
[INPUT]: 依赖精修台 HTML 的控件与状态类。
[OUTPUT]: 提供页头工具导航、时间轴、音乐轨、接地辅助、倍速和自动处理报告样式。
[POS]: 精修台专用样式；不定义动作数据。
[PROTOCOL]: Update this header on change, then check AGENTS.md
*/
:root {
  color-scheme: dark;
  --ui-scale: 1;
  --ink: #f3f6ef;
  --muted: #9da9a3;
  --dim: #69736f;
  --panel: #111714;
  --panel-2: #171e1a;
  --line: #2b3631;
  --line-hot: #64786e;
  --green: #b9ff48;
  --green-dim: #657f24;
  --amber: #ffb443;
  --red: #ff5d54;
  --cyan: #5ad7db;
  --font-display: "DIN Alternate", "Bahnschrift Condensed", "Noto Sans SC", sans-serif;
  --font-body: "Aptos", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

html, body { min-width: 1180px; height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    linear-gradient(rgba(185, 255, 72, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 255, 72, .025) 1px, transparent 1px),
    radial-gradient(circle at 14% -10%, #213d2a 0, transparent 34%),
    #090d0b;
  background-size: 32px 32px, 32px 32px, auto, auto;
}

button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

/* The editor owns the viewport: panes scroll inside, the page itself does not. */
body { overflow: hidden; }
.lab-shell {
  height: 100dvh; padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
main { flex: 1 1 auto; min-height: 0; display: flex; }

.lab-header {
  flex: 0 0 auto;
  min-height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: rgba(12, 17, 14, .92);
  box-shadow: 0 18px 70px rgba(0, 0, 0, .32);
}

.brand-lockup, .header-actions, .section-heading, .viewer-heading, .playback-strip,
.timeline-toolbar, .timeline-legend, .joint-heading { display: flex; align-items: center; }
.brand-lockup { gap: 16px; flex: 0 0 auto; }
.header-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.editor-title {
  padding: 0; border: 0; background: transparent; letter-spacing: inherit;
  cursor: pointer; touch-action: manipulation; user-select: none;
}
.gmr-tool-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.gmr-tool-links[hidden] { display: none; }
.gmr-tool-links a { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }

h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--font-display); letter-spacing: .025em; }
h1 { font-size: calc(30px * var(--ui-scale)); line-height: .9; text-transform: uppercase; }
h2 { font-size: calc(20px * var(--ui-scale)); font-weight: 650; }
.kicker {
  margin-bottom: 6px; color: var(--green); font: 700 calc(10px * var(--ui-scale))/1 var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase;
}

.status-pill, .tool-button, .primary-button, .transport-button {
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
  transition: border-color .14s, background .14s, transform .14s;
}
.status-pill { padding: 10px 14px; color: var(--muted); font: 700 calc(11px * var(--ui-scale)) var(--font-mono); }
.status-pill.busy { color: var(--amber); border-color: #715527; }
.status-pill.ready { color: var(--green); border-color: var(--green-dim); }
.status-pill.error { color: var(--red); border-color: #71312d; }
.tool-button { min-height: 40px; padding: 0 14px; font-size: calc(13px * var(--ui-scale)); font-weight: 700; }
/* Two-line variant: the shortcut sits under the label as plain mono text.
   Both buttons share one min-width so the pair lines up, and explicit line-heights keep the
   Chinese label (font-body) and the Latin keycap glyphs (font-mono) on one optical centre. */
/* One shared column width keeps the 撤销/重做 pair identical, however long the hint is. */
.history-pair { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.tool-button.has-hint {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 4px 10px; width: 100%;
}
.tool-label { line-height: 1.1; }
.tool-hint {
  display: block; padding: 0; border: 0; background: none; min-height: 0;
  color: var(--muted);
  font: 600 calc(10px * var(--ui-scale))/1.1 var(--font-mono);
  white-space: nowrap;
}
.tool-button.has-hint:hover:not(:disabled) .tool-hint { color: var(--green); }
.tool-button.has-hint:disabled .tool-hint { color: var(--dim); }
.tool-button.has-hint:disabled { opacity: .6; }
.tool-hint:empty { display: none; }
html.compact .tool-hint { display: none; }
.tool-button.accent { color: #11170e; background: var(--green); border-color: var(--green); }
.tool-button:hover:not(:disabled), .transport-button:hover:not(:disabled) { border-color: var(--green); transform: translateY(-1px); }
button:disabled { opacity: .35; cursor: not-allowed; }

.upload-stage { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; place-items: center; padding: 16px 0; }
.upload-stack { display: grid; gap: 16px; justify-items: center; }
.recent-card {
  width: 900px; padding: 20px 24px 14px; border: 1px solid var(--line);
  background: rgba(13, 18, 15, .94);
}
.recent-card.hidden { display: none; }
.recent-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.recent-head h2 { font-size: calc(22px * var(--ui-scale)); }
.recent-note { max-width: 430px; color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.6; }
.recent-list {
  display: grid; gap: 6px; padding: 10px 0 0; margin: 0; list-style: none;
  max-height: min(52vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  padding-right: 4px; scrollbar-width: thin;
}
.recent-list::-webkit-scrollbar { width: 9px; }
.recent-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.recent-list::-webkit-scrollbar-thumb { background: var(--green-dim); border: 2px solid #0b100d; }
.recent-list::-webkit-scrollbar-thumb:hover { background: var(--green); }
.recent-item { display: flex; align-items: stretch; gap: 4px; }
.recent-open {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 6px 12px; display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; text-align: left; cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 255, 255, .015); color: var(--ink);
}
.recent-remove {
  flex: 0 0 auto; width: 30px; min-height: 44px; padding: 0; color: var(--dim); cursor: pointer;
  border: 1px solid transparent; background: rgba(255, 255, 255, .015);
  font: 700 calc(13px * var(--ui-scale)) var(--font-mono);
}
.recent-remove:hover:not(:disabled), .recent-remove:focus-visible {
  color: var(--red); border-color: rgba(255, 93, 84, .55); background: rgba(255, 93, 84, .08); outline: none;
}
.recent-remove:disabled { opacity: .4; cursor: progress; }
.recent-restore {
  margin-top: 8px; padding: 0; color: var(--muted); background: transparent; border: 0;
  cursor: pointer; font: calc(10px * var(--ui-scale)) var(--font-mono); text-decoration: underline;
}
.recent-restore:hover { color: var(--green); }
.recent-open:hover:not(:disabled), .recent-open:focus-visible {
  border-color: var(--green-dim); background: rgba(185, 255, 72, .06); outline: none;
}
.recent-open:disabled { opacity: .5; cursor: progress; }
.recent-name { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font: 650 calc(13px * var(--ui-scale)) var(--font-display); letter-spacing: .01em; }
.recent-meta { grid-column: 1; color: var(--dim); font: calc(10px * var(--ui-scale)) var(--font-mono); }
.recent-action { grid-column: 2; grid-row: 1 / span 2; color: var(--green); font: 700 calc(10px * var(--ui-scale)) var(--font-mono); letter-spacing: .06em; }
.recent-item:first-child .recent-name { color: var(--green); }
.recent-empty {
  margin: 10px 0 2px; padding: 12px 14px; color: var(--muted);
  border: 1px dashed var(--line); background: rgba(255, 255, 255, .015);
  font-size: 11px; line-height: 1.85;
}
.recent-empty code { color: var(--green); font: 10px var(--font-mono); }
.recent-footer { margin: 8px 0 0; color: var(--dim); font: 9px var(--font-mono); overflow-wrap: anywhere; }
.recent-footer code { color: var(--muted); }
.upload-card {
  width: 900px; display: grid; grid-template-columns: 80px 1fr 300px; gap: 26px;
  align-items: center; padding: 38px; border: 1px solid var(--line);
  background: linear-gradient(130deg, rgba(30, 47, 37, .84), rgba(14, 20, 17, .96));
  box-shadow: 0 36px 100px rgba(0,0,0,.45); position: relative; overflow: hidden;
}
.upload-card::after {
  content: ""; position: absolute; width: 260px; height: 260px; right: -120px; top: -150px;
  border: 1px solid rgba(185,255,72,.22); border-radius: 50%; box-shadow: 0 0 0 38px rgba(185,255,72,.025), 0 0 0 76px rgba(185,255,72,.018);
}
.upload-index { color: var(--green); font: 300 calc(58px * var(--ui-scale))/1 var(--font-display); align-self: start; }
.upload-card h2 { max-width: 460px; margin-bottom: 14px; font-size: calc(32px * var(--ui-scale)); line-height: 1.06; }
.upload-card p:not(.kicker) { max-width: 520px; color: var(--muted); line-height: 1.65; }
.drop-zone {
  min-height: 154px; padding: 20px; display: grid; place-content: center; text-align: center; gap: 8px;
  border: 1px dashed var(--line-hot); background: rgba(185,255,72,.025); cursor: pointer; z-index: 1;
}
.drop-zone.dragging { border-color: var(--green); background: rgba(185,255,72,.08); }
.drop-zone input { display: none; }
.drop-zone strong { font: 700 calc(15px * var(--ui-scale)) var(--font-display); }
.drop-zone span { color: var(--muted); font-size: calc(12px * var(--ui-scale)); }
.fps-field { grid-column: 2; display: grid; grid-template-columns: 100px 90px 1fr; gap: 10px; align-items: center; }
.fps-field span { font-size: calc(13px * var(--ui-scale)); font-weight: 700; }
.fps-field small { color: var(--dim); }
input, select {
  min-height: 38px; color: var(--ink); border: 1px solid var(--line); background: #0b100d; padding: 0 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--green-dim); box-shadow: 0 0 0 2px rgba(185,255,72,.08); }
.primary-button {
  min-height: 48px; padding: 0 22px; color: #10150d; background: var(--green); border-color: var(--green);
  font: 800 calc(14px * var(--ui-scale)) var(--font-display); letter-spacing: .035em;
}
.upload-card .primary-button { grid-column: 3; }
.primary-button:hover:not(:disabled) { background: #d1ff81; transform: translateY(-1px); }

.editor-stage {
  flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 12px;
  animation: stage-in .35s ease both;
}
@keyframes stage-in { from { opacity: 0; transform: translateY(8px); } }
.viewer-column, .inspector-card { border: 1px solid var(--line); background: rgba(13, 18, 15, .94); }
.viewer-column {
  min-width: 0; min-height: 0; padding: 12px 14px;
  display: grid; grid-template-rows: auto auto minmax(170px, 1fr) auto auto;
}
.viewer-heading { justify-content: space-between; min-height: 48px; }
.motion-title {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  cursor: text; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s;
}
.motion-title:hover, .motion-title:focus-visible {
  color: var(--green); border-bottom-color: var(--green-dim); outline: none;
}
.motion-title-pencil { color: var(--dim); font-size: calc(13px * var(--ui-scale)); opacity: 0; transition: opacity .15s; }
.motion-title:hover .motion-title-pencil, .motion-title:focus-visible .motion-title-pencil { opacity: 1; }
.motion-title-input {
  width: min(560px, 100%); min-height: 30px; padding: 2px 8px;
  color: var(--ink); border: 1px solid var(--green-dim); background: #0b100d;
  font: 650 calc(18px * var(--ui-scale)) var(--font-display); letter-spacing: .02em;
}
.motion-title-input.hidden, .motion-title.hidden { display: none; }
.motion-title-input:focus { border-color: var(--green); outline: none; }
.motion-meta { color: var(--muted); font: calc(11px * var(--ui-scale)) var(--font-mono); }
.viewer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 0 12px; }
.contact-toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: calc(12px * var(--ui-scale)); cursor: pointer; }
.contact-toggle input { width: 15px; height: 15px; min-height: 0; margin: 0; accent-color: var(--green); }
.viewer-tools-hint { flex: 1; color: var(--dim); font-size: calc(10px * var(--ui-scale)); }
.viewer-tools button { min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); background: transparent; font-size: calc(11px * var(--ui-scale)); cursor: pointer; }
.viewer-tools button:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.viewer-tools button:disabled { opacity: .4; cursor: not-allowed; }
.contact-panel { position: absolute; left: 14px; bottom: 14px; max-width: calc(100% - 28px); padding: 10px 12px; background: rgba(8, 12, 10, .88); border: 1px solid var(--line); color: var(--muted); pointer-events: none; }
.contact-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 14px; margin-bottom: 6px; font: calc(11px * var(--ui-scale)) var(--font-mono); }
.contact-row strong { color: var(--ink); }
.contact-row b { display: inline-block; min-width: 122px; font-weight: 500; font-variant-numeric: tabular-nums; }
.contact-row [data-state="near"] { color: #65d787; }
.contact-row [data-state="clearance"] { color: #ffc45d; }
.contact-row [data-state="penetrating"] { color: #ff665d; }
.contact-note { color: var(--muted); font-size: calc(10px * var(--ui-scale)); line-height: 1.5; }
.viewer-frame { height: 100%; min-height: 150px; position: relative; border: 1px solid var(--line); background: #080c0a; overflow: hidden; }
/* Absolute so the canvas cannot inflate the grid row with its intrinsic size. */
#robotCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.viewer-hud { position: absolute; top: 13px; left: 14px; display: grid; gap: 3px; padding: 6px 8px; background: rgba(8, 12, 10, .78); color: var(--green); font: calc(12px * var(--ui-scale)) var(--font-mono); pointer-events: none; }
.viewer-hud span:last-child { color: var(--muted); font-size: calc(10px * var(--ui-scale)); }
#frameReadout { color: var(--green); font-size: calc(19px * var(--ui-scale)); font-weight: 700; letter-spacing: .03em; line-height: 1.1; }
#timeReadout { color: var(--muted); font-size: calc(11px * var(--ui-scale)); }
.hud-extra { display: none; color: var(--muted); font-size: calc(9px * var(--ui-scale)); white-space: nowrap; }
.viewer-mode {
  position: absolute; top: 13px; right: 14px; padding: 6px 8px; pointer-events: none;
  color: var(--amber); border: 1px solid rgba(255, 180, 67, .42); background: rgba(8, 12, 10, .78);
  font: 700 calc(9px * var(--ui-scale)) var(--font-mono); letter-spacing: .08em;
}
.viewer-mode.ready { color: var(--green); border-color: rgba(185, 255, 72, .42); }
.viewer-mode.fallback { color: var(--muted); border-color: var(--line-hot); }
.joint-popover {
  position: absolute; z-index: 8; width: 250px; padding: 13px; color: var(--ink);
  border: 1px solid var(--green-dim); background: rgba(10, 17, 13, .97);
  box-shadow: 0 18px 45px rgba(0, 0, 0, .52); backdrop-filter: blur(12px);
}
.joint-popover.hidden { display: none; }
.joint-popover-head, .joint-popover-value-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.joint-popover-head { margin-bottom: 12px; cursor: grab; user-select: none; touch-action: none; }
.joint-popover.dragging .joint-popover-head { cursor: grabbing; }
.joint-popover-head strong { display: block; color: var(--green); font: 650 calc(14px * var(--ui-scale)) var(--font-display); }
.joint-popover-head .kicker { margin-bottom: 3px; font-size: calc(8px * var(--ui-scale)); }
.popover-close { min-width: 24px; min-height: 24px; padding: 0; color: var(--muted); border: 1px solid var(--line); background: transparent; font: calc(18px * var(--ui-scale))/1 var(--font-mono); }
.popover-close:hover { color: var(--green); border-color: var(--green-dim); }
.joint-popover-value-row { margin-bottom: 8px; color: var(--muted); font: calc(10px * var(--ui-scale)) var(--font-mono); }
.joint-popover-value-row span:first-child { color: var(--green); font-size: calc(17px * var(--ui-scale)); }
.joint-popover-value-row input { width: 84px; min-height: 29px; padding: 0 6px; text-align: right; font: calc(11px * var(--ui-scale)) var(--font-mono); }
.joint-popover-slider { width: 100%; min-height: 24px; padding: 0; accent-color: var(--green); }
.joint-popover-limits { display: flex; justify-content: space-between; margin-top: 4px; color: var(--dim); font: calc(9px * var(--ui-scale)) var(--font-mono); }
.joint-popover-hint { margin: 10px 0 0; color: var(--dim); font-size: calc(10px * var(--ui-scale)); line-height: 1.45; }
.axis-mark { position: absolute; right: 16px; bottom: 14px; display: flex; gap: 8px; font: 700 calc(10px * var(--ui-scale)) var(--font-mono); }
.axis-mark .x { color: #ff665d; }.axis-mark .y { color: #65d787; }.axis-mark .z { color: #6fb7ff; }
.playback-strip { gap: 8px; padding-top: 10px; }
.transport-button { min-width: 42px; height: 38px; font: 700 calc(11px * var(--ui-scale)) var(--font-mono); }
.playback-strip > input[type="range"] { flex: 1; min-width: 90px; min-height: 24px; padding: 0; accent-color: var(--green); }
.frame-jump { display: flex; align-items: center; gap: 4px; color: var(--dim); font: calc(9px * var(--ui-scale)) var(--font-mono); }
.frame-jump input { width: 68px; min-height: 30px; padding: 0 6px; text-align: right; font: calc(10px * var(--ui-scale)) var(--font-mono); }
.frame-jump input::-webkit-inner-spin-button { opacity: .45; }
.frame-jump input:focus { color: var(--green); }

.timeline-panel { margin-top: 8px; padding-top: 10px; min-height: 0; position: relative; border-top: 1px solid var(--line); }
.timeline-resize-handle {
  position: absolute; z-index: 5; top: -9px; left: 0; width: 100%; height: 18px;
  display: grid; place-items: center; color: var(--dim); cursor: ns-resize;
  user-select: none; touch-action: none; font: calc(8px * var(--ui-scale)) var(--font-mono); letter-spacing: .08em;
}
.timeline-resize-handle::before { content: ""; position: absolute; width: 76px; height: 3px; border-radius: 2px; background: var(--line-hot); }
.timeline-resize-handle span { opacity: 0; transform: translateY(-11px); transition: opacity .15s; }
.timeline-resize-handle:hover::before, .timeline-panel.resizing .timeline-resize-handle::before { background: var(--green); }
.timeline-resize-handle:hover span, .timeline-panel.resizing .timeline-resize-handle span { opacity: 1; }
.timeline-view-button { min-height: 30px; padding: 0 9px; color: var(--muted); border: 1px solid var(--line); background: #0b100d; cursor: pointer; font: calc(9px * var(--ui-scale)) var(--font-mono); }
.timeline-view-button:hover { color: var(--green); border-color: var(--green-dim); }
.timeline-toolbar { justify-content: space-between; margin-bottom: 8px; }
.timeline-readouts { display: flex; align-items: end; gap: 18px; }
.timeline-signal-readout { display: grid; justify-items: end; gap: 2px; }
.timeline-signal-readout span { color: var(--dim); font-size: calc(10px * var(--ui-scale)); text-transform: uppercase; }
.timeline-signal-readout strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #75d9ff; font: calc(12px * var(--ui-scale)) var(--font-mono); }
.timeline-signal-readout small { color: var(--dim); font: calc(8px * var(--ui-scale)) var(--font-mono); }
.range-readout { display: grid; justify-items: end; gap: 2px; }
.range-readout span { color: var(--dim); font-size: calc(10px * var(--ui-scale)); text-transform: uppercase; }
.range-readout strong { color: var(--green); font: calc(12px * var(--ui-scale)) var(--font-mono); }
.range-fields { display: flex; align-items: center; gap: 4px; color: var(--green); font: calc(12px * var(--ui-scale)) var(--font-mono); }
.range-fields em { color: var(--muted); font-style: normal; }
.range-fields small { color: var(--green); font: inherit; }
.range-frame-input {
  width: calc(52px * var(--ui-scale)); padding: 1px 4px; text-align: center;
  color: var(--green); background: rgba(185, 255, 72, .06);
  border: 1px solid rgba(185, 255, 72, .28); border-radius: 3px;
  cursor: text;
  font: calc(12px * var(--ui-scale)) var(--font-mono);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.range-frame-input::-webkit-outer-spin-button,
.range-frame-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.range-frame-input:hover { border-color: var(--green); }
.range-frame-input:focus { outline: none; border-color: var(--green); background: rgba(185, 255, 72, .12); }
:root { --timeline-base: 208px; --timeline-h: var(--timeline-base); }
.timeline-wrap { height: var(--timeline-h); min-height: 128px; position: relative; border: 1px solid var(--line); background: #080c0a; overflow: hidden; }

.music-lane { margin-bottom: 8px; border: 1px solid var(--line); background: #0b100d; }
.music-toggle {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 8px;
  color: var(--green); border: 1px solid var(--line); background: transparent; cursor: pointer;
  font: 650 calc(11px * var(--ui-scale)) var(--font-display); letter-spacing: .03em; white-space: nowrap;
}
.music-toggle:hover { border-color: var(--green); background: rgba(185, 255, 72, .06); }
.music-toggle-icon { color: var(--muted); font: calc(10px * var(--ui-scale)) var(--font-mono); width: 9px; }
.music-lane.collapsed { border-color: var(--line); }
.music-lane.collapsed .music-lane-head { border-bottom: 0; padding: 3px 6px; }
.music-lane.collapsed .music-drop-zone,
.music-lane.collapsed .music-controls,
.music-lane.collapsed .music-lane-body { display: none; }
.music-lane.collapsed .music-toggle { flex: 1 1 auto; justify-content: flex-start; color: var(--ink); }
.music-lane.collapsed.drop-ready { border-color: var(--green); background: rgba(185, 255, 72, .08); }
/* Collapsed lane hands its height to the curve editor (+34px) and the 3D view (the rest). */
.music-lane.collapsed + .timeline-wrap { height: calc(var(--timeline-h) + 34px); }
.music-lane-head { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.music-drop-zone {
  flex: 1; min-width: 0; min-height: 34px; padding: 4px 10px; display: grid; gap: 2px; align-content: center;
  border: 1px dashed var(--line-hot); background: rgba(185, 255, 72, .03); cursor: pointer;
  transition: .15s ease;
}
.music-drop-zone:hover, .music-drop-zone.dragging { border-color: var(--green); background: rgba(185, 255, 72, .1); }
.music-drop-zone.dragging { box-shadow: inset 0 0 0 1px rgba(185, 255, 72, .45); }
.music-drop-zone input { display: none; }
.music-drop-zone strong { color: var(--ink); font: 650 calc(12px * var(--ui-scale)) var(--font-display); letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-drop-zone span { color: var(--dim); font: calc(9px * var(--ui-scale)) var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-drop-zone.loaded strong { color: var(--green); }
.music-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.music-volume { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: calc(9px * var(--ui-scale)) var(--font-mono); text-transform: uppercase; }
.music-volume input { width: 76px; min-height: 22px; padding: 0; accent-color: var(--green); }
.music-volume input:disabled { opacity: .4; }
.music-offset { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font: calc(9px * var(--ui-scale)) var(--font-mono); text-transform: uppercase; }
.music-offset input { width: 62px; min-height: 26px; padding: 0 6px; text-align: right; font: calc(10px * var(--ui-scale)) var(--font-mono); }
.music-offset input:disabled { opacity: .4; }
.music-controls .contact-toggle { font-size: calc(11px * var(--ui-scale)); }
.music-controls .contact-toggle input:disabled { opacity: .4; }
.music-controls button { min-height: 26px; }
.music-wave-wrap { position: relative; height: 52px; background: #080c0a; }
#musicWaveCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
#musicWaveCanvas.has-track { cursor: grab; }
#musicWaveCanvas.has-track:active, #musicWaveCanvas.dragging { cursor: grabbing; }
.music-hint {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  pointer-events: none; text-align: center; padding: 0 78px 0 88px;
}
.music-hint span { padding: 3px 10px; color: var(--dim); background: #080c0a; border: 1px solid #1b241f; font: calc(10px * var(--ui-scale)) var(--font-mono); }
.music-hint.hidden { display: none; }
#timelineCanvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#timelineCanvas.dragging-point { cursor: ns-resize; }
#timelineCanvas.scrubbing { cursor: ew-resize; }
#timelineCanvas.selecting-points { cursor: crosshair; }
#timelineCanvas.panning { cursor: grabbing; }
.range-overlay { position: absolute; left: 0; width: 100%; height: 18px; min-height: 0; padding: 0; border: 0; background: transparent; pointer-events: none; accent-color: var(--green); }
.range-overlay::-webkit-slider-thumb { pointer-events: auto; cursor: ew-resize; }
.range-overlay::-moz-range-thumb { pointer-events: auto; cursor: ew-resize; }
.range-start { top: 0; }.range-end { bottom: 0; }
.timeline-legend { gap: 18px; padding-top: 8px; color: var(--muted); font-size: calc(10px * var(--ui-scale)); }
.timeline-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; }
.severity-ok { background: var(--green-dim); }.severity-warn { background: var(--amber); }.severity-limit { background: var(--red); }
.timeline-reset { min-height: 24px; padding: 3px 7px; color: #75d9ff; border: 1px solid rgba(117, 217, 255, .3); background: rgba(117, 217, 255, .06); font: calc(8px * var(--ui-scale)) var(--font-mono); text-transform: uppercase; }
.timeline-reset:hover { border-color: #75d9ff; background: rgba(117, 217, 255, .12); }
.timeline-hint { margin-left: auto; color: var(--dim); }
@media (max-width: 720px) {
  .timeline-toolbar { align-items: start; gap: 12px; }
  .timeline-readouts { align-items: start; flex-direction: column; gap: 5px; }
  .timeline-readouts > div { justify-items: start; }
  .timeline-hint { margin-left: 0; }
}

.inspector-column {
  height: 100%; min-height: 0; display: grid; gap: 10px; align-content: start;
  overflow-y: auto; overflow-x: hidden; padding: 0 6px 18px 0;
  overscroll-behavior: contain;
}
.inspector-column::-webkit-scrollbar { width: 9px; }
.inspector-column::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.inspector-column::-webkit-scrollbar-thumb { background: var(--green-dim); border: 2px solid #0b100d; }
.inspector-column::-webkit-scrollbar-thumb:hover { background: var(--green); }
.inspector-card { min-width: 0; }
.inspector-hint {
  display: none; position: sticky; top: 0; z-index: 3; margin: 0; padding: 5px 8px;
  color: var(--dim); border: 1px dashed var(--line); background: rgba(9, 13, 11, .96);
  font: calc(9px * var(--ui-scale)) var(--font-mono); letter-spacing: .04em; text-align: center;
}
.inspector-column.more-below .inspector-hint { display: block; }
.inspector-card { padding: 16px; }
.section-heading { justify-content: space-between; }
.section-heading.compact { margin-bottom: 13px; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.metric {
  min-height: 74px; padding: 10px; border: 1px solid var(--line); background: var(--panel-2);
  display: grid; align-content: space-between;
}
.metric span { color: var(--dim); font: calc(9px * var(--ui-scale)) var(--font-mono); text-transform: uppercase; }
.metric strong { font: 650 calc(20px * var(--ui-scale)) var(--font-display); }
.metric.alert strong { color: var(--red); }.metric.warn strong { color: var(--amber); }
.metric-locate { width: 100%; text-align: left; cursor: pointer; font: inherit; }
.metric-locate:hover, .metric-locate:focus-visible { outline: 1px solid var(--green); }
.joint-limit-panel { margin-top: 10px; border: 1px solid var(--line); padding: 8px; }
.joint-limit-panel summary { cursor: pointer; color: var(--ink); font-size: calc(12px * var(--ui-scale)); }
.joint-limit-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 7px 0; }
.joint-limit-navigation button { min-height: 28px; border: 1px solid var(--line); padding: 4px 8px; background: transparent; color: var(--ink); cursor: pointer; }
.joint-limit-navigation button:disabled { opacity: .4; cursor: not-allowed; }
.joint-limit-navigation span { font: calc(10px * var(--ui-scale)) var(--font-mono); color: var(--dim); }
.joint-limit-list { display: grid; gap: 5px; max-height: 300px; overflow-y: auto; }
.joint-limit-entry { width: 100%; text-align: left; white-space: pre-line; overflow-wrap: anywhere; padding: 7px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: calc(10px * var(--ui-scale))/1.6 var(--font-mono); cursor: pointer; }
.joint-limit-entry:hover, .joint-limit-entry:focus-visible { border-color: var(--green); }
#jointLimitReadout { white-space: pre-line; overflow-wrap: anywhere; }
.anomaly-list { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; overflow-x: hidden; }
.anomaly-chip { border: 1px solid #6c4d22; background: #22180c; color: var(--amber); padding: 6px 8px; cursor: pointer; font: calc(10px * var(--ui-scale)) var(--font-mono); white-space: nowrap; }

.optimizer-card > label { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.optimizer-card label span, .weight-grid span { color: var(--muted); font-size: calc(11px * var(--ui-scale)); }
.weight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0; }
.weight-grid label { display: grid; gap: 5px; }
.weight-grid input { width: 100%; }
.optimize-button { width: 100%; }
.optimization-preview {
  margin-top: 9px; padding: 10px; border: 1px solid rgba(185,255,72,.42);
  border-radius: 8px; background: rgba(185,255,72,.055);
}
.optimization-preview > strong { color: var(--green); font-size: calc(12px * var(--ui-scale)); }
#optimizationPreviewSummary { display: grid; gap: 4px; margin: 8px 0 10px; }
#optimizationPreviewSummary span { color: var(--muted); font: calc(10px * var(--ui-scale))/1.35 var(--font-mono); }
.optimization-preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.optimization-preview-actions button { width: 100%; }
.solver-note { margin-top: 10px; color: var(--dim); font-size: calc(10px * var(--ui-scale)); line-height: 1.55; }
.joint-heading { justify-content: space-between; }
.joint-heading select { width: 118px; }
.root-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-bottom: 12px; margin-bottom: 11px; border-bottom: 1px solid var(--line); }
.root-controls label { display: grid; gap: 4px; }
.root-controls span { color: var(--dim); font: calc(8px * var(--ui-scale)) var(--font-mono); text-transform: uppercase; }
.root-controls input { width: 100%; min-width: 0; padding: 0 5px; font: calc(9px * var(--ui-scale)) var(--font-mono); }
.joint-controls { display: grid; gap: 8px; }
.joint-section-label {
  position: sticky; top: -1px; z-index: 2; margin: 4px -2px 0; padding: 7px 2px 5px;
  color: var(--green); border-bottom: 1px solid var(--green-dim); background: var(--panel);
  font: 700 calc(8px * var(--ui-scale)) var(--font-mono); letter-spacing: .12em;
}
.joint-row { display: grid; grid-template-columns: 118px 1fr 62px; gap: 8px; align-items: center; }
.joint-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: calc(9px * var(--ui-scale)) var(--font-mono); }
.joint-row.selected .joint-name { color: var(--green); }
.joint-row input[type="range"] { width: 100%; min-height: 22px; padding: 0; accent-color: var(--green); }
.joint-value { min-height: 28px; padding: 0 5px; text-align: right; font: calc(10px * var(--ui-scale)) var(--font-mono); }
.joint-row input:disabled, .joint-row input[readonly] {
  opacity: 1; color: var(--muted); cursor: default; pointer-events: none;
}
.joint-limit-mark { color: var(--red) !important; }
.download-card h2 { margin-bottom: 10px; }
.download-card a { display: block; margin-top: 6px; padding: 10px; color: var(--green); border: 1px solid var(--green-dim); text-decoration: none; font-size: calc(12px * var(--ui-scale)); }
.timeline-context-menu {
  position: fixed; z-index: 40; width: 286px; padding: 7px; color: var(--ink);
  border: 1px solid #4b5852; background: rgba(24, 29, 27, .985);
  box-shadow: 0 20px 55px rgba(0, 0, 0, .62); user-select: none;
}
.timeline-context-menu > button, .timeline-menu-branch > button, .timeline-submenu button {
  width: 100%; min-height: 31px; padding: 0 10px; display: flex; align-items: center;
  justify-content: space-between; gap: 14px; color: var(--ink); border: 0;
  background: transparent; cursor: pointer; text-align: left; font-size: calc(13px * var(--ui-scale));
}
.timeline-context-menu button:hover:not(:disabled), .timeline-menu-branch:focus-within > button:not(:disabled),
.timeline-menu-branch:hover > button:not(:disabled) { color: #071006; background: var(--green); }
.timeline-context-menu button:disabled, .timeline-menu-branch.disabled { color: var(--dim); cursor: not-allowed; }
.timeline-context-menu kbd { color: var(--muted); font: calc(11px * var(--ui-scale)) var(--font-mono); white-space: nowrap; }
.timeline-context-menu button:hover:not(:disabled) kbd, .timeline-menu-branch:hover > button:not(:disabled) kbd { color: #25300f; }
.menu-separator { height: 1px; margin: 6px 4px; background: #46504b; }
.timeline-menu-branch { position: relative; }
.timeline-submenu {
  display: none; position: absolute; z-index: 2; top: -7px; left: calc(100% - 2px); width: 220px;
  padding: 7px; border: 1px solid #4b5852; background: rgba(24, 29, 27, .99);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .55);
}
.timeline-submenu-up { top: auto; bottom: -7px; }
.timeline-menu-branch:not(.disabled):hover > .timeline-submenu,
.timeline-menu-branch:not(.disabled):focus-within > .timeline-submenu { display: block; }
.handle-submenu { width: 250px; }
.handle-submenu p { margin: 5px 9px 8px; color: var(--amber); font-size: calc(10px * var(--ui-scale)); line-height: 1.45; }

.task-progress {
  position: fixed; left: 50%; bottom: 82px; z-index: 32; transform: translateX(-50%);
  width: min(430px, calc(100vw - 60px)); padding: 11px 14px 10px;
  border: 1px solid var(--green-dim); background: rgba(12, 18, 14, .97);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .5);
}
.task-progress.hidden { display: none; }
.task-progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.task-progress-head strong { color: var(--green); font: 650 calc(12px * var(--ui-scale)) var(--font-display); letter-spacing: .02em; }
.task-progress-head span { color: var(--muted); font: calc(10px * var(--ui-scale)) var(--font-mono); font-variant-numeric: tabular-nums; }
.task-progress-track { height: 6px; border: 1px solid var(--line); background: #080c0a; overflow: hidden; }
.task-progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg, var(--green-dim), var(--green)); transition: width .16s linear; }
.task-progress-stage { margin: 7px 0 0; color: var(--dim); font: calc(10px * var(--ui-scale)) var(--font-mono); min-height: 12px; }
.task-progress.done { border-color: var(--green); }
.task-progress.failed { border-color: var(--red); }
.task-progress.failed .task-progress-bar { background: var(--red); }
.task-progress.failed .task-progress-head strong { color: #ffc2be; }

#settingsBtn, #compactBtn { display: inline-flex; align-items: center; gap: 5px; }
#compactBtn[aria-pressed="true"] { color: #10150d; background: var(--green); border-color: var(--green); }

/* Compact layout: the three chrome bands step aside so preview and curves grow. */
html.compact .lab-shell { padding: 6px; gap: 6px; }
html.compact .lab-header { min-height: 36px; padding: 3px 10px; gap: 8px; }
html.compact .brand-lockup { gap: 10px; }
html.compact .brand-lockup .kicker { display: none; }
html.compact .brand-lockup h1 { font-size: calc(17px * var(--ui-scale)); line-height: 1; }
html.compact .status-pill { display: none; }
html.compact .header-actions .tool-button { min-height: 26px; padding: 2px 8px; font-size: calc(10px * var(--ui-scale)); }
html.compact .viewer-column { padding: 8px 10px; }
html.compact .viewer-heading { min-height: 24px; }
html.compact .viewer-heading .kicker { display: none; }
html.compact .viewer-heading h2 { font-size: calc(14px * var(--ui-scale)); }
html.compact .viewer-tools { padding: 2px 0 4px; gap: 6px; }
html.compact .viewer-tools button { min-height: 26px; padding: 2px 8px; }
html.compact .viewer-tools-hint { display: none; }
html.compact .playback-strip { min-height: 34px; }
html.compact .timeline-panel { margin-top: 4px; padding-top: 6px; }
html.compact .timeline-toolbar { margin-bottom: 4px; }
html.compact .timeline-toolbar .kicker, html.compact .timeline-toolbar h2 { display: none; }
html.compact .timeline-legend { display: none; }
html.compact .music-lane { margin-bottom: 4px; }
html.compact { --timeline-h: calc(var(--timeline-base) + 96px); }
html.compact .timeline-toolbar { display: none; }
html.compact .music-lane { display: none; }
html.compact .viewer-hud { gap: 2px; }
html.compact .viewer-hud .hud-extra { display: block; color: var(--green); }
html.compact .hud-extra { font-size: calc(9px * var(--ui-scale)); }
html.compact .viewer-hud .hud-extra:nth-of-type(4) { color: var(--muted); }

/* Compact-only controls that replace the collapsed toolbar. */
.compact-only { display: none; }
html.compact .compact-only {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; margin-left: 6px;
  color: var(--muted); border: 1px solid var(--line); background: #0b100d; cursor: pointer;
  font: calc(9px * var(--ui-scale)) var(--font-mono);
}
html.compact .compact-only:hover { color: var(--green); border-color: var(--green-dim); }

/* Shortcut settings dialog */
.shortcut-dialog {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(4, 7, 6, .72); backdrop-filter: blur(3px);
}
.shortcut-dialog.hidden { display: none; }
.shortcut-panel {
  width: min(720px, calc(100vw - 48px)); max-height: min(82vh, 780px); display: flex; flex-direction: column;
  padding: 18px 20px; border: 1px solid var(--green-dim); background: rgba(11, 16, 13, .98);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.shortcut-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.shortcut-head h2 { font-size: calc(22px * var(--ui-scale)); }
.shortcut-note { margin: 8px 0 12px; color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.65; }
.display-settings { padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.display-settings h3 {
  margin: 0 0 6px; color: var(--green); font: 650 calc(12px * var(--ui-scale)) var(--font-display); letter-spacing: .04em;
}
.display-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 240px) 52px auto; align-items: center; gap: 10px; }
.display-label { color: var(--ink); font-size: calc(12px * var(--ui-scale)); }
.display-row input[type="range"] { min-height: 24px; padding: 0; accent-color: var(--green); }
.display-row output { color: var(--green); font: 11px var(--font-mono); text-align: right; }
.display-row .tool-button { min-height: 28px; padding: 0 9px; font-size: calc(10px * var(--ui-scale)); }
.display-note { margin: 6px 0 0; color: var(--muted); font-size: calc(11px * var(--ui-scale)); line-height: 1.6; }
.shortcut-groups { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 6px; display: grid; gap: 14px; }
.shortcut-groups::-webkit-scrollbar { width: 9px; }
.shortcut-groups::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.shortcut-groups::-webkit-scrollbar-thumb { background: var(--green-dim); border: 2px solid #0b100d; }
.shortcut-group h3 {
  margin: 0 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
  color: var(--green); font: 650 calc(12px * var(--ui-scale)) var(--font-display); letter-spacing: .04em;
}
.shortcut-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 118px 54px; align-items: center; gap: 8px;
  padding: 4px 0;
}
.shortcut-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: calc(12px * var(--ui-scale)); }
.shortcut-key {
  min-height: 30px; padding: 0 8px; color: var(--green); border: 1px solid var(--line-hot);
  background: #0b100d; cursor: pointer; font: calc(11px * var(--ui-scale)) var(--font-mono); letter-spacing: .02em;
}
.shortcut-key:hover { border-color: var(--green); }
.shortcut-key.capturing { color: #10150d; background: var(--green); border-color: var(--green); }
.shortcut-key.custom { color: var(--amber); border-color: #6c4d22; }
.shortcut-reset {
  min-height: 30px; padding: 0 6px; color: var(--muted); border: 1px solid var(--line);
  background: transparent; cursor: pointer; font: calc(10px * var(--ui-scale)) var(--font-mono);
}
.shortcut-reset:disabled { opacity: .3; cursor: default; }
.shortcut-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--line); }
.shortcut-foot .primary-button { min-height: 34px; }

#fullscreenBtn { display: inline-flex; align-items: center; gap: 5px; }
#fullscreenBtn[aria-pressed="true"] { color: #10150d; background: var(--green); border-color: var(--green); }

/* Short viewports: trim the chrome before the viewer gives up its space. */
@media (min-height: 1000px) {
  .metric { min-height: 84px; }
  .inspector-card { padding: 18px; }
}
@media (max-height: 960px) {
  :root { --timeline-base: 186px; }
  .viewer-tools { padding: 6px 0 8px; }
  .viewer-heading { min-height: 42px; }
}
@media (max-height: 880px) {
  .lab-shell { padding: 8px; gap: 8px; }
  .lab-header { min-height: 50px; padding: 6px 12px; }
  .editor-stage { gap: 8px; }
  .viewer-column { padding: 10px 12px; }
  :root { --timeline-base: 164px; }
  .music-wave-wrap { height: 44px; }
  .timeline-legend .timeline-hint { display: none; }
}
@media (max-height: 780px) {
  :root { --timeline-base: 140px; }
  .timeline-wrap { min-height: 110px; }
  .viewer-frame { min-height: 140px; }
  .timeline-legend { padding-top: 4px; }
  .inspector-card { padding: 12px; }
  .metric { min-height: 62px; }
}
@media (max-height: 780px) and (min-height: 641px) {
  .lab-shell { padding: 6px; gap: 6px; }
  .lab-header { min-height: 46px; padding: 5px 10px; }
  .editor-stage { gap: 6px; }
  .viewer-column { padding: 8px 10px; }
  .viewer-tools { padding: 4px 0 6px; }
  :root { --timeline-base: 132px; }
  .timeline-wrap { min-height: 104px; }
  .music-wave-wrap { height: 40px; }
  .timeline-panel { margin-top: 6px; padding-top: 8px; }
}
@media (max-height: 700px) {
  .viewer-column { grid-template-rows: auto auto minmax(110px, 1fr) auto auto; }
  .viewer-frame { min-height: 110px; }
  :root { --timeline-base: 100px; }
  .timeline-wrap { min-height: 92px; }
  .music-wave-wrap { height: 34px; }
  .viewer-heading { min-height: 34px; }
  .viewer-tools { padding: 3px 0 5px; }
  .playback-strip { min-height: 38px; }
  .timeline-legend { display: none; }
  .music-lane { margin-bottom: 6px; }
}
/* Scaled-up text can outgrow the viewport; fall back to a scrolling page instead of clipping. */
html.ui-scale-overflow body { overflow: auto; }
html.ui-scale-overflow .lab-shell { height: auto; min-height: 100dvh; }
html.ui-scale-overflow .viewer-column { grid-template-rows: auto auto minmax(220px, auto) auto auto; }
html.ui-scale-overflow .inspector-column { height: min(70dvh, 720px); }

/* Below ~560px of height nothing useful fits side by side; scroll the page instead. */
@media (max-height: 560px) {
  body { overflow: auto; }
  .lab-shell { height: auto; min-height: 100dvh; }
  main, .editor-stage { min-height: 0; height: auto; }
  .viewer-column { grid-template-rows: auto auto minmax(260px, auto) auto auto; }
  .inspector-column { height: min(560px, calc(100dvh - 96px)); overflow-y: auto; }
  :root { --timeline-base: 150px; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translate(-50%, 20px);
  min-width: 260px; max-width: 620px; padding: 12px 16px; opacity: 0; pointer-events: none;
  color: var(--ink); border: 1px solid var(--line-hot); background: #111814; box-shadow: 0 18px 50px rgba(0,0,0,.45);
  transition: opacity .18s, transform .18s; text-align: center; font-size: calc(12px * var(--ui-scale));
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--red); color: #ffc2be; }

.timeline-context-menu.open-left .timeline-submenu { left: auto; right: calc(100% - 2px); }

.playback-rate-control {
  flex: 0 0 224px; height: 38px; display: grid; grid-template-columns: auto minmax(96px, 1fr) 42px;
  align-items: center; gap: 8px; padding: 0 9px; color: var(--muted); border: 1px solid var(--line);
  background: #0b100d; user-select: none;
}
.playback-rate-label { color: var(--dim); font: 700 calc(8px * var(--ui-scale)) var(--font-mono); letter-spacing: .08em; }
.playback-rate-control input[type="range"] {
  width: 100%; min-width: 0; min-height: 24px; padding: 0; border: 0; outline: none;
  background: transparent; cursor: ew-resize; appearance: none; -webkit-appearance: none;
}
.playback-rate-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 3px; border: 1px solid #34413b;
  background: linear-gradient(to right, var(--green) 0 var(--rate-progress), var(--line-hot) var(--rate-progress) 100%);
}
.playback-rate-control input[type="range"]::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -7px; border: 2px solid var(--green); border-radius: 50%;
  background: #111714; box-shadow: 0 0 0 3px rgba(185, 255, 72, .08); appearance: none; -webkit-appearance: none;
}
.playback-rate-control input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 3px; border: 1px solid #34413b; background: var(--line-hot);
}
.playback-rate-control input[type="range"]::-moz-range-progress { height: 4px; border-radius: 3px; background: var(--green); }
.playback-rate-control input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid var(--green); border-radius: 50%;
  background: #111714; box-shadow: 0 0 0 3px rgba(185, 255, 72, .08);
}
.playback-rate-control:focus-within { border-color: var(--green-dim); box-shadow: 0 0 0 2px rgba(185,255,72,.08); }
.playback-rate-control input[type="range"]:focus { box-shadow: none; }
.playback-rate-control output { color: var(--green); text-align: right; font: 700 calc(11px * var(--ui-scale)) var(--font-mono); }
#playbackRateSteps { display: none; }

#autoKeyframeSummary { display: grid; gap: 4px; margin-top: 8px; }
#autoKeyframeSummary span { color: var(--muted); font: calc(10px * var(--ui-scale))/1.35 var(--font-mono); }
@media (max-width: 720px) {
  .playback-strip { flex-wrap: wrap; }
  .playback-rate-control { flex: 1 1 200px; }
}

/* 推定持刀叠加控件：与接地开关同一行，只影响显示。 */
.grip-length-toggle { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font-size: calc(11px * var(--ui-scale)); }
.grip-length-toggle input { width: 58px; min-height: 28px; padding: 2px 6px; font-size: calc(11px * var(--ui-scale)); }
.grip-length-toggle input:disabled { opacity: .5; }
