/*
  King: the AceLM web UI (mockup).
  A browser application, not a terminal: sidebar navigation, pages with tabs,
  tables, cards, a slide-over detail panel, a command palette, and modals.
  Same identity as acelm.ai (paper, ink, felt green, vermilion, ochre) with a dark theme.
*/
@font-face { font-family: "AceLM Serif"; src: url("/fonts/source-serif-display-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "AceLM Serif"; src: url("/fonts/source-serif-display-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "AceLM Sans"; src: url("/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "AceLM Sans"; src: url("/fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "AceLM Sans"; src: url("/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "AceLM Mono"; src: url("/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "AceLM Mono"; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #f5f1e8;          /* page */
  --bg-2: #ece6d8;        /* hover, wells */
  --bg-3: #e2dac8;
  --surface: #fbf8f1;     /* cards, panels */
  --surface-2: #f7f3ea;
  --ink: #16191d;
  --ink-2: #3a3f45;
  --ink-3: #5d636a;
  --rule: #d9d1bf;
  --rule-strong: #b3a98f;
  --felt: #1e5a46;
  --felt-deep: #143f31;
  --felt-tint: #dce8df;
  --red: #b43a1e;
  --red-tint: #f3ddd3;
  --ochre: #8a5a10;
  --ochre-tint: #f1e5c9;
  --blue: #2c5282;
  --blue-tint: #dde6f1;
  --code-bg: #fdfbf6;
  --add-bg: #e3efe6;
  --add-ink: #1e5a46;
  --del-bg: #f6e1da;
  --del-ink: #9a3018;
  --shadow: 0 1px 2px rgba(22, 25, 29, 0.06), 0 4px 16px rgba(22, 25, 29, 0.06);
  --shadow-lg: 0 12px 40px rgba(22, 25, 29, 0.18);
  --count-ink: #fff;
  --font-serif: "AceLM Serif", Georgia, serif;
  --font-sans: "AceLM Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "AceLM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 6px;
  --r-sm: 4px;
  --top: 52px;
  --side: 236px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121518;
  --bg-2: #1b2024;
  --bg-3: #252b30;
  --surface: #171b1f;
  --surface-2: #1d2226;
  --ink: #ebe6da;
  --ink-2: #c3c0b8;
  --ink-3: #a3a6a3;
  --rule: #2c3237;
  --rule-strong: #434b51;
  --felt: #7fc4a4;
  --felt-deep: #a3d8bf;
  --felt-tint: #1f3a30;
  --red: #f08a6c;
  --red-tint: #3d231c;
  --ochre: #e0b062;
  --ochre-tint: #3a2f1b;
  --blue: #8fb4e3;
  --blue-tint: #1e2b3b;
  --code-bg: #14181b;
  --add-bg: #17322a;
  --add-ink: #9fd8bd;
  --del-bg: #3a201a;
  --del-ink: #f2a58d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
  --count-ink: #1a0d08;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--felt); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--felt); outline-offset: 2px; border-radius: 3px; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: var(--top) 1fr; height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--rule); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); min-width: calc(var(--side) - 24px); }
.brand:hover { text-decoration: none; }
.brand svg { width: 20px; height: 27px; }
.brand b { font-family: var(--font-serif); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.brand .pip { font-family: var(--font-serif); color: var(--red); font-size: 13px; border: 1px solid var(--rule-strong); border-radius: 3px; padding: 0 5px; line-height: 18px; }
.brand .pip + span { color: var(--ink-3); font-size: 13px; }
.menu-btn { display: none; padding: 6px; border-radius: var(--r-sm); color: var(--ink-2); }
.menu-btn:hover { background: var(--bg-2); }
.project-switch {
  display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface-2); color: var(--ink-2); font-size: 13px; white-space: nowrap;
}
.project-switch:hover { border-color: var(--rule-strong); }
.project-switch .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--felt); }
.search-btn {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-left: 6px;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--bg); color: var(--ink-3); font-size: 13px; text-align: left;
}
.search-btn:hover { border-color: var(--rule-strong); color: var(--ink-2); }
.search-btn span { flex: 1; }
kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 3px;
  border: 1px solid var(--rule); border-bottom-width: 2px; background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.deck-pill {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--rule); background: var(--surface-2); white-space: nowrap;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--felt); box-shadow: 0 0 0 3px var(--felt-tint); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
