/*
 * Tessera interface (CLAUDE.md 90).
 *
 * One stylesheet for the editor and the library, built on the tokens below.
 * Rules of the system:
 *   - roughly 95% neutral, 5% accent / semantic colour;
 *   - the accent is an indigo, never the steel blue of Revit-generated geometry
 *     (--revit-blue), so a control cannot be mistaken for model linework;
 *   - one spacing scale (4 8 12 16 24 32), one control height (32), one
 *     toolbar height (28), three radii, no gradients, almost no shadow;
 *   - Geist for the interface, Geist Mono for numbers and diagnostics.
 */

/* ---------------------------------------------------------------- fonts */

@font-face {
  font-family: "Geist";
  src: url("./vendor/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("./vendor/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------- tokens */

:root {
  /* type */
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --text-xs: 11px;   /* captions, technical readouts */
  --text-sm: 12px;   /* buttons, toolbar, helper text */
  --text-md: 13px;   /* labels, inputs, body */
  --text-lg: 15px;   /* product title */

  /* colour: neutrals */
  --ink: #181817;
  --ink-2: #44443f;          /* strong secondary: values, active labels */
  --muted: #74746e;          /* secondary text */
  --faint: #a3a39c;
  --canvas: #f5f5f2;         /* app + viewport ground */
  --panel: #fbfbf9;          /* bars and the properties panel */
  --surface: #ffffff;        /* inputs and raised segments */
  --inset: #ecece8;          /* segmented-control track, disabled fields */
  --hover: #f0f0ec;
  --line: #e3e3df;
  --line-strong: #cfcfc9;

  /* colour: accent + semantics */
  --accent: #4347c6;
  --accent-hover: #373bb0;
  --accent-soft: #ececfa;
  --accent-ink: #31349a;
  --ok: #2e7d4f;
  --ok-soft: #e8f3ec;
  --warn: #9a5b13;
  --warn-soft: #fbf0df;
  --danger: #b3362b;
  --danger-soft: #fbeae8;
  /* The one blue the model draws in (Revit-generated outline): used for that
     legend and nothing else. */
  --revit-blue: #5b7fa6;

  /* shape + space */
  --r-sm: 4px;
  --r: 6px;
  --r-lg: 8px;
  --r-pill: 999px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --control-h: 32px;
  --tool-h: 28px;
  --header-h: 48px;
  --label-w: 124px;
  --panel-w: clamp(336px, 25vw, 392px);
  --inset-view: 12px;        /* the viewport's own margin, all four sides */

  /* older names, kept so nothing outside this file breaks */
  --bg: var(--canvas);
  --radius: var(--r);
  --select: #c8531f;
}

* { box-sizing: border-box; }

/* Several panels below are display:flex, which beats the hidden attribute unless
   this is stated explicitly. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  font: 400 var(--text-md)/1.45 var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, summary { font: inherit; color: inherit; }

/* --------------------------------------------------------------- header */

header, footer {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header { height: var(--header-h); }

footer {
  min-height: 28px;
  border-bottom: none;
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--muted);
}
footer:has(#selection-info:empty) { display: none; }
footer > span:not(.spacer) { font-family: var(--font-mono); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { height: 22px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: var(--text-lg); font-weight: 600; letter-spacing: -.01em; }
.brand-text i {
  font-style: normal; font-size: 10.5px; color: var(--muted); letter-spacing: .01em;
}
.header-sep { width: 1px; height: 20px; background: var(--line); flex: none; }
.filename {
  font-size: var(--text-sm); color: var(--muted);
  max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spacer { flex: 1; }
#library-link {
  border-color: transparent; background: transparent; color: var(--muted); padding: 0 var(--s-2);
}
#library-link:hover:not(:disabled) { background: var(--hover); color: var(--ink); }

.output-readout {
  font-size: var(--text-xs); font-family: var(--font-mono); color: var(--muted);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
a.button { display: inline-flex; }
.button:hover:not(:disabled) { background: var(--hover); border-color: var(--faint); }
.button:disabled { opacity: .45; cursor: default; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

/* The toolbar's button. Outlined on its own, flat inside a segmented control. */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--tool-h);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover:not(:disabled) { background: var(--hover); border-color: var(--faint); }
.chip:disabled { opacity: .4; cursor: default; }
.chip.toggle {
  border-color: transparent; background: transparent; font-weight: 400; color: var(--ink-2);
  padding: 0 var(--s-2); gap: 6px;
}
.chip.toggle:hover { background: var(--hover); }
.chip.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.chip.primary:disabled { background: var(--inset); color: var(--muted); border-color: var(--line); opacity: 1; }
.chip.active { background: var(--surface); }   /* refined per container below */

input[type="checkbox"], input[type="radio"] {
  width: 14px; height: 14px; margin: 0; accent-color: var(--accent); flex: none;
}

/* A segmented control is a track holding one choice at a time. Use it only for
   modes and states; everything else is a plain button. */
.segmented {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--inset);
  border-radius: calc(var(--r) + 1px);
}
.segmented .chip {
  height: calc(var(--tool-h) - 4px);
  border-color: transparent; background: transparent;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: 0 10px;
}
.segmented .chip:hover:not(:disabled):not(.active) { background: rgba(0, 0, 0, .05); border-color: transparent; }
.segmented .chip.active {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 1px rgba(0, 0, 0, .04);
}

/* The active tool is the one state a person must never have to look for. */
#tool-mode-group .chip.active {
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent);
}
/* The edge-state commands carry the colours the viewport draws them in. */
#edge-hide.active { background: var(--danger); border-color: var(--danger); color: #fff; }
#edge-show.active { background: var(--ok); border-color: var(--ok); color: #fff; }
#edge-auto.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.history-group .chip { border-color: transparent; background: transparent; color: var(--ink-2); }
.history-group .chip:hover:not(:disabled) { background: var(--hover); }

.chip .ico {
  width: 14px; height: 14px; flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------- status pill */

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 420px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-pill);
  font-size: var(--text-xs); border: 1px solid transparent;
  background: transparent; color: var(--muted); white-space: nowrap;
}
.status-pill .status-text { overflow: hidden; text-overflow: ellipsis; }
.status-pill .status-icon { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.status-pill .status-dismiss {
  display: none; border: 0; background: none; color: inherit;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px;
}
.status-pill[data-state="ready"] .status-icon { background: var(--ok); }
.status-pill[data-state="busy"] { background: var(--accent-soft); color: var(--accent-ink); }
.status-pill[data-state="busy"] .status-icon {
  background: none; border: 2px solid #b7b9ee; border-top-color: var(--accent);
  animation: status-spin .8s linear infinite; width: 10px; height: 10px;
}
.status-pill[data-state="done"] { background: var(--ok-soft); color: var(--ok); }
.status-pill[data-state="done"] .status-icon { background: var(--ok); }
.status-pill[data-state="error"] { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.status-pill[data-state="error"] .status-icon { background: var(--danger); }
.status-pill[data-state="error"] .status-dismiss { display: inline; }
@keyframes status-spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- layout */

/* The workspace is flush: panes meet at a hairline instead of floating as cards,
   so the model gets every pixel the chrome does not need. */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: minmax(240px, 42%) minmax(0, 1fr);
  grid-template-areas: "viewer controls" "plan plan";
  min-height: 0;
}

.viewer { grid-area: viewer; }
.controls { grid-area: controls; }
.plan { grid-area: plan; }

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
  overflow: hidden;
  position: relative;
}
.pane.viewer { background: var(--canvas); border-right: 1px solid var(--line); }
.pane.plan, .pane.redraw { border-right: 1px solid var(--line); background: var(--surface); }

/* Toolbar rows: one visual block above the model, hairlines between. */
.pane-title, .view-bar, .edge-bar, .edit-bar, .clean-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-3);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  row-gap: var(--s-1);
}
.pane-title {
  font-size: var(--text-sm); font-weight: 600; color: var(--ink);
  justify-content: space-between;
}
.pane-tools { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; flex-wrap: wrap; row-gap: var(--s-1); justify-content: flex-end; }
.view-bar, .edge-bar { min-height: 36px; }
/* Camera orientation is the quietest row: the state is shown, the track is not. */
.view-bar .segmented { background: transparent; padding: 0; gap: 0; }
.view-bar .segmented .chip { color: var(--muted); border-radius: var(--r); padding: 0 var(--s-3); }
.view-bar .segmented .chip:hover:not(:disabled):not(.active) { background: var(--hover); color: var(--ink); }
.view-bar .segmented .chip.active { background: var(--hover); color: var(--ink); box-shadow: none; }
.clean-bar .spacer { flex: 1; }
.edge-bar .spacer { flex: 0 0 0; }

