: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;
  --fit-color: #9ad9ff;
  --fill-color: #ffbc70;
}
* { 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; }
#sizing-mode[data-mode="both"] button[data-mode="fit"] { color: var(--fit-color); }
#sizing-mode[data-mode="both"] button[data-mode="fill"] { color: var(--fill-color); }
.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(2, 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: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
#screen-size[data-mode="fit"] { color: var(--fit-color); }
#screen-size[data-mode="fill"] { color: var(--fill-color); }
.size-comparison {
  display: grid;
  grid-template-columns: max-content max-content min-content max-content min-content;
  align-items: baseline;
  column-gap: 5px;
  row-gap: 5px;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
  font-size: 17px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.size-row { display: contents; }
.size-key { font-size: 10px; font-weight: 700; padding-right: 7px; }
.size-width, .size-height { text-align: right; }
.size-cross, .size-unit { text-align: center; }
.fit-row { color: var(--fit-color); }
.fill-row { color: var(--fill-color); }
.scene-panel { position: relative; 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 {
  position: absolute; top: 8px; right: 8px; left: 8px; z-index: 2;
  pointer-events: none; padding: 0; background: none; font-size: 13px;
}
.scene-head button, .scene-head .mode-legend { pointer-events: auto; }
.scene-head button { background: #1b261edb; }
.scene-head button { min-width: 32px; height: 30px; min-height: 30px; padding: 0; font-size: 21px; }
.scene-head #distortion-quality,
.scene-head #screen-drag-mode { padding: 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.scene-head #distortion-quality[aria-pressed=true],
.scene-head #screen-drag-mode[aria-pressed=true] { color: #a9ffd0; background: #245239eb; border-color: #53ad7d; }
.mode-legend { display: flex; gap: 12px; align-items: center; margin-left: auto; font-size: 11px; letter-spacing: .04em; }
.mode-legend .fit-key { color: var(--fit-color); }
.mode-legend .fill-key { color: var(--fill-color); }
#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; }
#scene3d #project-mode[aria-pressed=true]{
  background:#e1f0e8;color:#0b1710;border-color:#ffffff;
}
#project-settings[hidden]{display:none!important;}
#project-settings{
  padding:9px 12px 10px;background:#16231bb8;
  border-top:1px solid #35513c;
}
#project-settings .control-header{margin-bottom:4px;}
#project-settings label,.control-header label[for]{cursor:default;touch-action:manipulation;}
#project-settings input[type=range]{
  width:100%;height:28px;margin:0;display:block;background:transparent;
  appearance:none;-webkit-appearance:none;touch-action:none;
}
#project-settings input[type=range]::-webkit-slider-runnable-track{
  height:11px;border-radius:9px;background:linear-gradient(90deg,#070b09,#35463b,#8d9889,#fff);
}
#project-settings input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;appearance:none;width:18px;height:18px;
  background:#e7f7ed;border:2px solid #254b37;border-radius:50%;margin-top:-4px;
}
#project-settings input[type=range]::-moz-range-track{
  height:11px;border-radius:9px;background:linear-gradient(90deg,#070b09,#35463b,#8d9889,#fff);
}
#project-settings input[type=range]::-moz-range-thumb{
  width:18px;height:18px;background:#e7f7ed;border:2px solid #254b37;border-radius:50%;
}
#scene3d #project-mode{min-width:68px;font-size:11px;font-weight:750;letter-spacing:.02em;}
.axes-indicator {
  position: absolute; left: 10px; bottom: 10px;
  width: 96px; height: 96px; pointer-events: none; z-index: 2;
  overflow: visible;
}
.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: #a0b0be; background: #27343eea; color: #e8f0f8; }
.scene-actions { min-height: 45px; flex-direction: column; align-items: stretch; font-size: 11px; color: var(--muted); background: #151f18; }
.scene-head { gap: 4px; left: 6px; right: 6px; }
.scene-head button { flex: 0 0 auto; }
.scene-head #distortion-quality,
.scene-head #screen-drag-mode,
.scene-head #walk-mode { padding-inline: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0; }
.scene-head #reset-view { width: 31px; }
@media(max-width:390px) {
  .scene-head #walk-mode { width: 42px; flex: 0 0 42px; min-width: 42px; padding-inline: 2px; }
}
.scene-visual-controls { flex: 0 1 auto; min-width: 0; display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; pointer-events: auto; }
.scene-visual-controls[hidden] { display:none !important; }
.scene-visual-controls .scene-color-compact {
  display: flex; align-items: center; justify-content: center;
  position:relative; width: 55px; height: 30px; flex: 0 0 55px;
  border: 1px solid var(--edge); border-radius: 8px;
  background: #1b261edb; color: #e5f5eb; font: 700 10px system-ui;
  cursor: pointer;
}
.scene-color-compact select { position: absolute; inset:0; width: 100%; height:100%;
  opacity:0; cursor:pointer; appearance:none; }
.scene-visual-controls #pixel-grid-toggle { padding-inline:5px; min-width:50px; font-size:10px; }
.scene-visual-controls button[aria-pressed=true] { color:#a9ffd0; background:#245239eb; border-color:#53ad7d; }
.scene-visual-controls #pixel-grid-step { width: 53px; flex: 0 0 53px; min-width: 0;
  padding: 4px 0; font-size: 10px; height:30px; background:#1b261edb; }
.scene-visual-controls #pixel-grid-step[hidden] { display:none!important; }
.scene-actions #color-range { align-self:flex-start; font-size:11px; font-variant-numeric:tabular-nums;
  color:#a4c7b2; margin-left:5px; }
.scene-actions #color-range[hidden] { display:none!important; }
@media(max-width:390px) {
 .scene-head { gap:3px; left:4px; right:4px; }
 .scene-head #distortion-quality,
 .scene-head #screen-drag-mode,.scene-head #walk-mode { font-size:9px; padding-inline:4px; }
 .scene-visual-controls { gap:3px; }
 .scene-visual-controls .scene-color-compact { width:49px; flex-basis:49px; }
 .scene-visual-controls #pixel-grid-toggle { min-width:45px; padding-inline:3px; font-size:9px; }
 .scene-visual-controls #pixel-grid-step { width:44px; flex-basis:44px; font-size:9px; }
}
.scene-actions #drag-plane {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  width: min(100%, 560px); margin-inline: auto;
}
.scene-actions #drag-plane button { min-width: 0; min-height: 36px; padding: 4px 2px; }
.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; }
.slider-label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.slider-label svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.slider-label label { min-width: 0; }
.control input[type=range], .aim-control input[type=range] {
  display: block; width: 100%; height: 26px; margin: 0;
  appearance: none; -webkit-appearance: none; background: transparent; touch-action: pan-y;
}
.control input[type=range]::-webkit-slider-runnable-track,
.aim-control input[type=range]::-webkit-slider-runnable-track {
  height: 9px; border-radius: 10px; background: var(--range-bg, #2c3b30);
}
.control input[type=range]::-webkit-slider-thumb,
.aim-control input[type=range]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px;
  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,
.aim-control input[type=range]::-moz-range-track { height: 9px; border-radius: 10px; background: var(--range-bg, #2c3b30); }
.control input[type=range]::-moz-range-thumb,
.aim-control input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg);
}
.control input[type=range].invalid::-moz-range-thumb { background: #ee7176; }
.aim-control { min-width: 0; }
.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; }
@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: 18px; }
  .size-comparison { font-size: 15px; column-gap: 3px; }
  .size-key { font-size: 9px; padding-right: 5px; }
  .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: 16px; }
  .segmented button { padding-inline: 7px; }
}

