/* YEL PoC — borrows the v5 mockup palette, less chrome */

:root {
  --bg-0: #f4f5f2;
  --bg-1: #fbfbf9;
  --bg-2: #ffffff;
  --bg-3: #ffffff;
  --border-1: #efefea;   /* faintest hairline on paper */
  --border-2: #e7e7e1;   /* = --doc-line, the standard hairline */
  --border-3: #d9dad2;   /* = --doc-line-2, the stronger rule */
  --ink-0: #1a1c1a;
  --ink-1: #33352f;
  --ink-2: #5f615a;
  --ink-3: #6f7168;
  --ink-4: #6f7168;
  /* Paper-legible values of the same four hues. The originals — #ff6a3d,
     #7dd3fc, #fbbf24, #34d399 — were tuned to glow on #0f1218 and measure
     2.85:1, 1.67:1, 1.67:1 and 1.92:1 on white. #437 flipped the inks and
     grounds and left these behind, so every accent-coloured label in the app
     was unreadable: the rail's completeness %, the nav counts, the weekly
     brief's action links. Same values as workspace.css, which must agree. */
  --accent: #a8462c;
  --accent-cyan: #2a6b65;
  --accent-amber: #9a6a12;
  --accent-green: #1f7a52;
  /* danger — was hardcoded #f87171 in ~60 places; now a token */
  --danger: #f87171;
  --danger-weak: rgba(248, 113, 113, .08);
  --danger-mid:  rgba(248, 113, 113, .15);
  --danger-line: rgba(248, 113, 113, .40);
  /* type scale — use these instead of ad-hoc px (no fractional sizes) */
  --fs-2xs: 10px;
  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-base:13px;
  --fs-md:  14px;
  --fs-lg:  17px;
  --fs-xl:  20px;
  --fs-2xl: 24px;
  /* radius scale */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-pill: 999px;
  /* spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --scrollbar-size: 8px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: #d9dad2;
  --scrollbar-thumb-hover: #c3c4ba;
  --scrollbar-thumb-active: #adaea4;

  --doc-bg: #fbfbf9;
  --doc-card: #ffffff;
  --doc-wash: #f4f5f2;
  --doc-line: #e7e7e1;
  --doc-line-2: #d9dad2;
  --doc-ink-0: #1a1c1a;
  --doc-ink-1: #33352f;
  --doc-ink-2: #5f615a;
  --doc-ink-3: #6f7168;
  --doc-accent: #1d4e4a;
  --doc-accent-2: #2a6b65;
  --doc-amber: #9a6a12;
  --doc-sans: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  --doc-subtle: #f6f7f9;
  --doc-border: #e7e7e1;
  --doc-accent-soft: #e8f0ee;
  --doc-amber-soft: #f6edd7;
  --doc-green: #1f7a52;
  --doc-warn: #a8462c;
  /* Ink for a label sitting on an amber wash. --doc-amber is tuned for white and
     drops to 4.12:1 once an 8% wash lifts the ground under it. */
  --doc-amber-ink: #8a5a12;
  /* --doc-ink-4 shipped at #a9aaa1 — 2.35:1 on white, roughly half the AA floor,
     across 50 call sites. It is an alias of --doc-ink-3 rather than a ported
     value, so those call sites need no edit and the pale grey cannot come back. */
  --doc-ink-4: #6f7168;
  /* .ctx-modal-card and .ctx-icp-textarea read var(--surface) with no fallback,
     which rendered a transparent modal. It is the card ground. */
  --surface: #ffffff;
  --doc-serif: 'Fraunces', Georgia, serif;
}

/* The document palette — the light skin, for reading surfaces.
 *
 * Declared here because this file is where tokens live and the only one the
 * design-system check lets define raw colour. Five stylesheets currently carry
 * their own copy of these values, and mbo.css repeats the block eight times
 * inside itself; this is the canonical one to migrate them onto. Nothing is
 * migrated here — a re-skin is the wrong change to bundle that into.
 *
 * Opt in per PAGE, never per mode. A surface either reads or it edits: give a
 * reading surface the doc class, leave everything else on the dark tokens
 * above. These are deliberately NOT on :root, so declaring them changes the
 * rendering of nothing until a selector asks for them.
 *
 * CONTRAST, measured on doc-bg, not assumed:
 *   ink-0 16.6   ink-1 12.0   ink-2 6.1   ink-3 4.8   accent 9.0   accent-2 6.0
 *   ink-4 2.3 — fails AA, so there is no ink-4 here. The dark scale's ink-4
 *   carries 11px labels; on cream that is unreadable, and a token named to
 *   match would invite a one-to-one swap that ships it.
 */
.doc-skin { /* alias: the document tokens live on :root now */ }

/* ───── scrollbars (Firefox + WebKit) ───── */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 100px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-active);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-1);
  color: var(--ink-1);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;             /* page itself doesn't scroll — only inner regions */
}
.topbar { flex: 0 0 auto; }     /* fixed natural height */
.shell  { flex: 1 1 auto; }     /* fills the rest reliably regardless of topbar size */

button { font-family: inherit; cursor: pointer; }
textarea, input { font-family: inherit; }

