/* ==========================================================================
   Color system. Every color in the app comes from these tokens.
   - Surfaces: bg (page) < panel (cards) < raised (menus); sunken for wells and inputs.
   - Text: text (primary), text-2 (secondary), muted (hints). All >= 4.5:1 on their surfaces.
   - Accent: champagne gold (dark) / deep bronze (light), for brand, primary actions, links.
   - Premium grading: onyx and ivory surfaces, warm neutrals, hairline borders, soft depth.
   - Status: each has a mark (dots, bars, borders; >= 3:1) and an ink + tint pair for
     text on a tinted background (>= 4.5:1). Checked with a colorblind-separation validator;
     "waiting on another task" is a neutral slate on purpose: inactive, not a state to act on.
   Dark mode uses its own selected steps, not an automatic inversion.
   ========================================================================== */
:root {
  color-scheme: light dark;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --bg: #f7f4ee;
  --panel: #fffdf9;
  --raised: #ffffff;
  --sunken: #efe9df;
  --sidebar: #f1ece3;
  --border: #e3dbcd;
  --border-strong: #cfc4b1;
  --text: #1c1813;
  --text-2: #4d453b;
  --muted: #6b6253;

  --accent: #8a6116;
  --accent-hover: #74500f;
  --accent-ink: #7d5712;
  --accent-tint: #f4ead6;
  --on-accent: #ffffff;
  --gold-1: #b8862b;  --gold-2: #8a6116;  --gold-3: #5c3f0c;
  --focus: #8a6116;

  --s-you: #e2621f;      --s-you-ink: #b13d0b;      --s-you-bg: #fdece3;
  --s-progress: #2a78d6; --s-progress-ink: #1c5cab; --s-progress-bg: #e7f0fc;
  --s-blocked: #8a8578;  --s-blocked-ink: #57534a;  --s-blocked-bg: #efeee9;
  --s-done: #16a34a;     --s-done-ink: #106b1d;     --s-done-bg: #e4f3e6;

  /* Usage meters: how much of a limit is left. */
  --m-ok: #16a34a;       --m-ok-ink: #106b1d;
  --m-warn: #c98500;     --m-warn-ink: #8a5a00;
  --m-crit: #d03b3b;     --m-crit-ink: #a82727;

  --shadow: 0 1px 2px rgb(44 32 16 / 6%), 0 4px 14px rgb(44 32 16 / 5%);
  --radius: 12px;

  /* Favorites */
  --star: #a8740a;

  /* Console: always dark, like a terminal, in both themes. */
  --con-bg: #121110;      --con-hover: #1c1a18;    --con-text: #e8e4de;
  --con-time: #6f685f;    --con-tag: #8f877d;      --con-claude: #e9a36c;
  --con-claude-text: #f4efe8;  --con-tool: #8fb4ff;  --con-result: #a59d92;
  --con-done: #6fd39c;    --con-error: #ff8a70;    --con-stderr: #d9a497;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0c0b;
    --panel: #161412;
    --raised: #1e1b18;
    --sunken: #0a0908;
    --sidebar: #110f0d;
    --border: #2a2622;
    --border-strong: #3d3731;
    --text: #f4efe6;
    --text-2: #c9c0b2;
    --muted: #9d9384;

    --accent: #d6b46a;
    --accent-hover: #e6c785;
    --accent-ink: #e0c07a;
    --accent-tint: #2a2216;
    --on-accent: #1a1408;
    --gold-1: #f6e2a8;  --gold-2: #d6b46a;  --gold-3: #9a7128;
    --focus: #e0c07a;

    --s-you: #df6a2c;      --s-you-ink: #f39a64;      --s-you-bg: #3a2316;
    --s-progress: #3987e5; --s-progress-ink: #86b6ef; --s-progress-bg: #172a44;
    --s-blocked: #8e897d;  --s-blocked-ink: #c9c5ba;  --s-blocked-bg: #2a2926;
    --s-done: #2fae55;     --s-done-ink: #6fd38a;     --s-done-bg: #14301c;

    --m-ok: #2fae55;       --m-ok-ink: #6fd38a;
    --m-warn: #e0a526;     --m-warn-ink: #f2c45e;
    --m-crit: #e05555;     --m-crit-ink: #f08a8a;

    --shadow: 0 1px 0 rgb(255 240 210 / 3%) inset, 0 8px 24px rgb(0 0 0 / 35%);
    --star: #e0a526;
  }
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  background: var(--sidebar);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
  text-decoration: none;
  margin: 0 0 22px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 2px 6px rgb(138 97 22 / 35%)); }