.mock-pill { font-size: 11px; color: var(--ochre); border: 1px dashed var(--ochre); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.icon-btn { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); color: var(--ink-2); }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn .count {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--red); color: var(--count-ink); font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}
.avatar-btn { margin-left: 4px; }

/* Sidebar */
.sidebar {
  grid-row: 2; background: var(--surface); border-right: 1px solid var(--rule); overflow-y: auto;
  padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 14px;
}
.nav-group h6 { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 4px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r); color: var(--ink-2); font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--felt-tint); color: var(--felt-deep); font-weight: 500; }
[data-theme="dark"] .nav-item[aria-current="page"] { color: var(--felt); }
.nav-item .badge { margin-left: auto; }
.nav-item .n { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.side-foot { margin-top: auto; border-top: 1px solid var(--rule); padding-top: 12px; display: grid; gap: 8px; font-size: 12px; color: var(--ink-3); }
.side-foot .meter { height: 5px; }
.provs { display: grid; gap: 9px; color: inherit; padding: 8px; margin: 0 -8px; border-radius: var(--r); }
.provs:hover { background: var(--bg-2); text-decoration: none; }
.prov-h { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: 3px; }
.prov-h .mono { font-size: 11px; font-weight: 400; color: var(--ink-3); }
.prov-m { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 5px; align-items: center; font-size: 10.5px; color: var(--ink-3); }
.prov-m .meter { height: 4px; }
.pgroup + .pgroup { margin-top: 22px; }
.pgroup-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.pgroup-h h2 { font-family: var(--font-serif); font-size: 18px; }
.pgroup-h .win { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); min-width: 170px; }
.pgroup-h .win .meter { width: 80px; }
.win-cell { min-width: 150px; }
.win-cell .meter { margin: 4px 0 2px; }
.scrim { display: none; }

/* Main */
.main { grid-row: 2; overflow-y: auto; min-width: 0; }
.page { padding: 22px 28px 48px; max-width: 1480px; }
.page.full { max-width: none; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .t { flex: 1; min-width: 260px; }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-3); }
h1 { font-family: var(--font-serif); font-weight: 600; font-size: 26px; letter-spacing: -0.01em; line-height: 1.2; }
h1 .id { font-family: var(--font-mono); font-size: 17px; color: var(--ink-3); font-weight: 400; margin-right: 6px; }
.sub { color: var(--ink-3); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13.5px; font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r); font-size: 13px; font-weight: 500;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--bg-2); text-decoration: none; }
.btn.primary { background: var(--felt); border-color: var(--felt); color: #fff; }
[data-theme="dark"] .btn.primary { color: #0f1c17; }
.btn.primary:hover { background: var(--felt-deep); border-color: var(--felt-deep); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); }
.btn.danger:hover { background: var(--red-tint); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--r); overflow: hidden; }
.seg button { padding: 5px 11px; font-size: 12.5px; color: var(--ink-2); border-right: 1px solid var(--rule); background: var(--surface); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 8px 12px 9px; color: var(--ink-3); font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  display: flex; gap: 7px; align-items: center;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--felt); font-weight: 500; }