/* ───── top bar ───── */
.topbar {
  display: flex; align-items: baseline; gap: 14px;
  padding: 12px 22px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-2);
}
.topbar .brand { font-size: 13px; color: var(--ink-2); font-weight: 700; letter-spacing: 0.06em; }
.topbar .brand-sub { font-size: 11px; color: var(--ink-4); font-weight: 400; letter-spacing: 0.02em; margin-left: 8px; }
a.brand-home {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
}
a.brand-home:hover { opacity: 0.88; }
a.brand-home .brand { color: inherit; }
.topbar .sub { font-size: 13px; color: var(--ink-2); flex: 1; }
.topbar .meta {
  font-size: 11px; font-family: ui-monospace, monospace;
  color: var(--ink-4); padding: 3px 8px;
  background: var(--bg-2); border-radius: 4px;
}
.topbar .meta.live { color: var(--accent-cyan); }
.topbar .meta.err  { color: #f87171; }

/* ───── shell ───── */
.shell {
  display: grid;
  grid-template-columns: var(--ws-rail-w, 52px) 260px 1fr;
  grid-template-rows: 1fr;
  min-height: 0;
  overflow: hidden;
}
.shell.ws-rail-expanded { --ws-rail-w: 212px; }
.shell > * { min-height: 0; min-width: 0; }

/* ───── workspace section rail (index + shared) ───── */
.ws-section-rail {
  width: var(--ws-rail-w, 52px);
  flex: none;
  border-right: 1px solid var(--border-1);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  padding: 8px 0 10px;
  gap: 2px;
  transition: width .2s ease;
  overflow: hidden;
}
.ws-section-rail.expanded { width: var(--ws-rail-w, 212px); }
.ws-section-rail .rail-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 6px;
  gap: 6px;
}
.ws-section-rail.expanded .rail-head {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  gap: 8px;
}
.ws-section-rail .rail-pct {
  width: 100%;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-green);
  padding: 4px 0;
  line-height: 1.2;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: inherit;
  text-decoration: none;
}
.ws-section-rail a.rail-pct:hover { color: var(--accent-cyan); }
.ws-section-rail .rail-pct:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
  border-radius: 4px;
}
.ws-section-rail.expanded .rail-pct {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 4px 0 4px 6px;
  width: auto;
}
.ws-section-rail .rail-pct small {
  display: block;
  font-size: 8px;
  color: var(--ink-4);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.ws-section-rail .rail-toggle {
  flex: none;
  width: 28px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform .2s, color .15s, background .15s;
}
.ws-section-rail.expanded .rail-toggle { width: 24px; height: 24px; font-size: 14px; }
.ws-section-rail .rail-toggle:hover { color: var(--ink-0); background: var(--bg-3); }
.ws-section-rail.expanded .rail-toggle { transform: rotate(180deg); }
.ws-section-rail .rail-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 6px;
}
.ws-section-rail.expanded .rail-items { align-items: stretch; }
.ws-section-rail .nav-row-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
}
.ws-section-rail.expanded .nav-row-wrap {
  width: 100%;
  height: auto;
  min-height: 38px;
  gap: 4px;
  padding-right: 2px;
}
.ws-section-rail .nav-row-wrap.on .nav-row {
  background: var(--bg-2);
  border-color: var(--border-2);
  color: var(--ink-0);
}
.ws-section-rail .nav-row-wrap.on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  z-index: 1;
}
.ws-section-rail .nav-row {
  flex: 1;
  min-width: 0;
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 15px;
  background: transparent;
  padding: 0 0 0 6px;
  font-family: inherit;
  text-align: left;
}
.ws-section-rail.expanded .nav-row { padding: 0 4px 0 6px; }
.ws-section-rail .nav-row:hover { background: var(--bg-2); color: var(--ink-1); }
.ws-section-rail .nav-row-link { text-decoration: none; display: flex; align-items: center; gap: 10px; width: 100%; }
.ws-section-rail .nav-row-ic { flex: none; width: 24px; text-align: center; font-size: 15px; line-height: 1; }
.ws-section-rail .nav-row-label {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  width: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.ws-section-rail.expanded .nav-row-label { opacity: 1; width: auto; pointer-events: auto; }
.ws-section-rail .rail-group-label {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4);
  padding: 10px 8px 4px; width: 100%; flex-shrink: 0;
}
.ws-section-rail:not(.expanded) .rail-group-label { display: none; }
.ws-section-rail .rail-foot {
  margin-top: auto;
  padding: 8px 6px 0;
  border-top: 1px solid var(--border-1);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ws-section-rail.expanded .rail-foot { align-items: stretch; }
/* Page-navigation rows (anchors) get a trailing affordance so they read as
   "goes to another page", distinct from overlay-trigger rows (buttons). */
.ws-section-rail.expanded .rail-foot a.nav-row-link::after {
  content: '↗';
  margin-left: auto;
  padding-left: 6px;
  font-size: 11px;
  color: var(--ink-4);
  opacity: 0.7;
}

.rail {
  background: var(--bg-0);
  padding: 16px 14px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-gutter: stable;
}
.rail-left  { border-right: 1px solid var(--border-1); }
.rail-right { border-left:  1px solid var(--border-1); }
.rail h2 {
  margin: 0; font-size: 10px;
  color: var(--ink-4); letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 600;
}
.hint { font-size: 11px; color: var(--ink-4); margin-bottom: 4px; }

/* ───── rail h2 row with view toggle ───── */
.rail-h2-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.view-toggle {
  display: inline-flex; gap: 0;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 5px; padding: 2px;
}
.vt-btn {
  padding: 3px 8px; font-size: 10px;
  background: transparent; color: var(--ink-3);
  border: none; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.vt-btn.on {
  background: var(--bg-3); color: var(--ink-1);
}

/* ───── agent list ───── */
.agent-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }

.agent-section {
  margin-top: 6px;
}
.agent-section:first-child { margin-top: 0; }
.agent-section-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 4px; cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 4px;
}
.agent-section-head:hover { color: var(--ink-1); }
.agent-section-head .caret {
  font-size: 9px; color: var(--ink-4);
  transition: transform 0.15s;
  width: 10px; text-align: center;
}
.agent-section.collapsed .caret { transform: rotate(-90deg); }
.agent-section-head .stitle {
  flex: 1; font-size: 10px;
  color: var(--ink-2); letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 600;
}
.agent-section-head .scount {
  font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace;
}
.agent-section-head .stagline {
  font-size: 9px; color: var(--ink-4); font-style: italic;
  display: block; margin-left: 16px; margin-top: -2px; margin-bottom: 4px;
}
.agent-section.collapsed .agent-section-content { display: none; }

.agent-subsection {
  margin: 4px 0 6px 10px;
}
.agent-subsection-head {
  font-size: 9px; color: var(--ink-4); letter-spacing: 0.06em;
  padding: 3px 4px; text-transform: uppercase;
}

