/* Splicedeck app — built to the brand kit v1.1 (BRAND.md §4-§6):
   Bench Neutral chrome, Barlow Semi Condensed / Source Sans 3 / IBM Plex Mono, 36 px controls,
   dense 32 px table rows with sticky 34 px headers, status pills with symbol + text + border,
   colour identities as swatch + ordinal + NAME. TIA hues appear only as data swatches. */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--sd-canvas); color: var(--sd-ink); font: 400 14px/20px var(--sd-font-text); -webkit-font-smoothing: antialiased; }
a { color: var(--sd-ink); text-underline-offset: 2px; }
.sd-id, code { font-family: var(--sd-font-mono); font-weight: 500; font-size: 12.5px; letter-spacing: 0; }

/* ---------- shell */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 24px; min-height: 60px;
  background: var(--sd-surface); border-bottom: 1px solid var(--sd-hairline); position: sticky; top: 0; z-index: 5; }
.brand { color: var(--sd-ink); display: inline-flex; padding: 0; }
.brand svg { height: 36px; width: auto; }                        /* brand minimum height: 36 px */
.who { display: flex; gap: 18px; align-items: center; color: var(--sd-muted); font-size: 13px; }
.who strong { color: var(--sd-ink); font-weight: 600; }
.who nav.top { display: flex; gap: 4px; }
.who nav.top a { color: var(--sd-ink); font-weight: 600; text-decoration: none; padding: 6px 10px; border-radius: var(--sd-radius); }
.who nav.top a:hover { background: var(--sd-selection); }
main { max-width: 1200px; margin: 28px auto 64px; padding: 0 24px; }

/* ---------- type scale (BRAND.md §5) */
h1 { font: 600 28px/32px var(--sd-font-display); margin: 0; }
h2 { font: 600 20px/26px var(--sd-font-display); margin: 0 0 10px; }
.eyebrow { font: 600 12px/16px var(--sd-font-text); letter-spacing: .12em; text-transform: uppercase; color: var(--sd-muted); margin: 0 0 6px; }
.muted { color: var(--sd-muted); }
.small { font-size: 13px; line-height: 18px; }
p { margin: 0 0 10px; }

/* ---------- controls: 36 px, 6 px radius, label above */
button { font: 500 14px/1 var(--sd-font-text); height: 36px; padding: 0 14px; border-radius: var(--sd-radius); cursor: pointer;
  border: 1px solid var(--sd-control-border); background: var(--sd-raised); color: var(--sd-ink); white-space: nowrap; }
button:hover { background: var(--sd-selection); }
button.primary { background: var(--sd-action); color: var(--sd-action-text); border-color: var(--sd-action); font-weight: 600; }
button.primary:hover { background: var(--sd-action-hover); }
button.small { height: 28px; padding: 0 10px; font-size: 13px; }
button.link { height: auto; border: 0; background: none; padding: 0; text-decoration: underline; font-weight: 500; color: var(--sd-ink); }
button:disabled { opacity: .55; cursor: default; }
label { display: block; margin: 0 0 12px; font: 600 13px/18px var(--sd-font-text); }
label > span { display: block; margin-bottom: 4px; }
input, select { display: block; width: 100%; height: 36px; padding: 0 10px; font: 400 14px var(--sd-font-text); color: var(--sd-ink);
  background: var(--sd-raised); border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); }
input::placeholder { color: var(--sd-muted); opacity: 1; }        /* full Muted token, never opacity */
.sd-focusable:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--sd-focus); outline-offset: 2px; }

/* ---------- forms */
form.stack { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; margin: 0 0 16px;
  padding: 14px 16px; background: var(--sd-surface); border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); }
form.stack label { margin: 0; }
form.stack button { justify-self: start; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 0 0 14px; }
form.inline label { margin: 0; }
form.inline input, form.inline select { width: auto; min-width: 120px; }
.card { background: var(--sd-surface); border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius-lg); padding: 28px; }
.narrow { max-width: 400px; margin: 48px auto; }
.narrow h1 { margin-bottom: 18px; }
.narrow form label input { margin-top: 4px; }
.narrow form button { width: 100%; margin-top: 6px; }
.hint { margin: -6px 0 12px; font-weight: 400; }