/* Badges & status */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--bg-2); color: var(--ink-2); white-space: nowrap; line-height: 18px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge.ok, .badge.running { background: var(--felt-tint); color: var(--felt-deep); }
[data-theme="dark"] .badge.ok, [data-theme="dark"] .badge.running { color: var(--felt); }
.badge.running::before { animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.badge.wait { background: var(--ochre-tint); color: var(--ochre); }
.badge.fail { background: var(--red-tint); color: var(--red); }
.badge.info { background: var(--blue-tint); color: var(--blue); }
.badge.idle { background: var(--bg-2); color: var(--ink-3); }
.badge.count { background: var(--red); color: var(--count-ink); padding: 0 7px; }
.badge.count::before { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 11.5px;
  background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--rule); white-space: nowrap;
}
.chip svg.i { width: 12px; height: 12px; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.prio-high { color: var(--red); } .prio-med { color: var(--ochre); } .prio-low { color: var(--ink-3); }

/* Avatars for agents and people */
.av {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  font-size: 10.5px; font-weight: 600; color: #fff; background: var(--ink-3); letter-spacing: 0.02em;
}
.av.sm { width: 20px; height: 20px; font-size: 9px; }
.av.lg { width: 38px; height: 38px; font-size: 13px; }
.av.p-openai { background: #3c6e5c; } .av.p-anthropic { background: #a2522e; } .av.p-google { background: #3d5f93; }
.av.p-local { background: #6b5b8a; } .av.p-kiro { background: #8a5a10; } .av.p-bedrock { background: #7a4a1e; } .av.p-openrouter { background: #4a5a6a; } .av.p-system { background: #5d636a; } .av.p-human { background: var(--ink); color: var(--bg); }
.av-stack { display: inline-flex; } .av-stack .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); } .av-stack .av:first-child { margin-left: 0; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who b { font-weight: 500; }
.who .m { font-size: 12px; color: var(--ink-3); }

/* Cards & panels */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--rule); }
.card-h h2, .card-h h3 { flex: 1; }
.card-b { padding: 14px; }
.card-b.flush { padding: 0; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.split.wide-side { grid-template-columns: minmax(0, 1fr) 400px; }
.split.left { grid-template-columns: 300px minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.split > *, .grid > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
hr.rule { border: 0; border-top: 1px solid var(--rule); margin: 12px 0; }

/* Stat tiles */
.stat { padding: 14px 16px; display: grid; gap: 4px; }
.stat .k { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat .v { font-family: var(--font-serif); font-size: 28px; font-weight: 600; line-height: 1.1; }
.stat .v small { font-family: var(--font-sans); font-size: 13px; color: var(--ink-3); font-weight: 400; }
.stat .d { font-size: 12px; color: var(--ink-3); }
.stat.attn .v { color: var(--red); }
a.stat { color: inherit; } a.stat:hover { text-decoration: none; background: var(--surface-2); }

/* Meters */
.meter { height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--felt); border-radius: 3px; transition: width 0.6s var(--ease, ease); }
.meter.wait > i { background: var(--ochre); } .meter.fail > i { background: var(--red); } .meter.idle > i { background: var(--ink-3); }
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 12.5px; }
.meter-row .meter { grid-column: 1 / -1; }

/* Lists */
.list { list-style: none; }
.list > li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-bottom: 1px solid var(--rule); }
.list > li:last-child { border-bottom: 0; }
.list > li.click { cursor: pointer; }
.list > li.click:hover, .list > li[aria-selected="true"] { background: var(--surface-2); }
.list > li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--felt); }
.list .body { flex: 1; min-width: 0; }
.list .title { font-weight: 500; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.list .side { text-align: right; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.kicon { width: 30px; height: 30px; border-radius: var(--r); display: grid; place-items: center; flex: none; background: var(--bg-2); color: var(--ink-2); }
.kicon.ok { background: var(--felt-tint); color: var(--felt); } .kicon.wait { background: var(--ochre-tint); color: var(--ochre); }
.kicon.fail { background: var(--red-tint); color: var(--red); } .kicon.info { background: var(--blue-tint); color: var(--blue); }

/* Key-value */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t .meter { width: 90px; display: inline-block; vertical-align: middle; margin-right: 6px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.input {
  padding: 6px 10px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--surface); min-width: 0;
}
.input:focus { outline: 2px solid var(--felt); outline-offset: -1px; border-color: transparent; }
.input.search { padding-left: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d636a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 15px; background-position: 9px center; }
select.input { padding-right: 26px; }
textarea.input { width: 100%; resize: vertical; min-height: 70px; line-height: 1.45; }
label.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; cursor: pointer; }
label.check input { margin-top: 3px; accent-color: var(--felt); }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 10px; background: var(--bg-3); transition: background 0.2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--felt); }
.switch input:checked + i::after { transform: translateX(14px); }

/* Board (kanban) */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--bg-2); border-radius: var(--r); padding: 8px; display: grid; gap: 8px; align-content: start; min-height: 200px; }
[data-theme="dark"] .col { background: var(--surface-2); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.col-h .n { color: var(--ink-3); font-weight: 400; }
.tcard { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 11px; display: grid; gap: 8px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,0.03); }
.tcard:hover { border-color: var(--rule-strong); }
.tcard .top { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--ink-3); }
.tcard .ttl { font-weight: 500; line-height: 1.35; }
.tcard .foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); }