.agent-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 4px;
  cursor: pointer; user-select: none;
  font-size: 11.5px;
}
.agent-item:hover { background: var(--bg-2); }
.agent-item.on {
  background: rgba(125,211,252,0.10);
}
.agent-item .check {
  width: 12px; height: 12px; border-radius: 2px;
  border: 1px solid var(--border-3); background: var(--bg-0);
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
}
.agent-item.on .check {
  background: var(--accent-cyan); border-color: var(--accent-cyan);
  color: #0c1018; font-weight: 700;
}
.agent-item .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
}
.agent-item .name {
  flex: 1; color: var(--ink-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.agent-item .name:hover { color: var(--accent-cyan); }
.agent-item .skilltag {
  font-size: 8px; padding: 1px 4px;
  background: rgba(251,191,36,0.12); color: var(--accent-amber);
  border: 1px solid rgba(251,191,36,0.3); border-radius: 2px;
}
.agent-item .multitag {
  font-size: 8px; color: var(--ink-4);
  font-family: ui-monospace, monospace;
}
.agent-item .modeltag {
  font-size: 8px; padding: 1px 5px;
  border-radius: 2px;
  font-family: ui-monospace, monospace;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.agent-item .modeltag.gemini {
  background: rgba(251,191,36,0.10); color: var(--accent-amber);
  border: 1px solid rgba(251,191,36,0.3);
}
.agent-item .modeltag.openai {
  background: rgba(52,211,153,0.10); color: var(--accent-green);
  border: 1px solid rgba(52,211,153,0.3);
}
.agent-item .modeltag.missing {
  background: rgba(248,113,113,0.08);
  color: #f87171; border-color: rgba(248,113,113,0.3);
  text-decoration: line-through;
}
.agent-item.unavailable { opacity: 0.55; }
.agent-item .open-hint {
  opacity: 0; font-size: 9px; color: var(--ink-4);
  transition: opacity 0.12s; flex: none;
}
.agent-item:hover .open-hint { opacity: 1; }

/* ───── skills list ───── */
.skill-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 50vh; overflow-y: auto;
}
.skill-group-head {
  font-size: 9px; color: var(--ink-4); letter-spacing: 0.08em;
  text-transform: uppercase; margin-top: 8px; padding: 0 4px;
}
.skill-group-head:first-child { margin-top: 0; }
.skill-item {
  padding: 6px 8px; border-radius: 5px;
  cursor: pointer; font-size: 11.5px;
  display: flex; align-items: center; gap: 6px;
}
.skill-item:hover { background: var(--bg-2); }
.skill-item .sname {
  flex: 1; color: var(--ink-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.skill-item .stag {
  font-size: 8px; padding: 1px 5px; border-radius: 3px;
  background: rgba(125,211,252,0.12); color: var(--accent-cyan);
  border: 1px solid rgba(125,211,252,0.3);
  font-family: ui-monospace, monospace;
}
.skill-item .stag.auto {
  background: rgba(167,139,250,0.10); color: #c4b5fd;
  border-color: rgba(167,139,250,0.3);
}
.skill-item .sopen { font-size: 9px; color: var(--ink-4); opacity: 0; }
.skill-item:hover .sopen { opacity: 1; }
.skill-empty {
  font-size: 11px; color: var(--ink-4); font-style: italic; padding: 8px;
}

/* ───── center ───── */
.center {
  background: var(--bg-1);
  padding: 18px 26px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;          /* let the column scroll when stacked panes overflow */
  overflow-x: hidden;
  min-width: 0;
  min-height: 0;             /* required for flex item to honor parent height */
  scrollbar-gutter: stable;
}

.kb-context-bar {
  background: rgba(52, 211, 153, .06);
  border: 1px solid rgba(52, 211, 153, .25);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.kb-context-bar .kb-title { font-size: 13px; font-weight: 600; color: var(--ink-0); }
.kb-context-bar .kb-summary { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.45; max-width: 52ch; }
.kb-context-bar .kb-links { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kb-context-bar a { font-size: 11px; color: var(--accent-cyan); text-decoration: none; }
.kb-context-bar a:hover { text-decoration: underline; }
.kb-context-bar button { font-size: 11px; padding: 5px 10px; background: var(--bg-3); border: 1px solid var(--border-3); border-radius: 6px; color: var(--ink-1); cursor: pointer; }
.kb-context-bar button:hover { border-color: var(--accent-green); }

.problem-card {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.problem-card .lbl {
  font-size: 10px; color: var(--ink-4); letter-spacing: 0.12em; text-transform: uppercase;
}
.problem-card textarea {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  color: var(--ink-1);
  padding: 10px 12px;
  font-size: 13px; line-height: 1.55;
  resize: vertical;
  outline: none;
}
.problem-card textarea:focus { border-color: var(--accent-cyan); }
.usecase-card { display: flex; flex-direction: column; gap: 6px; }
.usecase-select {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  color: var(--ink-1);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.usecase-select:focus { border-color: var(--accent-cyan); }
.usecase-hint { font-size: 11px; color: var(--ink-4); line-height: 1.5; }
.problem-card .actions {
  display: flex; align-items: center; gap: 12px;
}
.picked-meta {
  flex: 1; font-size: 11px; color: var(--ink-3); font-family: ui-monospace, monospace;
}
.run-btn {
  padding: 8px 16px; font-size: 12.5px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), #ffb86b);
  color: #1a0d05; border: none; border-radius: 6px;
}
.run-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
  background: var(--bg-3); color: var(--ink-3);
}

/* ───── outputs grid ───── */
.outputs {
  /* fixed-ish height inside the scrollable center, so columns can
     scroll internally instead of collapsing to content height */
  min-height: 360px;
  max-height: 60vh;
  overflow-x: auto;
  overflow-y: hidden;
  display: grid; gap: 12px;
  grid-auto-flow: column;
  grid-auto-columns: minmax(320px, 1fr);
}
.outputs .empty {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4); font-style: italic;
  border: 1px dashed var(--border-2); border-radius: 10px;
  padding: 40px;
}
.col {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-left-width: 3px;
  border-radius: 10px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.col header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.col header .name { font-weight: 600; color: var(--ink-1); flex: 1; }
.col header .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.col header .state.streaming { background: rgba(125,211,252,0.18); color: var(--accent-cyan); }
.col header .state.done      { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.col header .state.error     { background: rgba(248,113,113,0.16); color: #f87171; }
.col .meta {
  padding: 4px 14px 0; font-size: 10px;
  color: var(--ink-4); font-family: ui-monospace, monospace;
}
.col .output {
  flex: 1; overflow-y: auto;
  padding: 12px 14px;
  font-size: 13px; line-height: 1.65; color: var(--ink-1);
  white-space: pre-wrap; word-wrap: break-word;
}
.col .output:empty::before {
  content: 'waiting…';
  color: var(--ink-4); font-style: italic;
}
.col .output .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent-cyan); animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }
.col .stderr {
  padding: 6px 14px; font-size: 10px;
  color: #f87171; background: rgba(248,113,113,0.06);
  border-top: 1px solid rgba(248,113,113,0.15);
  white-space: pre-wrap;
}

/* per-column include toggle in header */
.col header .include {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--border-3); background: var(--bg-0);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none; font-size: 9px; color: transparent;
}
.col.included header .include {
  background: var(--accent-cyan); border-color: var(--accent-cyan);
  color: #0c1018; font-weight: 700;
}

/* per-column weight dots */
.col header .weight {
  display: inline-flex; align-items: center; gap: 3px;
  margin-left: auto; padding-right: 4px;
  opacity: 0.45;
}
.col.included header .weight { opacity: 1; }
.col header .weight .wlabel {
  font-size: 9px; color: var(--ink-4); letter-spacing: 0.06em;
  text-transform: uppercase; margin-right: 4px;
}
.col header .weight .wdot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg-0); border: 1px solid var(--border-3);
  cursor: pointer;
}
.col header .weight .wdot.on {
  background: var(--accent-cyan); border-color: var(--accent-cyan);
}
.col header .weight .wdot:hover {
  border-color: var(--ink-3);
}

/* ───── remix bar ───── */
.remix-bar {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: -4px;
}
.remix-bar .rb-row { display: flex; align-items: center; gap: 14px; }
.remix-bar .rb-top { justify-content: space-between; }
.remix-bar .rb-meta {
  font-size: 11px; color: var(--ink-3); font-family: ui-monospace, monospace;
}
.remix-bar .rb-controls { flex-wrap: wrap; }
.remix-bar .rb-group { display: flex; align-items: center; gap: 8px; }
.remix-bar .rb-label {
  font-size: 10px; color: var(--ink-4);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.chip-group { display: flex; gap: 4px; }
.chip {
  padding: 4px 10px; font-size: 11px;
  background: var(--bg-0); color: var(--ink-3);
  border: 1px solid var(--border-2); border-radius: 5px;
}
.chip.on {
  background: rgba(167,139,250,0.15); color: #c4b5fd;
  border-color: rgba(167,139,250,0.4);
}
.chip:hover:not(.on) { color: var(--ink-1); border-color: var(--border-3); }
.remix-bar input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-0); border: 1px solid var(--border-2);
  border-radius: 6px; color: var(--ink-1);
  font-size: 12px; outline: none;
}
.remix-bar input:focus { border-color: var(--accent-cyan); }
.remix-btn {
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  background: rgba(167,139,250,0.15); color: #c4b5fd;
  border: 1px solid rgba(167,139,250,0.35); border-radius: 6px;
}
.remix-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.summarize-btn {
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  background: rgba(251,191,36,0.12); color: #fcd34d;
  border: 1px solid rgba(251,191,36,0.35); border-radius: 6px;
}
.summarize-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ───── remix output pane ───── */
.remix-pane {
  background: linear-gradient(180deg, rgba(167,139,250,0.06), rgba(167,139,250,0.01));
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 10px;
  padding: 16px 22px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 45vh; overflow: hidden;
}
.remix-pane .rp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
}
.remix-pane .rp-head .left { display: flex; gap: 10px; align-items: center; }
.remix-pane .rp-head .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #a78bfa;
}
.remix-pane .rp-head .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.remix-pane .rp-head .state.streaming { background: rgba(167,139,250,0.2); color: #c4b5fd; }
.remix-pane .rp-head .state.done { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.remix-pane .rp-head .state.error { background: rgba(248,113,113,0.16); color: #f87171; }
.remix-pane .rp-body {
  font-size: 13.5px; line-height: 1.7; color: var(--ink-1);
  white-space: pre-wrap; word-wrap: break-word;
  overflow-y: auto; flex: 1; min-height: 0;
}
.remix-pane .rp-body:empty::before { content: 'thinking…'; color: var(--ink-4); font-style: italic; }
.remix-pane .rp-body .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: #c4b5fd; animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}

/* ───── summary pane (amber, distinct from remix purple) ───── */
.summary-pane {
  background: linear-gradient(180deg, rgba(251,191,36,0.06), rgba(251,191,36,0.01));
  border: 1px solid rgba(251,191,36,0.35);
  border-radius: 10px;
  padding: 14px 20px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 45vh; overflow: hidden;
}
.summary-pane .sp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
}
.summary-pane .sp-head .left { display: flex; gap: 10px; align-items: center; }
.summary-pane .sp-head .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-amber);
}
.summary-pane .sp-head .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.summary-pane .sp-head .state.streaming { background: rgba(251,191,36,0.22); color: #fcd34d; }
.summary-pane .sp-head .state.done { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.summary-pane .sp-head .state.error { background: rgba(248,113,113,0.16); color: #f87171; }
.summary-pane .sp-body {
  font-size: 12.5px; line-height: 1.65; color: var(--ink-1);
  overflow-y: auto; flex: 1; min-height: 0;
  white-space: pre-wrap; word-wrap: break-word;
}
.summary-pane .sp-body:empty::before { content: 'thinking…'; color: var(--ink-4); font-style: italic; }
.summary-pane .sp-body .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: #fcd34d; animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}

/* ───── HoAC advisor toggle + pane ───── */
.advisor-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-3); cursor: pointer;
  padding: 4px 8px; border-radius: 5px;
  background: var(--bg-0); border: 1px solid var(--border-2);
}
.advisor-toggle:hover { color: var(--ink-1); border-color: var(--border-3); }
.advisor-toggle input { margin: 0; cursor: pointer; }

.advisor-pane {
  background: linear-gradient(180deg, rgba(125,211,252,0.07), rgba(125,211,252,0.01));
  border: 1px solid rgba(125,211,252,0.35);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.advisor-pane .ap-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.advisor-pane .ap-head .left { display: flex; align-items: center; gap: 8px; }
.advisor-pane .ap-head .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-cyan);
}
.advisor-pane .ap-head .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.advisor-pane .ap-head .state.streaming { background: rgba(125,211,252,0.22); color: var(--accent-cyan); }
.advisor-pane .ap-head .state.done { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.advisor-pane .ap-head .state.error { background: rgba(248,113,113,0.16); color: #f87171; }
.advisor-pane .ap-body {
  font-size: 12.5px; line-height: 1.65; color: var(--ink-1);
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 28vh; overflow-y: auto;
}
.advisor-pane .ap-body .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent-cyan); animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}
.advisor-pane .ap-quick-add {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 6px; border-top: 1px dashed rgba(125,211,252,0.25);
}
.advisor-pane .quick-add-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 11px;
  background: var(--bg-0); color: var(--accent-cyan);
  border: 1px solid rgba(125,211,252,0.35); border-radius: 5px;
  cursor: pointer;
}
.advisor-pane .quick-add-chip:hover {
  background: rgba(125,211,252,0.12);
}
.advisor-pane .quick-add-chip.added {
  background: rgba(52,211,153,0.12); color: var(--accent-green);
  border-color: rgba(52,211,153,0.35); cursor: default;
}
.advisor-pane .quick-add-chip .qa-dot {
  width: 6px; height: 6px; border-radius: 50%;
}

