:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-gutter: #12121f;
  --border-color: #0f3460;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --accent: #e94560;
  --verified: #2d6a4f;
  --verified-bright: #4a9e7a;
  --active: #40c463;
  --warn: #f0b84c;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.skip-nav {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 1000;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-nav:focus {
  position: fixed;
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  padding: 8px 16px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--accent);
  overflow: visible;
}

#navbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 34px;
  padding: 6px 12px;
  /* overflow visible (was overflow-x:auto) so the merged status group's gate popover can drop
     DOWN out of the bar without being clipped (owner 2026-06-30: one menu bar). */
  overflow: visible;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  white-space: nowrap;
}

#navbar .logo {
  flex-shrink: 0;
  margin-right: 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

#navbar .sep {
  flex-shrink: 0;
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

.nav-btn,
.gate-action,
.overlay-mode-btn {
  flex-shrink: 0;
  min-height: 26px;
  padding: 5px 9px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: #d0d0d0;
  font-size: 11px;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-btn:hover,
.gate-action:hover,
.overlay-mode-btn:hover {
  background: var(--border-color);
  color: #fff;
}

.nav-btn:focus-visible,
.gate-action:focus-visible,
.overlay-mode-btn:focus-visible,
#anchor-overlay-toggle:focus-visible,
#gutter:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.overlay-mode-control {
  display: inline-flex;
  flex-shrink: 0;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.overlay-mode-btn {
  min-height: 24px;
  border: 0;
  border-radius: 0;
}

.overlay-mode-btn + .overlay-mode-btn {
  border-left: 1px solid var(--border-color);
}

.overlay-mode-btn[aria-pressed="true"] {
  background: var(--verified);
  color: #fff;
}

#anchor-overlay-toggle {
  flex-shrink: 0;
  min-height: 23px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: #d0d0d0;
  font-size: 11px;
  line-height: 1.1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#anchor-overlay-toggle:hover {
  background: var(--border-color);
  color: #fff;
}

#anchor-overlay-toggle[aria-pressed="true"] {
  background: var(--verified);
  color: #fff;
}

.dt-specs-panel {
  position: relative;
  flex-shrink: 0;
}

.dt-specs-panel summary {
  min-height: 24px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: #d0d0d0;
  font-size: 11px;
  line-height: 1.1;
  cursor: pointer;
  list-style: none;
}

.dt-specs-panel summary::-webkit-details-marker {
  display: none;
}

.dt-specs-panel[open] summary {
  border-color: var(--verified-bright);
  color: #fff;
}

.spec-config-menu {
  position: fixed;
  top: 40px;
  left: 154px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: min(460px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: rgba(17, 24, 47, 0.98);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  color: var(--text-primary);
  font-size: 11px;
  overflow: auto;
}

.spec-depth-row {
  display: grid;
  grid-template-columns: auto 120px 2ch;
  align-items: center;
  gap: 8px;
}

.spec-section-title {
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.spec-editor {
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
}

.spec-editor {
  min-height: 330px;
  padding: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.35;
  resize: vertical;
  white-space: pre;
}

.spec-source-summary {
  color: #aeb8cf;
  font-size: 10px;
  line-height: 1.35;
}

.mathobject-node-summary {
  color: #fde68a;
  font-size: 10px;
  line-height: 1.35;
}

.mathobject-node-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 118px;
  overflow: auto;
}

.mathobject-node-button {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  max-width: 100%;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid rgba(34, 197, 94, 0.56);
  border-radius: 4px;
  background: rgba(24, 18, 7, 0.92);
  color: #f0fff4;
  font-size: 10px;
  line-height: 1.2;
  cursor: pointer;
}

.mathobject-node-button:hover,
.mathobject-node-button.active {
  border-color: #fef3c7;
  background: rgba(92, 53, 5, 0.96);
}

#open-dt-spec {
  color: var(--accent);
}

#documentgraph-depth-control {
  width: 120px;
  accent-color: var(--verified-bright);
}

#documentgraph-depth-value {
  color: #ffffff;
  font-weight: 700;
  text-align: right;
}

.nav-btn.nav-graph {
  background: var(--border-color);
  color: #fff;
}

#split {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#unified-d3-tree {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

body[data-overlay-mode="leaf"] #unified-d3-tree {
  display: none;
}

.unified-d3-tree-link {
  fill: none;
  stroke: rgba(64, 196, 99, 0.56);
  stroke-width: 1.2;
  pointer-events: all;
}