.aim-track { position: relative; padding-bottom: 0; }
.aim-control .aim-track input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #2c3b30 0%, #2c3b30 calc(50% - 1px), #c2d7c9 calc(50% - 1px), #c2d7c9 calc(50% + 1px), #2c3b30 calc(50% + 1px), #2c3b30 100%);
}
.aim-control .aim-track input[type="range"]::-moz-range-track {
  background: linear-gradient(to right, #2c3b30 0%, #2c3b30 calc(50% - 1px), #c2d7c9 calc(50% - 1px), #c2d7c9 calc(50% + 1px), #2c3b30 calc(50% + 1px), #2c3b30 100%);
}
.aim-zero { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: 10px; color: #b0c7b7; pointer-events: none; line-height: 1; }
#projector-dialog {
  width: min(480px, calc(100vw - 22px)); max-height: calc(100dvh - 30px); overflow: auto;
  border: 1px solid #536c59; border-radius: 13px; padding: 17px;
  background: #151f18; color: var(--text); box-shadow: 0 16px 65px #0009;
}
#projector-dialog::backdrop { background: #000b; }
#projector-dialog h2 { font-size: 18px; margin: 0 0 14px; }
.projector-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.projector-fields label { display: flex; flex-direction: column; min-width: 0; gap: 5px; font-size: 12px; color: var(--muted); }
.projector-fields .projector-wide { grid-column: 1 / -1; }
.projector-fields input {
  min-width: 0; width: 100%; min-height: 41px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--edge); background: #0c150f; color: var(--text); font-size: 16px;
}
.projector-fields input:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.projector-form-error { color: #ffaaa5; margin: 10px 0 0; font-size: 12px; }
.projector-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.projector-form-actions button { min-height: 41px; }
.projector-form-actions .projector-save { border-color: #478a60; background: #275239; color: #e3ffe8; }
@media(max-width: 550px) {
  #orientation button { font-size: 11px; padding-inline: 7px; }
  .toolbar-end { justify-content: flex-end; }
}


/* Compact room selector and image-distribution strip. */
.room-toolbar { display:flex; align-items:center; gap:6px; margin:0 0 9px; }
.room-toolbar select { flex:1; min-width:0; max-width:380px; }
.room-toolbar button { white-space:nowrap; font-size:11px; font-weight:600; min-height:37px; }
.room-toolbar button:disabled { opacity:.36; cursor:default; }
#room-delete { font-size:20px; padding:0 11px; }
.room-coverage { display:flex; gap:5px 14px; flex-wrap:wrap; margin:0 0 10px;
  font-size:10px; color:#91ae9b; font-variant-numeric:tabular-nums; letter-spacing:.02em; }
.room-coverage span { white-space:nowrap; }
.room-coverage .room-surface-stat[hidden] { display:none!important; }
.room-coverage .projection-area-stat { color:#d9efe0; }
.room-coverage .projection-area-stat b { color:#a9ffce; }
.room-coverage b { color:#90e7b0; font-size:11px; font-weight:650; padding-left:3px; }
#room-dialog {
  width:min(760px,calc(100vw - 12px)); max-height:calc(100dvh - 16px);
  background:#141c16; color:var(--text); border:1px solid #435e4a;
  padding:12px; border-radius:12px; overflow-y:auto; overscroll-behavior:contain;
}
#room-dialog::backdrop { background:#000d; }
.room-dialog-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:9px; }
.room-dialog-head h2 { font-size:17px; margin:0; }
.room-dialog-head .segmented button { min-width:54px; }
#room-dialog label { font-size:10px; letter-spacing:.035em; color:var(--muted);
  display:flex; flex-direction:column; gap:4px; min-width:0; }
#room-dialog input { width:100%; min-width:0; border:1px solid #3b5141; background:#0b140e;
  border-radius:7px; padding:7px; color:var(--text); font-size:16px; height:37px; }
.room-name-label { margin-bottom:9px; }
.room-dimensions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; margin-bottom:9px; }
.room-editor-viewport { height:min(44dvh,410px); min-height:210px; background:#0e1611;
  border:1px solid #344b3a; border-radius:9px; overflow:hidden; }
#room-plan,#room-editor-3d,#room-editor-3d canvas { width:100%; height:100%; display:block; }
#room-plan { touch-action:none; }
#room-editor-3d { touch-action:none; }
#room-editor-3d canvas { touch-action:none; }
.room-grid { stroke:#2b4231; stroke-width:1; }
.room-outline { fill:#284632; fill-opacity:.68; stroke:#95d5aa; stroke-width:3; }
.room-vertex { fill:#74e9ae; stroke:#0b1510; stroke-width:3; cursor:grab; }
.room-vertex.selected { fill:#ffcd80; stroke:#f6d49e; }
.room-midpoint { fill:#ce965f; stroke:#263c2e; stroke-width:2; cursor:copy; }
.room-main-label { fill:#9ed2ff; font:700 14px "Segoe UI",sans-serif; }
.room-point-fields { display:grid; grid-template-columns:auto 1fr 1fr auto; gap:7px;
  align-items:end; margin-top:9px; }
#room-point-index { font-size:10px; color:#c4d5c8; align-self:center; white-space:nowrap; }
#room-remove-point { min-height:37px; font-size:10px; padding:4px 8px; }
#room-remove-point:disabled { opacity:.35; }
.room-form-actions { display:flex; justify-content:flex-end; gap:7px; margin-top:10px; }
.room-form-actions button { min-height:39px; min-width:90px; font-size:12px; }
.room-form-actions .room-save { background:#28583c; border-color:#478a60; }
@media(max-width:550px){
  .room-toolbar button { font-size:10px; padding-inline:8px; }
  #room-dialog { padding:9px; }
  .room-coverage { gap:4px 10px; }
  .room-point-fields { grid-template-columns:1fr 1fr auto; }
  #room-point-index { grid-column:1/-1; }
  .room-editor-viewport { height:min(37dvh,350px); min-height:190px; }
}


/* Compact choice selectors. Only the current choice is visible until opened. */
.toolbar { position:relative; z-index:5; justify-content:space-between; align-items:center; }
.toolbar-end { margin-left:auto; }
.segmented.collapsible { position:relative; display:inline-flex; border:1px solid #26372e;
  background:#162119; padding:2px; min-width:0; overflow:visible; isolation:isolate; }
.segmented.collapsible button { white-space:nowrap; font-size:11px; }
.segmented.collapsible button[aria-pressed=true] { padding-right:27px; min-width:82px; }
.segmented.collapsible button[aria-pressed=true]::after {
  content:''; position:absolute; right:10px; top:50%; width:7px; height:7px;
  border-right:2px solid #adc2b2; border-bottom:2px solid #adc2b2;
  transform:translateY(-70%) rotate(45deg); pointer-events:none;
}
.segmented.collapsible:not(.open) button[aria-pressed=false] { display:none; }
.segmented.collapsible.open { z-index:20; }
.segmented.collapsible.open button[aria-pressed=false] {
  display:block; position:absolute; left:0; top:calc(100% + var(--choice-offset, 2px));
  width:100%; min-height:35px; border:1px solid #4a6953;
  background:#20362a; box-shadow:0 8px 20px #0007; color:#eff8f0;
  padding:6px 5px; font-size:11px;
}
.segmented.collapsible.open button[aria-pressed=false]:hover { background:#31513e; }
#sizing-mode.collapsible { min-width:80px; }
#orientation.collapsible { min-width:109px; }
#mirror-count.collapsible { min-width:115px; }
.projector-room-row { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:2px 0 9px; }
.projector-room-row select,.projector-room-row button { min-width:0; width:100%; min-height:43px; }
.projector-room-row select { max-width:none; }
#room-trigger,#projector-trigger { display:flex; align-items:center; gap:8px; text-align:left; font-size:13px; }
#room-trigger-name,#projector-trigger-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.picker-chevron { flex:none; width:18px; height:18px; color:#adc2b2; pointer-events:none; }
#screen-move { font-size:10px; font-weight:700; line-height:1; min-width:105px;
  width:auto; padding:7px 9px; margin-left:auto; }
#screen-move[aria-pressed=true] { background:#325a48; color:#c2ffe0; }
.scene-head { justify-content:flex-end; }
.axes-indicator { left:1px; bottom:1px; width:70px; height:70px; }
.scene-label { display:none!important; }
.room-coverage { gap:5px 17px; }
#room-picker-dialog,#projector-picker-dialog,#room-dialog {
  color:var(--text); background:#141e17; border:1px solid #4b6654; border-radius:13px;
  max-height:calc(100dvh - 14px); box-shadow:0 18px 65px #000b;
}
#room-picker-dialog::backdrop,#projector-picker-dialog::backdrop,#room-dialog::backdrop { background:#000d; }
#room-picker-dialog,#projector-picker-dialog { width:min(440px,calc(100vw - 16px)); padding:13px; }
.room-picker-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.room-picker-head h2 { margin:0; font-size:14px; font-weight:700; letter-spacing:.08em; }
#room-picker-close,#projector-picker-close { font-size:21px; padding:0 12px; }
.room-picker-list { display:flex; flex-direction:column; gap:5px; max-height:48dvh; overflow-y:auto; }
.room-list-item { display:flex; align-items:center; justify-content:space-between; gap:8px;
  width:100%; padding:11px 12px; text-align:left; border-radius:8px; }
.room-list-item strong { min-width:0; overflow:hidden; text-overflow:ellipsis; font-weight:600; }
.room-list-item span { color:#a2b4a7; white-space:nowrap; font-size:11px; }
.room-list-item[aria-pressed=true] { background:#28513a; border-color:#639677; }
.room-picker-actions { display:grid; grid-template-columns:1fr 1fr 1fr; gap:7px; margin-top:12px; }
.room-picker-actions button { min-width:0; font-size:11px; padding:9px 4px; }
.room-picker-actions button:disabled { opacity:.4; cursor:default; }
#room-dialog { width:min(880px,calc(100vw - 14px)); padding:10px; overflow-y:auto; }
.room-editor-fields { display:grid; grid-template-columns:minmax(0,2fr) minmax(100px,1fr); gap:8px; margin-bottom:9px; }
.room-editor-viewport { height:min(50dvh,490px); min-height:240px; position:relative;
  background:#101714; border-color:#42534b; }
#room-plan,#room-editor-3d { width:100%; height:100%; display:block; touch-action:none; }
#room-editor-3d canvas { width:100%; height:100%; display:block; touch-action:none; }
.room-grid-layer line { stroke:#35423d; stroke-width:.85; }
.room-plan-fill { fill:#707a76; fill-opacity:.20; stroke:none; }
.room-edge { stroke:#b6c0bc; stroke-width:2.8; }
.room-edge.selected { stroke:#f0f2ef; stroke-width:4; }
.room-edge-hit { stroke:transparent; stroke-width:20; pointer-events:stroke; cursor:pointer; }
.room-handle { fill:#ccd6d2; stroke:#1c2b23; stroke-width:2.5; cursor:grab; }
.room-handle.selected { fill:#ffffff; stroke:#687a70; stroke-width:3; }
.room-length-label { fill:#e6efeb; stroke:#131b16; stroke-width:3; paint-order:stroke;
  font-size:11px; font-weight:650; pointer-events:none; }
.room-area-label { fill:#f1f7f3; font-size:15px; font-weight:750;
  stroke:#18251d; stroke-width:3; paint-order:stroke; pointer-events:none; }
.room-plan-controls { display:flex; align-items:center; flex-wrap:nowrap; gap:8px;
  margin:9px 0; min-height:34px; font-size:11px; color:#a5b9ab; }
.room-plan-controls .room-snap-label { display:flex!important; flex-direction:row!important;
  align-items:center; gap:6px!important; cursor:pointer; margin-right:auto; white-space:nowrap; }
#room-snap { width:18px!important; height:18px!important; accent-color:#73d3a0; }
#room-area,#room-zoom { white-space:nowrap; }
.room-plan-controls button { min-height:30px; height:30px; min-width:30px; padding:0 5px; font-size:16px; }
.room-point-fields { grid-template-columns:auto minmax(0,1fr) minmax(0,1fr) auto auto; }
.room-point-fields button { font-size:10px; white-space:nowrap; padding:4px 6px; }
#room-add-point { color:#adf4c7; }
@media(max-width:600px) {
  #room-dialog { padding:8px; }
  .room-editor-viewport { height:min(43dvh,420px); min-height:205px; }
  .room-plan-controls { gap:5px; font-size:10px; }
  #room-zoom { display:none; }
  .room-point-fields { grid-template-columns:1fr 1fr auto auto; gap:5px; }
  #room-point-index { grid-column:1/-1; }
  .room-point-fields button { padding:3px 5px; }
}
@media(max-width:400px) {
  .toolbar { gap:4px; }
  #mirror-count.collapsible { min-width:90px; }
  #orientation.collapsible { min-width:89px; }
  #sizing-mode.collapsible { min-width:68px; }
  .segmented.collapsible button[aria-pressed=true] { font-size:10px; min-width:0; padding:5px 18px 5px 5px; }
  .segmented.collapsible button[aria-pressed=true]::after { right:4px; }
  .projector-room-row select,.projector-room-row button { font-size:11px; }
}

#room-plan[hidden], #room-editor-3d[hidden], #room-plan-controls[hidden] { display:none !important; }

/* Shared modal typography, wall finish and first-person scene controls. */
#projector-trigger { min-width:0; }
#projector-picker-dialog button,#room-picker-dialog button,
#projector-dialog button,#room-dialog button { font-size:12px; }
#projector-picker-dialog .room-picker-actions button,#room-picker-dialog .room-picker-actions button {
  font-size:11px;font-weight:600;
}
.room-editor-fields { grid-template-columns:minmax(0,2fr) minmax(90px,1fr) auto; }
.room-color-label { min-width:70px!important; }
#room-wall-color { width:68px!important;height:37px!important;padding:3px!important;cursor:pointer; }
.aim-control .aim-track::after {content:"";position:absolute;top:8px;left:50%;
  transform:translateX(-50%);height:11px;width:2px;background:#b5cbb9;pointer-events:none;}
#walk-mode {padding:0 10px;min-width:58px;width:auto;font-size:11px;font-weight:700;margin-right:5px;}
#walk-mode[aria-pressed=true] {background:#2d5a41;color:#c7f9dd;}
.scene-panel {position:relative;}
#walk-controls {
  position:absolute;bottom:10px;right:10px;z-index:8;
  display:flex;flex-direction:column;align-items:center;gap:7px;
  pointer-events:auto;
}
#walk-controls[hidden],#walk-settings[hidden],#distortion-legend[hidden] {display:none!important;}
#walk-fine {width:100%;min-height:32px;font-size:11px;font-weight:700;
  background:#17251de8;border:1px solid #53705a;letter-spacing:.03em;}
#walk-fine[aria-pressed=true] {background:#42634f;color:#d8ffe5;border-color:#87c59f;}
.walk-pad {display:grid;grid-template-columns:repeat(3,46px);grid-template-rows:repeat(2,46px);gap:5px;}
.walk-pad button {font-size:23px;min-width:46px;min-height:46px;background:#1b2d23e9;
  border-color:#4d6957;border-radius:10px;touch-action:none;user-select:none;}
.walk-pad button:active {background:#42765a;}
.walk-pad [data-walk=forward] {grid-column:2;grid-row:1;}
.walk-pad [data-walk=left] {grid-column:1;grid-row:2;}
.walk-pad [data-walk=back] {grid-column:2;grid-row:2;}
.walk-pad [data-walk=right] {grid-column:3;grid-row:2;}
#walk-settings {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;
  padding:10px 12px 12px;border-top:1px solid #344739;background:#121d17;}
.walk-setting {min-width:0;}
.walk-setting .control-header {margin:0 0 4px;}
.walk-setting input[type=range] {display:block;width:100%;height:29px;margin:0;
  appearance:none;-webkit-appearance:none;background:transparent;touch-action:pan-y;}
.walk-setting input[type=range]::-webkit-slider-runnable-track {height:10px;border-radius:9px;background:#38533e;}
.walk-setting input[type=range]::-webkit-slider-thumb {-webkit-appearance:none;appearance:none;width:21px;
  height:21px;border-radius:50%;background:#8dd5a7;border:2px solid #142019;margin-top:-5.5px;}
.walk-setting input[type=range]::-moz-range-track {height:10px;border-radius:9px;background:#38533e;}
.walk-setting input[type=range]::-moz-range-thumb {width:21px;height:21px;border-radius:50%;background:#8dd5a7;}
#distortion-legend {display:flex;align-items:center;gap:8px;padding:5px 12px 8px;
  color:#a3b5a9;font-size:9px;font-weight:650;letter-spacing:.03em;line-height:1;}
#distortion-legend .distortion-gradient {height:8px;border-radius:3px;flex:1;min-width:25px;
  background:linear-gradient(90deg,#31c46c 0%,#f5d13b 40%,#fa742d 72%,#dc2b36 100%);}
.scene-panel.walking .scene-actions {display:none;}
#scene3d.walk-look {cursor:grab;}
#scene3d.walk-look:active {cursor:grabbing;}
.scene-panel:fullscreen {display:flex;flex-direction:column;width:100%;height:100dvh;
  margin:0;border:0;border-radius:0;background:#101712;padding:0;}
.scene-panel:fullscreen #scene3d {flex:1 1 auto;min-height:0;height:auto;}
.scene-panel:fullscreen #walk-settings {flex:0 0 auto;padding:8px 12px;}
.scene-panel:fullscreen #distortion-legend {flex:0 0 auto;}
.scene-panel:fullscreen #walk-controls {bottom:12px;right:12px;}
@media(max-width:400px){
 .walk-pad {grid-template-columns:repeat(3,42px);grid-template-rows:repeat(2,42px);}
 .walk-pad button {min-width:42px;min-height:42px;}
 #walk-settings {gap:10px;padding-inline:9px;}
}
@media(max-width:420px){
 .room-editor-fields {grid-template-columns:minmax(0,1fr) minmax(84px,.54fr) 68px;}
 .room-color-label {min-width:0!important;}
 #room-wall-color {width:100%!important;}
}

@media(max-width:340px) {
  .scene-head { gap:2px; left:3px; right:3px; }
  .scene-head #distortion-quality { width:39px; min-width:39px; padding:0; font-size:8px; }
  .scene-head #screen-drag-mode { width:44px; min-width:44px; padding:0; font-size:8px; }
  .scene-head #walk-mode { width:35px; min-width:35px; flex:0 0 35px; padding:0; font-size:8px; }
  .scene-head #reset-view { width:29px; min-width:29px; padding:0; }
  .scene-visual-controls { flex:0 0 auto; gap:2px; }
  .scene-visual-controls .scene-color-compact { width:42px; flex-basis:42px; font-size:9px; }
  .scene-visual-controls #pixel-grid-toggle { width:40px; min-width:40px; padding:0; font-size:8px; }
  .scene-visual-controls #pixel-grid-step { width:36px; flex-basis:36px; padding:0; font-size:8px; }
}

/* Independent color and pixel-grid dialogs, with dedicated viewer controls. */
.scene-head #color-settings,.scene-head #pixel-settings {
  min-width:0; padding:0 5px; font-size:10px; font-weight:700;
}
.scene-head #walk-fullscreen { min-width:30px; width:30px; padding:0; font-size:18px; }
.render-setting-dialog {
  color:var(--text); background:#141e17; border:1px solid #4b6654;
  border-radius:12px; padding:13px; width:min(400px,calc(100vw - 18px));
  max-height:calc(100dvh - 22px); box-shadow:0 18px 65px #000b;
}
.render-setting-dialog::backdrop { background:#000c; }
#color-close,#pixel-close { font-size:21px; padding:0 12px; }
.appearance-body { display:grid; grid-template-columns:110px minmax(0,1fr); gap:10px; align-items:center; }
.appearance-body label { font-size:11px; color:var(--muted); font-weight:650; }
.appearance-body select,.appearance-body button { min-width:0; width:100%; min-height:40px;
  font-size:12px; padding:8px 10px; }
.appearance-body #pixel-grid-toggle[aria-pressed=true] { background:#28513a; border-color:#63a77d; color:#d6ffe3; }
.appearance-body #pixel-grid-step[hidden] { display:none!important; }
#pixel-size-metric[hidden] { display:none!important; }
.metric-pixel { grid-column:1/-1; }
.metric-pixel .pixel-dimensions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.metric-pixel .pixel-dimensions>div { display:flex; flex-direction:column; gap:4px; min-width:0; }
.metric-pixel small { color:var(--muted); font-size:10px; }
.metric-pixel strong { font-size:clamp(12px,3.5vw,17px); letter-spacing:-.015em; }
@media(max-width:370px) {
 .scene-head #color-settings,.scene-head #pixel-settings { min-width:0; font-size:9px; padding:0 3px; }
 .scene-head #walk-fullscreen { min-width:28px; width:28px; font-size:16px; }
 .scene-head #walk-mode { min-width:35px; width:35px; flex-basis:35px; font-size:8px; }
 .scene-head #distortion-quality { min-width:39px; font-size:8px; }
 .scene-head #screen-drag-mode { min-width:44px; font-size:8px; }
 .scene-head #reset-view { min-width:28px; width:28px; }
}

.appearance-body #pixel-grid-step-label[hidden] { display:none!important; }

@media(max-width:370px) {
 .scene-head { gap:2px; left:3px; right:3px; }
 .scene-head #color-settings,.scene-head #pixel-settings { font-size:8px; padding:0 2px; }
 .scene-head #distortion-quality,.scene-head #screen-drag-mode,
 .scene-head #walk-mode { min-width:0; padding:0 2px; font-size:8px; }
 .scene-head #walk-fullscreen,.scene-head #reset-view { width:27px; min-width:27px; padding:0; }
}

/* Projector controls are direct, no one-option modal windows. */
.scene-head > #projection-color-mode,.scene-head > #pixel-grid-step {
  pointer-events:auto; flex:0 1 auto; box-sizing:border-box;
  background:#1b261edb; border:1px solid var(--edge); border-radius:8px;
  min-width:0; height:30px; min-height:30px; padding:0 3px;
  color:var(--text); font:700 10px system-ui; cursor:pointer;
}
.scene-head > #projection-color-mode,.scene-head > #pixel-grid-step {
  appearance:none; -webkit-appearance:none; text-align:center; text-align-last:center;
  padding-inline:1px;
}
.scene-head > #projection-color-mode { width:75px; }
.scene-head > #pixel-grid-step { width:56px; }
.scene-head > #pixel-grid-toggle { min-width:0; padding:0 5px; font-size:10px; font-weight:700; }
.scene-head > #pixel-grid-toggle[aria-pressed=true] {
  color:#a9ffd0; background:#245239eb; border-color:#53ad7d;
}
.scene-head > #projection-color-mode[hidden],.scene-head > #pixel-grid-step[hidden],
.scene-head > #pixel-grid-toggle[hidden] { display:none!important; }
@media(max-width:390px) {
  .scene-head > #projection-color-mode { width:60px; font-size:9px; padding:0 1px; }
  .scene-head > #pixel-grid-step { width:46px; font-size:9px; padding:0; }
  .scene-head > #pixel-grid-toggle { padding:0 2px; font-size:9px; }
}
@media(max-width:340px) {
  .scene-head { gap:1px; left:2px; right:2px; }
  .scene-head > #projection-color-mode { width:53px; font-size:8px; }
  .scene-head > #pixel-grid-step { width:40px; font-size:8px; }
  .scene-head > #pixel-grid-toggle { font-size:8px; padding:0 1px; }
  .scene-head #distortion-quality,.scene-head #screen-drag-mode,
  .scene-head #walk-mode { padding:0 1px; min-width:0; font-size:8px; }
  .scene-head #walk-fullscreen,.scene-head #reset-view { width:25px; min-width:25px; }
}

/* Two-point 3D measurement overlay, outside the crowded rendering toolbar. */
#scene3d .measure-overlay {
  position:absolute;top:48px;left:10px;z-index:5;
  display:flex;gap:6px;align-items:center;max-width:calc(100% - 20px);
  pointer-events:auto;
}
#scene3d .measure-overlay button {
  min-height:35px;padding:0 9px;white-space:nowrap;
  background:#19291fdc;border:1px solid #466c53;border-radius:8px;
  color:#e0f4e7;font-size:10px;font-weight:700;
}
#scene3d .measure-overlay button[aria-pressed=true] {
  background:#31563e;color:#d2ffdf;border-color:#75c18b;
}
#scene3d .measure-overlay .measure-result {
  background:#101b14dd;border:1px solid #496a53;border-radius:7px;
  padding:7px 8px;font-size:12px;font-weight:650;color:#e4ffef;
  font-variant-numeric:tabular-nums;white-space:nowrap;
}
#scene3d .measure-overlay .measure-clear {
  min-width:32px;padding:0 7px;font-size:18px;
}
#scene3d .measure-overlay [hidden] { display:none!important; }


/* Four compact measurement cards share one row. */
.metrics { grid-template-columns:minmax(0,1.45fr) repeat(3,minmax(0,1fr)); gap:5px; }
.metric { padding:9px 7px; min-width:0; }
.metric > span { font-size:9px; letter-spacing:.025em; line-height:1.3; min-height:22px; }
.metric strong { font-size:clamp(10px,2.7vw,18px); line-height:1.22; white-space:normal; }
.metric-screen .size-main { display:flex; flex-wrap:wrap; align-items:baseline; gap:3px; }
#screen-size .size-number { color:var(--fill-color); }
#screen-size[data-mode="fit"] .size-number { color:var(--fit-color); }
#screen-size .size-neutral { color:var(--text); opacity:.9; font-weight:500; }
#projection-size-area { color:var(--muted); white-space:nowrap; font-size:clamp(10px,2.3vw,13px); }
.metric-pixel { grid-column:auto; }
.metric-pixel[hidden] { display:none!important; }
.metric-pixel strong { font-size:clamp(10px,2.5vw,15px); font-variant-numeric:tabular-nums; letter-spacing:-.025em; }
.metric-pixel small { display:block; font-size:10px; line-height:1.4; color:var(--muted); }
.metric-screen .size-comparison { font-size:clamp(10px,2.3vw,14px); gap:2px 2px; }
.metric-screen .size-row .size-key { font-size:9px; padding-right:2px; }
@media (max-width:370px) {
  .metrics { gap:3px; }
  .metric { padding:8px 3px; }
  .metric > span { font-size:8px; letter-spacing:0; }
  .metric-pixel strong { font-size:10px; }
}

/* Low-profile stacked coverage bars: only positive categories are rendered. */
.room-coverage { display:block; margin:0 0 9px; }
.room-coverage[hidden] { display:none!important; }
.coverage-bar { display:flex; width:100%; height:24px; border-radius:5px; overflow:hidden; }
.coverage-segment { display:flex; align-items:center; justify-content:center;
  min-width:0; box-sizing:border-box; border:1px solid #d9f8ec88;
  background:var(--coverage-base); color:var(--coverage-label);
  font-size:11px; white-space:nowrap; line-height:1; font-weight:500; }
.coverage-label { color:var(--coverage-label); white-space:nowrap;
  -webkit-text-stroke:.32px #07110c; text-shadow:0 0 2px #000,0 1px 1px #000; }
.coverage-label b { font-weight:800; font-size:inherit; color:inherit; padding-left:3px; }
.coverage-small-labels { display:flex; flex-wrap:wrap; gap:2px 12px; margin-top:3px; font-size:10px; }
.coverage-small-labels:empty { display:none; }
.coverage-small-labels .coverage-label { background:transparent; }

/* Exactly one top row. Each item uses only its content width. */
.scene-head { display:flex; flex-flow:row nowrap; align-items:center; justify-content:flex-end;
  left:3px; right:3px; gap:2px; overflow:visible; }
.scene-head > * { flex:0 0 auto!important; min-width:0!important; }
.scene-head > button { width:auto!important; min-width:0!important; height:30px; min-height:30px;
  font-size:10px!important; font-weight:750; padding:0 3px!important; }
.scene-head > #walk-fullscreen,.scene-head > #reset-view { font-size:18px!important;
  padding:0 3px!important; }
.scene-head > select { appearance:none; -webkit-appearance:none; text-align:center;
  text-align-last:center; box-sizing:border-box; width:auto!important; max-width:none;
  height:30px; min-height:30px; padding:0 3px!important; border:1px solid var(--edge);
  border-radius:8px; background:#1b261edb; color:var(--text); font-weight:750;
  font-size:10px; pointer-events:auto; }
.scene-head > [hidden] { display:none!important; }
.scene-head > #distortion-quality[aria-pressed=true] { color:#a9ffd0; }
.scene-head > #distortion-quality[data-calculating=true] { outline:1px solid #78e6a0; }
@media(max-width:380px) {
  .scene-head { gap:1px; left:2px; right:2px; }
  .scene-head > button { font-size:9px!important; padding:0 2px!important; }
  .scene-head > select { font-size:9px; padding:0 2px!important; }
  .scene-head > #walk-fullscreen,.scene-head > #reset-view { font-size:16px!important; }
}

/* Walk-pad turn arrows sit directly above lateral strafe arrows. */
.walk-pad { grid-template-rows:repeat(2,44px); }
.walk-pad [data-walk=turn-left] { grid-column:1; grid-row:1; }
.walk-pad [data-walk=turn-right] { grid-column:3; grid-row:1; }
.walk-pad [data-walk=turn-left],.walk-pad [data-walk=turn-right] {
  background:#23333de8; border-color:#638b9b; color:#c8e8ff;
  font-size:24px;
}
.walk-pad [data-walk=turn-left]:active,.walk-pad [data-walk=turn-right]:active {
  background:#3b6478; color:#eff9ff;
}
@media(max-width:400px){.walk-pad{grid-template-rows:repeat(2,42px)}}
/* No multirow wraps or 58px fixed-width WALK buttons. */
.scene-head #screen-drag-mode { letter-spacing:0; font-size:9px!important; }

/* Active screen movement is controlled exclusively by MOVE SCREEN in the top bar. */
#scene3d .measure-overlay .measure-result:empty { display:none!important; }

@media(max-width:340px){
  .scene-head > #screen-drag-mode {
    font-size:8px!important;letter-spacing:-.045em;
    padding-inline:1px!important;
  }
  .scene-head > #walk-mode { letter-spacing:-.04em; }
  .scene-head > #walk-fullscreen,.scene-head > #reset-view { padding-inline:2px!important; }
}

/* Actual squircle-shaped viewer controls, distributed across the single row. */
.scene-head {
  left:9px;right:9px;gap:5px;justify-content:space-between;
  flex-wrap:nowrap;white-space:nowrap;overflow:visible;
}
.scene-head > button,.scene-head > select {
  box-sizing:border-box;min-width:0!important;width:auto!important;
  height:36px!important;min-height:36px!important;
  font-size:11px!important;font-weight:700;
  border-radius:12px!important;
  padding:0 7px!important;
  letter-spacing:0!important;
}
.scene-head > #walk-fullscreen,.scene-head > #reset-view {
  font-size:20px!important;padding:0 6px!important;
}
.scene-head > #screen-drag-mode {
  font-size:11px!important;letter-spacing:0!important;
  padding:0 7px!important;
}
@media(max-width:440px) {
  .scene-head {left:6px;right:6px;gap:3px;}
  .scene-head > button,.scene-head > select {
    font-size:10px!important;padding:0 5px!important;
    height:34px!important;min-height:34px!important;border-radius:11px!important;
  }
  .scene-head > #screen-drag-mode {font-size:10px!important;padding:0 5px!important;}
  .scene-head > #walk-fullscreen,.scene-head > #reset-view {
    font-size:19px!important;padding:0 4px!important;
  }
}
@media(max-width:390px) {
  .scene-head {gap:2px;left:3px;right:3px;}
  .scene-head > button,.scene-head > select {
    font-size:9px!important;padding:0 3px!important;
    border-radius:10px!important;
  }
  .scene-head > #screen-drag-mode {font-size:9px!important;padding:0 3px!important;}
  .scene-head > #walk-fullscreen,.scene-head > #reset-view {padding:0 3px!important;}
}
/* Tight metric labels, units on their value line, with only values bold. */
.metrics {align-items:stretch;}
.metric > span {min-height:0!important;margin-bottom:3px!important;line-height:1.15;}
.metric .pixel-value {display:flex;align-items:baseline;gap:3px;min-width:0;white-space:nowrap;}
.metric .pixel-value strong {display:inline;font-weight:400;}
.metric .pixel-value .pixel-number {font-weight:650;}
.metric .pixel-value .pixel-cross {font-weight:400;color:var(--text);opacity:.9;}
.metric .pixel-value small {display:inline;font-size:11px;line-height:1;white-space:nowrap;font-weight:400;}
#screen-size .size-neutral {font-weight:400!important;}
#screen-size .size-number {font-weight:650;}
#projection-size-area {font-weight:400;}
/* All names and percentages stay ON the full-width surface bar. */
.coverage-bar {position:relative;display:flex;align-items:stretch;overflow:hidden;}
.coverage-segment {flex:0 0 auto;min-width:0;}
.coverage-bar > .coverage-label {
  position:absolute;top:50%;transform:translateY(-50%);z-index:1;
  font-size:11px;font-weight:600;line-height:1;
  -webkit-text-stroke:.45px #000;
  paint-order:stroke fill;
  text-shadow:none;
}
.coverage-bar > .coverage-label b {font-weight:800;}
.coverage-small-labels {display:none;}

/* Keep physical pixel dimensions and their units together on one line. */
.metric .pixel-value strong {
  white-space:nowrap!important;
  font-size:11px!important;
  letter-spacing:-.03em;
}
.metric .pixel-value small {font-size:9px!important;}
.metric .pixel-value {gap:2px;}
.metric-pixel {padding-inline:5px!important;}

/* A secondary, compact physical-pixel aspect ratio: width is always 1. */
.metric-pixel .pixel-aspect {
  margin-top:3px;
  color:var(--muted);
  font-size:10px;
  line-height:1.1;
  font-weight:400;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
/* The explicit GRID labels must stay in the same squircle toolbar row. */
@media(max-width:440px){
  .scene-head {gap:2px;}
  .scene-head > button,.scene-head > select {padding-inline:4px!important;}
  .scene-head > #pixel-grid-step {font-size:9px!important;}
}

/* Full-size squircle controls still fit within the scene at normal phone width. */
@media(min-width:391px) and (max-width:440px){
  .scene-head {left:4px;right:4px;}
}

/* Lens POV, light output and pixel inspector controls. */
.scene-aux-controls{position:absolute;left:8px;top:51px;z-index:3;display:flex;gap:5px;pointer-events:none;}
.scene-aux-controls button{pointer-events:auto;background:#16271edf;color:#dff6e6;
  border:1px solid #3c614a;border-radius:9px;padding:7px 9px;min-height:35px;
  font:700 11px system-ui;touch-action:manipulation;}
.scene-aux-controls button[aria-pressed=true]{background:#2f6247;color:#fff;border-color:#97edb5;}
.scene-aux-controls button[hidden]{display:none!important;}
#scene3d.pixel-inspect canvas{cursor:crosshair!important;}
#pixel-info-tooltip{
  position:fixed;inset:auto;margin:0;z-index:2147483647;
  width:min(325px,calc(100vw - 16px));max-height:min(65dvh,460px);overflow:auto;
  box-sizing:border-box;color:var(--text);background:#111c17f7;
  border:1px solid #6ca27d;border-radius:10px;padding:5px 11px 6px;
  box-shadow:0 10px 38px #000a;pointer-events:auto;
}
#pixel-info-tooltip:not(:popover-open){display:none!important;}
.pixel-info-toolbar{position:sticky;top:-5px;display:flex;align-items:center;gap:5px;
  background:#111c17f7;padding:4px 0 7px;z-index:1;}
#pixel-info-title{flex:1;color:#bce8cb;letter-spacing:.06em;font-size:11px;}
#pixel-info-pin,#pixel-info-close{position:static!important;min-width:30px;min-height:28px;
  border-radius:6px;border:1px solid #3b5842;background:#23392a;color:#d4f4dc;}
#pixel-info-pin[aria-pressed=true]{background:#37694a;color:#fff;border-color:#92d7a6;}
#pixel-info-pin svg{width:17px;height:17px;display:block;margin:auto;}
#pixel-info-close{
  position:absolute;right:5px;top:5px;min-width:28px;min-height:27px;
  border:1px solid #3b5842;border-radius:6px;
  color:var(--text);background:#203327;font:20px/1 system-ui;
}
#pixel-info-list{display:grid;gap:0;font-variant-numeric:tabular-nums;}
.pixel-info-row{
  min-width:0;border-bottom:1px solid #354638;padding:7px 0 6px;
  font:12px/1.3 system-ui;
}
.pixel-info-row:last-child{border-bottom:0;}
.pixel-info-line{display:flex;flex-wrap:wrap;gap:2px 6px;align-items:baseline;}
.pixel-info-label{font-size:12px;color:#e1eee3;font-weight:650;}
.pixel-info-value{font-size:13px;color:#fff;font-weight:750;white-space:nowrap;}
.pixel-info-range{font-size:11px;color:#b8cbbb;white-space:normal;}
.pixel-info-differences{
  display:flex;flex-wrap:wrap;gap:0;align-items:baseline;
  color:#b8cbbb;font:11px/1.35 system-ui;margin-top:2px;
}
.pixel-info-diff{font-weight:650;}
.pixel-info-diff[data-sign="positive"]{color:#80da9e;}
.pixel-info-diff[data-sign="negative"]{color:#ef9b74;}
.pixel-info-diff[data-sign="neutral"]{color:#d3dbc9;}
@media(max-width:390px){.scene-aux-controls{left:5px;top:47px;gap:3px;}
.scene-aux-controls button{font-size:10px;padding:6px 7px;min-height:32px;}
#pixel-info-tooltip{padding:5px 8px;}
.pixel-info-row{padding:6px 0 5px;}}

/* Keep the lens/light/pixel controls clear of the measurement overlay. */
.scene-aux-controls {left:10px;top:92px;}
@media(max-width:390px){.scene-aux-controls{left:6px;top:89px;}}

/* Stable 2D markers keep measured floor and ceiling points visible. */
#scene3d .measure-overlay .measure-result{
  white-space:normal;line-height:1.25;max-width:calc(100vw - 130px);font-size:11px;
}
#scene3d .measure-point-marker{
  position:absolute;z-index:4;pointer-events:none;
  width:22px;height:22px;box-sizing:border-box;border-radius:50%;
  background:#53e5ff;border:3px solid #08141b;
  box-shadow:0 0 0 2px #edffff,0 0 12px #53e5ff9c;
  transform:translate(-50%,-50%);
}
#scene3d .measure-point-marker::after{
  content:attr(data-number);display:block;
  text-align:center;font:700 10px/16px system-ui;color:#071620;
}
#scene3d .measure-point-marker[hidden]{display:none!important;}
@media(max-width:400px){
  #scene3d .measure-overlay .measure-result{font-size:10px;max-width:calc(100vw - 120px);}
}

/* Live physical-scale legend; never intercepts a camera or object gesture. */
#scene3d .projection-legend{
  position:absolute;left:8px;top:150px;z-index:5;pointer-events:none;
  width:max-content;min-width:0;max-width:calc(100% - 16px);box-sizing:border-box;
  padding:8px 7px 10px;
  border:1px solid #597366a0;border-radius:11px;
  background:#09140fda;color:#f2fff7;
  box-shadow:0 3px 15px #0005;font-variant-numeric:tabular-nums;
}
#scene3d .projection-legend[hidden],#scene3d .projection-legend-log[hidden]{
  display:none!important;
}
#scene3d .projection-legend-title{
  font:800 10px/1.15 system-ui;letter-spacing:.035em;
}
#scene3d .projection-legend-unit{
  margin-top:3px;white-space:nowrap;font:600 10px/1.1 system-ui;
  color:#c6e3d1;
}
#scene3d .projection-legend-log{
  display:inline-block;margin:4px 0 -2px;padding:1px 4px;
  color:#ffffff;background:#3b5650;border-radius:4px;
  font:800 8px/1.25 system-ui;letter-spacing:.045em;
}
#scene3d .projection-legend-track{
  position:relative;margin-top:10px;
  width:max-content;min-width:42px;
  height:min(225px,calc(57dvh - 170px));
  min-height:110px;
}
#scene3d .projection-legend-ramp{
  position:absolute;left:0;top:0;bottom:0;width:15px;
  border:1px solid #d1e9d699;border-radius:4px;
  box-sizing:border-box;
}
#scene3d .projection-legend-ticks{
  position:relative;margin-left:20px;top:5px;
  height:calc(100% - 10px);width:max-content;min-width:0;
  padding-right:3px;
}
#scene3d .projection-legend-tick{
  position:absolute;left:0;display:block;
  transform:translateY(50%);
  color:#effff5;font:650 10px/1.1 system-ui;
  text-shadow:0 1px 3px #000,0 0 5px #000;
  white-space:nowrap;
}
#scene3d .projection-legend-tick:before{
  content:'';position:absolute;width:4px;height:1px;
  left:-6px;top:50%;background:#effff5;
}
@media(max-width:390px){
  #scene3d .projection-legend{left:4px;top:143px;width:max-content;padding:6px 5px 8px;}
  #scene3d .projection-legend-unit{font-size:9px;}
}

/* Compact, unnumbered measurement points. */
#scene3d .measure-point-marker{
  width:12px;height:12px;border:2px solid #07151d;
  box-shadow:0 0 0 1px #efffff,0 0 6px #53e5ff80;
}
#scene3d .measure-point-marker::after{content:none;display:none;}

/* Prompt only if an orbit camera has moved the complete room out of view. */
#scene3d .room-camera-toast{
  position:absolute;left:50%;bottom:12px;z-index:12;
  transform:translateX(-50%);display:flex;align-items:center;
  justify-content:center;flex-wrap:wrap;gap:7px;
  width:max-content;max-width:calc(100% - 20px);box-sizing:border-box;
  padding:9px 10px;border:1px solid #75957b;border-radius:10px;
  background:#101c15ee;box-shadow:0 4px 20px #0009;
  font:600 12px/1.35 system-ui;color:#ecfff1;pointer-events:auto;
}
#scene3d .room-camera-toast[hidden]{display:none!important;}
#scene3d .room-camera-toast span{flex:1 1 165px;max-width:270px;}
#scene3d .room-camera-toast button{
  min-height:35px;min-width:65px;padding:5px 10px;
  border:1px solid #688d71;border-radius:7px;
  background:#244d35;color:#f0fff4;font:700 11px system-ui;
}
#scene3d .room-camera-toast button:last-child{
  background:#1c2c22;border-color:#4d6654;
}

#project-settings .project-flip-controls{
  display:flex;gap:6px;align-items:center;justify-content:flex-end;margin-top:6px;
}
#project-settings .project-flip-controls button{
  flex:1;min-height:34px;max-width:125px;padding:5px 11px;
  font:700 11px system-ui;letter-spacing:.025em;
  background:#203427;color:#dcebdd;border:1px solid #47634e;border-radius:7px;
}
#project-settings .project-flip-controls button[aria-pressed=true]{
  color:#0d1f16;background:#d5f5e1;border-color:#fff;
}

#projector-focus-controls[hidden]{display:none!important;}
#projector-focus-controls{margin:7px 0 9px;}
.projector-focus-row{display:flex;align-items:center;gap:7px;min-width:0;}
#project-settings .projector-focus-row input[type=range]{flex:1;min-width:75px;width:auto;}
#projector-focus-auto{padding:7px 9px;border:1px solid #53715e;border-radius:5px;
  background:#1d3023;color:#d6eee0;font-size:11px;font-weight:700;cursor:pointer;}
#projector-focus-auto[aria-pressed=true]{background:#d9efe1;color:#14271b;}

/* Room editor: configurable snap grid, precision nudging and lower ceiling areas. */
#room-dialog .room-step-label {display:flex;flex-direction:row;gap:5px;align-items:center;
  white-space:nowrap;letter-spacing:0;}
#room-snap-step,#room-nudge-step,#room-section-select {width:auto;min-width:0;color:#dceee2;
  border:1px solid #3b5141;background:#0b140e;border-radius:4px;font-size:12px;
  padding:5px;min-height:33px;}
