/* DocIntel v3 — two-rail information architecture (DESIGN §11).
   Keeps the v2 visual language (fonts, radii, spacing, the gold accent) but in
   LIGHT mode, as requested. Self-contained tokens — does not link main.css. */

:root {
  /* surfaces (light) */
  --bg-primary: #f6f7f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef1f5;
  --bg-elevated: #ffffff;

  --surface-glass: rgba(17, 24, 39, 0.02);
  --surface-glass-hover: rgba(17, 24, 39, 0.045);
  --surface-glass-active: rgba(17, 24, 39, 0.07);

  --border-subtle: rgba(17, 24, 39, 0.06);
  --border-default: rgba(17, 24, 39, 0.11);
  --border-strong: rgba(17, 24, 39, 0.18);

  --text-primary: #1b2330;
  --text-secondary: #45506a;
  --text-tertiary: #6b7689;
  --text-muted: #97a0b0;

  /* gold brand accent, tuned for light backgrounds */
  --accent-primary: #b27a26;
  --accent-primary-hover: #cf9035;
  --accent-primary-glow: rgba(178, 122, 38, 0.16);
  --accent-primary-subtle: rgba(178, 122, 38, 0.10);

  --accent-success: #1f9d6b;  --accent-success-glow: rgba(31, 157, 107, 0.12);
  --accent-warning: #c98a1a;  --accent-warning-glow: rgba(201, 138, 26, 0.12);
  --accent-error:   #d24a4a;  --accent-error-glow:   rgba(210, 74, 74, 0.10);
  --accent-info:    #2f74c9;  --accent-info-glow:    rgba(47, 116, 201, 0.10);

  /* PDF bbox overlay fills — translucent, colored by content type (light). */
  --box-title:     rgba(178, 122, 38, 0.22);
  --box-paragraph: rgba(47, 116, 201, 0.16);
  --box-table:     rgba(31, 157, 107, 0.20);
  --box-list:      rgba(201, 138, 26, 0.20);
  --box-default:   rgba(17, 24, 39, 0.10);

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px; --radius-full: 9999px;
  --spacing-xs: 4px; --spacing-sm: 8px; --spacing-md: 16px; --spacing-lg: 24px; --spacing-xl: 32px;
  --shadow-sm: 0 1px 2px rgba(17,24,39,.06), 0 1px 1px rgba(17,24,39,.04);
  --shadow-md: 0 4px 14px rgba(17,24,39,.10);
  --shadow-lg: 0 16px 48px rgba(17,24,39,.16);
  --transition-fast: 120ms ease;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }

/* ── shell ── */
.v3-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.v3-topbar {
  height: 48px; flex: 0 0 48px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
  z-index: 30;
}
.v3-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; }
.v3-brand svg { width: 20px; height: 20px; color: var(--accent-primary); }
.v3-topbar-actions { display: flex; gap: 4px; }
.v3-iconbtn {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; color: var(--text-secondary);
  padding: 6px 10px; border-radius: var(--radius-md); font-size: 13px;
}
.v3-iconbtn:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.v3-iconbtn.active { background: var(--accent-primary-subtle); color: var(--accent-primary); border-color: var(--border-default); }
.v3-iconbtn svg { width: 16px; height: 16px; }

.v3-body { flex: 1 1 auto; display: flex; min-height: 0; }

/* ── Rail 1: spaces drilldown ── */
.v3-rail1 {
  width: 230px; flex: 0 0 230px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column; transition: width var(--transition-fast, 120ms ease);
  overflow: hidden;
}
.v3-rail1.collapsed { width: 38px; flex-basis: 38px; }
.v3-rail-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; color: var(--text-tertiary); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.v3-rail1.collapsed .v3-rail-head span, .v3-rail1.collapsed .space-name { display: none; }
.v3-spaces { overflow-y: auto; flex: 1; padding: 4px; }
.space-node { display: flex; align-items: center; gap: 7px; padding: 7px 8px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.space-node:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.space-node.active { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.space-node .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; flex: 0 0 auto; }
.v3-rail1.collapsed .space-node { justify-content: center; }

/* Collapsed rail: vertical breadcrumb of the active space's ancestry, read
   top (root) to bottom (current), rotated 90 degrees to fit the narrow rail. */
.v3-crumbs {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: flex;
  flex-direction: row;      /* in vertical writing-mode this runs top→bottom */
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  font-size: 12.5px;
  letter-spacing: .01em;
  white-space: nowrap;
}
.v3-crumbs .crumb { color: var(--text-secondary); cursor: pointer; }
.v3-crumbs .crumb:hover { color: var(--text-primary); text-decoration: underline; }
.v3-crumbs .crumb.active { color: var(--accent-primary); font-weight: 700; }
.v3-crumbs .crumb-sep { color: var(--text-muted); opacity: .55; }
.v3-addbtn { margin: 6px; padding: 7px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-tertiary); border-radius: var(--radius-sm); font-size: 13px; }
.v3-addbtn:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

