:root {
  color-scheme: light;
  --ink: #10212c;
  --ink-soft: #40515b;
  --muted: #74828a;
  --paper: #f2f5f3;
  --surface: #fff;
  --surface-alt: #f8faf9;
  --line: #dce5e2;
  --line-strong: #c4d2cf;
  --teal: #167d79;
  --teal-dark: #0f6663;
  --teal-pale: #e5f3f0;
  --orange: #d77b32;
  --orange-pale: #fff2e4;
  --red: #b44c46;
  --red-pale: #fff0ee;
  --blue: #4677a1;
  --shadow: 0 8px 30px rgba(24, 43, 51, .055);
  --radius: 17px;
  --radius-small: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(22, 125, 121, .32);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; min-height: 100dvh; }

.topbar {
  min-height: 76px;
  padding: 12px max(20px, calc((100vw - 1380px) / 2));
  background: var(--ink);
  color: #f6fbf9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: #9ee4d7; background: rgba(107, 205, 185, .12); }
.brand-mark svg { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 13px; letter-spacing: .13em; font-weight: 760; }
.brand-copy small { color: #a8b8bd; font-size: 12px; }
.topbar-status { display: inline-flex; align-items: center; gap: 12px; }

.save-indicator { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: #b7c9ca; white-space: nowrap; }
.save-indicator i { width: 7px; height: 7px; border-radius: 50%; background: #9baeb1; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.save-indicator[data-state="saved"] i { background: #62d0ae; }
.save-indicator[data-state="saving"] i { background: #ffc170; animation: pulse 1s infinite alternate; }
.save-indicator[data-state="error"] { color: #ffd1bf; }
.save-indicator[data-state="error"] i { background: #ff8e72; }
@keyframes pulse { to { opacity: .45; } }

.icon-button {
  width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px;
  background: rgba(255,255,255,.06); color: #ecf7f3; display: grid; place-items: center; cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.12); }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stage-nav {
  display: flex; gap: 7px; align-items: stretch; overflow-x: auto; scrollbar-width: thin;
  padding: 8px max(20px, calc((100vw - 1380px) / 2)); background: #172a36; color: #b0c0c5;
  border-top: 1px solid rgba(255,255,255,.035);
}
.stage-tab { position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; color: inherit; font-weight: 620; cursor: pointer; }
.stage-tab:hover { color: white; background: rgba(255,255,255,.055); }
.stage-tab.is-active { color: #10212c; background: #f4faf7; }
.stage-tab.is-active::after { content: ""; height: 3px; position: absolute; left: 14px; right: 14px; bottom: -8px; border-radius: 3px 3px 0 0; background: #66cbbb; }
.stage-index { font-size: 10px; letter-spacing: .08em; opacity: .66; font-variant-numeric: tabular-nums; }

main { max-width: 1380px; margin: 0 auto; padding: 24px 24px 36px; }
.project-bar { display: flex; justify-content: space-between; align-items: center; gap: 22px; padding: 2px 1px 20px; }
.project-heading { min-width: 0; flex: 1; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .14em; }
.project-name { display: block; width: min(100%, 530px); padding: 0; border: 0; border-radius: 6px; color: var(--ink); background: transparent; font-size: clamp(23px, 3vw, 30px); font-weight: 760; letter-spacing: -.035em; }
.project-name:focus-visible { outline-offset: 4px; }
.project-summary { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.project-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.button { display: inline-flex; min-height: 42px; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 0 14px; cursor: pointer; font-size: 13px; font-weight: 690; transition: background-color .16s ease, border-color .16s ease, transform .16s ease; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { color: white; background: var(--teal); }
.button-primary:hover:not(:disabled) { background: var(--teal-dark); }
.button-secondary { color: var(--teal-dark); border-color: #cbe2dc; background: var(--teal-pale); }
.button-secondary:hover:not(:disabled) { border-color: #a8d1c7; background: #d8eee9; }
.button-quiet { color: var(--ink-soft); border-color: var(--line); background: rgba(255,255,255,.7); }
.button-quiet:hover:not(:disabled) { border-color: var(--line-strong); background: white; }
.button-danger { color: var(--red); border-color: #f0d1cd; background: white; }
.button-small { min-height: 35px; border-radius: 9px; padding: 0 11px; font-size: 12px; }
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.notice-region:empty { display: none; }
.notice-region { margin: 0 0 14px; padding: 11px 14px; border-radius: 11px; font-size: 13px; line-height: 1.45; }
.notice-region[data-kind="info"] { color: #36535c; background: #eaf1f1; }
.notice-region[data-kind="success"] { color: #155f53; background: #e0f4ec; }
.notice-region[data-kind="warning"] { color: #7d4b13; background: var(--orange-pale); }
.notice-region[data-kind="error"] { color: #8e3731; background: var(--red-pale); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); gap: 18px; align-items: start; }
.stage-panel, .guide-panel { min-width: 0; }
.stack { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-pad { padding: 19px; }
.card-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; }
.card-header h2, .card-header h3 { margin: 0; font-size: 16px; line-height: 1.3; letter-spacing: -.02em; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.card-kicker { margin: 0 0 5px; color: var(--teal); font-size: 10px; font-weight: 780; letter-spacing: .13em; text-transform: uppercase; }
.subtle { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.tiny { font-size: 11px; line-height: 1.45; }
.separator { height: 1px; margin: 17px 0; border: 0; background: var(--line); }
.inline { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { min-width: 0; display: grid; gap: 6px; }
.field > label, .field-label { color: #42545c; font-size: 12px; font-weight: 680; }
.field input, .field select, .field textarea, .form-control {
  width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; color: var(--ink); background: #fff; font-size: 14px;
}
.field input::placeholder, .field textarea::placeholder { color: #9aa7ac; }
.field textarea { min-height: 78px; resize: vertical; }
.field-help { margin: -2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.unit-input { display: flex; align-items: center; gap: 8px; }
.unit-input input { min-width: 0; }
.unit-input span { color: var(--muted); font-size: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 13px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--teal); }

.hint-banner { display: flex; gap: 11px; padding: 13px 14px; border: 1px solid #f1d3ad; border-radius: 12px; color: #714614; background: var(--orange-pale); font-size: 12px; line-height: 1.48; }
.hint-banner strong { display: block; margin-bottom: 2px; font-size: 12px; }
.hint-icon { flex: 0 0 27px; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; color: #9d5815; background: #ffe2bd; font-size: 15px; font-weight: 760; }
.info-banner { padding: 12px 14px; border: 1px solid #cfe1e0; border-radius: 12px; color: #37555b; background: #edf5f4; font-size: 12px; line-height: 1.5; }
.info-banner strong { color: #21444b; }
.warning-banner { padding: 12px 14px; border: 1px solid #efd3c2; border-radius: 12px; color: #794823; background: #fff5ee; font-size: 12px; line-height: 1.5; }

.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.metric-cell { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-alt); }
.metric-cell span { display: block; color: var(--muted); font-size: 10px; line-height: 1.3; }
.metric-cell strong { display: block; margin-top: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }

.point-list, .measurement-list, .photo-list, .furniture-list { display: grid; gap: 9px; }
.point-row, .measurement-row, .furniture-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt); }
.point-main, .measurement-main, .furniture-main { min-width: 0; }
.point-title, .measurement-title, .furniture-title { display: flex; align-items: center; gap: 8px; font-weight: 710; font-size: 13px; }
.point-meta, .measurement-meta, .furniture-meta { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.point-badge { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 25px; border-radius: 8px; color: var(--teal-dark); background: var(--teal-pale); font-size: 10px; font-weight: 770; }
.point-badge.is-origin { color: #8b4e14; background: var(--orange-pale); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; color: #53636a; background: #edf1f0; font-size: 10px; font-weight: 690; white-space: nowrap; }
.status-pill[data-status="measured"], .status-pill[data-status="ok"] { color: #126252; background: #e2f4eb; }
.status-pill[data-status="approximate"], .status-pill[data-status="mismatch"] { color: #875016; background: #fff0df; }
.status-pill[data-status="unknown"], .status-pill[data-status="pending"] { color: #6b777d; background: #eef1f1; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.text-button { padding: 5px 7px; border: 0; border-radius: 7px; color: var(--teal-dark); background: transparent; font-size: 11px; font-weight: 720; cursor: pointer; }
.text-button:hover { background: var(--teal-pale); }
.text-button.is-danger { color: var(--red); }

.photo-frame { position: relative; overflow: visible; width: 100%; margin-inline: auto; border-radius: 13px; background: #dbe5e2; }
.photo-frame img { display: block; width: 100%; height: 100%; border-radius: 13px; object-fit: contain; }
.photo-overlay { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: auto; }
.photo-mark-layer { position: absolute; z-index: 2; inset: 0; overflow: visible; pointer-events: none; }
.photo-mark { position: absolute; display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 999px; color: #fff; background: rgba(16,33,44,.86); box-shadow: 0 1px 5px rgba(0,0,0,.42); font: inherit; font-size: 14px; font-weight: 800; line-height: 1; white-space: nowrap; cursor: pointer; pointer-events: auto; touch-action: manipulation; }
.photo-mark.is-origin { color: #fff; background: #12667b; }
.photo-mark.is-target { color: #10212c; background: #f3a645; }
.photo-mark:focus-visible { outline: 3px solid #10212c; outline-offset: 2px; }
.photo-overlay .guide-line { fill: none; stroke: #ffad58; stroke-width: 2; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.photo-caption { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 9px 3px 0; color: var(--muted); font-size: 11px; }
.photo-thumb { position: relative; display: grid; grid-template-columns: 64px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.photo-thumb.is-selected { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(22,125,121,.1); }
.photo-thumb img { display: block; width: 64px; height: 52px; border-radius: 7px; object-fit: cover; background: #e5ecea; }
.photo-thumb strong { display: block; overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.photo-thumb small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.photo-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.photo-drop { min-height: 170px; display: grid; place-items: center; padding: 20px; border: 1px dashed #9ebdb7; border-radius: 14px; color: var(--ink-soft); background: #f5faf8; text-align: center; }
.photo-drop svg { width: 34px; height: 34px; margin-bottom: 8px; fill: none; stroke: var(--teal); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.photo-drop strong { display: block; margin-bottom: 5px; font-size: 14px; }
.photo-drop p { max-width: 265px; margin: 0 auto 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.guide-step { display: grid; grid-template-columns: 29px minmax(0,1fr); gap: 10px; padding: 11px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-alt); }
.guide-step.is-current { border-color: #efc18f; background: #fff8ef; }
.guide-number { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; color: #985818; background: #ffe4c2; font-size: 11px; font-weight: 800; }
.guide-step strong { display: block; font-size: 12px; }
.guide-step p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.reading-value { color: var(--teal-dark); font-size: 14px; font-weight: 780; font-variant-numeric: tabular-nums; }
.guide-form { display: grid; gap: 11px; }
.guide-action { padding: 15px; border: 1px solid #f0d0a9; border-radius: 13px; background: var(--orange-pale); }
.guide-action .card-kicker { color: #9a5c1c; }
.guide-action h3 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.guide-action p { margin: 6px 0 0; color: #725632; font-size: 12px; line-height: 1.48; }
.anchor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.step-queue { display: grid; gap: 7px; }

.empty-state { display: grid; justify-items: center; padding: 29px 20px; border: 1px dashed var(--line-strong); border-radius: 13px; color: var(--muted); text-align: center; }
.empty-icon { width: 43px; height: 43px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 14px; color: var(--teal); background: var(--teal-pale); }
.empty-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.empty-state strong { margin-bottom: 5px; color: var(--ink-soft); font-size: 13px; }
.empty-state p { max-width: 295px; margin: 0 0 12px; font-size: 11px; line-height: 1.5; }

.plan-wrap { padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #f6faf8; }
.plan-svg, .viewer-svg { display: block; width: 100%; height: auto; min-height: 230px; touch-action: none; }
.plan-svg text, .viewer-svg text { font-family: inherit; }
.plan-outline { fill: rgba(22,125,121,.10); stroke: #177d79; stroke-width: 3; stroke-linejoin: round; }
.plan-point { fill: #fff; stroke: #167d79; stroke-width: 3; }
.plan-point.is-control { fill: #ffe3be; stroke: #d27a32; }
.plan-label { fill: #243a43; font-size: 12px; font-weight: 770; }
.plan-dimension { fill: #53666c; font-size: 10px; font-weight: 650; }
.plan-edge { stroke: #77928e; stroke-width: 1.5; stroke-dasharray: 5 4; }
.plan-furniture { fill: rgba(215,123,50,.19); stroke: #cf7734; stroke-width: 2; }
.viewer-frame { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: radial-gradient(circle at 50% 20%, #fff 0, #edf4f1 70%, #e6efed 100%); }
.viewer-svg { min-height: 360px; cursor: grab; }
.viewer-svg.is-dragging { cursor: grabbing; }
.viewer-floor { fill: #d8e8e4; stroke: #718d89; stroke-width: 1.5; }
.viewer-wall { stroke: rgba(28,56,62,.45); stroke-width: 1.1; }
.viewer-wall.is-approximate { stroke-dasharray: 5 3; }
.viewer-caption { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--muted); font-size: 11px; }
.viewer-controls { position: absolute; right: 10px; bottom: 40px; z-index: 1; display: grid; gap: 6px; }
.viewer-controls button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: rgba(255,255,255,.92); font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.08); cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 13px; color: var(--muted); font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }
.legend-dot.approx { background: var(--orange); }
.legend-line { width: 13px; border-top: 2px dashed #839691; }

.switch-row { display: flex; gap: 5px; padding: 4px; border-radius: 11px; background: #edf2f0; }
.switch-row button { flex: 1; min-height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 690; cursor: pointer; }
.switch-row button.is-active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(21,44,51,.08); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { padding: 9px 7px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-size: 10px; font-weight: 720; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .number { font-variant-numeric: tabular-nums; white-space: nowrap; }

.app-dialog { width: min(560px, calc(100vw - 28px)); max-width: none; max-height: min(760px, calc(100dvh - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(7,20,28,.28); }
.app-dialog::backdrop { background: rgba(10,24,31,.58); backdrop-filter: blur(3px); }
.dialog-content { padding: 21px; }
.dialog-close { flex: 0 0 auto; width: 34px; height: 34px; border-color: var(--line); color: var(--ink); background: var(--surface-alt); font-size: 20px; line-height: 1; }
.project-list { display: grid; gap: 8px; max-height: min(430px, 50dvh); overflow: auto; }
.project-choice { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt); }
.project-choice strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.project-choice small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 15px; }
.dialog-empty { padding: 15px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.app-footer { display: flex; justify-content: space-between; gap: 20px; max-width: 1380px; margin: 0 auto; padding: 0 24px calc(24px + env(safe-area-inset-bottom)); color: #6d7b81; font-size: 11px; line-height: 1.45; }
.app-footer p { margin: 0; }
.app-footer strong { color: #41565d; }
.footer-device { text-align: right; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 960px) {
  main { padding-inline: 18px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-panel { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; align-items: start; }
  .guide-panel > .stack { display: contents; }
  .app-footer { padding-inline: 18px; }
}

@media (max-width: 640px) {
  .topbar { min-height: 66px; padding: 9px 15px; }
  .brand-mark { width: 39px; height: 39px; }
  .brand-copy strong { font-size: 12px; }
  .brand-copy small { font-size: 10px; }
  .save-indicator { max-width: 134px; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
  .icon-button { width: 38px; height: 38px; }
  .stage-nav { padding: 7px 12px; gap: 2px; }
  .stage-tab { min-height: 43px; gap: 7px; padding: 0 12px; font-size: 12px; }
  .stage-tab.is-active::after { bottom: -7px; }
  main { padding: 18px 13px 28px; }
  .project-bar { display: grid; align-items: start; gap: 12px; padding-bottom: 15px; }
  .project-actions { justify-content: flex-start; }
  .button { min-height: 40px; padding-inline: 12px; font-size: 12px; }
  .workspace-grid { gap: 13px; }
  .guide-panel { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
  .guide-panel > .stack { display: grid; }
  .card { border-radius: 15px; }
  .card-pad { padding: 15px; }
  .field-grid, .anchor-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-strip { gap: 6px; }
  .metric-cell { padding: 9px; }
  .metric-cell strong { font-size: 13px; }
  .photo-frame img { max-height: 46vh; }
  .viewer-svg { min-height: 300px; }
  .dialog-content { padding: 16px; }
  .dialog-actions .button { flex: 1 1 auto; }
  .app-footer { display: grid; gap: 5px; padding: 0 14px calc(20px + env(safe-area-inset-bottom)); font-size: 10px; }
  .footer-device { text-align: left; }
}

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

/* Room Survey workflow surfaces */
.stage-content { display: grid; gap: 14px; min-width: 0; }
.stage-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 2px 2px 1px; }
.stage-heading h1 { margin: 0; font-size: clamp(21px, 2.4vw, 27px); letter-spacing: -.035em; line-height: 1.2; }
.stage-heading p:not(.card-kicker) { max-width: 640px; margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.room-grid, .view-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: 14px; align-items: start; min-width: 0; }
.room-grid > *, .view-grid > * { min-width: 0; }
.room-grid > .stack { min-width: 0; }
.stage-content .card { padding: 18px; }
.stage-content .card-header { margin-bottom: 14px; }
.card-emphasis { border-color: #efd3ae; background: linear-gradient(145deg, #fffaf4, #fff 68%); }
.card-emphasis .card-kicker { color: #a05c1a; }
.badge { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); background: #f6f8f7; font-size: 10px; font-weight: 720; line-height: 1.35; text-align: center; }
.badge-success { color: #126252; border-color: #c4e5d6; background: #e7f6ee; }
.badge-warm { color: #865019; border-color: #f2d4ae; background: #fff2e1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 11px; min-width: 0; }
.form-grid-tight { gap: 9px; }
.form-grid > .field, .form-grid > .button, .form-grid > .form-actions, .form-grid > .saved-reading, .form-grid > p { min-width: 0; }
.form-grid > .button[type="submit"], .form-actions { grid-column: 1 / -1; }
.field > span { color: #42545c; font-size: 12px; font-weight: 680; }
.field > span small { color: var(--muted); font-size: 10px; font-weight: 590; }
.field-hint { min-height: 14px; margin: -2px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.button-block { width: 100%; }
.callout { margin-top: 12px; padding: 11px 12px; border-left: 3px solid #72a9a0; border-radius: 0 9px 9px 0; color: #415a5d; background: #edf5f3; font-size: 11px; line-height: 1.5; }
.callout-warm { border-left-color: var(--orange); color: #704b23; background: #fff5e9; }
.warning-text { margin: 7px 0 0; color: #8a501f; font-size: 11px; line-height: 1.45; }
.outline-sequence { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 10px 0 14px; }
.outline-token { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid #d4e3df; border-radius: 9px; color: var(--ink-soft); background: #f5faf8; font-size: 11px; font-weight: 690; }
.outline-token b { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 6px; color: #fff; background: var(--teal); font-size: 9px; }
.outline-arrow { color: #92a39f; font-size: 12px; }
.point-mark { display: inline-grid; place-items: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 8px; color: var(--teal-dark); background: var(--teal-pale); font-size: 10px; font-weight: 780; }
.fixed-mark { color: var(--muted); font-size: 10px; }
.status-pill.measured, .status-pill[data-status="measured"], .status-pill[data-status="ok"] { color: #126252; background: #e2f4eb; }
.status-pill.approximate, .status-pill[data-status="approximate"], .status-pill[data-status="mismatch"] { color: #875016; background: #fff0df; }
.status-pill.unknown, .status-pill[data-status="unknown"], .status-pill[data-status="pending"] { color: #6b777d; background: #eef1f1; }
.row-actions button:not(.danger-icon), .height-row button { min-height: 34px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--teal-dark); background: white; font-size: 10px; font-weight: 690; cursor: pointer; }
.row-actions button:disabled { opacity: .45; cursor: default; }
.danger-icon { width: 32px; min-width: 32px; height: 32px; border: 1px solid #efd5d1; border-radius: 9px; color: var(--red); background: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.saved-reading { grid-column: 1 / -1; padding: 9px 11px; border-radius: 9px; color: #704b23; background: #fff1df; font-size: 11px; }
.saved-reading span { display: block; margin-bottom: 3px; color: #8a6a42; }
.photo-add { position: relative; overflow: hidden; }
.photo-add input { position: absolute; width: 1px; height: 1px; opacity: .001; }
.photo-add:focus-within { outline: 3px solid rgba(22,125,121,.25); outline-offset: 2px; }
.photo-thumb[role="button"] { text-align: left; }
.photo-thumb[role="button"]:focus-visible { outline: 3px solid rgba(22,125,121,.3); outline-offset: 2px; }
.photo-remove { width: 27px; height: 27px; border: 1px solid #efd5d1; border-radius: 8px; color: var(--red); background: #fff; font-size: 17px; cursor: pointer; }
.photo-thumb-placeholder { display: grid; place-items: center; width: 64px; height: 52px; border-radius: 7px; color: var(--muted); background: #e8efed; font-size: 10px; }
.photo-drop > div > span { display: block; margin-bottom: 7px; color: var(--teal); font-size: 27px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row label { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-soft); background: #fff; font-size: 11px; }
.choice-row input { accent-color: var(--teal); }
.guide-sticky { position: sticky; top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.guide-sticky h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.guide-sticky > p:not(.card-kicker) { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.guide-warm { border-color: #f0d1a7; background: linear-gradient(155deg, #fffaf2, white 70%); }
.guide-warm .card-kicker { color: #a05c1a; }
.guide-line-preview { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--ink); font-size: 11px; font-weight: 740; }
.guide-line-preview i { flex: 1; border-top: 2px dashed #a7bab5; }
.guide-line-preview.is-active i { border-color: var(--orange); }
.guide-photo-state { margin: 11px 0; padding: 9px 10px; border-radius: 9px; color: #725632; background: #fff5e9; font-size: 10px; line-height: 1.4; }
.guide-photo-state.is-connected { color: #165c4e; background: #e7f5ee; }
.outline-diagnostic { color: #7c4821; }
.secondary-details { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.secondary-details summary { color: var(--teal-dark); font-size: 12px; font-weight: 720; cursor: pointer; }
.distance-editor { grid-column: 1 / -1; margin: 11px 0 2px; padding: 12px; border: 1px solid #d8e5e1; border-radius: 10px; background: #fff; }
.distance-editor .small { grid-column: 1 / -1; margin: 0; }
.height-list { display: grid; gap: 8px; margin-bottom: 12px; }
.height-row { display: grid; grid-template-columns: minmax(75px,.7fr) minmax(0,1fr) auto auto; align-items: center; gap: 7px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fafcfb; font-size: 10px; }
.height-row strong { color: var(--ink-soft); font-weight: 640; }
.project-list-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); }
.project-list-row > div:first-child { min-width: 0; }
.project-list-row strong, .project-list-row small { display: block; overflow-wrap: anywhere; }
.project-list-row strong { font-size: 12px; }
.project-list-row small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.project-list-row .row-actions { flex-wrap: wrap; justify-content: flex-end; }
.view-grid { grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); }
.viewer-mount, .plan-frame { min-width: 0; }
.metric-strip > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-alt); }
.metric-strip > div span { display: block; color: var(--muted); font-size: 10px; line-height: 1.3; }
.metric-strip > div strong { display: block; margin-top: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.diagnostic-grid > div { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); }
.diagnostic-grid strong { font-size: 12px; }
.diagnostic-grid p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.diagnostic-list { display: grid; gap: 6px; margin: 11px 0; padding-left: 20px; color: #80501f; font-size: 11px; line-height: 1.45; }
.modal-inline-card { border-color: #e9d4b9 !important; background: #fffaf3 !important; }

@media (max-width: 960px) {
  .room-grid, .view-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-sticky { position: static; }
}

@media (max-width: 640px) {
  .stage-heading { display: grid; grid-template-columns: minmax(0,1fr); }
  .stage-content .card { padding: 14px; }
  .form-grid { grid-template-columns: minmax(0,1fr); gap: 9px; }
  .form-grid > .button[type="submit"], .form-actions, .saved-reading, .distance-editor .small { grid-column: 1; }
  .point-row, .measurement-row, .furniture-row { grid-template-columns: minmax(0,1fr); }
  .row-actions { justify-content: flex-end; }
  .photo-thumb { grid-template-columns: 50px minmax(0,1fr) auto; gap: 7px; }
  .photo-thumb img, .photo-thumb-placeholder { width: 50px; height: 44px; }
  .height-row { grid-template-columns: minmax(55px,.65fr) minmax(0,1fr) auto; }
  .height-row .danger-icon { grid-column: 3; }
  .metric-strip > div { padding: 8px; }
  .metric-strip > div strong { font-size: 12px; }
  .diagnostic-grid { grid-template-columns: minmax(0,1fr); }
  .project-list-row { grid-template-columns: minmax(0,1fr); }
  .project-list-row .row-actions { justify-content: flex-start; }
}

.ar-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 410px); grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom)); color: #f4f8f8; background: rgba(7, 17, 23, .2); isolation: isolate; }
.ar-overlay[hidden] { display: none; }
.ar-scene { position: absolute; z-index: -1; inset: 0; overflow: hidden; background: #18252b; }
.ar-overlay:xr-overlay .ar-scene { background: transparent; }
.ar-scene canvas { display: block; width: 100%; height: 100%; }
.ar-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ar-reticle { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 38px; height: 38px; transform: translate(-50%, -50%); border: 1px solid rgba(255,255,255,.82); border-radius: 50%; color: white; text-shadow: 0 1px 4px #000; }
.ar-reticle span::before, .ar-reticle span::after { position: absolute; left: 50%; top: 50%; content: ""; background: white; transform: translate(-50%, -50%); }
.ar-reticle span::before { width: 18px; height: 2px; }
.ar-reticle span::after { width: 2px; height: 18px; }
.ar-topbar { grid-column: 1; display: flex; align-items: start; justify-content: space-between; gap: 15px; min-width: 0; padding: 12px 15px; border: 1px solid rgba(255,255,255,.22); border-radius: 15px; color: white; background: rgba(11, 25, 32, .86); backdrop-filter: blur(12px); }
.ar-topbar h2 { margin: 2px 0 0; font-size: clamp(17px, 2vw, 22px); line-height: 1.2; }
.ar-kicker { margin: 0 0 4px; color: #9ccbc7; font-size: 9px; font-weight: 800; letter-spacing: .11em; line-height: 1.3; }
.ar-close { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.3); border-radius: 12px; color: white; background: rgba(255,255,255,.1); font-size: 26px; line-height: 1; cursor: pointer; }
.ar-status { grid-column: 1; align-self: start; max-width: min(680px, 100%); min-height: 40px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; color: white; background: rgba(11,25,32,.78); font-size: 12px; line-height: 1.45; backdrop-filter: blur(10px); }
.ar-controls { grid-column: 2; grid-row: 1 / 4; min-width: 0; max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 16px; border: 1px solid rgba(255,255,255,.3); border-radius: 18px; color: var(--ink); background: rgba(250, 252, 251, .96); box-shadow: 0 20px 70px rgba(0,0,0,.28); -webkit-overflow-scrolling: touch; }
.ar-controls-head, .ar-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ar-controls-head h3, .ar-list-heading h3 { margin: 0; font-size: 15px; line-height: 1.25; }
.ar-list-heading { margin: 14px 0 8px; }
.ar-list-heading .ar-kicker { margin-bottom: 2px; }
.ar-badge { flex: 0 0 auto; padding: 5px 8px; border: 1px solid #d5e3df; border-radius: 999px; color: #39545a; background: #f4f8f6; font-size: 10px; font-weight: 730; }
.ar-explanation { margin: 9px 0; color: #596a70; font-size: 11px; line-height: 1.45; }
.ar-task-panel, .ar-selection-panel { display: grid; gap: 8px; }
.ar-card { padding: 11px; border: 1px solid #dce6e2; border-radius: 12px; background: white; }
.ar-card h4 { margin: 0 0 6px; font-size: 12px; }
.ar-card p { margin: 5px 0; color: #53666d; font-size: 11px; line-height: 1.45; }
.ar-card strong { color: var(--ink); }
.ar-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.ar-button { min-height: 42px; padding: 8px 11px; border: 1px solid #cbd9d5; border-radius: 10px; color: #174b4c; background: #fff; font-size: 11px; font-weight: 730; cursor: pointer; }
.ar-button-primary { border-color: #176f6b; color: white; background: #176f6b; }
.ar-button-warn { border-color: #ebd5b6; color: #754816; background: #fff6e9; }
.ar-button:disabled { opacity: .48; cursor: not-allowed; }
.ar-guide-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; padding: 2px; overscroll-behavior: contain; }
.ar-guide-row { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: start; gap: 8px; width: 100%; padding: 8px; border: 1px solid #dde6e3; border-radius: 10px; color: var(--ink); background: white; text-align: left; cursor: pointer; }
.ar-guide-row.is-selected { border-color: #1c817b; background: #eaf5f2; box-shadow: 0 0 0 2px rgba(28,129,123,.1); }
.ar-guide-row:focus-visible, .ar-label:focus-visible { outline: 3px solid rgba(22,125,121,.42); outline-offset: 2px; }
.ar-guide-row .ar-guide-title { display: block; font-size: 11px; font-weight: 760; line-height: 1.35; }
.ar-guide-row .ar-guide-meta { display: block; margin-top: 2px; color: #5e6f74; font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.ar-guide-row .ar-guide-detail { display: block; margin-top: 4px; color: #42585f; font-size: 10px; line-height: 1.4; }
.ar-guide-row .ar-guide-kind { margin-top: 1px; padding: 3px 5px; border-radius: 6px; color: #526a6e; background: #eff4f2; font-size: 8px; font-weight: 760; white-space: nowrap; }
.ar-guide-row .ar-guide-kind.is-free { color: #7a4a12; background: #fff1dc; }
.ar-vector-form { display: grid; gap: 8px; margin-top: 13px; padding: 11px; border: 1px solid #e6d4b8; border-radius: 12px; background: #fffbf5; }
.ar-vector-form[hidden] { display: none; }
.ar-vector-form label { display: grid; gap: 4px; color: #465b61; font-size: 10px; font-weight: 700; }
.ar-vector-form input, .ar-vector-form select, .ar-point-form input { width: 100%; min-height: 40px; padding: 7px 9px; border: 1px solid #d5dfdc; border-radius: 8px; color: var(--ink); background: white; font-size: 12px; }
.ar-field-pair { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.ar-callout { margin: 0; padding: 9px 10px; border-left: 3px solid #d78a3e; border-radius: 0 8px 8px 0; color: #684b2a; background: #fff1dc; font-size: 10px; line-height: 1.45; }
.ar-callout-muted { margin-top: 12px; border-left-color: #76aaa1; color: #445c60; background: #edf5f2; }
.ar-rotate-pad { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 8px 10px; border: 1px dashed #c7a775; border-radius: 9px; color: #684b2a; background: #fff7eb; touch-action: pan-y; user-select: none; cursor: ew-resize; }
.ar-rotate-pad span:first-child { font-size: 20px; font-weight: 760; }
.ar-rotate-pad span:last-child { font-size: 9px; line-height: 1.35; }
.ar-label { position: absolute; transform: translate(-50%, -50%); max-width: min(230px, 40vw); padding: 5px 7px; border: 1px solid rgba(255,255,255,.76); border-radius: 8px; color: #fff; background: rgba(11,29,34,.86); box-shadow: 0 2px 8px rgba(0,0,0,.35); font-size: 10px; line-height: 1.25; text-align: left; pointer-events: auto; cursor: pointer; }
.ar-label[data-kind="free-vector"] { border-color: #ffd391; background: rgba(97,56,12,.88); }
.ar-label[data-kind="measurement"] { border-color: #bfe7dc; }
.ar-vector-form input:focus-visible, .ar-vector-form select:focus-visible, .ar-point-form input:focus-visible { outline: 3px solid rgba(22,125,121,.3); }

@media (max-width: 760px) {
  .ar-overlay { display: block; padding: calc(9px + env(safe-area-inset-top)) 10px 0; }
  .ar-topbar { position: relative; margin-right: auto; width: min(100%, 560px); padding: 9px 10px; border-radius: 13px; }
  .ar-topbar h2 { font-size: 16px; }
  .ar-close { width: 42px; height: 42px; flex-basis: 42px; }
  .ar-status { position: relative; width: min(100%, 560px); min-height: 0; margin-top: 7px; padding: 8px 9px; font-size: 10px; }
  .ar-controls { position: absolute; left: 0; right: 0; bottom: 0; max-height: min(54dvh, 520px); padding: 13px 13px calc(14px + env(safe-area-inset-bottom)); border-radius: 19px 19px 0 0; }
  .ar-guide-list { max-height: 210px; }
  .ar-reticle { width: 34px; height: 34px; }
  .ar-label { max-width: 42vw; font-size: 9px; }
}

@media (max-width: 380px) {
  .ar-controls { padding-inline: 10px; }
  .ar-guide-row { grid-template-columns: 25px minmax(0,1fr); }
  .ar-guide-row .ar-guide-kind { grid-column: 2; justify-self: start; }
  .ar-field-pair { gap: 6px; }
}
