:root {
  color-scheme: dark;
  --bg: #0d1420;
  --panel: #151f2e;
  --inset: #101925;
  --line: #2a394a;
  --ink: #edf3f8;
  --muted: #aab8c9;
  --accent: #79e5ce;
  --accent-bg: #193c3e;
  --warn: #f2c38f;
  font: 16px/1.4 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--ink) }
button, input { font: inherit }
button { color: var(--ink); cursor: pointer }
button, .unit-field { border: 1px solid var(--line); background: var(--inset); border-radius: 7px }
button:hover:not(:disabled) { border-color: #67908e; background: #253b49 }
button:disabled { opacity: .39; cursor: default }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px }
h1, h2, h3, p { margin: 0 }
.masthead { min-height: 68px; display: flex; align-items: center; gap: 18px; padding: 0 28px; border-bottom: 1px solid var(--line); background: #111a27 }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; letter-spacing: -.035em; white-space: nowrap }
.brand-mark { width: 32px; height: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 6px; border-radius: 9px; background: var(--accent); transform: rotate(-7deg) }
.brand-mark i { display: block; background: #142c34; border-radius: 1px }
.brand-mark i:first-child { grid-row: span 2 }
.room-size { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 9px; white-space: nowrap }
.room-size span { display:block; height: 15px; width:1px; background:var(--line) }
.history { display:flex; margin-left:auto; align-items:center; gap:6px }
.history button { min-width:36px; height:34px; font-size:1.15rem }
.history button:last-child { font-size:.85rem; padding:0 12px }
.workspace { display:grid; grid-template-columns:minmax(0,1.32fr) minmax(0,1fr); align-items:start; gap:15px; padding:18px 24px 0; max-width:1632px; margin:0 auto }
.panel { min-width:0; background:var(--panel); border:1px solid var(--line); border-radius:13px; overflow:hidden }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:15px 16px }
.panel-head h1, .panel-head h2 { font-size:1.15rem; letter-spacing:-.035em; line-height:1.2 }
.panel-head p { color:var(--muted); font-size:.85rem; margin-top:5px }
.segmented { display:flex; gap:3px; padding:3px; border:1px solid var(--line); background:var(--inset); border-radius:9px; width:max-content; max-width:100%; flex-shrink:0 }
.segmented button { border-color:transparent; border-radius:6px; padding:6px 10px; font-size:.85rem; font-weight:600; background:transparent; color:var(--muted); white-space:nowrap }
.segmented button[aria-pressed=true], .object-list button[aria-pressed=true] { border-color:#3c7270; background:var(--accent-bg); color:var(--accent) }
.plan-stage { height:clamp(420px, 59vh, 660px); position:relative; touch-action:none; isolation:isolate; overflow:hidden; background-color:#111b29; background-image:radial-gradient(circle,#344556 1px,transparent 1.2px); background-size:17px 17px; border-block:1px solid var(--line) }
canvas { display:block; width:100%; height:100%; touch-action:none }
#plan-canvas[data-cursor=move] { cursor:move }
#plan-canvas[data-cursor=rotate], #plan-canvas[data-cursor=orbit] { cursor:grab }
#plan-canvas[data-dragging=true], #camera-canvas:active { cursor:grabbing }
.orientation { position:absolute; left:16px; top:15px; display:grid; place-items:center; grid-template-columns:19px 16px; grid-template-rows:16px 19px; font-size:.75rem; color:var(--muted); pointer-events:none }
.orientation span:first-child { grid-column:1; color:var(--accent) }
.orientation span:last-child { grid-column:2; grid-row:2 }
.orientation i { grid-column:1; grid-row:2; display:block; height:13px; width:13px; border-radius:1px; border-left:1px solid var(--muted); border-bottom:1px solid var(--muted); transform:rotate(180deg); position:relative }
.orientation i::after { content:""; position:absolute; height:5px; width:5px; border-top:1px solid var(--muted); border-left:1px solid var(--muted); left:-3px; bottom:-3px; transform:rotate(-45deg) }
.room-annotations { position:absolute; inset:0; overflow:hidden; pointer-events:none; font-size:.78rem; color:#c7d6e4; font-variant-numeric:tabular-nums }
.width-label, .length-label { position:absolute; display:grid; place-items:center; background:#182536; border:1px solid #3c5366; border-radius:4px; padding:1px 5px; transform:translate(-50%,-50%) }
.plan-floater { position:absolute; bottom:12px; left:12px; right:122px; pointer-events:none; font-size:.8rem }
#geometry-status:not(:empty) { display:inline-block; border:1px solid #795a3d; color:#ffe0bc; background:#35271f; border-radius:6px; padding:4px 8px }
#geometry-status[data-snap=true]:not(:empty) { border-color:#3c7270; background:#163033; color:var(--accent) }
.zoom { position:absolute; right:12px; bottom:12px; display:flex; align-items:center; overflow:hidden; border:1px solid var(--line); border-radius:8px; background:#172535 }
.zoom button { border:none; background:transparent; border-radius:0; height:33px; padding:0 8px; min-width:31px }
#zoom-reset { font-size:.76rem; min-width:47px; font-variant-numeric:tabular-nums; color:var(--muted) }
.tool-row { padding:11px 14px; display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid var(--line) }
.switch { display:flex; align-items:center; color:var(--muted); font-size:.86rem; gap:7px; cursor:pointer; position:relative }
.switch input { position:absolute; width:32px; height:20px; left:0; margin:0; opacity:0; cursor:pointer }
.switch-ui { display:inline-block; border:1px solid #587287; height:18px; width:31px; border-radius:12px; background:#25384a; pointer-events:none }
.switch-ui::before { content:""; width:12px; height:12px; display:block; margin:2px; background:#9bb1c2; border-radius:50%; transition:transform 120ms ease }
.switch input:checked+.switch-ui { border-color:#467d76; background:#24514f }
.switch input:checked+.switch-ui::before { transform:translateX(13px); background:var(--accent) }
.switch input:focus-visible+.switch-ui { outline:2px solid var(--accent); outline-offset:3px }
.layout-bottom { padding:13px 14px 0 }
.object-list { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px }
.object-list button { display:flex; align-items:center; gap:7px; padding:5px 8px; font-size:.84rem; white-space:nowrap }
.object-list i { width:9px; height:9px; display:block; border-radius:2px; background:var(--swatch); border:1px solid #f5ffff55 }
.object-list button:first-child i { border-radius:50% }
.inspector { display:flex; align-items:end; flex-wrap:wrap; gap:8px; border:0; padding:0; margin:0; min-width:0 }
.inspector legend { font-size:.87rem; color:var(--ink); padding:0; margin-bottom:5px; font-weight:600 }
.inspector label { display:flex; gap:3px; flex-direction:column; color:var(--muted); font-size:.77rem }
.unit-field { display:flex; align-items:center; gap:4px; padding-right:6px; width:83px; height:32px }
.unit-field input { background:none; border:0; min-width:0; width:100%; padding:4px 0 4px 7px; color:var(--ink); font-size:.86rem; font-variant-numeric:tabular-nums }
.unit-field input:focus-visible { outline-offset:1px }
#rotate-quarter { height:32px; padding:3px 9px; font-size:.85rem }
.shortcuts { display:flex; flex-wrap:wrap; gap:9px 14px; padding:13px 14px; font-size:.77rem; color:var(--muted) }
kbd { background:#202e3f; border:1px solid #415266; border-radius:4px; padding:1px 4px; font:inherit; color:#dce7f1 }
.tag { background:#223144; color:#cad9e8; font-size:.65rem; letter-spacing:.1em; border:1px solid #364a62; border-radius:5px; padding:4px 6px; white-space:nowrap }
.camera-stage { aspect-ratio:16/9; position:relative; background:#0b1119; border-block:1px solid var(--line); overflow:hidden }
#camera-canvas { cursor:grab }
.viewfinder { position:absolute; inset:14px; pointer-events:none }
.viewfinder i { position:absolute; width:15px; height:15px; border:solid #dbfffa9c; border-width:2px 0 0 2px }
.viewfinder i:nth-child(2) { right:0; transform:rotate(90deg) }
.viewfinder i:nth-child(3) { bottom:0; right:0; transform:rotate(180deg) }
.viewfinder i:nth-child(4) { bottom:0; transform:rotate(270deg) }
.viewfinder b { position:absolute; width:14px; height:14px; left:50%; top:50%; transform:translate(-50%,-50%); background:linear-gradient(#d8fffdb0,#d8fffdb0) center/1px 100% no-repeat,linear-gradient(#d8fffdb0,#d8fffdb0) center/100% 1px no-repeat }
.frame-label { position:absolute; bottom:17px; left:20px; pointer-events:none; color:#e5f2f9; background:#122032de; border-radius:3px; padding:1px 5px; font-size:.68rem }
.visibility { display:flex; gap:8px; min-height:39px; align-items:center; padding:8px 15px; border-bottom:1px solid var(--line); color:var(--accent); font-size:.84rem }
.visibility[data-state=partial], .visibility[data-state=out], .visibility[data-state=blocked] { color:var(--warn) }
.status-dot { display:block; width:7px; height:7px; border-radius:50%; background:currentColor }
.aim { padding:14px 16px 15px }
.aim-header { display:flex; align-items:center; justify-content:space-between; gap:10px }
.aim h3 { font-size:1rem; letter-spacing:-.025em }
.aim-header button { font-size:.8rem; padding:4px 8px }
.aim-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 18px; margin:14px 0 8px }
.aim-controls label { display:grid; grid-template-columns:1fr auto; gap:3px; font-size:.88rem; color:var(--muted) }
.aim-controls output { color:var(--ink); font-variant-numeric:tabular-nums }
.aim-controls input { grid-column:1/-1; display:block; width:100%; margin:0; height:20px; accent-color:var(--accent) }
.camera-hint, .page-footer { color:var(--muted); font-size:.8rem }
.page-footer { max-width:1632px; margin:0 auto; display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 12px; padding:12px 25px 17px }
.mobile-nav, .mobile-placement, .touch-hint { display:none }
.load-error { position:absolute; inset:0; display:grid; place-items:center; text-align:center; padding:20px; background:var(--inset) }
[hidden] { display:none!important }
@media (max-width:960px) { .workspace { padding-inline:15px; gap:10px } .masthead { padding-inline:17px } .panel-head { padding-inline:12px } .panel-head p { font-size:.78rem } }
@media (max-width:730px), (max-width:950px) and (max-height:540px) {
  body { padding-bottom:calc(72px + env(safe-area-inset-bottom)); }
  button { touch-action:manipulation }
  .masthead { min-height:60px; gap:8px; padding-top:env(safe-area-inset-top); padding-left:max(12px,env(safe-area-inset-left)); padding-right:max(12px,env(safe-area-inset-right)); }
  .brand { font-size:1.03rem; gap:7px }
  .brand-mark { width:28px; height:28px; padding:5px }
  .history { gap:4px }
  .history button { min-width:44px; min-height:44px }
  .history button:last-child { padding-inline:8px }
  .workspace { grid-template-columns:minmax(0,1fr); padding:9px max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left)); }
  .workspace[data-active-view=layout] .webcam-panel, .workspace[data-active-view=webcam] .layout-panel { display:none }
  .panel-head { padding:11px 12px; gap:7px }
  .panel-head h1, .panel-head h2 { font-size:1.1rem }
  .panel-head p { font-size:.8rem }
  .segmented button { min-height:44px; padding:5px 8px; }
  .plan-stage { height:clamp(275px, 46svh, 465px) }
  .camera-stage { width:min(100%,calc(123svh - 116px)); margin-inline:auto; }
  .orientation { top:9px; left:9px }
  .zoom { right:7px; bottom:7px; flex-direction:column }
  .zoom button { min-width:46px; height:44px }
  #zoom-in { order:-1 }
  #zoom-out { order:2 }
  .plan-floater { bottom:8px; left:8px; right:64px; font-size:.76rem }
  .tool-row { padding:6px 9px; gap:6px }
  .switch { min-height:44px; padding:0 5px; }
  .switch input { width:100%; height:44px }
  .layout-bottom { padding:8px 9px 0 }
  .object-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; margin-bottom:8px }
  .object-list button { min-height:44px; padding:4px 6px; font-size:.82rem; white-space:normal; text-align:left; line-height:1.2 }
  .object-list i { flex:0 0 9px }
  .mobile-placement { display:flex; justify-content:space-between; gap:6px; align-items:center }
  .mobile-placement button { min-height:44px; padding:4px 10px; font-size:.86rem; }
  #rotate-quarter-mobile { border-color:#3c7270; background:var(--accent-bg); color:var(--accent) }
  #precise-placement { margin-top:8px; scroll-margin-bottom:calc(76px + env(safe-area-inset-bottom)); }
  #precise-placement[data-expanded=false], #rotate-quarter { display:none }
  .unit-field { min-height:44px; width:86px }
  .unit-field input { font-size:1rem }
  .shortcuts { display:none }
  .touch-hint { display:block; color:var(--muted); padding:8px 10px 10px; font-size:.79rem }
  .aim { padding:12px }
  .aim-header button { min-height:44px; font-size:.85rem }
  .aim-controls { gap:8px 15px; }
  .aim-controls label { min-width:0; font-size:.9rem }
  .aim-controls input { height:44px }
  .page-footer { padding:8px max(12px,env(safe-area-inset-right)) 7px max(12px,env(safe-area-inset-left)); font-size:.75rem }
  .mobile-nav { display:block; position:fixed; z-index:10; inset:auto 0 0; padding:6px max(10px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left)); background:#111b29; border-top:1px solid var(--line); }
  .mobile-nav div { display:grid; grid-template-columns:1fr 1fr; gap:7px; max-width:440px; margin:auto }
  .mobile-nav button { display:flex; align-items:center; justify-content:center; gap:8px; min-height:47px; background:transparent; color:var(--muted); border-color:transparent; font-weight:600; font-size:.9rem }
  .mobile-nav button[aria-selected=true] { color:var(--accent); background:var(--accent-bg); border-color:#3c7270 }
  .tab-icon { position:relative; width:15px; height:14px; display:inline-block; border:1.5px solid currentColor; border-radius:3px; }
  .tab-layout::before { content:""; position:absolute; top:0; bottom:0; left:5px; border-left:1.5px solid currentColor }
  .tab-layout::after { content:""; position:absolute; top:5px; left:5px; right:0; border-top:1.5px solid currentColor }
  .tab-webcam { width:17px; height:12px }
  .tab-webcam::before { content:""; position:absolute; top:2px; left:5px; width:4px; height:4px; border:1px solid currentColor; border-radius:50% }
  .tab-webcam::after { content:""; position:absolute; left:3px; right:3px; bottom:-4px; border-bottom:1px solid currentColor }
}
@media (max-width:390px) { .room-size { display:none } .panel-head p { font-size:.76rem } .segmented button { padding-inline:6px } }
@media (prefers-reduced-motion:reduce) { *, *::before, *::after { transition:none!important } }