/* ---------- status line: icon + message + boundary, never colour alone */
.status { min-height: 0; margin: 0 0 14px; }
.status:empty { display: none; }
.status { padding: 9px 12px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-surface); }
.status::before { content: "✓ "; font-weight: 700; }
.status.error { border-left-width: 4px; border-color: var(--sd-ink); }
.status.error::before { content: "! "; }
.notice { padding: 9px 12px; border: 1px solid var(--sd-control-border); border-left-width: 4px; background: var(--sd-surface); border-radius: var(--sd-radius); }

/* ---------- status pills (§6): 22 px, 4 px radius, symbol + text + border, monochrome-safe */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border: 1px solid var(--sd-control-border);
  border-radius: var(--sd-radius-sm); font: 600 11.5px/1 var(--sd-font-text); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; background: var(--sd-raised); }
.pill.strong { border-color: var(--sd-ink); }
.pill.dashed { border-style: dashed; }
.pill.inverse { background: var(--sd-action); color: var(--sd-action-text); border-color: var(--sd-action); }

/* ---------- dense tables (§6) */
.table-wrap { border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-surface); overflow: auto; max-height: 70vh; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 18px; }
.grid th { position: sticky; top: 0; z-index: 1; height: 34px; text-align: left; padding: 0 10px; background: var(--sd-raised); color: var(--sd-muted);
  font-weight: 600; font-size: 12px; letter-spacing: .02em; border-bottom: 1px solid var(--sd-control-border); white-space: nowrap; }
.grid td { height: 32px; padding: 4px 10px; border-bottom: 1px solid var(--sd-hairline); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--sd-selection); }
.grid tr[aria-current] td { background: var(--sd-selection); }
.grid td.code { font-family: var(--sd-font-mono); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.grid td.when { color: var(--sd-muted); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.grid td.actions { text-align: right; white-space: nowrap; }
.grid td.actions > * + * { margin-left: 6px; }

/* ---------- colour identity: swatch + ordinal + NAME (examples/core-label-pattern.html) */
.colour { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.colour .ord { font-family: var(--sd-font-mono); font-weight: 500; font-size: 12.5px; }
.colour .name { font-weight: 600; font-size: 12px; letter-spacing: .03em; }
.sw { position: relative; display: inline-block; width: 14px; height: 14px; border: 1px solid var(--sd-muted); border-radius: 3px; flex: none; overflow: hidden; }
.sw .tr { position: absolute; top: 0; right: 0; width: 40%; height: 100%; }

/* ---------- page layout */
.heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 6px; }
.crumbs { margin: 0 0 4px; }
.crumbs a { color: var(--sd-muted); }
nav.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--sd-control-border); margin: 14px 0 22px; }
nav.tabs a { padding: 9px 12px; color: var(--sd-muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav.tabs a[aria-current="page"] { color: var(--sd-ink); border-bottom-color: var(--sd-ink); }
nav.tabs a:hover { color: var(--sd-ink); }
section.block { margin: 0 0 30px; }
section.block > h2 { padding-bottom: 6px; border-bottom: 1px solid var(--sd-hairline); margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat { padding: 14px 16px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-surface); }
.stat strong { display: block; font: 600 32px/36px var(--sd-font-display); font-variant-numeric: tabular-nums; }
.stat span { color: var(--sd-muted); font-size: 13px; }

/* ---------- empty states (§6): one line icon, one sentence, one action */
.empty { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px dashed var(--sd-control-border); border-radius: var(--sd-radius); color: var(--sd-muted); }
.empty svg { flex: none; color: var(--sd-muted); }
.empty p { margin: 0; flex: 1; }

/* ---------- trace path: an ordered route, not a bullet list */
ol.path { list-style: none; padding: 0; margin: 8px 0 12px; border-left: 2px solid var(--sd-ink); }
ol.path li { position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0 6px 16px; }
ol.path li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 8px; height: 8px; transform: rotate(45deg); background: var(--sd-canvas); border: 1.5px solid var(--sd-ink); }
ol.path li .seg { font-family: var(--sd-font-mono); font-weight: 500; font-size: 12.5px; min-width: 120px; }
.landing { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-surface); margin: 6px 0; }
.landing .end { font: 600 12px/1 var(--sd-font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--sd-muted); }
.result { font-size: 15px; }
.result strong { font: 600 22px/1 var(--sd-font-display); margin-right: 6px; }
code.secret { display: inline-block; padding: 3px 8px; background: var(--sd-selection); border-radius: var(--sd-radius-sm); user-select: all; word-break: break-all; }
.theme-toggle { height: 30px; font-size: 13px; padding: 0 10px; }
.table-wrap + p, .table-wrap + .muted { margin-top: 10px; }
/* billing: room between the intro, the tables and the controls under them */
.billing-intro { margin: 0 0 26px; max-width: 80ch; }
.billing-portal { margin-top: 14px; }
.pay-state { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.usage-count { margin: 16px 0 10px; }
h2 .sd-id { font-size: 20px; }
.narrow form + p, .narrow form ~ p { margin-top: 14px; }

/* ================= shell: side menu + working area ================= */
.logo { height: 36px; width: auto; display: block; }                 /* brand minimum 36 px */
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }
.bar .theme-toggle { margin-left: auto; }
.gate-main { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.card.narrow .mark { height: 36px; width: auto; margin-bottom: 14px; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  background: var(--sd-surface); border-right: 1px solid var(--sd-hairline); padding: 18px 14px 14px; }
.side .brand { padding: 2px 6px 16px; }
.side nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.side .eyebrow { margin: 16px 8px 6px; }
.side nav > .eyebrow:first-child { margin-top: 0; }
.side .ws-name { margin: 0 8px 8px; font-weight: 600; font-size: 14px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--sd-radius); color: var(--sd-ink);
  text-decoration: none; font-weight: 500; font-size: 14px; }