/* ── Rail 2: space navigator ── */
.v3-rail2 {
  width: 270px; flex: 0 0 270px;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column; overflow: hidden;
}
.v3-rail2-title { padding: 12px 14px 8px; font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.nav-scroll { overflow-y: auto; flex: 1; padding: 0 6px 12px; }
.nav-channel { display: flex; align-items: center; gap: 8px; margin: 4px 6px 10px; padding: 9px 10px; border-radius: var(--radius-md); background: var(--surface-glass); color: var(--text-primary); font-weight: 600; }
.nav-channel:hover { background: var(--surface-glass-hover); }
.nav-channel.active { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.nav-section { margin: 8px 4px; }
.nav-section-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; color: var(--text-tertiary); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; user-select: none; }
.nav-section-head:hover { color: var(--text-secondary); }
.nav-section-head .count { margin-left: auto; background: var(--surface-glass-active); border-radius: var(--radius-full); padding: 1px 7px; font-size: 10px; }
.nav-section-head .nav-add { margin-left: 6px; background: none; border: none; color: var(--text-tertiary); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: var(--radius-sm); }
.nav-section-head .nav-add:hover { color: var(--accent-primary); background: var(--surface-glass-active); }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 13px; }
.nav-item:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.nav-item.active { background: var(--surface-glass-active); color: var(--text-primary); }
.nav-item .badge { margin-left: auto; font-size: 10px; color: var(--text-muted); }
.nav-item .badge.busy { color: var(--accent-warning); }
.nav-item .badge.parked { color: var(--accent-info); }
.nav-item .badge.error { color: var(--accent-error); }
.nav-item .badge.mcp { color: var(--accent-primary); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.nav-newbtn { width: calc(100% - 12px); margin: 4px 6px; padding: 6px; background: transparent; border: 1px dashed var(--border-strong); color: var(--text-tertiary); border-radius: var(--radius-sm); font-size: 12px; }
.nav-newbtn:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

/* ── Main surface ── */
.v3-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--bg-primary); position: relative; }
.surface-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border-subtle); }
.surface-head h2 { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.surface-head .sub { color: var(--text-tertiary); font-size: 12px; }
.surface-body { flex: 1; overflow-y: auto; padding: 18px; }
.v3-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); gap: 10px; text-align: center; }

/* ── workspace: VSCode-style tabs + split panes ── */
.ws-root { flex: 1 1 auto; display: flex; min-height: 0; min-width: 0; height: 100%; position: relative; }
.ws-empty { flex: 1; }
.ws-group { display: flex; flex-direction: column; min-width: 160px; min-height: 0; position: relative; overflow: hidden; border-right: 0; }
.ws-group.focused .ws-tabs { background: var(--bg-secondary); }
.ws-tabs { display: flex; align-items: stretch; gap: 0; min-height: 36px; background: var(--bg-tertiary, var(--bg-secondary)); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; overflow-y: hidden; }
.ws-tab { display: flex; align-items: center; gap: 6px; padding: 0 10px; max-width: 220px; font-size: 13px; color: var(--text-tertiary); cursor: pointer; border-right: 1px solid var(--border-subtle); user-select: none; white-space: nowrap; }
.ws-tab .ico { font-size: 12px; opacity: .8; }
.ws-tab .t { overflow: hidden; text-overflow: ellipsis; }
.ws-tab.active { background: var(--bg-primary); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent-info); }
.ws-tab:hover { color: var(--text-secondary); }
.ws-tab .x { border: none; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; border-radius: 4px; opacity: .5; }
.ws-tab .x:hover { opacity: 1; background: var(--surface-glass); }
.ws-panes { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }
.ws-pane { flex: 1 1 auto; min-height: 0; min-width: 0; width: 100%; overflow: auto; }
.ws-pane > * { height: 100%; }
.ws-resizer { flex: 0 0 6px; cursor: col-resize; background: var(--border-subtle); opacity: .35; transition: opacity .15s; }
.ws-resizer:hover { opacity: 1; background: var(--accent-info); }
body.ws-resizing { cursor: col-resize; user-select: none; }
.ws-error { padding: 16px; color: var(--accent-danger, #c0392b); }
/* drop indicators while dragging a tab over a group */
.ws-dropzones { position: absolute; inset: 0; pointer-events: none; display: none; z-index: 5; }
.ws-dropzones.show { display: block; }
.ws-dropzones::after { content: ''; position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent-info) 22%, transparent); border: 2px solid var(--accent-info); box-sizing: border-box; }
.ws-dropzones[data-zone="left"]::after { left: 0; width: 50%; }
.ws-dropzones[data-zone="right"]::after { right: 0; left: auto; width: 50%; }
.ws-dropzones[data-zone="center"]::after { left: 0; right: 0; }
.ws-root.ws-dragging .ws-pane { pointer-events: none; }
.ws-root.ws-drop { outline: 2px dashed var(--accent-info); outline-offset: -8px; }

/* ── chat (channel + session share styles) ── */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 760px; padding: 9px 13px; border-radius: var(--radius-md); line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--accent-primary-subtle); border: 1px solid var(--border-default); }
.msg.them { align-self: flex-start; background: var(--surface-glass); border: 1px solid var(--border-subtle); }
.msg .who { font-size: 11px; color: var(--text-tertiary); margin-bottom: 3px; }
.step { align-self: flex-start; max-width: 820px; font-size: 13px; border-left: 2px solid var(--border-strong); padding: 4px 12px; color: var(--text-secondary); }
.step.thinking { color: var(--text-tertiary); font-style: italic; border-color: var(--text-muted); }
.step.tool_call { border-color: var(--accent-info); }
.step.tool_result { border-color: var(--accent-success); color: var(--text-tertiary); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }
.step.final { align-self: flex-start; max-width: 820px; border-left: none; background: var(--surface-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 10px 14px; color: var(--text-primary); }
.step .label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 2px; }
.consent { align-self: stretch; background: var(--accent-warning-glow); border: 1px solid var(--accent-warning); border-radius: var(--radius-md); padding: 12px 14px; }
.consent .actions { margin-top: 10px; display: flex; gap: 8px; }
.consent button { padding: 6px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-glass); color: var(--text-primary); }
.consent button.approve { background: var(--accent-success-glow); border-color: var(--accent-success); }
.consent button.reject { background: var(--accent-error-glow); border-color: var(--accent-error); }