/* Agent cards */
.agent-card { padding: 14px; display: grid; gap: 10px; cursor: pointer; transition: border-color 0.15s; }
.agent-card:hover { border-color: var(--rule-strong); }
.agent-card .now { font-size: 12.5px; color: var(--ink-2); min-height: 36px; }
.agent-card .foot { display: flex; gap: 12px; font-size: 12px; color: var(--ink-3); }

/* Feed */
.feed { list-style: none; font-size: 13px; }
.feed li { display: flex; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--rule); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed time { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); width: 58px; flex: none; padding-top: 2px; }
.feed li.new { animation: flash 1.2s; }
@keyframes flash { from { background: var(--felt-tint); } to { background: transparent; } }

/* Code, diff, logs */
.code {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; background: var(--code-bg); border: 1px solid var(--rule);
  border-radius: var(--r); overflow: auto;
}
.code table { border-collapse: collapse; width: 100%; }
.code td { padding: 0 12px; white-space: pre; vertical-align: top; }
.code td.ln { width: 1%; text-align: right; color: var(--ink-3); user-select: none; padding-right: 10px; border-right: 1px solid var(--rule); opacity: 0.8; }
.code td.mk { width: 1%; padding: 0 4px; color: var(--ink-3); user-select: none; }
.code tr.add td { background: var(--add-bg); } .code tr.add td.mk { color: var(--add-ink); }
.code tr.del td { background: var(--del-bg); } .code tr.del td.mk { color: var(--del-ink); }
.code tr.hunk td { background: var(--blue-tint); color: var(--blue); }
.code tr.mod td.ln { box-shadow: inset 3px 0 0 var(--felt); }
.code tr.empty td { background: var(--bg-2); }
.code tr.cl:hover td.ln { color: var(--felt); cursor: pointer; }
.code tr.cl:hover td.ln::before { content: "+ "; }
.code tr.comment td { white-space: normal; background: var(--surface); padding: 10px 14px; font-family: var(--font-sans); font-size: 13px; }
.diff2 { display: grid; grid-template-columns: 1fr 1fr; }
.diff2 > .code:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.diff2 > .code:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tok-k { color: #8a3d8a; } .tok-s { color: #1e6a4a; } .tok-c { color: var(--ink-3); font-style: italic; } .tok-n { color: #8a5000; } .tok-f { color: #2c5282; }
[data-theme="dark"] .tok-k { color: #d6a4e6; } [data-theme="dark"] .tok-s { color: #9fd8bd; } [data-theme="dark"] .tok-n { color: #e8c07a; } [data-theme="dark"] .tok-f { color: #9cc0ee; }
.log { font-family: var(--font-mono); font-size: 12px; line-height: 1.65; background: var(--code-bg); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 0; overflow: auto; max-height: 420px; }
.log div { padding: 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log div:hover { background: var(--bg-2); }
.log .ts { color: var(--ink-3); margin-right: 10px; }
.log .ok { color: var(--felt); } .log .fail { color: var(--red); } .log .warn { color: var(--ochre); }
.filehead { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--rule); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; font-size: 12.5px; }
.filehead + .code, .filehead + .diff2 > .code { border-top-left-radius: 0; border-top-right-radius: 0; }
.plus { color: var(--felt); font-family: var(--font-mono); font-size: 12px; } .minus { color: var(--red); font-family: var(--font-mono); font-size: 12px; }

/* File tree */
.tree { list-style: none; font-size: 13px; padding: 6px 0; }
.tree li > .node { display: flex; align-items: center; gap: 6px; padding: 3px 10px; cursor: pointer; border-radius: 0; color: var(--ink-2); white-space: nowrap; }
.tree li > .node:hover { background: var(--bg-2); }
.tree li > .node[aria-selected="true"] { background: var(--felt-tint); color: var(--ink); }
.tree ul { list-style: none; }
.tree .st { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.st-M { color: var(--ochre); } .st-A, .st-U { color: var(--felt); } .st-D { color: var(--red); }

/* Stepper / timeline */
.steps { list-style: none; position: relative; }
.steps > li { position: relative; padding: 0 0 18px 34px; }
.steps > li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--rule); }
.steps > li:last-child::before { display: none; }
.steps .dot { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--rule-strong); color: var(--ink-3); }
.steps .dot svg.i { width: 13px; height: 13px; stroke-width: 2.4; }
.steps .done .dot { background: var(--felt); border-color: var(--felt); color: #fff; }
.steps .active .dot { border-color: var(--felt); color: var(--felt); box-shadow: 0 0 0 4px var(--felt-tint); }
.steps .failed .dot { background: var(--red); border-color: var(--red); color: #fff; }
.steps .waiting .dot { border-color: var(--ochre); color: var(--ochre); }
.steps .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 24px; }
.steps .head b { font-weight: 500; }
.steps .detail { margin-top: 8px; }

/* Gantt */
.gantt { display: grid; grid-template-columns: 210px 1fr; font-size: 12.5px; }
.gantt .lab { padding: 10px 12px; border-bottom: 1px solid var(--rule); display: flex; gap: 8px; align-items: center; min-width: 0; }
.gantt .lane { position: relative; border-bottom: 1px solid var(--rule); background-image: linear-gradient(to right, var(--rule) 1px, transparent 1px); background-size: calc(100% / 6) 100%; }
.gantt .bar { position: absolute; top: 11px; height: 22px; border-radius: 4px; background: var(--felt); color: #fff; font-size: 11px; padding: 0 8px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .gantt .bar { color: #0f1c17; }
.gantt .bar.wait { background: var(--ochre); } .gantt .bar.fail { background: var(--red); } .gantt .bar.idle { background: var(--ink-3); } .gantt .bar.prev { background: var(--bg-3); color: var(--ink-2); }
.gantt .bar.live::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 6px; background: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 2px, transparent 2px 4px); }
.gantt .scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); padding: 6px 0; border-bottom: 1px solid var(--rule); }
.gantt .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 1; }