.side nav a .ico { color: var(--sd-muted); flex: none; }
.side nav a:hover { background: var(--sd-selection); }
.side nav a.on { background: var(--sd-selection); font-weight: 600; box-shadow: inset 3px 0 0 var(--sd-ink); }
.side nav a.on .ico { color: var(--sd-ink); }
.side .proj { margin: 6px 0 2px; padding: 4px 0 6px; border-top: 1px solid var(--sd-hairline); border-bottom: 1px solid var(--sd-hairline); }
.side .proj-name { display: flex; flex-direction: column; gap: 2px; margin: 0 8px 8px; }
.side .proj-name span:last-child { font-size: 13px; color: var(--sd-muted); line-height: 17px; }
.side-foot { border-top: 1px solid var(--sd-hairline); padding-top: 12px; }
.side-foot .who-line { display: flex; flex-direction: column; margin: 0 6px 10px; font-size: 13px; }
.side-foot .foot-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.work { min-width: 0; padding: 26px 32px 64px; }
.work > .status { max-width: 1240px; }
.work main { max-width: 1240px; margin: 0; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 20px; padding-bottom: 14px; border-bottom: 1px solid var(--sd-control-border); }
.head-actions { display: flex; gap: 8px; align-items: center; }
.sd-id.big { font-size: 20px; }
/* ---- phones and narrow tablets: top bar + drawer menu */
.mobile-bar, .side-backdrop { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .mobile-bar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 14px;
    background: var(--sd-surface); border-bottom: 1px solid var(--sd-hairline); }
  .mobile-bar .brand { padding: 0; flex: none; }
  .mobile-bar .mark { height: 32px; width: auto; }
  .mobile-title { flex: 1; min-width: 0; font: 600 16px/20px var(--sd-font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #menu-toggle { height: 36px; padding: 0 14px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-raised); color: var(--sd-ink); font: 600 14px var(--sd-font-text); }
  .side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(300px, 86vw); height: 100%; transform: translateX(-105%);
    transition: transform .18s ease-out; box-shadow: 0 0 40px rgba(0, 0, 0, .25); visibility: hidden; }
  .shell.menu-open .side { transform: none; visibility: visible; }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(20, 19, 17, .45); }
  .side-backdrop[hidden] { display: none; }
  .side nav a { padding: 10px 8px; }   /* 44 px touch targets */
  .work { padding: 16px 14px 48px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-head h1 { font-size: 26px; line-height: 30px; }
  form.inline { gap: 8px; }
  form.inline label, form.inline input, form.inline select { width: 100%; }
  form.inline > button { width: auto; }
  form.stack { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .table-wrap { max-height: none; }
  .editor-fields { grid-template-columns: 1fr; }
  dialog.editor form { padding: 16px; }
  .chat-starters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .chat-starters button { white-space: nowrap; }
  .copy-row { flex-wrap: wrap; }
  .ai-form label:has(input[name="base_url"]) { grid-column: auto; }
  .ai-form input[name="base_url"] { min-width: 0; }
  .sx-fig > svg:not(.sx-map), .sx-fig.diagram img { min-width: 620px; }   /* keep labels readable: scroll sideways */
  .sx-fig { -webkit-overflow-scrolling: touch; }
  .sx-map { touch-action: pan-y pinch-zoom; min-height: 240px; }   /* the page still scrolls over the map */
  .sx-map .sx-node { touch-action: none; }                           /* dragging a node still works */
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* ================= edit dialog ================= */
dialog.editor { border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius-lg); padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--sd-surface); color: var(--sd-ink); box-shadow: 0 18px 50px rgba(0, 0, 0, .28); }
dialog.editor::backdrop { background: rgba(20, 19, 17, .45); }
dialog.editor form { padding: 20px 22px; }
dialog.editor h2 { margin-bottom: 14px; }
.editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.editor-fields label { margin: 0; }
.editor-fields label.check { display: flex; align-items: center; gap: 8px; }
.editor-fields label.check input { width: auto; height: auto; }
.editor-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ================= libraries ================= */
.lib-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; margin-top: 14px; }
.lib-nav { display: flex; flex-direction: column; gap: 1px; align-self: start; position: sticky; top: 16px; }
.lib-nav a { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: var(--sd-radius); text-decoration: none; color: var(--sd-ink); font-size: 14px; }
.lib-nav a:hover { background: var(--sd-selection); }
.lib-nav a.on { background: var(--sd-selection); font-weight: 600; box-shadow: inset 3px 0 0 var(--sd-ink); }
.lib-nav .count { font-family: var(--sd-font-mono); font-size: 12px; color: var(--sd-muted); }
@media (max-width: 1000px) { .lib-layout { grid-template-columns: minmax(0, 1fr); } .lib-nav { position: static; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); } }

