/* VeryUseful.Records structural stylesheet.
 *
 * Layout only reads design tokens (CSS custom properties). The active design
 * pack is written onto :root at runtime by themes.js — see docs/THEMING.md.
 * The values below are the Very Useful (vut) light pack, inlined as a
 * no-JavaScript / no-flash fallback so the app is styled before themes.js runs.
 */
:root {
  --bg: #faf9f7; --panel: #ffffff; --ink: #3f4638; --muted: #7a866b;
  --accent: #606b53; --accent-ink: #ffffff; --line: #d4d9cb;
  --chip: #e8ebe3; --danger: #a34d3f; --ok: #606b53; --warn: #9a7b2d;
  --danger-ink: #ffffff; --ok-ink: #ffffff; --warn-ink: #ffffff;
  --shadow: 0 1px 3px rgba(28, 31, 24, .09);
  --radius: 4px; --radius-lg: 8px;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Playfair Display", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font-body);
}
#app { display: flex; min-height: 100vh; }

/* sidebar */
#sidebar {
  width: 240px; flex: none; border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
#brand h1 { margin: 0; font-size: 20px; letter-spacing: .3px; font-family: var(--font-head); }
#brand .tagline { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; }

/* wordmark — the [[ ]] bracket mark (bracket packs only) */
#brand h1.wm {
  /* mono is wide: sized so a long product name still fits the sidebar */
  font-family: var(--font-mono); font-weight: 800; letter-spacing: -.5px;
  font-size: 15px; display: flex; align-items: baseline; gap: 0;
  white-space: nowrap;
}
#brand .wm .br { color: var(--accent); }
#brand .wm .br.in { color: var(--ink); }
#brand .wm .wm-name { color: var(--ink); padding: 0 1px; }
[data-brackets="off"] #brand h1 { font-family: var(--font-head); }

/* eyebrow section labels — [[ Label ]] above a heading */
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase; color: var(--accent);
  margin: 0 0 6px;
}
[data-brackets="on"] .eyebrow::before { content: "[[ "; opacity: .65; }
[data-brackets="on"] .eyebrow::after  { content: " ]]"; opacity: .65; }

#bases .base-item {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: 0; background: none; color: var(--ink); border-radius: var(--radius-lg);
  cursor: pointer; font-size: 14.5px;
}
#bases .base-item:hover { background: var(--chip); }
#bases .base-item.active { background: var(--accent); color: var(--accent-ink); }
#basenav { display: flex; flex-direction: column; gap: 2px; }
#basenav .navhead {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 10px 6px 4px;
}
/* a navigation group inside Views or Compose: the design's `group` label as
   a shelf that opens and closes. Closed, the sidebar is a short list of
   headings (each carrying the unread count of what is inside); the group
   holding the page you are on is the open one. The pinned items sit above
   the shelves, parted by a rule. */
#basenav details.navgroup { margin: 0; }
#basenav details.navgroup > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px;
  padding: 7px 10px 7px 9px; border-radius: var(--radius-lg);
  font-size: 13.5px; font-weight: 600; color: var(--ink); user-select: none;
}
#basenav details.navgroup > summary::-webkit-details-marker { display: none; }
#basenav details.navgroup > summary:hover { background: var(--chip); }
#basenav details.navgroup > summary .chev {
  width: 0; height: 0; flex: none; opacity: .65;
  border-left: 5px solid currentColor; border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent; transition: transform .15s ease;
}
#basenav details.navgroup[open] > summary .chev { transform: rotate(90deg); }
#basenav details.navgroup > summary .lbl { flex: 1; min-width: 0; }
#basenav details.navgroup[open] > summary .count { display: none; }
/* the heading's count is a tally, not a call to action: quieter than a view's */
#basenav details.navgroup > summary .count {
  background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted);
}
#basenav details.navgroup > a { margin-left: 16px; }
#basenav .navsep { border-top: 1px solid var(--line); margin: 4px 10px 3px; }
/* the Create page: a card per form a person makes by hand, grouped */
.newgroup {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 20px 0 6px; font-weight: 600;
}
.newcards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px; margin: 0 0 6px;
}
.newcard {
  display: block; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--panel); color: var(--ink);
  text-decoration: none;
}
.newcard:hover { border-color: var(--accent); }
.newcard .newtitle { display: block; font-weight: 600; margin-bottom: 3px; }
.newcard .newdesc {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--muted); font-size: 12.5px; line-height: 1.35;
}
/* the line under the Messages composer that leads there */
#composer .newhint { align-self: center; color: var(--muted); font-size: 13px; text-decoration: none; }
#composer .newhint:hover { color: var(--accent); }
/* a version field on the compose form: the server's number, shown not typed */
.versionfield { padding: 6px 0; font-size: 14px; }
.cm-editor .cm-lp-table .tablewrap { margin: 0; }
#basenav a {
  padding: 6px 10px; border-radius: var(--radius-lg); color: var(--ink);
  text-decoration: none; font-size: 14px; display: flex; justify-content: space-between;
}
#basenav a:hover { background: var(--chip); }
#basenav a.active { background: var(--chip); font-weight: 600; }
/* the view you arrived through: a lighter green than the active page, and not
   bold — it says "you're reading within this view", not "you are here" */
#basenav a.from {
  background: var(--chip);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
}
#basenav .count {
  background: var(--accent); color: var(--accent-ink); border-radius: 10px;
  font-size: 11px; padding: 1px 7px; align-self: center;
}
#sidebar-foot { margin-top: auto; }

/* main */
#main { flex: 1; padding: 26px 34px; max-width: 1080px; }
h2 { margin: 0 0 4px; font-size: 22px; font-family: var(--font-head); font-weight: 700; letter-spacing: -.01em; }
h3, h4 { font-family: var(--font-head); }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }

/* page navigation — the back button (to wherever you came from) and a light
   breadcrumb, above the title. A hash router has no referrer, so both read
   from the in-app navigation trail. */
.pagenav {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  margin: -6px 0 14px;
}
.backbtn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 4px 13px 4px 11px; font-size: 13px; cursor: pointer;
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.backbtn:hover { border-color: var(--accent); color: var(--accent); }
.crumbs { color: var(--muted); font-size: 12.5px; display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .csep { opacity: .5; }
.crumbs .here { color: var(--ink); }

/* dates a change actually happens on — chips under the header, not buried
   in the property grid */
.datechips { margin: 0 0 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip.cal { background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  border: 1px solid var(--line); color: var(--ink); }

/* a diagram, drawn low in the body: a mermaid field, or a derived design
   lifecycle. Full-width, centred, its own panel. */
.doc-diagram { padding: 16px 20px; }
.doc-diagram > .eyebrow { margin-bottom: 8px; }
.doc-diagram .sketch-orig { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* document header — the title carries the page, section is its eyebrow,
   summary is the lead. Emphasis lives here, not on the field labels. */
.doctitle {
  margin: 0 0 6px; font-size: 31px; line-height: 1.12;
  font-family: var(--font-head); font-weight: 700; letter-spacing: -.02em;
}
.lead {
  font-size: 16.5px; line-height: 1.5; color: var(--ink);
  margin: 0 0 10px; max-width: 68ch;
}
/* the body of a document gets the full width, unlabelled — it's the read */
.doc-body { padding: 20px 24px; }
.doc-body .md { font-size: 15.5px; line-height: 1.6; }
.doc-body .md > :first-child { margin-top: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }

/* buttons & inputs */
button {
  font: inherit; border: 0; border-radius: var(--radius); padding: 7px 14px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost {
  background: none; border: 1px solid var(--line); color: var(--ink);
}
button.danger { background: var(--danger); color: var(--danger-ink); }
button:disabled { opacity: .5; cursor: default; }
/* bracket flourish on primary buttons (bracket packs only) */
[data-brackets="on"] button.brackety::before { content: "[["; opacity: .55; margin-right: 4px; }
[data-brackets="on"] button.brackety::after  { content: "]]"; opacity: .55; margin-left: 4px; }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input.checkbox { width: auto; }
textarea.jsonfield { font-family: var(--font-mono); font-size: 12.5px; min-height: 120px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
/* Properties: a switch row — box, name, one line of what it does */
.propswitch { display: flex; gap: 10px; align-items: flex-start; color: var(--ink); font-size: 13.5px; margin: 8px 0; }
.propswitch input { width: auto; margin-top: 3px; flex: none; }
label:first-child { margin-top: 0; }
.req { color: var(--danger); }

/* state-gated sections: a form phase heading, and a locked field's value */
h3.formsec {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 18px 0 2px; padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
h3.formsec:first-child { margin-top: 0; }
h3.formsec.locked { opacity: .75; }
.fval.locked {
  font-size: 14px; color: var(--muted); padding: 6px 0 2px;
  white-space: pre-wrap; word-break: break-word;
}
.fieldgrid .fsec {
  grid-column: 1 / -1; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); margin-top: 10px;
  padding-bottom: 3px; border-bottom: 1px solid var(--line);
}

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--chip); }

/* view-table shaping: sortable, draggable, resizable headers */
th { position: relative; }
th .colsort {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-transform: inherit; letter-spacing: inherit; text-align: inherit;
  cursor: pointer;
}
th .colsort:hover { color: var(--ink); }
.sortmark { margin-left: 4px; font-size: 9px; }
th .colgrip {
  position: absolute; top: 0; right: -4px; width: 9px; height: 100%;
  cursor: col-resize; touch-action: none; user-select: none; z-index: 2;
}
th .colgrip:hover, th .colgrip.active { box-shadow: inset 3px 0 0 var(--accent); }
th.dropcol { box-shadow: inset 0 -2px 0 var(--accent); }
table.colsized th, table.colsized td { overflow-wrap: break-word; }
.when { white-space: nowrap; }

/* pinned first column: stays put while the table scrolls sideways */
.tablewrap.pinfirst th:first-child, .tablewrap.pinfirst td:first-child {
  position: sticky; left: 0; background: var(--panel); z-index: 1;
}
.tablewrap.pinfirst th:first-child { z-index: 3; }  /* above neighbours' grips */
.tablewrap.pinfirst tr.rowlink:hover td:first-child { background: var(--chip); }
.tablewrap.pinfirst tr.cat-head td { background: var(--chip); }

/* unread documents — a per-user mark. One skinnable class on the line: swap
   this rule to reskin. Deliberately NOT colour-only (WCAG 1.4.1) — the row
   also carries a ● dot and a screen-reader-only "Unread" label. */
tr.rowlink.unread td { font-weight: 600; }
tr.rowlink.unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.unread-dot { color: var(--accent); margin-right: 6px; font-size: 10px; vertical-align: middle; }
/* a link-styled button: the in-view "mark all read" affordance */
.linkbtn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline;
}
.linkbtn:hover { color: var(--ink); }
/* visually hidden but still announced by screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.cat-head td {
  font-weight: 700; background: var(--chip); font-size: 13px;
}
tr.cat-head { cursor: pointer; }
tr.cat-head:hover td { background: var(--line); }

/* twisties — the fold/unfold affordance on categories and response subtrees */
.twisty {
  background: none; border: 0; padding: 0 6px 0 0; cursor: pointer;
  font: inherit; color: var(--muted); line-height: 1;
}
.twisty:hover { color: var(--ink); }

/* response hierarchy: responses indent beneath the document they answer */
.indent { display: inline-block; }
.twisty-gap { display: inline-block; min-width: 16px; color: var(--muted); }
.respref { margin: 2px 0 10px; font-size: 13px; }
.responses .respitem { margin: 6px 0 0; }

/* the view designer: control grids over a $view's JSON */
.mono { font-family: var(--font-mono); font-size: 13px; }
.vd-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.vd-colrow { display: flex; gap: 6px; margin: 6px 0; align-items: center; }
.vd-colrow input, .vd-colrow select { margin: 0; }
.vd-colrow .vd-cf, .vd-colrow .vd-ff { flex: 0 0 170px; }
.vd-colrow .vd-cl { flex: 0 0 150px; }
.vd-colrow .vd-cc, .vd-colrow .vd-fv { flex: 1; min-width: 60px; }
.vd-colrow .vd-fo { flex: 0 0 auto; width: auto; }
.vd-colrow button { padding: 2px 9px; flex: 0 0 auto; }
.vd-check { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.vd-check input { width: auto; margin: 0; }
.vd-cgwrap {
  display: inline-flex; gap: 4px; align-items: center; cursor: pointer;
  padding: 0 4px; user-select: none;
}
.vd-cgwrap input { width: auto; margin: 0; }
#vd-chatlog { max-height: 260px; overflow-y: auto; }
#vd-chatlog .vd-chat { margin: 6px 0; }
#vd-chatlog .vd-chat-designer { color: var(--accent); }
#vd-chatlog .vd-chat-designer strong { color: var(--accent); }
@media (max-width: 640px) {
  .vd-grid2 { grid-template-columns: 1fr; }
  .vd-colrow { flex-wrap: wrap; }
}
.tablewrap { overflow-x: auto; }

/* the form designer: a $form's fields as a list, the selected one's
   properties beside it. Wider than a reading column, never edge to edge. */
#main:has(.fd-shell) { max-width: 1400px; }
.fd-shell fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fd-settings #fd-desc { max-width: 72ch; min-height: 64px; }
.fd-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; }
.fd-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.fd-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.fd-props textarea { min-height: 72px; }
.fd-props .fd-json textarea { min-height: 140px; font-size: 12.5px; }
.fd-props details { margin-top: 12px; }
.fd-props summary { cursor: pointer; font-size: 13px; }
.fd-preview { margin-top: 10px; padding: 8px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.fd-preview .staticblock { margin: 0; }
.fd-help { font-size: 12.5px; line-height: 1.45; margin: 4px 0 0; }
.fd-sec {
  margin: 14px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); padding-bottom: 3px; border-bottom: 1px solid var(--line);
}
.fd-sec:first-child { margin-top: 0; }
.fd-empty { font-size: 13px; margin: 6px 0; }
.fd-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 7px 10px 7px 6px; margin: 6px 0; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; background: var(--panel);
}
.fd-row:hover { border-color: var(--accent); }
.fd-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fd-row.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.fd-row.static .fd-main strong { font-weight: 500; font-style: italic; }
.fd-move { display: flex; flex-direction: column; gap: 2px; }
.fd-move button { padding: 0 7px; font-size: 11px; line-height: 16px; }
.fd-main { min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fd-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.fd-glyph { display: inline-block; min-width: 1.6em; text-align: center; color: var(--muted); font-size: 13px; }
.fd-name { font-size: 12px; }
.fd-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.fd-add { margin-top: 12px; align-items: center; }
.fd-add select { width: auto; }
/* a text block on a form: the form's own words between the fields */
.staticblock { margin: 14px 0 2px; }
.staticblock > :first-child { margin-top: 0; }
.staticblock + label { margin-top: 8px; }
/* design panels (client/formpanels.js): a design element's JSON drawn as
   fields — cards, groups, rows — with the JSON one click away */
.fp-panel > summary { font-size: 15px; }
.fp-panel > summary .fp-sum { font-weight: 400; font-size: 13px; margin-left: 8px; }
.fp-bar { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 8px 0 12px; }
.fp-bar .fd-help { margin: 0; max-width: 80ch; }
.fp-bar-btns { display: flex; gap: 6px; flex-shrink: 0; }
.fp-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 16px; align-items: start; }
.fp-aside { position: sticky; top: 12px; border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; }
.fp-aside .mermaid { margin: 0; }
.fp-group { margin-top: 14px; }
.fp-h { font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.fp-h .muted { font-weight: 400; }
.fp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; align-items: start; }
.fp-field { min-width: 0; margin-top: 10px; }
.fp-field > label { margin-top: 0; }
.fp-field.wide { max-width: 100%; }
.fp-leaf { display: block; }
.fp-leaf.mono input, .fp-leaf.mono textarea, input.fp-key, textarea.fp-json { font-family: var(--font-mono); font-size: 12.5px; }
.fp-leaf[data-t="code"] textarea { min-height: 110px; white-space: pre; overflow-x: auto; }
textarea.fp-json { min-height: 260px; }
.fp-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.fp-item-head { display: flex; align-items: center; gap: 8px; }
.fp-item-head input.fp-key { max-width: 22em; font-weight: 600; }
.fp-item-head .fp-x, .fp-rowitem .fp-x { margin-left: auto; }
.fp-rowitem { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.fp-rowitem .fp-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; }
.fp-rowitem .fp-row > .fp-leaf, .fp-rowitem .fp-row > .fp-pick { flex: 1 1 140px; min-width: 0; }
.fp-arrow { color: var(--muted); }
.fp-x { padding: 2px 8px; }
.fp-pick { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.fp-pick select, .fp-pick input { min-width: 0; flex: 1 1 9em; }
.fp-refs { display: block; }
.fp-refs .fp-mode { margin-bottom: 6px; }
.fp-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.fp-checks[hidden], .fp-pick .fp-other[hidden] { display: none; }
label.fp-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--ink); white-space: nowrap; }
label.fp-check input { width: auto; margin: 0; }
.fp-panel [aria-invalid="true"] { border-color: var(--danger); }
@media (max-width: 900px) {
  .fd-body { grid-template-columns: 1fr; }
  .fd-side { position: static; max-height: none; }
  .fp-split { grid-template-columns: 1fr; }
  .fp-aside { position: static; }
}

