:root {
  --ink: #0f172a;
  --muted: #667085;
  --bg: #f7f3ec;
  --panel: #fffaf2;
  --line: #e6dccd;
  --purple: #6d28d9;
  --purple-dark: #4c1d95;
  --teal: #0f766e;
  --amber: #b45309;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(109, 40, 217, 0.13), transparent 25%),
    radial-gradient(circle at 80% 0%, rgba(20, 184, 166, 0.12), transparent 26%),
    var(--bg);
}
.shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 56px; }

/* ── Hero ─────────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: stretch; margin-bottom: 20px; }
.eyebrow, .kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; color: var(--purple); margin: 0 0 10px; }
h1 { font-size: clamp(40px, 6.5vw, 72px); line-height: .92; letter-spacing: -0.07em; margin: 0; max-width: 870px; }
h2 { font-size: 24px; line-height: 1; letter-spacing: -0.04em; margin: 0; }
.hero-copy { font-size: 18px; max-width: 720px; color: var(--muted); line-height: 1.55; margin: 16px 0 0; }
.hero-card, .panel { background: rgba(255, 250, 242, 0.88); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.hero-card { padding: 24px; display: flex; flex-direction: column; justify-content: flex-end; min-height: 210px; background: linear-gradient(145deg, #0f172a, #2e1065); color: white; }
.hero-card span { color: #c4b5fd; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; }
.hero-card strong { font-size: 30px; line-height: 1; letter-spacing: -0.05em; margin: 8px 0; }
.hero-card p { color: #ddd6fe; line-height: 1.45; margin: 0; }

/* ── Stat rail ────────────────────────────────────────── */
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.score-grid.rail { grid-template-columns: repeat(4, 1fr); margin: 0 0 18px; }
.score-box { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.score-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.score-box strong { font-size: 22px; letter-spacing: -0.03em; }
.alert-ok { color: var(--teal); }
.alert-warn { color: var(--amber); }

/* ── Tabs ─────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.tab { border: 1px solid var(--line); background: rgba(255,250,242,.82); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-weight: 850; }
.tab.active { background: var(--ink); color: white; border-color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Galaxy ───────────────────────────────────────────── */
.galaxy-panel {
  background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 55%, #2e1065 100%);
  border-radius: 28px; border: 1px solid rgba(196,181,253,.18);
  box-shadow: var(--shadow); padding: 6px; overflow: hidden;
}
#galaxy { width: 100%; height: auto; display: block; }
.node { cursor: pointer; }
.node circle.body { transition: transform .15s ease; }
.node:hover circle.body { filter: brightness(1.25); }
.node.selected circle.ring { stroke-width: 3; opacity: 1; }
.node text { pointer-events: none; }
.leaf { opacity: .85; }
.leaf:hover { opacity: 1; }
.edge { fill: none; stroke-linecap: round; }
.edge.flow { stroke-dasharray: 7 9; animation: flow 2.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -64; } }
.spoke { stroke: rgba(255,255,255,.07); }
@keyframes pulse { 0%,100% { opacity:.35; } 50% { opacity:.9; } }
.pulse { animation: pulse 3.2s ease-in-out infinite; }