.unified-d3-tree-link[data-depth="2"],
.unified-d3-tree-link[data-depth="3"] {
  stroke-dasharray: 3 6;
  opacity: 0.48;
}

/*
 * Edges to Concept nodes — documentgraph-extracted mentions that aren't
 * formally bound to a MathObject/ThoughtStep in neo4j-shared. Rendered as
 * a thinner amber-warn dashed stroke so they read distinctly from the
 * resolved (green) backbone of the neighborhood. Uses a tighter 2/4 dash
 * pattern (vs. the 3/6 depth-fade above) so depth and resolution remain
 * independently legible when combined via CSS specificity.
 */
.unified-d3-tree-link[data-resolution-status="unresolved"] {
  stroke: rgba(240, 184, 76, 0.62);
  stroke-dasharray: 2 4;
  stroke-width: 1;
  opacity: 0.55;
}

.unified-d3-tree-node {
  pointer-events: all;
  cursor: pointer;
}

.unified-d3-tree-node circle {
  fill: #ecfdf5;
  stroke: #40c463;
  stroke-width: 1.7;
}

.unified-d3-tree-node[data-side="rhs"] circle,
.unified-d3-tree-node[data-labels~="WorkContractTest"] circle {
  fill: #dffbea;
}

.unified-d3-tree-node[data-active="true"] circle {
  fill: #40c463;
  stroke: #f8fafc;
  stroke-width: 2;
}

.unified-d3-tree-node text {
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.88);
  stroke-width: 3px;
  fill: #0f172a;
  font-size: 10px;
  font-weight: 700;
}

/*
 * Anchored nodes show an abbreviated tag (see abbreviatedTreeNodeLabel
 * in split-view.js). Mute the tag so unanchored nodes — which still get
 * the full name — remain the dominant visual signal. The same paint-order
 * + white halo stroke is kept for legibility against PDF text behind.
 */
.unified-d3-tree-node[data-anchored="true"] text {
  fill: rgba(15, 23, 42, 0.62);
  font-size: 9px;
  font-weight: 500;
}

.pane-wrapper {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  background: #0f1326;
}

#split iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f7f8fb;
}

.iframe-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  pointer-events: none;
}

.iframe-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#gutter {
  position: relative;
  z-index: 8;
  flex-shrink: 0;
  width: 60px;
  overflow: visible;
  border-left: 1px solid #1a1a3a;
  border-right: 1px solid #1a1a3a;
  background: linear-gradient(to right, var(--bg-gutter) 0%, #161625 30%, #161625 70%, var(--bg-gutter) 100%);
  cursor: col-resize;
  -webkit-user-select: none;
  user-select: none;
}

#gutter-svg {
  position: absolute;
  inset: 0;
  z-index: 9;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#gutter-svg .connector {
  fill: none;
  stroke-linecap: round;
  pointer-events: all;
  cursor: pointer;
  transition: opacity 0.2s ease, stroke-width 0.15s ease, filter 0.2s ease;
}

#gutter-svg .connector:hover {
  opacity: 1;
  stroke-width: 3;
  filter: drop-shadow(0 0 3px currentColor);
}

#gutter-svg .connector.active {
  opacity: 1;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 6px rgba(64, 196, 99, 0.4));
}

#gutter-svg .documentgraph-cross-pane-edge {
  fill: none;
  stroke-linecap: round;
  stroke-width: 1.25;
  opacity: 0.42;
  pointer-events: all;
  cursor: pointer;
  transition: opacity 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease;
}

#gutter-svg .documentgraph-cross-pane-edge[data-graph-depth="2"] {
  opacity: 0.25;
}

#gutter-svg .documentgraph-cross-pane-edge:hover {
  opacity: 0.9;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 3px currentColor);
}

#gutter-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 260px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 10px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}

#gutter-tooltip.visible {
  opacity: 1;
}

#gatebar {
  position: relative;
  flex-shrink: 0;
}

.gatebar-popover summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #7a2d2d;
  border-radius: 4px;
  background: #361a22;
  color: #ffd7d7;
  font-size: 11px;
  cursor: pointer;
  list-style: none;
}

.gatebar-popover summary::-webkit-details-marker {
  display: none;
}

.gatebar-popover summary::after {
  content: "^";
  color: #ffd7d7;
  font-size: 9px;
}