/* ───── download menu ───── */
.dl-wrap { position: relative; display: inline-flex; }
.dl-btn {
  background: transparent; color: var(--ink-3);
  border: 1px solid var(--border-2); border-radius: 4px;
  padding: 2px 7px; font-size: 11px; cursor: pointer;
  line-height: 1;
}
.dl-btn:hover { color: var(--ink-1); border-color: var(--border-3); background: var(--bg-2); }
.dl-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-1); border: 1px solid var(--border-3);
  border-radius: 6px; padding: 4px; z-index: 50;
  display: flex; flex-direction: column; gap: 1px;
  box-shadow: 0 12px 28px -8px rgba(0,0,0,0.5);
  min-width: 80px;
}
.dl-opt {
  background: transparent; color: var(--ink-1);
  border: none; padding: 5px 10px; font-size: 11px;
  text-align: left; border-radius: 3px;
  font-family: ui-monospace, monospace;
}
.dl-opt:hover { background: var(--bg-3); }

/* ───── market research pane (pink, distinct from cyan advisor) ───── */
.research-pane {
  background: linear-gradient(180deg, rgba(240,171,252,0.07), rgba(240,171,252,0.01));
  border: 1px solid rgba(240,171,252,0.35);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.research-pane .rsp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.research-pane .rsp-head .left { display: flex; align-items: center; gap: 8px; }
.research-pane .rsp-head .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #f0abfc;
}
.research-pane .rsp-head .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.research-pane .rsp-head .state.searching { background: rgba(125,211,252,0.22); color: var(--accent-cyan); }
.research-pane .rsp-head .state.synthesizing { background: rgba(240,171,252,0.22); color: #f0abfc; }
.research-pane .rsp-head .state.done { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.research-pane .rsp-head .state.error { background: rgba(248,113,113,0.16); color: #f87171; }
.research-pane .rsp-meta {
  font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace;
  border-bottom: 1px dashed rgba(240,171,252,0.25);
  padding-bottom: 6px;
}
.research-pane .rsp-body {
  font-size: 12.5px; line-height: 1.65; color: var(--ink-1);
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 38vh; overflow-y: auto;
}
.research-pane .rsp-body:empty::before { content: 'thinking…'; color: var(--ink-4); font-style: italic; }
.research-pane .rsp-body .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: #f0abfc; animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}

/* ───── refine bar (post-remix passes) ───── */
.refine-bar {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.refine-bar .rfb-head {
  display: flex; align-items: baseline; justify-content: space-between;
}
.refine-bar .rfb-label {
  font-size: 11px; color: var(--ink-2);
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
}
.refine-bar .rfb-hint {
  font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace;
}
.refine-bar .rfb-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.refine-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; font-size: 11.5px;
  background: var(--bg-0); color: var(--ink-1);
  border: 1px solid var(--border-2); border-radius: 6px;
  cursor: pointer;
}
.refine-chip:hover {
  border-color: rgba(52,211,153,0.5);
  background: rgba(52,211,153,0.06);
}
.refine-chip:disabled { opacity: 0.4; cursor: wait; }
.refine-chip .rc-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
}
.refine-chip .rc-tag {
  font-size: 8px; padding: 1px 4px;
  background: rgba(251,191,36,0.12); color: var(--accent-amber);
  border: 1px solid rgba(251,191,36,0.3); border-radius: 2px;
  font-family: ui-monospace, monospace;
}
.refine-chip .rc-mode {
  font-size: 9px; color: var(--ink-4); font-family: ui-monospace, monospace;
}

/* ───── refine output pane (green tint, distinct from remix purple) ───── */
.refine-pane {
  background: linear-gradient(180deg, rgba(52,211,153,0.06), rgba(52,211,153,0.01));
  border: 1px solid rgba(52,211,153,0.35);
  border-radius: 10px;
  padding: 16px 22px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 50vh; overflow: hidden;
}
.refine-pane .rp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
}
.refine-pane .rp-head .left { display: flex; gap: 10px; align-items: center; }
.refine-pane .rp-head .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-green);
}
.refine-pane .rp-head .state {
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--ink-3);
}
.refine-pane .rp-head .state.streaming { background: rgba(52,211,153,0.20); color: var(--accent-green); }
.refine-pane .rp-head .state.done { background: rgba(52,211,153,0.16); color: var(--accent-green); }
.refine-pane .rp-head .state.error { background: rgba(248,113,113,0.16); color: #f87171; }
.refine-pane .rp-body {
  font-size: 13.5px; line-height: 1.7; color: var(--ink-1);
  overflow-y: auto; flex: 1; min-height: 0;
  white-space: pre-wrap; word-wrap: break-word;
}
.refine-pane .rp-body:empty::before { content: 'thinking…'; color: var(--ink-4); font-style: italic; }
.refine-pane .rp-body .cursor {
  display: inline-block; width: 2px; height: 1em;
  background: var(--accent-green); animation: blink 1s steps(2) infinite;
  vertical-align: text-bottom; margin-left: 1px;
}

/* ───── file viewer overlay ───── */
.viewer-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; justify-content: flex-end;
}
.viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
.viewer {
  position: relative;
  width: min(720px, 60vw);
  height: 100%;
  background: var(--bg-1);
  border-left: 1px solid var(--border-2);
  display: flex; flex-direction: column;
  box-shadow: -24px 0 48px -20px rgba(0,0,0,0.6);
}
.viewer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 22px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-2);
  gap: 14px;
}
.viewer-title { flex: 1; min-width: 0; }
.viewer-title .vt-name {
  font-size: 14px; color: var(--ink-1); font-weight: 600;
}
.viewer-title .vt-path {
  font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace;
  margin-top: 2px; word-break: break-all;
}
.viewer-close {
  background: transparent; color: var(--ink-3); border: none;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.viewer-close:hover { color: var(--ink-1); }
.viewer-body {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.6;
  color: var(--ink-1);
  white-space: pre-wrap; word-wrap: break-word;
}
.viewer-body .vb-meta {
  font-family: -apple-system, sans-serif;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 6px;
  padding: 6px 10px; margin-bottom: 12px;
  display: flex; justify-content: space-between;
}
.viewer-body .vb-section {
  font-family: -apple-system, sans-serif;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-amber); font-weight: 600;
  margin: 18px 0 8px;
  padding-bottom: 4px; border-bottom: 1px dashed var(--border-3);
}
.viewer-body .vb-section:first-child { margin-top: 0; }
.viewer-body .vb-section.cyan { color: var(--accent-cyan); }

/* ───── file browser ───── */
.browser-panel { width: min(820px, 70vw); }
.browser-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-2);
}
.browser-toolbar .mini { flex: none; }
.browser-path-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-0); border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--ink-1); font-family: ui-monospace, monospace;
  font-size: 11px; outline: none;
}
.browser-path-input:focus { border-color: var(--accent-cyan); }