.chat-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-subtle); background: var(--bg-secondary); }
.chat-input textarea { flex: 1; resize: none; min-height: 40px; max-height: 220px; overflow-y: auto; background: var(--bg-tertiary); border: 1px solid var(--border-default); border-radius: var(--radius-md); color: var(--text-primary); padding: 10px 12px; font-family: inherit; font-size: 14px; line-height: 1.45; }
.chat-input button { padding: 0 18px; border-radius: var(--radius-md); border: none; background: var(--accent-primary); color: #fff; font-weight: 600; }
.chat-input button:disabled { opacity: .5; cursor: not-allowed; }
/* Dictate: neutral until recording, then pulsing red */
.chat-input button.mic { flex: 0 0 auto; padding: 0 12px; background: var(--bg-tertiary); border: 1px solid var(--border-default); color: var(--text-secondary); display: inline-flex; align-items: center; }
.chat-input button.mic:hover { color: var(--text-primary); border-color: var(--border-strong); }
.chat-input button.mic.rec { background: #c0392b; border-color: #c0392b; color: #fff; animation: mic-pulse 1.4s ease-in-out infinite; }
.chat-input button.mic.busy { opacity: .55; pointer-events: none; animation: mic-pulse 1.4s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .45); } 50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); } }

/* Read-aloud button on AI messages */
.step.final .who .say { background: none; border: none; padding: 1px 4px; margin-left: 6px; color: var(--text-muted); cursor: pointer; vertical-align: middle; border-radius: var(--radius-sm); display: inline-flex; align-items: center; }
.step.final .who .say:hover { color: var(--text-primary); background: var(--surface-glass-active); }
.step.final .who .say.playing { color: var(--accent-primary); }
.step.final .who .say.loading { opacity: .5; animation: mic-pulse 1.4s ease-in-out infinite; }
.status-pill { font-size: 11px; padding: 2px 9px; border-radius: var(--radius-full); border: 1px solid var(--border-default); color: var(--text-tertiary); }
.status-pill.busy { color: var(--accent-warning); border-color: var(--accent-warning); }
.status-pill.parked { color: var(--accent-info); border-color: var(--accent-info); }
.status-pill.error { color: var(--accent-error); border-color: var(--accent-error); }
.status-pill.mcp { color: var(--accent-primary); border-color: var(--accent-primary); background: var(--accent-primary-subtle); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ── artifact renderer ── */
.renderer-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--border-subtle); flex-wrap: wrap; }
.renderer-pick { padding: 5px 12px; border-radius: var(--radius-full); border: 1px solid var(--border-default); background: var(--surface-glass); color: var(--text-secondary); font-size: 12px; }
.renderer-pick.active { background: var(--accent-primary-subtle); color: var(--accent-primary); border-color: var(--accent-primary); }
.renderer-host { flex: 1; overflow: auto; }
.renderer-host iframe { width: 100%; height: 100%; border: none; background: #fff; }
.renderer-md { padding: 20px 26px; max-width: 1000px; line-height: 1.6; }
.renderer-md pre { background: var(--bg-tertiary); padding: 12px; border-radius: var(--radius-sm); overflow:auto; }
.renderer-md pre.json-view { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; white-space: pre; color: var(--text-secondary); max-height: 100%; }
.renderer-md h3 { font-family: var(--font-display); font-size: 14px; margin: 18px 0 8px; color: var(--text-secondary); }
.renderer-md code { font-family: var(--font-mono); font-size: 12px; color: var(--accent-primary); }
.renderer-md ul { padding-left: 18px; }
.v3-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.v3-tbl th { text-align: left; color: var(--text-tertiary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 10px; border-bottom: 1px solid var(--border-default); }
.v3-tbl td { padding: 6px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }

/* document dual view: PDF source (reused pdf-viewer-container) ‖ markdown */
.dual .src { padding: 0; }
.dual pdf-viewer-container { display: block; width: 100%; height: 100%; }

/* ── quick-peek slide-over ── */
.v3-peek { position: absolute; top: 0; right: 0; height: 100%; width: 460px; max-width: 92vw; background: var(--bg-secondary); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 180ms ease; z-index: 40; display: flex; flex-direction: column; }
.v3-peek.open { transform: translateX(0); }
.v3-peek-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.v3-peek-body { flex: 1; overflow: auto; }
.v3-peek .close { background: transparent; border: none; color: var(--text-tertiary); font-size: 20px; }

/* ── doc dual view ── */
.dual { display: flex; height: 100%; }
.dual > div { flex: 1; overflow: auto; padding: 16px; }
.dual .src { border-right: 1px solid var(--border-subtle); background: var(--bg-secondary); }
.unparsed-note { margin: 14px; padding: 14px; border: 1px dashed var(--accent-warning); border-radius: var(--radius-md); color: var(--accent-warning); }

/* ── pipeline definition view ── */
.pipe-view { padding: 20px 24px; overflow: auto; height: 100%; max-width: 920px; }
.pipe-head { display: flex; align-items: center; gap: 10px; }
.pipe-head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; }
.pipe-view h3 { font-family: var(--font-display); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin: 22px 0 10px; }
.pipe-iface { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.pipe-iface > div { background: var(--surface-glass); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 10px 12px; }
.pipe-ports { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pipe-port { font-family: var(--font-mono); font-size: 12px; background: var(--bg-tertiary, var(--bg-secondary)); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 2px 8px; }
.pipe-steps { display: flex; flex-direction: column; gap: 8px; }
.pipe-step { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-secondary); overflow: hidden; }
.pipe-step-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.pipe-num { width: 20px; height: 20px; flex: 0 0 auto; border-radius: var(--radius-full); background: var(--surface-glass); color: var(--text-tertiary); font-size: 11px; display: flex; align-items: center; justify-content: center; }
.pipe-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.pipe-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: var(--radius-full); font-weight: 600; }
.pipe-kind.ai { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.pipe-kind.validate { background: color-mix(in srgb, var(--accent-success) 18%, transparent); color: var(--accent-success); }
.pipe-kind.tool { background: color-mix(in srgb, var(--accent-info) 18%, transparent); color: var(--accent-info); }
.pipe-kind.script { background: color-mix(in srgb, var(--accent-primary) 18%, transparent); color: var(--accent-primary); }
.pipe-code { font-family: var(--font-mono); font-size: 11.5px; white-space: pre-wrap; background: var(--bg-tertiary); border-radius: var(--radius-sm); padding: 8px 10px; margin: 4px 0 0; overflow-x: auto; color: var(--text-secondary); }
.pipe-kind.emit { background: color-mix(in srgb, var(--accent-warning) 18%, transparent); color: var(--accent-warning); }
.pipe-step-body { padding: 0 12px 10px 40px; font-size: 13px; color: var(--text-secondary); }
.pipe-kind-desc { font-size: 11px; }
.pipe-note { font-size: 12px; margin: 0 0 10px; }
.pipe-stepinputs, .pipe-grounding { padding: 0 12px 8px 40px; font-size: 12px; color: var(--text-tertiary); }
.pipe-stepinputs code, .pipe-grounding code { font-family: var(--font-mono); }
.pipe-grounding { display: flex; gap: 6px; align-items: baseline; }
.pipe-ports.col { flex-direction: column; align-items: flex-start; gap: 8px; }
.pipe-port-desc { display: block; font-size: 11px; color: var(--text-tertiary); margin-top: 2px; font-family: var(--font-sans, inherit); }
.pipe-when { padding: 0 12px 10px 40px; font-size: 12px; }
.pipe-when code, .pipe-emit code { font-family: var(--font-mono); font-size: 12px; }
.pipe-emit { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); }
.pipe-raw pre { white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: 12px; padding: 14px; }
.tag-row .ns.grounded { color: var(--accent-warning); }
/* view-mode toggle: PDF only / split / markdown only — flat, matches tab bar */
/* Markdown tables — bordered cells everywhere prose renders: the documents'
   Parsed pane, markdown artifacts, manuals, and AI session messages. */
.renderer-md table, .step.final table, .msg table {
  border-collapse: collapse; margin: 10px 0 16px; font-size: 12.5px; max-width: 100%; display: block; overflow-x: auto; width: fit-content; }
.renderer-md th, .renderer-md td, .step.final th, .step.final td, .msg th, .msg td {
  border: 1px solid var(--border-strong); padding: 4px 10px; text-align: left; vertical-align: top; }
.renderer-md thead th, .step.final thead th, .msg thead th {
  background: var(--surface-glass-active); font-weight: 600; color: var(--text-primary); }
.renderer-md tbody tr:nth-child(even) td, .step.final tbody tr:nth-child(even) td, .msg tbody tr:nth-child(even) td {
  background: var(--bg-secondary); }

/* Flash highlight for agent selection references ([[ref:...|label|quote]]) */
mark.sel-flash { background: var(--accent-primary-glow); color: inherit; border-radius: 2px;
  box-shadow: 0 0 0 2px var(--accent-primary-glow); transition: background .4s ease; }

/* View modes: doc = source only; split = source + rendered; text = rendered
   only; md = raw markdown only. The raw pane is hidden unless mode-md. */
.dual .raw { display: none; }
.dual .raw pre { white-space: pre-wrap; word-break: break-word; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; line-height: 1.6; max-width: 900px; margin: 0 auto; color: var(--text-secondary); }
.dual.mode-doc .rendered, .dual.mode-doc .raw { display: none; }
.dual.mode-doc .src { border-right: none; }
.dual.mode-split .raw { display: none; }
.dual.mode-text .src, .dual.mode-text .raw { display: none; }
.dual.mode-text .rendered { max-width: 960px; margin: 0 auto; }
.dual.mode-md .src, .dual.mode-md .rendered { display: none; }
.dual.mode-md .raw { display: block; }

/* Office source renders (docx via mammoth, xlsx via SheetJS) */
.office-doc, .office-sheet { padding: 24px 28px; max-width: 900px; margin: 0 auto; font-size: 13.5px; line-height: 1.55; }
.office-doc img { max-width: 100%; }
.office-doc table, .office-sheet table { border-collapse: collapse; margin: 10px 0 18px; }
.office-doc td, .office-doc th, .office-sheet td, .office-sheet th {
  border: 1px solid var(--border-default); padding: 3px 9px; font-size: 12.5px; }
.office-sheet h3 { margin: 18px 0 6px; font-size: 13px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: .05em; }
.doc-bar { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-tertiary, var(--bg-secondary)); }
.doc-bar .seg { display: inline-flex; }
.doc-bar .seg button { border: none; background: transparent; color: var(--text-tertiary); font-size: 11px; padding: 4px 10px; cursor: pointer; border-bottom: 2px solid transparent; }
.doc-bar .seg button:hover { color: var(--text-secondary); }
.doc-bar .seg button.active { color: var(--text-primary); border-bottom-color: var(--accent-info); }