.gatebar-popover[open] summary::after {
  content: "v";
}

.gate-state {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  padding: 1px 5px;
  border: 1px solid rgba(255, 215, 215, 0.38);
  border-radius: 3px;
  background: rgba(15, 19, 38, 0.82);
  color: #ffd7d7;
  font-size: 10px;
}

.gate-list {
  position: absolute;
  right: 0;
  /* opens DOWNWARD from the top bar (was bottom-anchored when the statusbar sat at the page bottom) */
  top: calc(100% + 8px);
  z-index: 50;
  display: grid;
  width: min(760px, calc(100vw - 24px));
  grid-template-columns: 1fr;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(233, 69, 96, 0.38);
  border-radius: 4px;
  background: rgba(17, 24, 47, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.gate-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid rgba(233, 69, 96, 0.32);
  border-radius: 4px;
  background: rgba(26, 26, 46, 0.82);
}

.gate-name {
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.gate-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-action {
  border-color: rgba(233, 69, 96, 0.45);
  background: rgba(15, 52, 96, 0.7);
  color: #f5d4da;
  font-family: inherit;
}

#statusbar {
  /* Merged into #navbar (owner 2026-06-30: "one menu bar at most"): a right-aligned status group
     INSIDE the single top bar, no longer a standalone band below the panes. position:relative is
     kept so the gate popover anchors to this element; margin-left:auto pushes it to the bar's right. */
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 11px;
}

#status-left {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  white-space: nowrap;
}

#statusbar a {
  color: var(--accent);
  text-decoration: none;
}

#statusbar a:hover {
  text-decoration: underline;
}

@keyframes statusbar-flash {
  0% {
    background-color: var(--verified);
  }
  100% {
    background-color: var(--bg-secondary);
  }
}

.statusbar-flash {
  animation: statusbar-flash 400ms ease-out forwards;
}

body.resizing {
  cursor: col-resize;
}

body.resizing iframe {
  pointer-events: none;
}

@media (max-width: 1080px) {
  .gate-list {
    width: min(620px, calc(100vw - 18px));
  }
}

@media (max-width: 768px) {
  #navbar {
    flex-wrap: wrap;
    white-space: normal;
  }

  #split {
    flex-direction: column;
  }

  #gutter {
    display: none;
  }

  #statusbar {
    /* in the wrapped (narrow) navbar the status group drops to its own line, no longer force-pushed right */
    margin-left: 0;
    flex-wrap: wrap;
    gap: 8px;
  }

  .status-actions {
    flex-wrap: wrap;
    white-space: normal;
  }
}

/* Owner 2026-06-30: the far-right #node-detail COLUMN was removed (no more 380px reserved gutter,
   no .node-detail / .nd-* styles). Node detail is now the in-graph HOVER in the RHS Neo4j-graph
   (nb-wrapper.css: .dt-graph-hover). */

/* ── TABBED TOOL DOCK — POSITION IS A CONFIG CHOICE (owner likes both, 2026-07-06) ─
   The dock with tabs [🤖 chat][$ shell][📁 files] — one NATIVE tool surface (iframe /
   xterm) visible at a time — can live as a LEFT COLUMN or a full-width BOTTOM BAND.
   left-dock.js stamps data-dock-position="left|bottom" on #main-row (from
   WISE_VIEWER_CONFIG.dockPosition, or a ?dock= override). These base rules are
   direction-agnostic; the two attribute-keyed layout rule-sets further down re-flow the
   SAME dock (same tabs/panels/collapse/resize logic) between the two positions. In EITHER
   position the dock is a collapsible TOOL panel, NOT a second persistent menu bar. */