.room-plan-controls .room-snap-label {margin-right:0;}
#room-area {margin-left:auto;}
.room-point-fields {align-items:end;}
.room-nudge-controls {display:grid;grid-template-columns:repeat(4,38px) minmax(64px,auto);
  gap:3px;align-items:end;}
.room-nudge-controls button {height:40px;min-width:38px;padding:0;font-size:17px!important;}
.room-nudge-controls label {white-space:nowrap;}
.room-section-controls {display:flex;align-items:end;gap:6px;margin:8px 0;}
.room-section-controls label {display:flex;align-items:center;gap:5px;min-width:0;flex:1;}
#room-section-select {flex:1;max-width:240px;}
.room-section-controls button {min-height:34px;padding:5px 8px;white-space:nowrap;}
.room-section-controls button:disabled {opacity:.38;}
.room-section-fields {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:7px;margin-bottom:8px;}
#room-point-fields[hidden],#room-section-fields[hidden] {display:none!important;}
.room-lower-fill {fill:#6eb6d6;fill-opacity:.27;stroke:#9bd6ee;stroke-width:2;cursor:move;}
.room-lower-fill.selected {fill-opacity:.43;stroke:#e0f7ff;stroke-width:3;}
.room-lower-handle {fill:#9bd6ee;stroke:#102129;stroke-width:2;cursor:nwse-resize;}
.room-lower-label {fill:#f0faff;stroke:#15212b;stroke-width:3;paint-order:stroke;
  font:700 11px system-ui,sans-serif;pointer-events:none;}
@media(max-width:700px){
  .room-point-fields {grid-template-columns:repeat(2,minmax(0,1fr)) auto auto;}
  .room-nudge-controls {grid-column:1/-1;justify-content:start;}
  .room-plan-controls {flex-wrap:wrap;gap:5px;}
  #room-area {margin-left:auto;}
  .room-section-fields {grid-template-columns:repeat(3,minmax(0,1fr));}
}
@media(max-width:380px){
  .room-nudge-controls {grid-template-columns:repeat(4,36px) minmax(58px,auto);}
  .room-section-controls {flex-wrap:wrap;}
  .room-section-controls label {flex-basis:100%;}
}

/* Non-camera history and persistent simulation bookmarks. */
.history-actions,.room-history-controls {display:flex;align-items:center;gap:4px;flex:none;}
.history-actions button,.room-history-controls button {
  display:grid;place-items:center;flex:none;width:36px;height:36px;min-height:36px;
  padding:6px;border-radius:9px;
}
.history-actions svg,.room-history-controls svg {width:19px;height:19px;}
.history-actions button:disabled,.room-history-controls button:disabled {
  opacity:.3;cursor:default;
}
.room-dialog-head {gap:6px;}
.room-dialog-head h2 {margin-right:auto;}
.room-history-controls button {width:34px;height:34px;min-height:34px;}
#bookmarks-dialog {
  width:min(450px,calc(100vw - 20px));max-height:calc(100dvh - 24px);
  padding:14px;color:var(--text);background:#141e17;
  border:1px solid #4b6654;border-radius:13px;box-shadow:0 18px 65px #000b;
}
#bookmarks-dialog::backdrop {background:#000d;}
#bookmarks-close {font-size:21px;padding:0 12px;}
.bookmarks-list {display:flex;flex-direction:column;gap:6px;max-height:55dvh;overflow-y:auto;}
.bookmark-row {display:flex;gap:6px;align-items:stretch;}
.bookmark-open {
  display:flex;flex:1;min-width:0;flex-direction:column;align-items:flex-start;
  gap:3px;min-height:49px;padding:8px 11px;text-align:left;
}
.bookmark-open strong {max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;}
.bookmark-open small {color:var(--muted);font-size:11px;}
.bookmark-delete {width:44px;min-width:44px;display:grid;place-items:center;}
.bookmark-delete svg {width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.bookmark-form {display:flex;gap:7px;margin-top:12px;}
.bookmark-form input {
  flex:1;min-width:0;font-size:16px;color:var(--text);
  background:#0b140e;border:1px solid #3b5141;border-radius:8px;padding:9px;
}
.bookmark-form button {font-size:11px;font-weight:650;white-space:nowrap;border-color:#478a60;background:#28583c;}
.bookmarks-empty {margin:10px 0;color:var(--muted);text-align:center;}
@media(max-width:450px){
  .topbar {gap:6px;}
  .topbar h1 {font-size:13px;letter-spacing:.055em;}
  .history-actions {gap:3px;}
  .history-actions button {width:33px;height:34px;min-height:34px;padding:5px;}
  .room-dialog-head h2 {font-size:14px;}
  .room-history-controls {gap:2px;}
  .room-history-controls button {width:30px;min-height:32px;height:32px;padding:5px;}
  .room-dialog-head .segmented button {min-width:38px;padding-inline:6px;}
}

/* One top toolbar plus one unified measurement/project controls row. */
.scene-head{
  top:7px;left:7px;right:7px;gap:3px;
  justify-content:space-between;flex-wrap:nowrap;
}
.scene-head > *{min-width:0!important;}
.scene-head > button,.scene-head > select{flex-shrink:1!important;}
.scene-aux-controls{
  top:46px!important;left:7px!important;right:7px!important;
  display:flex;flex-wrap:nowrap;gap:4px;width:auto;max-width:none;
  align-items:stretch;box-sizing:border-box;z-index:6;
}
.scene-aux-controls button,#scene3d .scene-aux-controls .measure-button{
  flex:1 1 auto;min-width:0;min-height:35px;
  padding:5px 4px;font-size:clamp(8px,2.4vw,11px);
  line-height:1;white-space:nowrap;
}
#scene3d .scene-aux-controls button[aria-pressed=true]{
  background:#2f6247;color:#fff;border-color:#97edb5;
}
#scene3d .scene-aux-controls #project-mode[aria-pressed=true]{
  background:#e1f0e8;color:#0b1710;border-color:#fff;
}
#scene3d .scene-aux-controls button[hidden]{display:none!important;}
#scene3d .scene-aux-controls button:first-child{
  border-color:#466c53;background:#19291fdc;color:#e0f4e7;
}
/* Measurement results are not a third button row. */
#scene3d .measure-overlay{top:91px;left:7px;pointer-events:none;}
#scene3d .measure-overlay .measure-result{
  max-width:calc(100% - 16px);pointer-events:none;
}
#project-settings-toggle[hidden]{display:none!important;}
#project-settings-toggle{
  position:absolute;left:78px;bottom:10px;z-index:7;
  display:grid;place-items:center;
  width:40px;height:40px;min-width:40px;min-height:40px;
  border:1px solid #5b7b62;border-radius:10px;
  background:#1b3227e9;color:#d9f5e3;padding:8px;
  box-shadow:0 2px 9px #0005;pointer-events:auto;touch-action:manipulation;
}
#project-settings-toggle svg{width:22px;height:22px;}
#project-settings-toggle[aria-expanded=true]{
  background:#325c43;color:#fff;border-color:#9fe1b6;
}
#project-settings input[type=range]{
  /* Same thumb-only drag, guarded pointer scrub, and scroll protection
     used by the lower range sliders. */
  user-select:none;-webkit-user-select:none;touch-action:none;
}
@media(max-width:390px){
  .scene-head{left:4px;right:4px;gap:2px;}
  .scene-aux-controls{left:4px!important;right:4px!important;gap:2px;}
  .scene-aux-controls button{padding:5px 2px!important;font-size:clamp(7.5px,2.5vw,10px)!important;}
  #scene3d .measure-overlay{left:4px;}
}