.browser-body {
  flex: 1; overflow-y: auto;
  padding: 8px 22px;
}
.browser-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin: 2px 0;
  border-radius: 5px;
  cursor: pointer; font-size: 12.5px;
  font-family: ui-monospace, monospace;
  user-select: none;
}
.browser-row:hover { background: var(--bg-2); }
.browser-row.picked {
  background: rgba(125,211,252,0.10);
  border: 1px solid rgba(125,211,252,0.35);
  padding: 5px 9px;
}
.browser-row .br-ic { width: 16px; text-align: center; flex: none; }
.browser-row .br-name { flex: 1; color: var(--ink-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-row.dir .br-name { color: var(--accent-cyan); }
.browser-row .br-size { font-size: 10px; color: var(--ink-4); flex: none; }

.browser-truncated {
  padding: 10px; text-align: center;
  color: var(--ink-4); font-size: 11px; font-style: italic;
}

.browser-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  background: var(--bg-2);
  border-top: 1px solid var(--border-2);
}
.browser-foot .picked-list {
  flex: 1; font-size: 11px;
  color: var(--ink-3); font-family: ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* primary mini button */
.mini.primary {
  background: rgba(125,211,252,0.12);
  border-color: rgba(125,211,252,0.35);
  color: var(--accent-cyan);
}

/* per-attachment remove (×) next to attached file rows */
.mem-file .rm {
  font-size: 12px; color: var(--ink-4);
  cursor: pointer; padding: 0 4px;
}
.mem-file .rm:hover { color: #f87171; }

/* clickable file rows + agent names */
.mem-file:hover { background: rgba(125,211,252,0.06); border-radius: 3px; }
.agent-item .name { cursor: pointer; }
.agent-item .name:hover .open-hint { opacity: 1; }
.agent-item .open-hint {
  opacity: 0; font-size: 9px; color: var(--ink-4); margin-left: 4px;
  transition: opacity 0.12s;
}

/* ───── memory list ───── */
.memory-list { display: flex; flex-direction: column; gap: 8px; }
.mem-group {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  padding: 8px 10px;
}
.mem-group .gh {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 5px;
}
.mem-group .gh .gh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-group .gh .gh-actions { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.mem-group .gh .gh-btn {
  background: transparent; border: 1px solid var(--border-2); color: var(--ink-3);
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 1px 5px; border-radius: 4px; cursor: pointer;
}
.mem-group .gh .gh-btn:hover { color: var(--ink-1); border-color: var(--border-3); background: var(--bg-3); }
.mem-group .gh .cnt { color: var(--ink-4); }

/* Add-files button moved to the top of the Memory rail */
.mem-top { margin: 2px 0 8px; }
.mem-file {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0; font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--ink-2); cursor: pointer;
}
.mem-file .ck {
  width: 10px; height: 10px; border-radius: 2px;
  border: 1px solid var(--border-3); background: var(--bg-0);
  flex: none;
}
.mem-file.on .ck { background: var(--accent-green); border-color: var(--accent-green); }
.mem-file .nm {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mem-file .sz { color: var(--ink-4); font-size: 9px; }
.mem-file.off { opacity: 0.5; }

.mem-foot {
  margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border-1);
  display: flex; align-items: center; gap: 6px;
}
.mini {
  font-size: 10px; padding: 3px 8px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  color: var(--ink-2); border-radius: 4px;
}
.mem-meta {
  margin-left: auto; font-size: 10px;
  color: var(--ink-4); font-family: ui-monospace, monospace;
}

/* ── Deep Research layout ────────────────────────────────────── */
.research-center { display: flex; flex-direction: column; gap: 0; padding: 0; }
.research-center > .stage { padding: 16px 20px 0; }
.research-center > .stage:last-child { padding-bottom: 20px; }
.research-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 14px 20px 10px; background: var(--bg-1); border-bottom: 1px solid var(--border-2);
  position: sticky; top: 0; z-index: 35;
}
.research-header-main { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.research-company-select {
  width: 100%; max-width: 420px; padding: 8px 10px; font-size: 13px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 7px; color: var(--ink-1);
}
.research-header-actions { display: flex; gap: 8px; flex-shrink: 0; padding-bottom: 2px; }

.dr-domain-refresh {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(52, 211, 153, .08); border-bottom: 1px solid var(--border-2);
}
.dr-domain-refresh-label { font-size: 12.5px; color: var(--ink-2); flex: 1; min-width: 200px; }
.dr-domain-refresh-label strong { color: var(--ink-0); }
.dr-domain-refresh-status { font-size: 11.5px; color: var(--ink-3); }

.research-stepper {
  position: sticky; top: 62px; z-index: 34;
  justify-content: center; flex-wrap: wrap;
  padding: 10px 20px; background: var(--bg-1);
  border-bottom: 1px solid var(--border-2);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.stepper-caption {
  position: sticky; top: 100px; z-index: 33;
  margin: 0; padding: 6px 20px 10px;
  text-align: center; font-size: 12px; color: var(--ink-3);
  background: var(--bg-1); border-bottom: 1px solid var(--border-2);
}
.stepper-caption:empty { display: none; }

/* Threads left rail */
.threads-rail .new-thread-btn {
  width: 100%; padding: 8px 10px; font-size: 12px; font-weight: 600;
  background: var(--bg-2); border: 1px dashed var(--border-3); border-radius: 7px;
  color: var(--accent-cyan); cursor: pointer;
}
.threads-rail .new-thread-btn:hover { border-color: var(--accent-cyan); background: rgba(125,211,252,.06); }
.threads-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.thread-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer;
  background: var(--bg-2);
}
.thread-item:hover { border-color: var(--border-2); }
.thread-item.active { border-color: rgba(125,211,252,.45); background: rgba(125,211,252,.08); }
.thread-item-title {
  flex: 1; font-size: 12px; color: var(--ink-1); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.thread-item-del {
  flex: 0 0 auto; font-size: 14px; color: var(--ink-4); padding: 0 4px; line-height: 1;
  background: transparent; border: none; cursor: pointer;
}
.thread-item-del:hover { color: #f87171; }
.rail.collapsed .threads-list, .rail.collapsed .new-thread-btn { display: none; }

/* Agent composition section */
.compose-section {
  margin: 16px 20px; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 10px;
}
.compose-section-head { margin-bottom: 12px; }
.compose-section-head h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-1); }
.compose-section-hint { margin: 0; font-size: 11px; color: var(--ink-3); line-height: 1.4; }
.compose-roster-label {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-2);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}
.compose-agents { margin-top: 8px; }

.compose-picked {
  min-height: 32px; margin-bottom: 10px; padding: 8px 10px;
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 8px;
}
.compose-picked-empty { font-size: 11px; color: var(--ink-4); font-style: italic; }
.compose-picked-row { display: flex; flex-wrap: wrap; gap: 6px; }
.compose-picked-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 6px;
  border-radius: 20px; border: 1px solid rgba(125,211,252,.3);
  background: rgba(125,211,252,.08); color: var(--ink-1); font-size: 11px; cursor: pointer;
}
.compose-picked-chip .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--agent-color, #888);
}
.compose-picked-chip .rm { color: var(--ink-4); font-size: 13px; line-height: 1; }
.compose-picked-chip:hover { border-color: #f87171; background: rgba(248,113,113,.08); }

.compose-agent-toolbar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
}
.compose-agent-search {
  flex: 1; padding: 8px 10px;
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 7px;
  color: var(--ink-1); font-size: 12px; outline: none;
}
.compose-agent-search:focus { border-color: var(--accent-cyan); }
.compose-back-btn {
  flex-shrink: 0; padding: 7px 10px; font-size: 11px; white-space: nowrap;
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 6px;
  color: var(--accent-cyan); cursor: pointer;
}
.compose-back-btn:hover { border-color: var(--accent-cyan); }

/* Discipline tile grid — level 1 */
.compose-discipline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
  max-height: 280px; overflow-y: auto; padding: 2px;
}
.compose-disc-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 10px 10px 8px; min-height: 72px; text-align: left;
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 9px;
  cursor: pointer; overflow: hidden; transition: border-color .15s, transform .12s;
}
.compose-disc-tile:hover { border-color: var(--disc-color, var(--accent-cyan)); transform: translateY(-1px); }
.compose-disc-tile.has-picked { border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.05); }
.compose-disc-tile .cd-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--disc-color, #888);
}
.compose-disc-tile .cd-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  color: var(--disc-color, #888); margin-top: 2px;
}
.compose-disc-tile .cd-name {
  font-size: 12px; font-weight: 600; color: var(--ink-1); line-height: 1.2;
}
.compose-disc-tile .cd-meta {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: auto;
}
.compose-disc-tile .cd-count {
  font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace;
}
.compose-disc-tile .cd-picked {
  font-size: 9px; color: var(--accent-green); font-weight: 600;
}