#main-row {
  display: flex;
  flex: 1;
  min-height: 0;
}
.left-dock {
  flex-shrink: 0;
  display: flex;
  min-height: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
}
.left-dock-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 8px 4px;
}
.left-dock-tab,
.left-dock-collapse {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.left-dock-tab:hover,
.left-dock-collapse:hover { border-color: var(--accent); }
.left-dock-tab[aria-selected="true"] { background: var(--border-color); }
.left-dock-panels {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}
.left-dock-panel {
  display: none;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}
#left-dock[data-active-tab="chat"] .left-dock-panel[data-dock-panel="chat"],
#left-dock[data-active-tab="shell"] .left-dock-panel[data-dock-panel="shell"],
#left-dock[data-active-tab="files"] .left-dock-panel[data-dock-panel="files"] { display: flex; }
.left-dock-panel > iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}
.dock-placeholder {
  padding: 12px;
  color: var(--text-secondary);
  overflow: auto;
}
.dock-placeholder pre {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  overflow-x: auto;
  user-select: all;
}
.shell-term { flex: 1; min-height: 0; padding: 4px 6px; background: #0f1326; }
.shell-term .xterm { height: 100%; }
/* collapsed = a thin tab rail (tabs stay clickable); panels hidden entirely, in BOTH positions */
#left-dock[data-collapsed="true"] .left-dock-panels { display: none; }
#left-dock[data-collapsed="true"] + #left-dock-divider { display: none; }
.left-dock-divider {
  flex-shrink: 0;
  background: transparent;
  touch-action: none;
}
.left-dock-divider:hover,
.left-dock-divider.dragging { background: rgba(34, 197, 94, 0.35); }
/* the chat tab's agent-console strip keeps its bottom-of-panel divider look */
#dock-panel-chat .agent-console-dock { border-top: 1px solid var(--border-color); }

/* ── LAYOUT A — LEFT COLUMN (committed default) ───────────────────────────────
   Dock to the LEFT of the PDF | gutter | RHS panes; tabs stacked vertically; a
   right-edge divider resizes WIDTH (left-dock.js clientX branch); collapses to a
   thin 38px rail. #split keeps flex:1, taking the remaining width to the right. */
#main-row[data-dock-position="left"] { flex-direction: row; }
#main-row[data-dock-position="left"] .left-dock {
  flex-direction: row;
  width: 380px;
  min-width: 220px;
  max-width: 70vw;
}
#main-row[data-dock-position="left"] .left-dock-tabs {
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}
#main-row[data-dock-position="left"] #left-dock[data-collapsed="true"] {
  width: 38px;
  min-width: 38px;
}
#main-row[data-dock-position="left"] .left-dock-divider {
  width: 6px;
  cursor: ew-resize;
  border-right: 1px solid var(--border-color);
}

/* ── LAYOUT B — BOTTOM BAND ────────────────────────────────────────────────────
   The three panes (#split) span FULL WIDTH on top; the dock is a full-width band
   below, tabs a HORIZONTAL row, a top-edge divider resizes HEIGHT (left-dock.js
   clientY branch); collapses to just the tab row. flex `order` re-stacks the DOM
   children (dock, divider, split) into split → divider → dock — no markup moves,
   so the source-order one-menu-bar contract is untouched. */
#main-row[data-dock-position="bottom"] { flex-direction: column; }
#main-row[data-dock-position="bottom"] #split { order: 0; }
#main-row[data-dock-position="bottom"] #left-dock-divider { order: 1; }
#main-row[data-dock-position="bottom"] .left-dock { order: 2; }
#main-row[data-dock-position="bottom"] .left-dock {
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 320px;
  min-height: 120px;
  max-height: 70vh;
}
#main-row[data-dock-position="bottom"] .left-dock-tabs {
  flex-direction: row;
  border-bottom: 1px solid var(--border-color);
}
#main-row[data-dock-position="bottom"] #left-dock[data-collapsed="true"] {
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
}
#main-row[data-dock-position="bottom"] .left-dock-divider {
  width: 100%;
  height: 6px;
  cursor: ns-resize;
  border-top: 1px solid var(--border-color);
}

/* ── Docked coding-agent console (Round 1) ────────────────────────────────────
   Now the composer/console strip at the BOTTOM OF THE CHAT TAB in #left-dock
   (owner 2026-07-06 — the separate bottom band is retired). Still flex-shrink: 0
   so it never competes with the opencode iframe's flex:1 above it; resize:vertical
   + the top divider let the user drag it taller; collapsing leaves the header bar. */
.agent-console-dock {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 220px;
  min-height: 34px;
  max-height: 85vh;
  resize: vertical;
  overflow: hidden;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
}
/* grabbable TOP edge: drag up to give the opencode console more space */
.agent-console-divider {
  flex-shrink: 0;
  height: 6px;
  cursor: ns-resize;
  background: transparent;
  border-top: 1px solid var(--border-color);
  touch-action: none;
}
.agent-console-divider:hover,
.agent-console-divider.dragging {
  background: rgba(34, 197, 94, 0.35);
}
.agent-console-dock[data-collapsed="true"] { height: 34px; min-height: 34px; max-height: 34px; resize: none; }
.agent-console-dock[data-collapsed="true"] .agent-console-divider { display: none; }
.agent-console-dock[data-collapsed="true"] .agent-console-body { display: none; }