.label-hint {
  font-size: var(--text-xs); color: var(--muted); letter-spacing: 0;
}

#viewer3d { flex: 1; min-height: 0; position: relative; }
#viewer3d canvas { display: block; }

/* The diagnostics live in one fixed-height bar, so a longer line or a new
   status can never resize the canvas under the pointer. */
.status-bar {
  display: flex; align-items: center; gap: var(--s-4);
  height: 28px; padding: 0 var(--inset-view);
  background: var(--panel); border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.status-bar .readout { display: flex; gap: var(--s-3); align-items: baseline; margin: 0; min-width: 0; }
.status-bar .readout div { display: block; padding: 0; }
.status-bar .readout b { color: var(--ink-2); font-weight: 500; }
.status-bar .readout .wide { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-style: normal; }
.status-bar .readout .warn { color: var(--danger); }
.status-bar #viewport-readout { flex: 0 1 auto; }
.status-bar .spacer { flex: 1 1 0; }
.contour-key { color: #5b7fa6; font-weight: 600; }

/* Viewport overlays share one inset and one type style. */
.axis-hint {
  position: absolute; left: var(--inset-view); bottom: var(--inset-view);
  font: 400 var(--text-xs)/16px var(--font-mono);
  color: var(--muted);
  pointer-events: none;
}
.scale-bar {
  position: absolute; right: var(--inset-view); bottom: var(--inset-view); pointer-events: none;
  font: 400 var(--text-xs)/16px var(--font-mono); color: var(--muted); max-width: 60%;
  display: flex; flex-direction: column; align-items: flex-end; text-align: right;
}
.scale-bar[hidden] { display: none; }
.scale-bar-rule {
  position: relative; height: 6px; margin-top: 16px; margin-bottom: 4px;
  border: 1px solid var(--ink-2); border-top: none;
}
.scale-bar-label {
  position: absolute; right: 0; bottom: 6px; white-space: nowrap;
  font-weight: 500; color: var(--ink-2);
}
.scale-bar.tiny .scale-bar-model { color: var(--warn); font-weight: 600; }
.scale-bar-caption, .scale-bar-model { color: var(--muted); text-shadow: 0 0 3px var(--canvas), 0 0 3px var(--canvas); }

/* The viewport's own transient marks. */
.brush-cursor {
  position: absolute; pointer-events: none; border-radius: 50%;
  border: 1.5px solid #a8442c; background: rgba(168, 68, 44, .08);
}
.brush-cursor.restore { border-color: #2f7a4d; background: rgba(47, 122, 77, .08); }
.select-box { position: absolute; border: 1px solid var(--accent); background: rgba(67, 71, 198, .10); pointer-events: none; }
.select-lasso { position: absolute; pointer-events: none; overflow: visible; }
.select-lasso .lasso-fill { fill: rgba(67, 71, 198, .10); stroke: none; }
.select-lasso .lasso-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; }

/* ------------------------------------------------------------ toolbar rows */

.mode-anchor { flex: none; }
.view-bar .advanced-disclosure { margin-right: auto; }


/* One line that takes the free space and truncates: selecting an edge, or the
   Tab count appearing, must not wrap the bar's buttons onto a second row and
   move the model under the pointer (measured, CLAUDE.md 73.8). The whole text
   is in the tooltip. */
.tool-context { display: grid; flex: 1 1 0; min-width: 0; align-items: center; }
.tool-context > * { grid-area: 1 / 1; min-width: 0; }
.edge-selection {
  font-size: var(--text-xs); color: var(--muted);
  flex: 1 1 0; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tool-name { display: none; }  /* the active button says it; kept for assistive text */
.brush-size { display: inline-flex; align-items: center; gap: var(--s-2); }
.brush-size input[type="range"] { width: 88px; }
.brush-size .readout { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); min-width: 32px; margin: 0; }
.history-group {
  display: inline-flex; align-items: center; gap: 2px;
  padding-left: var(--s-2); margin-left: var(--s-1); border-left: 1px solid var(--line);
}
.history-group .label-hint { margin-right: var(--s-1); }

/* A tool's own context strip: summary on the left, its commit on the right. */
.clean-bar { min-height: 36px; font-size: var(--text-sm); background: var(--accent-soft); color: var(--accent-ink); }
#brush-bar, #restore-bar { background: var(--inset); color: var(--ink-2); }
#brush-summary, #restore-summary, #box-summary, #clean-summary { color: inherit; }

/* Display-only options and the experimental/diagnostic tools, tucked in "More". */
.advanced-disclosure { position: relative; flex: none; display: inline-flex; align-items: center; }
.advanced-disclosure summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; height: var(--tool-h);
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-2);
  padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
}
.advanced-disclosure summary::-webkit-details-marker { display: none; }
.advanced-disclosure summary:hover { background: var(--hover); }
.advanced-disclosure[open] summary { background: var(--hover); border-color: var(--faint); }
.advanced-disclosure .advanced-body {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: var(--s-1); box-shadow: 0 8px 24px rgba(24, 24, 23, .10); width: max-content; min-width: 220px;
}
.advanced-disclosure .advanced-body .chip {
  justify-content: flex-start; text-align: left; border-color: transparent; background: transparent;
}
.advanced-disclosure .advanced-body .chip:hover:not(:disabled) { background: var(--hover); }
.advanced-disclosure .advanced-body .chip.active { background: var(--accent-soft); color: var(--accent-ink); }