.strand { display: inline-flex; align-items: center; gap: 8px; }
.term { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 0; }
.small-link { font-size: 13px; }

/* ================= schematics (web/schematics.js): neutral linework from the tokens ================= */
.sx-fig { margin: 0 0 14px; padding: 12px; background: var(--sd-surface); border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); overflow-x: auto; }
.sx-fig figcaption { margin-top: 6px; }
.sx-fig.diagram { background: #FFFFFF; max-height: 640px; overflow: auto; }
.sx-fig.diagram img { display: block; width: 100%; height: auto; }
.sx { display: block; max-width: 100%; height: auto; font-family: var(--sd-font-text); }
.sx-t { fill: var(--sd-ink); font-size: 12px; }
.sx-id { font-family: var(--sd-font-mono); font-weight: 500; font-size: 12px; }
.sx-small { font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.sx-tiny { font-size: 9px; fill: var(--sd-muted); }
.sx-muted { font-size: 11px; fill: var(--sd-muted); }
.sx-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: .12em; fill: var(--sd-muted); }
.sx-bang { font-size: 16px; font-weight: 700; fill: var(--sd-ink); }
.sx-link { stroke: var(--sd-ink); stroke-width: 1.75; fill: none; }
.sx-link.cord { stroke-dasharray: 2 3; }
.sx-panel { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 1.25; }
.sx-open { fill: none; stroke: var(--sd-control-border); stroke-width: 1.25; stroke-dasharray: 4 3; }
.sx-enclosure { fill: none; stroke: var(--sd-control-border); stroke-width: 1; stroke-dasharray: 3 3; }
.sx-splice { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 1.5; }
.sx-port { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 1; }
.sx-port.on { fill: var(--sd-ink); }
.sx-port.front { stroke-width: 2.5; }
.sx-port-rear { fill: var(--sd-ink); }
.sx-swatch { stroke: var(--sd-ink); stroke-width: .8; }
.sx-jacket { fill: var(--sd-surface); stroke: var(--sd-ink); stroke-width: 2.5; }
.sx-tube { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 1; }
.sx-tube-colour { fill: none; stroke-width: 3; opacity: .9; }
.sx-core { stroke: var(--sd-ink); stroke-width: .9; }
.sx-tracer { fill: none; stroke-width: 1.8; }
.sx-allocated { fill: none; stroke: var(--sd-ink); stroke-width: 1.2; stroke-dasharray: 2 2; }
.sx-click { cursor: pointer; }
.sx-click:hover .sx-core, .sx-click:focus .sx-core, .sx-click:hover .sx-port, .sx-click:focus .sx-port { stroke-width: 2.5; }
.sx-click:focus { outline: none; }
.sx-map { min-height: 320px; max-height: 70vh; touch-action: none; }
.sx-seg { stroke: var(--sd-control-border); stroke-width: 3; }
.sx-seg.tray, .sx-seg.ladder { stroke-width: 6; stroke-opacity: .55; }
.sx-seg.subduct, .sx-seg.conduit { stroke-width: 2; }
.sx-seg.direct_buried { stroke-dasharray: 8 4; }
.sx-seg.over { stroke: var(--sd-ink); stroke-dasharray: 2 3; stroke-width: 4; }
.sx-seg-label { fill: var(--sd-muted); font-size: 10px; text-anchor: middle; font-family: var(--sd-font-mono); }
.sx-hi { stroke: var(--sd-ink); stroke-width: 4; stroke-linecap: square; fill: none; }
.sx-hi.path-b { stroke-dasharray: 9 6; }
.sx-hi.route { stroke-width: 5; }
.sx-node-shape { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 1.5; }
.sx-node-shape.room, .sx-node-shape.cabinet { fill: var(--sd-selection); }
.sx-node-shape.handhole { stroke-dasharray: 3 2; }
.sx-node .sx-id { font-size: 11px; }
.sx-drag { cursor: grab; }
.sx-drag:active { cursor: grabbing; }
.sx-shared { fill: none; stroke: var(--sd-ink); stroke-width: 2; stroke-dasharray: 3 2; }
.sx-host { margin-bottom: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 8px; }
.toolbar form { margin: 0; }

/* ---- project assistant */
.chat { display: grid; gap: 12px; max-width: 920px; }
.chat-log { display: grid; gap: 10px; max-height: 62vh; overflow-y: auto; padding: 12px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-surface); min-height: 160px; align-content: start; }
.chat-msg { padding: 10px 12px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-canvas); }
.chat-msg.user { border-left: 4px solid var(--sd-ink); }
.chat-msg.assistant { border-left: 4px solid var(--sd-control-border); }
.chat-msg.pending .chat-text { font-style: italic; }
.chat-who { margin: 0 0 4px; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-tools { margin: 6px 0 0; }
.chat-form { display: grid; gap: 8px; }
.chat-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px 10px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-surface); color: var(--sd-ink); resize: vertical; }
.chat-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chat-starters { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-form label:has(input[name="base_url"]) { grid-column: span 2; }
.ai-form input[name="base_url"] { width: 100%; }
.ai-form .ai-help { margin-top: 8px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.secret-link { flex: 1; min-width: 0; font-family: var(--sd-font-mono); font-size: 12.5px; height: 36px; padding: 0 10px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-surface); color: var(--sd-ink); }

/* ---- pathway drawing: map tools, lanes, sections, chamber view */
.mode-bar { display: inline-flex; gap: 0; margin: 0 0 10px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); overflow: hidden; }
.mode-bar button { border: 0; border-radius: 0; border-right: 1px solid var(--sd-control-border); background: var(--sd-raised); }
.mode-bar button:last-child { border-right: 0; }
.mode-bar button.on { background: var(--sd-action); color: var(--sd-action-text); }
.sx-bg { fill: transparent; }
.sx-map.mode-add .sx-bg { cursor: crosshair; }
.sx-map.mode-connect .sx-node { cursor: pointer; }
.sx-seg-hit { stroke: transparent; stroke-width: 14; }
.sx-click:hover .sx-seg, .sx-click:hover .sx-lane { stroke: var(--sd-ink); }
.sx-pending { fill: none; stroke: var(--sd-ink); stroke-width: 2.5; }
.sx-lane { stroke: var(--sd-muted); stroke-width: 1; }
.sx-link.through { stroke-width: 2.25; }
.sx-warn { font-size: 11px; font-weight: 600; fill: var(--sd-ink); }
.sx-duct { fill: var(--sd-surface); stroke: var(--sd-ink); stroke-width: 1.5; }
.sx-duct-wall { fill: var(--sd-selection); stroke: var(--sd-control-border); stroke-width: 1; }
.sx-tray { fill: none; stroke: var(--sd-ink); stroke-width: 2.5; }
.sx-cable-x { fill: var(--sd-control-border); stroke: var(--sd-ink); stroke-width: 1; }
.sx-subduct { fill: none; stroke: var(--sd-ink); stroke-width: 1.25; stroke-dasharray: 3 2; }
.sx-chamber { fill: var(--sd-raised); stroke: var(--sd-ink); stroke-width: 2; }
.sx-room { fill: var(--sd-selection); stroke: var(--sd-ink); stroke-width: 2; }
.sx-entry { stroke: var(--sd-ink); stroke-width: 6; stroke-opacity: .28; }
.sx-click:hover .sx-entry { stroke-opacity: .55; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--sd-muted); font-size: 13px; }
dl.facts dd { margin: 0; }
@media (max-width: 600px) { dl.facts { grid-template-columns: 1fr; gap: 2px; } dl.facts dd { margin-bottom: 8px; } }