/* chips & states */
.chip {
  display: inline-block; background: var(--chip); border-radius: 10px;
  padding: 1px 9px; font-size: 12px; color: var(--ink);
}
.chip.state { background: var(--accent); color: var(--accent-ink); }
/* a response row's own line, drawn across the parent's columns: what kind
   of record it is, what it calls itself, the state it is in */
.respline .chip.kind { background: var(--line); color: var(--muted); margin-right: 8px; }
.respline .chip.state { margin-left: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: .6em; }
button.chip { border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 12px; }
button.chip:hover { background: var(--accent); color: var(--accent-ink); }
.chip.warn { background: var(--warn); color: var(--warn-ink); }
.chip.danger { background: var(--danger); color: var(--danger-ink); }

/* tag pills — read-only in the value cell, removable in the editor */
.pillrow { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--chip); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 11px; font-size: 12.5px; line-height: 1.7;
}
.tag button {
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  color: var(--muted); font-size: 11px; line-height: 1;
}
.tag button:hover { color: var(--danger); }
/* a clickable tag pill (read view): click for a focused read of the subject */
button.tag-link { font: inherit; cursor: pointer; transition: background .12s, color .12s; }
button.tag-link:hover, button.tag-link:focus-visible {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); outline: none;
}

/* tag focus — a subject-scoped read that streams in over the document */
#tagfocus:empty { display: none; }
.card.focus { border-left: 3px solid var(--accent); animation: focusin .25s ease; }
@keyframes focusin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.focushead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.focushead .eyebrow { margin: 0; }
.focushead button { padding: 2px 8px; font-size: 12px; }
.focusbody { white-space: pre-wrap; line-height: 1.6; font-size: 15px; min-height: 1.2em; }
.focusbody.typing::after {
  content: "▍"; color: var(--accent); margin-left: 1px;
  animation: caret 1.05s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.tagfield .taglist:empty { display: none; }
.tagfield .taglist { margin-bottom: 8px; }
.tagfield .taginput { max-width: 320px; }

/* participants — a person pill carries a kind, so a transcript says at a
   glance who in the room was a human and who was a model */
.peoplefield .peoplelist:empty { display: none; }
.peoplefield .peoplelist { margin-bottom: 8px; }
.peopleadd { display: flex; gap: 6px; align-items: center; }
.peopleadd .peopleinput { max-width: 260px; }
.peopleadd .peoplekind { width: auto; font-size: 12.5px; padding: 4px 6px; }
.tag.person.ai { border-style: dashed; color: var(--muted); }

/* the type-ahead a field's `source` produces: suggestions, never a fence —
   whatever you type still stands */
.tagfield, .peoplefield, .pickfield { position: relative; }
/* a single-value lookup wears the select's clothes: chevron on the right,
   click opens the list — same component to the eye, live list underneath */
.pickfield input { padding-right: 30px; }
.pickfield::after {
  content: "▾"; position: absolute; right: 11px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: var(--muted); font-size: 13px; line-height: 1;
}
.suggest {
  position: absolute; z-index: 40; left: 0; top: 100%; margin-top: 4px;
  min-width: 260px; max-width: 420px; max-height: 250px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.suggestrow {
  display: flex; justify-content: space-between; gap: 12px; width: 100%;
  background: none; border: 0; border-radius: 0; text-align: left;
  padding: 6px 11px; font: inherit; font-size: 13.5px; color: var(--ink);
  cursor: pointer;
}
.suggestrow .muted { font-size: 12.5px; }
.suggestrow:hover, .suggestrow.on { background: var(--accent); color: var(--accent-ink); }
.suggestrow:hover .muted, .suggestrow.on .muted { color: var(--accent-ink); opacity: .8; }

/* floor pickers (client/pickers.js): a short list is tapped, not typed. A
   radio group of big buttons over the field's own input or select, which
   stays in the page as the value (and as where a `required` message points)
   but out of sight and out of the tab order while the buttons stand. */
.tapfield { position: relative; }
.taplist { display: flex; flex-wrap: wrap; gap: 10px; margin: 2px 0 4px; }
.taplist .tap {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 48px; min-width: 96px; max-width: 100%; padding: 8px 18px;
  font: inherit; font-size: 17px; line-height: 1.25; text-align: left;
  background: var(--panel); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.taplist .tap .taplabel { overflow-wrap: anywhere; }
.taplist .tap .tapnote { font-size: 12.5px; color: var(--muted); }
.taplist .tap:hover { border-color: var(--accent); }
.taplist .tap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.taplist .tap.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.taplist .tap.on::before { content: "✓ "; }
.taplist .tap.on .taplabel { display: inline; }
.taplist .tap.on { flex-direction: row; align-items: center; gap: 2px; }
.taplist .tap.on .tapnote { color: var(--accent-ink); opacity: .85; margin-left: 8px; }
.taplist .tap.tapother { border-style: dashed; }
.tapsaid { margin: 2px 0 6px; font-size: 13.5px; }
.pickfield.taps:not(.tapother-open) > input, .tapfield.taps > select {
  position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}
.pickfield.taps:not(.tapother-open)::after { content: none; }
.pickfield.taps.tapother-open > input { max-width: 420px; }
.pickfield.taps.tapother-open::after { top: auto; bottom: 12px; transform: none; }
@media (pointer: coarse) {
  .taplist { gap: 12px; }
  .taplist .tap { min-height: 56px; min-width: 120px; font-size: 19px; padding: 10px 22px; }
}
@media print { .taplist .tap:not(.on) { display: none; } }
/* the picking card inside the field's properties panel: one narrow column */
.fd-pick { margin: 10px 0; }
.fd-pick .fp-panel { padding: 10px 12px; box-shadow: none; margin: 0; }
.fd-pick .fp-bar { flex-direction: column; align-items: stretch; gap: 6px; }
.fd-pick .fp-grid { grid-template-columns: 1fr; }

/* doc fields */
.fieldgrid { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.fieldgrid .fname { color: var(--muted); font-size: 13px; padding-top: 2px; }
.fieldgrid .fval { white-space: pre-wrap; word-break: break-word; }
.fieldgrid .fval .pillrow { white-space: normal; }
/* an audio attachment playing in place of its ▶ chip */
.fieldgrid .fval audio { height: 32px; vertical-align: middle; max-width: 100%; }
/* read-only: a design element shown as fields, not raw JSON. Code and
   structure keep their own scrollable panels so long values stay legible. */
.fieldgrid.ro {
  align-items: start;
  /* the label column hugs its longest label; minmax(0, …) keeps a long
     unbreakable line from pushing the value column out of the card */
  grid-template-columns: fit-content(220px) minmax(0, 1fr);
}
.fieldgrid.ro .fval pre {
  margin: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; overflow: auto;
  max-height: 320px; font-size: 12.5px; font-family: var(--font-mono);
  white-space: pre; word-break: normal;
  max-width: 80ch;   /* a reading width — the box stops well short of a wide screen's edge */
}
.fieldgrid.ro .fval pre.ro-text { font-family: var(--font-body); font-size: 14px; white-space: pre-wrap; }

/* mermaid field — a diagram authored as text, with a live preview */
.mermaidfield textarea { font-family: var(--font-mono); font-size: 12.5px; min-height: 120px; }
.mmdpreview {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-top: 8px; background: var(--bg);
}

/* markdown fields */
.md { white-space: normal; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; }
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li.task { list-style: none; margin-left: -18px; }
.md blockquote {
  border-left: 3px solid var(--line); margin: 0 0 8px;
  padding: 2px 12px; color: var(--muted);
}
.md pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; overflow-x: auto; font-size: 13px; font-family: var(--font-mono);
}
.md code { background: var(--chip); border-radius: 4px; padding: 1px 5px; font-size: 13px; font-family: var(--font-mono); }
.md pre code { background: none; padding: 0; }
/* mermaid diagrams: a ```mermaid block, rendered inline in the markdown.
   The engine measures label widths in the page's body font, so the rendered
   SVG must use it too (the surrounding `.md pre` is monospace) — otherwise
   labels are measured narrow and clipped. */
.md pre.mermaid { text-align: center; overflow-x: auto; font-family: var(--font-body); }
.md pre.mermaid svg text { font-family: var(--font-body); }
.md pre.mermaid:not(.mermaid-ready):not(.mermaid-error) {
  /* pre-render / lazy-loading the engine: show the source, faint */
  color: var(--muted); opacity: .6; white-space: pre-wrap; text-align: left;
}
.md pre.mermaid.mermaid-ready { background: none; border: none; padding: 0; }
.md pre.mermaid svg { max-width: 100%; height: auto; }
.md pre.mermaid.mermaid-error { border-left: 3px solid var(--danger); white-space: normal; }
.md pre.mermaid .mermaid-err { color: var(--danger); font-weight: 600; margin-bottom: 4px; }
.md pre.mermaid.mermaid-error pre { margin: 6px 0 0; opacity: .7; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md .tablewrap { margin: 0 0 8px; }
.md table { font-size: 13.5px; }
/* wikilinks: [[Page title]] — solid when the page exists, red-dashed when
   it doesn't (click a red link to create the page) */
.md a.wikilink { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }
.md a.wikilink.missing { color: var(--danger); border-bottom: 1px dashed var(--danger); }
.md img.mdembed {
  max-width: 100%; border-radius: var(--radius);
  border: 1px solid var(--line); margin: 4px 0 8px; display: block;
}
.card.backlinks p { margin: 6px 0 0; }
.card.backlinks a { color: var(--accent); text-decoration: none; }
.mdbar { margin: 6px 0 0; }
.mdbar button.on { background: var(--chip); border-color: var(--accent); }
.mdpreview {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 6px;
}

/* ---------- WYSIWYG markdown editor (NotesEditor / CodeMirror) ----------
   The document is plain markdown; these classes are decorations laid over it
   by client/editor.js. Everything reads the design-pack tokens so the editor
   themes with the rest of the app (light/dark, all packs). */
.mdfield { position: relative; }
/* a markdown field is a document, not a remark box — start it roomy
   (the raw textarea matches, for source mode and the no-engine fallback) */
.mdfield textarea { min-height: 220px; }
.cm-wrap { margin-top: 0; }

/* the formatting toolbar (editor-tools.js), attached to the editor's top.
   The row holds the markdown-writing buttons; what doesn't fit moves into
   the "⋯" menu (where buttons show their full labels); the right group is
   the mode/insert actions and never collapses. */
.mdtools {
  position: relative; display: flex; gap: 6px; align-items: center;
  /* inline-size containment: the buttons must never widen the page — the
     toolbar takes the field's width and overflow moves into the ⋯ menu */
  contain: inline-size;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; padding: 4px 6px;
}
.mdfield .cm-editor,
.mdfield textarea:not(.cm-src-hidden) { border-top-left-radius: 0; border-top-right-radius: 0; }
.mdtools-row {
  display: flex; gap: 2px; align-items: center;
  flex: 1 1 auto; min-width: 0; overflow: hidden;
}
.mdtools-row .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; flex: none; }
.mdtools-row button, .mdtools-menu button, .mdtools-more {
  background: none; border: 0; border-radius: var(--radius); color: var(--ink);
  min-width: 28px; height: 26px; padding: 2px 6px; font-size: 13px;
  cursor: pointer; flex: none; line-height: 1;
}
.mdtools-row button:hover, .mdtools-menu button:hover, .mdtools-more:hover { background: var(--chip); }
.mdtools-row button.on, .mdtools-menu button.on { background: var(--accent); color: var(--accent-ink); }
.mdtools button:focus-visible, .mdtools-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mdtools .glyph { font-family: var(--font-body); }
.mdtools .glyph.tg-b { font-weight: 700; }
.mdtools .glyph.tg-i { font-style: italic; }
.mdtools .glyph.tg-s { text-decoration: line-through; }
.mdtools .mlbl { display: none; }
.mdtools-menu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; flex-direction: column; gap: 2px; min-width: 180px;
}
.mdtools-menu.open { display: flex; }
.mdtools-menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.mdtools-menu button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; }
.mdtools-menu .glyph { min-width: 26px; text-align: center; }
.mdtools-menu .mlbl { display: inline; }
.mdtools-right { display: flex; gap: 4px; margin-left: auto; align-items: center; flex: none; }
.mdtools-right button.on { background: var(--chip); border-color: var(--accent); }
@media (max-width: 980px) { .mdtools-right .lbl { display: none; } }
/* The backing textarea is the form value; hide it behind the editor WITHOUT
   display:none so a `required` field stays focusable and native validation
   (and its bubble) still works. Toggled to visible in "Source" mode. */
.mdfield textarea.cm-src-hidden {
  position: absolute; top: 0; left: 0; z-index: -1;
  width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0;
  border: 0; opacity: 0; overflow: hidden; resize: none; pointer-events: none;
}
.cm-editor {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
.cm-editor.cm-focused { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cm-editor .cm-scroller {
  font-family: var(--font-body); line-height: 1.6;
  overflow-x: auto;
}
.cm-editor .cm-content { padding: 10px 12px; min-height: 216px; caret-color: var(--accent); }
.cm-editor .cm-line { padding: 0; }
.cm-editor .cm-placeholder { color: var(--muted); }

/* headings — mirror the read view's serif display face */
.cm-editor .cm-lp-h { font-family: var(--font-head); font-weight: 700; color: var(--ink); line-height: 1.25; letter-spacing: -.01em; }
.cm-editor .cm-lp-h1 { font-size: 1.7em; }
.cm-editor .cm-lp-h2 { font-size: 1.45em; }
.cm-editor .cm-lp-h3 { font-size: 1.25em; }
.cm-editor .cm-lp-h4 { font-size: 1.1em; }
.cm-editor .cm-lp-h5 { font-size: 1em; }
.cm-editor .cm-lp-h6 { font-size: .92em; color: var(--muted); }

/* inline spans */
.cm-editor .cm-lp-strong { font-weight: 700; }
.cm-editor .cm-lp-em { font-style: italic; }
.cm-editor .cm-lp-strike { text-decoration: line-through; color: var(--muted); }
.cm-editor .cm-lp-code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--chip); border-radius: 4px; padding: 1px 4px;
}
.cm-editor .cm-lp-link { color: var(--accent); }
.cm-editor .cm-lp-wikilink,
.cm-editor .cm-lp-embed { color: var(--accent); border-bottom: 1px solid var(--accent); }

/* blocks */
.cm-editor .cm-lp-quote {
  border-left: 3px solid var(--line); color: var(--muted);
  padding-left: 10px; font-style: italic;
}
.cm-editor .cm-lp-codeblock {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--chip);
}
.cm-editor .cm-lp-hr {
  border-bottom: 1px solid var(--line);
  color: transparent; line-height: .1;
}
.cm-editor .cm-line.cm-lp-hr::selection,
.cm-editor .cm-lp-hr *::selection { color: var(--ink); }