/* In the menu a mode that does not use an option simply omits it: a popup has no
   toolbar to reflow. */
.advanced-body .reserved-off { display: none; }
.advanced-body .chip.toggle {
  justify-content: flex-start; padding: 0 var(--s-2); height: var(--tool-h);
  font-size: var(--text-sm); color: var(--ink-2);
}
.advanced-body .chip.toggle:first-of-type { margin-top: 0; }

/* A control that belongs to other modes: invisible and inert, but still
   holding its place, so switching modes cannot reflow anything. */
.reserved-off { visibility: hidden; pointer-events: none; }

/* Beta is one switch (CLAUDE.md 86.6): every [data-beta] control hides with it. */
body:not(.beta-on) [data-beta] { display: none !important; }
.beta {
  display: inline-block; vertical-align: 1px; margin-left: var(--s-1);
  padding: 1px 6px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 600; letter-spacing: .02em; text-transform: none;
  background: var(--warn-soft); color: var(--warn);
}

/* ------------------------------------------------------- properties panel */

.pane.controls { border-left: 1px solid var(--line); }
.controls-body { overflow-y: auto; flex: 1; padding-bottom: var(--s-5); }

.section { border-bottom: 1px solid var(--line); }
.section > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: var(--s-2);
  height: 44px; padding: 0 var(--s-4);
  font-size: var(--text-md); font-weight: 600; color: var(--ink);
  user-select: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after {
  content: ""; margin-left: auto; width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .12s ease;
}
.section[open] > summary::after { transform: rotate(45deg); }
.section > summary:hover { background: var(--hover); }
.unit-note { font-weight: 400; font-size: var(--text-xs); color: var(--muted); }