/* ---- import */
.import-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; margin-bottom: 12px; }
.import-pick label { margin: 0; }
.sheet-preview { max-height: 360px; }
.sheet-preview th.mapped { background: var(--sd-selection); }
.sheet-preview tr.header-row td { font-weight: 600; background: var(--sd-selection); }
.sheet-preview tr.skipped-row td { color: var(--sd-muted); }
.map-table select, .map-table input { width: 100%; min-width: 160px; }
.map-table .req { font-weight: 700; }
.notice.check { border-left-style: dashed; }

/* ---- assistant (v2): full-width conversation + side column */
.chat { display: none; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.chat-main { display: flex; flex-direction: column; min-height: calc(100vh - 210px); border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius-lg); background: var(--sd-surface); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--sd-hairline); min-height: 48px; }
.chat-head .eyebrow { margin: 0; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 20px 16px; overflow-y: auto; max-height: calc(100vh - 330px); min-height: 220px; border: 0; border-radius: 0; background: none; }
.chat-row { display: flex; gap: 10px; align-items: flex-start; }
.chat-row.user { justify-content: flex-end; }
.chat-bubble { max-width: min(78%, 640px); padding: 10px 14px; border-radius: 12px 12px 3px 12px; background: var(--sd-action); color: var(--sd-action-text); }
.chat-avatar { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--sd-control-border); border-radius: 50%; background: var(--sd-raised); color: var(--sd-ink); }
.chat-answer { flex: 1; min-width: 0; max-width: 820px; padding-top: 4px; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 22px; }
.chat-reads { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chat-read { font-size: 12px; padding: 1px 8px; border: 1px solid var(--sd-hairline); border-radius: 10px; background: var(--sd-raised); color: var(--sd-muted); }
.chat-read.failed { border-style: dashed; }
.chat-row.pending .dots { letter-spacing: 2px; font-weight: 700; }
.chat-empty { margin: auto; max-width: 560px; text-align: center; padding: 24px 8px; }
.chat-empty-mark { width: 56px; height: 56px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid var(--sd-control-border); border-radius: 50%; background: var(--sd-raised); }
.chat-empty h3 { margin: 0 0 6px; }
.chat-empty-starters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; text-align: left; }
.chat-starter { display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 9px 12px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-canvas); color: var(--sd-ink); font: 400 14px/19px var(--sd-font-text); text-align: left; cursor: pointer; }
.chat-starter:hover { border-color: var(--sd-control-border); background: var(--sd-raised); }
.chat-starter .ico { flex: none; margin-top: 1px; color: var(--sd-muted); }
.chat-composer { margin: 0 16px 16px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius-lg); background: var(--sd-canvas); }
.chat-composer:focus-within { outline: 2px solid var(--sd-focus); outline-offset: 1px; }
.chat-input { display: block; width: 100%; box-sizing: border-box; border: 0; background: transparent; color: var(--sd-ink); font: inherit; padding: 12px 14px 4px; resize: vertical; min-height: 52px; }
.chat-input:focus { outline: none; }
.chat-composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 8px 14px; }
.chat-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.chat-side-block { padding-bottom: 14px; border-bottom: 1px solid var(--sd-hairline); }
.chat-side-block .eyebrow { margin-bottom: 8px; }
.chat-model { display: flex; flex-direction: column; gap: 2px; margin: 0 0 6px; }
.chat-side-starters { display: flex; flex-direction: column; gap: 6px; }
.chat-can { margin: 0; padding-left: 18px; font-size: 14px; line-height: 21px; }
@media (max-width: 1100px) { .chat-layout { grid-template-columns: minmax(0, 1fr); } .chat-side { position: static; } .chat-side-starters { display: none; } }
@media (max-width: 900px) {
  .chat-main { min-height: 0; }
  .chat-log { max-height: none; padding: 14px 10px; }
  .chat-composer { margin: 0 10px 10px; }
  .chat-bubble { max-width: 88%; }
  .chat-empty-starters { grid-template-columns: 1fr; }
  .chat-composer-bar > .muted { display: none; }
}

