/* Atlas_Trace — warm-dark link-analysis console.
   Palette from the Atlas_Trace direction: near-black warm neutral, red primary,
   green for confirmed movement. The board is the app; panels float over it. */

:root {
  --bg:        oklch(0.10 0.003 40);
  --bg-2:      oklch(0.13 0.004 45);
  --surface:   oklch(0.15 0.006 50);
  --surface-2: oklch(0.19 0.008 50);
  --line:      oklch(0.27 0.008 50);
  --line-soft: oklch(0.22 0.008 50);

  --text:  oklch(0.95 0.008 50);
  --dim:   oklch(0.72 0.008 50);
  --muted: oklch(0.55 0.008 50);
  --faint: oklch(0.40 0.008 50);

  --red:      oklch(0.60 0.19 25);
  --red-soft: oklch(0.60 0.19 25 / 0.14);
  --green:    oklch(0.65 0.16 150);
  --amber:    oklch(0.76 0.15 75);
  --cyan:     oklch(0.72 0.11 210);
  --blue:     oklch(0.66 0.14 255);
  --violet:   oklch(0.68 0.16 300);

  /* Risk bands. Distinct from the entity palette on purpose — the subject is
     red, so red alone must not be what "dangerous" looks like. */
  --risk-low:      oklch(0.62 0.03 240);
  --risk-elevated: oklch(0.78 0.14 85);
  --risk-high:     oklch(0.70 0.17 45);
  --risk-critical: oklch(0.62 0.24 12);

  --mono: 'JetBrains Mono', 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
  --sans: 'Space Grotesk', system-ui, sans-serif;

  --shadow: 0 18px 44px oklch(0 0 0 / 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* Panels and menus set `display`, which would otherwise beat the UA rule for
   the hidden attribute and make them impossible to close. */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: repeating-linear-gradient(
    to bottom, oklch(1 0 0 / 0.012) 0 1px, transparent 1px 3px);
}
body.is-dragging { user-select: none; cursor: grabbing; }

::selection { background: var(--red-soft); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ── top bar ───────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; flex-shrink: 0; z-index: 60;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--bg));
}

.brand { display: flex; align-items: baseline; gap: 9px; flex-shrink: 0; }
.brand-mark {
  font-family: var(--mono); font-weight: 700; font-size: 19px; color: var(--red);
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.35; } }
.brand-name { font-family: var(--mono); font-weight: 500; font-size: 19px; letter-spacing: -0.02em; }
.brand-sub {
  font-size: 10.5px; color: var(--muted); text-transform: lowercase;
  letter-spacing: 0.06em; padding-left: 9px; border-left: 1px solid var(--line);
}

.toolbar {
  display: flex; gap: 3px; padding: 3px; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.tool {
  min-width: 32px; padding: 4px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  border: 1px solid transparent; transition: all 0.12s;
}
.tool:hover { color: var(--text); background: var(--surface-2); }
.tool.is-active { color: var(--red); background: var(--red-soft); border-color: oklch(0.60 0.19 25 / 0.4); }

.add-type {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; font-family: var(--mono); font-size: 12px; color: var(--dim);
}

.board-stats { display: flex; gap: 14px; margin-left: 4px; }
.bstat { text-align: center; line-height: 1.1; }
.bstat b { display: block; font-family: var(--mono); font-size: 15px; color: var(--text); }
.bstat b.red { color: var(--red); }
.bstat span {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint);
}

.search {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 0 13px; height: 38px; width: 100%;
}
.search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search-sig { font-family: var(--mono); color: var(--faint); font-size: 13px; }
.search input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  font-family: var(--mono); font-size: 13.5px;
}
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.4); }

.status-strip { display: flex; gap: 7px; flex-shrink: 0; }
.chip {
  font-family: var(--mono); font-size: 10.5px; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface); color: var(--dim); white-space: nowrap;
}
.chip-ok      { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.4); }
.chip-warn    { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.4); }
.chip-bad     { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.45); background: var(--red-soft); }
.chip-pending { color: var(--faint); }
.chip-operator { color: var(--dim); font-family: var(--mono); cursor: default; }
.chip-operator::before { content: '◍ '; color: var(--green); }
.chip-operator.is-admin { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.4); }
.chip-operator.is-admin::before { color: var(--amber); }

.chip-logout {
  color: var(--muted); font-family: var(--mono); cursor: pointer;
  transition: all 0.12s;
}
.chip-logout:hover {
  color: var(--red); border-color: oklch(0.60 0.19 25 / 0.45);
  background: var(--red-soft);
}
.chip-logout:disabled { opacity: 0.5; cursor: progress; }

/* ── the board ─────────────────────────────────────────────────────────── */

.stage { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.board-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }

/* ── panel rail ────────────────────────────────────────────────────────── */

.rail {
  width: 76px; flex-shrink: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  padding: 10px 6px; overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, var(--surface), var(--bg));
}
.case-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; margin-bottom: 8px; border-radius: 7px;
  border: 1px solid oklch(0.60 0.19 25 / 0.35); background: var(--red-soft);
  color: var(--red); transition: all 0.12s;
}
.case-btn:hover { filter: brightness(1.25); }
.case-btn-glyph { font-family: var(--mono); font-size: 15px; line-height: 1; }
.case-btn-name {
  font-family: var(--mono); font-size: 8.5px; line-height: 1.2; text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rail-label {
  font-family: var(--mono); font-size: 8.5px; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--faint); text-align: center; padding-bottom: 6px;
}
.rail-panels { display: flex; flex-direction: column; gap: 3px; }
.rail-spacer { flex: 1; min-height: 10px; }