.section-body {
  display: grid; row-gap: var(--s-2);
  border: 0; margin: 0; min-width: 0;
  padding: 0 var(--s-4) var(--s-4);
}

/* The grid every row sits on: one label column, one control column. Inputs all
   start at the same x and every full-width control ends at the same x. */
.dim-row {
  display: grid;
  grid-template-columns: var(--label-w) minmax(0, 1fr);
  column-gap: var(--s-2);
  align-items: center;
  min-height: var(--control-h);
}
.dim-row > label, .dim-row > .row-label { color: var(--muted); font-size: var(--text-md); line-height: 1.25; }
.dim-row.control-only > :first-child { grid-column: 2; }
.dim-row .chip.primary { height: var(--control-h); }
.required { color: var(--danger); }

input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%;
  height: var(--control-h);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-size: var(--text-md);
  text-overflow: ellipsis;
}
input[type="number"] { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled) { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { background: var(--inset); color: var(--muted); }
input::placeholder { color: var(--faint); }
input.derived { color: var(--muted); font-style: italic; }
input.invalid { border-color: var(--danger); background: var(--danger-soft); }
.wide-input { margin: var(--s-1) 0 var(--s-2); }

.inline-pair { display: flex; gap: var(--s-2); align-items: center; min-width: 0; }
.inline-pair input { flex: 1; min-width: 0; }
.inline-pair .chip { height: var(--control-h); flex: none; }

.check {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: var(--control-h); font-size: var(--text-md); color: var(--ink); cursor: pointer;
}
.dim-row .check { min-height: var(--control-h); }

/* The compiled Family Name is a result, not a field: type, not a box. */
.result-row { align-items: start; padding: var(--s-1) 0; }
.result-row .row-label { padding-top: 1px; }
.compiled-name output {
  font: 500 12.5px/1.4 var(--font-mono); color: var(--ink); overflow-wrap: anywhere;
}

/* Edge Angle: label, slider, numeric field with its degree mark inside it. */
.slider-field { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: var(--s-3); align-items: center; }
.unit-field { position: relative; display: block; }
.unit-field input { padding-right: 22px; text-align: right; }
.unit-field .unit {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: var(--text-sm); pointer-events: none;
}

input[type="range"] { -webkit-appearance: none; appearance: none; height: 20px; background: transparent; margin: 0; width: 100%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--accent); cursor: pointer;
}
input[type="range"]:focus-visible { outline-offset: 4px; border-radius: 2px; }