/* ── overlay panels (Knowledge / Interfaces / Account) ── */
.v3-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60; display: none; align-items: flex-start; justify-content: center; padding: 60px 20px; }
.v3-overlay.open { display: flex; }
.v3-overlay-card { width: 720px; max-width: 100%; max-height: 80vh; overflow: auto; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 20px 24px; }
.v3-overlay-card h2 { margin-top: 0; font-family: var(--font-display); }
.tag-row, .guide-row { display: flex; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); align-items: baseline; }
.tag-row .name { font-family: var(--font-mono); color: var(--accent-primary); }
.tag-row .ns { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.tag-row .count { margin-left: auto; color: var(--text-tertiary); }

.muted { color: var(--text-muted); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── v3 sidebar/page interactions (added) ── */
.space-node { gap: 6px; }
.space-node .space-tag { margin-left: auto; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 0 6px; }
.space-node .space-tag.pub { color: var(--accent-info); border-color: var(--accent-info); }
.space-node.drop-into { outline: 2px dashed var(--accent-primary); outline-offset: -2px; background: var(--accent-primary-subtle); }
.v3-rename { font: inherit; width: 100%; border: 1px solid var(--accent-primary); border-radius: var(--radius-sm); padding: 2px 6px; background: var(--bg-secondary); color: var(--text-primary); }

/* context menu + account dropdown */
.v3-ctx, .v3-dropdown { position: fixed; z-index: 80; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 4px; min-width: 180px; }
.v3-ctx-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text-primary); padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px; }
.v3-ctx-item:hover { background: var(--surface-glass-hover); }
.v3-ctx-item.danger { color: var(--accent-error); }
.v3-ctx-sep { height: 1px; background: var(--border-subtle); margin: 4px 2px; }
.v3-dropdown .dd-email { padding: 8px 10px; color: var(--text-tertiary); font-size: 12px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 4px; }

