:root {
  --bg: #ffffff; --fg: #1d2330; --muted: #6a7282; --line: #d9dde5; --accent: #2457c5;
  --amber: #a86400; --refusal: #b3261e; --notice: #6b4e00; --panel: #f5f7fa;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15181e; --fg: #e3e6ec; --muted: #9aa2b1; --line: #313744; --accent: #7aa2ff;
          --amber: #f0b45a; --refusal: #ff8a80; --notice: #f2d27a; --panel: #1d2129; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, sans-serif; }
button { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 8px; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
code, pre { font-family: var(--mono); }
.page { height: 100vh; display: flex; flex-direction: column; }
.title-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.product { font-weight: 600; }
/* what the page is and the host's build tag, beside the product name (Colin, 24 Oct 16:55, item 1) */
.version { margin: 0 auto 0 12px; }
.who { color: var(--muted); }
.sign-in { max-width: 46rem; padding: 16px; }
.registry-line { background: var(--panel); border: 1px solid var(--line); padding: 8px; overflow-x: auto; white-space: pre; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.refusal { color: var(--refusal); }
.notice { color: var(--notice); }
.workbench { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.ask { display: flex; gap: 6px; align-items: center; }
.window { padding: 8px 16px; overflow-x: auto; }
/* every editor window is a real browser window (Colin, 22 Oct 23:49, item 1; PopupWindow.tsx): its content fills it,
   and the tree fills the page's own window below the title bar */
.window-page { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.window-page > .window, .main-window { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.window .diagram-window { flex: 1; min-height: 0; }
.window .diagram-canvas { flex: 1; height: auto; min-height: 200px; }
.window-header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--muted); }
.rows, .records, .steps { list-style: none; margin: 0; padding: 0; }
.row { position: relative; }
.line { display: inline-flex; align-items: center; gap: 4px; }
.chevron { border: none; background: transparent; width: 1.4em; padding: 0; }
.chevron.none { display: inline-block; width: 1.4em; }
.badge { font-family: var(--mono); font-size: 12px; padding: 0 4px; }
.lock { font-size: 11px; opacity: .6; }
.menu-button { border: none; background: transparent; color: var(--muted); }
.menu { list-style: none; margin: 2px 0 6px 2rem; padding: 4px; border: 1px solid var(--line); background: var(--bg); border-radius: 4px; width: max-content; max-width: min(36rem, 90vw); }
.menu button { display: block; width: 100%; text-align: left; border: none; background: transparent; }
.menu-reason { font-style: italic; }
.menu-why { display: block; font-size: 12px; color: var(--muted); padding: 0 8px 4px; }
.check { margin: 2px 0 6px 2rem; }
.finding .rule { color: var(--muted); }
.lock-line { color: var(--muted); margin: 0 0 6px; }
.text-rows { font-family: var(--mono); font-size: 13px; }
.text-row { white-space: pre-wrap; padding-left: 0; text-indent: 0; }
.text-row.selected { background: var(--selected, #e3edfb); outline: 1px solid #9bb8e6; }
.text-row .pairs { display: inline; }
.text-row .badge { border: none; background: transparent; color: var(--accent); padding: 0; }
.island.absent { color: var(--muted); }
.island.unbound { color: var(--amber); text-decoration: underline dotted; }
.island.bound, .island.present { color: var(--accent); }
.island.fixed { color: var(--muted); }
.record { padding: 4px 0; border-bottom: 1px solid var(--line); }
.record .kind { font-weight: 600; }
.summary { margin-left: 1.4em; color: var(--muted); }
.steps { margin-left: 2.4em; font-family: var(--mono); font-size: 12px; }
/* drafts (milestone (ii)) */
.island-button { border: none; background: transparent; padding: 0; font: inherit; cursor: text; }
.island-button:hover .island { outline: 1px dashed var(--line); }
.island-editor { font: inherit; font-family: var(--mono); font-size: 13px; border: 1px solid var(--accent); border-radius: 3px; padding: 0 3px; vertical-align: top; }
textarea.island-editor { min-width: 24ch; }
.text-row.refused { background: color-mix(in srgb, var(--refusal) 10%, transparent); }
.text-row.previewed { background: color-mix(in srgb, var(--amber) 10%, transparent); }
.text-row.advised { background: color-mix(in srgb, var(--amber) 6%, transparent); }
.text-row.auxiliary { color: var(--muted); font-style: italic; }
.mark-text { margin-left: 1ch; font-family: system-ui, sans-serif; font-size: 12px; color: var(--muted); }
.changed-mark { margin-left: 0.5ch; color: var(--accent); font-size: 10px; }
.panel { margin: 6px 0; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.outcome { margin: 4px 0; padding: 6px 8px; border-radius: 4px; border: 1px solid var(--line); }
.outcome.refusal { border-color: var(--refusal); }
.outcome.stale { border-color: var(--amber); color: var(--amber); }
.outcome.notice-ok { border-color: var(--accent); }
.outcome.advised { border-color: var(--amber); }
.outcome .sets { margin: 4px 0 0; padding-left: 1.25rem; }
.preview-line { color: var(--amber); margin: 0 0 6px; }
.kept-line { color: var(--amber); margin: 0 0 6px; }
.kept-line button { margin-left: 6px; }
.toggle { font-size: 12px; }

/* The diagram window (clade-editor-web-diagrams §2.3a): hard-edged style (A6) — white boxes, black
   strokes, sharp corners, orthogonal edges; deterministic text layout (A5) — one line per token run,
   truncated with an ellipsis, the whole run in the tooltip; a node grows with its rows. */
.diagram-window { display: flex; flex-direction: column; gap: 4px; }
.diagram-canvas { position: relative; height: 70vh; min-height: 320px; border: 1px solid var(--line); background: #fff; }
.diagram-defs { position: absolute; width: 0; height: 0; }
.diagram-node { box-sizing: border-box; width: 100%; height: 100%; background: #fff; color: #000; border: 1px solid #000;
  border-radius: 0; font: 12px/20px system-ui, sans-serif; overflow: hidden; }
.diagram-node.ghost { border-style: dashed; color: #555; }
.diagram-node.dot { border-radius: 50%; background: #000; overflow: visible; }
.diagram-node.dot .dot-name { position: absolute; left: 18px; top: -4px; white-space: nowrap; font-size: 11px; line-height: 14px; color: #000; }
.diagram-node .react-flow__handle { opacity: 0; pointer-events: none; }
/* in a draft a handle starts an edge (§5): shown faintly, plainly on the node's hover */
.diagram-node .react-flow__handle.connectable { opacity: .35; pointer-events: all; background: #1a5fb4; border-color: #1a5fb4; cursor: crosshair; }
.diagram-node:hover .react-flow__handle.connectable { opacity: 1; }
.node-header { height: 26px; line-height: 26px; padding: 0 6px; font-weight: 600; border-bottom: 1px solid #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diagram-node.ghost .node-header, .diagram-node[data-form="compact"] .node-header { border-bottom: none; }
.node-row { height: 20px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-row:first-of-type { margin-top: 3px; }
.node-row.reference { font-style: italic; }
.token.badge { font-weight: 400; color: #555; margin-right: 2px; }
.token.outside { text-decoration: underline dotted; }
.token.unbound { color: #a15c00; text-decoration: underline dotted #a15c00; }
.token.absent { color: #777; }
.token.unread { color: #555; }
.diagram-node.marked.advisory, .node-row.marked.advisory, .edge-label.marked.advisory { box-shadow: inset 3px 0 0 #c98a00; }
.diagram-node.marked.refused, .node-row.marked.refused, .edge-label.marked.refused { box-shadow: inset 3px 0 0 #b00020; }
.react-flow__node.selected .diagram-node { outline: 2px solid #1a5fb4; }
.diagram-edge { stroke: #000; stroke-width: 1; }
.diagram-edge.reference { stroke-dasharray: 4 3; }
#pamola-arrow path { fill: #000; }
#pamola-triangle path.hollow { fill: #fff; stroke: #000; stroke-width: 1; }
/* a container's arrangement (#844 container.band): a full-width band, its name at its top left, a line between neighbours */
.diagram-node.arranged.band { border: none; border-top: 1px solid #000; background: transparent; }
.diagram-node.arranged.band > .node-header { border-bottom: none; font-weight: 400; }
/* a shape (#844 expandedForm): the outline is drawn behind the name and rows, the box itself has none */
.diagram-node.shaped { border: none; background: transparent; position: relative; overflow: visible; }
.diagram-node.shaped .node-outline { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; overflow: visible; }
.diagram-node.shaped .node-outline path { fill: #fff; stroke: #000; stroke-width: 1; }
.diagram-node.shaped > .node-header { margin-top: 6px; text-align: center; border-bottom: none; }
.diagram-node.shaped.with-rows > .node-header { border-bottom: 1px solid #000; }
.edge-label { position: absolute; background: #fff; padding: 0 3px; font: 11px/16px system-ui, sans-serif; white-space: nowrap;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; pointer-events: all; }
.diagram-menu { z-index: 10; margin: 0; }
.findings li.refused { border-left: 3px solid #b00020; padding-left: 4px; }
.findings li.advisory { border-left: 3px solid #c98a00; padding-left: 4px; }
.diagram-node.drop-target { outline: 2px dashed #1a5fb4; }
.drop-hint { position: absolute; top: -20px; left: 0; font: 11px/16px system-ui, sans-serif; background: #1a5fb4; color: #fff; padding: 0 4px; white-space: nowrap; }
.diagram-node { position: relative; overflow: visible; }
.token-edit { font: inherit; width: calc(100% - 8px); }
.token.editable { cursor: text; text-decoration: underline dotted transparent; } .token.editable:hover { text-decoration-color: currentColor; }
.display-panel { border: 1px solid var(--line); background: var(--bg); padding: 6px 8px; margin: 4px 0; display: grid; gap: 4px; max-width: min(28rem, 100%); }
.display-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.display-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.just-committed > .line { outline: 1px solid var(--line); }
.route-segment { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: move; }
.bend { position: absolute; width: 8px; height: 8px; background: #fff; border: 1px solid #1a5fb4; pointer-events: all; cursor: move; }
.bend.hand { background: #1a5fb4; }

/* §3a point 3: one floating menu at the pointer, over the content, moving nothing; submenus open to the right */
.floating-menu { z-index: 50; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); border-radius: 4px; background: var(--bg); }
.floating-menu > .menu, .floating-menu .menu { margin: 0; }
.menu-folder > .menu-folder-label { display: block; width: 100%; text-align: left; border: none; background: transparent; }
.menu-folder > .menu-folder-label::after { content: ' ▸'; float: right; padding-left: 1.5em; color: var(--muted); }
.floating-submenu { z-index: 51; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); }
.menu-group-label { font-size: 12px; color: var(--muted); padding: 4px 8px 0; border-top: 1px solid var(--line); }
/* empty space below the last row: a right-click there gives the window's clade menu (§3a point 3) */
.server-view .rows, .text-window .text-rows { min-height: 50vh; }
/* in a window, the tree and a text window fill it, so the empty space below the rows reaches the window's foot */
.window .server-view, .window .text-window { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.window .server-view .rows, .window .text-window .text-rows { flex: 1; min-height: auto; }
/* a ward stands inside the node it is a ward of (17 Oct 11:19): edge labels and bend handles stay above every box */
.diagram-window .react-flow__edgelabel-renderer { z-index: 5000; }   /* React Flow lifts an edge between nested nodes by 1000 */
/* a double-click on a row opens Clade ▸ See (17 Oct 11:19): it selects no text */
.server-view .row .line { user-select: none; }
/* a dialogue (17 Oct 12:49): named slots, Run, and the result read-only beneath */
.dialogue .slots { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.dialogue .slot { display: flex; flex-direction: column; gap: 2px; }
.dialogue .slot-label { font-weight: 600; }
.dialogue .slot input { min-width: 0; }
.dialogue .result { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
.dialogue .result-heading { font-size: 14px; margin: 4px 0; }
.dialogue .result-row { cursor: context-menu; }

/* A box's resize corner (diagrams §6a.1): a small grip at its bottom-right, shown on hover */
.react-flow__resize-control.resize-corner { background: transparent; border: none; width: 12px; height: 12px; }
.resize-grip { display: block; width: 10px; height: 10px; border-right: 2px solid #888; border-bottom: 2px solid #888;
  opacity: 0; cursor: nwse-resize; }
.diagram-node:hover .resize-grip, .react-flow__node.selected .resize-grip { opacity: 1; }
