/* Festplot canvas chrome. Monochrome, square-cornered, colour reserved
   for map features. Pages outside the canvas use Tailwind + templUI
   (styles.css / theme.css); this file owns the dark workspace. */

:root {
  --chrome: #141414;        /* panel surface */
  --chrome-raised: #1d1d1d; /* hover / raised surface */
  --chrome-input: #232323;  /* input wells */
  --hairline: #2C2720;      /* borders inside panels */
  --edge: #17140F;             /* borders between regions */
  --ink-hi: #ececec;        /* primary text */
  --ink-mid: #a3a3a3;       /* secondary text */
  --ink-low: #6f6f6f;       /* tertiary text */
  --danger: #e07070;
  --link: #9ab8d8;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  --chrome-ink: var(--ink-hi); /* legacy alias */
}

body.full-bleed main { position: relative; overflow: hidden; }

/* Workspace inherits the page font (Inter via styles.css). */
.side-panel, .toolbar, .item-dialog, .shortcuts-card, .comment-popup .maplibregl-popup-content {
  font-family: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

::selection { background: #D8D2C4; color: #211E19; }

/* Panel scrollbars: thin, quiet. */
.side-panel *::-webkit-scrollbar { width: 8px; }
.side-panel *::-webkit-scrollbar-thumb { background: #322D24; }
.side-panel *::-webkit-scrollbar-thumb:hover { background: #3E382E; }
.side-panel *::-webkit-scrollbar-track { background: transparent; }

/* ---- Workspace grid: catalogue | canvas | inspector+BoQ -------------- */
.workspace {
  display: grid;
  grid-template-columns: 15.5rem 1fr 19.5rem;
  position: absolute;
  inset: 0;
}

.side-panel {
  background: var(--chrome);
  color: var(--ink-hi);
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-size: 0.85rem;
  z-index: 5;
}
.side-panel { border-right: 1px solid var(--edge); }
.side-panel-right { border-right: none; border-left: 1px solid var(--edge); }
.side-panel-right .boq { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.side-panel-right .boq[hidden] { display: none; }

.side-panel-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline);
  min-height: 2.9rem;
}
.side-panel-head strong { font-weight: 600; letter-spacing: -0.01em; }
.side-panel-head a { color: var(--ink-mid); text-decoration: none; transition: color 0.12s; }
.side-panel-head a:hover { color: var(--ink-hi); }
/* The event/plan title doubles as the details button (rename, archive). */
.head-title {
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; text-align: left;
  min-width: 0; flex: 1; cursor: pointer;
}
.head-title strong { transition: color 0.12s; }
.head-title:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.archived-pill {
  padding: 2px 7px;
  border: 1px solid #8A5A3A;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #E0A070;
  white-space: nowrap;
}
.side-panel-body { overflow-y: auto; flex: 1; padding: 0.4rem 0 0.8rem; min-height: 0; }

/* Section headers (catalogue groups, BoQ categories) share one voice. */
.cat-group summary,
.cat-toolbar,
.boq-cat {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-low);
  user-select: none;
}

/* ---- Catalogue -------------------------------------------------------- */
.cat-group summary {
  cursor: pointer;
  padding: 0.5rem 1rem 0.3rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.12s;
}
.cat-group summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform 0.12s;
}
.cat-group[open] summary::before { transform: rotate(90deg); }
.cat-group summary::-webkit-details-marker { display: none; }
.cat-group[open] summary, .cat-group summary:hover { color: var(--ink-mid); }

.cat-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.34rem 1rem;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--ink-hi);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.cat-item:hover { background: var(--chrome-raised); }
.cat-item[aria-pressed=true] {
  background: var(--chrome-raised);
  border-left-color: var(--ink-hi);
}
.cat-swatch { width: 0.6rem; height: 0.6rem; flex: none; }
.cat-kind { margin-left: auto; color: var(--ink-low); font-size: 0.75rem; }