/* navigator collapsible + labels */
.nav-section-head { user-select: none; }
.nav-section-head .chev { display: inline-block; transition: transform var(--transition-fast); margin-right: 4px; font-size: 10px; }
.nav-section-head .chev.open { transform: rotate(90deg); }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.parsed { color: var(--accent-success); }
.badge.unparsed { color: var(--text-muted); }

/* file-drop highlight on Rail 2 */
.v3-rail2.file-drop { outline: 2px dashed var(--accent-primary); outline-offset: -4px; background: var(--accent-primary-subtle); }
/* section-scoped file drop (Documents / Artifacts) */
.nav-section.nav-dropzone { border-radius: var(--radius-md); transition: background var(--transition-fast), box-shadow var(--transition-fast); }
.nav-section.file-drop { outline: 2px dashed var(--accent-primary); outline-offset: -2px; background: var(--accent-primary-subtle); }
.nav-section.file-drop .nav-section-head { color: var(--accent-primary); }

/* full pages (Knowledge / Interfaces) */
.v3-page { position: absolute; inset: 48px 0 0 0; background: var(--bg-primary); z-index: 25; overflow: auto; display: none; }
/* Full-width sticky header bar with its content centered to match the body. */
.page-head { display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-primary); z-index: 2; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.page-head > * { }
/* center head content + body at the same column width so nothing looks off-center */
.v3-page > .page-head { padding-left: max(28px, calc((100% - 1080px) / 2)); padding-right: max(28px, calc((100% - 1080px) / 2)); }
.page-body { padding: 24px max(28px, calc((100% - 1080px) / 2)); }
/* the inner container just fills the centered body now */
.page-body > .page-container { width: 100%; }
/* user manuals: a wider centered column; toc on the left, guide on the right.
   The head must align to the SAME wider column, else it looks off-center. */