/* Captions are for what prevents a mistake or reports a live number. */
.caption, .hint {
  margin: 0; font-size: var(--text-xs); color: var(--muted);
  font-family: var(--font-mono); line-height: 1.5;
}
.dim-row + .caption { padding-left: calc(var(--label-w) + var(--s-2)); }
.caption.warn, #plan-lock-hint.warn { color: var(--warn); font-weight: 600; font-family: var(--font-sans); }

.readout { font-size: var(--text-xs); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.section-body .readout { display: grid; row-gap: var(--s-1); }
.section-body .readout div { display: flex; justify-content: space-between; gap: var(--s-3); padding: 0; }
.readout span { color: var(--muted); }
.readout b { font-weight: 500; color: var(--ink-2); }
.readout .muted { color: var(--muted); }
#comparison-readout div { display: grid; grid-template-columns: 1fr auto auto; gap: var(--s-2); align-items: baseline; }
#comparison-readout i { font-style: normal; color: var(--warn); min-width: 48px; text-align: right; }

.warning {
  margin: var(--s-3) var(--s-4) 0; padding: var(--s-2) var(--s-3);
  font-size: var(--text-sm); color: var(--warn); background: var(--warn-soft);
  border: 1px solid #efd7ae; border-radius: var(--r);
}

/* -------------------------------------------------------- category combobox */

.combo { position: relative; }
.combo input { padding-right: 28px; cursor: pointer; }
.combo::after {
  content: ""; position: absolute; right: 12px; top: 12px; width: 5px; height: 5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: var(--s-1); list-style: none;
  max-height: 264px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: 0 8px 24px rgba(24, 24, 23, .10);
}
.combo-list li {
  padding: 6px var(--s-2); border-radius: var(--r-sm); font-size: var(--text-md); cursor: pointer;
}
.combo-list li.active { background: var(--hover); }
.combo-list li[aria-selected="true"] { color: var(--accent-ink); font-weight: 600; }
.combo-list li.empty { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------------- plan */

#plan-wrap { flex: 1; min-height: 0; background: var(--surface); position: relative; }
#plan-svg { width: 100%; height: 100%; display: block; }
.tool-hint { margin-left: var(--s-1); font-size: var(--text-xs); color: var(--muted); }
.pane.plan .pane-title { align-items: center; flex-wrap: wrap; }
#plan-pane-title { white-space: nowrap; }
.pane.plan .readout.inline, .pane.redraw .readout.inline {
  display: flex; gap: var(--s-4); padding: 6px var(--s-3); margin: 0;
  border-top: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.pane.plan .readout.inline div { display: block; padding: 0; }

#plan-svg .stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; }
#plan-svg .footprint { stroke: #1a1a1a; }
#plan-svg .primary { stroke: #1a1a1a; }
#plan-svg .secondary { stroke: #6b6b6b; }
#plan-svg .auto-ghost { stroke: #b9c9d6; }
#plan-svg .pickable { cursor: pointer; }
#plan-svg .hit { stroke: transparent; }
#plan-svg .selected { stroke: var(--select) !important; }
#plan-svg .flagged { stroke: #c8531f !important; stroke-dasharray: 4 3; }
#plan-svg .handle { fill: #fff; stroke: var(--select); cursor: pointer; }
#plan-svg .handle.armed { fill: var(--select); }
#plan-svg .scale-grid { fill: none; vector-effect: non-scaling-stroke; pointer-events: none; }
#plan-svg .scale-grid.minor { stroke: #eeede8; stroke-width: 1; }
#plan-svg .scale-grid.major { stroke: #d9d7cf; stroke-width: 1; }

/* The drafting pane's header wraps like the viewer's: at 1440 x 900 with Beta on
   the pane is ~550 px, and its tools used to be clipped off the right edge
   (CLAUDE.md 88.3) -- see the .pane.plan .pane-title rule above. */

.redraw { grid-area: redraw; display: flex; flex-direction: column; min-height: 0; }
body.redraw-open main {
  grid-template-rows: minmax(240px, 52%) minmax(0, 1fr);
  grid-template-areas: "viewer controls" "redraw redraw";
}
body.redraw-open section.pane.plan { display: none; }
#redraw-wrap { flex: 1; min-height: 0; background: var(--surface); }
#redraw-svg { width: 100%; height: 100%; display: block; }
#redraw-svg .locked { stroke: #b9b4a8; }
#redraw-svg .redrawn { stroke: #1b1b18; }
#redraw-svg .outline { fill: #efece4; }
#plan-lock.active { background: var(--ink); color: #fff; }
/* Plan Redraw belongs to the Current engine: while Symbolisation V2 draws the
   plan it is neither shown nor exported, so its section steps aside. */
body.engine-v2 details[data-section="redraw"] { display: none; }
/* Low / Medium / High is the Current engine's detail; V2 has one drawing. */
body.engine-v2 #detail-group { display: none; }

/* With symbolisation off the plan pane is gone, so the viewer takes its room.
   grid-template-rows has to be reset as well as the areas: the two-row default
   keeps the first row at 42% of the page whether or not there is a second row. */
body.no-symbolisation main {
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "viewer controls";
}
/* The drafting pane opens for anyone using Beta after a Redraw, so it must leave
   the model room: wide screens put it beside the model, narrow ones under it. */
main { grid-template-rows: minmax(300px, 62%) minmax(0, 1fr); }
@media (min-width: 1200px) {
  body:not(.no-symbolisation):not(.redraw-open) main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--panel-w);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "viewer plan controls";
  }
}

/* -------------------------------------------------------------------- modal */

.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(24, 24, 23, .32);
}
.modal-box {
  width: min(480px, 90vw); max-height: 80vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5) var(--s-5); box-shadow: 0 16px 48px rgba(24, 24, 23, .18);
}
.modal-box h3 { margin: 0 0 var(--s-2); font-size: var(--text-lg); font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }
.modal-list { display: flex; flex-direction: column; gap: var(--s-1); }
.modal-list label { display: flex; align-items: center; gap: var(--s-2); padding: 3px 0; }
.modal-list .meta { color: var(--muted); font-size: var(--text-sm); }