#epson-optics-controls[hidden]{display:none!important;}
#epson-optics-controls{margin:7px 0 11px;}
#epson-optics-controls .segmented{display:flex;max-width:310px;}
#epson-optics-controls .segmented button{flex:1;min-width:0;}

#epson-pixel-shift{width:100%;max-width:310px;min-height:36px;margin-top:8px;
  border:1px solid #53715e;border-radius:6px;background:#1d3023;
  color:#d6eee0;font-size:12px;font-weight:700;}
#epson-pixel-shift[aria-pressed=true]{background:#d9efe1;color:#14271b;}

/* Compact two-option wide-angle mapping switch within the existing FOV field. */
#wide-projection-mode{display:flex;width:100%;gap:4px;margin-top:4px;}
#wide-projection-mode button{flex:1;min-width:0;min-height:34px;padding:5px 2px;
  font-size:clamp(8px,1.1vw,11px);white-space:nowrap;}
#wide-projection-mode button[aria-pressed=true]{background:#386d4c;color:#fff;border-color:#92dcac;}

/* Full measurement names remain readable in the color mode selector. */
.scene-head > #projection-color-mode{
  flex:1 1 auto!important;width:min(195px,42vw)!important;
  min-width:100px!important;max-width:195px!important;
  text-align:left;text-align-last:left;font-weight:600;
  padding-inline:9px!important;
}
@media(max-width:430px){
  .scene-head > #projection-color-mode{width:min(145px,41vw)!important;
    min-width:95px!important;padding-inline:5px!important;font-size:10px!important;}
}