.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px; border-radius: 7px; border: 1px solid transparent;
  color: var(--muted); transition: all 0.12s;
}
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn.is-open {
  color: var(--red); background: var(--red-soft);
  border-color: oklch(0.60 0.19 25 / 0.35);
}
.rail-glyph { font-family: var(--mono); font-size: 15px; line-height: 1; }
.rail-name {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.04em;
  text-align: center; line-height: 1.2; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-util {
  padding: 6px 2px; border-radius: 6px; color: var(--muted);
  font-family: var(--mono); font-size: 14px; border: 1px solid transparent;
}
.rail-util:hover { color: var(--red); border-color: var(--line); background: var(--surface-2); }

#board {
  position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab;
  touch-action: none; /* the board handles its own panning and pinching */
}
#board[data-mode='add']    { cursor: crosshair; }
#board[data-mode='link']   { cursor: cell; }
#board[data-mode='delete'] { cursor: not-allowed; }
body.is-dragging #board { cursor: grabbing; }

.at-node { cursor: grab; }
.at-node:active { cursor: grabbing; }
.at-label {
  fill: var(--text); font-family: var(--mono); font-weight: 500;
  user-select: none; pointer-events: none;
}
.at-sublabel {
  fill: var(--faint); font-family: var(--mono); user-select: none; pointer-events: none;
}
.at-glyph { user-select: none; pointer-events: none; font-family: var(--mono); }
.at-ring { animation: ringSpin 12s linear infinite; transform-origin: center; }
@keyframes ringSpin { to { stroke-dashoffset: -80; } }
.at-edge { cursor: pointer; }
.at-edge-label { font-family: var(--mono); user-select: none; pointer-events: none; }
.at-edge-dash { animation: edgeDash 1.4s linear infinite; }
@keyframes edgeDash { to { stroke-dashoffset: -24; } }

.hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 18px; z-index: 30; pointer-events: none;
  background: var(--red-soft); border: 1px solid oklch(0.60 0.19 25 / 0.35);
  color: var(--red); font-family: var(--mono); font-size: 12px;
}

.tooltip {
  position: fixed; top: 0; left: 0; z-index: 300; pointer-events: none;
  min-width: 190px; max-width: 300px; padding: 9px 11px; border-radius: 8px;
  background: oklch(0.13 0.004 45 / 0.97); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-family: var(--mono); font-size: 11px;
}
.tip-head { color: var(--text); font-size: 12px; margin-bottom: 3px; }
.tip-addr { color: var(--faint); font-size: 10px; word-break: break-all; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.tip-row b { color: var(--dim); font-weight: 500; }
.tip-labels { margin-top: 5px; color: var(--amber); font-size: 10.5px; }
.tip-hint { margin-top: 6px; color: var(--faint); font-size: 9.5px; }

.minimap {
  position: absolute; right: 16px; bottom: 16px; z-index: 30;
  background: oklch(0.13 0.004 45 / 0.92); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; line-height: 0;
}

.zoom-stack {
  position: absolute; left: 16px; bottom: 16px; z-index: 30;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.zoom-btn {
  width: 30px; height: 30px; border-radius: 7px;
  background: oklch(0.13 0.004 45 / 0.92); border: 1px solid var(--line);
  color: var(--muted); font-family: var(--mono); font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s;
}
.zoom-btn:hover { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.4); }
.zoom-level { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }

/* ── floating windows ──────────────────────────────────────────────────── */

.windows { position: absolute; inset: 0; pointer-events: none; }

.win {
  position: absolute; pointer-events: auto;
  display: flex; flex-direction: column; overflow: hidden;
  background: oklch(0.15 0.006 50 / 0.96);
  border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}
.win.is-active { border-color: oklch(0.60 0.19 25 / 0.45); }
.win.is-min .win-body, .win.is-min .win-resize { display: none; }

.win-head {
  display: flex; align-items: center; gap: 8px; height: 28px; flex-shrink: 0;
  padding: 0 8px 0 10px; cursor: grab; user-select: none;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.win-head:active { cursor: grabbing; }
.win-grip { font-family: var(--mono); color: var(--faint); font-size: 11px; letter-spacing: -1px; }
.win-title {
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--dim);
}
.win.is-active .win-title { color: var(--red); }
.win-rule {
  flex: 1; height: 1px; color: var(--line);
  background-image: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px);
}
.win-tag {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win-btn {
  width: 18px; height: 18px; border-radius: 4px; color: var(--muted);
  font-family: var(--mono); font-size: 12px; line-height: 1;
}
.win-btn:hover { background: var(--surface-2); color: var(--text); }
.win-btn[data-act='close']:hover { background: var(--red-soft); color: var(--red); }

.win-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }

/* Resize handles — thin strips on every edge, larger pads at the corners. */
.win-edge { position: absolute; z-index: 2; }
.win.is-min .win-edge:not(.win-edge-e):not(.win-edge-w) { display: none; }

