:root { color-scheme: light dark; }
body { font: 15px/1.5 system-ui, sans-serif; max-width: 1100px; margin: 2rem auto; padding: 0 1.25rem; }
/* The Build board needs room for its columns — give it (almost) the full viewport
   so all pipeline stages are visible without horizontal scrolling. */
body[data-page="flow"] { max-width: min(1600px, 96vw); }
h1 { margin-bottom: 0.25rem; }
h2 { margin-top: 2rem; font-size: 1rem; }
nav { display: block; margin: 0.5rem 0 1.25rem; }
nav a { text-decoration: none; color: inherit; }
.nav-primary { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: 1.05rem; font-weight: 700; }
.nav-primary a { opacity: 0.65; padding-bottom: 2px; }
.nav-primary a.active { opacity: 1; border-bottom: 2px solid currentColor; }
.nav-secondary { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; font-size: 0.82rem; }
.nav-secondary a { opacity: 0.6; font-weight: 500; }
.nav-secondary a:hover { opacity: 0.9; }
.nav-secondary .logout { margin-left: auto; }

/* Intent capture bar (Overview) */
.capture { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.5rem 0 1.25rem; }
.capture #cap-prompt { flex: 1 1 320px; min-width: 200px; padding: 0.5rem 0.7rem; font: inherit; border: 1px solid #8884; border-radius: 6px; background: Canvas; color: inherit; }
.capture select { padding: 0.5rem; font: inherit; border: 1px solid #8884; border-radius: 6px; background: Canvas; color: inherit; }
.capture button { font: inherit; font-weight: 600; padding: 0.5rem 0.9rem; border-radius: 6px; border: 1px solid #1f6feb; background: #1f6feb; color: #fff; cursor: pointer; }
.capture button.ghost { background: transparent; color: inherit; border-color: #8884; font-weight: 500; }
.capture #cap-msg { flex-basis: 100%; }
.meta { color: #888; font-size: 0.85rem; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #ddd3; vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: #888; }
.pill { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.pill[data-status="ok"], .pill[data-status="done"] { background: #1a7f37; color: #fff; }
.pill[data-status="warn"], .pill[data-status="pending"], .pill[data-status="claimed"], .pill[data-status="running"] { background: #bf8700; color: #fff; }
.pill[data-status="down"], .pill[data-status="error"] { background: #cf222e; color: #fff; }
.pill[data-status="?"] { background: #6e7781; color: #fff; }
.state { color: #888; padding: 1rem 0; }
button { font: inherit; padding: 0.3rem 0.8rem; cursor: pointer; }
form { display: grid; gap: 0.5rem; }
input, textarea, select { font: inherit; padding: 0.4rem; box-sizing: border-box; }
textarea { min-height: 4rem; resize: vertical; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.muted { color: #888; font-size: 0.85rem; }
.dash { color: #aaa; }
code { font-size: 0.85em; }
ul.links { line-height: 2; }
/* product board */
.board { display: grid; gap: 0.6rem; align-items: start; margin-top: 0.5rem; }
.board-col { background: #8881; border-radius: 8px; padding: 0.5rem; min-height: 3rem; }
.board-col h3 { margin: 0.2rem 0.2rem 0.5rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #888; }
.board-col h3 .count { color: #aaa; font-weight: 400; }
.idea-card { background: #8882; border: 1px solid #8884; border-radius: 6px; padding: 0.4rem 0.5rem; margin-bottom: 0.4rem; }
.idea-card .t { font-weight: 600; font-size: 0.9rem; }
.idea-card .sub { color: #888; font-size: 0.75rem; margin-top: 0.2rem; }
@media (max-width: 720px) { .board { grid-template-columns: 1fr 1fr !important; } }
/* run detail */
tr.rowlink:hover { background: #8881; }
pre { white-space: pre-wrap; word-break: break-word; background: #8881; padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.82rem; overflow-x: auto; }
.banner { font-size: 0.75rem; color: #888; margin: 0.3rem 0 0.5rem; font-family: ui-monospace, monospace; }
.transcript { display: flex; flex-direction: column; gap: 0.5rem; }
/* each turn is a collapsible <details> card with a role-colored left accent */
.turn { border: 1px solid #8883; border-left-width: 3px; border-radius: 6px; overflow: hidden; }
.turn > summary { cursor: pointer; padding: 0.45rem 0.7rem; display: flex; align-items: baseline; gap: 0.6rem; }
.turn > summary::-webkit-details-marker { display: none; }
.turn > summary::marker { content: ""; }
.turn > summary::after { content: "▸"; margin-left: auto; color: #aaa; font-size: 0.7rem; align-self: center; }
.turn[open] > summary::after { content: "▾"; }
.turn .who { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: #888; white-space: nowrap; }
.turn .teaser { flex: 1; color: #999; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn[open] .teaser { display: none; }
.turn-body { padding: 0 0.7rem 0.6rem; }
.turn-body > :first-child, .turn-body .md > :first-child { margin-top: 0; }
.turn-body > :last-child { margin-bottom: 0; }
/* role colors — assistant gets a friendly green */
.turn-user      { border-left-color: #2f81f7; background: #2f81f70f; }
.turn-assistant { border-left-color: #1f883d; background: #1f883d12; }
.turn-assistant > summary .who { color: #1a7f37; }
.turn-tool      { border-left-color: #bf8700; background: #bf87000d; }
.turn-tool.failed { border-left-color: #cf222e; background: #cf222e12; }
.turn-tool.failed > summary .who { color: #cf222e; }
.t-err { background: #cf222e22; }
.md :is(h3,h4,h5) { margin: 0.4rem 0 0.2rem; }
.md ul, .md ol { margin: 0.2rem 0 0.2rem 1.2rem; }
/* delivery / error summary card (always visible, not collapsible) */
.dcard { border: 1px solid #8883; border-left: 3px solid #818cf8; border-radius: 6px; padding: 0.5rem 0.7rem; margin: 0.5rem 0; }
.dcard.failed { border-left-color: #cf222e; }
.dcard .who { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: #888; margin-bottom: 0.3rem; }
.dcard p:last-child { margin-bottom: 0; }

/* Home "Needs you" decisions inbox */
.attn-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.attn-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.3rem 0 0.6rem; }
.attn-row { display: flex; align-items: center; gap: 0.6rem; border: 1px solid #8883; border-left: 3px solid #6e7781; border-radius: 6px; padding: 0.5rem 0.7rem; }
.attn-row[data-sev="1"] { border-left-color: #cf222e; }
.attn-row[data-sev="2"] { border-left-color: #bf8700; }
.attn-row[data-sev="3"] { border-left-color: #1f6feb; }
.attn-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #6e7781; }
.attn-row[data-sev="1"] .attn-dot { background: #cf222e; }
.attn-row[data-sev="2"] .attn-dot { background: #bf8700; }
.attn-row[data-sev="3"] .attn-dot { background: #1f6feb; }
.attn-body { flex: 1 1 auto; min-width: 0; }
.attn-text { font-size: 0.92rem; }
.attn-meta { color: #888; font-size: 0.78rem; margin-top: 0.1rem; }
.attn-act { flex: 0 0 auto; }
.attn-btn { font: inherit; font-size: 0.82rem; padding: 0.3rem 0.7rem; border: 1px solid #1f6feb; background: #1f6feb; color: #fff; border-radius: 6px; cursor: pointer; }
.attn-btn:disabled { opacity: 0.5; cursor: default; }
.attn-link { font-size: 0.82rem; white-space: nowrap; }
.attn-clear { color: #1a7f37; font-weight: 600; }

/* Flow board (the factory floor) */
.flow-board { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.5rem; align-items: flex-start; }
.fcol { flex: 1 1 0; min-width: 150px; background: #8881; border: 1px solid #8883; border-radius: 8px; }
.fcol-head { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #888; padding: 0.5rem 0.6rem; border-bottom: 1px solid #8883; }
.fcol-count { float: right; background: #8883; border-radius: 999px; padding: 0 0.45rem; font-size: 0.72rem; }
.fcol-body { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.5rem; min-height: 2rem; }
.fcol-empty { color: #8886; text-align: center; margin: 0.3rem 0; }
.fcard { display: block; text-decoration: none; color: inherit; border: 1px solid #8883; border-left: 3px solid #1f6feb; border-radius: 6px; padding: 0.45rem 0.55rem; background: Canvas; }
.fcard:hover { border-color: #1f6feb; }
.fcard.warn { border-left-color: #cf222e; }
.fcard-title { font-size: 0.85rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fcard-meta { font-size: 0.72rem; color: #888; margin-top: 0.2rem; }
.fcard-sub { font-size: 0.7rem; color: #888; margin-top: 0.15rem; }
.raw-logs { margin-top: 1rem; }
.raw-logs summary { cursor: pointer; color: #888; font-size: 0.85rem; }
/* project cockpit */
.att-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.att-dot.s1 { background: #cf222e; } .att-dot.s2 { background: #bf8700; } .att-dot.s3 { background: #888; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 34px; margin: 6px 0; }
.spark .bar { flex: 1; background: #2f81f7; min-height: 2px; border-radius: 1px 1px 0 0; opacity: 0.8; }
/* read-only Operate dashboards: Usage / Governance / Memory + Goals cards */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gbar { background: #8883; border-radius: 999px; height: 8px; overflow: hidden; margin: 3px 0 6px; }
.gbar > span { display: block; height: 100%; background: #1a7f37; }
.gbar > span[data-status="warn"] { background: #bf8700; }
.gbar > span[data-status="error"] { background: #cf222e; }
.lim-win { font-size: 0.85rem; margin: 0.35rem 0; }
.goals { margin-top: 0.5rem; }
.goal-card { border: 1px solid #8883; border-radius: 8px; padding: 0.4rem 0.65rem; margin-bottom: 0.4rem; }
.goal-card > summary { cursor: pointer; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.goal-card > summary .count { color: #888; font-size: 0.78rem; }
.goal-card p { margin: 0.4rem 0 0.1rem; }
/* manager chat (wave 2) */
.chat { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem;
        max-height: 60vh; overflow-y: auto; padding: 0.25rem; }
.msg { padding: 0.5rem 0.75rem; border-radius: 0.6rem; max-width: 90%; white-space: pre-wrap; }
.msg.you { align-self: flex-end; background: #2f81f733; }
.msg.mgr { align-self: flex-start; background: #88888822; }
.msg .who { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: #888; }
/* rendered manager markdown inside a chat bubble */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.4rem 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 0.6rem 0 0.3rem; }
.md ul, .md ol { margin: 0.4rem 0; padding-left: 1.3rem; }
.md li { margin: 0.15rem 0; }
.md pre { background: #8882; padding: 0.5rem 0.6rem; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; }
.md code { background: #8883; padding: 0.05rem 0.3rem; border-radius: 4px; }
.md a { color: #2f81f7; }

/* Work Funnel — Signals page (badges + clusters + triage digest) */
.sig-badge { display: inline-block; font-size: 0.72rem; padding: 0.05rem 0.4rem; border-radius: 4px; background: #8883; color: #aaa; margin-right: 0.2rem; }
.sig-cluster { margin-bottom: 1rem; }
.sig-cluster-head { margin: 0 0 0.4rem; }
.sig-cluster-head .muted { font-size: 0.82rem; }
.sig-digest { border-left: 3px solid #1f6feb; }
.sig-digest .who { font-weight: 600; }
.attn-act .attn-btn.sig-btn { margin-left: 0.25rem; }