#scene3d .scene-aux-controls #projector-lock{flex:0 0 38px;display:grid;place-items:center;padding:5px!important;}
#projector-lock svg{width:18px;height:18px;}
#scene3d .scene-aux-controls #projector-lock[aria-pressed=true]{background:#80533d;color:#fff0d7;border-color:#e7ae72;}

/* Plane selector stays beside the XYZ direction indicator, not in the scene toolbar. */
#plane-control{position:absolute;bottom:9px;left:76px;z-index:9;pointer-events:none;}
#plane-control button{display:grid;place-items:center;padding:5px;pointer-events:auto;}
#plane-picker-toggle{width:40px;height:40px;min-height:40px;background:#1b3227ed;
  border:1px solid #5b7b62;border-radius:10px;color:#c4efda;box-shadow:0 2px 9px #0008;}
#plane-picker-toggle svg{width:25px;height:25px;}
#plane-picker-menu{position:absolute;bottom:46px;left:0;display:grid;
  grid-template-columns:repeat(3,44px);gap:5px;padding:7px;
  border:1px solid #609776;border-radius:12px;background:#102018f2;
  box-shadow:0 8px 25px #000a;pointer-events:auto;}
#plane-picker-menu[hidden]{display:none!important;}
#plane-picker-menu button{width:44px;height:44px;min-height:44px;
  background:#233c2c;color:#b9dacc;border:1px solid #3b5b48;border-radius:9px;}