/* ---- API usage help */
.api-usage { margin: 6px 0 14px; padding: 12px 14px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-surface); }
.api-usage dl.facts { margin-bottom: 10px; }
.code-row { display: flex; gap: 8px; align-items: center; margin: 4px 0; min-width: 0; }
.code-block { flex: 1; min-width: 0; display: block; padding: 6px 10px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-canvas); white-space: nowrap; overflow-x: auto; }
.code-row code.secret { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }
.chat-starter { height: auto; min-height: 36px; white-space: normal; overflow-wrap: anywhere; }
.chat-starter span { min-width: 0; }
.api-usage dl.facts { align-items: center; }

/* ---- dashboard: KPI tiles, checks, meters, quick actions */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius-lg); background: var(--sd-surface); color: var(--sd-ink); text-decoration: none; }
a.kpi:hover { border-color: var(--sd-control-border); }
.kpi-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sd-muted); }
.kpi-value { font: 600 28px/34px var(--sd-font-text); }
.kpi-sub { font-size: 12.5px; color: var(--sd-muted); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.checks { display: flex; flex-direction: column; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius); background: var(--sd-surface); }
.check-row { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--sd-hairline); color: var(--sd-ink); text-decoration: none; }
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--sd-raised); }
.check-row .pill { grid-row: span 2; }
.check-title { font-weight: 600; }
.meter { margin: 0 0 12px; }
.meter-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 4px; }
.meter-num { color: var(--sd-muted); font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: 4px; background: var(--sd-selection); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 4px; background: var(--sd-ink); }
.quicks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 6px 0 18px; }
.quick { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-raised); color: var(--sd-ink); text-decoration: none; font-weight: 600; }
.quick:hover { background: var(--sd-selection); }

