:root {
  color-scheme: light;
  --paper: #e9e8e2;
  --panel: #f7f6f1;
  --ink: #191a1d;
  --muted: #71716e;
  --line: #d7d5cd;
  --line-strong: #bbb8ae;
  --stage: #090a0d;
  --stage-text: #f6f3eb;
  --stage-muted: #9c9a95;
  --cyan: #72d9dc;
  --gold: #efbd58;
  --coral: #ef7966;
  --violet: #aca2ed;
  --radius: 6px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

button, input, select { font: inherit; }
button, select, input { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100svh;
}

.control-panel {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  height: 100svh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  overflow: hidden;
  background: var(--ink);
  border-radius: 50%;
}

.brand-mark i {
  position: absolute;
  left: 5px;
  top: 18px;
  width: 34px;
  height: 11px;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  transform: rotate(-24deg);
}
.brand-mark i:nth-child(2) { transform: rotate(26deg); border-color: var(--gold); }
.brand-mark b {
  position: absolute;
  left: 19px;
  top: 19px;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px var(--gold);
}

.brand p, .brand h1 { margin: 0; letter-spacing: 0; }
.brand p { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.brand h1 { font-size: 18px; font-weight: 650; }

.control-section { padding: 21px 28px 23px; border-bottom: 1px solid var(--line); }
.scene-section { padding-top: 18px; padding-bottom: 20px; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
  margin-bottom: 15px;
}
.section-heading h2 { margin: 0; font-size: 13px; font-weight: 700; }
.section-index { color: var(--line-strong); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.icon-button {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 20px;
}
.icon-button:hover { color: var(--ink); background: var(--paper); }
.field-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 650; }
.select-wrap { position: relative; }
.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}
select {
  width: 100%;
  height: 40px;
  padding: 0 38px 0 12px;
  appearance: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
}

.range-control { display: block; }
.range-control + .range-control { margin-top: 16px; }
.range-control > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.range-control b, .switch-control b { font-size: 11px; font-weight: 600; }
.range-control output { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 14px; margin: 0; appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--range-progress, 50%), var(--line) var(--range-progress, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  appearance: none;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; background: var(--panel); border: 2px solid var(--ink); border-radius: 50%; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.segmented button { min-width: 0; height: 32px; padding: 0 8px; color: var(--muted); background: transparent; border: 0; border-radius: 4px; font-size: 11px; font-weight: 650; }
.segmented button[aria-pressed="true"] { color: var(--stage-text); background: var(--ink); }
.switch-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 17px; }
.switch-control { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control > span { position: relative; width: 28px; height: 16px; flex: 0 0 28px; background: var(--line-strong); border-radius: 10px; transition: background .2s ease; }
.switch-control > span::after { position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; content: ""; background: #fff; border-radius: 50%; transition: transform .2s ease; }
.switch-control input:checked + span { background: var(--ink); }
.switch-control input:checked + span::after { transform: translateX(12px); }
.interaction-hint { min-height: 30px; margin: 15px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.panel-footer { display: flex; justify-content: space-between; margin-top: auto; padding: 16px 28px; color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; }

.simulation-stage {
  position: relative;
  min-width: 0;
  height: 100svh;
  overflow: hidden;
  background: var(--stage);
  color: var(--stage-text);
  isolation: isolate;
}
#space-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.stage-header {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  min-height: 96px;
  padding: 20px 28px;
  pointer-events: none;
}
.scene-title { display: flex; align-items: center; gap: 11px; }
.live-dot { width: 7px; height: 7px; background: var(--cyan); border-radius: 50%; box-shadow: 0 0 12px rgba(114, 217, 220, .65); }
.scene-title div { display: grid; gap: 4px; }
.scene-title span { color: var(--stage-muted); font-size: 9px; font-weight: 700; }
.scene-title strong { font-size: 13px; font-weight: 650; }
.metrics { display: flex; align-items: stretch; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); background: rgba(9,10,13,.76); }
.metrics > div { display: grid; min-width: 82px; gap: 4px; padding: 10px 14px; text-align: center; }
.metrics > div + div { border-left: 1px solid rgba(255,255,255,.1); }
.metrics span { color: var(--stage-muted); font-size: 9px; }
.metrics strong { color: var(--stage-text); font: 600 13px ui-monospace, SFMono-Regular, Consolas, monospace; }
.metrics small { color: var(--stage-muted); font-size: 8px; }
.stage-actions { display: flex; justify-content: flex-end; gap: 8px; pointer-events: auto; }
.stage-actions button { display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 13px; color: var(--stage-text); background: rgba(9,10,13,.76); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); font-size: 11px; font-weight: 650; }
.stage-actions button:hover { border-color: rgba(255,255,255,.38); }
.stage-actions .primary-action { color: var(--stage); background: var(--gold); border-color: var(--gold); }

.canvas-status { position: absolute; z-index: 2; left: 28px; bottom: 23px; display: flex; align-items: center; gap: 11px; color: var(--stage-muted); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; pointer-events: none; }
.canvas-status i { width: 38px; height: 1px; background: rgba(255,255,255,.25); }
.scale-mark { position: absolute; z-index: 2; right: 28px; bottom: 22px; display: grid; justify-items: end; gap: 6px; color: var(--stage-muted); pointer-events: none; }
.scale-mark span { width: 76px; height: 5px; border: 1px solid rgba(255,255,255,.34); border-top: 0; }
.scale-mark small { font: 8px ui-monospace, SFMono-Regular, Consolas, monospace; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .brand, .control-section { padding-left: 22px; padding-right: 22px; }
  .stage-header { grid-template-columns: 1fr auto; padding: 18px; }
  .metrics { position: absolute; top: 72px; left: 18px; }
  .stage-actions { grid-column: 2; grid-row: 1; }
}

@media (max-width: 720px) {
  .app-shell { display: flex; flex-direction: column; }
  .simulation-stage { order: 0; height: 62svh; min-height: 430px; }
  .control-panel { order: 1; height: auto; overflow: visible; border-right: 0; }
  .brand { min-height: 86px; }
  .control-section { padding-top: 18px; padding-bottom: 20px; }
  .stage-header { min-height: 74px; padding: 15px 16px; }
  .metrics { top: 74px; left: 16px; right: 16px; width: fit-content; }
  .metrics > div { min-width: 70px; padding: 8px 10px; }
  .canvas-status { left: 16px; bottom: 17px; }
  .scale-mark { right: 16px; bottom: 16px; }
  .action-label { display: none; }
  .stage-actions button { width: 38px; padding: 0; }
}

@media (max-width: 390px) {
  .simulation-stage { height: 60svh; min-height: 390px; }
  .scene-title strong { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .metrics > div { min-width: 66px; }
  .scale-mark { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