/* -------------------------------------------------------------- the library */

body.library-page main.library { display: block; overflow: auto; padding: var(--s-6) var(--s-4) var(--s-6); }
.library-section { max-width: 960px; margin: 0 auto var(--s-5); }
.library-section h2 {
  font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--s-2); color: var(--muted);
}
.library-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.library-table th, .library-table td {
  text-align: left; padding: 10px var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle;
}
.library-table th { font-weight: 500; font-size: var(--text-xs); color: var(--muted); background: var(--panel); }
.library-table tr:last-child td { border-bottom: none; }
.library-table tbody tr:hover td { background: var(--panel); }
.library-table td.muted { color: var(--muted); font-size: var(--text-sm); }
.library-table td a { color: inherit; text-decoration: none; }
.library-table td a b { font-weight: 600; }
.library-table td a:hover b { text-decoration: underline; }
.lib-failed { color: var(--danger); font-weight: 500; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--s-6) var(--s-4); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
}
.viewport-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; z-index: 1;
}
.viewport-empty h3 { margin: 0 0 var(--s-1); font-size: var(--text-lg); font-weight: 600; }
.viewport-empty p { margin: 0 0 var(--s-4); color: var(--muted); }
.empty-mark { height: 40px; width: auto; margin-bottom: var(--s-4); opacity: .9; }
.empty-state h3 { margin: 0 0 var(--s-1); font-size: var(--text-lg); font-weight: 600; }
.empty-state p { margin: 0 0 var(--s-4); color: var(--muted); max-width: 44ch; }
@media (max-width: 640px) {
  .library-table th:nth-child(2), .library-table td:nth-child(2),
  .library-table th:nth-child(4), .library-table td:nth-child(4) { display: none; }
}