/* GFM task checkbox rendered inline */
.cm-editor .cm-lp-checkbox { width: auto; margin: 0 4px 0 0; vertical-align: -1px; cursor: pointer; accent-color: var(--accent); }
.cm-editor .cm-lp-taskmark { font-family: var(--font-mono); color: var(--muted); }
.cm-editor .cm-lp-bullet { color: var(--accent); }

/* block embeds inside the editor: ```mermaid diagrams and ```sketch drawings
   (client/editor-blocks.js). Click one to put the caret in it and get the
   source back. */
.cm-editor .cm-lp-block {
  margin: 8px 0; padding: 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); cursor: default;
}
.cm-editor .cm-lp-block svg { max-width: 100%; height: auto; }
.cm-lp-blockbar { display: flex; gap: 6px; margin-top: 8px; }
.cm-lp-blockbar button { padding: 2px 8px; font-size: 12px; }

/* Focus mode ("⛶ Expand", app.js wireFields): the field takes over the
   viewport like a full-size compose window. Pure CSS — the field stays inside
   its <form> (never reparented), so save/readForm/validation are untouched.
   z-index sits UNDER .modal-back (60) so the sketch modal still opens on top. */
.mdfield.mdmax {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; align-items: center;
  padding: 3vh 16px;
}
.mdfield.mdmax .cm-wrap,
.mdfield.mdmax .mdtools,
.mdfield.mdmax textarea:not(.cm-src-hidden) { width: min(980px, 100%); }
.mdfield.mdmax .cm-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mdfield.mdmax .cm-editor { flex: 1; min-height: 0; }
.mdfield.mdmax .cm-editor .cm-scroller { overflow-y: auto; overscroll-behavior: contain; }
.mdfield.mdmax textarea:not(.cm-src-hidden) { flex: 1; min-height: 0; resize: none; }
body.mdmax-open { overflow: hidden; }

/* The edit box stays within the screen. A long document (an SOP's procedure
   runs to pages) used to grow the editor to its full length, so the form's
   header and actions scrolled away while writing; now the editor is capped
   and the document scrolls inside it, the toolbar staying in reach. Expand
   mode (.mdmax) sizes itself by flex above and is left alone. (Jamie's
   second pass over the creamery demo, 25 Oct 2026.) */
.mdfield:not(.mdmax) .cm-editor { max-height: 70vh; }
.mdfield:not(.mdmax) .cm-editor .cm-scroller { overflow-y: auto; overscroll-behavior: contain; }
.mdfield:not(.mdmax) textarea:not(.cm-src-hidden) { max-height: 70vh; }

/* sketches embedded in markdown, read view + editor widget */
.sketchembed { text-align: center; }
.sketchembed svg { max-width: 100%; height: auto; }

/* modal — the sketch pad, opened from inside a note */
.modal-back {
  position: fixed; inset: 0; z-index: 60; padding: 16px;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 18px; width: min(860px, 100%); max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 10px; font-family: var(--font-head); }
.modal .row-actions { margin-bottom: 0; }
/* give the in-note pad more paper than the inline 320px default */
.modal canvas.sketchpad { height: min(58vh, 520px); }

/* attachment fields — DAOS-style refs rendered as chips */
.attachlist { margin: 4px 0 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.attachlist .chip button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 0 0 0 4px; font-size: 12px;
}
.attachlist .chip button:hover { color: var(--danger); }
button.chip { border: 1px solid var(--line); cursor: pointer; }
button.chip:hover { border-color: var(--accent); }

/* sketchnote fields — the canvas is paper: always light */
.sketchbar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.sketchbar button {
  background: none; border: 1px solid var(--line); color: var(--ink);
  padding: 3px 9px; border-radius: var(--radius); font-size: 14px; min-width: 32px;
}
.sketchbar button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sketchbar .swatch { width: 22px; height: 22px; min-width: 22px; padding: 0; border-radius: 50%; }
.sketchbar .swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.sketchbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
canvas.sketchpad {
  width: 100%; height: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); touch-action: none; cursor: crosshair; display: block;
}
svg.sketchview {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  max-width: 100%; height: auto;
}

/* misc */
.answer { white-space: pre-wrap; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 10px 0; }
.spinner { color: var(--muted); font-style: italic; }
pre.json {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; overflow-x: auto; font-size: 12.5px; font-family: var(--font-mono);
}
.proposal { border-left: 3px solid var(--warn); }

/* theme picker (preferences) */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.swatch-card {
  border: 2px solid var(--line); border-radius: var(--radius-lg); padding: 8px 10px;
  cursor: pointer; background: var(--panel); color: var(--ink); text-align: left; min-width: 118px;
}   /* color: a button's default ink is --accent-ink, which left the pack names white on the card */
.swatch-card.on { border-color: var(--accent); }
.swatch-card .dots { display: flex; gap: 4px; margin-bottom: 6px; }
.swatch-card .dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); }
.swatch-card .lbl { font-size: 13px; font-weight: 600; }

