:root {
  --bg: #f5f5f7;            /* aligned with PFOS src/design/tokens.css (light) */
  --panel: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #3c3c43;
  --ink-3: #6e6e73;
  --line: #e3e3e8;
  --accent: #0a66d6;
  --accent-ink: #ffffff;
  --accent-soft: #e8f1fd;
  --select: #0a66d6;
  --floor: #f6f1e6;
  --floor-draft: #fbf8f1;
  --wall: #3a3f45;
  --grid-minor: #e3e6e9;
  --grid-major: #cfd4d8;
  --warn: #935a00;
  --warn-soft: #fdf3e1;
  --error: #c0281c;
  --error-soft: #fdecea;
  --ok: #1e7b34;
  --radius: 10px;
  --touch: 44px;
  --fill: #f2f2f5;           /* quiet button fill */
  --fill-2: #e9e9ee;
  --shadow-card: 0 0 0 1px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--select); outline-offset: 2px; }

.app {
  display: grid;
  grid-template-columns: 330px 1fr 310px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top top" "tools stage inspector";
  height: 100vh;
  height: 100dvh;
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tools { grid-area: tools; border-right: 1px solid var(--line); }
.inspector { grid-area: inspector; border-left: 1px solid var(--line); }
.panel { background: var(--panel); overflow-y: auto; padding: 14px; }
.stage { grid-area: stage; position: relative; overflow: hidden; }
.canvas { width: 100%; height: 100%; display: block; background: #fbfbfa; touch-action: none; user-select: none; }
.canvas.panning { cursor: grabbing; }
.canvas-controls { position: absolute; right: 10px; bottom: 30px; display: flex; gap: 6px; padding: 4px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.canvas-hint { position: absolute; left: 12px; right: 12px; bottom: 6px; margin: 0; font-size: 12px; color: var(--ink-3); pointer-events: none; }
.banner:empty, .confirm:empty { display: none; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 55vh auto auto; grid-template-areas: "top" "stage" "tools" "inspector"; height: auto; }
  .tools, .inspector { border: 0; border-top: 1px solid var(--line); }
  .canvas-hint { display: none; }
  .canvas-controls { bottom: 10px; }
}

.brand { display: flex; align-items: baseline; gap: 6px; font-weight: 700; letter-spacing: .02em; }
.brand .mark { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 2px 7px; }
.brand .sub { font-weight: 500; color: var(--ink-2); }
.project-name { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.group { display: flex; align-items: center; gap: 6px; }

.btn, .text-btn, .icon-btn, .dir-btn, .tab {
  min-height: var(--touch); border-radius: var(--radius); border: 1px solid transparent; background: var(--fill); padding: 0 14px; font-weight: 500;
}
.icon-btn { min-width: var(--touch); padding: 0; font-size: 20px; line-height: 1; background: var(--panel); }
.text-btn { background: var(--panel); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--error); }
.btn:disabled, .icon-btn:disabled, .dir-btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: var(--touch); padding: 0 12px; font-size: 14px; }

select, input[type="text"] { min-height: var(--touch); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; background: #fff; width: 100%; }
label.field { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.hint { font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }
.preview { font-size: 13px; margin: 4px 0 0; min-height: 18px; }
.preview.ok { color: var(--ok); }
.preview.err { color: var(--error); }
h2 { font-size: 15px; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; font-weight: 600; }
.tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); background: #fff; }
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.pill.saved .dot { background: var(--ok); }
.pill.saving .dot, .pill.unsaved .dot { background: var(--warn); }
.pill.failed, .pill.conflict { border-color: var(--error); color: var(--error); background: var(--error-soft); }
.pill.failed .dot, .pill.conflict .dot { background: var(--error); }
.pill.unsent { border-color: var(--warn); }
.pill.unsent .dot { background: var(--warn); }

.compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.dir-btn { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; background: var(--panel); font-weight: 600; }
.dir-btn .arrow { font-size: 22px; line-height: 1; }
.dir-btn .code { font-size: 12px; color: var(--ink-2); }
.dir-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dir-btn[aria-pressed="true"] .code { color: var(--accent-ink); }
.compass .center { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 4px; }

.walls { list-style: none; padding: 0; margin: 0; counter-reset: wall; }
.walls li button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 8px; min-height: var(--touch); border: 1px solid transparent; border-radius: 8px; background: none; padding: 0 8px; }
.walls li button:hover { background: #f3f5f6; }
.walls li button[aria-current="true"] { border-color: var(--select); background: #eef3fd; }
.walls .src { font-size: 12px; color: var(--ink-3); }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; }
.card.ok { border-color: #b7dfc4; background: #f1faf4; }
.card.warn { border-color: #f1d49c; background: var(--warn-soft); }
.card.err { border-color: #f3b8b2; background: var(--error-soft); }
.card p { margin: 4px 0; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 8px 0; }
.check input { width: 22px; height: 22px; margin: 0; }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 8px 0; }
.stats dt { color: var(--ink-2); }
.stats dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
table.edges { width: 100%; border-collapse: collapse; font-size: 14px; }
table.edges th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 4px; }
table.edges td { padding: 0; border-top: 1px solid #eef0f2; }
table.edges td button { width: 100%; min-height: var(--touch); text-align: left; background: none; border: 0; padding: 0 4px; display: grid; grid-template-columns: 32px 1fr auto; gap: 6px; align-items: center; }
table.edges tr[aria-selected="true"] td button { background: #eef3fd; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .02em; border-radius: 4px; padding: 1px 5px; border: 1px solid currentColor; }
.tag.measured { color: var(--ok); }
.tag.derived { color: var(--warn); }
.tag.provisional { color: var(--ink-3); border-style: dashed; }
.tag.adjusted { color: var(--select); }
.tag.copied { color: #6d4aa8; border-style: dotted; }
.room-list { list-style: none; padding: 0; margin: 0; }
.room-list button { width: 100%; min-height: var(--touch); display: flex; justify-content: space-between; background: none; border: 0; border-bottom: 1px solid #eef0f2; padding: 0 4px; }
.muted { color: var(--ink-3); }

.notice { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.08); font-size: 14px; }
.notice.err { border-color: #f3b8b2; background: var(--error-soft); }
.notice.warn { border-color: #f1d49c; background: var(--warn-soft); }
.notice .grow { flex: 1; min-width: 200px; }

.overlay { position: fixed; inset: 0; background: rgba(20, 25, 30, .45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay[hidden] { display: none; }
.dialog { background: #fff; border-radius: 14px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog h1 { font-size: 18px; margin: 0 0 12px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* Canvas drawing */
.grid-minor { stroke: var(--grid-minor); stroke-width: 1; }
.grid-major { stroke: var(--grid-major); stroke-width: 1; }
.wall { fill: var(--wall); stroke: var(--wall); stroke-linejoin: miter; }
.floor { fill: var(--floor); }
.floor.invalid { fill: var(--error-soft); }
.dim { font-size: 12px; fill: var(--ink); paint-order: stroke; stroke: var(--floor); stroke-width: 4px; font-variant-numeric: tabular-nums; }
.dim.outside { stroke: #fbfbfa; }
.dim.derived { font-style: italic; fill: var(--warn); }
.dim.provisional { fill: var(--ink-3); }
.dim.adjusted { fill: var(--select); }
.dim.copied { fill: #6d4aa8; }
.room-name { font-size: 14px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--floor); stroke-width: 4px; }
.room-area { font-size: 12px; fill: var(--ink-2); paint-order: stroke; stroke: var(--floor); stroke-width: 4px; font-variant-numeric: tabular-nums; }
.sel-outline { fill: none; stroke: var(--select); stroke-width: 2; stroke-dasharray: 6 4; }
.sel-outline.also { stroke-width: 1.5; stroke-dasharray: none; opacity: .55; }
.sel-hatch { pointer-events: none; }
.sel-hatch-line { stroke: var(--select); stroke-width: 1; opacity: .16; }
/* Round 6: selection has to be obvious on every category colour, and on service-only and
   unassigned rooms. The wash tints whatever is underneath without replacing it; the outline is
   thick and high-contrast; the focused room gets a second inner line, so the rest still read as
   selected beside it. Editor-only: customer drawings and frozen layouts never carry these. */
.sel-wash { fill: var(--select); opacity: .18; pointer-events: none; }
.sel-outline { fill: none; stroke: var(--select); stroke-width: 4; stroke-linejoin: round; paint-order: stroke; pointer-events: none; }
.sel-outline.focused { stroke-width: 6; stroke-dasharray: none; filter: drop-shadow(0 0 2px rgba(255,255,255,.9)); }
@media (prefers-contrast: more) { .sel-wash { opacity: .28; } .sel-outline { stroke-width: 5; } }
.sel-edge { stroke: var(--select); stroke-width: 6; stroke-linecap: round; }
.handle { fill: #fff; stroke: var(--select); stroke-width: 2; }
.draft-path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.draft-close { fill: none; stroke: var(--warn); stroke-width: 2; stroke-dasharray: 8 6; }
.draft-dim { font-size: 12px; fill: var(--accent); font-weight: 600; paint-order: stroke; stroke: #fbfbfa; stroke-width: 4px; }
.draft-close-label { font-size: 12px; fill: var(--warn); font-style: italic; paint-order: stroke; stroke: #fbfbfa; stroke-width: 4px; }
.draft-start { fill: var(--accent); }
.endpoint { fill: #fff; stroke: var(--accent); stroke-width: 3; }
.endpoint-label { font-size: 12px; fill: var(--accent); font-weight: 600; paint-order: stroke; stroke: #fbfbfa; stroke-width: 4px; }
.ghost { fill: none; stroke: var(--select); stroke-width: 2; stroke-dasharray: 4 4; }
.moved { fill: var(--select); }
.bad-edge { stroke: var(--error); stroke-width: 4; }
.draft-wall-selected { stroke: var(--select); stroke-width: 6; stroke-linecap: round; }

/* Milestone 4: editing, snapping, overlap */
.wall-handle { fill: #fff; stroke: var(--select); stroke-width: 2; cursor: grab; }
.handle { cursor: grab; }
.handle.moved-corner { fill: var(--select); }
.dim.changed { fill: var(--select); font-weight: 700; }
.invalid-preview { fill: rgba(180, 35, 24, .08); stroke: var(--error); stroke-width: 2; stroke-dasharray: 6 4; }
.snap-guide { stroke: #d6336c; stroke-width: 2; stroke-dasharray: 10 5; }
.snap-guide.corner { stroke-width: 1.5; stroke-dasharray: 3 4; }
.overlap-outline { fill: rgba(180, 35, 24, .12); stroke: var(--error); stroke-width: 2.5; stroke-dasharray: 2 4; }
.icon-btn[aria-pressed="true"], .text-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.text-btn[aria-pressed="false"] { color: var(--ink-3); }
.ready-ok { color: var(--ok); font-weight: 700; }
.ready-no { color: var(--warn); font-weight: 700; }

/* Milestone 5 */
.room-heading { font-size: 17px; margin: 0 0 8px; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 1 1 auto; }
.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin-bottom: 8px; border-radius: var(--radius); background: #eef3fd; border: 2px solid var(--select); color: var(--select); }
.row-static { display: grid; grid-template-columns: 32px 1fr auto; gap: 6px; align-items: center; min-height: 36px; padding: 0 4px; }
.empty-state { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink-2); font-size: 14px; }
.empty-state p { margin: 4px 0; }
fieldset.conflict { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 4px 10px; }
fieldset.conflict legend { font-size: 13px; font-weight: 600; }
.editing-outline { fill: none; stroke: var(--select); stroke-width: 3; }
.sel-vertex { fill: var(--select); stroke: #fff; stroke-width: 2; }
.start-marker { fill: var(--select); }
.split-marker { fill: #fff; stroke: var(--accent); stroke-width: 3; }
.ghost-rotate, .ghost-remove, .ghost-merge, .ghost-length { fill: rgba(31, 95, 214, .08); stroke: var(--select); stroke-width: 2; stroke-dasharray: 8 5; }
.ghost-merge { fill: rgba(10, 102, 214, .1); stroke: var(--accent); stroke-width: 3; }
.pivot { stroke: var(--select); stroke-width: 2; }
.merge-secondary { fill: rgba(214, 51, 108, .12); stroke: #d6336c; stroke-width: 2; stroke-dasharray: 4 3; }
.draft-other-end { fill: #fff; stroke: var(--accent); stroke-width: 2; }

/* Milestone 6: visual tools, keypad, angles, rotation */
.icon { width: 24px; height: 24px; flex: none; }
.with-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.with-icon .icon { width: 22px; height: 22px; }
.stage-top { position: absolute; top: 8px; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); z-index: 3; display: flex; flex-direction: column; align-items: stretch; gap: 8px; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
/* The overlay strip: transparent to touches so taps land on the plan beneath it. */
.toolbar { display: flex; align-items: flex-start; gap: 8px; align-self: stretch; pointer-events: none; }
/* The part that actually holds the groups — and the part that has to receive touches. It
   shrink-wraps, so it never covers plan it is not drawing on. */
.toolbar-scroll { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; max-width: 100%; pointer-events: auto; }
.toolbar-more { display: none; }
.tool-group { display: flex; gap: 6px; padding: 4px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.08); pointer-events: auto; flex-wrap: wrap; }
.tool-btn { min-width: 60px; min-height: 58px; padding: 4px 6px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1.5px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); }
.tool-btn .tool-label { font-size: 12px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.tool-btn:hover:not(:disabled) { background: #f1f3f5; }
.tool-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tool-btn[aria-pressed="true"] .tool-label::before { content: "● "; font-size: 9px; vertical-align: 1px; }
.tool-btn.primary { background: var(--accent); color: var(--accent-ink); }
.tool-btn.primary:hover { background: #0858bb; }
.tool-btn.danger { color: var(--error); }
.tool-btn:disabled { color: var(--ink-3); opacity: .42; cursor: not-allowed; }
.tool-btn.small { min-width: 52px; min-height: 52px; }
.tool-btn.small .tool-label { font-size: 11px; }
.tool-status { display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 14px; min-height: 58px; }
.confirm-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; border-radius: 14px; border: 2px solid var(--select); background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 14px; }
.confirm-bar.warn { border-color: #e0a431; background: var(--warn-soft); }
.confirm-bar.err { border-color: var(--error); background: var(--error-soft); }
.confirm-bar .grow { flex: 1 1 240px; display: inline-flex; align-items: center; gap: 8px; }
.confirm-bar .btn { min-height: 48px; }
.confirm-bar .bar-stepper { display: inline-flex; align-items: center; gap: 4px; }
.confirm-bar .bar-stepper .step-btn { min-width: 48px; min-height: 48px; }
.confirm-bar .bar-stepper + .btn { margin-left: auto; }
@media (max-width: 600px) { .confirm-bar .icon-only-narrow span { display: none; } .confirm-bar .icon-only-narrow { min-width: 48px; padding: 0 10px; } }
.confirm-bar .bar-count { min-width: 28px; text-align: center; font-weight: 800; font-size: 18px; }

.measure-field { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; padding: 0 12px; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; font-size: 18px; font-variant-numeric: tabular-nums; }
.measure-field.big { min-height: 58px; font-size: 20px; font-weight: 600; }
.measure-field .mf-value.empty { color: var(--ink-3); font-weight: 400; font-size: 16px; }
.measure-field .mf-icon { color: var(--accent); }
.measure-field.active { border-color: var(--select); box-shadow: 0 0 0 3px rgba(31,95,214,.18); }
.mfield-wrap .field { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.dir-btn .icon { width: 22px; height: 22px; }

.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 4px 0 8px; }
.big-stat { display: flex; flex-direction: column; }
.big-stat .k { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.big-stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); background: #f7f8f9; color: var(--ink-2); }
.chip.ok { color: var(--ok); border-color: #b7dfc4; background: #f1faf4; }
.chip.warn { color: var(--warn); border-color: #f1d49c; background: var(--warn-soft); }
.card.focus { border-left: 4px solid var(--select); }
.card.muted-card { border-left-color: var(--line); }
.card.compact p { font-size: 13px; }
.card-title { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-weight: 700; font-size: 15px; margin: 2px 0 4px; }
.card-title > span:first-of-type { flex: 1; }
.card-title .icon { width: 20px; height: 20px; }
.big-line { font-size: 24px; font-weight: 700; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.big-line .small { font-size: 13px; font-weight: 400; }
.err-text { color: var(--error); }
.edit-banner .icon { width: 22px; height: 22px; }
.edit-banner strong { flex: 1; }
.details { border-top: 1px solid var(--line); margin-top: 12px; }
.details > summary { list-style: none; min-height: var(--touch); display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.details > summary::-webkit-details-marker { display: none; }
.details .chev { width: 18px; height: 18px; transition: transform .15s; }
.details[open] .chev { transform: rotate(90deg); }
p.field { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
.tab.with-icon { gap: 6px; padding: 0 8px; white-space: nowrap; font-size: 15px; }
#tools .tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
#tools .tab.with-icon { flex-direction: column; gap: 2px; padding: 4px 2px; font-size: 13px; min-height: 56px; min-width: 0; }
.tab.with-icon .icon { width: 20px; height: 20px; }

/* Keypad */
.keypad-host { z-index: 6; background: var(--panel); overflow-y: auto; padding: 12px; box-shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0,0,0,.18); }
.keypad-host[hidden] { display: none; }
.keypad-host[data-dock="tools"] { grid-area: tools; }
.keypad-host[data-dock="inspector"] { grid-area: inspector; }
.keypad { display: flex; flex-direction: column; gap: 8px; }
.kp-pad { display: flex; flex-direction: column; gap: 8px; }
.kp-head { display: flex; flex-direction: column; gap: 2px; }
.kp-title { font-weight: 700; font-size: 15px; }
.kp-current { font-size: 13px; color: var(--ink-3); }
.kp-display { border: 2px solid var(--select); border-radius: 12px; padding: 8px 12px; background: #f7faff; outline: none; }
.kp-value { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.kp-sec { font-size: 14px; color: var(--ink-2); min-height: 18px; }
.kp-sec.err { color: var(--error); font-weight: 600; }
.kp-sys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.kp-sysbtn { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #f7f8f9; font-weight: 600; }
.kp-sysbtn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.kp-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kp-unit { min-height: 48px; border: 2px solid var(--line); border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 14px; }
.kp-unit.big { min-height: 60px; flex-direction: column; gap: 0; }
.kp-unit .kp-fv { font-size: 20px; font-variant-numeric: tabular-nums; }
.kp-unit[aria-pressed="true"] { border-color: var(--select); background: #eef3fd; color: var(--select); box-shadow: inset 0 -4px 0 var(--select); }
.kp-fracs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.kp-frac { min-height: 46px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kp-frac.more { font-size: 13px; color: var(--ink-2); background: #f7f8f9; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kp-key { min-height: 56px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 24px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.kp-key:active, .kp-frac:active, .tool-btn:active { transform: translateY(1px); }
.kp-actions { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 8px; }
.kp-act { min-height: 56px; border: 1px solid var(--line); border-radius: 10px; background: #f7f8f9; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; }
.kp-act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.kp-act.not-ready { opacity: .5; }
.kp-display:focus { outline: none; }
.kp-display:focus-visible { outline: 3px solid var(--select); outline-offset: 2px; }
.kp-compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kp-dir-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-align: center; border: 1px dashed var(--ink-3); border-radius: 10px; background: #fff; min-height: 46px; }
.kp-compass.big .kp-dir, .kp-compass.big .kp-dir-center { min-height: 72px; font-size: 14px; }
.kp-compass.big .kp-dir { flex-direction: column; }
.kp-compass.big .icon { width: 28px; height: 28px; }
.kp-draft { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kp-actions.one { grid-template-columns: 1fr; }
.kp-dir { min-height: 46px; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.kp-hint { font-size: 12px; color: var(--ink-3); margin: 0; }

/* Canvas: angles, rotation, pending values */
.angle-arc { fill: rgba(31, 95, 214, .12); stroke: var(--select); stroke-width: 1.5; }
.angle-label { font-size: 13px; font-weight: 700; fill: var(--select); paint-order: stroke; stroke: #fff; stroke-width: 4px; font-variant-numeric: tabular-nums; }
.angle.snapped .angle-arc { fill: rgba(214, 51, 108, .16); stroke: #d6336c; stroke-width: 2.5; }
.angle.snapped .angle-label { fill: #b0254f; }
.angle.small .angle-label { font-size: 11px; }
.angle.static .angle-arc { fill: rgba(31, 95, 214, .07); }
.rotate-handle { cursor: grab; }
.rotate-handle circle { fill: var(--accent); stroke: #fff; stroke-width: 3; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.rotate-handle path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pivot-mark circle { fill: rgba(255,255,255,.85); stroke: var(--select); stroke-width: 2; }
.pivot-mark path { stroke: var(--select); stroke-width: 2; }
.ghost-original { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 6 5; }
.rotate-arm { stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 4 4; }
.rotate-arm.snapped { stroke: #d6336c; stroke-width: 2; }
.rotate-deg { font-size: 22px; font-weight: 800; fill: var(--select); paint-order: stroke; stroke: #fff; stroke-width: 5px; font-variant-numeric: tabular-nums; }
.rotate-readout.snapped .rotate-deg { fill: #b0254f; }
.rotate-turn { font-size: 12px; font-weight: 600; fill: var(--ink-2); paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.pending-label { font-size: 14px; font-weight: 800; fill: var(--accent); paint-order: stroke; stroke: #fff; stroke-width: 5px; font-variant-numeric: tabular-nums; }
.pending-label.active { fill: var(--select); }
.ghost-rect { fill: rgba(10, 102, 214, .06); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 8 5; }

@media (max-width: 1000px) {
  .keypad-host { position: fixed; left: 0; right: 0; bottom: 0; max-height: 60vh; max-height: 60dvh; border-radius: 16px 16px 0 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .keypad-host .keypad { max-width: 560px; margin: 0 auto; }
  /* Keep the plan visible above the keypad sheet. */
  body.keypad-open .app { grid-template-rows: auto 38vh auto auto; padding-bottom: 60vh; }
  /* While the keypad sheet is open the plan shows what is being measured; the tools wait. */
  body.keypad-open .toolbar, body.keypad-open .canvas-controls { display: none; }
}
@media (max-width: 600px) {
  /* Phone: fractions beside the digits, slightly smaller keys, so the plan stays visible. */
  .kp-pad:not(.digits-only) { display: grid; grid-template-columns: 3fr 2fr; gap: 8px; }
  .kp-pad .kp-fracs { order: 2; grid-template-columns: repeat(2, 1fr); align-content: start; }
  .kp-pad .kp-grid { order: 1; }
  .kp-key { min-height: 48px; font-size: 22px; }
  .kp-frac { min-height: 44px; font-size: 15px; }
  .kp-unit.big { min-height: 50px; }
  .kp-value { font-size: 26px; }
  .kp-act { min-height: 50px; }
  .keypad { gap: 6px; }
  .kp-title { font-size: 14px; }
  /* A compact top bar: two rows instead of four. */
  .topbar { gap: 6px; padding: 6px 8px; }
  .brand .sub, .topbar label[for="level-select"] { display: none; }
  .project-name { max-width: 96px; font-size: 14px; }
  .topbar .btn.small { padding: 0 10px; }
  /* Round 5: the scenario selector rides on the first row rather than adding one — on a phone a
     row of the top bar is a row the plan and the tool dock lose. The selector itself names the
     scenario in view, so the word "Scenario", the button's label and the alternatives count are
     what give up their space; every target stays 44 px. */
  .scenario-group > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .scenario-group #scenario-count { display: none; }
  .scenario-group #scenario-select { max-width: 30vw; }
  .scenario-group .scenario-add span { display: none; }
  .scenario-group .scenario-add { min-width: 44px; padding: 0 10px; }
  .pill { font-size: 12px; padding: 0 8px; }

  .tool-btn { min-width: 54px; }
}
.btn.big-btn { min-height: 56px; font-size: 17px; }

/* Milestone 7: staircases */
.stair-flight { fill: #e8eef6; stroke: #3d4d63; stroke-width: 2; }
.stair-landing { fill: #f1ece0; stroke: #3d4d63; stroke-width: 2; }
.stair-flight.provisional, .stair-landing.provisional { stroke-dasharray: 7 4; }
.tread-line { stroke: #6f7f93; stroke-width: 1.2; }
.stair-top-rise { stroke: #3d4d63; stroke-width: 3; }
.stair-arrow { fill: none; stroke: #1d2329; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stair-up { font-size: 10px; font-weight: 800; letter-spacing: .06em; fill: #1d2329; paint-order: stroke; stroke: #e8eef6; stroke-width: 3px; }
.stair-name { font-size: 13px; font-weight: 800; fill: var(--ink); paint-order: stroke; stroke: #e8eef6; stroke-width: 4px; }
.stair-label { font-size: 12px; font-weight: 600; fill: var(--ink-2); paint-order: stroke; stroke: #e8eef6; stroke-width: 4px; }
.stair-label.small { stroke: #f1ece0; }
.stair-part-selected { fill: rgba(31, 95, 214, .14); stroke: var(--select); stroke-width: 3; }
.stair-step-selected { fill: rgba(31, 95, 214, .32); stroke: var(--select); stroke-width: 2; }
.stair-step-removed { fill: rgba(180, 35, 24, .28); stroke: var(--error); stroke-width: 2; stroke-dasharray: 4 3; }
.ghost-stair { fill: none; stroke: var(--select); stroke-width: 2; stroke-dasharray: 6 4; }
.ghost-rotate-g .ghost-stair { fill: rgba(31, 95, 214, .06); }
polygon.ghost-original { fill: none; }

.tp-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tp-card { display: grid; grid-template-columns: 84px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; min-height: 96px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.tp-card .tp-diagram { grid-row: 1 / span 2; }
.tp-card .tp-name { font-weight: 800; font-size: 16px; align-self: end; }
.tp-card .tp-desc { font-size: 13px; color: var(--ink-2); align-self: start; }
.tp-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tp-flight { fill: #e8eef6; stroke: #3d4d63; stroke-width: 1.5; }
.tp-landing { fill: #f1ece0; stroke: #3d4d63; stroke-width: 1.5; }
.tp-lines line { stroke: #6f7f93; stroke-width: 1; }
.tp-arrow { fill: none; stroke: #1d2329; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin: 4px 0 8px; }
.seg.parts { margin-bottom: 10px; }
.seg-btn { min-height: 48px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; font-size: 14px; padding: 4px 8px; }
.seg-btn[aria-pressed="true"] { border-color: var(--select); background: #eef3fd; color: var(--select); }
.sv-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.sv-row .measure-field.sv { flex: 1; display: grid; grid-template-columns: 1fr auto auto; gap: 8px; min-height: 52px; font-size: 16px; }
.sv-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sv-value { font-weight: 800; }
.tag.inherit { color: var(--ink-3); border-style: dotted; }
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; align-items: center; }
.step-btn { min-height: 52px; font-size: 26px; font-weight: 700; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.step-btn:disabled { opacity: .4; }
.step-count { text-align: center; font-size: 24px; font-weight: 800; min-height: 52px; border: 1.5px dashed var(--line); border-radius: 10px; background: #fff; font-variant-numeric: tabular-nums; }
.step-count.pending { color: var(--error); border-color: var(--error); }
.stepper-confirm { margin-top: 6px; }
.stepper-confirm .row { display: flex; gap: 8px; flex-wrap: wrap; }
.stepper-confirm .btn { min-height: 48px; }
.hint.warn { color: var(--warn); }
.step-list { display: flex; flex-direction: column; gap: 4px; }
.step-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; min-height: 48px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; text-align: left; font-variant-numeric: tabular-nums; }
.step-row.top { background: #eef1f5; border-style: dashed; }
.step-row.selected { border: 2px solid var(--select); background: #eef3fd; }
.sr-n { font-weight: 800; }
.ovr { color: var(--select); font-size: 14px; }
.qty { width: 100%; border-collapse: collapse; font-size: 14px; }
.qty th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 5px 6px 5px 0; vertical-align: top; }
.qty td { text-align: right; font-weight: 700; padding: 5px 0; font-variant-numeric: tabular-nums; }
.qty tr + tr { border-top: 1px solid #eef0f2; }
.qty-note { font-size: 11px; font-weight: 400; color: var(--ink-3); }
h3.sub { font-size: 14px; margin: 14px 0 4px; }
.warn-text { color: var(--warn); }
.stair-status ul { padding-left: 18px; margin: 6px 0; }
.stair-status li.note { color: var(--ink-2); }
.icon.inline { width: 20px; height: 20px; vertical-align: -3px; }
.seg.three { grid-auto-columns: 1fr; }

/* Milestone 8: U-stair width link, stair scope (finish, risers, skirts) */
.sv-label .sv-was { display: block; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.measure-field.sv.calc { background: #f7f8f9; border-style: dashed; cursor: default; }
.link-card { border-left: 4px solid var(--line); }
.link-card.linked { border-left-color: var(--accent); }
.link-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.lock-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; min-width: 132px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 800; font-size: 15px; }
.lock-btn.on { border-color: var(--accent); background: #e6f3f2; color: var(--accent); }
.link-desc { margin: 0; font-size: 13px; color: var(--ink-2); }
.link-calc { margin: 8px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.relink { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.seg-btn.tall { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; gap: 1px; }
.seg-btn:disabled { opacity: .45; }
.qty .was { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.linkish { border: 0; background: none; padding: 0; color: var(--select); font: inherit; text-decoration: underline; min-height: 0; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 12px 0 6px; border: 2px solid var(--line); border-radius: 999px; background: #fff; font-weight: 800; font-size: 15px; }
.switch-knob { width: 44px; height: 26px; border-radius: 999px; background: #cfd5db; position: relative; flex: none; transition: background .15s; }
.switch-knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s; }
.switch[aria-checked="true"] { border-color: var(--accent); }
.switch[aria-checked="true"] .switch-knob { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob::after { left: 21px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.toggle-btn { min-height: 48px; padding: 4px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; font-size: 14px; }
.toggle-btn[aria-pressed="true"] { border-color: var(--accent); background: #e6f3f2; color: var(--accent); }
.toggle-btn[aria-pressed="true"]::before { content: '✓ '; }
.skirt-list { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 8px; }
.skirt-row .measure-field.sv { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; min-height: 52px; font-size: 16px; }
.skirt-row.review .measure-field.sv { border-color: #f1d49c; }
.skirt-n { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; background: #8a4b12; color: #fff; font-size: 12px; font-weight: 800; }
.card.slim { padding: 8px 10px; margin: 6px 0; }
.hint.small { font-size: 11px; }
.skirt-diagram { margin: 8px 0; }
.skirt-diagram svg { display: block; max-width: 320px; margin: 0 auto; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; }
.sd-flight { fill: #e8eef6; stroke: #3d4d63; stroke-width: 1.2; }
.sd-landing { fill: #f1ece0; stroke: #3d4d63; stroke-width: 1.2; }
.sd-tread { stroke: #8a97a8; stroke-width: .8; }
.sd-arrow { fill: none; stroke: #1d2329; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sd-edge { stroke: #b8c0c9; stroke-width: 2; stroke-dasharray: 4 3; }
.sd-edge.on { stroke: #8a4b12; stroke-width: 5; stroke-dasharray: none; stroke-linecap: round; }
.sd-side { font-size: 13px; font-weight: 800; fill: #4b5563; }
.sd-badge circle { fill: #8a4b12; }
.sd-badge text { fill: #fff; font-size: 11px; font-weight: 800; }
.sd-badge.plan circle { stroke: #fff; stroke-width: 2; }
.skirt-line { stroke: #8a4b12; stroke-width: 6; stroke-linecap: round; opacity: .85; pointer-events: none; }
.stair-rotate-part { fill: rgba(31, 95, 214, .10); stroke: none; pointer-events: none; }
.stair-rotate-frame { fill: none; stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }
.stair-rotate-label { font-size: 12px; font-weight: 800; fill: var(--select); paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
.scope-sum td { font-weight: 600; }
.sd-badge.plan { pointer-events: none; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 1 1 140px; }
.skirt-row .measure-field.sv { grid-template-columns: 1fr auto; grid-template-areas: "label label" "value tag"; padding: 6px 12px; }
.skirt-row .measure-field.sv .sv-label { grid-area: label; }
.skirt-row .measure-field.sv .sv-value { grid-area: value; }
.skirt-row .measure-field.sv .tag { grid-area: tag; justify-self: end; }

/* Milestone 9: curved flights, split landings, irregular treads */
.stair-platform.lower { fill: #efe8d6; }
.stair-platform.higher { fill: #f7f2e6; }
.stair-platform { stroke: #3d4d63; stroke-width: 1; pointer-events: none; }
.split-riser { stroke: #1d2329; stroke-width: 4; stroke-linecap: round; pointer-events: none; }
.split-riser-label { font-size: 11px; font-weight: 800; fill: #1d2329; paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
.split-preview { fill: rgba(31, 95, 214, .08); stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }
.split-preview.lower { fill: rgba(31, 95, 214, .14); }
.split-preview-line { stroke: var(--select); stroke-width: 4; stroke-dasharray: 8 5; pointer-events: none; }
/* Landing treads (field fixes): divided landings, winders, the preview and the line handles. */
.stair-winder { fill: #f4eee0; stroke: #3d4d63; stroke-width: 1; pointer-events: none; }
.stair-winder.alt { fill: #ece4cf; }
.division-line { stroke: #6f7f93; stroke-width: 1.2; stroke-dasharray: 5 4; pointer-events: none; }
.division-line.bad, .divide-preview-line.bad { stroke: var(--error); stroke-dasharray: 4 3; }
.divide-preview { fill: rgba(31, 95, 214, .07); stroke: none; pointer-events: none; }
.divide-preview.alt { fill: rgba(31, 95, 214, .16); }
.divide-preview-line { stroke: var(--select); stroke-width: 3; pointer-events: none; }
.divide-preview-label { font-size: 12px; font-weight: 800; fill: var(--select); pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.division-handle circle { fill: #fff; stroke: var(--select); stroke-width: 2.5; }
.division-handle.shared circle { fill: var(--select); }
.division-handle circle.hit { fill: transparent; stroke: none; }
.divide-card .stepper { margin: 4px 0 8px; }
.div-areas tr.total th, .div-areas tr.total td { font-weight: 800; border-top: 1px solid var(--line); }
.div-start .btn { flex: 1 1 140px; min-height: 44px; }
.couple-wrap .sv-row { align-items: stretch; }
.couple-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; min-height: 44px; padding: 2px 6px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-size: 11px; font-weight: 800; color: var(--muted, #556); }
.couple-btn.on { border-color: var(--accent); background: #e6f3f2; color: var(--accent); }
.couple-btn .icon { width: 18px; height: 18px; }
.split-remove-line { stroke: var(--error); stroke-width: 6; stroke-dasharray: 6 4; pointer-events: none; }
.stair-irregular { fill: rgba(154, 91, 0, .16); stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 3; pointer-events: none; }
.irr-mark circle { fill: var(--warn); }
.irr-mark text { fill: #fff; font-size: 12px; font-weight: 900; }
.irr-mark { pointer-events: none; }
.irr-chip { display: inline-block; padding: 0 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 800; border: 1px solid #f1d49c; }
.step-row.irregular { border-color: #f1d49c; }
.irr-box { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.irr-box.on .switch { border-color: var(--warn); }
.irr-box.on .switch[aria-checked="true"] .switch-knob { background: var(--warn); }
.split-card { border-left: 4px solid #8a97a8; }
.split-icon { display: block; margin: 0 auto 2px; }
.si-landing { fill: #f1ece0; stroke: #3d4d63; stroke-width: 1.5; }
.si-cut { stroke: #1d2329; stroke-width: 3; }
.si-flight { stroke: #3d4d63; stroke-width: 2; }
.plat-btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; }
.plat-btn[aria-pressed="true"]::before { content: none; }
.sd-split { stroke: #1d2329; stroke-width: 3; }
.cd-centre { fill: #1d2329; }
.cd-dim { stroke-width: 2; }
.cd-dim.r { stroke: var(--select); }
.cd-dim.w { stroke: var(--accent); stroke-width: 4; }
.cd-dim.ro { stroke: #8a4b12; stroke-dasharray: 5 4; }
.cd-turn { fill: none; stroke: #6d4aa8; stroke-width: 2; }
.cd-label { font-size: 13px; font-weight: 800; paint-order: stroke; stroke: #fafbfc; stroke-width: 3px; }
.cd-label.r { fill: var(--select); }
.cd-label.w { fill: var(--accent); }
.cd-label.ro { fill: #8a4b12; font-size: 12px; }
.cd-label.t { fill: #6d4aa8; }
.cd-label.up { fill: #1d2329; font-size: 11px; }
.chip.warn { color: var(--warn); }
/* Narrow nested cards: label on its own line, value + tag below; side buttons wrap under. */
.split-card .sv-row, .irr-box .sv-row { flex-wrap: wrap; }
.split-card .sv-row > .measure-field.sv, .irr-box .sv-row > .measure-field.sv { flex: 1 1 180px; min-width: 0; grid-template-columns: 1fr auto; grid-template-areas: "label label" "value tag"; padding: 6px 12px; }
.split-card .measure-field.sv .sv-label, .irr-box .measure-field.sv .sv-label { grid-area: label; }
.split-card .measure-field.sv .sv-value, .irr-box .measure-field.sv .sv-value { grid-area: value; }
.split-card .measure-field.sv .tag, .irr-box .measure-field.sv .tag { grid-area: tag; justify-self: end; }
.split-card .sv-row > .btn.small, .irr-box .sv-row > .btn.small { flex: 1 0 auto; }
.card .card.split-card { padding: 10px; }

/* Milestone 10: simpler tread sizes */
.cust-chip { display: inline-block; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 800; border: 1px solid currentColor; }
.tread-area { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: baseline; padding: 8px 12px; margin: 6px 0; border-radius: 10px; background: var(--bg); }
.tread-area .ta-label { font-weight: 700; }
.tread-area .ta-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.tread-area .ta-how { grid-column: 1 / -1; font-size: 13px; color: var(--ink-3); }
.legacy-tread { margin-top: 10px; }
.stair-custom { fill: rgba(10, 102, 214, .10); stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
.cust-mark circle { fill: var(--accent); }
.cust-mark text { fill: #fff; font-size: 11px; font-weight: 900; }
.cust-mark { pointer-events: none; }

/* Milestone 10: openings */
.opening .op-gap { fill: var(--floor); stroke: none; }
.opening .op-jamb { stroke: var(--wall); stroke-width: 2; }
.opening .op-glass { stroke: #3d7ea6; stroke-width: 1.5; }
.opening .op-leaf { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.opening .op-swing { fill: none; stroke: var(--ink-3); stroke-width: 1.25; stroke-dasharray: 4 3; }
.opening .op-unknown { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 3; }
.opening .op-sel { stroke: var(--select); stroke-width: 5; stroke-linecap: round; opacity: .75; }
.opening .op-handle { fill: #fff; stroke: var(--select); stroke-width: 3; }
.opening.flagged .op-gap { fill: var(--error-soft); }
.op-flag circle { fill: var(--error); }
.op-flag text { fill: #fff; font-size: 12px; font-weight: 900; }
.opening { pointer-events: none; }
.opening-adds { flex-wrap: wrap; gap: 8px; }
.opening-adds .btn { flex: 1 1 110px; min-height: 44px; }
.opening-adds .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.opening-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.opening-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); text-align: left; }
.opening-row[aria-pressed="true"] { border-color: var(--select); box-shadow: inset 0 0 0 1px var(--select); }
.opening-row.flagged { border-color: var(--warn); }
.opening-row .grow { flex: 1 1 auto; min-width: 0; }
.opening-card .sv-row { flex-wrap: wrap; }
.opening-card .sv-row > .measure-field.sv { flex: 1 1 200px; min-width: 0; }
.opening-card .sv-row > .btn { flex: 0 0 auto; }
.opening-card .seg-btn { min-height: 44px; }
.shared-box { margin-top: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--bg); }
.place-bar .place-kinds { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.place-bar .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.row.wrap { flex-wrap: wrap; }

/* Milestone 10: notes, photos, camera, site conditions */
.tab-count { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 18px; text-align: center; }
.notes-panel { display: grid; gap: 4px; }
.notes-dest { margin: 8px 0 0; }
.note-section { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.note-section.client { border-left: 4px solid var(--accent); }
.note-section.internal { border-left: 4px solid var(--ink-3); }
.note-head { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0; }
.vis-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; border: 1px solid currentColor; }
.vis-chip.client { color: var(--accent); background: var(--accent-soft); }
.vis-chip.internal { color: var(--ink-2); background: var(--bg); }
.note-text { width: 100%; min-height: 72px; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); resize: vertical; background: #fff; }
.note-text:focus { outline: 2px solid var(--select); outline-offset: 1px; }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin: 8px 0; }
.photo-strip:empty { display: none; }
.photo-tile { position: relative; aspect-ratio: 1; min-height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .ph-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-tile .ph-badge { position: absolute; top: 4px; left: 4px; padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.ph-badge.saving { background: var(--warn-soft); color: var(--warn); }
.ph-badge.failed { background: var(--error-soft); color: var(--error); }
.photo-tile.job.failed { aspect-ratio: auto; flex-direction: column; gap: 4px; padding: 6px; border-color: var(--error); background: var(--error-soft); grid-column: 1 / -1; }
.ph-err { color: var(--error); font-size: 13px; }
.ph-missing { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--ink-3); padding: 4px; text-align: center; }
.ph-loading { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: ph-spin 0.9s linear infinite; }
@keyframes ph-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ph-loading { animation: none; } }
.photo-actions .btn { flex: 1 1 140px; min-height: 44px; }
.viewer-host[hidden], .camera-host[hidden] { display: none; }
.viewer-host { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 12px; }
.viewer-backdrop { position: absolute; inset: 0; background: rgba(20, 25, 30, .6); }
.viewer { position: relative; background: #fff; border-radius: 14px; width: min(760px, 100%); max-height: calc(100vh - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: grid; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.viewer-head p { margin: 0; }
.viewer-img { background: #111; display: flex; align-items: center; justify-content: center; min-height: 200px; }
.viewer-img img { max-width: 100%; max-height: 60vh; display: block; }
.viewer-body { padding: 10px 14px 14px; }
.viewer .seg { display: flex; gap: 6px; }
.viewer .seg-btn { flex: 1; min-height: 44px; }
.viewer select { min-height: 44px; flex: 1 1 auto; min-width: 0; }
.camera-host { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: stretch; justify-content: center; }
.camera { display: flex; flex-direction: column; width: 100%; max-width: 1100px; color: #fff; padding: 10px; gap: 8px; }
.camera-dest { margin: 0; }
.camera video { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #111; border-radius: 8px; }
.camera-msg { margin: 0; min-height: 22px; }
.camera-actions { display: flex; gap: 10px; }
.camera-actions .btn { flex: 1; min-height: 56px; font-size: 18px; }
.site-details summary { flex-wrap: wrap; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip-btn { min-height: 44px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chip-btn.unknown[aria-pressed="true"] { background: var(--bg); border-color: var(--ink-3); color: var(--ink-2); }
.opening.window .op-gap { fill: #fff; }
.opening.window .op-glass { stroke: #2b6c99; stroke-width: 2; }
.site-details summary .muted { font-weight: 400; }

/* Scan review (scan → review → canvas): solid = scanned, dotted = suggested and not applied. */
:root { --proposal: #7a3fc4; --proposal-soft: rgba(122, 63, 196, .12); }
.scan-proposed { stroke: var(--proposal); stroke-width: 4; stroke-dasharray: 2 7; stroke-linecap: round; fill: none; }
.scan-proposed.selected { stroke-width: 6; }
.scan-replaced { stroke: var(--proposal-soft); stroke-width: 16; stroke-linecap: round; }
.scan-semantic { stroke: var(--proposal); stroke-width: 5; stroke-dasharray: 2 6; stroke-linecap: round; }
.scan-proposed-label { fill: var(--proposal); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.scan-marker { cursor: pointer; }
.scan-marker circle { fill: #fff; stroke: var(--proposal); stroke-width: 2.5; }
.scan-marker text { fill: var(--proposal); font-size: 14px; font-weight: 800; }
.scan-marker.review circle { stroke: var(--warn); }
.scan-marker.review text { fill: var(--warn); }
.scan-marker.selected circle { fill: var(--proposal); }
.scan-marker.selected text { fill: #fff; }
.scan-marker.review.selected circle { fill: var(--warn); }
.scan-head { border-left: 4px solid var(--proposal); }
.scan-title { display: flex; align-items: center; gap: 6px; margin: 0; }
.scan-title .icon { color: var(--proposal); }
.scan-progress { margin: 4px 0 0; }
.scan-card { border: 1.5px solid var(--proposal); }
.scan-card.review { border-color: var(--warn); }
.scan-compare { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; }
.scan-compare dt { color: var(--muted, #5b6670); }
.scan-compare dd { margin: 0; }
.scan-decide .btn { flex: 1 1 0; }
.scan-photos { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin: 8px 0; }
.scan-photo { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; }
.scan-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.scan-list button { width: 100%; display: flex; align-items: center; gap: 8px; min-height: var(--touch); padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: left; font: inherit; color: inherit; }
.scan-list button[aria-pressed="true"] { border-color: var(--proposal); box-shadow: 0 0 0 2px var(--proposal-soft); }
.scan-dot { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 2px solid var(--proposal); color: var(--proposal); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.scan-dot.review { border-color: var(--warn); color: var(--warn); }
.scan-diag dd { overflow-wrap: anywhere; }
.warn-text { color: var(--warn); }
.scan-observed { stroke: #8a8f95; stroke-width: 3; stroke-dasharray: 7 5; stroke-linecap: round; }
.scan-observed.hot { stroke: var(--warn); stroke-width: 5; }
.scan-observed-opening { stroke: #8a8f95; stroke-width: 6; stroke-dasharray: 2 4; stroke-linecap: round; }
.scan-observed-opening.hot { stroke: var(--warn); }
.op-flag { cursor: pointer; }
/* Level alignment: the whole room where PFM proposes it (dotted), never over the scanned outline's meaning. */
.scan-proposed-room { stroke: var(--proposal); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; fill: none; opacity: .55; }
.scan-proposed-room.selected { stroke-width: 3.5; opacity: 1; fill: var(--proposal-soft); }
.scan-align-arrow { stroke: var(--proposal); stroke-width: 2; marker-end: url(#scan-arrow); }
.scan-doorway-link { stroke: var(--proposal); stroke-width: 3; stroke-dasharray: 1 5; stroke-linecap: round; }
.scan-doorway-linked { stroke: var(--ok, #2f7d4f); stroke-width: 3; stroke-linecap: round; }
.scan-level { border-left: 4px solid var(--proposal); }
.scan-level .row { flex-wrap: wrap; }
.scan-level .row .btn { flex: 1 1 auto; }
.scan-uses { margin: 4px 0; }
.scan-uses .chip { margin-right: 4px; }
.scan-changes { margin: 4px 0 8px; padding-left: 18px; font-size: 14px; }

/* Focused review (one issue at a time): minimap = where, canvas = which part, A/B = which decision. */
.review-focus { display: flex; flex-direction: column; gap: 8px; }
.review-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.review-count { margin: 0; }
.review-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.review-progress span { display: block; height: 100%; background: var(--proposal); }
.review-where { margin: 0; font-size: 14px; }
.review-q { margin: 2px 0 0; font-size: 20px; }
.ab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ab-grid.one { grid-template-columns: 1fr; }
.ab-card { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid var(--line); border-radius: 12px; background: #fff; text-align: left; font: inherit; color: inherit; min-height: 44px; cursor: pointer; }
.ab-card.single { cursor: default; }
.ab-card:not([disabled]):hover { border-color: var(--proposal); }
.ab-card[disabled] { cursor: default; opacity: .85; }
.ab-card.selected { border-width: 4px; border-color: var(--proposal); box-shadow: 0 0 0 3px var(--proposal-soft); }
.ab-head { display: flex; align-items: center; gap: 6px; min-height: 28px; }
.ab-key { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); font-weight: 800; }
.ab-card.selected .ab-key { background: var(--proposal); border-color: var(--proposal); color: #fff; }
.ab-label { font-weight: 700; }
.ab-chosen { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--proposal); }
.ab-svg { width: 100%; height: auto; display: block; border-radius: 8px; }
.ab-bg { fill: #fbfbfa; }
.ab-context { fill: #f4f2ef; stroke: #d3d0ca; stroke-width: 1; }
.ab-other { fill: #eef1f4; stroke: #5b6670; stroke-width: 1.5; }
.ab-ghost { fill: none; stroke: #6b7178; stroke-width: 1.6; stroke-dasharray: 5 4; }
.ab-subject { fill: rgba(122, 63, 196, .14); stroke: #1e2a33; stroke-width: 3; stroke-linejoin: round; }
.ab-seg { stroke-linecap: butt; }
.ab-opening { stroke: #1e2a33; stroke-width: 7; }
.ab-opening-other { stroke: #5b6670; stroke-width: 7; stroke-dasharray: 3 2; }
.ab-link { stroke: var(--proposal); stroke-width: 3; stroke-dasharray: 1 4; stroke-linecap: round; }
.ab-observed { stroke: #8a8f95; stroke-width: 4; stroke-dasharray: 7 5; }
.ab-overlap { stroke: none; }
.ab-hatch-line { stroke: var(--warn); stroke-width: 3; }
.ab-note { font-size: 14px; font-weight: 700; fill: var(--proposal); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.ab-note-ring { fill: none; stroke: var(--proposal); stroke-width: 1.5; }
.ab-room-label { font-size: 14px; fill: #3b4650; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.review-decided { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.review-decided p { margin: 0; flex: 1 1 100%; }
.review-secondary { flex-wrap: wrap; }
.review-secondary .btn { flex: 1 1 auto; }
.review-nav { justify-content: space-between; align-items: center; }
.review-photos .scan-photos { grid-template-columns: repeat(3, 1fr); }
.scan-marker.dim { opacity: .22; }
.review-camera circle { fill: #fff; stroke: var(--proposal); stroke-width: 2; }
.review-camera line { stroke: var(--proposal); stroke-width: 2.5; }
.review-camera text { fill: var(--proposal); font-size: 12px; font-weight: 800; }
.minimap { position: absolute; left: 10px; bottom: 30px; z-index: 2; }
.minimap-btn { display: flex; flex-direction: column; gap: 2px; padding: 4px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.08); font: inherit; cursor: pointer; }
.minimap-svg { width: 180px; height: 130px; display: block; }
.mm-room { fill: #f1efeb; stroke: #9aa0a6; stroke-width: 1; }
.mm-hot { fill: var(--proposal-soft); stroke: var(--proposal); stroke-width: 2.5; }
.mm-view { fill: none; stroke: #1e2a33; stroke-width: 1.5; stroke-dasharray: 3 2; }
.mm-here { fill: var(--proposal); }
.mm-here-ring { fill: none; stroke: var(--proposal); stroke-width: 2; }
.mm-caption { font-size: 11px; color: var(--ink-2, #5b6670); }
@media (max-width: 1000px) {
  .minimap { bottom: 10px; }
  .minimap-svg { width: 130px; height: 94px; }
}
@media (max-width: 380px) {
  .ab-grid { grid-template-columns: 1fr; }
}
.app.focus-review { grid-template-columns: 0 1fr minmax(380px, 480px); }
.app.focus-review .tools { display: none; }
.review-actions { display: none; }
@media (max-width: 1000px) {
  .app.focus-review { grid-template-columns: 1fr; grid-template-rows: auto 45vh auto; grid-template-areas: "top" "stage" "inspector"; }
}

/* Phase 8: recommendation-first, doorway observations, the exact opening, editor, merge, add feature. */
.ab-badge { display: inline-block; align-self: flex-start; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #fff; background: var(--proposal); }
.ab-card.recommended { border-style: solid; }
.ab-band { fill: var(--proposal-soft); stroke: var(--proposal); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ab-tag { font-size: 12px; font-weight: 700; fill: #1e2a33; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.canvas.focus-dim .opening, .canvas.focus-dim text.dim { opacity: .35; }
.focus-halo { stroke-linecap: round; fill: none; }
.focus-halo.target { stroke: var(--proposal); stroke-width: 16; opacity: .45; }
.focus-halo.obs-a { stroke: #1e2a33; stroke-width: 9; }
.focus-halo.obs-b { stroke: #1e2a33; stroke-width: 9; stroke-dasharray: 6 4; }
.focus-halo.preview { stroke: var(--proposal); stroke-width: 7; stroke-dasharray: 3 4; }
.focus-band { fill: var(--proposal-soft); stroke: var(--proposal); stroke-width: 2; stroke-dasharray: 5 4; }
.focus-tag { font-size: 13px; font-weight: 800; fill: #1e2a33; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.review-editor .review-field { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.review-editor input { min-height: 44px; font-size: 18px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
.review-done { border-left: 4px solid var(--ok, #2f7d4f); }
.photo-caps { display: flex; gap: 6px; justify-content: space-between; }
.photo-caps span { flex: 1 1 0; text-align: center; }
.feature-menu { display: grid; gap: 6px; }
.feature-item { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left; font: inherit; color: inherit; }
.feature-item small { display: block; color: var(--muted, #5b6670); font-size: 13px; }
.transition line { stroke: #b5651d; stroke-width: 5; stroke-dasharray: 10 5; stroke-linecap: round; }
.transition circle { fill: #fff; stroke: #b5651d; stroke-width: 2; }
.transition text { fill: #b5651d; font-size: 12px; font-weight: 800; }
.transition.selected line { stroke-width: 8; }
.transition-start { fill: #b5651d; opacity: .7; }
.seg.four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

/* ---------------------------------------------------------------------------
   Pre-DISTO visual refinement: a calm, monochrome working drawing. The plan leads; colour is
   kept for meaning (selection, warnings, errors, scan review). Information is kept — hierarchy,
   not deletion. Scan Review keeps its semantic colours as a temporary analytical overlay.
   --------------------------------------------------------------------------- */
:root {
  --bg: #f2f2f4;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #48484d;
  --ink-3: #86868b;
  --line: #e2e2e6;
  --hair: #ececf0;
  --accent: #1d1d1f;          /* primary actions: charcoal, not a second brand colour */
  --accent-ink: #ffffff;
  --accent-soft: #ececef;
  --select: #0a66d8;          /* the one accent: selection and focus */
  --floor: #ffffff;
  --floor-draft: #fafafa;
  --wall: #1c1c1e;
  --grid-minor: #ebebee;
  --grid-major: #dcdce1;
  --warn: #a35a00;
  --warn-soft: #fff7ea;
  --error: #c4291c;
  --error-soft: #fdf1f0;
  --ok: #1f7a3f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.canvas { background: #f5f5f7; }
.topbar { border-bottom-color: var(--hair); }
.tools { border-right-color: var(--hair); }
.inspector { border-left-color: var(--hair); }
.brand .mark { background: var(--ink); }

/* Plan: black walls, white floors, quiet grid and dimensions. */
.wall { fill: var(--wall); stroke: var(--wall); }
.dim { fill: var(--ink-2); stroke: var(--floor); }
.dim.outside { stroke: #f5f5f7; }
.dim.provisional { fill: var(--ink-3); }
.room-name { font-weight: 600; letter-spacing: -.01em; }
.room-area { fill: var(--ink-3); }
.stair-landing, .tp-landing, .sd-landing, .si-landing { fill: #f2f2f4; stroke: #3a3a3c; }
.stair-platform.higher { fill: #f7f7f9; }
/* Overlap stays a real warning, drawn as a dashed red outline with the lightest tint (no salmon wash). */
.overlap-outline { fill: rgba(196, 41, 28, .025); stroke: var(--error); stroke-width: 1.75; stroke-dasharray: 5 4; }
.invalid-preview { fill: rgba(196, 41, 28, .05); }

/* Openings: three symbols that read at a glance. Door = leaf + quarter swing; window = glazing;
   cased = open passage with a dashed head line. */
.opening .op-gap { fill: var(--floor); }
.opening .op-jamb { stroke: var(--ink); stroke-width: 1.75; }
.opening .op-leaf { stroke: var(--ink); stroke-width: 2.5; }
.opening .op-fan { fill: rgba(29, 29, 31, .045); stroke: none; }
.opening .op-swing { stroke: #6e6e73; stroke-width: 1.2; stroke-dasharray: none; }
.opening .op-unknown { stroke: var(--ink-3); }
.opening.window .op-gap { fill: #fff; }
.opening.window .op-glass, .opening .op-glass { stroke: #3a3a3c; stroke-width: 1.25; }
.opening .op-head { stroke: #6e6e73; stroke-width: 1.2; stroke-dasharray: 3 3; }
.opening.flagged .op-gap { fill: var(--error-soft); }

/* Surfaces: white panels, hairlines, few shadows. */
.card { border-color: var(--hair); border-radius: 12px; }
.card.ok { border-color: var(--hair); background: #fff; border-left: 3px solid var(--ok); }
.card.warn, .notice.warn, .confirm-bar.warn { background: #fff; border-color: var(--hair); border-left: 3px solid #d58a1c; }
.card.err, .notice.err, .confirm-bar.err { background: #fff; border-color: var(--hair); border-left: 3px solid var(--error); }
.notice { border-color: var(--hair); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05); color: var(--ink-2); }
.notice.warn::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: #d58a1c; color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.card.focus { border-left: 3px solid var(--select); }
.chip { background: transparent; border-color: var(--line); color: var(--ink-2); font-weight: 600; }
.chip.ok { color: var(--ok); border-color: #cfe5d6; background: transparent; }
.chip.warn { color: var(--warn); border-color: #ecd3ad; background: transparent; }

/* Buttons and controls: one weight of border, charcoal primary, quiet secondary. */
.btn, .text-btn, .icon-btn, .dir-btn, .tab { border-color: var(--line); background: #fff; }
.btn.primary { background: var(--ink); border-color: var(--ink); }
.btn.danger { color: var(--error); background: #fff; }
.btn:disabled, .icon-btn:disabled, .dir-btn:disabled { opacity: .35; }
.tabs { background: #ececef; border-radius: 10px; padding: 2px; gap: 2px; }
.tab { border: 0; background: transparent; min-height: var(--touch); font-weight: 600; color: var(--ink-2); }
.tab[aria-selected="true"] { background: #fff; color: var(--ink); border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-btn { border-width: 1px; font-weight: 600; }
.seg-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.measure-field { border-width: 1px; border-color: var(--line); }
.measure-field .mf-icon { color: var(--ink-3); }
.edit-banner { background: #f2f7fe; border: 1px solid var(--select); }
.icon-btn[aria-pressed="true"], .text-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--line); color: var(--ink); }

/* Floating toolbar: contextual, light; disabled recedes; destructive is clear but not loud. */
.tool-group { background: rgba(255,255,255,.94); border-color: var(--hair); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.06); backdrop-filter: saturate(1.4) blur(10px); }
.tool-btn { color: var(--ink); }
.tool-btn .tool-label { font-weight: 500; color: var(--ink-2); }
.tool-btn:hover:not(:disabled) { background: #f2f2f4; }
.tool-btn[aria-pressed="true"] { background: #ececef; border-color: transparent; color: var(--ink); }
.tool-btn.primary { background: var(--ink); }
.tool-btn.primary .tool-label { color: #fff; }
.tool-btn.primary:hover { background: #3a3a3c; }
.tool-btn.danger { color: var(--error); }
.tool-btn.danger .tool-label { color: var(--ink-3); }
.tool-btn:disabled { opacity: .28; }
.canvas-controls { border-color: var(--hair); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.06); }

/* Typography does the hierarchy: name, then numbers, then secondary information. */
.room-heading { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.big-stat .k { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.big-stat .v { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.card-title { font-size: 14px; font-weight: 600; }
.hint { color: var(--ink-3); }
.readout { margin: 6px 0 0; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.obs-line { margin-top: 2px; }
.details summary { color: var(--ink-2); }

/* Dimension provenance: Scanned (an observation) / Typed (entered) / Laser (reserved). */
.tag { font-weight: 600; border-radius: 5px; }
.tag.scanned { color: var(--ink-3); border-style: dashed; }
.tag.typed, .tag.measured { color: var(--ink); }
.tag.laser { color: var(--select); }

/* Scan photos in Notes (Phase 11): where they came from, and where they were taken. */
.photo-tile .ph-src { position: absolute; left: 4px; top: 4px; font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 1px 5px; border-radius: 4px; background: rgba(29,29,31,.78); color: #fff; }
.capture-line { color: var(--ink-2); }
.photo-spot circle { fill: var(--select); stroke: #fff; stroke-width: 2.5; }
.photo-spot .photo-spot-view { fill: rgba(10,102,216,.16); stroke: var(--select); stroke-width: 1.2; }
.photo-spot text { font-size: 12px; font-weight: 700; fill: var(--select); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.vis-chip { white-space: nowrap; }

/* Multi-room selection (overnight field UX) */
.multi-sel { border-color: var(--select); background: #f3f7fe; }
.sel-chips { flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.sel-chip { font: inherit; font-size: 14px; border: 1px solid var(--select); color: var(--select); background: #fff; border-radius: 999px; padding: 4px 10px; min-height: 44px; padding: 4px 14px; cursor: pointer; }
.review-scope { margin: 4px 0 6px; }
.scan-observed-label { font-size: 11px; fill: #5f656b; paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
.kp-key.kp-mark { font-size: 26px; color: var(--ink-2); background: #f7f8f9; }
.kp-key.kp-fine { font-size: 15px; color: var(--ink-2); background: #f7f8f9; }
.kp-key.kp-fine[aria-pressed="true"] { background: var(--select); border-color: var(--select); color: #fff; }

/* Experimental photographic walkthrough (overnight Phase 2) */
.viewer.walk { width: min(1180px, 100%); }
.walk-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; }
.walk-stage { position: relative; background: #111; }
.walk-img { min-height: 360px; overflow: hidden; }
.walk-img img { max-height: 68vh; }
.walk-img img.turned { max-width: 68vh; max-height: 100%; }
.walk-missing { color: #ddd; text-align: center; padding: 40px 16px; }
.walk-missing .muted { color: #aaa; }
.walk-nav .walk-step { position: absolute; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.88); font-size: 26px; font-weight: 700; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.walk-nav .walk-step[disabled] { opacity: .25; }
.walk-step.ahead { top: 12px; left: calc(50% - 26px); }
.walk-step.behind { bottom: 12px; left: calc(50% - 26px); }
.walk-step.left { left: 12px; top: calc(50% - 26px); }
.walk-step.right { right: 12px; top: calc(50% - 26px); }
.walk-side { padding: 10px 14px 14px; border-left: 1px solid var(--line); }
.walk-plan { width: 100%; height: auto; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; }
.walk-room { fill: #f1f3f5; stroke: #8a8f95; stroke-width: 1.2; }
.walk-room.here { fill: #eef3fd; stroke: var(--select); }
.walk-dot { fill: #fff; stroke: #5f656b; stroke-width: 1.5; cursor: pointer; }
.walk-dot.mark { fill: var(--proposal, #6b3fd6); stroke: #fff; }
.walk-here { fill: var(--select); stroke: #fff; stroke-width: 2; pointer-events: none; }
.walk-view { fill: rgba(31, 95, 214, .25); stroke: var(--select); stroke-width: 1; pointer-events: none; }
.walk-doors { flex-wrap: wrap; gap: 6px; }
@media (max-width: 760px) {
  .walk-body { grid-template-columns: 1fr; }
  .walk-side { border-left: 0; border-top: 1px solid var(--line); }
  .walk-img { min-height: 240px; }
}

/* Experimental immersive walkthrough (spatial photo mapping) */
.walk-host { position: fixed; inset: 0; z-index: 30; background: #0d0f12; }
.walk-host[hidden] { display: none; }
.walk3d { position: absolute; inset: 0; display: flex; flex-direction: column; }
.walk3d-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.walk3d-head p { margin: 0; flex: 1; min-width: 0; }
.walk3d-head select { min-height: 40px; width: auto; flex: 0 0 auto; }
.walk3d-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.walk3d-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; }
.walk3d-stage canvas:active { cursor: grabbing; }
.walk3d-targets { position: absolute; inset: 0; pointer-events: none; }
.walk3d-step { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid rgba(255,255,255,.95); background: rgba(31,95,214,.28); box-shadow: 0 1px 6px rgba(0,0,0,.35); pointer-events: auto; cursor: pointer; padding: 0; min-height: 0; }
.walk3d-step:hover, .walk3d-step:focus-visible { background: rgba(31,95,214,.55); }
.walk3d-door { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; border: 0; border-radius: 999px; background: rgba(255,255,255,.92); color: var(--ink); font-weight: 600; font-size: 14px; padding: 8px 14px; min-height: 40px; box-shadow: 0 2px 10px rgba(0,0,0,.35); cursor: pointer; }
.walk3d-plan { position: absolute; left: 12px; bottom: 12px; width: 220px; background: rgba(255,255,255,.92); border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.3); padding: 4px; }
.walk3d-plansvg { width: 100%; height: auto; display: block; }
.walk3d-plan .walk-dot.current { fill: var(--select); stroke: #fff; }
.walk3d-hint { position: absolute; right: 12px; bottom: 12px; margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; font-size: 13px; pointer-events: none; }
.walk3d-info { position: absolute; right: 12px; top: 12px; max-width: min(460px, 70%); margin: 0; padding: 8px 10px; background: rgba(0,0,0,.72); color: #e8f0ff; font-size: 12px; white-space: pre-wrap; border-radius: 8px; pointer-events: none; }
@media (max-width: 760px) {
  .walk3d-plan { width: 150px; left: 8px; bottom: 8px; }
  .walk3d-hint { display: none; }
}

/* Walkthrough: clean shell + spatial photo evidence */
.walk3d.clean .walk3d-stage { background: #f2f3f5; }
.walk3d-cards { position: absolute; inset: 0; pointer-events: none; }
.walk-cards-row { position: absolute; transform: translate(-50%, -100%) scale(var(--k, 1)); transform-origin: 50% 100%; display: flex; gap: 6px; align-items: flex-end; padding-bottom: 8px; pointer-events: none; }
.walk-cards-row::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 1px; height: 8px; background: rgba(60, 64, 70, .45); }
.walk-card { position: relative; width: 64px; height: 48px; padding: 0; border: 2px solid #fff; border-radius: 8px; overflow: hidden; background: #e4e6ea; box-shadow: 0 2px 8px rgba(20, 25, 30, .22); pointer-events: auto; cursor: pointer; min-height: 0; }
.walk-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.walk-card-wait { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #e4e6ea, #eef0f2, #e4e6ea); }
.walk-card.mark { border-color: var(--proposal, #6b3fd6); }
.walk-mark { position: absolute; left: 2px; bottom: 2px; font-size: 9px; font-weight: 700; line-height: 1; padding: 2px 4px; border-radius: 4px; background: rgba(255,255,255,.92); color: var(--proposal, #6b3fd6); }
.walk-more { pointer-events: auto; min-height: 0; height: 30px; padding: 0 10px; border-radius: 999px; border: 0; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 600; font-size: 13px; box-shadow: 0 2px 8px rgba(20, 25, 30, .22); cursor: pointer; }
.walk-photo { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: #0f1114; }
.walk-photo[hidden] { display: none; }
.walk-photo-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; }
.walk-photo-head p { margin: 0; flex: 1; min-width: 0; }
.walk-photo-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.walk-photo-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.walk-photo-stage img.turned { max-width: calc(100vh - 120px); max-height: 100vw; }
.walk-photo-nav { position: absolute; top: calc(50% - 26px); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); font-size: 30px; line-height: 1; color: var(--ink); }
.walk-photo-nav[disabled] { opacity: .25; }
.walk-photo-nav.prev { left: 12px; }
.walk-photo-nav.next { right: 12px; }
.walk-photo-debug { margin: 0; padding: 8px 12px; background: #11151a; color: #cfe0ff; font-size: 12px; white-space: pre-wrap; }
/* View all photos: the current room's whole evidence set */
.walk-all { position: absolute; left: 12px; top: 12px; z-index: 2; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(255,255,255,.94); color: var(--ink); font-weight: 600; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; }
.walk-all[hidden] { display: none; }
.walk-gallery { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; background: #f2f3f5; }
.walk-gallery[hidden] { display: none; }
.walk-gallery-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.walk-gallery-head p { margin: 0; flex: 1; min-width: 0; }
.walk-gallery-grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; padding: 12px; align-content: start; }
.walk-tile { position: relative; aspect-ratio: 4 / 3; padding: 0; min-height: 0; border: 2px solid #fff; border-radius: 8px; overflow: hidden; background: #e4e6ea; box-shadow: 0 1px 4px rgba(20, 25, 30, .18); cursor: pointer; content-visibility: auto; contain-intrinsic-size: 132px 99px; }
.walk-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.walk-tile.mark { border-color: var(--proposal, #6b3fd6); }
.walk-tile .walk-mark { font-size: 11px; left: 4px; bottom: 4px; }
@media (max-width: 760px) {
  .walk-card { width: 54px; height: 40px; }
  .walk-all { left: 8px; top: 8px; }
  .walk-gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; }
}

/* DISTO V1: laser chip, reading queue in the keypad, laser sheet */
:root { --laser: #b4232f; --laser-soft: #fdeced; }
.laser-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.laser-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.laser-chip.ok .laser-dot, .laser-status.ok .laser-dot { background: var(--ok); }
.laser-chip.ok { color: var(--ink); }
.laser-chip.busy .laser-dot, .laser-status.busy .laser-dot { background: var(--select); animation: laser-pulse 1s ease-in-out infinite; }
.laser-chip.warn, .laser-status.warn { color: var(--warn); }
.laser-chip.warn .laser-dot, .laser-status.warn .laser-dot { background: var(--warn); }
.laser-chip.bad, .laser-status.bad { color: var(--ink-3); }
.laser-chip.fresh { animation: laser-fresh 2.5s ease-out forwards; }
@keyframes laser-fresh { 0%, 40% { border-color: var(--laser); background: var(--laser-soft); } 100% { border-color: var(--line); background: #fff; } }
@keyframes laser-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .laser-chip.busy .laser-dot, .laser-status.busy .laser-dot { animation: none; } .laser-chip.fresh, .laser-reading.fresh { animation-duration: .01s; } }
.kp-laser { display: flex; flex-direction: column; gap: 6px; }
.kp-laser-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kp-laser-head .laser-chip { flex: 0 1 auto; }
.laser-act { min-height: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #f7f8f9; font-size: 13px; font-weight: 700; }
.laser-act.quiet { margin-left: auto; background: transparent; border-color: transparent; color: var(--ink-3); font-weight: 600; }
.kp-laser-list { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.kp-laser-list::-webkit-scrollbar { display: none; }
.laser-reading { flex: none; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; min-height: 48px; min-width: 92px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; }
.laser-reading .lr-val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.laser-reading .lr-age { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.laser-reading.fresh { animation: laser-reading-fresh 2.5s ease-out forwards; }
@keyframes laser-reading-fresh { 0%, 40% { border-color: var(--laser); box-shadow: 0 0 0 3px var(--laser-soft); } 100% { border-color: var(--line); box-shadow: none; } }
.laser-reading.used { background: #f7f8f9; }
.laser-reading.used .lr-val { color: var(--ink-3); font-weight: 600; }
.laser-reading.picked { border: 2px solid var(--laser); background: var(--laser-soft); }
.laser-reading.picked .lr-val { color: var(--laser); }
.laser-empty { font-size: 13px; color: var(--ink-3); padding: 6px 2px; }
.kp-display.laser { border-color: var(--laser); background: var(--laser-soft); }
.kp-src { display: inline-block; vertical-align: middle; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--laser); border-radius: 4px; padding: 2px 5px; }
.tag.laser { color: var(--laser); }
.kp-turns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kp-turn { min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid var(--ink); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 700; }
.kp-turn .icon { width: 26px; height: 26px; }
.laser-host { position: fixed; inset: 0; z-index: 40; }
.laser-host[hidden] { display: none; }
.laser-backdrop { position: absolute; inset: 0; background: rgba(20, 24, 28, .35); }
.laser-sheet { position: absolute; right: 16px; top: 16px; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.laser-sheet-head { display: flex; align-items: center; gap: 8px; }
.laser-sheet-head p { margin: 0; flex: 1; }
.laser-status { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: 16px; }
.laser-sheet .row.wrap { flex-wrap: wrap; }
.laser-devices { display: flex; flex-direction: column; gap: 6px; }
.laser-device { min-height: 52px; text-align: left; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; }
.laser-device.disto { border-color: var(--laser); }
.laser-mock { border-top: 1px dashed var(--line); padding-top: 8px; }
.laser-diag pre { max-height: 260px; overflow: auto; background: #11151a; color: #cfe0ff; font-size: 11px; padding: 8px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; }
.linkish { background: none; border: 0; padding: 0; color: var(--select); text-decoration: underline; font-size: 13px; }
@media (max-width: 600px) {
  .laser-sheet { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 85vh; border-radius: 14px 14px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .laser-reading { min-width: 84px; }
  /* Phone keypad: status dot and readings share one row, so the digits stay in reach. */
  .kp-laser { flex-direction: row; align-items: stretch; gap: 6px; }
  .kp-laser-head { flex: none; }
  .kp-laser-head .laser-chip { min-height: 48px; padding: 0 12px; }
  .kp-laser-head .laser-chip span:last-child { display: none; }
  .kp-laser-head .laser-act.quiet { display: none; }
  .kp-laser-head .laser-act { min-height: 48px; }
  .kp-laser-list { flex: 1; min-width: 0; }
  .laser-reading .lr-val { font-size: 15px; }
  /* Phone: the laser lives in the keypad (status + readings); the top bar stays one line shorter. */
  #laser-chip-top, #laser-open { display: none; }
}
.src.laser { color: var(--laser); font-weight: 700; }

/* The PFM iPhone app (native host): feel like an app, not a page in a browser. */
.native-app, .native-app body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
.native-app body { -webkit-tap-highlight-color: transparent; }
.native-app .topbar, .native-app .toolbar, .native-app .keypad-host, .native-app .canvas, .native-app .tools .tab, .native-app button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.native-app input, .native-app textarea, .native-app [contenteditable] { -webkit-user-select: text; user-select: text; }
.native-app .canvas-hint { display: none; }

/* ---------------------------------------------------------------------------------------------
   Field UX (iPhone): Draw walls as a focused mode. While the wall keypad is open the normal
   chrome steps aside; one slim focus bar, the plan, and the contextual input (laser readings /
   number pad / direction pad, Close room). Phone portrait: nothing to scroll in the loop. */
.focusbar { grid-area: focus; position: relative; z-index: 7; background: var(--panel); border-bottom: 1px solid var(--line); padding: calc(4px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); }
.focusbar[hidden] { display: none; }
.fb-row { display: flex; align-items: center; gap: 4px; min-height: 44px; }
.fb-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.fb-btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-weight: 700; font-size: 14px; padding: 0 8px; }
.fb-btn.icon-only { padding: 0; }
.fb-btn:disabled { opacity: .35; cursor: not-allowed; }
.fb-btn .icon { width: 22px; height: 22px; }
.fb-exit { border-color: var(--line); background: #f7f8f9; }
.fb-issue { min-height: 36px; display: inline-flex; align-items: center; gap: 3px; padding: 0 9px; border: 1px solid #e0a431; background: var(--warn-soft); color: var(--warn); border-radius: 999px; font-weight: 800; font-size: 13px; }
.fb-issue .icon { width: 16px; height: 16px; }
.fb-menu { position: absolute; right: 8px; top: 100%; margin-top: 4px; z-index: 20; display: flex; flex-direction: column; min-width: 270px; max-width: calc(100vw - 16px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; }
.fb-menu button { min-height: 48px; text-align: left; padding: 0 12px; border: 0; background: none; border-radius: 8px; font-size: 15px; }
.fb-menu button:hover { background: #f1f3f5; }
.app.draw-focus .topbar, .app.draw-focus .tools, .app.draw-focus .inspector, .app.draw-focus .toolbar, .app.draw-focus .canvas-controls, .app.draw-focus .canvas-hint { display: none !important; }
.app.draw-focus { grid-template-columns: minmax(360px, 420px) 1fr; grid-template-rows: auto 1fr; grid-template-areas: "focus focus" "kp stage"; }
.app.draw-focus .keypad-host[data-dock] { grid-area: kp; }
.keypad.draw { gap: 6px; }
.kp-drawrow { display: flex; gap: 6px; align-items: stretch; }
.kp-drawrow .kp-display { flex: 1; min-width: 0; }
.keypad.draw .kp-display { padding: 4px 10px; }
.keypad.draw .kp-value { font-size: 26px; line-height: 1.15; }
.keypad.draw .kp-sec { font-size: 12.5px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-unitcycle { flex: none; min-width: 58px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #f7f8f9; font-weight: 700; font-size: 14px; }
.kp-seg.slim .kp-unit { min-height: 44px; flex-direction: row; gap: 8px; }
.kp-seg.slim .kp-fv { font-size: 18px; }
.keypad.draw .kp-grid { gap: 6px; }
.keypad.draw .kp-key { min-height: 46px; }
.keypad.draw .kp-frac { min-height: 44px; }
.keypad.draw .kp-act { min-height: 52px; }
.kp-actions.draw { grid-template-columns: 1fr 1.2fr; }
.kp-actions.draw.one { grid-template-columns: 1fr; }
.kp-act.close-room { flex-direction: column; gap: 0; line-height: 1.15; border: 1.5px solid var(--accent); color: var(--accent); background: #fff; }
.close-room .cr-main { display: inline-flex; align-items: center; gap: 6px; }
.close-room .cr-main .icon { width: 20px; height: 20px; }
.close-room .cr-sub { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.keypad.draw .kp-compass.big .kp-dir, .keypad.draw .kp-compass.big .kp-dir-center { min-height: 58px; }
.keypad.draw .kp-turn { min-height: 52px; }
/* The working laser queue: each waiting reading with its own discard. */
.laser-item { flex: none; display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.laser-item .laser-reading { border: 0; border-radius: 0; min-width: 78px; }
.laser-item .laser-reading.picked { border: 0; }
.laser-item:has(.laser-reading.picked) { border: 2px solid var(--laser); }
.lr-discard { flex: none; width: 40px; border: 0; border-left: 1px solid var(--line); background: #f7f8f9; color: var(--ink-3); display: flex; align-items: center; justify-content: center; }
.lr-discard:active { background: var(--error-soft); color: var(--error); }
.laser-item.fresh { animation: laser-reading-fresh 2.5s ease-out forwards; }
.laser-history ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.laser-history .lh-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.laser-history .lh-used .lh-val, .laser-history .lh-discarded .lh-val { color: var(--ink-3); }
/* The active end corner of an open room can be dragged: the last wall swings, its length locked. */
.endpoint.grab { fill: #fff; stroke: var(--select); stroke-width: 3; cursor: grab; }
.endpoint-halo { fill: rgba(31, 95, 214, .10); stroke: none; }
.swing-arc { fill: none; stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 4 4; }
.swing-readout { font-size: 15px; font-weight: 800; fill: var(--select); paint-order: stroke; stroke: #fff; stroke-width: 5px; font-variant-numeric: tabular-nums; }
.swing-readout.snapped { fill: #b0254f; }
@media (max-width: 1000px) {
  /* Phone / narrow: a fixed full-screen column — focus bar, plan (flexible), contextual input. */
  .app.draw-focus, body.keypad-open .app.draw-focus { position: fixed; inset: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 0; }
  .app.draw-focus .stage { flex: 1 1 0; min-height: 120px; }
  .app.draw-focus .keypad-host { position: static; flex: none; max-height: none; overflow: visible; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.10); padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .app.draw-focus .keypad-host .keypad { max-width: 560px; margin: 0 auto; }
}
.endpoint-label.hint { fill: var(--select); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .laser-item.fresh { animation-duration: .01s; } }
@media (max-width: 1000px) and (max-height: 720px) {
  /* Short phones (iPhone SE class): a little tighter, touch targets still 44 px. */
  .app.draw-focus .keypad.draw { gap: 4px; }
  .keypad.draw .kp-key, .keypad.draw .kp-frac { min-height: 44px; }
  .keypad.draw .kp-grid { gap: 4px; }
  .keypad.draw .kp-act { min-height: 48px; }
  .keypad.draw .kp-value { font-size: 22px; }
  .keypad.draw .laser-reading, .kp-laser-head .laser-chip, .kp-laser-head .laser-act { min-height: 44px; }
  .app.draw-focus .stage { min-height: 110px; }
}

/* ---------------------------------------------------------------------------------------------
   Field fixes (iPhone): Scan Review as one focused screen — the plan (focused on the issue) on
   top, one decision in a sheet below with its progress pinned; no app chrome competing. */
@media (max-width: 1000px) {
  .app.focus-review { position: fixed; inset: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-top: env(safe-area-inset-top); }
  .app.focus-review .topbar, .app.focus-review .toolbar, .app.focus-review .canvas-controls { display: none !important; }
  .app.focus-review .stage { flex: 1 1 0; min-height: 30vh; }
  .app.focus-review .inspector { flex: none; max-height: 58vh; max-height: 58dvh; overflow-y: auto; overscroll-behavior: contain; border-top: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 20px rgba(0,0,0,.10); padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
  .app.focus-review .review-top { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 10px 0 4px; }
  .app.focus-review .review-progress { position: sticky; top: 52px; z-index: 2; }
  .app.focus-review .review-q { font-size: 18px; margin: 2px 0; }
  .app.focus-review .review-scope, .app.focus-review .review-where { margin: 0; font-size: 13px; }
  .app.focus-review .minimap { bottom: 8px; left: 8px; }
  .app.focus-review .minimap-svg { width: 104px; height: 75px; }
  .app.focus-review .review-nav .btn { min-height: 48px; }
  .app.focus-review .review-actions { display: flex; position: sticky; bottom: calc(-12px - env(safe-area-inset-bottom)); z-index: 2; gap: 8px; flex-wrap: wrap; margin: 8px -12px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .app.focus-review .review-actions .btn { flex: 1 1 auto; min-height: 52px; justify-content: center; }
  .app.focus-review .review-actions #ra-approve, .app.focus-review .review-actions #ra-finish, .app.focus-review .review-actions #ra-next { flex: 1 1 100%; }
  .app.focus-review .review-secondary .dup-approve, .app.focus-review .review-secondary .dup-adjust, .app.focus-review .review-secondary .dup-skip { display: none; }
  .app.focus-review .ab-grid { gap: 8px; }
}

/* The running measured total on the plan (compact; tap for details). */
.area-chip { position: absolute; left: 10px; bottom: 30px; z-index: 3; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 6px; max-width: min(360px, calc(100% - 20px)); }
.area-chip[hidden] { display: none; }
.area-btn { display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.96); box-shadow: 0 2px 10px rgba(0,0,0,.08); font-variant-numeric: tabular-nums; }
.area-btn strong { font-size: 16px; }
.area-btn span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.area-btn.warn { border-color: #e0a431; }
.area-pop { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 10px 12px; max-height: 50vh; overflow-y: auto; }
.area-rows { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.area-rows li { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.area-pop .stats { margin: 4px 0; }
.area-pop .hint { margin: 4px 0 0; }

/* Reclaimed canvas space on phones: compact history buttons, no zoom buttons on touch (pinch). */
@media (max-width: 600px) {
  .app { grid-template-rows: auto 64vh auto auto; }
  .tool-group[aria-label="History"] .tool-btn { min-width: 44px; min-height: 44px; padding: 0 4px; }
  .tool-group[aria-label="History"] .tool-label { display: none; }
  .tool-group { padding: 3px; gap: 4px; border-radius: 12px; }
  .toolbar, .toolbar-scroll { gap: 6px; }
  .tool-btn { min-height: 52px; }
  .canvas-controls .tool-btn { min-width: 44px; min-height: 44px; }
  .canvas-controls .tool-label { display: none; }
  .area-chip { bottom: 10px; }
  .brand { display: none; }
}
@media (max-width: 1000px) and (pointer: coarse) {
  .canvas-controls [data-action="zoom-in"], .canvas-controls [data-action="zoom-out"] { display: none; }
}
@media (max-width: 600px) {
  /* One row of tools over the plan. A room has more actions than fit a phone, so the row
     scrolls sideways. `touch-action: pan-x` gives the sideways drag to this scroller and
     nothing else, so the plan underneath keeps its own pan and pinch. */
  .toolbar-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-padding-inline: 12px;
  }
  .toolbar-scroll::-webkit-scrollbar { display: none; }
  .toolbar-scroll .tool-group { flex: none; flex-wrap: nowrap; }
  /* More actions along the row: fade the edge that continues, so the cut-off button reads as
     "keep going" rather than as the end of the row. */
  .toolbar-scroll[data-overflow="right"], .toolbar-scroll[data-overflow="both"] {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
  .toolbar-scroll[data-overflow="left"] {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 26px), transparent);
  }
  .toolbar-scroll[data-overflow="both"] {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 26px, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 26px, #000 calc(100% - 26px), transparent);
  }
  /* …and a tap target that jumps to them, for anyone who does not try the swipe. */
  .toolbar-more {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 44px; min-height: 44px; align-self: center; margin-left: -4px;
    border: 1px solid var(--line); border-radius: 12px;
    background: rgba(255,255,255,.96); color: var(--ink);
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    pointer-events: auto;
  }
  .toolbar-more[hidden] { display: none; }
  .toolbar-more.back { transform: scaleX(-1); }
  .banner .notice { font-size: 13px; padding: 6px 8px; }
}

/* Split Room preview */
.split-part { stroke: none; }
.split-part.kept { fill: rgba(31, 95, 214, .14); }
.split-part.new { fill: rgba(15, 140, 110, .18); }
.split-line { stroke: #b0254f; stroke-width: 3; stroke-dasharray: 8 5; }
.split-line.bad { stroke: var(--error); stroke-dasharray: 3 4; }
.split-halo { fill: rgba(176, 37, 79, .12); }
.split-dot { fill: #fff; stroke: #b0254f; stroke-width: 3; cursor: grab; }
.split-label { font-size: 12px; font-weight: 800; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.split-len { font-size: 13px; font-weight: 800; fill: #b0254f; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.split-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.split-key.kept { background: rgba(31, 95, 214, .5); }
.split-key.new { background: rgba(15, 140, 110, .55); }

/* ---------------------------------------------------------------------------
   Estimating (estimating-spike): module navigation, the room's Estimate tab, and the Products,
   Build Sheet and Proposal workspaces. */
/* width 0 + min-width 100%: the row never widens the page; its tabs scroll sideways on a phone. */
.modules { flex: 0 0 100%; width: 0; min-width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.modules::-webkit-scrollbar { display: none; }
.module-tab { min-height: var(--touch); padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: none; border-radius: 6px 6px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.module-tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--select); }
.module-tab.future { color: var(--ink-3); font-weight: 500; opacity: .55; cursor: not-allowed; }
.module-tab.future::after { content: " · soon"; font-size: 11px; }

.workspace { grid-column: 1 / -1; grid-row: 2 / -1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.workspace[hidden] { display: none; }
.app.module-open > .tools, .app.module-open > .stage, .app.module-open > .inspector { display: none; }
.ws-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ws-bar .btn.small { min-height: 34px; }
.ws-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.ws-main { overflow-y: auto; padding: 16px 20px 40px; }
.ws-side { overflow-y: auto; padding: 16px; background: var(--panel); border-left: 1px solid var(--line); }
.ws-main h2, .ws-side h2 { font-size: 16px; }
.ws-main h3, .ws-side h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 18px 0 6px; }
.ws-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); }
.ws-controls label { display: flex; align-items: center; gap: 6px; }
.ws-controls select { width: auto; }
textarea[data-est-field] { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font: inherit; resize: vertical; }
@media (max-width: 1000px) {
  .workspace { grid-row: auto; }
  .ws-body { display: block; }
  .ws-side { border-left: 0; border-top: 1px solid var(--line); }
  /* Proposal on a small screen: the controls (customer, issue, export) come before the paper. */
  .ws-body.side-first { display: flex; flex-direction: column; }
  .ws-body.side-first .ws-side { order: -1; border-top: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .ws-body.side-first .ws-main { overflow: visible; }
}

.est-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.est-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafafb; }
.est-table td { padding: 9px 10px; border-bottom: 1px solid var(--hair, var(--line)); vertical-align: top; }
.est-table tbody tr { cursor: pointer; }
.est-table tbody tr:hover { background: #fafafb; }
.est-table tbody tr.selected { background: rgba(10, 102, 216, .07); box-shadow: inset 3px 0 0 var(--select); }
.est-table .num, .pp-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.est-c-mark { width: 26px; }
.est-desc { font-weight: 600; }
.est-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.est-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: -2px; margin-right: 6px; flex: none; }
.est-swatch[data-empty] { border-style: dashed; }
.est-mark { display: inline-block; margin-left: 4px; font-size: 12px; font-weight: 700; }
.est-mark.edited { color: var(--select); }
.est-mark.review { color: var(--warn); }
.est-mark.rule { color: var(--proposal, #7a3fc4); }
.est-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--ink-2); }
.est-tag.cond { background: var(--warn-soft); color: var(--warn); }
.est-sample { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: var(--warn-soft); color: var(--warn); vertical-align: 1px; }
.est-totals, .ws-totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; justify-content: end; max-width: 340px; margin: 14px 0 0 auto; font-size: 14px; font-variant-numeric: tabular-nums; }
.est-totals dd, .ws-totals dd { margin: 0; text-align: right; }
.est-totals .total, .ws-totals .total { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
/* A total that cannot be complete says so in the figure itself, not only in the note beside it. */
.est-totals.incomplete .total { color: var(--warn); }
.est-add { margin-top: 22px; max-width: 640px; }
.est-flags { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; }
.est-flags li { padding: 3px 0; }
.est-flags li.review { color: var(--warn); }
.est-flags li.info { color: var(--ink-2); }
.est-suggestion { border-left: 3px solid var(--proposal, #7a3fc4); }
.est-suggestion p { margin: 0 0 4px; }
.est-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.est-editor-head h2 { margin: 0 0 6px; }
.est-x { border: 0; background: none; min-width: 36px; min-height: 36px; font-size: 15px; color: var(--ink-3); border-radius: 8px; }
.est-x:hover { background: var(--accent-soft); color: var(--ink); }
.est-rooms { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-top: 6px; }
.est-history { margin: 4px 0; padding-left: 18px; font-size: 12px; color: var(--ink-3); }
.est-cost { color: var(--ink-2); }
.est-products { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.est-product-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.est-product-card .grow { flex: 1; min-width: 0; }
.est-product-actions { flex: none; width: 190px; }
.est-product-actions .btn { width: 100%; }

.est-product { margin: 0 0 4px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.est-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.est-two label, .est-layer-fields label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: grid; gap: 3px; }
.est-layers { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.est-layers li { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px 8px; background: #fff; }
.est-layer-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.est-layer-fields { display: grid; grid-template-columns: minmax(96px, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.est-layer-fields select, .est-layer-fields input { min-height: 36px; padding: 0 4px; font-size: 13px; }
.est-add-layer { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(104px, 1fr) auto; gap: 6px; }
.est-add-layer select, .est-add-layer input { min-height: 38px; font-size: 13px; padding: 0 6px; }
.est-add-layer .btn { min-height: 38px; }
.est-none { margin: 0 0 6px; font-size: 13px; }
.est-impacts { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.est-scope { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.est-scope li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.est-scope li > .btn.small { flex: 1; white-space: nowrap; }
.est-scope li > button:first-child { flex: 1; display: flex; justify-content: space-between; gap: 8px; min-height: 40px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; font-size: 14px; }
.est-scope li > button[aria-current="true"] { border-color: var(--select); }
.est-scope li > button:first-child { flex: 1 0 100%; }

.floor-product { opacity: .3; pointer-events: none; }
.lay-dir { pointer-events: none; }
.lay-dir line, .lay-dir path { stroke: var(--ink-2); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.floor-legend { position: absolute; left: 10px; bottom: 84px; max-width: 46%; z-index: 1; pointer-events: none; }
.est-legend { list-style: none; margin: 0; padding: 6px 10px; display: grid; gap: 3px; font-size: 12px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 10px; }
.est-legend li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The proposal: an original Portland Floor layout. */
.ws-paper { background: #e9e9ec; }
.proposal { max-width: 800px; margin: 0 auto; background: #fff; color: #1d1d1f; padding: 44px 48px; box-shadow: 0 1px 12px rgba(0,0,0,.12); font-size: 13.5px; line-height: 1.45; }
.pp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; border-bottom: 3px solid #1f4d3a; padding-bottom: 14px; }
.pp-company { font-size: 26px; font-weight: 700; letter-spacing: .01em; color: #1f4d3a; }
.pp-kind { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: #666; margin-top: 2px; }
.pp-meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; font-size: 12.5px; }
.pp-meta dt { color: #777; }
.pp-meta dd { margin: 0; text-align: right; font-weight: 600; }
.pp-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 18px 0 6px; }
.pp-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #777; margin-bottom: 2px; }
.pp-section { margin-top: 22px; }
.pp-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #1f4d3a; margin: 0 0 6px; }
.pp-table { width: 100%; border-collapse: collapse; }
.pp-table th { text-align: left; font-size: 11px; font-weight: 600; color: #777; padding: 4px 0; border-bottom: 1px solid #cfcfd4; }
.pp-table td { padding: 7px 0; border-bottom: 1px solid #ececf0; vertical-align: top; }
.pp-table td + td, .pp-table th + th { padding-left: 16px; }
.pp-table tfoot td { border-bottom: 0; font-weight: 600; color: #444; }
.pp-item { font-weight: 600; }
.pp-rooms { font-size: 12px; color: #666; }
.pp-note, .pp-explain { font-size: 12.5px; color: #555; margin: 2px 0 0; }
.pp-explain { margin-bottom: 8px; }
.pp-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 22px; padding: 12px 16px; background: #f1f5f2; border-left: 4px solid #1f4d3a; font-size: 15px; }
.pp-total strong { font-size: 22px; font-variant-numeric: tabular-nums; }
/* A draft whose pricing is not finished does not look like a finished price. */
.pp-total.incomplete { background: var(--warn-soft); border-left-color: var(--warn); }
.pp-conditional { border: 1px dashed #b9b9c0; padding: 14px 16px; }
/* A proposal without its official PFOS number prints as a marked worksheet, never as a proposal. */
.pp-draft-banner { margin: 0 0 16px; padding: 10px 14px; border: 2px solid var(--warn, #b26b00); background: var(--warn-soft, #fff4e0); color: #5a3a00; font-size: 13px; }
.proposal.pp-draft { background-image: repeating-linear-gradient(-35deg, transparent 0 160px, rgba(178, 107, 0, .06) 160px 200px); }
.pp-signs { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; margin-top: 34px; font-size: 12px; color: #666; }
.pp-signs span { display: block; border-bottom: 1px solid #333; height: 26px; margin-bottom: 4px; }
@media print {
  body > *:not(#app), .app > *:not(.workspace), .ws-bar, .ws-side { display: none !important; }
  html, body, .app, .workspace, .ws-body, .ws-main { display: block !important; height: auto !important; overflow: visible !important; background: #fff !important; padding: 0 !important; }
  .proposal { box-shadow: none; max-width: none; padding: 0; }
}
/* Measuring on a phone: the keypad needs the room, so the module row steps aside while it is open. */
@media (max-width: 1000px) { body.keypad-open .modules { display: none; } }
/* Estimating on a phone: usable, not yet designed for it. Unit price, cost and margin columns give
   way to the description (they are in the line's details). */
@media (max-width: 700px) {
  .ws-main { padding: 12px 10px 32px; }
  .est-table th:nth-child(4), .est-table td:nth-child(4), .est-table th:nth-child(n+6), .est-table td:nth-child(n+6) { display: none; }
  .est-table td, .est-table th { padding: 8px 6px; }
  .est-product-card { flex-wrap: wrap; }
  .est-product-actions { width: 100%; }
  .proposal { padding: 22px 16px; }
  .pp-head { flex-direction: column; align-items: flex-start; }
  .pp-parties { grid-template-columns: 1fr; gap: 10px; }
}

/* Estimating, second slice: checklists, change impacts, service markers. */
.est-tag.rule { background: var(--proposal-soft, rgba(122, 63, 196, .12)); color: var(--proposal, #7a3fc4); }
.est-impacts-panel { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--select); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; }
.est-impacts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.est-impacts-head h3 { margin: 0; }
.est-impact-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.est-impact { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0 0; border-top: 1px solid var(--hair, var(--line)); font-size: 14px; }
.est-impact .grow { flex: 1; min-width: 0; }
.est-impact-why { margin: 3px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.est-impact-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.est-impact-actions .btn.small, .est-impacts-head .btn.small { min-height: 34px; }
.est-diff { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.est-walls { display: grid; gap: 6px; margin-top: 6px; }
.est-walls fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px 6px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.est-walls legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.est-unresolved p { margin: 0 0 4px; }

.est-cl { margin-bottom: 22px; }
.est-cl h2 { margin-bottom: 2px; }
.est-cl-list { list-style: none; margin: 8px 0 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.est-cl-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; border-bottom: 1px solid var(--hair, var(--line)); }
.est-cl-item:last-child { border-bottom: 0; }
.est-cl-item.open { box-shadow: inset 3px 0 0 var(--select); background: rgba(10, 102, 216, .05); }
.est-cl-tick { width: 26px; height: 26px; margin: 0 4px 0 12px; border: 2px solid var(--ink-3); border-radius: 7px; background: #fff; font-size: 15px; font-weight: 700; line-height: 1; color: #fff; padding: 0; position: relative; }
/* A full-size touch target around the small box. */
.est-cl-tick::after { content: ""; position: absolute; inset: -11px; }
.est-cl-tick[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.est-cl-tick[aria-checked="mixed"] { border-color: var(--proposal, #7a3fc4); color: var(--proposal, #7a3fc4); border-style: dashed; }
.est-cl-body { display: block; text-align: left; border: 0; background: none; padding: 9px 12px 9px 8px; min-height: var(--touch); width: 100%; }
.est-cl-body .est-desc, .est-cl-body .est-sub { display: block; }
.est-cl-item:not(.on) .est-desc { font-weight: 500; }
.est-cl-confirm { grid-column: 1 / -1; padding: 8px 12px 10px 46px; background: var(--warn-soft); font-size: 13px; }
.est-cl-confirm p { margin: 0 0 6px; }

.svc-badge { display: inline-block; padding: 1px 6px; margin-right: 4px; border-radius: 4px; background: #2f3a45; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; border: 1px solid #2f3a45; }
.svc-badge.possible { background: #fff; color: #2f3a45; border-style: dashed; }
.est-badges { margin: 0 0 6px; }
.est-legend-svc .svc-badge { margin-right: 3px; }
.svc-tags { pointer-events: none; }
.svc-tag rect { fill: #2f3a45; stroke: #2f3a45; stroke-width: 1; }
.svc-tag text { fill: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; }
.svc-tag.possible rect { fill: #fff; stroke-dasharray: 3 2; }
.svc-tag.possible text { fill: #2f3a45; }
.floor-unresolved { fill: url(#sel-hatch); stroke: var(--warn); stroke-width: 2; stroke-dasharray: 6 4; opacity: .9; pointer-events: none; }

/* Objects standing in the rooms, and the countertops above them.
   They sit ON the floor and never cut into it: the room polygon beneath is drawn complete and
   is not clipped or masked by any of this. They take no pointer events unless Objects mode is
   on, so tapping a room or a wall keeps working with a kitchen full of cabinets in the way. */
.acc { pointer-events: none; }
.acc-shape { fill: rgba(120, 120, 128, .13); stroke: #6c6c72; stroke-width: 1.25; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.acc.cabinetry .acc-shape { fill: rgba(126, 96, 48, .16); stroke: #7a5c2e; stroke-dasharray: none; }
.acc-front { stroke: #6c6c72; stroke-width: 1.25; vector-effect: non-scaling-stroke; opacity: .75; }
.acc.selected .acc-shape { stroke: var(--select); stroke-width: 2.5; fill: rgba(31, 95, 214, .18); }
.acc.selected .acc-front { stroke: var(--select); }
/* The owner's teal, the same one the countertop product category uses in the plan and catalogue. */
.ctop { fill: rgba(6, 120, 95, .22); stroke: #06785f; stroke-width: 1.75; vector-effect: non-scaling-stroke; pointer-events: none; }
.ctop.preliminary { stroke-dasharray: 7 4; }
.ctop.selected { stroke-width: 3; fill: rgba(6, 120, 95, .34); }
/* Objects mode: now they are the things being tapped. */
.object-mode .acc, .object-mode [data-accessory], .object-mode [data-countertop] { pointer-events: auto; cursor: pointer; }

/* The Objects section of the room panel. */
.obj-list { list-style: none; margin: 6px 0; padding: 0; }
.obj-row { padding: 8px 0; border-top: 1px solid var(--hair, var(--line)); font-size: 14px; }
.obj-row.selected { background: var(--accent-soft, #eef3fd); border-radius: 8px; padding: 8px; }
.obj-row > p { margin: 0 0 3px; }
.obj-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.obj-h { margin: 12px 0 2px; font-size: 14px; }
.obj-edit { margin: 6px 0 8px; padding: 8px; background: var(--panel); border: 1px solid var(--hair, var(--line)); border-radius: 8px; }
.obj-edit .field { margin-top: 6px; }
.ctop-piece { align-items: end; }
.ctop-row .chip { font-variant-numeric: tabular-nums; }
.obj-controls { margin: 2px 0 8px; }
@media (max-width: 700px) { .est-impact { flex-direction: column; } .est-impact-actions { justify-content: flex-start; } }

/* ---- Surface categories, layout illustration, existing/proposed plan view ---- */
.floor-cat { stroke: none; }
.floor-cat.unknown { stroke: #7a7f86; stroke-width: 1.2; stroke-dasharray: 5 4; }
.floor-layout { fill: none; stroke-width: .8; stroke-linecap: square; opacity: .85; pointer-events: none; }
.room-subtitle { font-size: 11px; font-weight: 600; fill: var(--ink-2, #44505c); paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; pointer-events: none; }
.plan-view-toggle { position: absolute; right: 10px; top: 10px; z-index: 2; }
.pv-seg { display: inline-flex; border: 1px solid rgba(0,0,0,.18); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.pv-btn { appearance: none; border: 0; background: transparent; min-height: 44px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2, #44505c); cursor: pointer; }
.pv-btn + .pv-btn { border-left: 1px solid rgba(0,0,0,.12); }
.pv-btn[aria-pressed="true"] { background: #2f3a45; color: #fff; }
.svc-tag.sf rect { fill: #2e7d32; stroke: #1b5e20; }
.svc-badge.sf { background: #2e7d32; border-color: #1b5e20; }
.est-swatch.cat { border-width: 2px; }
.est-swatch.cat.unknown { border-style: dashed; }
.est-legend-title { margin: 0 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2, #44505c); }
.est-legend-note { margin: 4px 0 0; font-size: 10.5px; color: var(--ink-2, #44505c); max-width: 34ch; }
.est-treatment { margin: 6px 0 10px; }
.est-surface { display: flex; align-items: center; gap: 6px; margin: 4px 0; }

/* ---- Assumed-cost worksheet and the cost sheet (owner only) ---- */
.est-worksheet { margin-top: 18px; padding-top: 10px; border-top: 2px solid rgba(0,0,0,.08); }
.ws-sec th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2, #44505c); padding-top: 10px; }
.ws-min { margin-top: 3px; font-size: 12px; color: #1b5e20; }
.ac-review { padding-left: 18px; }
.ac-review li { margin-bottom: 6px; }

/* ---- Proposal layout drawing ---- */
.pp-drawing { margin: 6px 0 10px; break-inside: avoid; }
.pp-drawing svg { width: 100%; height: auto; display: block; }
.pp-drawing figcaption { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.pp-room { fill: none; stroke: #2f3a45; stroke-width: 1.4; }
.pp-room-name { font-size: 11px; font-weight: 700; fill: #1f2a33; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.pp-room-sub { font-size: 9.5px; fill: #44505c; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.pp-drawing .lay-dir line, .pp-drawing .lay-dir path { stroke: #1f2a33; stroke-width: 1.4; fill: none; }
.pp-layout-key { font-size: 12px; padding-left: 18px; margin: 4px 0; }
.ws-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.ws-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 7px 10px; border-bottom: 1px solid var(--line); background: #fafafb; }
.ws-table td { padding: 8px 10px; border-bottom: 1px solid var(--hair, var(--line)); vertical-align: top; }
.ws-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Four room tabs fit the panel: they share the width and shrink their padding. */
#inspector .tabs .tab { min-width: 0; padding-left: 2px; padding-right: 2px; font-size: 13.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-review { font-size: 13px; }
/* Walls waiting for a person's word, on the selected room (readiness → plan). */
.wall-attention { stroke: var(--warn); stroke-width: 5; stroke-dasharray: 8 5; stroke-linecap: round; opacity: .85; pointer-events: none; }
.wall-attention.scanned { stroke: #b36b00; }
/* Room name shortcuts and readiness list (field review round 2). */
.chip-groups { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip-row-label { flex: 0 0 100%; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin-top: 4px; }
.chip-row .chip-btn { min-height: 36px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.chip-row .chip-btn.current { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#room-name-filter { width: 100%; margin-top: 6px; }
.readiness-list { list-style: none; padding: 0; margin: 2px 0 6px; }
.readiness-list li { margin: 2px 0; }
.link-btn { appearance: none; border: 0; background: transparent; padding: 2px 0; font: inherit; font-size: 13px; color: var(--select, #0a66d8); text-align: left; text-decoration: underline; cursor: pointer; min-height: 0; }
.wall-confirm-list { list-style: none; padding: 0; margin: 6px 0; }
.wall-confirm-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 0; border-top: 1px solid rgba(0,0,0,.06); flex-wrap: wrap; }
.est-contrib { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 2px; }
.est-contrib td { padding: 3px 4px; border-bottom: 1px solid rgba(0,0,0,.06); }
.est-contrib .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.est-contrib tr.total td { font-weight: 700; border-bottom: 0; }
/* Proposal plan: walls, openings and stairs share the working plan's symbols. */
.pp-wall { fill: none; stroke: #2f3a45; stroke-linejoin: miter; }
.pp-drawing .opening .op-gap { fill: #fff; }
.pp-drawing .opening .op-jamb { stroke: #2f3a45; stroke-width: 1.5; }
.pp-drawing .opening .op-leaf { stroke: #1f2a33; stroke-width: 2; stroke-linecap: round; }
.pp-drawing .opening .op-swing { fill: none; stroke: #6e6e73; stroke-width: 1; }
.pp-drawing .opening .op-fan { fill: rgba(29,29,31,.05); stroke: none; }
.pp-drawing .opening .op-glass { stroke: #3a3a3c; stroke-width: 1.2; }
.pp-drawing .opening .op-head { stroke: #6e6e73; stroke-width: 1; stroke-dasharray: 3 3; }
.pp-drawing .opening .op-unknown { stroke: #6e6e73; stroke-width: 1.2; stroke-dasharray: 3 3; }
.pp-drawing .opening.window .op-gap { fill: #fff; }
.pp-stair .stair-flight { fill: #f3f3f1; stroke: #2f3a45; stroke-width: 1.2; }
.pp-stair .stair-landing { fill: #e9e9e6; stroke: #2f3a45; stroke-width: 1.2; }
.pp-allowance { font-style: italic; }
/* The line picker (Add a line / Change…). */
.pick { margin-top: 6px; }
.pick-head { display: flex; align-items: center; justify-content: space-between; }
.pick-head h3 { margin: 0 0 4px; }
#pick-search { width: 100%; margin: 4px 0 6px; }
.pick-kinds { margin: 0 0 6px; }
.pick-kinds .seg-btn { min-height: 36px; font-size: 13px; }
.pick-groups { margin-bottom: 6px; }
.pick-list { list-style: none; padding: 0; margin: 0 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: 360px; overflow: auto; }
.pick-list li + li { border-top: 1px solid rgba(0,0,0,.06); }
.pick-row { appearance: none; border: 0; background: transparent; width: 100%; text-align: left; padding: 8px 10px; font: inherit; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-height: 44px; }
.pick-row:hover { background: #fafafb; }
.pick-row:disabled { opacity: .55; cursor: default; }
.pick-name { font-weight: 600; font-size: 14px; }
.pick-meta { display: flex; gap: 10px; font-size: 12px; flex-wrap: wrap; }
.pick-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.pick-price.needed { color: var(--warn); }
.est-tag.allow { background: #fff4d6; color: #7a4b00; border-color: #e9c46a; }
.pick-custom { margin-top: 6px; }
/* Checklist roadmap (stages, review states, show/hide). */
.btn.tiny { min-height: 28px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.est-cl-head { display: flex; align-items: center; gap: 10px; }
.est-cl-head h2 { margin: 0; flex: 1; }
.est-cl-stage { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.est-cl-item.na .est-desc, .est-cl-item.alt .est-desc { color: var(--ink-3); text-decoration: line-through; }
.est-cl-item.ref .est-cl-body.static { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; }
.est-cl-item .btn.tiny { align-self: center; margin-left: 4px; flex: 0 0 auto; }
.est-cl-more { margin-top: 12px; }
.cost-needed { color: var(--warn); font-weight: 700; }
.ws-table tr.needs-cost td { background: var(--warn-soft, #fff7e6); }
.ws-totals.incomplete .total { color: var(--warn); }

/* Round 3: the work roadmap (assisted scope builder), the pricing stage slider, material floors. */
.est-roadmap { margin-bottom: 22px; }
.est-rm-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.est-rm-top h2 { margin: 0; }
.est-rm-path { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; background: var(--panel); }
.est-rm-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.est-rm-head h3 { margin: 0; flex: 1 1 auto; }
.est-rm-stage { margin: 12px 0 2px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.est-rm-list { list-style: none; margin: 0; padding: 0; }
.est-rm-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--hair, var(--line)); font-size: 14px; }
.est-rm-item:last-child { border-bottom: 0; }
.est-rm-tick { width: 18px; text-align: center; color: var(--ink-3); }
.est-rm-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.est-rm-item.generated .est-rm-tick, .est-rm-item.in-estimate .est-rm-tick { color: var(--ok); font-weight: 700; }
.est-rm-item.conditional { background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); padding-left: 6px; }
.est-rm-item.conditional .est-rm-tick { color: var(--warn); font-weight: 700; }
.est-rm-item.reminder .est-desc, .est-rm-item.declined .est-desc { color: var(--ink-3); }
.est-rm-item.declined .est-desc { text-decoration: line-through; }
.est-tag.on { background: #e3f3e8; color: var(--ok); }
.est-tag.warn { background: var(--warn-soft); color: var(--warn); }
.est-rm-unresolved { margin-top: 10px; }
/* Possible additional work is marked by an icon and the word as well as the amber. */
.est-table tr.est-row-cond td { background: var(--warn-soft); }
.est-table tr.est-row-cond td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.est-cond-note { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; }
.est-cond-note p:first-child { margin-top: 0; }
/* The five-stage pricing slider: five labelled stops, never a bare handle. */
.est-stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 760px; margin: 10px 0 18px; }
.est-stage { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; min-height: 60px; }
.est-stage-bp { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.est-stage-label { font-size: 11.5px; color: var(--ink-2); text-align: center; line-height: 1.2; }
.est-stage-std { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.est-stage.standard { border-style: dashed; }
.est-stage.on { border-color: var(--select); box-shadow: inset 0 0 0 1px var(--select); background: rgba(10, 102, 216, .06); }
.est-pricing-table tr.est-pr-protected td, .est-pricing-table tr.est-pr-unclassified td { color: var(--ink-2); }
.est-pricing-table tr.est-pr-no-cost td { background: var(--warn-soft); }
.est-floor-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.est-floor { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.est-floor.below { border-color: var(--warn); background: var(--warn-soft); }
.est-floor.none { border-style: dashed; }
.est-floor-ask { grid-column: 1 / -1; }

/* Potential additional work: a readable table, with the circumstances first. */
.pp-conditional .pp-table { table-layout: fixed; width: 100%; }
.pp-conditional .pp-table th:nth-child(1), .pp-conditional .pp-table td:nth-child(1) { width: 36%; }
.pp-conditional .pp-table th:nth-child(2), .pp-conditional .pp-table td:nth-child(2) { width: 34%; }
.pp-conditional .pp-table th:nth-child(3), .pp-conditional .pp-table td:nth-child(3) { width: 17%; }
.pp-conditional .pp-table th:nth-child(4), .pp-conditional .pp-table td:nth-child(4) { width: 13%; }
.pp-conditional .pp-table td { vertical-align: top; overflow-wrap: anywhere; white-space: normal; }
.pp-conditional .pp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Round 4: the existing floor covering, substrates and the thickness control. */
.cover-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.cover-chip { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 13px; text-align: left; cursor: pointer; }
.cover-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-chip.on { border-color: var(--select); box-shadow: inset 0 0 0 1px var(--select); background: rgba(10, 102, 216, .06); font-weight: 600; }
.est-covering-fields { margin-bottom: 8px; }
.est-layer-move { display: inline-flex; gap: 4px; margin-left: auto; }
.est-layer-move .btn.tiny { min-width: 32px; min-height: 32px; }
.th-ctl { display: flex; gap: 4px; align-items: center; }
.th-ctl select { flex: 1 1 auto; min-width: 92px; }
.th-ctl .th-custom { flex: 1 1 70px; min-width: 64px; }
.est-add-layer .th-ctl { flex: 1 1 140px; }

/* Round 4: the floor-assembly HUD (the "sandwich"), discreet on the plan and expandable. */
.floor-hud { position: absolute; right: 10px; bottom: 84px; z-index: 3; max-width: min(330px, calc(100% - 20px)); }
.floor-hud[hidden] { display: none; }
.hud-strip { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.96); box-shadow: 0 2px 10px rgba(0,0,0,.08); font-size: 12.5px; cursor: pointer; max-width: 100%; }
.hud-strip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-strip-mark { width: 16px; height: 12px; border-radius: 2px; background: linear-gradient(#d5e5fb 0 33%, #f1ede6 33% 66%, #e4d8c3 66% 100%); border: 1px solid var(--line); flex: none; }
.hud-strip-chev { color: var(--ink-3); }
.hud-card { background: rgba(255,255,255,.98); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.12); padding: 8px 10px 10px; max-height: min(70vh, 560px); overflow: auto; }
.hud-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.hud-head strong { font-size: 13px; }
.hud-head .est-x { margin-left: auto; }
.hud-svg { display: block; max-width: 100%; }
.hud-svg .hud-label { font-size: 10.5px; fill: var(--ink); }
.hud-svg .hud-thick { font-size: 10.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.hud-svg .hud-support-text { font-size: 10px; fill: var(--ink-2); }
.hud-svg .hud-band.removed .hud-label { text-decoration: line-through; fill: var(--ink-3); }
.hud-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11.5px; }
.hud-list li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; border-bottom: 1px solid var(--hair, var(--line)); }
.hud-list li:last-child { border-bottom: 0; }
.hud-li-meta { color: var(--ink-2); flex: none; }
.hud-note { margin: 6px 0 0; font-size: 11px; color: var(--ink-2); }
.hud-heights { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; margin: 6px 0 0; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.hud-heights dd { margin: 0; text-align: right; }
@media (max-width: 1000px) {
  /* Phone: the strip stays discreet, and the expanded card keeps the plan and its controls usable. */
  .floor-hud { bottom: 64px; max-width: min(260px, 72%); }
  .hud-card { max-height: 38vh; padding: 6px 8px 8px; }
  .hud-card .hud-list, .hud-card .hud-heights { font-size: 11px; }
}

/* Round 4: readiness, wall confirmation and openings are compact lines, opened on demand. */
.ready-line { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.ready-line .ready-ok { color: var(--ok); font-weight: 600; }
.ready-line .ready-no { color: var(--warn); font-weight: 600; }
.ready-line .btn { margin-left: auto; }
details.compact-review { margin: 6px 0; }
details.compact-review > summary { display: flex; align-items: center; gap: 6px; min-height: 36px; cursor: pointer; font-size: 13px; }
details.compact-review .readiness-list, details.compact-review .wall-confirm-list { margin-top: 4px; }
details.card > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
details.card > summary .card-title { margin: 0; }
details.card > summary .chip { margin-left: 2px; }

/* Round 4: walls are one painted union per thickness — shared boundaries once, mitred corners. */
.walls .wall { stroke-linejoin: miter; stroke-linecap: butt; shape-rendering: geometricPrecision; }
.snap-guide { stroke: var(--select); stroke-width: 1.5; stroke-dasharray: 7 4; opacity: .95; }
.snap-guide.collinear { stroke-dasharray: 3 4; }

/* Round 4: the end-of-measure field checklist. */
.measure-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.measure-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--hair, var(--line)); font-size: 13px; }
.measure-row:last-child { border-bottom: 0; }
.measure-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.measure-row.done .measure-text strong { color: var(--ok); }
.measure-row.na .measure-text strong { color: var(--ink-3); text-decoration: line-through; }
.measure-row .btn.tiny { min-height: 44px; min-width: 52px; }

/* Round 5: the scenario selector and the New scenario form. */
.scenario-group .chip { white-space: nowrap; }
.scenario-new { position: absolute; top: 52px; left: 12px; z-index: 20; width: min(420px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 10px 12px; }
.scenario-modes { display: grid; gap: 6px; margin: 4px 0 8px; }
.scenario-modes .check { align-items: flex-start; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); }
.scenario-modes .check input { margin-top: 3px; }

/* Round 5: services in fine print on the plan — the real work, never a generic SVC pill. */
.svc-labels { cursor: default; }
.svc-labels .svc-label { font-size: 9.5px; font-weight: 600; letter-spacing: .01em; fill: var(--ink-2); paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 2.5px; stroke-linejoin: round; }
.svc-labels:focus { outline: none; }
.svc-labels:focus .svc-label { fill: var(--select); stroke-width: 3px; }
.pp-svc { font-size: 7.5px; font-weight: 600; fill: #55555c; }

/* Round 6: the three assembly sections, the visible cross-section, the lock and the selection. */
.est-subfloor { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.est-subfloor select { flex: 1 1 180px; min-width: 150px; }
.est-lock { margin-left: 8px; vertical-align: middle; }
.est-lock.on { background: var(--warn-soft, #fff4d6); border-color: var(--warn, #a86b00); color: var(--warn, #a86b00); }
.est-selection { border-left: 4px solid var(--select); }
.sw-figure { margin: 6px 0 10px; }
/* The default panel has to be readable on its own: "Bigger view" is comfort, not legibility.
   The drawing is laid out in its own coordinates and scaled by the viewBox, so the same figure
   works at phone width and at a desk. */
.sw-figure svg { width: 100%; height: auto; display: block; min-height: 180px; }
.sw-expanded svg { min-height: 300px; }
/* Dark labels on light fills, outside the bands, joined by a hairline leader. */
.sw-label { font-size: 11.5px; font-weight: 600; fill: var(--ink); dominant-baseline: middle; }
.sw-expanded .sw-label { font-size: 13px; }
.sw-dim { font-weight: 800; font-variant-numeric: tabular-nums; }
.sw-note { font-weight: 400; fill: var(--muted); font-size: .92em; }
.sw-leader { stroke: #9a9a9a; stroke-width: 1; }
.sw-band.sw-removed rect, .sw-band.sw-removed line:not(.sw-leader) { opacity: .45; }
.sw-band.sw-removed .sw-label { text-decoration: line-through; }
.sw-band.sw-new rect { stroke-width: 2.5; }
.sw-zero { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 3; }
.sw-zero-label { font-size: 10px; font-weight: 700; fill: var(--ink); }
/* The build-up above the subfloor, as a dimension. It is never a total while a layer is unrecorded. */
.sw-dim-line { stroke: var(--ink); stroke-width: 1.2; }
.sw-dim-text { font-size: 11px; font-weight: 800; fill: var(--ink); dominant-baseline: middle; font-variant-numeric: tabular-nums; }
.sw-dim-text.incomplete { fill: var(--warn); font-weight: 700; }
.sw-scale { font-size: 9px; fill: var(--muted); }
.sw-caption { font-size: 12px; color: var(--ink); margin: 2px 0 0; }
.sw-caption.incomplete { color: var(--warn); }
.sw-support .sw-label { fill: var(--muted); }
:root { --sw-covering: #cfe0f5; --sw-substrate: #e7e2d6; --sw-structural: #d9d3c7; --sw-unknown: #efefef; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { --sw-covering: #2d3f57; --sw-substrate: #403b31; --sw-structural: #35312a; --sw-unknown: #2c2c2c; }
}
@media (max-width: 600px) {
  .sw-label { font-size: 10px; }
  .est-subfloor select { flex-basis: 100%; }
}

/* ---- Estimating engine: scope builder, questions, conflicts, review, rules ---- */
.eng-panel { margin: 0 0 14px; }
.eng-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.eng-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.eng-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.eng-qs, .eng-conflicts { list-style: none; margin: 6px 0; padding: 0; }
.eng-q { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--hair, var(--line)); font-size: 14px; }
.eng-q > .grow { flex: 1; min-width: 0; }
.eng-q p { margin: 0 0 6px; }
.eng-q select, .eng-q input[type="text"] { max-width: 100%; }
.eng-q.missing-item { border-left: 3px solid var(--warn); padding-left: 8px; }
.eng-q.cannot-decide .est-tag { background: var(--warn-soft); color: var(--warn); }
.eng-conflict { padding: 8px 0 8px 10px; border-top: 1px solid var(--hair, var(--line)); border-left: 3px solid var(--warn); font-size: 14px; background: var(--warn-soft); margin-top: 4px; border-radius: 0 6px 6px 0; }
.eng-conflict.blocking { border-left-color: #b3261e; background: #fdeeed; }
.eng-conflict .btn { margin-top: 6px; display: inline-flex; }
.est-tag.block { background: #fdeeed; color: #8a1d16; }
.eng-review { border-left: 3px solid var(--accent); }
.eng-review ul li { padding: 3px 0; }
.eng-intent textarea { width: 100%; margin: 6px 0; }
.eng-cond { font-size: 11.5px; line-height: 1.35; white-space: pre-wrap; background: #f7f8f9; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-height: 180px; overflow: auto; margin: 4px 0 8px; }
.est-flags.small { font-size: 12.5px; }
.est-flags.small li { padding: 2px 0; }
.pp-generated p { margin: 4px 0; font-size: 12.5px; }
/* Questions grouped by topic: one heading, its rooms indented underneath. Generous spacing —
   this is the list the estimator works down, and a cramped one is the thing being fixed. */
.eng-topics, .eng-occs, .eng-assumptions { list-style: none; margin: 6px 0; padding: 0; }
.eng-topic, .eng-assumption { padding: 10px 0 12px; border-top: 1px solid var(--hair, var(--line)); font-size: 14px; }
.eng-topic > p, .eng-assumption > p { margin: 0 0 6px; }
.eng-topic-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.eng-topic .details, .eng-assumption .details { margin: 8px 0 0; }
.eng-occs { margin: 4px 0 0; padding: 0 0 0 10px; border-left: 2px solid var(--hair, var(--line)); }
.eng-occ { padding: 8px 0; }
.eng-occ + .eng-occ { border-top: 1px dashed var(--hair, var(--line)); }
.eng-occ > p { margin: 0 0 4px; }
.eng-assumption { border-left: 3px solid var(--warn); padding-left: 10px; background: var(--warn-soft); border-radius: 0 6px 6px 0; margin-top: 4px; }
.eng-topic select, .eng-occ select, .eng-assumption select, .eng-topic input[type="text"], .eng-occ input[type="text"] { max-width: 100%; }
@media (max-width: 700px) { .eng-q { flex-direction: column; } .eng-head { flex-direction: column; } .eng-head > div:first-child { flex-basis: auto; } .eng-occs { padding-left: 8px; } }

/* The selection box dragged with the Select tool (roomSelect.ts). Presentation only: it is drawn
   over everything, at a fixed screen width, and never survives the gesture that drew it. */
.marquee {
  fill: rgba(43, 108, 176, 0.1);
  stroke: #2b6cb0;
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
  pointer-events: none;
}
.sel-picks .chip { margin-left: 4px; }
.sel-chip { cursor: pointer; }

/* Cut plans (cutPlanUi.ts). The roll drawing is a recommendation and is labelled as one; the
   seam layout above it is what a customer is shown. */
.cut-rooms { list-style: none; margin: 6px 0; padding: 0; }
.cut-rooms li { padding: 2px 0; }
.cut-pools .chip { margin-left: 4px; }
.cut-change { border-left: 3px solid #2b6cb0; }
.cut-change .est-contrib td { padding: 2px 6px; }
.cut-room { padding: 8px 0; }

/* A room, tappable, with its number: the same number the cut sheet writes on its pieces. */
.cut-roomchip {
  display: flex; align-items: baseline; gap: 6px; width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; font: inherit; color: inherit; cursor: pointer; min-height: 40px;
}
.cut-roomchip:hover { background: #f4f4f7; }
.cut-roomchip.lit { background: #f0e9fa; border-color: #6b3fa6; }
.cut-roomno {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px;
  background: #6b3fa6; color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 auto;
}

/* The assumption bar: a budget figure says it is one, above the fold, next to the way to change it. */
.cut-ready { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: #f6f6f9; border: 1px solid #dcdce4; }
.cut-ready.assumed { background: #fbf7ff; border-color: #c3a7e4; }
.cut-assume { margin: 0 0 6px; font-size: 13px; }

/* The cut sheet. Purple stays the carpet colour; pieces are told apart by two depths of it, by
   their outlines and by their labels — never by borrowing another category's colour. */
.cut-rollwrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cut-roll { flex: 1 1 340px; max-width: 520px; margin: 0; }
.cut-roll.big { max-width: none; flex-basis: 100%; max-height: 70vh; overflow-y: auto; }
.cut-roll svg { display: block; }
.cut-roll figcaption { font-size: 12px; color: var(--muted, #667); margin-top: 6px; }
.cut-rollbg { fill: #e7e9ef; stroke: #9aa0ad; stroke-width: 1.2; }
/* Hatched: inside the usable band but not under a piece is material bought and not cut. */
.cut-usable { stroke: #6b3fa6; stroke-width: 1; stroke-dasharray: 5 4; }
.cut-piece { fill: #e6dbf5; stroke: #6b3fa6; stroke-width: 1.1; }
.cut-piece.alt { fill: #d6c4ee; }
.cut-pieceg { cursor: pointer; }
.cut-pieceg.lit .cut-piece { stroke-width: 2; }
.cut-pieceg.selected .cut-piece { stroke: #2b6cb0; stroke-width: 2.6; fill: #cfe0f3; }
.cut-pieceg:focus-visible { outline: none; }
.cut-pieceg:focus-visible .cut-piece { stroke: #2b6cb0; stroke-width: 2.6; }
/* The pile runs down the roll. Drawn on each piece so "do not reverse it" is visible, not a note. */
.cut-pile { stroke: #6b3fa6; stroke-width: 1; fill: none; opacity: 0.55; }
.cut-label { font-size: 11px; fill: #3d2363; font-weight: 600; cursor: pointer; }
.cut-label tspan:nth-child(n + 2) { font-weight: 400; }
.cut-label.out { fill: #44465a; }
.cut-label.selected { fill: #1c4f87; font-weight: 700; }
.cut-leader { stroke: #9aa0ad; stroke-width: 0.8; }
.cut-leader.selected { stroke: #2b6cb0; stroke-width: 1.4; }
/* The length ruler: every piece boundary, written where it can be read. */
.cut-tick line { stroke: #b9bcc8; stroke-width: 0.6; stroke-dasharray: 2 3; }
.cut-tick text { font-size: 9.5px; fill: #667; text-anchor: end; }
/* Bought and not cut: hatched, so the tail is never mistaken for a piece. */
.cut-tailband { fill: #9aa0ad; opacity: 0.18; }
.cut-tailtext { font-size: 9.5px; fill: #667; text-anchor: middle; }
.cut-usedline { stroke: #6b3fa6; stroke-width: 1.6; }
.cut-repeat { stroke: #b9b2c8; stroke-width: 0.5; stroke-dasharray: 2 3; }
.cut-legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted, #667); }
.cut-legend li { display: flex; align-items: center; gap: 6px; }
.cut-key { width: 16px; height: 10px; flex: 0 0 auto; border: 1px solid #9aa0ad; }
.cut-key.roll { background: #f2f2f4; }
.cut-key.usable { background: #fff; border: 1px dashed #6b3fa6; }
.cut-key.offcut { background: repeating-linear-gradient(45deg, #d6d8e0 0 2px, #fff 2px 5px); }
.cut-key.piece { background: #e6dbf5; border-color: #6b3fa6; }
.cut-arrow { color: #6b3fa6; font-weight: 700; width: 16px; text-align: center; flex: 0 0 auto; }

/* Checklists: a scope row is a switch, because that is what it does. */
.est-switch { background: none; border: 0; padding: 6px 4px 6px 0; cursor: pointer; flex: 0 0 auto; min-height: 40px; display: flex; align-items: center; }
.est-switch-track {
  display: inline-block; width: 38px; height: 22px; border-radius: 11px;
  background: #d6d8e0; border: 1px solid #b9bcc8; position: relative; transition: background 120ms;
}
.est-switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left 120ms; }
.est-switch.on .est-switch-track { background: #2b6cb0; border-color: #2b6cb0; }
.est-switch.on .est-switch-knob { left: 18px; }
.est-switch:focus-visible .est-switch-track { outline: 2px solid #2b6cb0; outline-offset: 2px; }
.est-rm-note { display: inline-block; width: 38px; text-align: center; color: var(--muted, #667); flex: 0 0 auto; }
.est-rm-rooms { margin: 6px 0 0; padding: 6px 8px; border-left: 2px solid #d6d8e0; }
.est-rm-confirm { margin: 6px 0 0; padding: 8px; }
.est-rm-reminders { margin-top: 10px; }
.est-rm-item.reminder { opacity: 0.8; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Products: a project product is a button, because tapping it opens its settings. */
.est-product-pick {
  display: block; text-align: left; background: none; border: 0; padding: 0; font: inherit;
  color: inherit; cursor: pointer; width: 100%; min-height: 40px;
}
.est-product-pick .est-sub { display: block; }
.est-product-card.open { outline: 2px solid #2b6cb0; outline-offset: 2px; border-radius: 6px; }
.est-catalog-picker { margin-top: 12px; }

/* A plan PFM does not believe, and a width that looks mistyped. Both say so before any figure. */
.cut-sanity { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: #f6f6f9; border: 1px solid #dcdce4; }
.cut-sanity.serious { background: #fff6f4; border-color: #e0a79a; }
.cut-sanity h3 { margin-top: 0; }
.cut-sanity .est-flags { margin: 0 0 8px; }
.cut-recover { margin: 10px 0; }
.cut-recover .est-contrib td { padding: 2px 6px; }

/* Recalculating: offered, compared, and taken on purpose. */
.cut-improve-ask { margin: 10px 0; align-items: center; gap: 10px; }
.cut-improve { margin: 10px 0; padding: 10px 12px; border-radius: 8px; border: 1px solid #dcdce4; background: #fbfbfd; }
.cut-improve.better { border-color: #7fae7f; background: #f6fbf6; }
.cut-improve h3 { margin-top: 0; }
.cut-improve .est-contrib td { padding: 2px 6px; }

/* The contextual panel: controls for the one thing that is selected, and nothing else. */
.cut-context { margin: 12px 0; padding: 10px 12px; border-radius: 8px; border: 1px solid #dcdce4; background: #fbfbfd; }
.cut-context.empty { color: var(--muted, #667); }
.cut-context h3 { margin-top: 0; display: flex; align-items: center; gap: 6px; }
.cut-context h4 { margin: 10px 0 4px; }
.cut-chips { gap: 6px; }
.cut-piecetable tbody tr { cursor: pointer; }
.cut-piecetable tbody tr:hover { background: #f4f0fb; }

@media (max-width: 560px) {
  .cut-roll { flex-basis: 100%; max-width: none; }
  .cut-rollwrap { gap: 20px; }
}

/* Carpet seams on the plan. Presentation until Move seams is on, like objects: a seam must never
   come between a finger and the room it is in. */
.seam { pointer-events: none; }
.seam-hit { stroke: transparent; stroke-width: 18; fill: none; }
.seam-line { stroke: #6b3fa6; stroke-width: 2; stroke-dasharray: 7 4; fill: none; }
.seam.locked .seam-line { stroke-dasharray: none; stroke-width: 2.5; }
.seam.selected .seam-line { stroke: #2b6cb0; stroke-width: 3.5; }
.seam-move .seam, .seam-move [data-seam] { pointer-events: auto; cursor: ew-resize; }

/* A carpet seam on the customer's drawing. Deliberately unlike a wall (solid, thick), an opening
   (a gap with a swing), a cut on the roll or a pattern line: a long dash in the carpet's own
   colour, so the legend has one mark to explain. */
.pp-seam { stroke: #6b3fa6; stroke-width: 1.6; stroke-dasharray: 9 5; fill: none; }
.pp-legend { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.pp-legend li { display: flex; align-items: center; gap: 8px; }
.pp-legend-mark { width: 28px; height: 10px; flex: 0 0 auto; }

/* Projects dialog: copies of a project (save a copy / import). */
.dialog .dlg-sub { font-size: 14px; margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid #eef0f2; }
#project-import-review .card { margin-top: 10px; }

/* Cut plans: the confirmed allowance policy, the review of other cuts, waste by cause, cross seams. */
.cut-policy { margin: 10px 0; }
.cut-policy .est-contrib td { padding: 2px 6px; }
.cut-improve.pending { border-style: dashed; }
.cut-improve.none, .cut-improve.folded { background: #fbfbfd; }
.cut-option { margin: 10px 0; padding: 10px 12px; border: 1px solid #d5e3d5; border-radius: 8px; background: #fff; }
.cut-option h4 { margin: 0 0 4px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cut-option .cut-saving { margin: 2px 0 6px; font-size: 14px; }
.cut-option[data-option="extra-seam"], .cut-option[data-option="direction-extra-seam"] { border-color: #e3d7b0; }
.cut-option[data-option="direction"] { border-color: #c9d6ea; }
.cut-sheetnote { margin: 8px 0 12px; border-color: #7fae7f; background: #f6fbf6; }
.cut-sheetnote .est-flags li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cut-waste { margin-top: 8px; }
.cut-waste .est-contrib td { padding: 2px 6px; vertical-align: top; }
.cut-finished { fill: none; stroke: #6b3fa6; stroke-width: 0.8; stroke-dasharray: 3 2.5; pointer-events: none; opacity: 0.85; }
.cut-pieceg.selected .cut-finished { stroke: #2b6cb0; }
.seam.cross .seam-line { stroke-dasharray: 2 4; stroke-width: 2.4; stroke-linecap: round; }
.pp-seam.cross { stroke-dasharray: 2 4; stroke-width: 2; stroke-linecap: round; }
.cut-sheetnote.policy { border-color: #e3d7b0; background: #fffaf0; }

/* PFOS project picker (src/app/projectPickerUi.ts) */
.pp-project-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 10px; margin: 6px 0; font-size: 14px; }
.pp-project-facts dt { color: var(--ink-2); font-weight: 600; }
.pp-project-facts dd { margin: 0; overflow-wrap: anywhere; }
#pp-project .card-title .chip + .chip { margin-left: 6px; }
#pp-project input[type="search"] { width: 100%; }
#pp-project-results li, #pp-project-recent li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; overflow-wrap: anywhere; }
.pp-sub { margin: 12px 0 2px; font-size: 14px; }

/* The printable carpet cut sheet (src/app/cutSheetPrint.ts). Previewed inside the Cut plans module;
   printed on its own: `body.print-cut-sheet` is set only while it prints. No prices are on it. */
.cut-sheet-print { margin-top: 18px; }
.cut-sheet-print > summary { cursor: pointer; font-weight: 600; min-height: var(--touch, 44px); display: flex; align-items: center; gap: 8px; }
.cs-doc { background: #fff; color: #111; border: 1px solid var(--line, #ddd); padding: 18px 20px; font-size: 12.5px; line-height: 1.35; }
.cs-doc h1 { font-size: 20px; margin: 0 0 8px; }
.cs-doc h2 { font-size: 15px; margin: 16px 0 6px; border-bottom: 2px solid #333; padding-bottom: 2px; }
.cs-doc h3 { font-size: 13px; margin: 10px 0 4px; }
.cs-kv, .cs-table { border-collapse: collapse; width: 100%; }
.cs-kv th, .cs-kv td, .cs-table th, .cs-table td { border: 1px solid #bbb; padding: 3px 6px; text-align: left; vertical-align: top; }
.cs-kv th, .cs-table thead th { background: #f0f0f0; font-weight: 600; white-space: nowrap; }
.cs-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-muted { color: #666; font-weight: 400; }
.cs-note { color: #333; font-size: 12px; margin: 4px 0; }
.cs-list { margin: 4px 0; padding-left: 18px; }
.cs-warn { color: #6b3d00; }
.cs-stop { border: 3px solid #a30000; color: #a30000; padding: 8px 12px; margin: 10px 0; }
.cs-stop ul { margin: 4px 0 0; color: #111; }
.cs-roll-fig { margin: 10px 0; break-inside: avoid; page-break-inside: avoid; }
.cs-roll-fig figcaption { font-size: 11px; color: #444; margin-bottom: 2px; }
.cs-roll-bg { fill: #f3f3f3; }
.cs-usable { fill: none; stroke: #7a3fc4; stroke-dasharray: 4 3; stroke-width: 1; }
.cs-piece { fill: rgba(122, 63, 196, .14); stroke: #3b1f63; stroke-width: 1; }
.cs-piece-label { font-size: 11px; font-weight: 700; fill: #111; }
.cs-piece-size { font-size: 9.5px; fill: #222; }
.cs-roll-edge { fill: none; stroke: #111; stroke-width: 1.2; }
.cs-room-block { break-inside: avoid; page-break-inside: avoid; margin-bottom: 10px; }
.cs-room { fill: #fafafa; stroke: #111; stroke-width: 1.2; }
.cs-seam { stroke: #c00; stroke-width: 2; stroke-dasharray: 6 3; }
.cs-seam.cross { stroke: #c06000; }
.cs-foot { margin-top: 14px; font-size: 11px; color: #444; border-top: 1px solid #bbb; padding-top: 6px; }
.cs-piece.manual { fill: rgba(196, 120, 20, .16); stroke: #6b3d00; stroke-dasharray: 5 2; }
.cs-manual-row td { background: #fff8ec; }
.cs-tag { font-size: 11px; font-weight: 600; border: 1px solid #6b3d00; color: #6b3d00; padding: 0 4px; border-radius: 3px; }
.cs-table tr, .cs-kv tr, .cs-list li { break-inside: avoid; page-break-inside: avoid; }
.cs-table thead { display: table-header-group; }
.cs-doc h2, .cs-doc h3 { break-after: avoid; page-break-after: avoid; }
.cut-manual fieldset { border: 1px solid var(--line, #ddd); border-radius: 6px; margin: 8px 0; padding: 6px 10px; }
.cut-manual legend { font-weight: 600; }
.cut-manual .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 10px; }
.cut-manual label { display: flex; flex-direction: column; font-size: 12.5px; gap: 2px; }
@media print {
  body.print-cut-sheet .ws-main > *:not(.cut-sheet-print) { display: none !important; }
  body.print-cut-sheet .cut-sheet-print > summary, body.print-cut-sheet .cut-sheet-print > .row { display: none !important; }
  body.print-cut-sheet .cs-doc { border: 0; padding: 0; }
  body.print-cut-sheet .cs-roll { break-before: page; page-break-before: always; }
  body.print-cut-sheet .cs-rooms { break-before: page; page-break-before: always; }
  body.print-cut-sheet .cs-stairs { break-before: page; page-break-before: always; }
  body.print-cut-sheet .cut-manual { display: none !important; }
}

/* Carpet Layout workspace (src/app/carpetLayoutUi.ts): floor plan and roll, side by side. */
.cl-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.cl-panes[data-pane='floor'], .cl-panes[data-pane='roll'] { grid-template-columns: 1fr; }
@media (max-width: 900px) { .cl-panes { grid-template-columns: 1fr; } }
.cl-pane { border: 1px solid var(--line, #d6d9de); border-radius: 8px; padding: 8px; background: var(--card, #fff); min-width: 0; }
.cl-pane header { gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.cl-zoom { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.cl-svg { width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
#cl-floor { height: min(70vh, 640px); background: #fafbfc; border-radius: 6px; cursor: grab; }
.cl-rollscroll { max-height: min(70vh, 640px); overflow: auto; }
.cl-rollscroll .cl-svg { width: auto; }
.cl-room { fill: #f2f4f7; stroke: #4a5563; cursor: pointer; }
.cl-room.sel { fill: #e8f0fe; }
.cl-piece { fill: rgba(70, 120, 200, 0.18); stroke: #4678c8; cursor: pointer; }
.cl-piece.sel, .cl-rpiece.sel .cl-raw { fill: rgba(240, 160, 40, 0.35); stroke: #c07000; }
.cl-label { font: 600 12px system-ui, sans-serif; fill: #1f2933; pointer-events: none; }
.cl-dim { font: 11px system-ui, sans-serif; fill: #3e4c59; pointer-events: none; }
.cl-dir line { stroke: #7b8794; } .cl-dir circle { fill: #7b8794; }
.cl-seam line { stroke: #d64545; } .cl-seam.locked line:first-child { stroke: #8a1c1c; stroke-dasharray: none; }
.cl-seam:not(.locked) line:first-child { stroke-dasharray: 40 24; }
.cl-seam.sel line:first-child { stroke: #c07000; }
.cl-seam .cl-hit { stroke: transparent; cursor: ew-resize; }
.cl-seam.dragging line:first-child { stroke: #2f855a; } .cl-seam.dragging.bad line:first-child { stroke: #d64545; }
.cl-unused { fill: #eef0f3; stroke: #9aa5b1; }
.cl-selvage { fill: #d9dde2; }
.cl-rpiece { cursor: grab; }
.cl-rpiece .cl-raw { fill: #fde8c8; stroke: #a46b1f; }
.cl-rpiece .cl-fin { fill: #c9dcf5; stroke: #4678c8; stroke-dasharray: 3 2; }
.cl-rpiece.locked .cl-raw { stroke-width: 2.5; }
.cl-rpiece.dragging { opacity: 0.85; } .cl-rpiece.dragging .cl-raw { stroke: #2f855a; stroke-width: 2.5; }
.cl-rpiece.dragging.bad .cl-raw { fill: #fbd5d5; stroke: #d64545; }
.cl-pile { stroke: #52606d; fill: none; stroke-width: 1.5; pointer-events: none; }
.cl-grid { stroke: #b44dd6; stroke-width: 0.75; stroke-dasharray: 2 3; }
.cl-tick { stroke: #7b8794; } .cl-ruler { font: 11px system-ui, sans-serif; fill: #52606d; }
.cl-end { stroke: #1f2933; stroke-width: 2; }
.cl-live { min-height: 1.4em; font-size: 13px; margin: 4px 0; color: #2f855a; }
.cl-live[data-bad='1'] { color: #b42318; }
.cl-totals { border-collapse: collapse; width: 100%; font-size: 13px; }
.cl-totals th { text-align: left; font-weight: 500; color: #52606d; padding: 3px 6px 3px 0; }
.cl-totals td { padding: 3px 0; }
.cl-controls { gap: 6px; margin: 6px 0; }
.cl-pane-toggle { margin-left: auto; }
.cl-rooms { padding-left: 16px; } .cl-rooms li { margin-bottom: 8px; }
.cl-status { margin: 6px 0; }
.cl-hint { margin: 0 0 6px; }
.cl-rollscroll .cl-svg { max-width: none; }

/* Aligned with the PFOS design system (docs/DESIGN-SYSTEM.md in PFOS): quiet fills instead of outlines,
   one blue accent, hairline separators. The drawing canvas keeps its own fixed light colours. */
.btn:hover:not(:disabled), .text-btn:hover:not(:disabled), .dir-btn:hover:not(:disabled), .tab:hover:not(:disabled) { background: var(--fill-2); }
.icon-btn, .text-btn { background: var(--fill); }
.btn.primary:hover:not(:disabled), .tab.primary:hover:not(:disabled) { background: #0858bb; }
