:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #0a0a0a;
  --panel-2: #000;
  --line: #3a3a3f;
  --muted: #a2a2aa;
  --text: #fff;
  --amber: #fff;
  --green: #fff;
  --steel: #f0f0fa;
  --accent: #fff;
  --shadow: none;
  font-family: "D-DIN", "Arial Narrow", Arial, Verdana, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fbfbf9;
  --panel: #fff;
  --panel-2: #f6f6f3;
  --line: #dadad3;
  --muted: #62625b;
  --text: #211922;
  --amber: #e60023;
  --green: #103c25;
  --steel: #33332e;
  --accent: #e60023;
  --shadow: 0 18px 52px rgba(38, 38, 34, .08);
  font-family: "Noto Sans SC", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button { text-transform: uppercase; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); }

.shell {
  display: grid;
  grid-template-columns: minmax(400px, 440px) minmax(380px, 1fr) minmax(240px, 290px);
  height: 100vh;
  overflow: hidden;
}

.left-panel, .right-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  height: 100vh;
  padding: 20px;
  overflow: auto;
  background: var(--panel);
  border-color: var(--line);
}
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); }

.brand, .control-head, .section-title, .model-part-calibration summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.theme-switch {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}
.theme-switch button {
  min-width: 48px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
html[data-theme="dark"] .theme-switch [data-theme-choice="dark"],
html[data-theme="light"] .theme-switch [data-theme-choice="light"] { color: var(--bg); background: var(--text); }

.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: 28px; line-height: 1.05; letter-spacing: .04em; text-transform: uppercase; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0 0 12px; color: var(--steel); font-size: 13px; }
.version-line { margin: 8px 0 0; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.panel-heading { display: grid; gap: 6px; }
.panel-heading > p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.mode-button.is-active { color: var(--bg); border-color: var(--text); background: var(--text); }
.control-stack { display: grid; gap: 14px; }
#controls { display: grid; gap: 14px; }
.control-section, .future-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
}
.future-panel > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.algorithm-panel { gap: 12px; }
.coordinate-contract { padding: 10px; border-left: 3px solid var(--accent); background: var(--bg); }
.ik-controls { display: grid; gap: 10px; }
.compact-section { padding: 10px; }
.ik-coordinate-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.ik-coordinate-grid label, .select-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.ik-coordinate-grid input, .select-control select {
  min-width: 0;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.path-point-card { display: grid; gap: 8px; padding: 9px; border: 1px solid var(--line); background: var(--bg); }
.path-point-card > strong { color: var(--steel); font-size: 11px; }
.file-input { width: 100%; padding: 8px; border: 1px solid var(--line); color: var(--muted); background: var(--bg); font-size: 11px; }
.two-actions { grid-template-columns: 1fr auto; }
.fixed-output { display: grid; place-items: center; min-width: 72px; padding: 0 10px; border: 1px solid var(--line); color: var(--text); background: var(--bg); font-size: 11px; }
.primary-action, .secondary-action {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--bg);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}
.primary-action { color: var(--bg); border-color: var(--text); background: var(--text); }
.primary-action:disabled, .secondary-action:disabled { cursor: not-allowed; opacity: .35; }
.simulation-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.ik-status { display: block; padding: 9px; border: 1px solid var(--line); color: var(--muted); background: var(--bg); font-size: 11px; font-weight: 900; }
.ik-status.is-reachable { color: var(--green); }
.ik-status.is-unreachable { color: #ff8a6b; }
.ik-result-grid { gap: 7px; }
.ik-result-grid div { font-size: 11px; }
.ik-result-grid dd { max-width: 65%; }
.control-section > label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 0;
  color: var(--steel);
  font-size: 13px;
  font-weight: 800;
}
.control-section output { color: var(--amber); font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; }
input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--amber); }
.fixed-value {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
  font-size: 12px;
}
.fixed-value strong { color: var(--text); }
.control-section > .control-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--steel);
  background: var(--bg);
  font-size: 12px;
}
.control-toggle input { width: 16px; height: 16px; accent-color: var(--amber); }
.constraint-status { color: var(--muted); font-size: 11px; font-weight: 800; }
.constraint-status.is-exact { color: var(--green); }
.constraint-status.is-warning { color: #ff8a6b; }

/* 线性驱动：与 SP-S 的路径控制面板保持相同结构和排列。 */
.algorithm-panel { display: block; }
.linear-control {
  gap: 10px;
  padding: 12px;
}
.linear-control .control-head { align-items: center; }
.linear-control .control-head h3 { margin: 0; }
.linear-control .control-head output {
  color: var(--amber);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.linear-path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.linear-point-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}
.linear-point-card strong,
.linear-import-head strong {
  color: var(--text);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.linear-point-card label,
.linear-grid label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.linear-point-card input,
.linear-grid input,
.linear-grid select {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.linear-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.linear-grid output {
  display: flex;
  align-items: center;
  min-height: 30px;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.linear-import-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}
.linear-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.linear-import-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.linear-demo-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--amber);
  background: var(--bg);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}
.linear-demo-button { font-family: inherit; }
.coordinate-note {
  margin: 0;
  color: var(--steel);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.45;
}
.linear-path-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.4;
  text-align: right;
}
.linear-progress-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
}
.linear-progress-line input[type="range"] { width: 100%; }
.number-input {
  width: 58px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  background: var(--bg);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.linear-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.linear-actions button {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--amber);
  background: var(--bg);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}