/* ------------------------------------------------- narrower laptop widths */

/* Below ~1500 px only the active tool keeps its name; the rest are icons with
   tooltips, which keeps the tool row on one line beside the history buttons. */
@media (max-width: 1500px) {
  #tool-mode-group .chip:not(.active) .lbl { display: none; }
  #tool-mode-group .chip:not(.active) .ico { margin: 0; }
}
@media (max-width: 1360px) {
  .filename { max-width: 22ch; }
  .output-readout { display: none; }
}

/* ---- sign-in and the owner's library (CLAUDE.md 95) ---- */
.login-card { max-width: 420px; margin-top: var(--s-6); }
.login-card .muted, .muted { color: var(--muted); }
.login-field { display: grid; gap: var(--s-1); margin: var(--s-3) 0; font-size: var(--text-sm); color: var(--ink-2); }
.login-field input { height: var(--control-h); }
.library-user { color: var(--muted); font-size: var(--text-sm); }
.lib-state { font-size: var(--text-xs); }
.lib-state[data-state="ready"] { color: var(--ok); }
.lib-state[data-state="processing"] { color: var(--accent); }
.lib-state[data-state="failed"] { color: var(--danger); }
.lib-sub { display: block; color: var(--muted); font-size: var(--text-xs); font-weight: 400; }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { color: var(--danger); background: var(--hover); }
.empty-formats { font-family: var(--mono, "Geist Mono", monospace); font-size: var(--text-xs); color: var(--faint); margin: 0 0 var(--s-4); }
@media (max-width: 900px) {
  .library-table th:nth-child(3), .library-table td:nth-child(3),
  .library-table th:nth-child(6), .library-table td:nth-child(6) { display: none; }
}