/* Agent card grid — level 2 / search */
.compose-agent-grid { display: block; }
.compose-grid-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 8px; padding: 0 2px;
}
.compose-grid-title { font-size: 12px; font-weight: 600; color: var(--ink-1); }
.compose-grid-count { font-size: 10px; color: var(--ink-4); font-family: ui-monospace, monospace; }
.compose-agent-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  max-height: 280px; overflow-y: auto; padding: 2px;
}
.compose-agent-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 10px 8px; min-height: 68px; text-align: left;
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 9px;
  border-left: 3px solid var(--agent-color, #888);
  cursor: pointer; position: relative; transition: border-color .15s, box-shadow .15s;
}
.compose-agent-card:hover { border-color: var(--agent-color, var(--accent-cyan)); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.compose-agent-card.on {
  border-color: var(--accent-green); background: rgba(52,211,153,.07);
  box-shadow: 0 0 0 1px rgba(52,211,153,.25);
}
.compose-agent-card.unavailable { opacity: .45; }
.compose-agent-card .cac-check {
  position: absolute; top: 6px; right: 6px; width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent-green);
  border: 1px solid var(--border-3); border-radius: 4px; background: var(--bg-2);
}
.compose-agent-card.on .cac-check { background: var(--accent-green); color: #06281c; border-color: var(--accent-green); }
.compose-agent-card .cac-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .05em; color: var(--agent-color, #888);
}
.compose-agent-card .cac-name { font-size: 11.5px; font-weight: 600; color: var(--ink-1); line-height: 1.25; word-break: break-word; }
.compose-agent-card .cac-line {
  font-size: 10px; color: var(--ink-3); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.compose-empty {
  padding: 24px; text-align: center; font-size: 12px; color: var(--ink-4); font-style: italic;
}

/* Problem documents */
.problem-docs { display: flex; flex-direction: column; gap: 8px; }
.problem-docs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.problem-attachments { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.problem-attachments-empty { font-size: 11px; color: var(--ink-4); font-style: italic; }
.problem-doc-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 8px; font-size: 11px; border-radius: 5px;
  background: rgba(125,211,252,.08); border: 1px solid rgba(125,211,252,.25); color: var(--ink-2);
}
.problem-doc-chip.on { border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.08); }
.problem-doc-chip .doc-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; cursor: pointer;
}
.problem-doc-chip .doc-name:hover { color: var(--accent-cyan); }
.problem-doc-chip .doc-rm { color: var(--ink-4); cursor: pointer; padding: 0 2px; }
.problem-doc-chip .doc-rm:hover { color: #f87171; }

/* ── Stepper ─────────────────────────────────────────────────── */
.stepper { display: flex; gap: 4px; }
.stepper .step { display: flex; align-items: center; gap: 6px; background: transparent;
  border: 1px solid transparent; color: var(--ink-3); font-size: 11px; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; }
.stepper .step:hover { color: var(--ink-1); }
.stepper .step .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-3); }
.stepper .step.available { color: var(--ink-2); }
.stepper .step.done .dot { background: var(--accent-green); }
.stepper .step.active { background: var(--bg-2); border-color: var(--border-2); color: var(--ink-0); }

/* ── Stage sections ──────────────────────────────────────────── */
.stage { border-bottom: 1px solid var(--border-2); }
.stage-head { display: flex; align-items: center; gap: 8px; padding: 8px 4px; cursor: pointer;
  user-select: none; }
.stage-head .caret { transition: transform .12s; color: var(--ink-3); font-size: 11px; }
.stage.collapsed .stage-head .caret { transform: rotate(-90deg); }
.stage-title { font-size: 12px; font-weight: 600; color: var(--ink-1); letter-spacing: .02em; }
.stage.collapsed .stage-body { display: none; }

/* ── Rail collapse ───────────────────────────────────────────── */
.rail-collapse { background: transparent; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 12px; margin-left: auto; }
.rail.collapsed .rail-collapse { transform: rotate(-90deg); }
.rail.collapsed .agent-list, .rail.collapsed .memory-list, .rail.collapsed .mem-foot,
.rail.collapsed #agent-search, .rail.collapsed .hint { display: none; }

/* ── Global topbar nav ───────────────────────────────────────── */
.global-nav {
  display: flex; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0;
}
.global-nav-link {
  color: var(--ink-4); font-size: 10px; text-decoration: none;
  padding: 4px 9px; border-radius: 5px; white-space: nowrap;
}
.global-nav-link:hover { color: var(--ink-2); background: var(--bg-2); }
.global-nav-link.on { color: var(--ink-0); background: var(--bg-2); }
.global-nav-group {
  display: flex; align-items: center; gap: 2px;
}
.global-nav-group-label {
  color: var(--ink-4); font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 4px 4px 8px; white-space: nowrap; user-select: none;
}

/* legacy alias */
.about-link {
  color: var(--ink-4); font-size: 10px; text-decoration: underline;
  padding: 3px 8px; cursor: pointer;
}
.about-link:hover { color: var(--ink-2); }
.threads-menu { position: relative; display: flex; align-items: center; gap: 8px; margin-left: 16px; }
.threads-btn { background: var(--bg-2); border: 1px solid var(--border-2); color: var(--ink-1);
  font-size: 11px; padding: 3px 8px; border-radius: 5px; cursor: pointer; }
.thread-title { font-size: 11px; color: var(--ink-3); max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.threads-dropdown { position: absolute; top: 28px; left: 0; z-index: 60; min-width: 240px;
  background: var(--bg-1); border: 1px solid var(--border-2); border-radius: 6px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.threads-dropdown .trow { display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  border-radius: 4px; cursor: pointer; font-size: 11px; color: var(--ink-2); }
.threads-dropdown .trow:hover { background: var(--bg-2); }
.threads-dropdown .trow .tdel { margin-left: auto; color: var(--ink-4); padding: 0 4px; }
.threads-dropdown .trow .tdel:hover { color: #f87171; }

/* ============================================================================
 * Agent Composition Map (CompositionMap module) — Direction 3 "Roster + Routing"
 * All classes are cm-prefixed; every rule is scoped under #compmap-host so it
 * cannot leak into the app's existing .stage/.card/.panel/.toolbar/etc.
 * Tokens (--bg-*, --ink-*, --accent*, --border-*) are inherited from :root above.
 * ==========================================================================*/

/* ---------- panel shell ---------- */
#compmap-host { display: block; }
#compmap-host .cm-panel {
  background: var(--bg-1); border: 1px solid var(--border-2);
  border-radius: 8px; overflow: hidden; width: 100%;
  font-size: 12px; line-height: 1.4; color: var(--ink-1);
}
#compmap-host .cm-panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; user-select: none;
  background: var(--bg-2); border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
#compmap-host .cm-panel.cm-open .cm-panel-header { border-bottom-color: var(--border-2); }
#compmap-host .cm-panel-header:hover { background: var(--doc-wash); }
#compmap-host .cm-chevron {
  width: 14px; height: 14px; flex: 0 0 auto; color: var(--ink-3);
  transition: transform .2s ease;
}
#compmap-host .cm-panel.cm-open .cm-chevron { transform: rotate(90deg); }
#compmap-host .cm-panel-title { font-size: 12px; font-weight: 600; color: var(--ink-1); }
#compmap-host .cm-panel-title .cm-kbd { color: var(--ink-4); font-weight: 400; font-size: 10.5px; margin-left: 6px; }

/* collapsed glance summary (in header) */
#compmap-host .cm-glance {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--ink-2); white-space: nowrap;
}
#compmap-host .cm-panel.cm-open .cm-glance { display: none; }
#compmap-host .cm-gdots { display: inline-flex; gap: 3px; align-items: center; }
#compmap-host .cm-gdots i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
#compmap-host .cm-gsep { color: var(--ink-4); }
#compmap-host .cm-gtag { color: var(--ink-3); }

#compmap-host .cm-panel-body { display: none; }
#compmap-host .cm-panel.cm-open .cm-panel-body { display: block; }