.linear-actions button:hover {
  color: var(--bg);
  border-color: var(--text);
  background: var(--text);
}
.linear-solver-status { display: none; }

.preset-band, .model-panel, .readout-group { display: grid; gap: 12px; padding-top: 4px; }
.section-title { align-items: center; }
.section-title span { color: var(--steel); font-weight: 800; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--steel);
  background: var(--panel-2);
  cursor: pointer;
}
.preset-grid { display: grid; gap: 10px; }
.preset-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
}
.preset-button strong { font-size: 13px; }
.preset-button span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.icon-button:hover, .preset-button:hover { color: var(--bg); border-color: var(--text); background: var(--text); }

.stage { position: relative; min-height: 0; height: 100vh; overflow: hidden; background: #000; }
#scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; }
#scene:active { cursor: grabbing; }
#scene.is-linear-drag { cursor: crosshair; }
#scene.is-dragging-tcp { cursor: grabbing; }
.hud, .axis-legend {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(0,0,0,.82);
}
.hud span { color: var(--muted); font-size: 11px; font-weight: 800; }
.hud strong { color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
.top-left { top: 18px; left: 18px; }
.axis-legend { right: 18px; bottom: 18px; grid-template-columns: repeat(3,30px); place-items: center; padding: 8px; font-weight: 900; }
.axis-legend .x { color: #ff5d5d; } .axis-legend .y { color: #4bd3a5; } .axis-legend .z { color: #70a7ff; }
.view-controls {
  position: absolute;
  z-index: 4;
  top: 18px;
  right: 18px;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #000;
}
.view-controls button {
  min-width: 48px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line);
  color: #fff;
  background: #000;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
}
.view-controls button:last-child { border-right: 0; }
.view-controls button:hover { color: #000; background: #fff; }

.model-pose-controls { display: block; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2); }
.model-display-toggle,
.model-effect-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 900;
}
.model-display-toggle { cursor: pointer; }
.model-display-toggle input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--amber);
}
.model-display-toggle span { margin-left: auto; text-align: right; }
.model-effect-control select {
  min-width: 0;
  width: 58%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
}
.model-pose-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}
.model-pose-controls-head::-webkit-details-marker, .model-part-calibration summary::-webkit-details-marker { display: none; }
.model-pose-controls-head::after, .model-part-calibration summary::after { content: "+"; flex: 0 0 auto; color: var(--amber); font-size: 18px; font-weight: 900; }
.model-pose-controls[open] .model-pose-controls-head::after, .model-part-calibration[open] summary::after { content: "-"; }
.model-pose-controls-head strong, .model-part-calibration summary strong { color: var(--text); font-size: 13px; }
.model-pose-controls-head > span { color: var(--muted); font-size: 11px; font-weight: 900; }
.model-pose-controls-body { display: grid; gap: 10px; padding: 0 10px 10px; }
.ball-stick-control, .model-calibration { padding: 10px; }
.model-calibration > h3 { margin-bottom: 0; }
.control-hint { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.model-part-calibration { display: block; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2); }
.model-part-calibration summary { align-items: center; min-height: 44px; padding: 10px 0; cursor: pointer; list-style: none; }
.model-part-calibration summary strong { margin-right: auto; }
.model-status { max-width: 90px; color: var(--muted); overflow: hidden; font-size: 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.model-status.is-ready { color: var(--green); }
.model-status.is-error { color: #ff5d5d; }
.calibration-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding-bottom: 10px; }
.calibration-grid label { display: grid; gap: 4px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 900; }
.calibration-grid input {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.calibration-grid .calibration-wide { grid-column: 1 / -1; }
.model-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 12px; }
.model-actions button { min-height: 30px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); background: var(--bg); font-size: 10px; font-weight: 900; cursor: pointer; }
.model-actions button:hover { color: var(--bg); border-color: var(--text); background: var(--text); }