#plane-picker-menu button[aria-pressed=true]{background:#346b4a;color:#e9ffed;border-color:#7dd9a0;}
#plane-picker-menu svg{width:27px;height:27px;fill:none;stroke:currentColor;stroke-width:1.7;
  stroke-linecap:round;stroke-linejoin:round;}
#plane-picker-menu .plane-surface{fill:#4cba8c77;stroke:none;}
#plane-control select[hidden]{display:none!important;}
#project-settings-toggle{left:124px;}

/* This overlay follows the projector's actual 3D screen position. */
#projector-fine-controls{position:absolute;z-index:12;display:grid;grid-template-columns:repeat(3,38px);
  grid-template-rows:repeat(3,38px) 28px;gap:4px;padding:8px;border-radius:13px;
  background:#10241cf2;border:1px solid #6da88a;box-shadow:0 12px 32px #000c;
  transform:translate(-50%,-50%);pointer-events:auto;touch-action:manipulation;}
#projector-fine-controls[hidden]{display:none!important;}
#projector-fine-controls button{min-width:38px;min-height:38px;padding:0;
  border-radius:8px;background:#2b4b37;border:1px solid #47775b;
  color:#d5ffe3;font-size:24px;touch-action:manipulation;}
#projector-fine-controls [data-nudge="y-"]{grid-column:1;grid-row:1;color:#a4d7f5;}
#projector-fine-controls [data-nudge="z+"]{grid-column:2;grid-row:1;color:#a0ffb6;}
#projector-fine-controls [data-nudge="x-"]{grid-column:1;grid-row:2;color:#ffc7bb;}
#projector-fine-controls .fine-center{grid-column:2;grid-row:2;display:grid;place-items:center;color:#95cbae;}
#projector-fine-controls [data-nudge="x+"]{grid-column:3;grid-row:2;color:#ffc7bb;}
#projector-fine-controls [data-nudge="z-"]{grid-column:2;grid-row:3;color:#a0ffb6;}
#projector-fine-controls [data-nudge="y+"]{grid-column:3;grid-row:3;color:#a4d7f5;}
#projector-nudge-step{grid-column:1/-1;grid-row:4;width:100%;height:28px;min-height:28px;
  padding:2px 5px;text-align:center;background:#1c3527;border-color:#47775b;color:#d5ffe3;font-size:12px;}
@media(max-width:390px){#plane-control{left:73px;bottom:7px;}
  #plane-picker-toggle{width:38px;height:38px;min-height:38px;}
  #project-settings-toggle{left:119px;bottom:7px;}}