.brand-text { display: grid; line-height: 1.05; }
.brand-name { font-family: var(--font-display); font-size: 19px; letter-spacing: 0.01em; }
.brand-name .hide { font-weight: 400; color: var(--text); }
.brand-name .foundry {
  font-weight: 700;
  background: linear-gradient(120deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag { font-size: 9px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  border-left: 2px solid transparent;
  text-decoration: none;
  font-size: 14px;
}

.sidebar nav a { display: flex; align-items: center; gap: 8px; }
.sidebar nav a .nav-label { flex: 1; }
.nav-count {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-count[hidden] { display: none; }
.sidebar nav a.has-waiting:not(.active) { color: var(--text); font-weight: 600; }

.sidebar nav a:hover { background: var(--sunken); color: var(--text); }
.sidebar nav a.active { background: var(--accent-tint); font-weight: 600; color: var(--accent-ink); border-left-color: var(--accent); border-radius: 0 8px 8px 0; }

.content { padding: 32px 40px; max-width: 960px; }

.page-header h1 { margin: 0 0 6px; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.page-header { padding-bottom: 14px; border-bottom: 1px solid var(--border); }

.muted { color: var(--muted); margin: 0; }
.page-header .muted { color: var(--text-2); }

.cards { margin-top: 24px; display: grid; gap: 12px; }

.card, .empty {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.empty { text-align: center; padding: 48px 20px; }
.empty h2 { margin: 0 0 6px; font-size: 16px; }

.muted.small, .small { font-size: 12px; }

/* ---------- Task status: map each status class to its tokens ---------- */
.s-you      { --s: var(--s-you);      --s-ink: var(--s-you-ink);      --s-bg: var(--s-you-bg); }
.s-progress { --s: var(--s-progress); --s-ink: var(--s-progress-ink); --s-bg: var(--s-progress-bg); }
.s-blocked  { --s: var(--s-blocked);  --s-ink: var(--s-blocked-ink);  --s-bg: var(--s-blocked-bg); }
.s-done     { --s: var(--s-done);     --s-ink: var(--s-done-ink);     --s-bg: var(--s-done-bg); }

/* Dots: shape differs per status too, so color is never the only signal. */
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--s, var(--muted)); flex: none;
}
.s-progress > .dot { background: transparent; border: 2px solid var(--s); border-right-color: transparent; }
.s-blocked > .dot  { background: transparent; border: 2px dashed var(--s); }
.s-you > .dot      { box-shadow: 0 0 0 3px color-mix(in srgb, var(--s) 25%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .s-progress > .dot { animation: spin 1.2s linear infinite; }
  .s-you > .dot { animation: pulse 1.8s ease-in-out infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--s) 10%, transparent); } }

/* ---------- Toolbar ---------- */
.task-toolbar { margin-top: 20px; display: grid; gap: 12px; }

.task-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px;
}
.task-search:focus-within { border-color: var(--accent); }
.task-search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.task-search input {
  flex: 1; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; padding: 10px 0; outline: none;
}
.task-search kbd {
  font: 12px ui-monospace, monospace; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
}

.status-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px;
}
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--s, var(--accent)); }
.chip.on { background: var(--s-bg, var(--bg)); border-color: var(--s, var(--text)); font-weight: 600; }
.chip.on .count { color: var(--s-ink, var(--text)); }

.task-error {
  margin-top: 12px; padding: 10px 14px; border-radius: 8px;
  background: var(--s-you-bg); color: var(--s-you-ink); font-size: 14px;
}
.task-loading { color: var(--muted); padding: 24px 0; }

/* ---------- Cards ---------- */
.task-list { margin-top: 16px; display: grid; gap: 12px; }

.task-card {
  box-shadow: var(--shadow);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--s);
  border-radius: 10px;
  padding: 14px 16px;
}
.task-card.s-you { box-shadow: 0 0 0 1px color-mix(in srgb, var(--s) 35%, transparent); }
.task-card.s-done .task-card-title h2 { color: var(--muted); }

.task-card-head { display: flex; align-items: flex-start; gap: 8px; }
.task-card-title { flex: 1; min-width: 0; }
.task-card-title h2 { margin: 2px 0 6px; font-size: 15px; line-height: 1.35; }