.win-edge-n { top: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-edge-s { bottom: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-edge-e { right: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-edge-w { left: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-edge-ne { top: -3px; right: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-edge-nw { top: -3px; left: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-edge-sw { bottom: -3px; left: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-edge-se {
  bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize;
  color: var(--faint); font-size: 9px; line-height: 16px; text-align: right;
  padding-right: 1px;
}
.win-edge-se:hover { color: var(--red); }

/* ── command panel ─────────────────────────────────────────────────────── */

.cmd-picker {
  margin: 10px 12px 0; padding: 7px 9px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; color: var(--text); outline: none;
}
.cmd-picker:focus { border-color: var(--red); }

.blurb {
  padding: 8px 12px 2px; font-size: 12px; line-height: 1.45;
  color: var(--muted); text-transform: lowercase;
}

.fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 10px; padding: 8px 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font-family: var(--mono); font-size: 12px;
  outline: none; transition: border-color 0.12s, box-shadow 0.12s; min-width: 0;
}
.field textarea { resize: vertical; min-height: 54px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field .hint { font-size: 10px; color: var(--faint); text-transform: lowercase; }

.toggle {
  display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 5px 0;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
}
.toggle input { display: none; }
.toggle .box {
  font-family: var(--mono); color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px;
}
.toggle input:checked + .box { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.45); }

.preview {
  margin: 4px 12px 0; padding: 7px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; color: var(--green);
  background: var(--bg); border: 1px solid var(--line-soft);
  overflow-x: auto; white-space: nowrap;
}
.preview.invalid { color: var(--amber); }

.lint:empty { display: none; }
.lint { display: flex; flex-direction: column; gap: 4px; margin: 7px 12px 0; }
.lint-note {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.45;
  padding: 6px 8px; border-radius: 5px; border-left: 2px solid;
}
.lint-note.is-error { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.lint-note.is-warn { color: var(--amber); background: oklch(0.76 0.15 75 / 0.1); border-color: var(--amber); }
.lint-note::before { content: '! '; }

.preview-row {
  display: flex; gap: 8px; padding: 10px 12px; margin-top: auto;
  border-top: 1px solid var(--line-soft);
}
.btn {
  font-family: var(--mono); font-size: 11.5px; border-radius: 6px;
  padding: 7px 12px; white-space: nowrap; transition: filter 0.12s, background 0.12s;
}
.btn-primary { background: var(--red); color: oklch(0.98 0.01 25); font-weight: 700; flex: 1; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { border: 1px solid var(--line); color: var(--dim); background: var(--surface-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { border: 1px solid var(--red); color: var(--red); background: var(--red-soft); }

/* ── terminal ──────────────────────────────────────────────────────────── */

.term {
  flex: 1; min-height: 0; overflow: auto; background: var(--bg);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  padding: 10px 12px; color: var(--dim);
  white-space: pre-wrap; word-break: break-word;
}
.term:focus { outline: none; }
.term .l-banner { color: var(--red); }
.term .l-cmd { color: var(--text); }
.term .l-cmd .sig { color: var(--red); }
.term .l-err { color: var(--red); }
.term .l-ok { color: var(--green); }
.term .l-note { color: var(--faint); }
.term .cursor {
  display: inline-block; width: 7px; height: 13px; vertical-align: -2px;
  background: var(--red); animation: blink 1s steps(1) infinite;
}

/* ── trace readout ─────────────────────────────────────────────────────── */

.map { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.map .empty, .win-body > .empty {
  color: var(--faint); font-size: 12px; line-height: 1.6;
  text-transform: lowercase; padding: 12px;
}
.map-stats { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 5px 9px; min-width: 66px;
}
.stat .k {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--faint);
}
.stat .v { font-family: var(--mono); font-size: 14px; color: var(--text); }
.stat .v.red { color: var(--red); }
.stat .v.green { color: var(--green); }

.tree { font-family: var(--mono); font-size: 11.5px; line-height: 1.7; }
.hop { white-space: pre; display: block; cursor: pointer; }
.hop:hover { background: oklch(1 0 0 / 0.04); }
.hop .stem { color: var(--faint); }
.hop .addr { color: var(--text); }
.hop .arrow { color: var(--red); }
.hop .amount { color: var(--green); }
.hop .usd { color: var(--dim); }
.hop .bar { color: var(--red); }
.hop .bar .off { color: var(--line); }
.hop .swap { color: var(--cyan); }
.hop .meta { color: var(--faint); }

.section-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--faint);
  margin: 14px 12px 7px; display: flex; align-items: center; gap: 8px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.map .section-label { margin-left: 0; margin-right: 0; }

.terminal-node {
  font-family: var(--mono); font-size: 11px; line-height: 1.55; cursor: pointer;
  padding: 5px 8px; border-left: 2px solid var(--line); margin-bottom: 4px;
  background: var(--surface-2); border-radius: 0 5px 5px 0;
}
.terminal-node:hover { background: oklch(0.22 0.008 50); }
.terminal-node.r-labeled-entity { border-left-color: var(--green); }
.terminal-node.r-mixer { border-left-color: var(--red); }
.terminal-node.r-bridge { border-left-color: var(--cyan); }
.terminal-node.r-max-depth { border-left-color: var(--amber); }
.terminal-node .reason { color: var(--muted); }
.terminal-node .labels { color: var(--amber); }

/* ── inspector ─────────────────────────────────────────────────────────── */

.insp-head {
  display: flex; gap: 10px; align-items: center;
  padding: 12px; border-bottom: 1px solid var(--line-soft);
}
.insp-glyph {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 16px; color: var(--red);
  background: var(--red-soft); border: 1px solid oklch(0.60 0.19 25 / 0.35);
}
.insp-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.insp-addr { font-family: var(--mono); font-size: 10px; color: var(--faint); word-break: break-all; }

/* ── risk block ────────────────────────────────────────────────────────── */

.risk-block {
  margin: 10px 12px; padding: 10px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.risk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.risk-score {
  font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1;
  min-width: 44px; text-align: center; padding: 5px 6px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.risk-score.is-low { color: var(--risk-low); }
.risk-score.is-elevated { color: var(--risk-elevated); border-color: var(--risk-elevated); }
.risk-score.is-high { color: var(--risk-high); border-color: var(--risk-high); }
.risk-score.is-critical {
  color: var(--risk-critical); border-color: var(--risk-critical);
  background: color-mix(in oklch, var(--risk-critical) 12%, transparent);
}
.risk-meta { display: flex; flex-direction: column; gap: 2px; }
.risk-band {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--dim);
}
.risk-origin { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.risk-filed { font-family: var(--mono); font-size: 9.5px; color: var(--green); cursor: help; }
.risk-filed.is-unfiled { color: var(--faint); }

.risk-slider { width: 100%; accent-color: var(--risk-high); cursor: pointer; }

.risk-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.risk-chip {
  font-family: var(--mono); font-size: 9.5px; padding: 3px 7px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--line); color: var(--risk-elevated);
  cursor: help;
}
.risk-acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.tip-risk {
  font-family: var(--mono); font-size: 10.5px; margin-bottom: 6px;
  padding: 3px 6px; border-radius: 4px; border-left: 2px solid;
}
.tip-risk.is-low { color: var(--risk-low); border-color: var(--risk-low); }
.tip-risk.is-elevated { color: var(--risk-elevated); border-color: var(--risk-elevated); }
.tip-risk.is-high { color: var(--risk-high); border-color: var(--risk-high); }
.tip-risk.is-critical {
  color: var(--risk-critical); border-color: var(--risk-critical);
  background: color-mix(in oklch, var(--risk-critical) 14%, transparent);
}
.tip-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tip-flags span { font-size: 9.5px; color: var(--risk-elevated); }

.at-flag { cursor: help; }
.at-risk-value { font-family: var(--mono); user-select: none; pointer-events: none; }

.insp-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  margin: 10px 12px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-radius: 6px; overflow: hidden;
}
.insp-fact {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 5px 8px; background: var(--surface);
  font-family: var(--mono); font-size: 10.5px;
}
.insp-fact .k { color: var(--faint); }
.insp-fact .v { color: var(--dim); }

.insp-link {
  display: flex; gap: 8px; align-items: baseline; width: calc(100% - 24px);
  margin: 0 12px 3px; padding: 5px 8px; border-radius: 5px; text-align: left;
  background: var(--surface-2); font-family: var(--mono); font-size: 10.5px; color: var(--dim);
}
.insp-link:hover { background: oklch(0.23 0.008 50); }
.insp-link .dir { color: var(--red); }
.insp-link .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-link .amt { color: var(--green); }

.insp-hash {
  font-family: var(--mono); font-size: 10px; color: var(--dim); cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; word-break: break-all;
}
.insp-hash:hover { color: var(--text); border-color: var(--muted); }

.insp-actions {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 12px; margin-top: auto;
}
.insp-action {
  font-family: var(--mono); font-size: 10.5px; padding: 5px 9px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--dim);
  transition: all 0.12s;
}
.insp-action:hover { color: var(--text); border-color: var(--muted); background: oklch(0.23 0.008 50); }
.insp-action.danger { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.35); background: var(--red-soft); }

/* ── run log ───────────────────────────────────────────────────────────── */

.history { list-style: none; overflow-y: auto; padding: 8px 10px; }
.history li {
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  padding: 4px 7px; border-radius: 5px; display: flex; gap: 7px;
  align-items: baseline; cursor: pointer;
}
.history li:hover { background: var(--surface-2); }
.history .dot { font-size: 8px; }
.history .dot.ok { color: var(--green); }
.history .dot.bad { color: var(--red); }
.history .dot.run { color: var(--amber); }
.history .cmd { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .ms { color: var(--faint); font-size: 10px; }
.history .empty { color: var(--faint); cursor: default; }

/* ── legend ────────────────────────────────────────────────────────────── */

.legend { padding: 4px 0 12px; }
.legend .section-label { margin-top: 12px; }
.legend-row {
  display: flex; align-items: center; gap: 9px; padding: 3px 12px;
  font-family: var(--mono); font-size: 11px; color: var(--dim); cursor: default;
}
.legend-row:hover { background: var(--surface-2); }
.legend-glyph { width: 16px; text-align: center; font-size: 13px; }
.legend-line { width: 22px; letter-spacing: -1px; }
.legend-label { flex: 1; }
.legend-shape, .legend-count { color: var(--faint); font-size: 10px; }
.legend-count { color: var(--text); font-size: 11px; }

/* ── agent panel ───────────────────────────────────────────────────────── */

.agent-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.agent-msg { display: flex; flex-direction: column; gap: 3px; }
.agent-role {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--faint);
}
.agent-msg.is-you .agent-role { color: var(--red); }
.agent-text {
  font-size: 12.5px; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.agent-msg.is-you .agent-text {
  color: var(--dim); border-left: 2px solid var(--red);
  padding-left: 9px; background: var(--red-soft); border-radius: 0 6px 6px 0;
  padding: 6px 9px;
}
.agent-note {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.5; color: var(--faint);
  text-transform: lowercase;
}
.agent-note.is-err {
  color: var(--red); background: var(--red-soft); border-left: 2px solid var(--red);
  padding: 6px 8px; border-radius: 0 5px 5px 0; text-transform: none;
}
.agent-tool {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 8px;
  border-radius: 5px; background: var(--surface-2); border-left: 2px solid var(--green);
  font-family: var(--mono); font-size: 10.5px;
}
.agent-tool-name { color: var(--green); }
.agent-tool-name::before { content: '▸ '; }
.agent-tool-args {
  color: var(--faint); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.agent-form {
  flex-shrink: 0; padding: 10px 12px; border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.agent-input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 9px; font-family: var(--sans); font-size: 12.5px; color: var(--text);
  outline: none; resize: vertical; min-height: 44px;
}
.agent-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.agent-input::placeholder { color: var(--faint); }
.agent-controls { display: flex; gap: 7px; }
.agent-controls .btn-primary { flex: 1; }

/* ── csv panel ─────────────────────────────────────────────────────────── */

.csv-bar {
  display: flex; gap: 7px; padding: 10px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.csv-name {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font-family: var(--mono); font-size: 12px;
  outline: none;
}
.csv-name:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.csv-bar .btn-primary { flex: 0 0 auto; }

.csv-notes { padding: 8px 12px 0; display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.csv-note { font-family: var(--mono); font-size: 10px; color: var(--faint); }

.csv-table-wrap { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 12px; }
.csv-table { border-collapse: collapse; font-family: var(--mono); font-size: 10.5px; }
.csv-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  background: var(--surface-2); color: var(--dim); font-weight: 500;
  padding: 5px 8px; border-bottom: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 9.5px;
}
.csv-table td {
  padding: 4px 8px; color: var(--dim); border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis;
}
.csv-table td.num { color: var(--red); }
.csv-table tbody tr:hover td { background: oklch(1 0 0 / 0.03); color: var(--text); }

.csv-status {
  font-family: var(--mono); font-size: 10.5px; padding: 7px 12px; flex-shrink: 0;
  border-top: 1px solid var(--line-soft);
}
.csv-status.is-ok { color: var(--green); }
.csv-status.is-err { color: var(--red); background: var(--red-soft); }

/* ── case folder panel ─────────────────────────────────────────────────── */

.files-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.files-case {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.files-list .empty { padding: 12px 6px; }

.file-row { display: flex; align-items: stretch; gap: 4px; }
.file-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line-soft);
  background: var(--surface-2); transition: all 0.12s;
}
.file-open:hover { border-color: var(--muted); background: oklch(0.23 0.008 50); }
.file-glyph { font-family: var(--mono); color: var(--green); font-size: 13px; }
.file-text { min-width: 0; display: flex; flex-direction: column; }
.file-name {
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.file-act {
  display: flex; align-items: center; justify-content: center; width: 26px;
  border-radius: 6px; border: 1px solid var(--line-soft); background: var(--surface-2);
  color: var(--muted); font-family: var(--mono); font-size: 13px; text-decoration: none;
  transition: all 0.12s;
}
.file-act:hover { color: var(--text); border-color: var(--muted); }
.file-act.danger:hover { color: var(--red); background: var(--red-soft); border-color: var(--red); }

/* ── one-off question ──────────────────────────────────────────────────── */

.ask-overlay {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background: oklch(0.10 0.003 40 / 0.8); backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
}
.ask-panel {
  width: min(520px, 100%); padding: 24px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.ask-title {
  font-family: var(--mono); font-size: 17px; color: var(--text); margin-bottom: 10px;
}
.ask-body {
  font-size: 12.5px; line-height: 1.55; color: var(--dim);
  text-transform: lowercase; margin-bottom: 16px;
}
.ask-options { display: flex; flex-direction: column; gap: 8px; }
.ask-option {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: all 0.12s;
}
.ask-option:hover { border-color: var(--red); background: var(--red-soft); }
.ask-option-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.ask-option-note {
  font-size: 11.5px; line-height: 1.45; color: var(--muted); text-transform: lowercase;
}
.ask-foot {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  margin-top: 14px; text-transform: lowercase;
}

/* Rows for entities still waiting to be placed. */
.csv-table tbody tr.is-unplaced { cursor: crosshair; }
.csv-table tbody tr.is-unplaced td { color: var(--amber); }
.csv-table tbody tr.is-unplaced td:first-child::before { content: '⊕ '; color: var(--amber); }
.csv-table tbody tr.is-unplaced:hover td {
  background: oklch(0.76 0.15 75 / 0.12); color: var(--text);
}
#board[data-mode='place'] { cursor: copy; }

/* ── case picker ───────────────────────────────────────────────────────── */

.case-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background: oklch(0.10 0.003 40 / 0.86); backdrop-filter: blur(7px);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.case-panel {
  width: min(860px, 100%); max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}

.case-head { padding: 22px 26px 16px; border-bottom: 1px solid var(--line-soft); }
.case-head .brand { margin-bottom: 6px; }
.case-head .brand-name { font-size: 24px; }
.case-head .brand-mark { font-size: 24px; }
.case-tagline { font-size: 12.5px; color: var(--muted); text-transform: lowercase; }

.case-columns {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 0;
  min-height: 0; flex: 1;
}
.case-col { padding: 16px 22px; min-height: 0; display: flex; flex-direction: column; }
.case-col-new { border-left: 1px solid var(--line-soft); background: var(--bg); }
.case-col .section-label { margin: 0 0 10px; }

.case-list { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; min-height: 140px; }
.case-empty {
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
  padding: 18px 4px; text-transform: lowercase;
}

.case-row {
  text-align: left; padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--surface-2);
  transition: all 0.12s;
}
.case-row:hover { border-color: var(--muted); background: oklch(0.23 0.008 50); }
.case-row.is-active { border-color: var(--red); background: var(--red-soft); }
.case-row-top { display: flex; align-items: baseline; gap: 8px; }
.case-id { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.case-name { font-family: var(--mono); font-size: 13px; color: var(--text); flex: 1; }
.case-status {
  font-family: var(--mono); font-size: 9.5px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--muted); text-transform: uppercase;
}
.case-status.is-open { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.4); }
.case-desc { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.case-meta {
  display: flex; gap: 10px; margin-top: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--faint);
}
.case-current { color: var(--red); }

.case-row-wrap { display: flex; align-items: stretch; gap: 5px; }
.case-row-wrap .case-row { flex: 1; min-width: 0; }
.case-acts { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.case-act {
  font-family: var(--mono); font-size: 9.5px; padding: 4px 8px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  transition: all 0.12s; min-width: 58px;
}
.case-act:hover { color: var(--text); border-color: var(--muted); }
.case-act.danger { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.3); }
.case-act.danger:hover { background: var(--red-soft); }

.case-col-new .field { margin-bottom: 10px; }
.case-col-new .btn-primary { width: 100%; }
.case-error {
  font-family: var(--mono); font-size: 10.5px; color: var(--red);
  background: var(--red-soft); border-left: 2px solid var(--red);
  padding: 6px 8px; border-radius: 5px; margin-top: 10px;
}
.case-hint {
  font-size: 11px; line-height: 1.5; color: var(--faint);
  text-transform: lowercase; margin-top: auto; padding-top: 14px;
}

.case-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 22px; border-top: 1px solid var(--line-soft);
}

@media (max-width: 720px) {
  .case-columns { grid-template-columns: 1fr; }
  .case-col-new { border-left: none; border-top: 1px solid var(--line-soft); }
}

/* ── context menu ──────────────────────────────────────────────────────── */

.ctx-menu {
  position: fixed; z-index: 400; min-width: 178px; padding: 4px;
  background: oklch(0.15 0.006 50 / 0.98); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.ctx-menu hr { border: none; height: 1px; background: var(--line-soft); margin: 4px 2px; }
.ctx-item {
  text-align: left; padding: 6px 10px; border-radius: 5px;
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
}
.ctx-item:hover { background: var(--surface-2); color: var(--text); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red-soft); }

/* ── transactions and the investigation's origin ───────────────────────── */

.at-origin-ring { animation: originSpin 18s linear infinite; transform-origin: center; }
@keyframes originSpin { to { stroke-dashoffset: -60; } }
.at-origin-tag {
  font-family: var(--mono); letter-spacing: 0.12em;
  user-select: none; pointer-events: none;
}

.origin-note {
  margin: 10px 12px 0; padding: 7px 9px; border-radius: 6px;
  border-left: 2px solid var(--green);
  background: color-mix(in oklch, var(--green) 10%, transparent);
  font-family: var(--mono); font-size: 10.5px; color: var(--green);
}

/* The remembered answer, pre-selected so repeating it is one keypress. */
.ask-option.is-preferred {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px oklch(0.60 0.19 25 / 0.35);
}
.ask-option.is-preferred .ask-option-name::after {
  content: '  ⏎'; color: var(--red); font-size: 11px;
}
.ask-option:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }


/* ── find bar: search, facets, result count ─────────────────────────────── */

.find {
  position: relative; display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex: 1 1 520px; max-width: 720px; min-width: 240px;
}
.search-clear {
  border: none; background: none; color: var(--faint); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px;
}
.search-clear:hover { color: var(--red); }

.filter-btn {
  position: relative; flex-shrink: 0; height: 38px; min-width: 44px; padding: 0 12px;
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  color: var(--dim); font-family: var(--mono); font-size: 15px;
}
.filter-btn:hover { color: var(--text); border-color: var(--line); }
.filter-btn.is-on { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.5); background: var(--red-soft); }
.filter-count {
  font-size: 10px; font-weight: 700; background: var(--red); color: var(--bg);
  border-radius: 8px; padding: 0 5px; line-height: 15px;
}
.find-result {
  font-family: var(--mono); font-size: 10.5px; color: var(--amber);
  white-space: nowrap; flex-shrink: 0;
}

.filter-menu {
  position: absolute; top: 44px; right: 0; z-index: 200; width: 320px;
  max-height: 70vh; overflow-y: auto; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.filter-group { margin-bottom: 10px; }
.filter-group-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--faint); margin-bottom: 5px;
}
.filter-opt {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 4px 0;
  padding: 4px 8px; cursor: pointer; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  color: var(--dim); font-family: var(--mono); font-size: 11px;
}
.filter-opt:hover { border-color: var(--line); color: var(--text); }
.filter-opt.is-on { background: var(--red-soft); border-color: oklch(0.60 0.19 25 / 0.5); color: var(--red); }
.filter-opt.is-empty { opacity: 0.4; }
.filter-opt b { color: var(--faint); font-weight: 500; }
.filter-opt.is-on b { color: var(--red); }
.filter-foot { display: flex; gap: 6px; margin-top: 4px; }
.filter-toggle, .filter-reset {
  flex: 1; padding: 6px; cursor: pointer; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  color: var(--dim); font-family: var(--mono); font-size: 11px;
}
.filter-toggle.is-on { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.45); }
.filter-toggle:hover, .filter-reset:hover { color: var(--text); }
.filter-reset { flex: 0 0 80px; }
.filter-hint {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 9.5px; color: var(--faint); line-height: 1.5;
}

/* ── board markers ──────────────────────────────────────────────────────── */

.at-node.is-dim { opacity: 0.14; }
.at-node.is-hit .at-label { fill: var(--amber); }
.at-halo { pointer-events: none; }
.at-select-ring { pointer-events: none; animation: selectPulse 1.8s ease-in-out infinite; }
@keyframes selectPulse { 50% { opacity: 0.45; } }
.at-markers, .at-currency { pointer-events: none; }
.at-marker text, .at-currency text { font-family: var(--mono); user-select: none; }
.at-node.is-cluster { cursor: pointer; }

/* ── selection summary ──────────────────────────────────────────────────── */

.summary {
  position: absolute; left: 16px; bottom: 16px; z-index: 40; width: 296px;
  max-height: calc(100% - 120px); overflow-y: auto; padding: 12px 13px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(7px);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.summary-close {
  position: absolute; top: 6px; right: 8px; border: none; background: none;
  color: var(--faint); font-size: 15px; line-height: 1; cursor: pointer;
}
.summary-close:hover { color: var(--red); }
.summary-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; padding-right: 14px; }
.summary-glyph { font-family: var(--mono); font-size: 20px; }
.summary-title { font-family: var(--sans); font-weight: 600; font-size: 13.5px; color: var(--text); }
.summary-kind { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.summary-cur { margin-left: auto; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.summary-addr {
  display: flex; align-items: center; gap: 6px; margin-bottom: 9px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px; padding: 5px 7px;
}
.summary-addr code {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 10px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-copy {
  border: none; background: none; color: var(--faint); cursor: pointer;
  font-family: var(--mono); font-size: 9.5px;
}
.summary-copy:hover { color: var(--green); }

.summary-risk { margin-bottom: 9px; font-family: var(--mono); font-size: 10px; color: var(--dim); }
.summary-risk-bar {
  height: 4px; border-radius: 3px; background: var(--bg); overflow: hidden; margin-bottom: 4px;
}
.summary-risk-bar i { display: block; height: 100%; background: var(--risk-low); }
.summary-risk.is-elevated .summary-risk-bar i { background: var(--risk-elevated); }
.summary-risk.is-high .summary-risk-bar i { background: var(--risk-high); }
.summary-risk.is-critical .summary-risk-bar i { background: var(--risk-critical); }

.summary-marks { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 9px; }
.summary-marks.is-none {
  font-family: var(--mono); font-size: 10px; color: var(--faint); display: block;
}
.summary-mark, .insp-mark {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 11px; font-family: var(--mono); font-size: 10px;
  color: var(--mark); border: 1px solid color-mix(in oklch, var(--mark) 45%, transparent);
  background: color-mix(in oklch, var(--mark) 12%, transparent);
}
.summary-mark.is-maybe, .insp-mark.is-maybe { border-style: dashed; }

.summary-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin-bottom: 8px; }
.summary-facts div { display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 10px; }
.summary-facts span { color: var(--faint); }
.summary-facts b { color: var(--dim); font-weight: 500; }
.summary-labels, .summary-notes {
  font-size: 10.5px; color: var(--dim); line-height: 1.5; margin-bottom: 8px;
  padding: 6px 8px; background: var(--bg); border-radius: 6px;
  border-left: 2px solid var(--line);
}
.summary-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.summary-actions button {
  flex: 1; min-width: 84px; padding: 6px 8px; cursor: pointer; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  color: var(--dim); font-family: var(--mono); font-size: 10.5px;
}
.summary-actions button:hover { color: var(--text); border-color: var(--line); }
.summary-actions button:first-child { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.4); }

/* ── analyze panel additions ────────────────────────────────────────────── */

.insp-currency { margin-left: auto; font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.insp-marks { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.insp-exchange {
  font-size: 10.5px; line-height: 1.5; padding: 7px 9px; border-radius: 6px; margin-bottom: 9px;
  background: var(--bg); border-left: 2px solid var(--green); color: var(--dim);
}
.insp-exchange.is-possible { border-left-color: var(--amber); border-left-style: dashed; }

.tip-exchange {
  margin-top: 5px; font-family: var(--mono); font-size: 10px; color: var(--green);
}
.tip-exchange.is-possible { color: var(--amber); }
.tip-exchange span { display: block; color: var(--faint); }

/* ── grouping: marquee, multi-selection, clusters ───────────────────────── */

.at-marquee {
  fill: color-mix(in oklch, var(--amber) 10%, transparent);
  stroke: var(--amber); stroke-width: 1; stroke-dasharray: 5,4; pointer-events: none;
}
.at-multi-ring { pointer-events: none; animation: ringSpin 9s linear infinite; transform-origin: center; }
.at-node.is-multi .at-label { fill: var(--amber); }
.at-tether { pointer-events: none; }

.summary-rename {
  width: 100%; background: none; border: none; border-bottom: 1px dashed var(--line);
  color: var(--text); font-family: var(--sans); font-weight: 600; font-size: 13.5px;
  padding: 0 0 2px; outline: none;
}
.summary-rename:focus { border-bottom-color: var(--amber); }
.summary-members { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 9px; }
.summary-members span {
  font-family: var(--mono); font-size: 9.5px; color: var(--dim);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 4px; padding: 2px 5px;
}
.summary-members .more { color: var(--faint); border-style: dashed; }
.summary-field { display: block; margin-bottom: 9px; }
.summary-field span {
  display: block; font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;
}
.summary-field input {
  width: 100%; padding: 6px 8px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-family: var(--mono); font-size: 11px; outline: none;
}
.summary-field input:focus { border-color: var(--amber); }

/* Links out to the admin and database consoles, shown only to administrators. */
.chip-console { color: var(--dim); font-family: var(--mono); text-decoration: none; }
.chip-console:hover { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.45); }


/* ── settings ──────────────────────────────────────────────────────────────
   The switches for how the board behaves, kept out of the way of the work and
   one press from it. */

.settings { position: relative; flex-shrink: 0; }
.settings-btn {
  height: 38px; min-width: 44px; padding: 0 12px; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--dim); font-size: 15px; line-height: 1; transition: all 0.12s;
}
.settings-btn:hover { color: var(--text); border-color: var(--muted); }
.settings-btn[aria-expanded='true'] {
  color: var(--red); border-color: oklch(0.60 0.19 25 / 0.5); background: var(--red-soft);
}

.settings-menu {
  position: absolute; top: 44px; right: 0; z-index: 200; width: 340px;
  max-height: 76vh; overflow-y: auto; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.set-group {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--faint);
  margin: 10px 2px 6px; padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.set-group:first-child { margin-top: 2px; padding-top: 0; border-top: none; }
.set-row {
  display: block; padding: 7px 8px; border-radius: 7px; cursor: pointer;
}
.set-row:hover { background: var(--bg-2); }
.set-row.is-idle { opacity: 0.45; }
.set-head { display: flex; align-items: center; gap: 8px; }
.set-label { flex: 1; font-size: 12.5px; color: var(--text); }
.set-note {
  margin-top: 3px; font-size: 10.5px; line-height: 1.45; color: var(--faint);
  max-width: 40ch;
}
.set-check { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }
.set-number {
  width: 64px; padding: 3px 6px; text-align: right;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
}
.set-unit { font-family: var(--mono); font-size: 10px; color: var(--faint); width: 16px; }
.set-select {
  padding: 3px 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--dim);
}
.set-foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.set-reset {
  width: 100%; padding: 7px; border-radius: 7px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  color: var(--dim); font-family: var(--mono); font-size: 11px;
}
.set-reset:hover { color: var(--text); border-color: var(--line); }

/* ── reduce motion ─────────────────────────────────────────────────────────
   Honoured whether it was asked for in settings or by the operating system. */

:root[data-motion='reduced'] .brand-mark,
:root[data-motion='reduced'] .at-origin-ring { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .brand-mark, .at-origin-ring { animation: none; }
}

/* ── tablet ────────────────────────────────────────────────────────────────
   Two things change on a tablet: targets grow to a finger's width, and the
   top bar folds — the search stays out, everything else goes behind ⋯. */

.bar-more {
  display: none; width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--dim); font-size: 16px; line-height: 1;
}

.pan-pad {
  display: none; position: absolute; right: 16px; bottom: 136px; z-index: 30;
  width: 132px; height: 92px;
}
:root[data-touch='on'] .pan-pad { display: block; }
.pan-btn {
  position: absolute; width: 42px; height: 42px; border-radius: 10px;
  background: oklch(0.13 0.004 45 / 0.92); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.pan-btn:active { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.5); }
.pan-up    { top: 0;    left: 45px; }
.pan-down  { bottom: 0; left: 45px; }
.pan-left  { top: 25px; left: 0; }
.pan-right { top: 25px; right: 0; }

/* Fingers need something to hit; a mouse does not. */
:root[data-touch='on'] .tool { min-width: 44px; padding: 9px 13px; font-size: 15px; }
:root[data-touch='on'] .zoom-btn { width: 42px; height: 42px; font-size: 16px; }
:root[data-touch='on'] .rail-btn { padding: 10px 9px; }
:root[data-touch='on'] .rail-util { width: 38px; height: 38px; }
:root[data-touch='on'] .ctx-item { padding: 11px 12px; font-size: 13px; }
:root[data-touch='on'] .set-row { padding: 11px 8px; }
:root[data-touch='on'] .set-check { width: 20px; height: 20px; }
:root[data-touch='on'] .chip { font-size: 11.5px; padding: 5px 9px; }
:root[data-touch='on'] .minimap { bottom: 16px; right: 158px; }

/* A tablet in landscape: the counts go, the search keeps its width. */
@media (max-width: 1180px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .brand-sub { display: none; }
  .board-stats { gap: 10px; }
  .find { flex-basis: 380px; min-width: 200px; }
}

/* A tablet in portrait, and anything narrower: the bar folds. */
@media (max-width: 900px) {
  .bar-more { display: block; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar > .toolbar,
  .topbar > .board-stats,
  .topbar > .status-strip { display: none; }
  /* Search and the settings share the second row; both stay reachable. */
  .find { order: 3; flex: 1 1 220px; max-width: none; margin-left: 0; }
  .settings { order: 4; }

  body.bar-open .topbar > .toolbar,
  body.bar-open .topbar > .board-stats { display: flex; }
  body.bar-open .topbar > .status-strip {
    display: flex; order: 5; flex: 1 1 100%; flex-wrap: wrap;
  }

  /* Panels are windows on a desktop and full-width sheets here — dragging a
     372px panel around a 768px screen is not worth the floor space. */
  .rail { padding: 6px 4px; }
  .rail-name { display: none; }
  .minimap { display: none; }
}
