/* Fit Lab: warm monochrome, one hairline weight, colour only where it means a verdict. */
:root {
  --canvas: #f7f6f3; --surface: #ffffff; --line: #eaeaea; --line-2: #e2e0db;
  --text: #2f3437; --muted: #787774; --faint: #a3a19c; --hover: #f4f3ef;
  --works: #346538; --works-bg: #edf3ec; --works-3d: #4c8a57;
  --tight: #956400; --tight-bg: #fbf3db; --tight-3d: #c28a1e;
  --fails: #9f2f2d; --fails-bg: #fdebec; --fails-3d: #c2453d;
  --needs: #5f5e5b; --needs-bg: #f1f1ef; --needs-3d: #8e8d89;
  --conflict: #5e4a9c; --conflict-bg: #efebf8; --conflict-3d: #7a67b5;
  --label-2: #4c5154; /* labels' second lines in the model (ranges, margins, names): darker than --muted, they sit on the model */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  font: 14px/1.55 var(--sans);
  color: var(--text); background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; grid-template-columns: 384px 1fr; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
code, kbd { font-family: var(--mono); font-size: 11.5px; }
kbd { border: 1px solid var(--line); border-radius: 4px; background: var(--canvas); padding: 1px 6px; color: var(--text); }
svg { width: 16px; height: 16px; flex: none; }
.works { --fg: var(--works); --bg: var(--works-bg); --c: var(--works-3d); }
.tight { --fg: var(--tight); --bg: var(--tight-bg); --c: var(--tight-3d); }
.fails { --fg: var(--fails); --bg: var(--fails-bg); --c: var(--fails-3d); }
.needs { --fg: var(--needs); --bg: var(--needs-bg); --c: var(--needs-3d); }
.conflict { --fg: var(--conflict); --bg: var(--conflict-bg); --c: var(--conflict-3d); }

/* ---- the side panel ------------------------------------------------------------------------------- */
#panel { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 22px 20px 28px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; }
#picker:empty { display: none; }
#picker select { font: 12.5px var(--sans); color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
#head { padding: 0 4px; }
.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
#head h1 { margin: 0; font-size: 22px; line-height: 1.22; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
#head .addr { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
#head .use { margin: 12px 0 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#head .use:hover { -webkit-line-clamp: unset; }

.pill { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 999px; color: var(--fg); background: var(--bg); }
.pill b { font-family: var(--mono); font-weight: 600; }
#summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
#summary:empty { display: none; }

#checks ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#checks li { border-radius: 10px; transition: background-color 0.2s var(--ease); }
#checks li:hover, #checks li.hot { background: var(--hover); }
#checks li.open { background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line-2); }
#checks .row { width: 100%; text-align: left; display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 12px 12px 12px 10px; border-radius: 10px; }
#checks .row:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
#checks .n { font: 600 12px/22px var(--mono); color: var(--faint); text-align: center; }
#checks li.open .n { color: var(--c); }
#checks .main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#checks .title { font-size: 14px; font-weight: 550; line-height: 1.35; padding-top: 1px; }
#checks .metric { font: 12px/1.4 var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; column-gap: 8px; }
#checks .metric b { color: var(--text); font-weight: 600; }
#checks .row .pill { margin-top: 2px; }
#checks .none { color: var(--muted); padding: 0 4px; }

/* the opened check: height animates through a 0fr -> 1fr grid row */
#checks .body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.42s var(--ease); }
#checks li.open .body { grid-template-rows: 1fr; }
#checks .inner { overflow: hidden; min-height: 0; padding: 0 14px 0 42px; opacity: 0; transform: translateY(-4px); transition: opacity 0.3s var(--ease), transform 0.42s var(--ease); }
#checks li.open .inner { opacity: 1; transform: none; padding-bottom: 16px; transition-delay: 0.06s; }
.explain { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: #4a4f52; }
dl.facts { margin: 0; display: flex; flex-direction: column; }
dl.facts > div { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
dl.facts dt { font-size: 12px; color: var(--faint); padding-top: 1px; }
dl.facts dd { margin: 0; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
dl.facts small { display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
dl.facts .src { font-size: 12px; color: var(--muted); }
.tour { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.tour span { display: block; font-size: 11.5px; font-weight: 600; color: var(--fg); margin-bottom: 2px; }

#facts { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 4px 0; }
#facts summary { list-style: none; cursor: pointer; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; }
#facts summary::-webkit-details-marker { display: none; }
#facts summary::after { content: "+"; color: var(--faint); font-weight: 400; }
#facts[open] summary::after { content: "−"; }
#facts dl { margin-top: 10px; }
.built { margin: 10px 0 0; font-size: 11.5px; color: var(--faint); }

@media (prefers-reduced-motion: no-preference) {
  #checks li, #checks .sec { animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---- the model ------------------------------------------------------------------------------------ */
#stage { position: relative; overflow: hidden; background: radial-gradient(120% 95% at 50% 28%, #fdfdfc 0%, #f2f1ed 62%, #e8e6e1 100%); }
#stage canvas { display: block; }
#stage.dropping canvas { cursor: crosshair; }
#stage.walking canvas { cursor: grab; }
#stage.walking canvas:active { cursor: grabbing; }
#stage.walking.looking canvas { cursor: none; }
.css2d { position: absolute; inset: 0; pointer-events: none; }

#dock { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 300000; display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 12px; }
#dock, #hint, #toast, #tip, #north { background: rgb(255 255 255 / 0.86); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); border: 1px solid var(--line); box-shadow: 0 10px 30px rgb(47 52 55 / 0.07), 0 1px 2px rgb(47 52 55 / 0.04); }
#dock .seg { display: flex; gap: 2px; }
#dock .seg + #walk, #walk + .seg { margin-left: 4px; }
#dock button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; padding: 7px 11px; border-radius: 8px; color: var(--muted); transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease); }
#dock button:hover { background: var(--hover); color: var(--text); }
#dock button:active { transform: scale(0.97); }
#dock button.on { background: #ecebe7; color: var(--text); }
/* The dock's own tooltip: the browser's title tooltip takes a second of holding still and is easy to miss over the
   3D view, and with the chat open the dock is icons only. Explicit font size: the icon-only dock sets 0. */
#dock button { position: relative; }
#dock button[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translate(-50%, 4px); padding: 5px 9px; border-radius: 7px; font: 500 12px/1.3 var(--sans); white-space: nowrap; color: var(--text); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgb(0 0 0 / 0.14); opacity: 0; pointer-events: none; transition: opacity 0.15s var(--ease), transform 0.2s var(--ease); }
#dock button[data-tip]:hover::after, #dock button[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 0.25s; }
#dock #walk { background: var(--text); color: #ffffff; padding: 7px 14px; }
#dock #walk:hover { background: #3c4245; }
#dock #walk.on { background: #111111; box-shadow: 0 0 0 3px rgb(47 52 55 / 0.15); }

#hint { position: absolute; left: 50%; top: 18px; z-index: 300000; display: flex; align-items: center; gap: 7px; padding: 8px 8px 8px 14px; border-radius: 10px; font-size: 13px; color: var(--text); opacity: 0; transform: translate(-50%, -8px); pointer-events: none; transition: opacity 0.35s var(--ease), transform 0.45s var(--ease); }
#hint.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#hint .muted { color: var(--muted); }
#hint button { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 7px; background: var(--text); color: #ffffff; font-size: 12px; }
#hint button svg { width: 13px; height: 13px; }
/* Compact: one short line; nothing wraps a word per line when the chat narrows the stage. */
#hint { gap: 6px; padding: 5px; font-size: 12.5px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 40px); }
#hint > span, #hint kbd { white-space: nowrap; }
#hint > span:first-child { margin-left: 7px; }
#hint button.quiet { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
#hint button.quiet:hover, #hint button.quiet[aria-expanded="true"] { background: var(--hover); }
#hint .keys { flex-basis: 100%; display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; gap: 5px 10px; padding: 5px 6px 3px; font-size: 12px; }
#hint .keys[hidden] { display: none; }
#hint .keys > :nth-child(odd) { justify-self: end; white-space: nowrap; }
#hint .keys > :nth-child(even) { color: var(--muted); }
#hint .keys kbd + kbd { margin-left: 3px; }

/* LiDAR mode's note: what is shown, the colour key, what LiDAR cannot see. Above the dock's row, bottom left. */
#lidar-note { position: absolute; left: 18px; bottom: 78px; z-index: 299999; display: flex; flex-direction: column; gap: 2px; max-width: 320px; padding: 9px 12px; border-radius: 10px; font-size: 12px; line-height: 1.45; color: var(--text); background: rgb(255 255 255 / 0.86); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); border: 1px solid var(--line); box-shadow: 0 10px 30px rgb(47 52 55 / 0.07), 0 1px 2px rgb(47 52 55 / 0.04); opacity: 0; visibility: hidden; transform: translateY(6px); pointer-events: none; transition: opacity 0.35s var(--ease), transform 0.45s var(--ease), visibility 0s linear 0.35s; }
#lidar-note.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
#lidar-note b { font-weight: 600; }
#lidar-note .muted { color: var(--muted); }
#lidar-note .key { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#lidar-note .key i { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.22); }
#lidar-note .key i.bar { width: 64px; height: 7px; border-radius: 4px; margin-left: 6px; }

#toast { position: absolute; left: 18px; top: 18px; z-index: 300000; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; opacity: 0; transform: translateY(-6px); transition: opacity 0.35s var(--ease), transform 0.45s var(--ease); pointer-events: none; }
#toast.on { opacity: 1; transform: none; }
#tip { position: absolute; left: 0; top: 0; z-index: 400000; display: none; pointer-events: none; font-size: 12px; padding: 5px 9px; border-radius: 7px; white-space: nowrap; color: var(--text); }
#tip.on { display: block; }
#north { position: absolute; right: 18px; top: 18px; z-index: 300000; width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; }
#north span { font-size: 10.5px; font-weight: 700; color: var(--text); margin-top: 3px; }
#north::after { content: ""; position: absolute; top: 17px; left: 14px; border: 4px solid transparent; border-bottom: 8px solid var(--fails-3d); border-top: 0; }
#empty { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
#empty.on { display: flex; }

/* check markers: a numbered dot; the inner <i> carries any scaling (CSS2D owns the button's transform) */
.marker { pointer-events: auto; position: relative; display: block; padding: 0 0 4px; transition: opacity 0.4s var(--ease); }
.marker i { font: 700 11px/1 var(--mono); font-style: normal; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #ffffff; box-shadow: 0 0 0 2px #ffffff, 0 2px 6px rgb(47 52 55 / 0.22); transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease); }
.marker:hover i, .marker.hot i { transform: scale(1.18); }
.marker.sel i { transform: scale(1.32); box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent), 0 4px 12px rgb(47 52 55 / 0.25); }
.marker.faded { opacity: 0.2; }
.marker.faded:hover { opacity: 0.9; }
.marker::before { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; margin-left: -0.75px; height: var(--lead, 0px); background: var(--c); opacity: 0.6; }

/* labels drawn in the model (dimensions only show for the selected check, or with the Dimensions toggle) */
.dim, .elev, .name { white-space: nowrap; text-align: center; line-height: 1.2; color: var(--text); text-shadow: 0 0 4px #ffffff, 0 0 2px #ffffff, 0 0 1px #ffffff; }
.dim b { display: block; font: 600 12px var(--mono); }
.dim span { display: block; font-size: 10.5px; color: var(--label-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
/* under the drawn length: the range it comes from and its margin of error */
.dim em, .note em { display: block; font: 500 10.5px var(--mono); font-style: normal; color: var(--label-2); }
.dim.sel em { color: var(--text); }
.dim.sel b { font-size: 14px; color: var(--c); }
.dim.need b { display: inline-block; font-size: 12px; color: var(--fg); background: var(--bg); padding: 3px 8px; border-radius: 999px; text-shadow: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 35%, transparent); }
.elev { font-size: 10.5px; color: var(--label-2); }
.elev b { font: 600 10.5px var(--mono); color: var(--text); }
.elev span { margin-left: 4px; }
.name { font-size: 11px; color: var(--label-2); }
.name.area { text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.name.door b { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}

/* Placement checks: slide the deciding column through its margin */
.sweep { margin: 12px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.sweep label { display: block; font-size: 12px; color: var(--muted); }
.sweep input { width: 100%; margin-top: 6px; accent-color: var(--c); }
.sweep output { display: block; font-size: 13px; margin-top: 4px; color: var(--text); }

/* ---- the architect's layout: tabs for its alternatives, named sections ---------------------------------- */
#tabs:empty { display: none; }
#tabs { padding: 0 4px; }
/* Layouts dropdown: the open layout by its full name; the list underneath, one full name per line. */
.opts { position: relative; }
.opts summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 10px; background: var(--canvas); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-size: 14px; font-weight: 550; color: var(--text); }
.opts summary::-webkit-details-marker { display: none; }
.opts summary:hover { background: var(--hover); }
.opts summary:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.opts summary .opt-name { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opts summary .count { font-size: 12px; font-weight: 400; color: var(--faint); }
.opts[open] summary .caret { transform: rotate(180deg); }
.opts .opt-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; gap: 1px; padding: 4px; border-radius: 10px; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 14px 34px rgb(0 0 0 / 0.16); max-height: 60vh; overflow-y: auto; }
.opts .opt-list button { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 1px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: var(--text); }
.opts .opt-list .opt-name { text-align: left; }
.opts .opt-list .opt-sub { grid-column: 2; font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; }
.opts .opt-list button:hover, .opts .opt-list button:focus-visible { background: var(--hover); outline: none; }
.opts .opt-list button[aria-selected="true"] { background: var(--hover); font-weight: 550; }
.opts .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--line-2)); flex: none; }
.tab-note { margin: 9px 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

#checks .sec { border-top: 1px solid var(--line); }
#checks .sec:last-child { border-bottom: 1px solid var(--line); }
.sec-row { width: 100%; display: grid; grid-template-columns: 1fr auto 16px; gap: 10px; align-items: center; margin: 4px 0; padding: 10px 6px 10px 6px; border-radius: 8px; text-align: left; transition: background-color 0.18s var(--ease); }
.sec-row:hover { background: var(--hover); }
.sec-row:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.sec-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; }
.sec-tally { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.sec-tally .pill { font-size: 10.5px; padding: 1px 7px; }
.caret { display: flex; color: var(--faint); transition: transform 0.35s var(--ease); }
.caret svg { width: 14px; height: 14px; }
.sec.open .caret { transform: rotate(180deg); }
.sec-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.42s var(--ease); }
.sec.open > .sec-body { grid-template-rows: 1fr; }
.sec-inner { overflow: hidden; min-height: 0; opacity: 0; transition: opacity 0.3s var(--ease); }
.sec.open .sec-inner { opacity: 1; padding-bottom: 12px; transition-delay: 0.06s; }
.sec-text { margin: 2px 6px 12px; font-size: 13px; line-height: 1.6; color: #4a4f52; }
.sec-table { margin: 0 6px 12px; overflow-x: auto; }
.sec-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sec-table th { text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px 0; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.sec-table td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
.sec-table tr:last-child td { border-bottom: 0; }

/* the architect's drawings: their words show only while their section is open (or with Dimensions on) */
.note { white-space: nowrap; text-align: center; line-height: 1.25; color: var(--text); text-shadow: 0 0 4px #ffffff, 0 0 2px #ffffff, 0 0 1px #ffffff; }
.note b { display: block; font-size: 12px; font-weight: 600; }
.note span { display: block; font-size: 10.5px; color: var(--label-2); }
/* Over LiDAR points a glow is not enough: each label gets a soft frosted backing. */
#stage.lidar .dim, #stage.lidar .elev, #stage.lidar .name, #stage.lidar .note { padding: 1px 5px; border-radius: 5px; background: rgb(255 255 255 / 0.48); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); box-shadow: 0 1px 3px rgb(47 52 55 / 0.12); text-shadow: none; }

/* ---- the architect chat ---------------------------------------------------------------------------------- */
#chat-fab { position: absolute; right: 20px; bottom: 20px; z-index: 300001; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--text); color: #ffffff; box-shadow: 0 10px 30px rgb(47 52 55 / 0.18), 0 1px 2px rgb(47 52 55 / 0.1); transition: background-color 0.18s var(--ease), transform 0.18s var(--ease); }
#chat-fab svg { width: 21px; height: 21px; }
#chat-fab:hover { background: #3c4245; transform: translateY(-1px); }
#chat-fab:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
#chat-fab[hidden], #chat[hidden], #chat .send[hidden], #chat .stop[hidden] { display: none; }
#chat { position: absolute; right: 16px; top: 16px; bottom: 16px; width: min(392px, calc(100% - 32px)); z-index: 300002; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: rgb(255 255 255 / 0.95); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); border: 1px solid var(--line); box-shadow: 0 18px 50px rgb(47 52 55 / 0.12), 0 2px 6px rgb(47 52 55 / 0.05); animation: drawer 0.35s var(--ease) both; }
@keyframes drawer { from { opacity: 0; transform: translateX(12px); } }
#chat header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 10px 12px 18px; border-bottom: 1px solid var(--line); }
#chat header b { display: block; font-size: 14px; font-weight: 600; }
#chat header span { font-size: 11.5px; color: var(--faint); }
#chat header code { font-size: 11px; color: var(--muted); }
#chat .close { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
#chat .close:hover { background: var(--hover); color: var(--text); }
#chat .log { flex: 1; overflow-y: auto; padding: 16px 18px 10px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; }
#chat .empty { margin: auto 0; padding: 0 10px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--muted); }
.msg.me { align-self: flex-end; max-width: 88%; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg.me .seen { font-size: 11px; color: var(--faint); text-align: right; }
.msg.me .bubble { padding: 8px 12px; border-radius: 14px 14px 4px 14px; background: #efeee9; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; }
.msg.bot .md > :last-child { margin-bottom: 0; }
.msg.bot .md p { margin: 0 0 8px; }
.msg.bot .md .h { font-weight: 600; }
.msg.bot .md ul, .msg.bot .md ol { margin: 0 0 8px; padding-left: 18px; }
.msg.bot .md li + li { margin-top: 2px; }
.msg.bot .md code { font-size: 12px; padding: 1px 4px; border-radius: 4px; background: var(--hover); }
.msg.bot .md pre { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--canvas); font: 12px/1.5 var(--mono); overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.4; color: var(--muted); }
.step::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); flex: none; }
.step.live { color: var(--text); }
.step.live::before { background: var(--text); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
.msg .err { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--canvas); font-size: 12.5px; color: var(--text); }
#chat form { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
#chat .ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11.5px; }
#chat .ctx:empty { display: none; }
#chat .ctx .with { margin-right: 2px; color: var(--faint); }
#chat .chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--canvas); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat .chip.spot { color: var(--text); border-color: var(--line-2); }
#chat .chip button { display: flex; margin-right: -3px; color: var(--faint); }
#chat .chip button:hover { color: var(--text); }
#chat .chip svg { width: 11px; height: 11px; }
#chat textarea { width: 100%; field-sizing: content; max-height: 160px; resize: none; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font: 13.5px/1.5 var(--sans); color: var(--text); outline: none; transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease); }
#chat textarea:focus { border-color: #cbc8c0; box-shadow: 0 0 0 3px rgb(47 52 55 / 0.06); }
#chat .bar { display: flex; align-items: center; gap: 6px; }
#chat .pick { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); transition: background-color 0.18s var(--ease), color 0.18s var(--ease); }
#chat .pick svg { width: 15px; height: 15px; }
#chat .pick:hover { background: var(--hover); color: var(--text); }
#chat .pick.on { background: var(--text); border-color: var(--text); color: #ffffff; }
#chat .send { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--text); color: #ffffff; transition: background-color 0.18s var(--ease), transform 0.12s var(--ease); }
#chat .send:hover { background: #3c4245; }
#chat .send:active, #chat .pick:active { transform: scale(0.97); }
#chat .stop { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--hover); font-size: 12.5px; }
#chat .stop svg { width: 13px; height: 13px; }
/* with the chat open the dock turns to icons and centres on the model that is left */
#stage.chat-open #dock, #stage.chat-open #hint { left: calc((100% - 424px) / 2); }
#stage.chat-open #hint { max-width: calc(100% - 444px); }
#stage.chat-open #dock button { font-size: 0; gap: 0; padding: 8px 9px; }
/* A small window gets the same icons-only dock (names on hover), so the dock never runs off the stage's edges: with
   labels it needs about 860px of stage, which is the window less the 384px panel. */
@media (max-width: 1250px) { #dock button { font-size: 0; gap: 0; padding: 8px 9px; } }
#stage.chat-open #north { right: 428px; }
/* last, so it overrides the rules above */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; grid-template-rows: 58dvh 1fr; }
  #panel { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  #dock { bottom: 12px; }
  #chat { left: 12px; right: 12px; top: 12px; bottom: 12px; width: auto; }
}

/* ---- dark theme (the default; the dock's Dark button switches to light) ---------------------------------- */
:root[data-theme="dark"] {
  --label-2: #d4d2cc;
  color-scheme: dark;
  --canvas: #363b3e; --surface: #3d4245; --line: #4e5458; --line-2: #596064;
  --text: #ecebe7; --muted: #b5b3ad; --faint: #8f8d88; --hover: #464c50;
  --works: #8cc79a; --works-bg: rgb(76 138 87 / 0.18); --works-3d: #5aa66a;
  --tight: #e3b55a; --tight-bg: rgb(194 138 30 / 0.18); --tight-3d: #d39a2c;
  --fails: #f08a82; --fails-bg: rgb(194 69 61 / 0.2); --fails-3d: #d65a50;
  --needs: #b8b6b0; --needs-bg: rgb(255 255 255 / 0.07); --needs-3d: #8e8d89;
  --conflict: #b6a6ec; --conflict-bg: rgb(122 103 181 / 0.22); --conflict-3d: #8f7bd0;
}
[data-theme="dark"] .explain, [data-theme="dark"] .sec-text { color: #c3c1bb; }
[data-theme="dark"] #stage { background: radial-gradient(120% 95% at 50% 28%, #52575b 0%, #464b4f 60%, #3d4245 100%); }
[data-theme="dark"] #dock, [data-theme="dark"] #hint, [data-theme="dark"] #toast, [data-theme="dark"] #tip, [data-theme="dark"] #north {
  background: rgb(66 71 75 / 0.86); border-color: #5c6367; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25), 0 1px 2px rgb(0 0 0 / 0.3);
}
[data-theme="dark"] #dock button.on { background: #585e62; }
[data-theme="dark"] #dock #walk, [data-theme="dark"] #hint button, [data-theme="dark"] #chat-fab, [data-theme="dark"] #chat .send, [data-theme="dark"] #chat .pick.on { background: #e9e7e2; color: #363b3e; }
[data-theme="dark"] #hint button.quiet { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px #5c6367; }
[data-theme="dark"] #hint button.quiet:hover, [data-theme="dark"] #hint button.quiet[aria-expanded="true"] { background: rgb(255 255 255 / 0.07); }
[data-theme="dark"] #lidar-note { background: rgb(66 71 75 / 0.86); border-color: #5c6367; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25), 0 1px 2px rgb(0 0 0 / 0.3); }
[data-theme="dark"] #lidar-note .key i { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25); }
[data-theme="dark"] #dock #walk:hover, [data-theme="dark"] #chat-fab:hover, [data-theme="dark"] #chat .send:hover { background: #ffffff; }
[data-theme="dark"] #dock #walk.on { background: #ffffff; box-shadow: 0 0 0 3px rgb(255 255 255 / 0.15); }
[data-theme="dark"] .marker i { box-shadow: 0 0 0 2px #3d4245, 0 2px 8px rgb(0 0 0 / 0.4); }
[data-theme="dark"] .marker.sel i { box-shadow: 0 0 0 2px #3d4245, 0 0 0 5px color-mix(in srgb, var(--c) 35%, transparent), 0 4px 14px rgb(0 0 0 / 0.45); }
[data-theme="dark"] .dim, [data-theme="dark"] .elev, [data-theme="dark"] .name, [data-theme="dark"] .note { text-shadow: 0 0 4px #3d4245, 0 0 2px #3d4245, 0 0 1px #3d4245; }
[data-theme="dark"] #stage.lidar .dim, [data-theme="dark"] #stage.lidar .elev, [data-theme="dark"] #stage.lidar .name, [data-theme="dark"] #stage.lidar .note { background: rgb(54 59 62 / 0.5); box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); text-shadow: none; }
#stage.lidar .dim.need, [data-theme="dark"] #stage.lidar .dim.need { padding: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; } /* has its own pill */
[data-theme="dark"] #chat { background: rgb(61 66 69 / 0.96); border-color: #5c6367; }
[data-theme="dark"] .msg.me .bubble { background: #51575b; }
[data-theme="dark"] #chat textarea:focus { border-color: #6b7175; box-shadow: 0 0 0 3px rgb(255 255 255 / 0.05); }

/* A client page with no model open: the Start screen and the client list. */
.no-model #chat-fab, .no-model #dock, .no-model #north, .no-model #facts { display: none; }
#empty .start { max-width: 440px; padding: 0 24px; color: var(--text); }
#empty .start h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
#empty .start .meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
#empty .start p { font-size: 14px; line-height: 1.55; color: var(--muted); }
#empty .start #start { margin-top: 6px; padding: 9px 18px; border-radius: 8px; background: var(--text); color: var(--canvas); font-size: 14px; font-weight: 500; }
#empty .start #start:disabled { opacity: 0.6; cursor: progress; }
#empty .start .note { min-height: 1.5em; font-size: 13px; }
#empty .start .clients { padding-left: 18px; line-height: 1.9; }
#empty .start a { color: var(--text); }
#chat .save-error { font-size: 12px; color: var(--fails); padding: 2px 0; }

/* intro: the demo intro (viewer/intro.ts, ?intro=1): the model takes the whole window while it plays */
body.intro { grid-template-columns: 1fr; }
body.intro #panel, body.intro #dock, body.intro #chat-fab, body.intro #chat, body.intro #north, body.intro #hint, body.intro #toast { display: none; }
.intro-veil { position: absolute; inset: 0; z-index: 300002; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: 13px; letter-spacing: 0.02em; color: var(--muted); background: inherit; opacity: 0; visibility: hidden; transition: opacity 0.6s var(--ease), visibility 0s linear 0.6s; }
.intro-veil.on { opacity: 1; visibility: visible; transition: opacity 0.2s var(--ease); }
.intro-veil i { width: 180px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--text) calc(var(--p, 0) * 100%), var(--line) 0); }
.intro-credits { position: absolute; left: 14px; bottom: 12px; z-index: 300001; display: flex; align-items: center; gap: 8px; max-width: 60%; font-size: 11px; color: rgb(255 255 255 / 0.92); text-shadow: 0 1px 2px rgb(0 0 0 / 0.6); opacity: 0; transition: opacity 0.4s var(--ease); pointer-events: none; }
.intro-credits.on { opacity: 1; }
.intro-credits img { height: 18px; }
.intro-credits span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.intro-wait { opacity: 0 !important; }
body.intro .css2d > div { transition: opacity 0.7s ease-in-out; } /* each measurement's words fade in after the lines (intro.ts FADE_IN) */
body.intro #lidar-note { display: none; } /* the captions say what the survey is */
.intro-caption { position: absolute; right: clamp(32px, 7vw, 120px); bottom: 72px; z-index: 300001; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: min(720px, 52%); padding: 18px 28px 20px; border-radius: 20px; text-align: left; color: #ffffff; background: rgb(24 28 31 / 0.58); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%); box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); opacity: 0; transform: translateY(8px); transition: opacity 0.38s var(--ease), transform 0.5s var(--ease); pointer-events: none; }
.intro-caption.on { opacity: 1; transform: none; }
.intro-caption b { font-size: 29px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.intro-caption span { font-size: 17px; line-height: 1.4; color: rgb(255 255 255 / 0.8); }
/* brand: Obia's mark at the model's top left, as on obia.io; over Google's 3D in the intro it turns white */
#brand { position: absolute; left: 20px; top: 18px; z-index: 300000; display: flex; align-items: center; gap: 10px; color: var(--text); pointer-events: none; }
#brand svg { height: 26px; width: auto; display: block; }
#brand span { padding-left: 10px; border-left: 1px solid var(--line-2); font-size: 13px; font-weight: 500; letter-spacing: 0.01em; color: var(--muted); }
body.intro #brand { color: #ffffff; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.45)); }
body.intro #brand span { color: rgb(255 255 255 / 0.85); border-color: rgb(255 255 255 / 0.4); }
#toast { top: 58px; } /* under the brand */
/* the recorded intro playing on a loop (the Intro video button), over everything, letterboxed so nothing in it is cut off */
.intro-video { position: absolute; inset: 0; z-index: 300010; width: 100%; height: 100%; object-fit: contain; background: #24282b; }
/* Google's marking for a recorded video of its 3D, shown only while recording (?intro=record) */
.intro-promo { position: absolute; right: 18px; top: 18px; z-index: 300001; display: none; font-size: 12px; font-weight: 500; color: rgb(255 255 255 / 0.9); text-shadow: 0 1px 2px rgb(0 0 0 / 0.6); pointer-events: none; }
.intro-promo.on { display: block; }
.intro-cal { position: absolute; left: 16px; top: 16px; z-index: 300001; display: flex; flex-direction: column; gap: 3px; padding: 10px 13px; border-radius: 10px; font-size: 12px; color: var(--text); background: rgb(255 255 255 / 0.9); border: 1px solid var(--line); }
[data-theme="dark"] .intro-cal { background: rgb(66 71 75 / 0.92); border-color: #5c6367; }
.intro-cal .muted { color: var(--muted); }