.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; }
.needs-you { color: var(--s-you-ink); font-weight: 600; }

.progress {
  display: inline-flex; width: 120px; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--border); gap: 1px;
}
.progress > span { background: var(--s); }

/* Status pill: looks like a badge, is a real <select> for changing status. */
.status-pill {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--s-ink);
  background: var(--s-bg); border-radius: 999px; padding: 2px 9px 2px 8px;
  cursor: pointer; white-space: nowrap;
}
.status-pill select {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font: inherit;
}
.status-pill:focus-within { outline: 2px solid var(--s); outline-offset: 1px; }

.toggle, .reply-toggle {
  font: inherit; color: var(--muted); background: transparent; border: 0; cursor: pointer;
  border-radius: 6px;
}
.toggle { width: 22px; height: 22px; flex: none; font-size: 18px; line-height: 1; padding: 0; }
.toggle span { display: inline-block; transition: transform 0.15s; }
.toggle.open span { transform: rotate(90deg); }
.toggle:hover, .reply-toggle:hover { background: var(--bg); color: var(--text); }
.toggle-spacer { width: 22px; flex: none; }

.reply-toggle { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; padding: 4px 8px; white-space: nowrap; }
.reply-toggle.on { color: var(--accent); background: var(--bg); }

.task-body { margin: 8px 0 0 30px; font-size: 13px; }
.task-desc { margin: 0; white-space: pre-wrap; color: var(--text); }
.blocked-by { margin: 0 0 4px; color: var(--s-blocked-ink); }

/* ---------- Sub-task tree ---------- */
.subtasks { list-style: none; margin: 10px 0 0 10px; padding: 0 0 0 18px; border-left: 1px solid var(--border); }
.subtask { margin: 2px 0; }
.subtask-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px;
}
.subtask-row:hover { background: var(--bg); }
.subtask-title { flex: 0 1 auto; min-width: 0; margin-right: auto; font-size: 14px; }
.subtask.s-done > .subtask-row .subtask-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }
.subtask .task-body { margin-left: 36px; }

/* Search hits */
.match > .task-card-head h2, .match > .subtask-row .subtask-title {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 3px; box-decoration-break: clone; padding: 0 2px;
}