/* ---------- toolbar: mode toggle + summary ---------- */
#compmap-host .cm-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-2);
  background: var(--bg-1);
}
#compmap-host .cm-seg {
  display: inline-flex; background: var(--bg-3); border: 1px solid var(--border-3);
  border-radius: 6px; padding: 2px; gap: 2px;
}
#compmap-host .cm-seg button {
  appearance: none; border: 0; background: transparent; color: var(--ink-3);
  font-family: inherit; font-size: 11px; font-weight: 600; padding: 4px 12px;
  border-radius: 4px; cursor: pointer; transition: all .12s; letter-spacing: .02em;
}
#compmap-host .cm-seg button.cm-active { background: var(--accent); color: #1a0c06; }
#compmap-host .cm-seg button:not(.cm-active):hover { color: var(--ink-1); }
#compmap-host .cm-summary-line {
  font-size: 11px; color: var(--ink-3); margin-left: auto; white-space: nowrap;
}
#compmap-host .cm-summary-line b { color: var(--ink-1); font-weight: 600; }
#compmap-host .cm-hint-action { color: var(--accent-cyan); cursor: pointer; text-decoration: none; }
#compmap-host .cm-hint-action:hover { text-decoration: underline; }

/* ---------- wire-mode banner ---------- */
#compmap-host .cm-banner {
  display: none; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 11px;
  background: rgba(125, 211, 252, .07); border-bottom: 1px solid var(--border-2);
  color: var(--ink-2);
}
#compmap-host .cm-panel.cm-mode-wire .cm-banner { display: flex; }
#compmap-host .cm-pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent-cyan);
  box-shadow: 0 0 0 0 rgba(125, 211, 252, .5); animation: cmPulse 2s infinite; flex: 0 0 auto;
}
@keyframes cmPulse {
  0%   { box-shadow: 0 0 0 0 rgba(125, 211, 252, .5); }
  70%  { box-shadow: 0 0 0 6px rgba(125, 211, 252, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 211, 252, 0); }
}
#compmap-host .cm-banner b { color: var(--ink-1); font-weight: 600; }
#compmap-host .cm-wire-step {
  margin-left: auto; color: var(--ink-3); font-size: 10.5px; white-space: nowrap;
}
#compmap-host .cm-wire-step b { color: var(--accent-cyan); }

/* ---------- stage (scroll container) ---------- */
#compmap-host .cm-stage-wrap {
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .025) 1px, transparent 0) 0 0/22px 22px,
    var(--bg-1);
  max-height: 360px;
}
#compmap-host .cm-stage-scroll { overflow-x: auto; overflow-y: hidden; padding: 0; }
#compmap-host .cm-stage {
  position: relative; min-width: 600px; padding: 74px 18px 22px;
  display: flex; align-items: center; gap: 14px;
}
#compmap-host .cm-arc-layer {
  position: absolute; top: 0; left: 0; height: 74px; pointer-events: none;
  overflow: visible; z-index: 3;
}

/* ---------- pipeline nodes (Problem / Mix / Refine / Render) ---------- */
#compmap-host .cm-pnode {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 64px; transition: opacity .2s;
}
#compmap-host .cm-pchip {
  padding: 9px 12px; border-radius: 7px; background: var(--bg-3);
  border: 1px solid var(--border-3); font-size: 11px; font-weight: 600;
  color: var(--ink-1); white-space: nowrap; text-align: center; min-height: 54px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px;
}
#compmap-host .cm-pchip .cm-pn-sub { font-size: 9px; font-weight: 500; color: var(--ink-4); }
#compmap-host .cm-pnode.cm-problem .cm-pchip { border-color: #3a4456; }
#compmap-host .cm-panel.cm-mode-wire .cm-pnode { opacity: .32; }

#compmap-host .cm-flow-arrow { flex: 0 0 auto; color: var(--ink-4); font-size: 13px; transition: opacity .2s; }
#compmap-host .cm-panel.cm-mode-wire .cm-flow-arrow { opacity: .25; }

/* ---------- agent roster band ---------- */
#compmap-host .cm-roster {
  flex: 0 0 auto; display: flex; align-items: stretch; gap: 10px;
  padding: 4px; position: relative;
}
#compmap-host .cm-roster-label {
  position: absolute; top: -18px; left: 6px; font-size: 9px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}

/* ---------- agent card ---------- */
#compmap-host .cm-card {
  position: relative; flex: 0 0 auto; width: 128px;
  background: var(--bg-2); border: 1px solid var(--border-3);
  border-radius: 8px; padding: 9px 9px 8px; cursor: default;
  transition: transform .12s, box-shadow .12s, border-color .12s, opacity .2s;
  border-left: 3px solid var(--cm-color, #888);
}
#compmap-host .cm-card .cm-cn {
  font-size: 11px; font-weight: 600; color: var(--ink-0);
  line-height: 1.25; margin-bottom: 3px; word-break: break-word; overflow-wrap: anywhere;
}
#compmap-host .cm-card .cm-cmeta { display: flex; align-items: center; gap: 6px; }
#compmap-host .cm-card .cm-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .05em;
  padding: 1px 5px; border-radius: 4px; color: #0c0f14;
  background: var(--cm-color, #888); flex: 0 0 auto;
}
#compmap-host .cm-card .cm-disc { font-size: 9.5px; color: var(--ink-3); word-break: break-word; }

/* remove × */
#compmap-host .cm-card .cm-rm {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--bg-3); border: 1px solid var(--border-3);
  color: var(--ink-2); font-size: 12px; line-height: 1; display: none;
  align-items: center; justify-content: center; cursor: pointer; z-index: 4; padding: 0;
}
#compmap-host .cm-card:hover .cm-rm { display: flex; }
#compmap-host .cm-card .cm-rm:hover { background: #3a1f1f; border-color: #7a3a3a; color: #ffb4b4; }
#compmap-host .cm-panel:not(.cm-mode-wire) .cm-card:hover {
  transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

/* ---------- wire-mode card affordances ---------- */
#compmap-host .cm-panel.cm-mode-wire .cm-card { cursor: pointer; border-color: var(--border-2); }
#compmap-host .cm-panel.cm-mode-wire .cm-card:hover { border-color: var(--accent-cyan); }
#compmap-host .cm-panel.cm-mode-wire .cm-card:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }
#compmap-host .cm-panel.cm-mode-wire .cm-card.cm-src-selected {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 0 18px rgba(125, 211, 252, .25);
}
#compmap-host .cm-panel.cm-mode-wire .cm-card.cm-src-selected::after {
  content: "source"; position: absolute; top: -9px; left: 6px;
  font-size: 8px; font-weight: 700; letter-spacing: .06em; color: var(--accent-cyan);
  background: var(--bg-1); padding: 0 4px; border-radius: 3px; text-transform: uppercase;
}
#compmap-host .cm-panel.cm-mode-wire .cm-card.cm-cand-target { animation: cmCand 1.6s ease-in-out infinite; }
@keyframes cmCand { 0%, 100% { border-color: var(--border-3); } 50% { border-color: var(--accent-green); } }

/* ---------- + add card ---------- */
#compmap-host .cm-add {
  flex: 0 0 auto; width: 52px; align-self: stretch; min-height: 54px;
  border: 1.5px dashed var(--border-3); border-radius: 8px; background: transparent;
  color: var(--ink-3); font-size: 20px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all .12s; font-family: inherit;
}
#compmap-host .cm-add:hover { border-color: var(--accent); color: var(--accent); background: rgba(255, 106, 61, .05); }
#compmap-host .cm-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#compmap-host .cm-panel.cm-mode-wire .cm-add { opacity: .25; pointer-events: none; }

/* ---------- empty state ---------- */
#compmap-host .cm-empty {
  flex: 0 0 auto; width: 340px; min-height: 78px; border: 1.5px dashed var(--border-3);
  border-radius: 8px; display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start; justify-content: center; padding: 14px 16px;
  color: var(--ink-3); font-size: 11px;
}
#compmap-host .cm-empty-text { line-height: 1.45; }
#compmap-host .cm-suggest {
  appearance: none; border: 0; background: var(--accent); color: #1a0c06;
  font-family: inherit; font-size: 11px; font-weight: 700; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; transition: filter .12s;
}
#compmap-host .cm-suggest:hover { filter: brightness(1.08); }
#compmap-host .cm-suggest:disabled { opacity: .6; cursor: default; }

/* ---------- picker popover ---------- */
#compmap-host .cm-picker {
  position: absolute; z-index: 30; width: 280px; background: var(--bg-2);
  border: 1px solid var(--border-3); border-radius: 10px; padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5); display: none;
}
#compmap-host .cm-picker.cm-open { display: block; }
#compmap-host .cm-picker h4 {
  margin: 2px 4px 8px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