/* unified message stream */
#stream { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.msg {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 10px 14px; max-width: 88%; box-shadow: var(--shadow);
}
.msg.user { align-self: flex-end; background: var(--chip); }
.msg.ai { align-self: flex-start; }
.msg.system { align-self: center; border-style: dashed; color: var(--muted); }
.msg.agent { align-self: flex-start; border-left: 3px solid var(--warn); }
.msg.agent.pending { border-left-color: var(--accent); }
/* an unread message: the same accent bar as an unread row, plus the ● dot */
.msg.unread { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
/* a proposal mid-decision: dimmed and inert until it re-renders, so a click
   reads as "acted on" instantly and can't be double-fired (stream + inbox) */
.deciding { opacity: .55; pointer-events: none; transition: opacity .12s; }
/* the reject-reason box that replaces the buttons when you click Reject */
.rejreason { width: 100%; margin-top: 4px; resize: vertical; font: inherit; }
.rejbar { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.rejgo:disabled { opacity: .5; cursor: not-allowed; }
.msghead { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.badge {
  display: inline-block; border-radius: 9px; padding: 0 8px; font-size: 11.5px;
  font-weight: 600; border: 1px solid var(--line);
}
.badge.human { background: var(--accent); color: var(--accent-ink); border: 0; }
.badge.ai { background: var(--chip); }
.badge.agent { background: var(--warn); color: var(--warn-ink); border: 0; }
.badge.sys { background: var(--chip); color: var(--muted); }
/* The model tier that served an AI reply — a class word, never a model name */
.tier-chip {
  display: inline-block; border-radius: 9px; padding: 0 7px; font-size: 10.5px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); background: var(--chip); color: var(--muted);
}
.tier-chip.tier-frontier { border-color: var(--accent); color: var(--accent); }
.tier-chip.tier-secure { border-color: var(--ok, #2e7d32); color: var(--ok, #2e7d32); }
.tier-chip.tier-pinned { border-style: dashed; }
.brief-tier { margin-top: 8px; }
.msgbody { white-space: pre-wrap; }
.msgrefs { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.msgrefs a.chip { text-decoration: none; }
.msgfields { margin-top: 8px; font-size: 13.5px; }
.evt { font-size: 12.5px; color: var(--muted); padding: 0 6px; }
#composer { position: sticky; bottom: 12px; }
#composer textarea { min-height: 44px; }
.timeline { font-size: 13px; }
.timeline td { padding: 4px 10px; }
/* version history: a revision list with per-revision diffs and restore */
.card.history .revlist { list-style: none; margin: 8px 0 0; padding: 0; }
.card.history .rev { padding: 8px 0; border-top: 1px solid var(--line); }
.card.history .rev:first-child { border-top: 0; }
.card.history .rev.current { opacity: .85; }
.rev-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rev-n { font-weight: 600; font-size: 13px; }
.rev-meta { color: var(--muted); font-size: 12.5px; }
.rev-head .rev-restore { margin-left: auto; padding: 3px 9px; font-size: 12px; }
.rev-changes { margin-top: 5px; display: flex; gap: 5px; flex-wrap: wrap; font-size: 12.5px; }
.chip.diff { font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px;
  padding: 1px 6px; border: 1px solid var(--line); }
.chip.diff.add { background: color-mix(in srgb, var(--ok) 16%, var(--panel)); color: var(--ink); }
.chip.diff.chg { background: color-mix(in srgb, var(--warn) 18%, var(--panel)); color: var(--ink); }
.chip.diff.del { background: color-mix(in srgb, var(--danger) 14%, var(--panel)); color: var(--ink); }
.revdiff { margin-top: 6px; }
.revdiff > summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.revdiff .drow { display: flex; gap: 8px; align-items: baseline; padding: 3px 0;
  font-size: 12.5px; flex-wrap: wrap; }
.revdiff .dk { min-width: 96px; color: var(--muted); font-weight: 600; }
.revdiff .dv { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px;
  padding: 1px 6px; border-radius: var(--radius); word-break: break-word; }
.revdiff .dv.add { background: color-mix(in srgb, var(--ok) 15%, var(--panel)); }
.revdiff .dv.del { background: color-mix(in srgb, var(--danger) 13%, var(--panel));
  text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.revdiff .darr { color: var(--muted); }
/* the designer's byline + its own history panel */
.wfby { color: var(--muted); }
.wfhist { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.wfhist .revlist { list-style: none; margin: 6px 0 0; padding: 0; }
.wfhist .rev { padding: 6px 0; border-top: 1px solid var(--line); }
.wfhist .rev:first-child { border-top: 0; }
/* reading preferences */
body.font-dyslexic {
  --font-body: Verdana, "Trebuchet MS", system-ui, sans-serif;
  letter-spacing: .04em; word-spacing: .12em;
}
body.font-dyslexic h2, body.font-dyslexic h3, body.font-dyslexic h4 { font-family: var(--font-body); }
body.size-large { font-size: 17px; }
body.size-xlarge { font-size: 19px; }
body.density-spacious { line-height: 1.85; }
body.density-spacious .card { padding: 24px 26px; margin-bottom: 22px; }
body.density-spacious td { padding: 12px 10px; }
details summary { cursor: pointer; font-weight: 600; }

/* mobile */
#menu-toggle {
  display: none; position: fixed; top: 10px; left: 10px; z-index: 20;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 11px; font-size: 17px;
}
@media (max-width: 760px) {
  #menu-toggle { display: block; }
  #sidebar {
    position: fixed; left: 0; top: 0; z-index: 10; height: 100vh;
    background: var(--bg); transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  #main { padding: 54px 16px 16px; }
  .fieldgrid { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
}

/* reports / metrics */
#reportgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.card.metric { margin: 0; }
.metric-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.metric-big { font-size: 26px; font-weight: 700; color: var(--accent); }
.metric-big .muted { font-size: 12px; font-weight: 400; }
.metricbars { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.metricbar { display: grid; grid-template-columns: 100px 1fr 44px; align-items: center; gap: 8px; }
.mb-label { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-track { background: var(--line); border-radius: 5px; height: 9px; overflow: hidden; }
.mb-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.mb-val { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.card.metric table { font-size: 12.5px; margin-top: 10px; }
@media (max-width: 760px) { #reportgrid { grid-template-columns: 1fr; } }

/* ---------- Excalibur — the visual workflow designer ----------
 * A node graph over a $workflow document: node = step, wire = `next`.
 * Node hues key the eight step types. approval/agent/script borrow semantic
 * tokens; update/action/notify/condition use mid-tones that hold up on light
 * and dark packs alike, and a design pack may override them like any token.
 *
 * `http` is deliberately the loudest node on the canvas — it is the only step
 * that leaves the Base, and you should never have to read the JSON to notice
 * one. It borrows the danger token and wears a dashed edge.
 */
:root {
  --wf-approval: var(--warn);
  --wf-agent: var(--accent);
  --wf-script: var(--muted);
  /* the four step hues are the pack's own colours, mixed — a brand changes them with its tokens */
  --wf-update: color-mix(in srgb, var(--accent) 70%, var(--ink));
  --wf-action: color-mix(in srgb, var(--accent) 55%, var(--danger));
  --wf-notify: color-mix(in srgb, var(--accent) 60%, var(--panel));
  --wf-condition: color-mix(in srgb, var(--warn) 70%, var(--ink));
  --wf-http: var(--danger, #b3402f);
  --wf-hook: var(--ok, #606b53);
}
/* the graph wants the room a reading column doesn't */
#main:has(.wfshell) { max-width: none; }

.wfshell { display: flex; flex-direction: column; gap: 12px; }
.wftop { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.wftop .row-actions { margin: 0; align-items: center; }
.wfheading { margin: 0 0 4px; font-size: 22px; font-family: var(--font-head); font-weight: 700; }
.wftop .sub { margin-bottom: 0; }
#wfdirty { font-size: 12.5px; }

.wfpalette {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.wfpalette button { padding: 5px 10px; font-size: 13px; }

.wfbody { display: grid; grid-template-columns: 1fr 330px; gap: 12px; }
.wfhost { min-width: 0; }

.wfcanvas {
  position: relative; overflow: hidden; height: 64vh; min-height: 440px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 18px 18px;
  touch-action: none; cursor: grab;
}
.wfcanvas:active { cursor: grabbing; }
.wfworld { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wfedges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wfnodes { position: absolute; left: 0; top: 0; }

/* nodes */
.wfnode {
  position: absolute; padding: 9px 12px 15px;
  background: var(--panel); box-shadow: var(--shadow);
  border: 1px solid var(--line); border-left: 3px solid var(--wf-c, var(--accent));
  border-radius: var(--radius-lg); cursor: grab; user-select: none;
}
.wfnode:active { cursor: grabbing; }
/* a ring, not a border swap — the left stripe must keep saying which type it is */
.wfnode.sel { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.wfnode[data-type="approval"] { --wf-c: var(--wf-approval); }
.wfnode[data-type="agent"]    { --wf-c: var(--wf-agent); }
.wfnode[data-type="update"]   { --wf-c: var(--wf-update); }
.wfnode[data-type="action"]   { --wf-c: var(--wf-action); }
.wfnode[data-type="notify"]   { --wf-c: var(--wf-notify); }
.wfnode[data-type="script"]    { --wf-c: var(--wf-script); }
.wfnode[data-type="condition"] { --wf-c: var(--wf-condition); }
/* the door out of the Base: dashed border, so it reads as a boundary */
.wfnode[data-type="http"] {
  --wf-c: var(--wf-http);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--wf-http) 55%, var(--line));
}

.wfnode-head { display: flex; align-items: center; gap: 6px; }
.wfnode-icon { color: var(--wf-c); font-size: 14px; }
.wfnode-type {
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted);
}
.wfstart, .wfstate {
  margin-left: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 20px; white-space: nowrap;
}
.wfstart { background: var(--accent); color: var(--accent-ink); }
.wfstate { background: var(--chip); color: var(--ink); }
/* the door IN: a signed external webhook that starts this flow. Dashed green,
   the mirror of the http node's dashed red — an inbound trust boundary should
   be as legible on the canvas as an outbound one. */
.wfhook {
  margin-left: 6px; font-size: 10.5px; padding: 1px 7px; border-radius: 20px;
  white-space: nowrap; color: var(--wf-hook);
  border: 1px dashed color-mix(in srgb, var(--wf-hook) 60%, var(--line));
}
.wfnode-id { font-family: var(--font-mono); font-size: 13px; margin-top: 3px; }
.wfnode-sum { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.wfnode-hint { font-size: 11px; color: var(--muted); margin-top: 5px; font-style: italic; }
.wfnode-hint code { font-style: normal; }

/* ports: drag from an out-port onto a node to wire them up */
.wfport {
  position: absolute; width: 13px; height: 13px; margin-left: -6.5px;
  display: grid; place-items: center; font-size: 8px; line-height: 1;
  background: var(--panel); border: 2px solid var(--wf-c, var(--accent)); border-radius: 50%;
}
.wfport.in { top: -7px; }
.wfport.out { bottom: -7px; cursor: crosshair; }
.wfport.out:hover { transform: scale(1.3); }
.wfport.reject { border-color: var(--danger); color: var(--danger); }
/* a condition's branches are numbered along the bottom edge; ∗ is the fallback */
.wfport.branch, .wfport.otherwise { border-color: var(--wf-condition); color: var(--wf-condition); }
.wfport.otherwise { border-style: dashed; }
.wfcanvas.ro .wfnode, .wfcanvas.ro .wfport.out { cursor: default; }
.wfcanvas.ro .wfport.out:hover { transform: none; }

/* wires */
.wfedge { fill: none; stroke: var(--muted); stroke-width: 2; }
.wfedge.reject { stroke: var(--danger); stroke-dasharray: 5 4; }
.wfedge.branch { stroke: var(--wf-condition); }
.wfedge.otherwise { stroke: var(--wf-condition); stroke-dasharray: 5 4; opacity: .8; }
.wfedge.branch.taken, .wfedge.otherwise.taken { stroke: var(--accent); stroke-width: 3; }
.wfedge.preview { stroke: var(--accent); stroke-dasharray: 4 4; }
.wfedge.taken { stroke: var(--accent); stroke-width: 3; }
.wfedge.reject.taken { stroke: var(--danger); stroke-width: 3; }
.wfedge.untaken { opacity: .32; }
.wfedge.jump { stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 2 5; }
marker.m-next path   { fill: var(--muted); }
marker.m-reject path { fill: var(--danger); }
marker.m-taken path  { fill: var(--accent); }
marker.m-jump path   { fill: var(--muted); }

/* a run, drawn on its own graph */
.wfnode.idle { opacity: .5; }
.wfnode.done { border-color: var(--ok); border-left-color: var(--wf-c); }
.wfnode.done .wfnode-type::after { content: " ✓"; color: var(--ok); font-weight: 700; }
.wfnode.error, .wfnode.rejected { border-color: var(--danger); border-left-color: var(--wf-c); }
.wfnode.error .wfstate, .wfnode.rejected .wfstate { background: var(--danger); color: var(--danger-ink); }
.wfnode.current {
  border-color: var(--accent); border-left-color: var(--wf-c);
  animation: wfpulse 1.8s ease-in-out infinite;
}
.wfnode.current .wfstate { background: var(--accent); color: var(--accent-ink); }
@keyframes wfpulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent), var(--shadow); }
  50%      { box-shadow: 0 0 0 4px var(--chip), var(--shadow); }
}
.card.wfwait { border-left: 3px solid var(--warn); margin: 0; }

/* zoom control */
.wfzoom {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 3px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.wfzoom button { background: none; color: var(--ink); padding: 3px 10px; font-size: 14px; }
.wfzoom button:hover { background: var(--chip); filter: none; }

/* inspector */
.wfside {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 12px 14px; max-height: 64vh; overflow-y: auto;
}
.wfside-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.wfside-head button { padding: 3px 8px; font-size: 12px; }
.wfside .timeline { width: 100%; font-size: 12.5px; }
.wfform fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.wfform textarea { min-height: 96px; }
.wfhelp { font-size: 12.5px; line-height: 1.5; margin-top: 14px; }

/* lint strip — warnings, never a block */
.wflint {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--warn); border-radius: var(--radius-lg);
  padding: 10px 14px; font-size: 13px;
}
.wflint:has(.ok) { border-left-color: var(--ok); }
.wflint ul { margin: 6px 0 0; padding-left: 18px; }
.wflint li { color: var(--muted); margin: 2px 0; }
.wflint .ok { color: var(--ok); }

@media (max-width: 900px) {
  .wfbody { grid-template-columns: 1fr; }
  .wfside { max-height: none; }
  .wfcanvas { height: 52vh; }
}

/* the condition inspector: one row per branch, so a branch reads as a wire
   with a test on it rather than a JSON blob */
.wfbranches { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.wfbranch {
  border: 1px solid var(--line); border-left: 3px solid var(--wf-condition);
  border-radius: 6px; padding: 8px 10px;
}
.wfbranch-top { display: flex; align-items: center; gap: 6px; }
.wfbranch-top input { flex: 1; }
.wfbranch-n {
  display: grid; place-items: center; width: 18px; height: 18px; flex: none;
  border-radius: 50%; background: var(--wf-condition); color: var(--accent-ink);
  font-size: 11px; font-weight: 700;
}
.wfbranch .mono, .wfform input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.wfcheck { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.wfcheck input { width: auto; }
/* the start pin doubles as the trigger control */
.wfcanvas:not(.ro) .wfstart { cursor: pointer; }
.wfcanvas:not(.ro) .wfstart:hover { filter: brightness(1.15); }
/* a step's output is JSON: let it wrap rather than push the panel sideways */
.wfout { overflow-wrap: anywhere; font-size: 12px; }

/* the in-base switcher: ⌂ Desktop above the current Base and its connected
   companions boxed as one group — the full Base list lives on the Desktop */
#desktop-link, #feed-link {
  display: block; padding: 6px 10px; margin-bottom: 4px;
  border-radius: var(--radius-lg); color: var(--muted);
  text-decoration: none; font-size: 13px;
}
#desktop-link:hover, #feed-link:hover { background: var(--chip); color: var(--ink); }
#feed-link.active { background: var(--chip); color: var(--ink); }
#bases .base-group {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-lg);
}
#bases .base-item {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
/* connected-bases: the table of links, and the file-select-style picker */
table.conntable td { vertical-align: top; }
table.conntable .ghosted { opacity: .6; }
.connlist {
  max-height: 40vh; overflow: auto; margin: 8px 0;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.connlist .connopt {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 8px 12px; cursor: pointer;
}
.connlist .connopt:hover { background: var(--chip); }
.connlist .connopt.sel { background: var(--accent); color: var(--accent-ink); }
.connlist .connopt.sel .muted { color: var(--accent-ink); opacity: .85; }
#connmutwrap { display: inline-flex; align-items: center; gap: 5px; flex: 1 1 auto; white-space: nowrap; }
#connmutwrap input { width: auto; flex: 0 0 auto; }

/* the desktop workspace — Notes-style pages of Base tiles on a grid of whole
   cells (128×122 tiles, 14px gap, 8px padding: the numbers in app.js's DESK).
   An application (linked Bases) is one connected run of cells drawn as one
   .desk-board behind its tiles: the group's hue rides in on --desk-hue and is
   blended with theme tokens here, so tints follow the design pack in light
   and dark alike. */
.desk-tabs {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--line); margin: 14px 0 16px;
}
.desk-tab {
  background: var(--chip); color: var(--ink); border: 1px solid var(--line);
  border-bottom: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 6px 14px; font-size: 13px; display: inline-flex;
  align-items: center; gap: 6px; position: relative; top: 1px;
  transition: transform .12s ease, background-color .12s ease;
  transform-origin: bottom center;
}
.desk-tab.active {
  background: var(--panel); font-weight: 600;
  border-bottom: 1px solid var(--panel);
}
.desk-tab:hover:not(.active) { background: color-mix(in srgb, var(--chip) 55%, var(--panel)); }
/* a tile held over the tab: it grows to say "drop here" */
.desk-tab.drop {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  transform: scale(1.14); z-index: 2;
}
.desk-tab.add { padding: 6px 10px; color: var(--muted); }
/* unread on another page: the same pill the tiles wear */
.desk-tab .count {
  background: var(--accent); color: var(--accent-ink); border-radius: 10px;
  font-size: 11px; font-weight: 600; padding: 1px 7px; line-height: 16px;
}
.desk-tab.editing { padding: 3px 8px; }
.desk-rename {
  font: inherit; font-size: 13px; padding: 2px 6px; width: auto;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
}
.desk-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 128px);
  grid-auto-columns: 128px; grid-auto-rows: 122px; gap: 14px;
  position: relative; padding: 8px; min-height: 420px;
}
.desk-boards, .desk-empty { position: absolute; }     /* out of the grid's flow */
.desk-boards {
  left: 8px; top: 8px; width: calc(100% - 16px); height: calc(100% - 16px);
  overflow: visible; pointer-events: none;
}
.desk-empty { left: 8px; top: 8px; margin: 0; }
.desk-tile {
  width: 128px; height: 122px; position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px 9px; text-align: center; font: inherit; cursor: pointer;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.desk-tile:hover { border-color: var(--accent); }
/* held: it rides with the pointer above everything and lets pointer events
   through to whatever is under it (a page tab, the grid) */
.desk-tile.lifted {
  z-index: 5; pointer-events: none; cursor: grabbing;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28); opacity: .92;
  border-color: var(--accent);
}
.desk-tile.lifted.overtab { opacity: .45; }
.desk-tile.settling { transition: transform .18s ease; }
/* the keyboard's move: lifted look, but it keeps focus and its ring */
.desk-tile.nudging {
  z-index: 5; box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
  border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px;
  transition: transform .12s ease;
}
.desk-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.desk-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* our pop-up menu (tiles and page tabs only — the browser keeps its own
   menu everywhere else) */
.ctxmenu {
  position: fixed; z-index: 60; min-width: 200px; padding: 5px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
}
.ctxmenu [role=menuitem] {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  width: 100%; padding: 7px 10px; border: 0; border-radius: var(--radius);
  background: none; color: var(--ink); font: inherit; font-size: 13.5px;
  text-align: left; cursor: pointer;
}
.ctxmenu [role=menuitem]:hover, .ctxmenu [role=menuitem]:focus-visible {
  background: var(--accent); color: var(--accent-ink); outline: none;
}
.ctxmenu [role=menuitem][disabled] { color: var(--muted); cursor: default; }
.ctxmenu [role=menuitem][disabled]:hover { background: none; color: var(--muted); }
.ctxmenu kbd {
  font: inherit; font-size: 11px; color: inherit; opacity: .7;
  border: 1px solid currentColor; border-radius: 4px; padding: 0 5px;
}
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.ctxgroup { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px 2px; }
/* the cells a drop would take: welcome, or not */
.desk-drop.ok { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-dasharray: 5 4; }
.desk-drop.bad { fill: color-mix(in srgb, var(--danger, #c33) 12%, transparent); stroke: var(--danger, #c33); stroke-dasharray: 5 4; }
.desk-tile .desk-icon { font-size: 30px; line-height: 40px; }
.desk-tile .desk-icon.mono {
  width: 40px; height: 40px; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent) 16%, var(--chip));
  font-size: 21px; font-weight: 600; line-height: 40px;
}
.desk-tile .desk-title {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.desk-tile .desk-meta { font-size: 11.5px; color: var(--muted); margin-top: auto; }
.desk-tile .desk-flag { color: var(--warn); }
.desk-tile .count {
  position: absolute; top: 6px; right: 6px;
  background: var(--accent); color: var(--accent-ink); border-radius: 10px;
  font-size: 11px; padding: 1px 7px;
}
/* the application board: the outline of the linked Bases' cells, tinted and
   lifted — whatever shape they make, the application reads as one thing */
.desk-board {
  --gc: hsl(var(--desk-hue, 152) 42% 52%);
  fill: color-mix(in srgb, var(--gc) 9%, var(--panel));
  stroke: color-mix(in srgb, var(--gc) 50%, var(--line)); stroke-width: 1;
  filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--gc) 26%, transparent));
}
.desk-tile.grouped { --gc: hsl(var(--desk-hue, 152) 42% 52%); box-shadow: none; }
.desk-tile.grouped:hover { border-color: var(--gc); }
.desk-tile.grouped .desk-icon.mono {
  background: color-mix(in srgb, var(--gc) 22%, var(--chip));
}

/* ---------- Mail (F36): the mailbox surface ---------- */

.mailbar { display: flex; align-items: center; gap: 12px; }
.mailbar h2 { margin: 0; flex: 1; }
.mailtabs {
  display: flex; gap: 2px; margin: 12px 0 0; flex-wrap: wrap;
}
.mailtab {
  padding: 6px 12px; border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; background: var(--chip);
  color: var(--muted); text-decoration: none; font-size: 13.5px;
}
.mailtab.active { background: var(--panel); color: var(--ink); font-weight: 600; }
.mailtab:hover { color: var(--ink); }
.mailtab .count, #feedmail h3 .count { margin-left: 6px; }
.mailwrap {
  display: grid; grid-template-columns: minmax(260px, 2fr) 3fr;
  gap: 14px; align-items: start;
}
.mailwrap .card { margin-top: 0; border-top-left-radius: 0; }
.maillist { padding: 6px; display: flex; flex-direction: column; gap: 2px;
  max-height: 72vh; overflow-y: auto; }
.mailempty { padding: 12px; }
.mailitem {
  display: grid; grid-template-columns: 1fr auto; text-align: left;
  gap: 0 10px; padding: 8px 10px; border: 0; background: none;
  border-radius: var(--radius); cursor: pointer; color: var(--ink);
}
.mailitem:hover { background: var(--chip); }
.mailitem.active { background: var(--chip); box-shadow: inset 3px 0 0 var(--accent); }
.mailitem.unread .mailwho, .mailitem.unread .mailsubj { font-weight: 650; }
.mailwho { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailwhen { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.mailsubj { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailitem.unread .mailsubj { color: var(--ink); }
.mailchips { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.mailchips:empty { display: none; }
.mailread { max-height: 72vh; overflow-y: auto; }
.mailhead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mailhead h3 { margin: 0 8px 0 0; }
.mailmeta { margin: 8px 0; font-size: 13.5px; }
.mailaddr { margin: 2px 0; }
.mailaddr .muted { display: inline-block; min-width: 74px; }
.mailthread { margin: 8px 0; }
.mailbody { margin: 12px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.mailacts { border-top: 1px solid var(--line); padding-top: 10px; flex-wrap: wrap; }
.mailmodal { width: min(680px, 92vw); max-height: 88vh; overflow-y: auto; }
@media (max-width: 900px) {
  .mailwrap { grid-template-columns: 1fr; }
  .maillist, .mailread { max-height: none; }
}

/* ---------- the Feed ---------- */

.feeditem {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px;
  width: 100%; text-align: left; padding: 8px 10px; border: 0;
  background: none; border-radius: var(--radius); cursor: pointer;
  color: var(--ink); font-weight: 600;
}
.feeditem:hover { background: var(--chip); }
.feedprop { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

/* ---------- view pagination ---------- */
.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
#pagerbot { margin: 10px 0 0; }
.pgbtn { background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); cursor: pointer; font: inherit; min-width: 28px;
  padding: 2px 7px; }
.pgbtn:hover:not(:disabled):not(.cur) { color: var(--ink); border-color: var(--ink); }
.pgbtn:disabled { opacity: .4; cursor: default; }
.pgbtn.cur { background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); cursor: default; font-weight: 600; }
.pgshown { margin-left: 6px; }
.pgsizewrap { margin-left: auto; }
.pgsize { font: inherit; color: var(--ink); margin-left: 4px; }

/* -- records banner: platform chrome on every document view ---------------- */
.recbanner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin: 10px 0 14px;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); font-size: .92em; }
.recbanner .reclabel { opacity: .7; }
.card.record { border-left: 3px solid var(--accent); }
/* the protective marking (REC-10): a band above the record, loud when it
   says more than UNCLASSIFIED */
.markband { text-align: center; font-weight: 700; letter-spacing: .12em; font-size: .85em;
  padding: 4px 10px; margin: 10px 0 0; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--muted); }
.markband.on { color: var(--ink); border: 2px solid var(--danger, #b00020);
  background: color-mix(in srgb, var(--danger, #b00020) 8%, var(--panel)); }
.chip.markchip { font-weight: 700; letter-spacing: .06em; font-size: .78em; }
.rev.superseded .rev-changes { font-style: italic; }
p.disposal { font-size: .92em; }

/* -- the guided runsheet: a phased document worked as a journey ------------
   Structure only, on the pack's tokens. Targets are big — a plant-floor
   tablet, wet hands — and the current phase is unmistakable. */
.runhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 2px; }
.runhead h2 { margin: 0; }
.runhead .ident { font-family: var(--font-mono); font-weight: 600; letter-spacing: -.02em; }
.runhead .ident.muted { font-family: var(--font-body); font-weight: 400; }
.card.runsheet { padding: 0; overflow: hidden; }

.phases { display: flex; gap: 0; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--line); background: var(--chip); }
.phase { display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 1 1 0; min-width: 118px; padding: 12px 14px 10px;
  background: none; border: 0; border-right: 1px solid var(--line); border-bottom: 3px solid transparent;
  border-radius: 0; color: var(--muted); text-align: left; font: inherit; cursor: pointer;
  position: relative; }
.phase:last-child { border-right: 0; }
button.phase:hover { filter: none; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.phase:disabled, .phase.upcoming { cursor: default; opacity: .55; }
button.phase:disabled:hover { background: none; }
.phase .pnum { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .5px;
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; border: 1px solid var(--line); background: var(--panel); }
.phase.done .pnum { background: var(--ok); color: var(--ok-ink); border-color: var(--ok); }
.phase.current .pnum { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.phase .plabel { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.phase.upcoming .plabel { font-weight: 500; color: var(--muted); }
.phase .ptime { font-family: var(--font-mono); font-size: 11px; color: var(--muted); min-height: 14px; }
.phase.current { background: var(--panel); border-bottom-color: var(--accent); color: var(--ink); }
.phase.current .plabel { color: var(--accent); }
.phase[aria-selected="true"]:not(.current) { background: var(--panel); border-bottom-color: var(--muted); }
.phases.readonly { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.phases.readonly .phase { padding: 8px 12px 6px; min-width: 96px; }

.phasepanel { padding: 20px 24px 8px; }
.phasepanel .eyebrow { margin: 0 0 4px; }
.steptitle { margin: 0 0 12px; font-size: 24px; letter-spacing: -.01em; }
.phasepanel.done .steptitle { font-size: 20px; color: var(--muted); }

.steptimer { display: inline-flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 8px 14px; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent) 9%, var(--panel)); border: 1px solid var(--line); }
.steptimer .tlabel { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.steptimer .tval { font-family: var(--font-mono); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.steptimer .tnote { font-size: 13px; color: var(--muted); }
.steptimer.met { border-color: var(--ok); }
.steptimer.met .tnote { color: var(--ok); font-weight: 600; }
.steptimer.over { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); }
.steptimer.over .tnote { color: var(--warn); font-weight: 600; }

.stepguide { margin: 0 0 16px; padding: 12px 16px; border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--panel)); border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15.5px; line-height: 1.55; }
.stepguide > :first-child { margin-top: 0; }
.stepguide > :last-child { margin-bottom: 0; }
.stepguide.muted { font-style: italic; color: var(--muted); border-left-color: var(--line); background: none; }
.stepguide:empty { display: none; }

.stepfields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 22px; }
.stepfield { padding: 6px 0 10px; }
.stepfield label { margin: 0 0 6px; }
.stepfield input:not(.checkbox), .stepfield select { font-size: 18px; padding: 11px 12px; }
.stepfield input[type="number"] { font-family: var(--font-mono); font-size: 22px; letter-spacing: -.02em; }
.stepfield .target { margin-top: 6px; font-size: 13px; color: var(--muted); }
.stepfield .target .tgt { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
.stepfield .target .offnote { display: block; }
.stepfield .target.off .tgt { color: var(--warn); }
.stepfield .target.off .offnote { color: var(--warn); font-weight: 600; margin-top: 2px; }
.stepfield.locked .fval.locked { font-size: 18px; color: var(--ink); padding: 8px 0; }
.stepfield.locked .target { opacity: .8; }

.stepnotes { margin: 4px 24px 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.stepnotes summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.stepnotes[open] summary { margin-bottom: 4px; }

.stepnext { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  margin: 8px 24px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--chip); }
.stepnext .nextlabel { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.stepnext .nexttitle { font-weight: 600; }
.stepnext .nextline { color: var(--muted); font-size: 13.5px; flex: 1 1 100%; }

.runsheet .stepactions { padding: 16px 24px 0; margin: 0; align-items: center; }
.runsheet .stepactions .forward { margin-left: auto; }
button.big { font-size: 17px; padding: 13px 22px; font-weight: 600; }
button.big.forward { min-width: 200px; }
button.ghost.back { color: var(--muted); }
.runsheet .hint { margin: 8px 24px 0; font-size: 13px; color: var(--muted); }
.runsheet .hint:empty { display: none; }
.runsheet .error { margin: 6px 24px 16px; }
.runsheet .error:empty { display: none; margin: 0 0 16px; }

.card.stepask .askrow { display: flex; gap: 8px; }
.card.stepask .askrow input { font-size: 16px; padding: 10px 12px; }
.card.stepask .askanswer { margin-top: 12px; font-size: 15px; line-height: 1.55; }
.card.stepask .askanswer p { margin: 0 0 8px; }
.card.stepask .asksources { font-size: 12.5px; }

@media (max-width: 640px) {
  .phasepanel { padding: 16px 16px 6px; }
  .stepnotes, .stepnext { margin-left: 16px; margin-right: 16px; }
  .runsheet .stepactions { padding: 14px 16px 0; }
  .runsheet .stepactions .forward { margin-left: 0; width: 100%; }
  .runsheet .hint, .runsheet .error { margin-left: 16px; margin-right: 16px; }
  .steptitle { font-size: 21px; }
}

/* -- provenance: the "why" beside a field ----------------------------------- */
.why { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; }
.fval .why { margin-top: 4px; }
.fsec .why { display: inline-flex; margin: 0 0 0 10px; vertical-align: middle; text-transform: none; letter-spacing: 0; }
.phasepanel .steptitle + .why { margin: -6px 0 12px; }
.ref { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 1.6;
  padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--chip);
  color: var(--ink); text-decoration: none; }
a.ref:hover { border-color: var(--accent); color: var(--accent); }
.ref.off { opacity: .65; border-style: dashed; }
.ref.legislation { border-left: 3px solid var(--accent); }
.ref.standard { border-left: 3px solid var(--muted); }
.ref.sop { border-left: 3px solid var(--ok); }
.ref.hs { border-left: 3px solid var(--warn); }

/* -- photo evidence ---------------------------------------------------------- */
.photofield { display: flex; flex-direction: column; gap: 8px; }
.photolist { display: flex; flex-wrap: wrap; gap: 10px; }
.photoitem { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.photoitem .thumb { width: 160px; height: 120px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--chip); display: block; }
.photolist.read .thumb { width: 200px; height: 150px; }
.photoitem figcaption { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.photoitem figcaption button.ghost { padding: 0 6px; font-size: 12px; line-height: 1.6; }
.photobtn { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font: inherit; font-size: 16px; font-weight: 600; padding: 12px 18px; margin: 0;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.photobtn:hover { filter: brightness(1.08); }
.stepfield .photobtn { font-size: 17px; }
.photostatus:empty { display: none; }

.photoitem .thumb { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 24px;
  background: color-mix(in srgb, var(--ink) 80%, transparent); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 85vh; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); background: var(--panel); }
.lightbox p { color: var(--accent-ink); margin: 0; }

/* ---------- sign-in panel + Prefs → Security ---------- */
#signin {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  padding: 16px; background: var(--bg); overflow: auto;
}
#signin .signin-card { width: min(440px, 100%); margin: 0; }
#signin label { display: block; margin: 10px 0 0; font-size: 13.5px; }
#signin input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; }
#signin .signin-remember { display: flex; align-items: center; gap: 8px; }
#signin .signin-remember input { width: auto; margin: 0; }
#signin [hidden], #security [hidden] { display: none !important; }
#signin .signin-switch {
  cursor: pointer; display: inline-block; margin: 0; padding: 8px 12px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: transparent;
}
#signin .signin-switch:hover { border-color: var(--accent); }
#signin .signin-err { margin: 10px 0 0; }
#signin .signin-idnote { margin: 8px 0 0; font-size: 13px; }
/* the baseline profile (P2.2): logon notice, the persistent MFA bar, and the
   must-change / confirm-it's-you / idle-warning cards over the page */
#signin .signin-banner {
  margin: 12px 0 4px; padding: 10px 12px; border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: var(--radius-lg);
  background: var(--panel); font-size: 13.5px; white-space: pre-line;
}
#signin .signin-banner p { margin: 4px 0; }
.profile-modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  padding: 16px; overflow: auto;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.profile-modal .signin-card { width: min(440px, 100%); margin: 0; }
.profile-modal label { display: block; margin: 10px 0 0; font-size: 13.5px; }
.profile-modal input { display: block; width: 100%; margin-top: 4px; }
.profile-modal [hidden] { display: none !important; }
#mustchange { background: var(--bg); }
#profilebar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  max-width: min(640px, calc(100% - 32px)); padding: 10px 14px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); box-shadow: var(--shadow);
}
#profilebar.warn { border-left: 4px solid var(--danger, #b3261e); }
#profilebar.info { border-left: 4px solid var(--accent); }
#locknotice {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 60;
  max-width: min(640px, calc(100% - 32px)); padding: 10px 14px; font-size: 13.5px;
  border: 1px solid var(--line); border-left: 4px solid var(--danger, #b3261e);
  border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow);
}
#locknotice .locknotice-ok { margin-left: 8px; }
#keynotice {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 55;
  max-width: min(640px, calc(100% - 32px)); max-height: 60vh; overflow-y: auto;
  padding: 10px 14px; font-size: 13.5px;
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow);
}
#keynotice.overdue { border-left-color: var(--danger, #b3261e); }
#keynotice .keynotice-list { margin: 6px 0; padding-left: 18px; }
#keynotice .keynotice-list li { margin: 4px 0; }
#keynotice .keynotice-how code { font-size: 12px; overflow-wrap: anywhere; }
#security .profile-owed { border-left: 4px solid var(--accent); }
#security { margin-top: 28px; }
#security h3 { margin: 0 0 6px; font-size: 16px; }
#security form label { display: block; margin: 8px 0 0; font-size: 13.5px; }
#security form input { display: block; width: min(360px, 100%); margin-top: 4px; }
#security .mfasecret { font-size: 17px; letter-spacing: .08em; user-select: all; }
#security .mfauri { font-size: 11.5px; word-break: break-all; user-select: all; }
#security tr.current td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
#security .timeline li { margin: 4px 0; font-size: 13.5px; }
#who { margin: 8px 6px 0; font-size: 12.5px; }

/* -- design inheritance: provenance badges, the element banner, the plan --
   (docs/DEVELOPER.md "Design inheritance"). Structure on the pack's tokens. */
.chip.origin.inherited { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--ink); }
.chip.origin.overridden { background: color-mix(in srgb, var(--warn) 24%, var(--panel)); color: var(--ink); }
.chip.origin.broken { background: color-mix(in srgb, var(--danger) 16%, var(--panel)); color: var(--ink); }
.chip.origin.local { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.chip.behind { background: var(--warn); color: var(--warn-ink); }
.chip.protected { background: color-mix(in srgb, var(--ink) 8%, var(--panel)); }
.chip.action.replace, .chip.action.delete { background: color-mix(in srgb, var(--warn) 24%, var(--panel)); color: var(--ink); }
.chip.action.add { background: color-mix(in srgb, var(--ok) 16%, var(--panel)); color: var(--ink); }
.chip.action.collision, .chip.action.refused { background: color-mix(in srgb, var(--danger) 16%, var(--panel)); color: var(--ink); }
.designbanner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin: 10px 0 14px;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); font-size: .92em; }
.designbanner .reclabel { opacity: .7; }
.designbanner .acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.designbanner .acts button { margin: 0; }
table.kinds td { vertical-align: top; }
details.plan summary { cursor: pointer; }
details.plan.applied { opacity: .7; }
.difftable { width: 100%; font-size: 12.5px; margin-top: 8px; border-collapse: collapse; }
.difftable td, .difftable th { vertical-align: top; text-align: left; padding: 4px 6px; border-top: 1px solid var(--line); }
.difftable pre.json { margin: 0; max-height: 220px; overflow: auto; white-space: pre-wrap; }
pre.json.ro { opacity: .8; }
.modal.ask textarea { width: 100%; }
/* ---------- scan-back (a sheet photographed and typed beside its image) ---------- */
.scanstart { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.scanstart button.big { font-size: 22px; padding: 18px 28px; }
.scanwrap { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .scanwrap { grid-template-columns: 1fr; } }
.scanphoto { display: flex; flex-direction: column; gap: 10px; }
.scanphoto img { width: 100%; max-height: 70vh; object-fit: contain; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--panel); cursor: zoom-in; }
.tgridwrap { overflow-x: auto; }
.tgrid { border-collapse: collapse; width: 100%; }
.tgrid th, .tgrid td { border: 1px solid var(--line); padding: 4px 5px; vertical-align: top; text-align: left; }
.tgrid thead th { background: var(--chip); font-weight: 600; white-space: nowrap; }
.tgrid th.row { white-space: nowrap; }
.tgrid th.row small { display: block; color: var(--muted); font-weight: normal; }
.tgrid .cell { display: flex; flex-direction: column; gap: 6px; }
.tgrid .cell label { font-size: 12px; color: var(--muted); display: block; }
.tgrid .cell input, .tgrid .cell select { display: block; width: 5em; max-width: 100%; font-size: 18px; padding: 9px 6px; }
.tgrid .cell.dirty input, .tgrid .cell.dirty select { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
/* a days sheet's grid (print.orient "days"): the week down the page, a column per unit; a day's AM and PM side by
   side in the unit's cell so three or four units fit the completing page's panel; the unit's limit under its name */
.tgrid thead th small { display: block; color: var(--muted); font-weight: normal; font-size: 11px; text-transform: none; }
.tgrid.days thead th { white-space: normal; }
.tgrid.days .cell { flex-direction: row; flex-wrap: wrap; gap: 6px 8px; }
.tgrid.days .cell label { flex: 0 1 auto; }
.tgrid.days .cell input, .tgrid.days .cell select { width: 4.2em; }
.tgrid .cell .cellerr { color: var(--danger); font-size: 12px; }
.tgrid .cell .cellerr:empty { display: none; }
/* the grid on the document page (docs/requests/document-page-and-scan-flow.md, A2):
   a cell coloured by the stored read — green the reader was sure and the value is in
   the input, amber it was not (the proposal as a placeholder), red it could not read
   the ink, grey dashed an empty box; typing drops the colour (wireGrid) */
.tgrid .cell label.read-confident input, .tgrid .cell label.read-confident select { border-left: 5px solid var(--ok); }
.tgrid .cell label.read-unsure input, .tgrid .cell label.read-unsure select { border-left: 5px solid var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--panel)); }
.tgrid .cell label.read-unreadable input, .tgrid .cell label.read-unreadable select { border-left: 5px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--panel)); }
.tgrid .cell label.read-blank input, .tgrid .cell label.read-blank select { border-left: 5px dashed var(--line); }
.tgrid .cell label.read-confident input[type=checkbox] { outline: 2px solid var(--ok); outline-offset: 1px; border-left: 0; }
.tgrid .cell label.read-unsure input[type=checkbox] { outline: 2px solid var(--warn); outline-offset: 1px; border-left: 0; }
.tgrid .cell label.read-blank input[type=checkbox] { outline: 2px dashed var(--line); outline-offset: 1px; border-left: 0; }
.tgrid .cell label.screen { opacity: .85; }
.tgrid .cell label.screen::after { content: " (screen)"; font-size: 10.5px; color: var(--muted); }
.tgrid th.row a { font-weight: 600; }
.tgrid th.row .chip, .tgrid .cellref .chip { font-size: 11px; padding: 1px 7px; vertical-align: middle; }
.tgrid .norec { font-size: 12px; font-style: italic; }
.tgrid .cellref a { text-decoration: none; }
.sheetgrid .gridhead { margin: 0 0 10px; }
.sheetgrid .gridbar { align-items: center; margin-bottom: 0; }
.sheetgrid .gridnote { margin: 10px 0 0; }
/* the action bar under the state strip (A1): the strip is flush in its card */
.card > .phases + .row-actions { margin-top: 12px; }
.card > .phases:last-child { margin-bottom: 0; }
.scannames { display: flex; flex-wrap: wrap; gap: 8px; }
.scannames button { font-size: 17px; padding: 10px 16px; }
.scannames button.ghost.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
/* scan-back v2: the pile and the checking UI */
.pilepanel { position: relative; width: min(640px, 100%); display: flex; flex-direction: column; gap: 8px; }
.pilepanel[hidden] { display: none; }   /* the author display beat the attribute: the camera panel showed as a black box until Scan a pile */
.pilepanel video { width: 100%; max-height: 60vh; background: #000; border-radius: var(--radius-lg); object-fit: contain; }
.pilepanel.flash video { outline: 6px solid var(--panel); filter: brightness(1.6); }
ul.pile li b { font-weight: 600; }
.scanwrap.check { grid-template-columns: minmax(300px, 5fr) minmax(320px, 6fr); }
@media (max-width: 1000px) { .scanwrap.check { grid-template-columns: 1fr; } }
.checkphoto .pagebox { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.checkphoto .pagebox canvas { display: block; }
.checkphoto .readmeta { font-size: 12.5px; }
.checklist .readings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.checkrow { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr); gap: 8px 12px; align-items: center; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); border-left-width: 5px; }
.checkrow.confident { border-left-color: var(--ok); }
.checkrow.unsure { border-left-color: var(--warn); }
.checkrow.blank { border-left-color: var(--line); border-left-style: dashed; }
.checkrow.unreadable { border-left-color: var(--danger); }
/* the scan flow (docs/requests/document-page-and-scan-flow.md, part B): a cell of the
   typing grid coloured by the stored read — green the machine filled it, amber a value
   proposed for the person to confirm (the placeholder), red the box must be looked at on
   the paper, grey dashed nothing written; blue the cell the photo panel is following */
.tgrid .cell.read-confident, .tgrid .cell label.read-confident { border-left: 4px solid var(--ok); padding-left: 6px; }
.tgrid .cell.read-unsure, .tgrid .cell label.read-unsure { border-left: 4px solid var(--warn); padding-left: 6px; }
.tgrid .cell.read-unreadable, .tgrid .cell label.read-unreadable { border-left: 4px solid var(--danger); padding-left: 6px; }
.tgrid .cell.read-blank, .tgrid .cell label.read-blank { border-left: 4px dashed var(--line); padding-left: 6px; }
.tgrid .cell label.read-unsure input::placeholder, .tgrid .cell label.read-unreadable input::placeholder { color: var(--warn); opacity: 1; }
.tgrid .cell label.following { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: var(--radius); }
.tgrid .cell .readnote { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; max-width: 12em; }
.tgrid .cell label.read-unsure .readnote, .tgrid .cell label.read-unreadable .readnote { color: var(--warn); }
.tgrid .cell canvas.cellcrop { display: block; width: 100%; max-width: 160px; height: auto; margin-top: 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.scanwrap.complete { grid-template-columns: minmax(420px, 7fr) minmax(300px, 4fr); }
@media (max-width: 1000px) { .scanwrap.complete { grid-template-columns: 1fr; } }
.scanwrap.complete .scanphoto { position: sticky; top: 8px; }
.photopanel .pagebox { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.photopanel .pagebox canvas { display: block; cursor: crosshair; }
.photopanel .readmeta { font-size: 12.5px; }
.photopanel .panelcrop { display: none; }
.photopanel .panelcrop.on { display: block; }
.photopanel .panelcrop canvas { max-width: 200px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.photopanel .legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.photopanel .legend i { display: inline-block; width: 12px; height: 12px; border: 2px solid; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }
.photopanel .legend .lg-confident { border-color: var(--ok); }
.photopanel .legend .lg-unsure { border-color: var(--warn); }
.photopanel .legend .lg-unreadable { border-color: var(--danger); }
.photopanel .legend .lg-blank { border-color: var(--muted); border-style: dashed; }
ul.plain.tocomplete li .count { font-weight: 600; }
ul.plain.tocomplete li .count.allread { color: var(--ok); }
#scanstatus.applied { color: var(--ink); font-weight: 600; }
.checkrow.done { opacity: .72; }
.checkrow.current { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); opacity: 1; }
.checkrow .what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.checkrow .what b { font-size: 14px; }
.checkrow .what .muted { font-size: 12.5px; }
.checkrow canvas.crop { width: 100%; max-width: 160px; height: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; image-rendering: auto; }
.checkrow .decide { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.checkrow .proposed { min-width: 6em; font-size: 20px; }
.checkrow .proposed small { font-size: 12px; color: var(--muted); }
.checkrow .decide input { width: 6em; font-size: 20px; padding: 9px 8px; }
.checkrow .decide select { font-size: 17px; padding: 8px; }
.checkrow .decide button.accept { font-size: 16px; padding: 10px 14px; }
.checkrow .decide button.none { font-size: 14px; }
.checkrow .outcome { font-size: 12.5px; }
.checkrow.name { background: var(--chip); }
.checkbar { align-items: center; }
.checkhint { font-size: 13px; }
p.warn, span.warn { color: var(--warn); }
.proposal.sheetread p { margin: 4px 0; }
ul.plain li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* a reading outside its record's limits (Jamie, 4 Nov 2026): red on every page that shows it */
.tgrid label.overlimit input { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--panel)); color: var(--danger); font-weight: 700; }
.checkrow.overlimit { border-left: 4px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.checkrow.overlimit.done { opacity: 1; }
.overblock { border: 2px solid var(--danger); border-radius: 8px; padding: 8px 12px; margin: 10px 0; background: color-mix(in srgb, var(--danger) 6%, var(--panel)); }
.overblock input { width: 100%; }
.danger-text { color: var(--danger); font-weight: 600; }

/* one-tap OK on an amber box, and OK-all (Jamie, 4 Nov 2026) */
.okread { display: block; margin-top: 4px; padding: 2px 8px; font-size: 13px; border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-radius: 6px; cursor: pointer; }
.okallbar { margin: 6px 0 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.oversop { margin-top: 8px; }
.oversop .sopbody { font-size: 13.5px; }
.scanwrap.complete .tgrid input { min-width: 5.5em; }
.tgrid label .okread, .tgrid .cell .okread { color: #3d2e00 !important; font-weight: 600; opacity: 1; width: auto; min-width: 0; height: auto; text-transform: none; letter-spacing: 0; }

/* the Designer workspace (client/workspace.js, client/codeedit.js) — tokens only */
#maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#maincol > #main { flex: 1 1 auto; width: 100%; }
body.ws-on #main { max-width: 1400px; }
/* a link in the workspace is the accent (docs/THEMING.md), so it reads in dark too */
body.ws-on #main a:not([class]), .ws-estate a:not([class]) { color: var(--accent); text-underline-offset: 2px; }
body.ws-on #main a:not([class]):hover, .ws-estate a:not([class]):hover { color: var(--ink); }
#wsnav {
  width: 264px; flex: none; border-right: 1px solid var(--line); background: var(--bg);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; font-size: 13.5px;
}
#wsnav[hidden], #wsbar[hidden] { display: none; }
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ws-head strong { font-family: var(--font-head); font-size: 17px; }
.ws-find, .ws-find2 { padding: 3px 8px; font-size: 12.5px; white-space: nowrap; }
kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: var(--radius); padding: 0 4px; background: var(--panel); color: var(--muted); }
.ws-places { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ws-places a { padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none;
  color: var(--ink); background: var(--panel); text-align: center; }
.ws-places a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ws-q { width: 100%; margin: 0; }
.ws-filters { display: flex; flex-direction: column; gap: 4px; }
.ws-filters select { width: 100%; margin: 0; font-size: 12.5px; padding: 4px 6px; }
.ws-warnf { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 400; }
.ws-warnf input { width: auto; margin: 0; }
.ws-tree { flex: 1 1 auto; min-height: 80px; }
.ws-kind { margin: 0 0 4px; }
.ws-kind > summary { cursor: pointer; padding: 5px 2px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ws-kind > summary .muted { font-weight: 400; font-size: 12px; }
.ws-kicon { width: 1.4em; display: inline-block; text-align: center; }
.ws-add { margin-left: auto; text-decoration: none; padding: 0 7px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--accent); background: var(--panel); font-weight: 700; }
.ws-el { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 26px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.ws-el:hover { background: var(--chip); }
.ws-el.active { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-left-color: var(--accent); font-weight: 600; }
.ws-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-chips { display: flex; gap: 3px; flex: none; }
.ws-chips .chip { font-size: 10.5px; padding: 0 5px; }
.ws-none { margin: 2px 0 6px 26px; font-size: 12.5px; }
.ws-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 12.5px; }
.ws-foot a { color: var(--muted); text-decoration: none; }
.ws-foot a:hover { color: var(--accent); }

#wsbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 34px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 5; font-size: 13.5px; }
.ws-crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-crumb a { color: var(--muted); text-decoration: none; }
.ws-tabs { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.ws-tabs a { padding: 4px 11px; border-radius: var(--radius); text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.ws-tabs a:hover { background: var(--chip); }
.ws-tabs a.active { background: var(--accent); color: var(--accent-ink); }
.ws-navbtn { display: none; padding: 3px 9px; font-size: 12.5px; }
#wsbar .ws-find2 { margin-left: 0; }
#wsbar .ws-tabs + .ws-find2 { margin-left: 4px; }
#wsbar .ws-crumb + .ws-find2 { margin-left: auto; }
@media (max-width: 1240px) {
  .ws-navbtn { display: inline-block; }
  #wsnav { position: fixed; left: 0; top: 0; z-index: 15; transform: translateX(-105%); transition: transform .18s ease; box-shadow: var(--shadow); }
  body.ws-navopen #wsnav { transform: translateX(0); }
  #wsbar { padding: 8px 16px; }
  body.ws-on #main { padding: 20px 16px; }
}
@media (max-width: 760px) { #wsbar { padding-left: 58px; } }

/* the command palette */
.ws-palback { align-items: flex-start; padding-top: 12vh; }
.modal.ws-pal { width: min(640px, 100%); padding: 12px; }
.ws-palq { width: 100%; font-size: 16px; margin: 0 0 8px; }
.ws-pallist { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; }
.ws-palitem { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; }
.ws-palitem .muted { font-size: 12.5px; white-space: nowrap; }
.ws-palitem.active, .ws-palitem:hover { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.ws-palhelp { margin: 8px 2px 0; font-size: 12px; }

/* an element in the design panels */
.ws-edhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ws-edhead .row-actions { margin: 0; align-items: center; }
.ws-edhead .sub { margin-bottom: 10px; }
.ws-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
#ws-json { min-height: 420px; width: 100%; white-space: pre; }
.ghost-link { font-size: 13.5px; color: var(--accent); text-decoration: none; padding: 6px 8px; }
.ws-lintok, .ws-lintbad { margin: 0 0 12px; }
.ws-lintbad { border-left: 3px solid var(--warn); }
.ws-lintbad ul, .ws-problist, .ws-warnlist { margin: 6px 0; padding-left: 20px; }
.ok { color: var(--ok); }
#ws-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 14px; align-items: start; }
.ws-problist > li { margin-bottom: 6px; }
.ws-problist ul { margin: 2px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* the script editor */
.ce-editor { display: block; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-top: 4px; overflow: hidden; }
.ce-editor.bad { border-color: var(--warn); }
.ce-bar { display: flex; justify-content: space-between; gap: 10px; padding: 3px 9px; border-bottom: 1px solid var(--line);
  background: var(--chip); font-size: 11.5px; }
.ce-lang { font-family: var(--font-mono); color: var(--muted); letter-spacing: .3px; }
.ce-host .cm-editor { font-family: var(--font-mono); font-size: 12.5px; max-height: 60vh; background: var(--panel); color: var(--ink); }
.ce-host .cm-editor.cm-focused { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -2px; }
.ce-host .cm-scroller { font-family: var(--font-mono); line-height: 1.5; min-height: 96px; overflow: auto; }
.ce-host .cm-gutters { background: var(--chip); color: var(--muted); border-right: 1px solid var(--line); }
.ce-host .cm-activeLine { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ce-host .cm-activeLineGutter { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.ce-host .cm-cursor { border-left-color: var(--ink); }
.ce-host .cm-selectionBackground, .ce-host .cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 28%, var(--panel)); }
.ce-host .cm-matchingBracket { background: color-mix(in srgb, var(--ok) 30%, transparent); outline: 0; }
.ce-host .cm-nonmatchingBracket { background: color-mix(in srgb, var(--danger) 30%, transparent); }
.ce-kw { color: var(--accent); font-weight: 600; }
.ce-atom, .ce-num { color: var(--warn); }
.ce-str { color: color-mix(in srgb, var(--ok) 60%, var(--ink)); }
.ce-com { color: var(--muted); font-style: italic; }
.ce-std { color: color-mix(in srgb, var(--accent) 55%, var(--danger)); }
.ce-fn { color: color-mix(in srgb, var(--accent) 60%, var(--ink)); }
.ce-meta, .ce-op { color: var(--muted); }
.ce-problems ul { margin: 0; padding: 5px 9px 6px 26px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--warn); }
.ce-line { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
#ws-jsonwrap .ce-host .cm-editor { max-height: 70vh; }

/* the workflow inspector is the design panels, standing open */
.wfpanel { border: 0; padding: 0; margin: 0; min-width: 0; }
.wfpanel .fp-panel { border: 0; box-shadow: none; padding: 0; margin: 0 0 6px; background: transparent; }
.wfpanel.wfstep .fp-panel > summary { display: none; }
.wfpanel .fp-panel > summary { font-size: 13.5px; }
.wfpanel .fp-bar { margin: 4px 0 6px; }
.wfpanel .fp-bar .fd-help { font-size: 12.5px; }
.wfpanel .fp-grid { grid-template-columns: 1fr; }
.wfpanel .ce-host .cm-editor { max-height: 38vh; }
.wfresume { display: inline-flex; gap: 4px; }
.wfresume button { padding: 2px 8px; font-size: 12px; }
.wfrunlist .rowlink { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; font-size: 13px; }
@media (min-width: 1500px) { body.ws-on .wfbody { grid-template-columns: 1fr 400px; } }
@media (max-width: 1000px) { .wfbody { grid-template-columns: 1fr; } .wfside { max-height: none; } }

/* the map */
.ws-mapbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 10px; font-size: 13px; }
.ws-mapbar label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.ws-mapbar input { width: auto; margin: 0; }
.wm-legend { margin-left: auto; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.wm-key { display: inline-block; width: 22px; border-top: 2px solid var(--muted); margin-left: 8px; }
.wm-key.broken { border-top: 2px dashed var(--danger); }
.wm-key.miss { height: 11px; border: 1.5px dashed var(--danger); border-radius: 3px; }
.ws-mapbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.ws-mapbody.with-side { grid-template-columns: minmax(0, 1fr) 300px; }
.ws-mapscroll { overflow: auto; max-height: 72vh; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.ws-mapsvg { display: block; font-family: var(--font-body); max-width: 100%; height: auto; min-width: 720px; }
.wm-col { fill: var(--muted); font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; }
.wm-node { cursor: pointer; }
.wm-node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.2; }
.wm-node text { fill: var(--ink); font-size: 13px; }
.wm-node:hover rect, .wm-node:focus rect { stroke: var(--accent); stroke-width: 2; }
.wm-node:focus { outline: none; }
.wm-node.k-form rect { fill: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.wm-node.k-workflow rect { fill: color-mix(in srgb, var(--warn) 12%, var(--panel)); }
.wm-node.k-agent rect { fill: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.wm-node.outside rect { fill: var(--chip); stroke-dasharray: 2 3; }
.wm-node.warned rect { stroke: var(--warn); stroke-width: 1.8; }
.wm-node.missing rect { fill: color-mix(in srgb, var(--danger) 8%, var(--panel)); stroke: var(--danger); stroke-dasharray: 5 4; stroke-width: 1.6; }
.wm-node.missing text { fill: var(--danger); font-style: italic; }
.wm-node.focus rect { stroke: var(--accent); stroke-width: 2.6; }
.wm-node.dim, .wm-edge.dim { opacity: .22; }
.wm-warn { fill: var(--warn) !important; }
.wm-node.missing .wm-warn { fill: var(--danger) !important; }
.wm-edge { fill: none; stroke: var(--muted); stroke-width: 1.3; opacity: .75; }
.wm-edge.lit { stroke: var(--accent); stroke-width: 2.2; opacity: 1; }
.wm-edge.inherits { stroke-dasharray: 1 4; }
.wm-edge.broken { stroke: var(--danger); stroke-dasharray: 6 4; stroke-width: 1.8; opacity: 1; }
.wm-arrow path { fill: var(--muted); }
.wm-arrow.broken path { fill: var(--danger); }
.wm-rel { font-size: 11px; fill: var(--accent); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.wm-rel.broken { fill: var(--danger); }
.ws-mapside { margin: 0; font-size: 13.5px; }
.ws-mapside ul { margin: 2px 0 8px; padding-left: 18px; }
.ws-mapside p { margin: 6px 0 2px; }
.ws-links { margin-top: 12px; }
.ws-links > summary { cursor: pointer; }
.ws-brokenrow td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
@media (max-width: 1240px) { .ws-mapbody.with-side { grid-template-columns: 1fr; } }

/* history */
.ws-histbar, .ws-comparebar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.ws-histbar select, .ws-comparebar select { width: auto; margin: 0; max-width: 100%; }
.ws-comparebar label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.ws-day { padding-top: 8px; }
.ws-dayhead { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: .4px; margin-bottom: 4px; }
.ws-hist { width: 100%; }
.ws-hist td { vertical-align: top; }
.ws-when { white-space: nowrap; font-family: var(--font-mono); font-size: 12px; width: 1%; }
.ws-diffbtn { padding: 1px 8px; font-size: 12px; margin-left: 4px; }
.ws-diffrow > td { background: var(--bg); }
.ws-diffkey { margin: 6px 0 10px; }
.ws-diffpair { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; margin-top: 4px; }
.ws-diffpair pre, .ws-linediff { margin: 4px 0 0; max-height: 320px; overflow: auto; }
pre.ws-gone, span.ws-gone { background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }
pre.ws-came, span.ws-came { background: color-mix(in srgb, var(--ok) 13%, var(--panel)); }
span.ws-gone, span.ws-came { display: inline-block; min-width: 100%; }

/* the estate */
.ws-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 14px; }
.ws-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px 12px; display: flex; flex-direction: column; }
.ws-tilen { font-family: var(--font-head); font-size: 26px; line-height: 1.1; }
.ws-tile.warn { border-color: var(--warn); }
.ws-tile.bad { border-color: var(--danger); }
.ws-tile.bad .ws-tilen { color: var(--danger); }
.ws-estate td { vertical-align: top; }
.ws-counts span { white-space: nowrap; margin-right: 6px; }
.ws-estdetail td { background: var(--bg); font-size: 13px; padding-left: 32px; }
.ws-estdetail ul { margin: 2px 0 8px; padding-left: 18px; }
.ws-estdetail p { margin: 4px 0 0; }
a.chip { text-decoration: none; }