/* ---------- Replies ---------- */
.thread { margin: 10px 0 4px 30px; display: grid; gap: 8px; }
.replies { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reply { background: var(--bg); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.reply.from-you { border-left: 3px solid var(--accent); }
.reply.from-agent { border-left: 3px solid var(--border); }
.reply p { margin: 3px 0 0; white-space: pre-wrap; }
.reply-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }

.reply-form { display: grid; gap: 6px; }
.reply-form textarea {
  font: inherit; font-size: 13px; color: var(--text); resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.reply-form textarea:focus { outline: none; border-color: var(--accent); }
.reply-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.btn-primary {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--on-accent); background: var(--accent); border: 0; border-radius: 6px; padding: 6px 14px;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ---------- Shared ---------- */
a { color: var(--accent-ink); }
a:hover { color: var(--accent-hover); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.status-pill.static { cursor: default; }
.flash { animation: flash 1.6s ease-out 1; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.btn-danger {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--s-you-ink); background: var(--s-you-bg); border: 1px solid var(--s-you);
  border-radius: 6px; padding: 6px 14px;
}
.btn-danger:disabled { opacity: 0.6; cursor: default; }

/* ---------- Decisions ---------- */
.decision-tabs { margin-top: 20px; display: flex; gap: 6px; }
.decision-list { margin-top: 16px; display: grid; gap: 14px; }

.decision-card {
  box-shadow: var(--shadow);
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; display: grid; gap: 12px;
}
.decision-card.pending { border-left: 4px solid var(--s-you); }
.decision-card.closed { opacity: 0.92; }
.decision-head h2 { margin: 6px 0 0; font-size: 17px; line-height: 1.35; }
.decision-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; }
.decision-context { margin: 0; font-size: 14px; white-space: pre-wrap; }

.references { display: flex; gap: 10px; align-items: baseline; font-size: 13px; flex-wrap: wrap; }
.references-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.references ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.references a { text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.references a:hover { border-bottom-color: var(--accent); }

.options { display: grid; gap: 8px; }
.option {
  position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: var(--bg);
}
.options[role="radiogroup"] .option { cursor: pointer; }
.options[role="radiogroup"] .option:hover { border-color: var(--muted); }
.option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.option.recommended {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.option.selected { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.option.recommended.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.option.chosen { border-color: var(--s-done); box-shadow: inset 0 0 0 1px var(--s-done); }
.option.not-chosen { opacity: 0.6; }

.option-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.option-head strong { font-size: 14px; }
.radio {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); flex: none;
}
.option.selected .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.rec-badge {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 999px; padding: 2px 8px;
}
.chosen-badge {
  font-size: 11px; font-weight: 700; color: var(--s-done-ink); background: var(--s-done-bg);
  border-radius: 999px; padding: 2px 8px;
}
.option-desc { margin: 6px 0 0 26px; font-size: 13px; white-space: pre-wrap; }
.options:not([role="radiogroup"]) .option-desc { margin-left: 0; }
.pros-cons { margin: 8px 0 0 26px; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.options:not([role="radiogroup"]) .pros-cons { margin-left: 0; }
.pros-cons dt { font-weight: 600; font-size: 12px; }
.pros-cons dt.pro { color: var(--s-done-ink); }
.pros-cons dt.con { color: var(--s-you-ink); }
.pros-cons dd { margin: 0; white-space: pre-wrap; }
.rationale {
  margin: 10px 0 0 26px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.options:not([role="radiogroup"]) .rationale { margin-left: 0; }
.rationale-label { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.rationale p { margin: 3px 0 0; white-space: pre-wrap; }

.decide-form { display: grid; gap: 6px; }
.decide-form textarea {
  font: inherit; font-size: 13px; color: var(--text); resize: vertical;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.decide-form textarea:focus { outline: none; border-color: var(--accent); }
.outcome { margin: 0; font-size: 13px; }

/* ---------- Runs ---------- */
.runs { margin-top: 20px; display: grid; gap: 12px; }
.run-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.run-tab {
  display: flex; align-items: center; gap: 8px; flex: none; max-width: 260px;
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px;
}
.run-tab:hover { border-color: var(--muted); }
.run-tab.active { border-color: var(--s); box-shadow: inset 0 -2px 0 var(--s); }
.run-tab-text { display: grid; min-width: 0; }
.run-tab-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-tab-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.run-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.run-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.run-head-main { flex: 1; min-width: 0; }
.run-head h2 { margin: 0 0 6px; font-size: 15px; }

.channel-tabs { display: flex; align-items: center; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.channel-tab {
  display: inline-flex; gap: 6px; align-items: center; flex: none;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
  background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 9px 10px;
}
.channel-tab:hover { color: var(--text); }
.channel-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.channel-tab .count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.follow { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; padding-left: 12px; }

/* The console is always dark, like a terminal. */
.console {
  height: min(60vh, 560px); overflow: auto; padding: 10px 0;
  background: var(--con-bg); color: var(--con-text);
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.console:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.console-empty { color: var(--con-tag); padding: 8px 16px; }
.line { display: grid; grid-template-columns: 64px 56px 1fr; gap: 10px; padding: 1px 16px; }
.line:hover { background: var(--con-hover); }
.line-time { color: var(--con-time); }
.line-tag { color: var(--con-tag); text-align: right; }
.line-text { white-space: pre-wrap; word-break: break-word; }
.k-text .line-tag { color: var(--con-claude); }
.k-text .line-text { color: var(--con-claude-text); }
.k-tool_call .line-tag, .k-tool_call .line-text { color: var(--con-tool); }
.k-tool_result .line-text { color: var(--con-result); }
.k-result .line-tag, .k-result .line-text { color: var(--con-done); font-weight: 600; }
.k-error .line-tag, .k-error .line-text, .k-stderr .line-tag { color: var(--con-error); }
.k-stderr .line-text { color: var(--con-stderr); }
.k-system .line-text { color: var(--con-tag); font-style: italic; }

/* ---------- Skills ---------- */
.skill-filters { display: grid; gap: 10px; }
.star-icon { color: var(--star); }
.skill-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.skill-grid > .empty, .skill-grid > .task-loading { grid-column: 1 / -1; }
.skill-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.skill-card.fav { border-color: color-mix(in srgb, var(--star) 55%, var(--border)); }
.skill-head { display: flex; align-items: center; gap: 8px; }
.skill-name { margin: 0; font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.skill-source { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; }
.star { font-size: 18px; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.star:hover { background: var(--bg); color: var(--star); }
.star.on { color: var(--star); }
.skill-desc { margin: 0; font-size: 13px; flex: 1; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.skill-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.badge { font-size: 11px; font-weight: 600; text-decoration: none; color: var(--s-progress-ink); background: var(--s-progress-bg); border-radius: 999px; padding: 2px 8px; }
.badge.off { color: var(--muted); background: var(--bg); }
.skill-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.skill-path { font-size: 11px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-secondary {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.6; cursor: default; }

/* ---------- Schedules ---------- */
.schedule-note { margin: 16px 0 0; }
.schedule-list { margin-top: 12px; display: grid; gap: 10px; }
.schedule-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--s-progress);
  border-radius: 10px; padding: 14px 16px;
}
.schedule-card.off { border-left-color: var(--border); }
.schedule-card.off h2 { color: var(--muted); }
.schedule-main { flex: 1; min-width: 240px; }
.schedule-main h2 { margin: 0 0 6px; font-size: 15px; }
.schedule-controls { display: flex; align-items: center; gap: 12px; }
.every { font-size: 13px; color: var(--muted); }
.every select { font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--border); transition: background 0.15s; position: relative; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--s-done); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Decision: who asked, what an option does, whether it was carried out */
.asked-by { color: var(--muted); font-style: italic; }
.action-note { margin: 6px 0 0 26px; font-size: 12px; font-weight: 600; }
.options:not([role="radiogroup"]) .action-note { margin-left: 0; }
.action-note.a-merge { color: var(--s-done-ink); }
.action-note.a-close { color: var(--s-you-ink); }
.action-note.a-hold { color: var(--s-blocked-ink); }
.outcome { display: grid; gap: 4px; }
.outcome p { margin: 0; font-size: 13px; }
.applied.done { color: var(--s-done-ink); font-weight: 600; }
.applied.waiting { color: var(--s-blocked-ink); font-weight: 600; }

/* ---------- Home: accounts ---------- */
.section-title { margin: 24px 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }
.coordinator-strip { margin-top: 20px; }
.strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px; font-size: 14px;
}
.strip-usage { font-weight: 600; }
.strip-usage.m-ok, .meter.m-ok .meter-state { color: var(--m-ok-ink); }
.strip-usage.m-warn, .meter.m-warn .meter-state { color: var(--m-warn-ink); }
.strip-usage.m-crit, .meter.m-crit .meter-state { color: var(--m-crit-ink); }

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.account-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.account-card.is-coordinator { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.account-card.placeholder { border-style: dashed; box-shadow: none; background: transparent; }
.account-head { display: flex; align-items: flex-start; gap: 10px; }
.provider-mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  color: var(--accent-ink); background: var(--accent-tint);
}
.placeholder .provider-mark { color: var(--muted); background: var(--sunken); }
.account-id { flex: 1; min-width: 0; }
.account-id h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-id p { margin: 2px 0 0; }
.account-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.role-badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.role-badge.coordinator { color: var(--on-accent); background: var(--accent); }
.role-badge.worker { color: var(--text-2); background: var(--sunken); }
.plain-badge { font-size: 11px; font-weight: 600; color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 8px; }

.meters { display: grid; gap: 12px; }
.meter-top, .meter-bottom { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meter-label { font-size: 13px; font-weight: 600; }
.meter-value { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }
.meter-track { height: 8px; margin: 6px 0; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 4px; }
.meter.m-ok .meter-fill { background: var(--m-ok); }
.meter.m-warn .meter-fill { background: var(--m-warn); }
.meter.m-crit .meter-fill { background: var(--m-crit); }
.meter-state { font-size: 12px; font-weight: 600; }

.account-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.account-stat dt { font-size: 11px; color: var(--muted); }
.account-stat dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.account-stat.warn dd { color: var(--m-crit-ink); }
.account-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.account-foot span:first-child { flex: 1; min-width: 180px; }

.explainer { margin-top: 20px; font-size: 13px; color: var(--text-2); }
.explainer summary { cursor: pointer; font-weight: 600; color: var(--text); }
.explainer p { max-width: 70ch; }

/* ---------- Feature gates ---------- */
.gate-form {
  margin-top: 20px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px 14px;
}
.gate-form .section-title { margin-top: 12px; }
.gate-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 10px; }
.gate-fields label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.gate-fields .wide { grid-column: 1 / -1; }
.gate-fields input {
  font: inherit; font-size: 14px; color: var(--text); background: var(--sunken);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px;
}
.gate-fields input:focus { outline: none; border-color: var(--accent); }
.gate-fields input:user-invalid { border-color: var(--m-crit); }
.gate-list { margin-top: 12px; display: grid; gap: 10px; }
.gate-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px;
}
.gate-card.on { border-left-color: var(--s-done); }
.gate-main { flex: 1; min-width: 220px; }
.gate-main h3 { margin: 4px 0 2px; font-size: 15px; }
.gate-main p { margin: 2px 0 0; }
.gate-key { font-size: 12px; }
.gate-envs { display: flex; gap: 14px; }
.env-switch { display: grid; justify-items: center; gap: 3px; cursor: pointer; }
.env-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.env-state { font-size: 11px; color: var(--muted); }
.env-switch.on .env-state { color: var(--s-done-ink); font-weight: 600; }
.btn-ghost {
  font: inherit; font-size: 12px; color: var(--muted); background: transparent; cursor: pointer;
  border: 1px solid transparent; border-radius: 6px; padding: 5px 10px;
}
.btn-ghost:hover { color: var(--m-crit-ink); border-color: var(--border); }

/* ---------- Chats ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.s-fail { --s: var(--m-crit); --s-ink: var(--m-crit-ink); --s-bg: color-mix(in srgb, var(--m-crit) 14%, var(--panel)); }
.composer {
  margin-top: 20px; display: grid; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea, .chat-panel textarea {
  font: inherit; font-size: 14px; color: var(--text); resize: vertical; width: 100%;
  background: var(--sunken); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
.composer textarea:focus, .chat-panel textarea:focus { outline: none; border-color: var(--accent); }
.composer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer-actions .btn-primary { margin-left: auto; }
.file-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.file-chips:empty { display: none; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--sunken); border: 1px solid var(--border); border-radius: 999px; padding: 3px 6px 3px 10px;
}
.file-chip button { font: inherit; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; border-radius: 50%; }
.file-chip button:hover { color: var(--m-crit-ink); }
.chat-filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.show-hidden { font-size: 13px; color: var(--text-2); margin-left: auto; }

.chat-list { margin-top: 16px; display: grid; gap: 12px; }
.chat-card {
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--s);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 10px;
}
.chat-card.is-hidden { opacity: 0.7; border-style: dashed; }
.chat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-head h2 { margin: 0; font-size: 15px; flex: 1; min-width: 200px; }
.chat-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chat-msg { border-radius: 8px; padding: 10px 12px; font-size: 14px; background: var(--bg); }
.chat-msg.from-you { border-left: 3px solid var(--accent); }
.chat-msg.from-claude { border-left: 3px solid var(--s-done); background: var(--sunken); }
.chat-msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; margin-bottom: 4px; }
.chat-msg-body { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.chat-msg .file-chips { margin-top: 8px; }
.chat-working { margin: 0; font-size: 13px; color: var(--s-ink); display: flex; align-items: center; gap: 6px; }
.chat-failed { margin: 0; font-size: 13px; color: var(--m-crit-ink); }
.chat-panel { display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.chat-panel p { margin: 0; }
.chat-actions { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.chat-actions .spacer { flex: 1; }
.btn-secondary.on { border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost.danger:hover { color: var(--m-crit-ink); }
.chat-msg-body.md { white-space: normal; }
.md p { margin: 0 0 8px; white-space: pre-wrap; }
.md p:last-child, .md ul:last-child, .md ol:last-child, .md pre:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md .md-heading { font-weight: 700; }
.md pre { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--con-bg); color: var(--con-text); overflow: auto; }
.md pre code { background: none; border: 0; padding: 0; color: inherit; }

/* Decisions: keys, one-click options, Other */
.decision-key {
  font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent-ink);
  background: var(--accent-tint); border-radius: 6px; padding: 2px 7px;
}
.decision-key-inline { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent-ink); }
.decision-task { margin: 4px 0 0; }
.decision-tabs { margin-top: 0; }
.option-button {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
}
.option-button:hover:not(:disabled) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.option-button:active:not(:disabled) { transform: translateY(1px); }
.option-button:disabled { cursor: progress; opacity: 0.6; }
.option-button .option-desc, .option-button .pros-cons, .option-button .rationale, .option-button .action-note { margin-left: 0; }
.option.other { border-style: dashed; background: transparent; }
.option.other.open { border-style: solid; border-color: var(--accent); }
.other-wrap { display: grid; gap: 8px; }
.other-form { display: grid; gap: 6px; padding-left: 12px; border-left: 2px solid var(--accent); }
.other-form textarea {
  font: inherit; font-size: 13px; color: var(--text); resize: vertical;
  background: var(--sunken); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.other-form textarea:focus { outline: none; border-color: var(--accent); }
.pick-hint { margin: 0; }
.other-answer { padding: 8px 12px; border-radius: 8px; background: var(--accent-tint); font-size: 13px; }
.other-answer p { margin: 3px 0 6px; white-space: pre-wrap; }
.outcome-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Run history and triggers ---------- */
.schedule-card { flex-wrap: wrap; }
.schedule-history { flex-basis: 100%; border-top: 1px solid var(--border); padding-top: 8px; }
.history-toggle {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-2); background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.history-toggle:hover { background: var(--sunken); color: var(--text); }
.history-toggle .chev { display: inline-block; transition: transform 0.15s; }
.history-toggle.open .chev { transform: rotate(90deg); }
.history-empty { margin: 6px 6px 2px; }
.runs-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.runs-table th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.runs-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.runs-table tr:last-child td { border-bottom: 0; }
.runs-table tbody tr:hover { background: var(--sunken); }
.runs-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.runs-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2); }
.output-row td { background: var(--sunken); }
.firing-output {
  margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--con-bg); color: var(--con-text); border-radius: 8px; padding: 10px 12px;
}
.trigger-card h2 { display: flex; align-items: center; gap: 10px; }
.trigger-state { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 8px; }
.trigger-state.on { color: var(--s-done-ink); border-color: var(--s-done); background: var(--s-done-bg); }
.trigger-desc { margin: 0 0 8px; max-width: 70ch; }
.trigger-scope { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.trigger-scope .yes { color: var(--text); }
.trigger-scope .no { color: var(--text-2); }
.onoff { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; align-self: center; }
.onoff-btn {
  font: inherit; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; min-width: 64px; padding: 8px 16px;
  cursor: pointer; background: var(--panel); color: var(--text-2); border: 0;
}
.onoff-btn + .onoff-btn { border-left: 1px solid var(--border-strong); }
.onoff-btn:hover:not(.active) { background: var(--sunken); color: var(--text); }
.onoff-btn.on.active { background: var(--s-done); color: #fff; }
.onoff-btn.off.active { background: var(--sunken); color: var(--text); }

/* ---------- Ready PRs ---------- */
.pr-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.pr-toolbar p { margin: 0; }
.pr-toolbar p.warn { color: var(--m-warn-ink); }
.btn-secondary {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  color: var(--text); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 14px;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.btn-secondary:disabled { opacity: 0.6; cursor: default; }
.pr-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pr-jump .chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text-2); }
.pr-section {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--s);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 16px; margin-bottom: 16px;
  scroll-margin-top: 16px;
}
.pr-section-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 16px; }
.pr-section-head p { margin: 4px 0 0 34px; }
.pr-step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--s-bg); color: var(--s-ink); font-size: 12px; font-weight: 700;
}
.pr-count {
  margin-left: auto; min-width: 24px; padding: 1px 8px; border-radius: 999px; text-align: center;
  background: var(--s-bg); color: var(--s-ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pr-none { margin: 10px 0 0 34px; }
.pr-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.pr-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.pr-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.pr-title { display: flex; gap: 8px; align-items: baseline; font-weight: 600; }
.pr-number { font-variant-numeric: tabular-nums; text-decoration: none; }
.pr-priority {
  flex: none; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--sunken); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.pr-priority.p0 { background: var(--m-crit); color: #fff; }
.pr-priority.p1 { background: color-mix(in srgb, var(--m-warn) 22%, var(--panel)); color: var(--m-warn-ink); }
.pr-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.pr-fact { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--sunken); color: var(--text-2); }
.pr-fact.ok { background: var(--s-done-bg); color: var(--s-done-ink); }
.pr-fact.warn { background: color-mix(in srgb, var(--m-warn) 18%, var(--panel)); color: var(--m-warn-ink); }
.pr-next { margin: 0; color: var(--s-ink); font-weight: 600; }