.agent-console-bar {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  min-height: 34px; padding: 6px 14px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border-color); background: var(--bg-gutter);
}
.agent-console-toggle {
  appearance: none; border: none; background: transparent; cursor: pointer;
  color: var(--text-primary); font: inherit; font-weight: 600;
}
.agent-console-status { color: var(--text-secondary); font-size: 11px; }
.agent-console-spacer { flex: 1; }
.agent-console-btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 11px;
  border: 1px solid var(--border-color); border-radius: 4px;
  background: var(--bg-primary); color: var(--text-primary); padding: 5px 10px;
}
.agent-console-btn:hover { border-color: var(--accent); }

.agent-console-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.agent-console-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  white-space: pre-wrap; color: var(--text-secondary);
}
.agent-log-line { margin-bottom: 3px; }
.agent-log-user { color: var(--text-primary); }
.agent-log-system { color: var(--warn); }
/* walkthrough tool-call line: the raw `viewer-mcp_…[…]` syntax is replaced by clean action
   chips (agent-console.js renderToolActionLine) while the RHS graph focuses the referenced node. */
.agent-log-tool { color: var(--text-secondary); }
.agent-tool-action {
  display: inline-block; margin: 1px 2px; padding: 0 6px; border-radius: 9px;
  background: var(--border-color); color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.7;
}

.agent-console-context { flex-shrink: 0; border-top: 1px solid var(--border-color); padding: 4px 12px; max-height: 30%; overflow-y: auto; }
.agent-console-context > summary { cursor: pointer; color: var(--text-secondary); font-size: 11px; }
.agent-console-count {
  display: inline-block; min-width: 16px; text-align: center; border-radius: 8px;
  background: var(--border-color); color: var(--text-primary); font-size: 10px; padding: 0 5px;
}
.agent-console-context-list { list-style: none; margin: 4px 0 0; padding: 0; }
.agent-context-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 1px 0; }
.agent-context-label { font-family: ui-monospace, monospace; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-context-x, .agent-token-chip-x {
  appearance: none; border: none; background: transparent; cursor: pointer;
  color: #93c5fd; line-height: 1; padding: 0 2px; font: inherit;
}

.agent-composer {
  display: flex; align-items: flex-start; gap: 6px; flex-shrink: 0;
  padding: 8px 12px; border-top: 1px solid var(--border-color);
}
.agent-composer-input {
  flex: 1; min-width: 0; min-height: 38px; max-height: 120px; overflow-y: auto;
  border: 1px solid var(--border-color); border-radius: 4px; padding: 6px 8px;
  background: var(--bg-primary); color: var(--text-primary);
  font: inherit; line-height: 1.6; outline: none;
}
.agent-composer-input:empty::before { content: attr(data-placeholder); color: var(--text-secondary); }
.agent-composer-input:focus { border-color: var(--accent); }
.agent-composer-send {
  flex-shrink: 0; align-self: stretch; cursor: pointer; font: inherit;
  border: 1px solid var(--border-color); border-radius: 4px;
  background: var(--bg-gutter); color: var(--text-primary); padding: 6px 16px;
}
.agent-composer-send:hover { border-color: var(--active); color: var(--active); }

.agent-token-chip {
  display: inline-flex; align-items: center; gap: 3px; margin: 0 2px;
  padding: 0 4px 0 6px; border-radius: 3px; vertical-align: baseline;
  font-family: ui-monospace, monospace; font-size: 11px;
  background: rgba(56, 189, 248, 0.14); color: #dbeafe;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.agent-token-chip--edge { background: rgba(64, 196, 99, 0.14); border-color: rgba(64, 196, 99, 0.4); }
.agent-token-chip--node-prop { background: rgba(240, 184, 76, 0.16); border-color: rgba(240, 184, 76, 0.4); }
.agent-token-chip--flash { outline: 2px solid var(--accent); }

/* Round 2: when the live opencode terminal mounts, the log area hosts xterm.js. */
.agent-console-log.agent-console-xterm { padding: 4px 6px; overflow: hidden; background: #0f1326; }
.agent-console-log.agent-console-xterm .xterm { height: 100%; }