.page-body.manuals-layout { padding: 24px max(28px, calc((100% - 1400px) / 2)); display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 36px; align-items: start; }
.manuals-page > .page-head { padding-left: max(28px, calc((100% - 1400px) / 2)); padding-right: max(28px, calc((100% - 1400px) / 2)); }
/* knowledge page sections */
.k-section { margin-bottom: 30px; }
.k-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.k-section-head h3 { font-family: var(--font-display); font-size: 15px; color: var(--text-primary); margin: 0; }
.k-actions { display: flex; gap: 8px; margin: 10px 0; }
.guide-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); margin-bottom: 6px; }
.guide-row .guide-body { flex: 1; white-space: pre-wrap; color: var(--text-secondary); }
.guide-row .guide-actions { display: flex; gap: 6px; }
.guide-row .guide-actions button { font-size: 12px; padding: 2px 8px; border: 1px solid var(--border-default); background: var(--surface-glass); color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; }
.guide-row .guide-actions button.danger { color: var(--accent-error); border-color: var(--accent-error); }
/* shared buttons + modal */
.btn { font: inherit; font-size: 13px; padding: 7px 14px; border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--surface-glass); color: var(--text-secondary); cursor: pointer; }
.btn:hover { color: var(--text-primary); background: var(--surface-glass-hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { border-color: var(--accent-primary); color: var(--accent-primary); background: var(--accent-primary-subtle); }
.btn-danger { border-color: var(--accent-error); color: var(--accent-error); }
.btn-ghost { background: transparent; }
.modal-body { display: flex; flex-direction: column; gap: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
/* knowledge form controls */
.k-hint { font-size: 12px; margin: 0 0 10px; }
.k-input, .k-textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-primary); font: inherit; }
.k-textarea { resize: vertical; min-height: 90px; }
.k-list { margin-top: 10px; }
.k-searchbar { display: flex; gap: 8px; align-items: center; }
.k-searchbar .k-input { flex: 1; }
.k-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.k-filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.k-removebar { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 8px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-secondary); }
.k-removebar .muted { flex: 1; }
.manuals-toc { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 22px; }
.manuals-toc button { text-align: left; background: transparent; border: none; color: var(--text-secondary); padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 13px; }
.manuals-toc button:hover { background: var(--surface-glass); color: var(--text-primary); }
.manuals-toc button.active { background: var(--accent-primary-subtle); color: var(--accent-primary); font-weight: 600; }
.manuals-content { padding: 0; max-width: none; }
.manuals-content h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 12px; }
.manuals-content h2 { font-family: var(--font-display); font-size: 16px; margin: 22px 0 8px; color: var(--text-primary); }
.manuals-content p, .manuals-content li { color: var(--text-secondary); }
.manuals-content a { color: var(--accent-primary); cursor: pointer; }

.k-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.k-grid h3 { font-family: var(--font-display); font-size: 14px; color: var(--text-secondary); margin: 0 0 8px; }
.k-retrieve input { width: 100%; padding: 9px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-primary); font: inherit; }
.k-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.k-tag { font-size: 12px; padding: 3px 10px; border-radius: var(--radius-full); border: 1px solid var(--border-default); background: var(--surface-glass); color: var(--text-secondary); }
.k-tag.active { background: var(--accent-primary-subtle); color: var(--accent-primary); border-color: var(--accent-primary); }
.k-results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.k-chunk { padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-secondary); font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
@media (max-width: 900px) { .k-grid { grid-template-columns: 1fr; } }

/* ── scroll + layout fixes (added) ── */
/* Custom-element surfaces must fill Main and let their inner panes scroll. */
artifact-renderer, ai-session { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.chat-wrap { min-height: 0; }
.renderer-host { min-height: 0; }
.dual { flex: 1 1 auto; min-height: 0; height: auto; }
.surface-body { min-height: 0; }

/* Knowledge: the query window is the main column; tags/guidance to the right. */
.k-grid { grid-template-columns: 1.7fr 1fr; }
.k-retrieve input { font-size: 15px; padding: 12px 14px; }
.k-results { max-height: none; }

/* ── round 2 fixes (added) ── */
/* (page width/centering is handled by the padding-based centering above; the old
   max-width here left-aligned the content, so it's intentionally removed.) */
.k-grid { grid-template-columns: minmax(0, 2.6fr) minmax(240px, 1fr); }
/* back button to the left of the page title */
.page-head { justify-content: flex-start; gap: 12px; }
.page-back { border: 1px solid var(--border-strong); }

/* navigator search */
.nav-search { width: calc(100% - 12px); margin: 0 6px 8px; padding: 7px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-primary); font: inherit; font-size: 13px; }

/* rail collapse buttons + collapsed Rail 2 */
.rail-collapse, .rail-expand { background: transparent; border: none; color: var(--text-tertiary); font-size: 14px; padding: 2px 6px; border-radius: var(--radius-sm); }
.rail-collapse:hover, .rail-expand:hover { background: var(--surface-glass-hover); color: var(--text-primary); }
.v3-rail-head { align-items: center; }
.v3-rail1.collapsed .space-tag { display: none; }
.v3-rail2-title { display: flex; align-items: center; justify-content: space-between; }
.rail-expand { display: none; }
.v3-rail2.collapsed { width: 38px; flex-basis: 38px; }
.v3-rail2.collapsed #rail2title, .v3-rail2.collapsed .nav-scroll, .v3-rail2.collapsed .rail-collapse, .v3-rail2.collapsed #btnSpaceResources { display: none; }
.v3-rail2.collapsed .v3-rail2-title { justify-content: center; padding: 10px 0; }
.v3-rail2.collapsed .rail-expand { display: block; margin: 8px auto; }

/* session error banner + working indicator */
.session-error { margin: 6px 18px; padding: 8px 12px; border: 1px solid var(--accent-error); background: var(--accent-error-glow); color: var(--accent-error); border-radius: var(--radius-md); font-size: 13px; }
.working { color: var(--text-tertiary); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }

/* ── animations / smoother UX (added) ── */
@keyframes v3pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes v3fade { from { opacity: 0; } to { opacity: 1; } }

/* collapsible nav sections animate via max-height (toggled in place) */
.nav-section-body { overflow: hidden; max-height: 5000px; opacity: 1;
  transition: max-height .22s ease, opacity .16s ease, margin .22s ease; }