/* Graph (SVG) */
.graph { width: 100%; height: auto; display: block; }
.graph .edge { stroke: var(--rule-strong); stroke-width: 1.6; fill: none; }
.graph .edge.live { stroke: var(--felt); stroke-dasharray: 5 4; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -9; } }
.graph .node rect { fill: var(--surface); stroke: var(--rule-strong); stroke-width: 1.2; }
.graph .node.ok rect { stroke: var(--felt); } .graph .node.run rect { stroke: var(--felt); stroke-width: 2; fill: var(--felt-tint); }
.graph .node.wait rect { stroke: var(--ochre); fill: var(--ochre-tint); } .graph .node.fail rect { stroke: var(--red); fill: var(--red-tint); }
.graph .node.gate rect { stroke-dasharray: 4 3; }
.graph text { fill: var(--ink); font-family: var(--font-sans); font-size: 12px; }
.graph text.s { fill: var(--ink-3); font-size: 10.5px; }
.graph .node { cursor: pointer; }
.graph .commit { fill: var(--surface); stroke-width: 2.2; }

/* Chat */
.chat { display: grid; grid-template-columns: 260px minmax(0, 1fr) 290px; height: calc(100vh - var(--top)); }
.chat-threads { border-right: 1px solid var(--rule); overflow-y: auto; background: var(--surface); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 20px; border-bottom: 1px solid var(--rule); display: flex; gap: 12px; align-items: center; background: var(--surface); flex-wrap: wrap; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; display: grid; gap: 18px; align-content: start; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; max-width: 920px; }
.msg .mh { display: flex; gap: 8px; align-items: baseline; font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.msg .mh b { font-weight: 600; }
.msg .mh span { font-size: 12px; color: var(--ink-3); }
.msg .mb { display: grid; gap: 10px; }
.msg .mb p { line-height: 1.55; }
.msg.me .bubble { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 13px; }
details.thought { font-size: 12.5px; color: var(--ink-3); }
details.thought summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.thought summary::before { content: "\25B8"; font-size: 10px; transition: transform 0.15s; }
details.thought[open] summary::before { transform: rotate(90deg); }
details.thought p { margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--rule); }
.tool { border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); font-size: 12.5px; overflow: hidden; }
.tool > summary { display: flex; gap: 9px; align-items: center; padding: 7px 11px; cursor: pointer; list-style: none; }
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary .fn { font-family: var(--font-mono); font-weight: 500; }
.tool > summary .arg { font-family: var(--font-mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tool > summary .res { color: var(--ink-3); white-space: nowrap; }
.tool[open] > summary { border-bottom: 1px solid var(--rule); }
.tool .tb { padding: 0; }
.tool .tb .code, .tool .tb .log { border: 0; border-radius: 0; }
.composer { border-top: 1px solid var(--rule); padding: 12px 20px 16px; background: var(--surface); }
.composer .box { border: 1px solid var(--rule-strong); border-radius: 8px; background: var(--bg); }
.composer .box:focus-within { outline: 2px solid var(--felt); outline-offset: -1px; border-color: transparent; }
.composer textarea { width: 100%; border: 0; background: transparent; padding: 10px 12px 4px; resize: none; min-height: 46px; outline: none; }
.composer .bar { display: flex; gap: 8px; align-items: center; padding: 6px 8px 8px 10px; flex-wrap: wrap; }
.chat-ctx { border-left: 1px solid var(--rule); overflow-y: auto; background: var(--surface); padding: 16px; display: grid; gap: 18px; align-content: start; }
.typing { display: inline-flex; gap: 4px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: typing 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; } .typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Two-pane list/detail (inbox, review queue) */
.pane2 { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - var(--top)); }
.pane2 > .lp { border-right: 1px solid var(--rule); overflow-y: auto; background: var(--surface); }
.pane2 > .rp { overflow-y: auto; }
.pane2 .lp-h { padding: 16px 16px 10px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.pane2 .lp-h h1 { font-size: 21px; margin-bottom: 10px; }

/* Callouts */
.callout { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--surface-2); font-size: 13px; align-items: flex-start; }
.callout.ok { background: var(--felt-tint); border-color: color-mix(in srgb, var(--felt) 30%, transparent); }
.callout.wait { background: var(--ochre-tint); border-color: color-mix(in srgb, var(--ochre) 30%, transparent); }
.callout.fail { background: var(--red-tint); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.callout .body { flex: 1; min-width: 220px; } .callout b { font-weight: 600; }

/* Gate / check list */
.checks { list-style: none; }
.checks > li { border-bottom: 1px solid var(--rule); }
.checks > li:last-child { border-bottom: 0; }
.checks summary { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.checks summary::-webkit-details-marker { display: none; }
.checks summary .ttl { flex: 1; font-weight: 500; }
.checks .cb { padding: 0 14px 14px 40px; font-size: 13px; color: var(--ink-2); display: grid; gap: 8px; }
.ico-ok { color: var(--felt); } .ico-fail { color: var(--red); } .ico-wait { color: var(--ochre); } .ico-idle { color: var(--ink-3); }

/* Slide-over drawer */
.drawer-scrim { position: fixed; inset: 0; background: rgba(10, 12, 14, 0.28); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--rule); z-index: 41; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 0.24s var(--ease, ease); display: flex; flex-direction: column; }
.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer-open .drawer { transform: none; }
.drawer-h { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.drawer-h .t { flex: 1; min-width: 0; }
.drawer-b { overflow-y: auto; padding: 18px; display: grid; gap: 18px; align-content: start; flex: 1; }
.drawer-f { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; gap: 8px; flex-wrap: wrap; }

/* Modal & palette */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 14, 0.38); z-index: 60; display: grid; place-items: start center; padding-top: 12vh; animation: fade 0.12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 0.14s; }
@keyframes pop { from { transform: translateY(6px) scale(0.99); opacity: 0; } }
.modal-h { padding: 16px 18px 6px; } .modal-h h2 { font-size: 17px; font-family: var(--font-serif); }
.modal-b { padding: 8px 18px 16px; display: grid; gap: 14px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
.palette { width: min(640px, calc(100vw - 32px)); }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--rule); padding: 15px 18px; font-size: 15px; background: transparent; outline: none; }
.palette .res { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .grp { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); padding: 10px 10px 4px; }
.palette .opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r); cursor: pointer; font-size: 13.5px; }
.palette .opt[aria-selected="true"] { background: var(--felt-tint); }
.palette .opt .hint { margin-left: auto; display: flex; gap: 4px; color: var(--ink-3); font-size: 12px; }
.palette .foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--rule); font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); }
.keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; font-size: 13px; }
.keys div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--rule); }