.cat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem 0.3rem;
  border-top: 1px solid var(--hairline);
  margin-top: 0.5rem;
}
.cat-toolbar button {
  background: none;
  border: 1px solid #37322A;
  color: var(--ink-mid);
  font-size: 0.7rem;
  padding: 0.18rem 0.55rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  transition: color 0.12s, border-color 0.12s;
}
.cat-toolbar button:hover { border-color: var(--ink-hi); color: var(--ink-hi); }
.org-dot { color: #9DBFA9; font-size: 0.55rem; vertical-align: 0.1rem; }
.cat-actions { margin-left: auto; display: none; gap: 0.15rem; }
.cat-item:hover .cat-actions { display: inline-flex; }
.cat-actions button {
  background: none; border: none; color: var(--ink-low);
  font-size: 0.75rem; cursor: pointer; padding: 0 0.2rem;
  transition: color 0.12s;
}
.cat-actions button:hover { color: #fff; }

/* ---- Panel sub-sections (overlays, snapshots) -------------------------- */
.panel-sub { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.2rem 1rem 0.5rem; }
.panel-btn {
  background: none; border: 1px solid #37322A; color: var(--ink-mid);
  font-size: 0.72rem; padding: 0.25rem 0.55rem; cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.panel-btn:hover { border-color: var(--ink-hi); color: var(--ink-hi); }
.panel-empty { font-size: 0.72rem; color: var(--ink-low); line-height: 1.4; }

.snapshot-add { display: flex; gap: 0.35rem; }
.snapshot-add input {
  flex: 1; min-width: 0; background: var(--chrome-input); border: 1px solid #37322A;
  color: var(--ink-hi); font-size: 0.75rem; padding: 0.25rem 0.4rem;
}
.snapshot-row {
  display: flex; align-items: baseline; gap: 0.4rem;
  font-size: 0.78rem; color: var(--ink-mid);
}
.snapshot-row .snap-meta { margin-left: auto; font-size: 0.68rem; color: var(--ink-low); }
.snapshot-row button { background: none; border: none; color: var(--ink-low); cursor: pointer; font-size: 0.78rem; }
.snapshot-row button:hover { color: var(--ink-hi); }
.snapshot-row button[data-act=del]:hover { color: var(--danger); }

.overlay-row { display: flex; flex-direction: column; gap: 0.25rem; }
.overlay-head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; cursor: pointer; }
.overlay-head input { accent-color: var(--ink-hi); }
.overlay-head button { margin-left: auto; background: none; border: none; color: var(--ink-low); cursor: pointer; }
.overlay-head button:hover { color: var(--danger); }
.overlay-controls { display: flex; align-items: center; gap: 0.5rem; padding-left: 1.3rem; }
.overlay-controls input[type=range] { flex: 1; accent-color: var(--ink-hi); }

/* ---- Comment pins + thread popup --------------------------------------- */
.comment-pin {
  background: #211E19;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.comment-pin.resolved { background: #857E6E; opacity: 0.75; }

.comment-popup .maplibregl-popup-content {
  background: var(--chrome);
  color: var(--ink-hi);
  border: 1px solid #17140F;
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 0.7rem 0.8rem;
  font-family: inherit;
}
.comment-popup .maplibregl-popup-tip { border-top-color: var(--chrome); border-bottom-color: var(--chrome); }
.comment-popup .maplibregl-popup-close-button { color: var(--ink-mid); font-size: 1rem; right: 4px; }
.thread { display: flex; flex-direction: column; gap: 0.55rem; min-width: 15rem; }
.thread-msg { display: flex; flex-direction: column; gap: 0.15rem; }
.thread-meta { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.68rem; color: var(--ink-low); }
.thread-meta strong { color: var(--ink-mid); font-size: 0.72rem; }
.thread-del { margin-left: auto; background: none; border: none; color: var(--ink-low); cursor: pointer; font-size: 0.65rem; }
.thread-del:hover { color: var(--danger); }
.thread-body { font-size: 0.8rem; line-height: 1.35; white-space: pre-wrap; }
.thread-reply { display: flex; gap: 0.35rem; }
.thread-reply input {
  flex: 1; min-width: 0; background: var(--chrome-input); border: 1px solid #37322A;
  color: var(--ink-hi); font-size: 0.78rem; padding: 0.3rem 0.45rem; font-family: inherit;
}
.thread-reply button {
  background: var(--ink-hi); color: #211E19; border: none;
  font-size: 0.72rem; padding: 0.3rem 0.6rem; cursor: pointer;
}
.thread-resolve {
  background: none; border: 1px solid #37322A; color: var(--ink-mid);
  font-size: 0.72rem; padding: 0.3rem 0; cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.thread-resolve:hover { border-color: #5F8F72; color: #9DBFA9; }

#comments-toggle[aria-pressed=true] { background: var(--chrome-raised); color: var(--ink-hi); }

/* ---- Layers ----------------------------------------------------------- */
.layers-list { display: flex; flex-direction: column; }
.layer-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 1rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s;
}
.layer-row:hover { background: var(--chrome-raised); }
.layer-row input { accent-color: var(--ink-hi); }

/* ---- Canvas + floating chrome ----------------------------------------- */
.canvas-wrap { position: relative; min-width: 0; }
.plan-map { position: absolute; inset: 0; }

.toolbar {
  position: absolute;
  z-index: 10;
  top: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--chrome);
  color: var(--ink-hi);
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
  border: 1px solid #17140F;
}
.toolbar button {
  background: none;
  border: none;
  color: var(--ink-mid);
  padding: 0.34rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.toolbar button:hover { background: var(--chrome-raised); color: var(--ink-hi); }
.toolbar button[aria-pressed=true] { background: var(--ink-hi); color: #211E19; }
.toolbar-select {
  background: var(--chrome-input);
  color: var(--ink-hi);
  border: 1px solid #37322A;
  font-size: 0.78rem;
  padding: 0.26rem 0.3rem;
}
.toolbar-sep { width: 1px; height: 1.2rem; background: var(--hairline); margin: 0 0.35rem; }
.basemap-inline { display: flex; gap: 0.1rem; }
.basemap-inline button { padding: 0.34rem 0.55rem; font-size: 0.75rem; }

.toolbar button { display: inline-flex; align-items: center; gap: 0.35rem; }
.ticon { width: 0.95rem; height: 0.95rem; flex: none; }

/* Icon-only toolbar: square tap targets, tooltips on hover. */
.toolbar-icons { gap: 0.12rem; padding: 0.25rem 0.3rem; }
.toolbar-icons .tbtn {
  padding: 0; width: 1.85rem; height: 1.85rem;
  justify-content: center; border-radius: 3px;
}
.tbtn { position: relative; }
.tbtn[data-hint]:hover::after {
  content: attr(data-hint);
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; background: var(--ink-hi); color: #211E19;
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.01em;
  padding: 0.2rem 0.45rem; border-radius: 3px; pointer-events: none; z-index: 40;
}
.tbtn[data-hint]:hover::before {
  content: ""; position: absolute; top: calc(100% + 2px); left: 50%;
  transform: translateX(-50%); border: 4px solid transparent;
  border-bottom-color: var(--ink-hi); pointer-events: none; z-index: 40;
}
#undo-btn, #redo-btn { padding: 0.34rem 0.5rem; }
#undo-btn:disabled, #redo-btn:disabled { opacity: 0.3; cursor: default; }
#undo-btn:disabled:hover, #redo-btn:disabled:hover { background: none; color: var(--ink-mid); }

.save-state {
  font-size: 0.7rem;
  color: var(--ink-low);
  min-width: 3.6rem;
  text-align: center;
  transition: color 0.2s;
}
.save-state.saved { color: #9DBFA9; }

.basemap-blend { width: 4.5rem; accent-color: var(--ink-hi); }

/* Catalogue search */
.cat-search { padding: 0.35rem 1rem 0.15rem; }
.cat-search input {
  width: 100%;
  background: var(--chrome-input);
  border: 1px solid #37322A;
  color: var(--ink-hi);
  font-size: 0.78rem;
  padding: 0.32rem 0.5rem;
  transition: border-color 0.12s;
}
.cat-search input:focus { outline: none; border-color: var(--ink-hi); }
.cat-search input::placeholder { color: var(--ink-low); }

/* Swatch shapes: what does clicking this item do? */
.cat-swatch.swatch-line { height: 0.2rem; width: 0.75rem; }
.cat-swatch.swatch-poly { background: transparent !important; border: 1.5px solid; width: 0.6rem; height: 0.6rem; }

/* First-run guidance card */
.first-run {
  position: absolute;
  z-index: 15;
  /* Guidance must never intercept the first placement click; only its
     own controls are interactive. Sits above the toolbar, not centre. */
  pointer-events: none;
  top: 4.2rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(24rem, 85%);
  background: var(--chrome);
  color: var(--ink-hi);
  border: 1px solid #17140F;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.first-run strong { font-size: 1rem; letter-spacing: -0.01em; }
.first-run ol { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.first-run li { font-size: 0.82rem; color: var(--ink-mid); line-height: 1.45; }
.first-run li b { color: var(--ink-hi); font-weight: 600; }
.first-run li i { font-style: normal; border-bottom: 1px dotted var(--ink-low); }
.first-run-hint { font-size: 0.72rem; color: var(--ink-low); }
.first-run-hint kbd {
  background: var(--chrome-input); border: 1px solid #37322A; border-bottom-width: 2px;
  padding: 0 0.3rem; font-family: inherit; font-size: 0.68rem; color: var(--ink-hi);
}
#first-run-dismiss {
  background: var(--ink-hi); color: #211E19; border: none;
  padding: 0.45rem 0; font-size: 0.8rem; font-weight: 500; cursor: pointer;
}
#first-run-dismiss:hover { background: #fff; }
/* Only the card's own control is clickable; its text must let map
   clicks through (a list item otherwise steals the placement click). */
#first-run-dismiss { pointer-events: auto; }

/* Contractor view chips, floating under the toolbar. */
.contractor-chips {
  position: absolute;
  z-index: 10;
  top: 3.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 70%;
}
.chip {
  background: var(--chrome);
  color: var(--ink-mid);
  border: 1px solid #17140F;
  font-size: 0.72rem;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: color 0.12s, background 0.12s;
}
.chip:hover { color: var(--ink-hi); }
.chip[aria-pressed=true] { background: var(--ink-hi); color: #211E19; }
.chip-clear { color: var(--link); }

/* Read-only lock banner */
.lock-banner {
  position: absolute;
  z-index: 20;
  top: 3.6rem;
  left: 50%;
  transform: translateX(-50%);
  background: #6e2626;
  color: #fff;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  display: flex;
  gap: 0.7rem;
  align-items: center;
  box-shadow: var(--shadow);
}
.lock-banner button {
  background: #fff;
  color: #6e2626;
  border: none;
  font-size: 0.75rem;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
}

/* Floating chips (draw measurements, status toasts) */
.draw-chip, .status-chip {
  position: absolute;
  z-index: 20;
  background: rgba(10, 10, 10, 0.92);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.28rem 0.6rem;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.status-chip { bottom: 2.6rem; left: 50%; transform: translateX(-50%); }

/* Feature labels: HTML markers placed by labels.js (offline-safe, no
   glyph server). Drawing-office voice: small text, a paper halo instead
   of a box, tags and dimensions in mono, area names inside their zone. */
.lbl {
  --halo: #FBF8F1;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1.15;
  color: #1C1A16;
  font-family: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 500;
  text-shadow:
    1px 0 0 var(--halo), -1px 0 0 var(--halo), 0 1px 0 var(--halo), 0 -1px 0 var(--halo),
    1px 1px 0 var(--halo), -1px -1px 0 var(--halo), 1px -1px 0 var(--halo), -1px 1px 0 var(--halo);
  transition: opacity 0.12s;
}
.lbl .tag { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-weight: 500; }
.lbl-dim { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-weight: 400; color: #2B2721; }
.lbl-area {
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.92;
}
.lbl-area .sub {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  opacity: 0.85;
}
.lbl-annot { font-weight: 600; text-align: center; }
/* Labels are placed for a fixed view: hide while the view is changing. */
.lbl-moving .lbl { opacity: 0; transition: none; }

/* National Grid on the canvas (grid.js): metre values pinned to the top
   and left edges like a drawing sheet, the interval chip by the zoom
   control, and the cursor reference by the scale bar. */
.grid-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.grid-tick {
  position: absolute;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 0.62rem;
  line-height: 1.25;
  color: #4E483C;
  background: rgba(251, 248, 241, 0.86);
  padding: 0 0.28rem;
}
.grid-tick-band {
  font-family: "Archivo", system-ui, sans-serif; font-weight: 600; font-size: 0.7rem; color: #2B2721;
}
.grid-readout .ro-cell { color: #FFD9A8; font-weight: 600; }
.grid-tick-e { top: 0; transform: translateX(-50%); }
.grid-tick-n { left: 0; transform: translateY(-50%); }
.grid-chip {
  position: absolute; left: 0.6rem; bottom: 5.4rem; /* clears the two-row readout */
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 0.64rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: #4E483C; background: rgba(251, 248, 241, 0.86); padding: 0.12rem 0.4rem;
}
.grid-readout {
  position: absolute; left: 0.6rem; bottom: 2.55rem; z-index: 6;
  display: flex; flex-direction: column; gap: 0.1rem;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 0.7rem; line-height: 1.3;
  color: #E9E4D8; background: rgba(33, 30, 25, 0.9);
  padding: 0.3rem 0.55rem; border-radius: 4px;
  cursor: copy; user-select: none;
}
.grid-readout .ro-row { display: flex; gap: 0.55rem; align-items: baseline; white-space: nowrap; }
.grid-readout b { font-weight: 500; }
.grid-readout span { color: var(--ink-low, #9C9484); font-size: 0.64rem; }
.grid-readout .ro-w3w { color: #E9E4D8; }
.grid-readout .ro-pending { color: #6E6656; }
.grid-readout.copied { outline: 1px solid #E9E4D8; }
.grid-readout.copied::after {
  content: "Copied"; position: absolute; right: 0.5rem; top: 0.3rem;
  font-size: 0.62rem; color: #E9E4D8; letter-spacing: 0.06em; text-transform: uppercase;
}

/* ---- Shared form voice inside panels ---------------------------------- */
.inspector label, .item-form label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-low);
}
.inspector input, .inspector textarea, .item-form input, .item-form select {
  background: var(--chrome-input);
  border: 1px solid #37322A;
  color: var(--ink-hi);
  font-size: 0.84rem;
  padding: 0.34rem 0.5rem;
  font-family: inherit;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color 0.12s;
}
.inspector input:hover, .inspector textarea:hover,
.item-form input:hover, .item-form select:hover { border-color: #6E6656; }
.inspector input:focus, .inspector textarea:focus,
.item-form input:focus, .item-form select:focus {
  outline: none;
  border-color: var(--ink-hi);
}

/* Primary/secondary/danger buttons share one system. */
.insp-actions button, .item-actions button, #export-run {
  background: var(--ink-hi);
  color: #211E19;
  border: 1px solid var(--ink-hi);
  padding: 0.42rem 0;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.insp-actions button:hover, .item-actions button:hover, #export-run:hover {
  background: #fff;
}
.insp-actions button.danger, .item-actions button.danger {
  background: none;
  border-color: #6e3030;
  color: var(--danger);
}
.insp-actions button.danger:hover, .item-actions button.danger:hover {
  border-color: var(--danger);
  background: none;
}
.item-actions #item-cancel, .item-actions .item-cancel {
  background: none;
  border-color: #37322A;
  color: var(--ink-mid);
}
.item-actions #item-cancel:hover, .item-actions .item-cancel:hover { border-color: var(--ink-mid); background: none; }

/* ---- Inspector -------------------------------------------------------- */
.inspector { border-bottom: 1px solid var(--edge); max-height: 62%; display: flex; flex-direction: column; min-height: 0; }
.inspector .side-panel-body { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.75rem 1rem; }
.insp-metrics {
  font-size: 0.78rem;
  color: var(--ink-mid);
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.6rem;
}
.insp-metrics[hidden] { display: none; }
.insp-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.insp-metric span { color: var(--ink-low); }
.insp-metric b {
  font-weight: 400; color: var(--ink-hi); text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-size: 0.74rem;
}
.insp-note { color: var(--ink-low); font-size: 0.68rem; line-height: 1.4; padding-top: 0.2rem; }
.insp-metric.insp-muted b { color: var(--ink-low); }
.insp-tag {
  display: inline-block; margin-right: 0.4rem; padding: 0 0.3rem;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 0.72rem; font-weight: 500;
  color: #211E19; background: var(--ink-hi); border-radius: 2px;
}
.insp-actions {
  display: flex; gap: 0.5rem; flex: none;
  padding: 0.55rem 1rem 0.7rem; border-top: 1px solid var(--hairline);
}
.insp-actions button { flex: 1; }

/* Gates & gaps on fence runs */
.insp-insertions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-top: 1px solid var(--hairline);
  padding-top: 0.55rem;
}
.insp-insertions-title {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-low);
}
.insp-insertions-list { display: flex; flex-direction: column; gap: 0.2rem; }
.insp-ins-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-mid);
}
.insp-ins-row .at { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-hi); }
.insp-ins-row button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.7rem; }
.insp-ins-empty { font-size: 0.72rem; color: var(--ink-low); }
.insp-insertions-add { display: flex; gap: 0.35rem; }
.insp-insertions-add select {
  flex: 1; background: var(--chrome-input); color: var(--ink-hi);
  border: 1px solid #37322A; font-size: 0.75rem; padding: 0.25rem;
}
.insp-insertions-add input { width: 3rem; }
.insp-insertions-add button {
  background: none; border: 1px solid #37322A; color: var(--ink-mid);
  font-size: 0.75rem; padding: 0.2rem 0.55rem; cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.insp-insertions-add button:hover { color: var(--ink-hi); border-color: var(--ink-hi); }

/* ---- BoQ --------------------------------------------------------------- */
.boq-cat { padding: 0.55rem 1rem 0.2rem; }
.boq-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-mid);
}
.boq-line .qty { color: var(--ink-hi); font-variant-numeric: tabular-nums; white-space: nowrap; }
.boq-total {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--hairline);
  margin-top: 0.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.boq-est { color: var(--ink-low); font-size: 0.68rem; padding: 0.35rem 1rem 0.6rem; line-height: 1.4; }
#boq-csv, #boq-xlsx { font-size: 0.72rem; color: var(--link); text-decoration: none; }
#boq-csv { margin-left: auto; }
#boq-csv:hover, #boq-xlsx:hover { text-decoration: underline; }


/* ---- Exports + share --------------------------------------------------- */
.exports {
  border-top: 1px solid var(--edge);
  max-height: 45%;
  display: flex; flex-direction: column; min-height: 0;
}
.exports-cta { flex: none; padding: 0.7rem 1rem; }
/* The one way into sharing and exporting: quiet, but unmistakably a
   button rather than the text link it used to be. */
.panel-cta {
  width: 100%;
  background: none; border: 1px solid #4A4438; color: var(--ink-hi);
  font-size: 0.78rem; font-weight: 500; padding: 0.5rem 0.75rem;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.panel-cta:hover { background: var(--chrome-raised); border-color: var(--ink-hi); }
.exports-foot {
  flex: none; padding: 0.1rem 1rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  overflow-y: auto; min-height: 0;
}
.exports-foot[hidden] { display: none; }
.export-jobs { max-height: 7.5rem; overflow-y: auto; }
.link-btn {
  background: none; border: none; color: var(--link);
  font-size: 0.72rem; cursor: pointer; margin-left: auto;
}
.link-btn:hover { text-decoration: underline; }
.export-formats { display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.78rem; color: var(--ink-mid); }
.export-group { display: flex; flex-direction: column; gap: 0.35rem; }
.export-group-title { font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-low); }
/* .export-opt is a <label>, so inside a dialog it inherits the panel
   form voice: uppercase, stacked, tiny. These are readable sentences
   about who each format is for, so opt out of all of it. */
.export-opt,
.item-form .export-opt {
  display: grid; grid-template-columns: auto 1fr; gap: 0.5rem; align-items: start;
  font-size: 0.78rem; text-transform: none; letter-spacing: normal;
  color: var(--ink-mid); cursor: pointer; transition: color 0.12s;
}
.export-opt:hover { color: var(--ink-hi); }
.export-opt input { accent-color: var(--ink-hi); margin-top: 0.18rem; }
.export-opt b { font-weight: 500; color: var(--ink-hi); }
.export-opt small { display: block; font-size: 0.66rem; line-height: 1.35; color: var(--ink-low); }
.pdf-opts { display: flex; flex-direction: column; gap: 0.3rem; }
.pdf-opts-row { display: flex; gap: 0.35rem; }
.export-hint { font-size: 0.66rem; line-height: 1.35; color: var(--ink-low); }
#export-run:disabled { opacity: 0.55; cursor: default; }
.pdf-opts select {
  flex: 1; background: var(--chrome-input); color: var(--ink-hi);
  border: 1px solid #37322A; font-size: 0.72rem; padding: 0.22rem;
}
.export-jobs, .share-list { display: flex; flex-direction: column; gap: 0.28rem; font-size: 0.75rem; }
.export-job { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; color: var(--ink-mid); }
.export-job .st-queued, .export-job .st-running { color: #cfc27a; }
.export-job .st-failed { color: var(--danger); }
.export-err { color: var(--danger); font-size: 0.68rem; line-height: 1.35; padding-bottom: 0.2rem; }
.export-job a { color: var(--link); }
.share-row { display: flex; gap: 0.5rem; align-items: center; }
.share-row input {
  flex: 1; background: var(--chrome-input); border: 1px solid #37322A;
  color: var(--ink-mid); font-size: 0.7rem; padding: 0.24rem 0.4rem;
}
.share-row button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.7rem; }

/* ---- Custom item dialog ------------------------------------------------ */
.item-dialog {
  margin: auto; /* preflight zeroes dialog margins; modal dialogs centre */
  background: var(--chrome);
  color: var(--ink-hi);
  border: 1px solid #17140F;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  width: min(24rem, 92vw);
}
.item-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.item-dialog strong { font-size: 0.95rem; letter-spacing: -0.01em; }
.item-form { display: flex; flex-direction: column; gap: 0.75rem; font-size: 0.85rem; }
.item-form label { flex: 1; }
.item-form input[type=color] { padding: 0.1rem; height: 2rem; }
.item-row { display: flex; gap: 0.6rem; }
.muted-hint { color: var(--ink-low); text-transform: none; letter-spacing: normal; }
.item-actions { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.item-actions button { flex: 1; }
.item-actions button.danger, .item-actions #item-cancel, .item-actions .item-cancel { flex: 0.7; }
.dialog-note { margin: 0; font-size: 0.78rem; line-height: 1.45; color: var(--ink-mid); }
.dialog-foot {
  display: flex; flex-direction: column; gap: 0.45rem;
  margin-top: 0.2rem; padding-top: 0.6rem; border-top: 1px solid var(--hairline);
  font-size: 0.72rem; color: var(--ink-low);
}
.dialog-foot-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.dialog-foot .link-btn { margin-left: 0; white-space: nowrap; }

/* ---- Share or export dialog -------------------------------------------- */
.output-dialog { width: min(30rem, 94vw); }
.output-tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--hairline); }
.output-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--ink-low); font-size: 0.78rem; font-weight: 500;
  padding: 0.35rem 0.6rem; margin-bottom: -1px; cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.output-tab:hover { color: var(--ink-mid); }
.output-tab[aria-selected=true] { color: var(--ink-hi); border-bottom-color: var(--ink-hi); }
.output-panel { display: flex; flex-direction: column; gap: 0.75rem; min-height: 0; }
.output-panel[hidden] { display: none; }
/* On a phone the format list is taller than the viewport: scroll it,
   not the dialog, so the buttons stay put. */
.output-panel .export-formats { overflow-y: auto; max-height: min(30rem, 58vh); padding-right: 0.2rem; }
.output-panel .share-list { min-height: 2rem; }

/* ---- Feature finder ----------------------------------------------------- */
.find-box { position: relative; padding-top: 0.6rem; }
.find-results {
  position: absolute;
  left: 1rem; right: 1rem;
  top: 100%;
  z-index: 30;
  background: var(--chrome-raised);
  border: 1px solid #17140F;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 16rem;
  overflow-y: auto;
}
.find-results button {
  background: none; border: none; color: var(--ink-mid);
  font-size: 0.78rem; text-align: left; padding: 0.4rem 0.6rem; cursor: pointer;
}
.find-results button:hover { background: var(--chrome-input); color: var(--ink-hi); }
.find-results .panel-empty { padding: 0.4rem 0.6rem; }

/* ---- Narrow viewports: panels become drawers ---------------------------- */
/* An open drawer covers its own toggle, so dismissal is the drawer bar's
   close button, a tap on the backdrop, or Escape. All three are wired in
   plan.js; none of this chrome exists at desktop width. */
.drawer-toggle, .drawer-bar, .drawer-backdrop { display: none; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .side-panel {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: min(17rem, 85vw);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    border-right: 1px solid #17140F;
    z-index: 25;
  }
  .side-panel-right {
    left: auto; right: 0;
    transform: translateX(100%);
    border-left: 1px solid #17140F;
    width: min(20rem, 85vw);
  }
  .side-panel.drawer-open { transform: translateX(0); }
  .drawer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex: none;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-bottom: 1px solid var(--edge);
    background: var(--chrome-raised);
  }
  .drawer-bar strong {
    font-size: 0.7rem; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-mid);
  }
  .drawer-close {
    display: flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; /* thumb-sized */
    margin: -0.35rem 0;
    background: none; border: none; color: var(--ink-mid); cursor: pointer;
    transition: color 0.12s;
  }
  .drawer-close:hover, .drawer-close:focus-visible { color: var(--ink-hi); }
  .drawer-backdrop {
    display: block;
    position: absolute; inset: 0;
    z-index: 22;
    background: rgba(0, 0, 0, 0.5);
  }
  .drawer-backdrop[hidden] { display: none; }
  .drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 21;
    top: 0.9rem;
    width: 2.75rem; height: 2.75rem;
    background: var(--chrome);
    color: var(--ink-hi);
    border: 1px solid #17140F;
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  .drawer-toggle-left { left: 0.75rem; }
  .drawer-toggle-right { right: 0.75rem; }
  .toolbar { max-width: calc(100% - 8rem); flex-wrap: wrap; }
  .contractor-chips { top: 5.6rem; }
}

/* ---- Shortcuts overlay ------------------------------------------------- */
.shortcuts-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.shortcuts-card {
  background: var(--chrome);
  color: var(--ink-hi);
  border: 1px solid #17140F;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(22rem, 90vw);
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem 0.9rem;
  font-size: 0.8rem;
  color: var(--ink-mid);
  align-items: baseline;
}
.shortcuts-grid kbd {
  background: var(--chrome-input);
  border: 1px solid #37322A;
  border-bottom-width: 2px;
  color: var(--ink-hi);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 0.08rem 0.4rem;
  white-space: nowrap;
  justify-self: start;
}
.shortcuts-hint { font-size: 0.72rem; color: var(--ink-low); line-height: 1.4; }

/* ---- Viewer role ---------------------------------------------------- */
/* Editing affordances vanish for viewers; the server enforces the rest. */
.role-viewer [data-editonly], .plan-archived [data-editonly] { display: none !important; }
.viewer-pill { display: none; }
.role-viewer .viewer-pill {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #6E6656;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #B8B0A0;
}

/* ---- Brand ---------------------------------------------------------- */
/* One accent, used only for the mark's plotted point and rare signal
   moments; everything else stays monochrome with colour on the map. */
:root { --brand-accent: #FF4F1F; }

/* Measurements read surveyed, not typed: mono for live readouts. */
.draw-chip, .status-chip, .insp-metrics {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
.side-panel-body { font-variant-numeric: tabular-nums; }

/* ---- Right-click context menu (line editing) ------------------------ */
.ctx-menu {
  position: absolute; z-index: 30; min-width: 12rem;
  background: var(--chrome); color: var(--ink-hi);
  border: 1px solid #17140F; box-shadow: var(--shadow); padding: 0.25rem;
  font-size: 0.82rem;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; background: none;
  border: none; color: inherit; padding: 0.4rem 0.6rem; cursor: pointer;
  border-radius: 3px;
}
.ctx-menu button:hover { background: var(--chrome-raised); }
.ctx-menu button.danger { color: #E4552B; }
.ctx-sep { height: 1px; background: var(--hairline); margin: 0.25rem 0; }