.readout-panel { gap: 22px; }
.readout-group { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.metric-block, .logic-block, .part-list { display: grid; gap: 10px; }
.metric-list { display: grid; gap: 10px; }
.metric { display: grid; gap: 7px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.metric:last-child { border-bottom: 0; }
.metric > div:first-child, .logic-row, .part-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric span, .logic-row span, .part-row span { color: var(--muted); }
.metric strong, .logic-row strong, .part-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.metric > div:first-child { font-size: 13px; }
.bar { height: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.bar span { display: block; width: 0; height: 100%; background: var(--amber); transition: width 120ms linear; }
.logic-row, .part-row { min-height: 36px; border-bottom: 1px solid var(--line); font-size: 13px; }
.logic-row:last-child, .part-row:last-child { border-bottom: 0; }
dl { display: grid; gap: 10px; margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
dt { color: var(--muted); }
dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; }
.note { padding: 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--panel-2); }
.note strong { font-size: 12px; }
.note p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

html[data-theme="light"] .left-panel, html[data-theme="light"] .right-panel { box-shadow: var(--shadow); }
html[data-theme="light"] .control-section, html[data-theme="light"] .future-panel,
html[data-theme="light"] .preset-button, html[data-theme="light"] .model-pose-controls,
html[data-theme="light"] .model-part-calibration,
html[data-theme="light"] .model-display-toggle,
html[data-theme="light"] .model-effect-control { border-radius: 8px; }
html[data-theme="light"] .model-effect-control select { background: #fff; }
html[data-theme="light"] input[type="range"] { accent-color: #e60023; }
html[data-theme="light"] .linear-import-panel,
html[data-theme="light"] .linear-point-card { border-radius: 8px; background: var(--panel-2); }
html[data-theme="light"] .linear-point-card input,
html[data-theme="light"] .linear-grid input,
html[data-theme="light"] .linear-grid select,
html[data-theme="light"] .number-input { background: #fff; }
html[data-theme="light"] .linear-demo-button {
  color: #fff;
  border-color: #e60023;
  background: #e60023;
}
html[data-theme="light"] .mode-button.is-active,
html[data-theme="light"] .theme-switch [data-theme-choice="light"] {
  color: #fff;
  border-color: #e60023;
  background: #e60023;
}
html[data-theme="light"] .linear-actions button { color: var(--text); background: #fff; }
html[data-theme="light"] .linear-actions button:hover,
html[data-theme="light"] .linear-demo-button:hover { color: #fff; border-color: #e60023; background: #e60023; }
html[data-theme="light"] .stage { background: #f6f6f3; }
html[data-theme="light"] .hud, html[data-theme="light"] .axis-legend { background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
html[data-theme="light"] .hud strong { color: var(--text); }
html[data-theme="light"] .view-controls { background: rgba(255,255,255,.9); backdrop-filter: blur(14px); }
html[data-theme="light"] .view-controls button { color: var(--muted); background: transparent; }
html[data-theme="light"] .view-controls button:hover { color: #fff; background: #e60023; }

@media (max-width: 1040px) {
  .shell { grid-template-columns: 400px 1fr; }
  .right-panel { display: none; }
}
@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; height: auto; min-height: 100vh; overflow: auto; }
  .left-panel { min-height: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { height: auto; min-height: 520px; }
}
