:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  --bg: #0b100d;
  --panel: #141c16;
  --raised: #1b261e;
  --edge: #2b3b30;
  --text: #e3ece5;
  --muted: #91a194;
  --green: #61d996;
  --orange: #efaa70;
}
* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, select, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, select {
  color: var(--text); background: var(--raised);
  border: 1px solid var(--edge); border-radius: 10px; min-height: 35px; padding: 6px 10px;
}
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.app { max-width: 1100px; margin: auto; padding: 0 12px 20px; }
.topbar {
  display: flex; align-items: center; gap: 9px;
  position: sticky; z-index: 5; top: 0; padding: 10px 0;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg);
}
.topbar h1 { font-size: 15px; letter-spacing: .14em; font-variant: small-caps; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; }
.topbar select { min-width: 0; max-width: 220px; }
.back {
  width: 35px; height: 35px; flex: 0 0 35px; color: var(--muted);
  display: grid; place-items: center; border: 1px solid var(--edge); border-radius: 10px;
}
.back svg { width: 18px; height: 18px; }
.toolbar, .toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.toolbar { justify-content: space-between; padding: 3px 0 10px; }
.toolbar-end { margin-left: auto; }
.segmented { display: flex; gap: 3px; border-radius: 11px; padding: 3px; background: #151f18; }
.segmented button { border: 0; background: none; color: #abbbae; font-size: 12px; border-radius: 8px; min-height: 32px; }
.segmented button[aria-pressed=true] { background: #2b5039; color: #e1ffe9; }
.icon-button { display: grid; place-items: center; width: 36px; padding: 5px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button[aria-pressed=true] { background: #2b5039; border-color: #66ae7c; color: var(--green); }
.icon-button .shackle-locked { display: none; }
.icon-button[aria-pressed=true] .shackle-locked { display: block; }
.icon-button[aria-pressed=true] .shackle-unlocked { display: none; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.metric { min-width: 0; background: var(--panel); border-radius: 10px; padding: 10px; }
.metric span { color: var(--muted); font-size: 10px; letter-spacing: .12em; display: block; margin-bottom: 4px; }
.metric strong { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.scene-panel { margin: 10px 0; overflow: hidden; border: 1px solid var(--edge); border-radius: 12px; background: var(--panel); }
.scene-head, .scene-actions { display: flex; justify-content: space-between; align-items: center; padding: 7px 11px; gap: 8px; }
.scene-head { background: #1b261e; color: #b9cabc; letter-spacing: .14em; font-variant: small-caps; font-weight: 600; font-size: 13px; }
.scene-head button { min-width: 32px; height: 30px; min-height: 30px; padding: 0; font-size: 21px; }
#scene3d { position: relative; height: clamp(340px, 57dvh, 700px); background: #101712; overflow: hidden; touch-action: none; }
#scene3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-label { position: absolute; pointer-events: none; transform: translate(-50%,-50%); padding: 3px 7px; border-radius: 7px; border: 1px solid #539f6c; background: #162c1ded; font-size: 11px; color: #daffe6; font-weight: 700; }
.scene-label.mirror { border-color: #ab7b50; background: #352416ed; color: #ffe5c3; }
.scene-actions { min-height: 45px; font-size: 11px; color: var(--muted); background: #151f18; }
.scene-actions #drag-plane {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(228px, calc(100vw - 143px));
}
.scene-actions #drag-plane button { min-width: 0; min-height: 30px; padding: 4px 7px; }
@media (min-width: 560px) {
  .scene-actions #drag-plane { grid-template-columns: repeat(6, minmax(0, 1fr)); width: auto; }
  .scene-actions #drag-plane button { min-width: 42px; }
}
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-top: 14px; }
.control { min-width: 0; }
.control-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: #aab9ac; margin-bottom: 6px; }
.control-header output { color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.control input[type=range] {
  display: block; width: 100%; height: 19px; margin: 0;
  appearance: none; -webkit-appearance: none; background: transparent; touch-action: pan-y;
}
.control input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 10px; background: var(--range-bg, #2c3b30);
}
.control input[type=range]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; margin-top: -4.5px; background: var(--green); border: 2px solid var(--bg);
}
.control input[type=range].invalid::-webkit-slider-thumb { background: #ee7176; }
.control input[type=range]::-moz-range-track { height: 5px; border-radius: 10px; background: var(--range-bg, #2c3b30); }
.control input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg);
}
.control input[type=range].invalid::-moz-range-thumb { background: #ee7176; }
.mirror-readouts { display: flex; flex-wrap: wrap; gap: 8px 15px; color: #e8b27c; font-size: 12px; margin: 13px 0 9px; letter-spacing: .04em; }
.preview-wrap { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; }
#preview { display: block; width: 100%; height: 130px; }
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 9px; align-items: center;
  color: var(--muted); font-size: 12px; border-top: 1px solid var(--edge); margin-top: 14px; padding-top: 12px;
}
.footer label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.footer input { accent-color: var(--green); }
#status.warning { color: #ee9e90; }
.hint { margin: 10px 0 0; font-size: 11px; line-height: 1.5; color: #778c7d; }
@media (max-width: 550px) {
  .app { padding-inline: 8px; }
  .topbar h1 { font-size: 13px; }
  .topbar select { font-size: 12px; max-width: 46%; }
  .metric { padding: 9px 6px; }
  .metric strong { font-size: 14px; }
  .metric span { font-size: 9px; letter-spacing: .08em; }
  .controls { column-gap: 10px; }
  .control-header { font-size: 11px; }
}
@media (max-width: 370px) {
  .metric strong { font-size: 12px; }
  .segmented button { padding-inline: 7px; }
}