.nav-section-body.collapsed { max-height: 0; opacity: 0; margin: 0; }
.nav-section-head .chev { transition: transform .18s ease; }

/* rails resize smoothly */
.v3-rail1, .v3-rail2 { transition: width .2s ease, flex-basis .2s ease; }

/* floating menus + pages animate in */
.v3-ctx, .v3-dropdown { animation: v3pop .12s ease; transform-origin: top; }
.v3-page { animation: v3fade .16s ease; }
.v3-overlay.open { animation: v3fade .14s ease; }
.v3-overlay-card { animation: v3pop .16s ease; }

/* interactive elements ease their hover/active states */
.space-node, .nav-item, .nav-channel, .v3-iconbtn, .renderer-pick, .k-tag,
.v3-ctx-item, .status-pill, .badge { transition: background .14s ease, color .14s ease, border-color .14s ease, transform .12s ease; }
.space-node.drop-into { transition: background .1s ease, outline-color .1s ease; }
.nav-item:active, .space-node:active { transform: translateX(1px); }

/* renderer picker + chat messages fade in */
.msg, .step, .k-chunk { animation: v3fade .18s ease; }

/* ── session: refs + collapsed tool calls (added) ── */
.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px; border-top: 1px solid var(--border-subtle); background: var(--bg-secondary); }
.ref-chip { font-size: 12px; background: var(--accent-primary-subtle); color: var(--accent-primary); border: 1px solid var(--border-default); border-radius: var(--radius-full); padding: 2px 4px 2px 8px; display: inline-flex; align-items: center; gap: 4px; }
.ref-chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.chat-input.drag { outline: 2px dashed var(--accent-primary); outline-offset: -3px; }
/* dropping a doc/artifact anywhere on a session attaches it as a reference #1 */
.chat-wrap.ref-drag { outline: 2px dashed var(--accent-primary); outline-offset: -4px; border-radius: var(--radius-md); }
/* clickable working references the agent emits in its messages #4 */
.ai-ref { color: var(--accent-primary); background: var(--accent-primary-subtle); border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: 0 5px; cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap; }
.ai-ref:hover { background: var(--accent-primary); color: #fff; }

details.step { padding: 0; border-left: 2px solid var(--border-strong); margin: 0; }
details.step summary { cursor: pointer; padding: 4px 12px; font-size: 12px; color: var(--text-tertiary); list-style: none; }
details.step summary:hover { color: var(--text-secondary); }
details.step summary::-webkit-details-marker { display: none; }
details.step.tool_call { border-color: var(--accent-info); }
details.step.tool_result { border-color: var(--accent-success); }
details.step .ts-body { padding: 4px 12px 8px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; color: var(--text-secondary); word-break: break-word; }
/* tool calls coalesced into one "Tools · N" group, each tool nested inside #2 */
/* NB: no `overflow: hidden` here — in the flex-column chat scroll it makes the
   item's automatic min-size resolve to 0, so the group collapses to a clipped
   gray sliver when the conversation overflows. flex-shrink:0 also pins it. */
details.tools-group { align-self: stretch; flex-shrink: 0; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-secondary); margin: 4px 0; }
details.tools-group > summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); list-style: none; user-select: none; display: flex; align-items: center; gap: 8px; }
details.tools-group > summary::-webkit-details-marker { display: none; }
details.tools-group > summary::before { content: '▸'; font-size: 10px; color: var(--text-tertiary); transition: transform .15s ease; }
details.tools-group[open] > summary::before { transform: rotate(90deg); }
details.tools-group[open] > summary { border-bottom: 1px solid var(--border-subtle); }
details.tools-group > summary:hover { color: var(--text-primary); background: var(--surface-glass); }
details.tools-group .tools-body { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 4px; }
details.tool-item { border-left: 2px solid var(--accent-info); background: var(--bg-primary); border-radius: var(--radius-sm); }
details.tool-item > summary { cursor: pointer; padding: 5px 10px; font-size: 12px; color: var(--text-secondary); list-style: none; display: flex; align-items: center; gap: 6px; }
details.tool-item > summary::-webkit-details-marker { display: none; }
details.tool-item > summary::before { content: '▸'; font-size: 9px; color: var(--text-muted); transition: transform .15s ease; }
details.tool-item[open] > summary::before { transform: rotate(90deg); }
details.tool-item > summary:hover { color: var(--text-primary); }
details.tool-item .ts-body { padding: 4px 10px 6px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; color: var(--text-tertiary); word-break: break-word; }
details.tool-item .ts-result { border-top: 1px dashed var(--border-subtle); color: var(--text-secondary); }
/* the agent's interim commentary, shown between the tools inside the group */
.tool-thinking { padding: 4px 10px; font-size: 12.5px; font-style: italic; color: var(--text-tertiary); border-left: 2px solid var(--border-strong); }
.tool-thinking p { margin: 2px 0; }
/* Nested pipeline steps under a run_pipeline tool call. */
.pipe-steps { margin: 2px 0 4px 10px; padding-left: 8px; border-left: 2px dashed var(--border-subtle); display: flex; flex-direction: column; gap: 3px; }
.pipe-steps-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 2px 0; }
details.pipe-step { background: var(--bg-primary); border-radius: var(--radius-sm); border-left: 2px solid var(--border-strong); }
details.pipe-step > summary { cursor: pointer; padding: 4px 9px; font-size: 12px; color: var(--text-secondary); list-style: none; display: flex; align-items: center; gap: 6px; }
details.pipe-step > summary::-webkit-details-marker { display: none; }
details.pipe-step > summary::before { content: '▸'; font-size: 9px; color: var(--text-muted); transition: transform .15s ease; }
details.pipe-step[open] > summary::before { transform: rotate(90deg); }
details.pipe-step .ps-kind { margin-left: auto; font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.ps-status { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; padding: 0 5px; border-radius: var(--radius-full); background: var(--surface-glass-active); color: var(--text-tertiary); }
.ps-status.ps-st-ok { color: var(--accent-success, #3fb950); }
.ps-status.ps-st-warn { color: var(--accent-warning, #d29922); }
.ps-status.ps-st-error { color: var(--accent-error); }
/* AI model name pill in the session header + author label on final messages */
.surface-head .ai-name { font-size: 11px; color: var(--text-tertiary); background: var(--surface-glass-active); border: none; border-radius: var(--radius-full); padding: 2px 9px; cursor: pointer; font-family: inherit; }
.surface-head .ai-name:hover { color: var(--text-primary); background: var(--surface-glass-hover); }
.model-menu .v3-ctx-item.active { color: var(--accent-primary); }
/* floating action shown when text is selected in a document/artifact view */
.sel-action { position: fixed; z-index: 90; font: inherit; font-size: 12px; padding: 6px 12px; border-radius: var(--radius-md); border: 1px solid var(--accent-primary); background: var(--bg-elevated); color: var(--accent-primary); cursor: pointer; box-shadow: var(--shadow-lg); white-space: nowrap; }
.sel-action:hover { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
.step.final .who { font-size: 11px; color: var(--text-tertiary); margin-bottom: 3px; font-weight: 600; }
/* empty channel placeholder */
.chan-empty { color: var(--text-muted); text-align: center; padding: 40px 16px; font-size: 13px; }
/* account dropdown extras */
.v3-dropdown .dd-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 6px 12px 2px; }
.v3-dropdown .v3-ctx-item.active { color: var(--accent-primary); }
/* small icon button in the rail-2 title row (Space resources) */
.v3-rail2-title #rail2title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-iconbtn { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 2px 4px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; }
.rail-iconbtn:hover { color: var(--text-primary); background: var(--surface-glass-active); }
details.pipe-step .ts-body { padding: 4px 10px 6px; font-family: var(--font-mono); font-size: 11.5px; white-space: pre-wrap; color: var(--text-tertiary); word-break: break-word; }
details.pipe-step.ps-ok { border-left-color: var(--accent-success, #3fb950); }
details.pipe-step.ps-warn { border-left-color: var(--accent-warning, #d29922); }
details.pipe-step.ps-error { border-left-color: var(--accent-error); }
details.pipe-step.ps-skipped { border-left-color: var(--border-subtle); opacity: .7; }
/* Context-compaction marker — a quiet centered divider, not a chat bubble. */
details.step.compaction { align-self: stretch; border-left: none; border-top: 1px dashed var(--border-strong); border-bottom: 1px dashed var(--border-strong); margin: 8px 0; background: var(--surface-glass); }
details.step.compaction summary { text-align: center; font-style: italic; }
details.step.compaction .ts-body { font-family: var(--font-sans, inherit); white-space: normal; }

/* ── session: message refs + thinking bubble (added) ── */
.msg-refs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.msg.user .msg-refs .ref-chip { background: var(--bg-secondary); }
.thinking-bubble { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-md); background: var(--surface-glass); border: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: 13px; animation: v3fade .2s ease; }
.thinking-bubble .dots { display: inline-flex; gap: 3px; }
.thinking-bubble .dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-tertiary); display: inline-block; animation: v3blink 1.2s infinite both; }
.thinking-bubble .dots span:nth-child(2) { animation-delay: .2s; }
.thinking-bubble .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes v3blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ── resizable rails (#3) + knowledge column swap (#4) ── */
.v3-rail1, .v3-rail2 { position: relative; }
.rail-resizer { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 6; }
.rail-resizer:hover { background: var(--accent-primary-subtle); }
.v3-rail1.collapsed .rail-resizer, .v3-rail2.collapsed .rail-resizer { display: none; }
.v3-rail1.resizing, .v3-rail2.resizing { transition: none; user-select: none; }

/* Tags/Guidance on the left, Retrieval (dominant) on the right. */
.k-grid { grid-template-columns: minmax(240px, 1fr) minmax(0, 2.6fr); }

/* ── platform status page ── */
.status-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.status-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-secondary); }
.status-main { flex: 1; min-width: 0; }
.status-name { font-weight: 600; font-size: 13.5px; }
.status-detail { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.status-detail a { color: var(--accent-info); }
.status-lat { font-size: 11.5px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.ok { background: #27ae60; box-shadow: 0 0 0 3px rgba(39, 174, 96, .15); }
.status-dot.down { background: #c0392b; box-shadow: 0 0 0 3px rgba(192, 57, 43, .15); }
.status-dot.ext { background: var(--text-muted); box-shadow: 0 0 0 3px var(--surface-glass-active); }
.status-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: 2px 9px; border-radius: var(--radius-full); flex: 0 0 auto; }
.status-badge.ok { color: #27ae60; border: 1px solid #27ae60; }
.status-badge.down { color: #c0392b; border: 1px solid #c0392b; }
.status-badge.ext { color: var(--text-muted); border: 1px solid var(--border-strong); }