#compmap-host .cm-pk-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 6px;
  cursor: pointer; transition: background .1s;
}
#compmap-host .cm-pk-item:hover { background: var(--bg-3); }
#compmap-host .cm-pk-item .cm-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
#compmap-host .cm-pk-item .cm-pk-name { font-size: 11.5px; color: var(--ink-1); font-weight: 600; flex: 1; word-break: break-word; }
#compmap-host .cm-pk-item .cm-pk-tag {
  font-size: 9px; font-weight: 700; color: var(--ink-3); border: 1px solid var(--border-3);
  padding: 1px 5px; border-radius: 4px; flex: 0 0 auto;
}
#compmap-host .cm-pk-empty { padding: 14px; text-align: center; color: var(--ink-4); font-size: 11px; }

/* ---------- arc edge styling (future / not-live: dashed + reduced opacity) ---------- */
#compmap-host .cm-arc-path {
  fill: none; stroke-width: 1.6; stroke-dasharray: 5 4; opacity: .55;
  transition: opacity .15s, stroke-width .15s;
}
#compmap-host .cm-arc-hit { fill: none; stroke: transparent; stroke-width: 14px; pointer-events: stroke; cursor: pointer; }
#compmap-host .cm-arc-g:hover .cm-arc-path { opacity: .95; stroke-width: 2.1; }
#compmap-host .cm-arc-label {
  font-size: 9px; fill: var(--ink-2); paint-order: stroke; stroke: var(--bg-0);
  stroke-width: 3px; stroke-linejoin: round; font-weight: 600;
}
#compmap-host .cm-arc-kind { pointer-events: all; cursor: pointer; }
#compmap-host .cm-arc-kind[data-cm-kind="revise"] { fill: var(--accent); }
#compmap-host .cm-arc-kind:hover { fill: var(--ink-0); }
#compmap-host .cm-arc-del { pointer-events: all; cursor: pointer; opacity: 0; transition: opacity .12s; }
#compmap-host .cm-arc-g:hover .cm-arc-del { opacity: 1; }
#compmap-host .cm-arc-del circle { fill: var(--bg-3); stroke: var(--border-3); }
#compmap-host .cm-arc-del:hover circle { fill: #3a1f1f; stroke: #7a3a3a; }
#compmap-host .cm-arc-del text { fill: var(--ink-2); font-size: 11px; font-weight: 700; }
#compmap-host .cm-arc-del:hover text { fill: #ffb4b4; }

/* ---------- toast ---------- */
#compmap-host .cm-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--border-3); color: var(--ink-1);
  padding: 8px 14px; border-radius: 8px; font-size: 11px; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
#compmap-host .cm-toast.cm-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================================
 * Agent Composition Map — simple Parallel / Sequence model additions
 * Appended; every rule scoped under #compmap-host. Reuses existing cm- chrome.
 * (Legacy arc/wire/banner rules above are now unused but harmless.)
 * ==========================================================================*/

/* Parallel: cards wrap to multiple rows */
#compmap-host .cm-panel.cm-mode-parallel .cm-roster {
  flex-wrap: wrap; align-content: flex-start; max-width: 520px;
}
/* Sequence: keep cards + arrows on one line; the stage-scroll handles overflow */
#compmap-host .cm-panel.cm-mode-sequence .cm-roster {
  flex-wrap: nowrap; align-items: center;
}

/* glance: sequence ids (monospace, like the chain ids) */
#compmap-host .cm-gid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; color: var(--ink-2);
}

/* sequence separator arrow between cards */
#compmap-host .cm-seq-arrow {
  flex: 0 0 auto; color: var(--ink-4); font-size: 13px; align-self: center;
  user-select: none;
}

/* sequence ordinal badge on each card */
#compmap-host .cm-seq-card { padding-top: 14px; }
#compmap-host .cm-seq-num {
  position: absolute; top: -8px; left: -8px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--cm-color, #888); color: #0c0f14;
  font-size: 10px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4); z-index: 5;
}

/* drag affordances (sequence) */
#compmap-host .cm-seq-card { cursor: grab; }
#compmap-host .cm-seq-card:active { cursor: grabbing; }
#compmap-host .cm-seq-card.cm-dragging { opacity: .45; }
#compmap-host .cm-seq-card.cm-drop-before { box-shadow: -3px 0 0 0 var(--accent-cyan); }
#compmap-host .cm-seq-card.cm-drop-after  { box-shadow:  3px 0 0 0 var(--accent-cyan); }
#compmap-host .cm-seq-card:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }

/* subtle "run together" rail to the left of parallel cards */
#compmap-host .cm-panel.cm-mode-parallel .cm-roster::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px;
  border-radius: 2px; background: var(--border-3); opacity: .6;
}

/* ── New company profile modal ───────────────────────────────── */
.newprofile-btn { width: 100%; margin: 4px 0 8px; }
.newprofile-panel { max-width: 560px; }
.newprofile-body { display: block; padding: 14px 16px; overflow-y: auto; }
.np-input {
  width: 100%; padding: 7px 9px; margin-top: 4px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 5px;
  color: var(--ink-1); font-size: 12px; outline: none;
}
.np-input:focus { border-color: var(--border-3); }
.np-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.np-section-label { font-size: 11px; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; }
.np-md {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; line-height: 1.5; color: var(--ink-1);
  background: var(--bg-0); border: 1px solid var(--border-2); border-radius: 6px;
  padding: 10px 12px; max-height: 360px; overflow-y: auto;
}
.np-phases { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.np-phase {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px;
  color: var(--ink-3); padding: 4px 6px; border-radius: 5px;
}
.np-phase .np-phase-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-3); flex: none; }
.np-phase .np-phase-name { flex: 1; }
.np-phase .np-phase-st { font-family: ui-monospace, monospace; }
.np-phase.np-start { color: var(--ink-1); background: var(--bg-2); }
.np-phase.np-start .np-phase-dot { background: var(--accent-cyan); }
.np-phase.np-done { color: var(--ink-2); }
.np-phase.np-done .np-phase-dot { background: var(--accent-green); }
.np-phase.np-error .np-phase-dot { background: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════
   CANONICAL BASE COMPONENTS  —  see docs/DESIGN-STANDARD.md
   Page-agnostic building blocks for NEW pages. Reuse these instead of
   inventing a page-prefixed clone (ctx-btn, scn-btn, admin-btn, set-btn…).
   Purely additive: existing prefixed classes are left untouched.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Button: .btn + variants ── */
.btn {
  padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--border-3); border-radius: var(--radius-md);
  color: var(--ink-1); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-4); color: var(--ink-0); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-accent { background: var(--accent-green); border-color: var(--accent-green); color: #06281c; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.08); color: #06281c; }
.btn-ghost { background: transparent; border-color: var(--border-3); color: var(--accent-cyan); }
.btn-danger { border-color: var(--danger-line); color: var(--danger); background: var(--danger-weak); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-mid); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { padding: 11px 20px; font-size: var(--fs-base); font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 9px; color: var(--ink-3); }
.btn-icon:hover { color: var(--ink-0); border-color: var(--border-3); }
.btn-icon svg { display: block; }

/* ── Card / pane ── */
.card { background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 18px 20px; }
.pane { display: flex; flex-direction: column; gap: var(--space-4); }
.pane-title { margin: 0 0 6px; font-size: var(--fs-lg); font-weight: 600; color: var(--ink-0); }
.pane-desc { margin: 0; font-size: var(--fs-base); color: var(--ink-3); line-height: 1.5; max-width: 60ch; }

/* ── Badge / pill ── */
.badge { display: inline-block; font-size: var(--fs-2xs); font-weight: 700; background: var(--accent-amber); color: #1a1400; border-radius: var(--radius-lg); padding: 1px 7px; min-width: 18px; text-align: center; }
.pill { font-size: var(--fs-xs); padding: 4px 10px; border-radius: var(--radius-pill); background: var(--bg-3); border: 1px solid var(--border-3); color: var(--ink-2); }

/* ── Empty state ── */
.empty { color: var(--ink-4); font-size: var(--fs-sm); text-align: center; padding: 32px 16px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-card { position: relative; width: min(520px, 100%); max-height: min(90vh, 720px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--border-3); border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: 0 24px 64px rgba(0, 0, 0, .45); scrollbar-gutter: stable; }
.modal-sm .modal-card, .modal-card.modal-sm { width: min(420px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-title { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--ink-0); }
.modal-close { background: transparent; border: none; color: var(--ink-4); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--ink-1); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