/* ── Panels / control room ───────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.panel { padding: 24px; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin-bottom: 16px; }
.lower-panel { margin-top: 20px; }
.detail-empty { min-height: 220px; display: grid; place-items: center; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 22px; padding: 20px; }
.copy-block { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 15px; margin: 12px 0; }
.copy-block h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--purple); }
.copy-block p, .copy-block li { color: #344054; line-height: 1.5; margin: 6px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
button { font: inherit; cursor: pointer; }
.primary, .ghost { border: 0; border-radius: 999px; padding: 11px 16px; font-weight: 850; }
.primary { background: var(--purple); color: #fff; }
.ghost { background: #efe7dc; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.footnote { margin-top: 26px; text-align: center; }
a.link { color: var(--purple); font-weight: 800; text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 700; color: #344054; }
.chip.private { border-color: #fcd34d; background: #fffbeb; color: #92400e; }

/* agent cards */
.agents-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.agents-grid.wide { grid-template-columns: repeat(3, 1fr); }
.agent-card { border: 1px solid var(--line); background: white; border-radius: 20px; padding: 15px; display: flex; flex-direction: column; gap: 8px; }
.agent-card:hover { border-color: rgba(109,40,217,.55); }
.agent-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.agent-card strong { font-size: 16.5px; letter-spacing: -0.02em; }
.agent-card p { color: var(--muted); margin: 0; line-height: 1.45; font-size: 13px; }
.agent-actions { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.agent-actions button { border: 0; border-radius: 999px; padding: 8px 12px; font-weight: 800; background: #efe7dc; }
.agent-actions button.primary { background: var(--purple); color: white; }
.provider-badge { font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.provider-badge.openai { background: #0f172a; color: #e2e8f0; }
.provider-badge.anthropic { background: #fdf1e3; color: #b45309; border: 1px solid #f3d9b8; }
.model-tag { font-size: 11px; color: var(--muted); font-weight: 700; }

/* roster */
.roster-section { margin-bottom: 18px; }
.roster-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.roster-dot { width: 12px; height: 12px; border-radius: 50%; }
.roster-head h2 { font-size: 19px; }

/* ── Chat dock ────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; min-height: 460px; }
.chat-messages { flex: 1; overflow-y: auto; max-height: 430px; display: block; }
.chat-messages.live { border: 1px solid var(--line); border-radius: 18px; background: white; padding: 14px; }
.msg { margin: 0 0 10px; display: flex; }
.msg .bubble { max-width: 85%; padding: 10px 13px; border-radius: 16px; line-height: 1.5; font-size: 14px; white-space: pre-wrap; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--ink); color: white; border-bottom-right-radius: 5px; }
.msg.agent .bubble { background: #f4eee3; color: var(--ink); border-bottom-left-radius: 5px; }
.msg.agent .bubble .meta { display: block; margin-top: 7px; font-size: 11px; color: var(--muted); font-weight: 700; }
.msg .bubble.thinking { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); padding: 12px 16px; font: inherit; outline: none; }
.chat-form input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(109, 40, 217, .12); }

/* ── Ledger ───────────────────────────────────────────── */
.cost-line { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 10px 0; }
.cost-line:last-child { border-bottom: 0; }

/* ── To-Do board ──────────────────────────────────────── */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.board-col { background: rgba(255,250,242,.72); border: 1px solid var(--line); border-radius: 22px; padding: 14px; min-height: 220px; }
.board-col > h3 { margin: 0 0 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; }
.board-col > h3 .count { color: var(--ink); }
.task-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.task-top { display: flex; gap: 8px; align-items: flex-start; }
.task-top strong { font-size: 14.5px; letter-spacing: -.01em; line-height: 1.3; }
.prio { font-size: 10px; font-weight: 900; padding: 4px 7px; border-radius: 999px; flex: none; }
.prio.P0 { background: #fee2e2; color: #991b1b; }
.prio.P1 { background: #ede9fe; color: #5b21b6; }
.prio.P2 { background: #d1fae5; color: #065f46; }
.prio.P3 { background: #f1f5f9; color: #475569; }
.task-detail { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mini-chip { font-size: 10.5px; padding: 4px 8px; }
.mini-chip.rev { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; font-weight: 800; }
.task-value { font-size: 12px; color: #344054; margin: 8px 0 0; font-style: italic; }
.task-src { font-size: 10.5px; color: #98a2b3; margin: 8px 0 0; }
.task-actions { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.task-actions button { border: 0; border-radius: 999px; padding: 6px 10px; font-weight: 800; background: #efe7dc; font-size: 12px; }
.task-actions button.adv { background: var(--teal); color: white; }
.task-actions button.route { background: var(--purple); color: white; }
.task-form-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.task-form-row.two { grid-template-columns: 1fr 1fr; }
#taskForm select { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 12px; font: inherit; width: 100%; }
.task-line { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #f1ebe0; }
.task-line:last-child { border-bottom: 0; }
.task-line-title { font-weight: 700; font-size: 13px; flex: 1; }
button.mini { padding: 5px 10px; font-size: 11px; font-weight: 800; border: 0; border-radius: 999px; }
button.warn { background: #fee2e2; color: #991b1b; border: 0; border-radius: 999px; padding: 11px 16px; font-weight: 850; }
#agentForm textarea { margin-top: 10px; }
#agentForm select { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 12px; font: inherit; width: 100%; }

@media (max-width: 980px) {
  .hero, .grid.two { grid-template-columns: 1fr !important; }
  .score-grid.rail { grid-template-columns: repeat(2, 1fr); }
  .agents-grid, .agents-grid.wide { grid-template-columns: 1fr; }
  .hero-card { min-height: 160px; }
  .board { grid-template-columns: 1fr 1fr; }
  .task-form-row { grid-template-columns: 1fr 1fr; }
}