/* ---- project cards */
.proj-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 6px 0 14px; }
.proj-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--sd-hairline); border-radius: var(--sd-radius-lg); background: var(--sd-surface); }
.proj-card.archived, .proj-card.closed { opacity: .78; }
.proj-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.proj-code { font-size: 14px; }
.proj-title { font: 600 18px/22px var(--sd-font-display); color: var(--sd-ink); text-decoration: none; }
.proj-title:hover { text-decoration: underline; }
.proj-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.proj-nums dt { font-size: 11px; color: var(--sd-muted); text-transform: uppercase; letter-spacing: .05em; }
.proj-nums dd { margin: 0; font-weight: 600; font-size: 17px; }
.proj-card .meter { margin: 0; }
.proj-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--sd-hairline); padding-top: 10px; }
.proj-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- outputs */
.file-links { display: inline-flex; gap: 6px; }
.file-link { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid var(--sd-control-border); border-radius: var(--sd-radius); background: var(--sd-raised); color: var(--sd-ink); text-decoration: none; font-size: 13px; font-weight: 600; }
.file-link:hover { background: var(--sd-selection); }
@media (min-width: 1200px) { .kpis { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.recent { margin-top: 14px; }
.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.small-quick { padding: 8px 12px; font-weight: 500; font-size: 14px; flex-wrap: wrap; gap: 4px 8px; }