/* Popover menu */
.pop { position: absolute; top: calc(100% + 6px); right: 0; width: 360px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.pop .card-h { padding: 10px 14px; }
.pop .list > li { padding: 10px 14px; }
.menu { width: 220px; padding: 6px; }
.menu a, .menu button { display: flex; width: 100%; gap: 9px; align-items: center; padding: 7px 9px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 13px; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--bg-2); text-decoration: none; color: var(--ink); }

/* Toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 70; }
.toast { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; box-shadow: var(--shadow-lg); animation: pop 0.18s; }
.toast svg.i { color: var(--felt-tint); }
[data-theme="dark"] .toast svg.i { color: var(--felt-deep); }

/* Empty / misc */
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); display: grid; gap: 8px; justify-items: center; }
.empty svg.i { width: 30px; height: 30px; stroke-width: 1.3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.bar-h { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; }
.ac { list-style: none; display: grid; gap: 8px; }
.ac li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.ac li svg.i { margin-top: 2px; }
.link-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .chat { grid-template-columns: 240px minmax(0, 1fr); }
  .chat-ctx { display: none; }
  .split, .split.wide-side { grid-template-columns: minmax(0, 1fr) 300px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: grid; }
  .brand { min-width: 0; }
  .sidebar {
    position: fixed; top: var(--top); left: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%);
    transition: transform 0.22s; box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(10, 12, 14, 0.28); z-index: 29; }
  .main { grid-column: 1; }
  .split, .split.wide-side, .split.left { grid-template-columns: minmax(0, 1fr); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deck-pill .txt { display: none; }
}
@media (max-width: 820px) {
  .pane2 { grid-template-columns: 1fr; height: auto; }
  .pane2 > .lp { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 46vh; }
  .chat { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - var(--top)); }
  .chat-threads { display: none; }
  .chat-scroll { padding: 16px; }
  .diff2 { grid-template-columns: 1fr; }
  .diff2 > .code:first-child { display: none; }
  .diff2 > .code:last-child { border-radius: 0 0 var(--r) var(--r); }
  .gantt { grid-template-columns: 130px 1fr; }
}
@media (max-width: 820px) {
  .split.left[style] { display: flex !important; flex-direction: column; height: auto !important; }
  .split.left[style] > aside:first-child { max-height: 40vh; border-right: 0 !important; border-bottom: 1px solid var(--rule); }
  .split.left[style] > aside:last-child { display: none !important; }
  .split.left[style] > section { min-width: 0; width: 100%; }
  .split.left[style] > section .row { flex-wrap: wrap; }
  .split[style*="380px"] { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 640px) {
  .page { padding: 16px 14px 40px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .search-btn span, .search-btn kbd, .mock-pill, .project-switch, .deck-pill { display: none; }
  .topbar { gap: 6px; padding: 0 8px; }
  .brand b { font-size: 17px; }
  .search-btn { flex: 0 0 auto; margin-left: 0; }
  .brand .pip + span { display: none; }
  h1 { font-size: 22px; }
  .keys { grid-template-columns: 1fr; }
  .bar-h { grid-template-columns: 100px 1fr 70px; }
  .pop { position: fixed; top: calc(var(--top) + 4px); left: 8px; right: 8px; width: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Card suits: the owner's shapes (public/imgs/suits/), inline SVG in the text colour. */
.suit-icon { display: inline-block; width: 0.62em; height: 0.62em; vertical-align: -0.02em; fill: currentColor; }

/* Routing: a cascade is a row of models, first to last; the one in use is highlighted. */
.cas-chain { list-style: none; display: flex; align-items: stretch; gap: 6px; padding: 12px 14px 14px; flex-wrap: wrap; margin: 0; }
.cas-step { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); min-width: 230px; flex: 1 1 230px; }
.cas-step .cas-m { display: grid; gap: 3px; flex: 1; min-width: 0; }
.cas-step .cas-m b { font-weight: 500; }
.cas-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--bg-2); color: var(--ink-2); flex: none; }
.cas-active { border-color: var(--felt); box-shadow: 0 0 0 3px var(--felt-tint); }
.cas-active .cas-n { background: var(--felt); color: #fff; }
.cas-out { opacity: 0.6; }
.cas-out .cas-m b { text-decoration: line-through; text-decoration-color: var(--red); }
.cas-arrow { display: grid; place-items: center; color: var(--ink-3); }
@media (max-width: 760px) { .cas-arrow { display: none; } .cas-step { min-width: 0; flex-basis: 100%; } }
.cmd .chip { font-size: 11px; }
