:root {
  color-scheme: light dark;
  --bg: #faf7f1;
  --surface: #ffffff;
  --surface-2: #f2ede3;
  --line: #e2dbcc;
  --line-soft: #ece6da;
  --ink: #1d1a14;
  --ink-2: #5e574a;
  --ink-3: #8b8375;
  --accent: #b5760a;
  --accent-ink: #ffffff;
  --mine: #fdf2da;
  --mine-line: #ecd8a6;
  --danger: #b3261e;
  --ok: #1f7a4d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 26, 20, .06), 0 6px 18px rgba(29, 26, 20, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100c;
    --surface: #1b1813;
    --surface-2: #232019;
    --line: #322d24;
    --line-soft: #272319;
    --ink: #f2ece0;
    --ink-2: #b4ab9a;
    --ink-3: #8a8272;
    --accent: #e8ae3e;
    --accent-ink: #1a1409;
    --mine: #2a2213;
    --mine-line: #4a3a1c;
    --danger: #f2897f;
    --ok: #6ad39c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.mark {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px;
  background: linear-gradient(160deg, #f2b74a, #c6740e);
}

h1 {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  letter-spacing: -.01em;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.status {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.status.err { color: var(--danger); }

.iconbtn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.5;
}
.iconbtn:hover { border-color: var(--ink-3); }
.iconbtn[data-on="true"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }

/* ---------- channel tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs:empty { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 46vw;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab:hover { border-color: var(--ink-3); }
.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.tab .dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- notices ---------- */
.notice {
  margin: 10px 14px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}
.notice strong { color: var(--ink); font-weight: 600; }
.notice[hidden] { display: none; }

/* ---------- thread ---------- */
.thread {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.empty {
  margin: auto;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
}

.daysep {
  align-self: center;
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  padding: 3px 0;
}
.msg.mine { align-items: flex-end; }

/* One continuous inline flow so a long headline wraps naturally and the
   time stays hard against the end of the text instead of dropping a line. */
.row {
  display: block;
  max-width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.msg.mine .row {
  background: var(--mine);
  border-color: var(--mine-line);
  text-align: right;
}

.tag {
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--line-soft);
}
.tag.k-decision { color: #8a4b00; background: #ffe9c2; border-color: #f0d09a; }
.tag.k-alert    { color: #8c1d18; background: #ffe0dd; border-color: #f2c0bb; }
.tag.k-win      { color: #145c39; background: #d6f3e4; border-color: #aee0c8; }
@media (prefers-color-scheme: dark) {
  .tag.k-decision { color: #ffcd7a; background: #3d2c0d; border-color: #5b431a; }
  .tag.k-alert    { color: #ffb0a6; background: #401a16; border-color: #5f2b25; }
  .tag.k-win      { color: #8ae5b6; background: #103526; border-color: #1d5138; }
}

.headline {
  font-size: 14.5px;
  letter-spacing: -.005em;
  overflow-wrap: anywhere;
}

.time {
  margin-left: 7px;
  white-space: nowrap;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.more {
  margin-left: 7px;
  border: 0;
  background: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.flagbtn {
  margin-left: 7px;
  border: 0;
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--ink-3);
  opacity: .55;
}
.flagbtn:hover { opacity: 1; color: var(--ink-2); }
.flagbtn.on { color: var(--accent); opacity: 1; }

.detail {
  margin: 4px 0 0;
  padding: 9px 11px;
  max-width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.detail[hidden] { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip::before { content: "↗"; font-size: 11px; opacity: .7; }
.chip:hover { border-color: var(--accent); }

/* ---------- composer ---------- */
.composer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }

.send {
  flex: none;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  font-size: 14px;
}
.send:disabled { opacity: .45; cursor: default; }

/* ---------- images: attach + inline ---------- */
.attach {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink-2);
}
.attach:hover { border-color: var(--accent); color: var(--accent); }
.attach-preview {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--ink-2);
}
.attach-preview[hidden] { display: none; }
.attach-preview.sending { opacity: .55; }
.attach-preview .thumb { flex: none; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: var(--bg); }
.attach-preview .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-preview .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attach-preview .meta b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview .bad { flex: 1; color: var(--danger); }
.main.dropping .composer { outline: 2px dashed var(--accent); outline-offset: -4px; }

.msg-img {
  display: block;
  margin-top: 4px;
  max-width: min(100%, 340px);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  line-height: 0;
}
.msg-img img { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; min-width: 60px; min-height: 40px; object-fit: contain; }
.msg-img.err { line-height: 1.4; padding: 8px 11px; font-size: 12px; color: var(--ink-3); }
.run-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.run-imgs .msg-img { max-width: 160px; margin-top: 0; }
.run-imgs .msg-img img { max-height: 120px; }

/* ---------- gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.gate[hidden] { display: none; }

.gate form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.gate .mark { width: 34px; height: 34px; border-radius: 9px; }
.gate h2 { margin: 6px 0 0; font-size: 17px; font-weight: 650; }
.gate p { margin: 0; font-size: 13px; color: var(--ink-2); }
.gate input {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
}
.gate input:focus { border-color: var(--accent); }
.gate button {
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
.gate .msgline { font-size: 12.5px; min-height: 1.2em; }
.gate .msgline.err { color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .detail { animation: reveal .16s ease-out; }
  @keyframes reveal { from { opacity: 0; transform: translateY(-2px); } }
}

/* =====================================================================
   Topics, artifacts, tags, agent runs, read state.
   Patterns taken from docs/mockups/round2 (tree-nav-01 + 06's status
   column, r2-03's roll-up sections, topic-artifacts-02's toggle).
   Real tokens only; no new colours beyond the kind-tag ones above.
   ===================================================================== */
.app[hidden] { display: none; }
[hidden] { display: none !important; }

.app > header { grid-row: 1; }
.switcher { grid-row: 2; }
/* pinned to the 1fr row: the switcher is display:none on desktop and would otherwise pull the body into an auto row */
.body { grid-row: 3; display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.main { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.feed { display: flex; flex-direction: column; gap: 2px; }
.side { min-height: 0; overflow-y: auto; }
.muted { color: var(--ink-3); }

@media (min-width: 900px) {
  .app.has-tree { max-width: 1180px; }
  .app.has-tree .body { grid-template-columns: 330px minmax(0, 1fr); }
  .app.has-tree .side { border-right: 1px solid var(--line); }
  .switcher, .sheet, .scrim { display: none !important; }
}
@media (max-width: 899.98px) {
  .side { display: none !important; }
}

/* ---------- phone: Topics ▾ + path ---------- */
.switcher { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0; }
.switcher .iconbtn { display: inline-flex; align-items: center; gap: 5px; }
.switcher .path { font-size: 13px; font-weight: 600; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher .path b { color: var(--ink); font-weight: 650; }
.switcher .path .s { color: var(--ink-3); font-weight: 500; }
.switcher .badge { margin-left: 0; }

.scrim { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .28); }
@media (prefers-color-scheme: dark) { .scrim { background: rgba(0, 0, 0, .55); } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-height: 82dvh; overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
  background: var(--bg); box-shadow: var(--shadow);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }

/* ---------- Latest: its own modal, independent of .sheet/.scrim so it still works at desktop widths
   where the topics sheet is replaced by the permanent sidebar and .sheet/.scrim are force-hidden ---------- */
.latest-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .28); }
@media (prefers-color-scheme: dark) { .latest-scrim { background: rgba(0, 0, 0, .55); } }
:root[data-theme="dark"] .latest-scrim { background: rgba(0, 0, 0, .55); }
.latest-sheet {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 40;
  width: min(560px, calc(100vw - 32px)); max-height: min(78dvh, 720px); overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--bg); box-shadow: var(--shadow);
  padding-bottom: 10px;
}
.latest-sheet .grab { display: none; }
.latest-sheet[hidden], .latest-scrim[hidden] { display: none; }
.latest-list { padding: 0 8px 8px; }
.latest-list .pl { cursor: pointer; }
.latest-list .pl:hover { text-decoration: underline; }
.latest-list .msg { padding: 7px 6px; border-radius: 9px; }
.latest-list .msg:hover { background: var(--surface-2); }
@media (max-width: 640px) {
  .latest-sheet { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: auto; max-height: 82dvh; border-radius: 16px 16px 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .latest-sheet .grab { display: block; }
}

/* ---------- tree panel ---------- */
.panel-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.panel-h h2 { margin: 0; flex: 1; min-width: 0; line-height: 1.4; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.panel-h .tools { display: inline-flex; gap: 12px; }
.side-foot { margin: 4px 16px 16px; font-size: 11.5px; line-height: 1.4; color: var(--ink-3); }
.linkbtn {
  border: 0; background: none; padding: 0;
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px; white-space: nowrap;
}

.tree { display: flex; flex-direction: column; padding: 2px 8px 8px; }
.tree .kids { margin-left: 10px; padding-left: 4px; border-left: 1px solid var(--line-soft); }
.tree .kids:hover { border-left-color: var(--line); }
.tree .kids .node { font-weight: 550; font-size: 13px; }
.tree-h { display: none; }
.nrow { display: flex; align-items: center; min-width: 0; }
.caret { flex: none; width: 22px; height: 30px; border: 0; background: none; padding: 0; color: var(--ink-3); font-size: 10px; transition: transform .12s; }
.caret[aria-expanded="true"] { transform: rotate(90deg); }
.caret-sp { flex: none; width: 22px; }
.node {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border: 1px solid transparent; border-radius: 9px;
  background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 600; text-align: left; line-height: 1.45;
}
.node:hover { border-color: var(--line); background: var(--surface); }
.node[aria-current="true"] { background: var(--mine); border-color: var(--mine-line); color: var(--accent); }
.node[aria-current="true"] .lbl { color: var(--accent); font-weight: 700; }
.node.hasnew .lbl { color: var(--ink); font-weight: 700; }
.node .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .sp { flex: 1; min-width: 4px; }
.node .c-ag, .node .c-new, .node .c-art { flex: none; display: inline-flex; align-items: center; justify-content: center; }
.node .c-ag:empty, .node .c-new:empty, .node .c-art:empty { display: none; }
.node .c-art { font-size: 11.5px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.node[aria-current="true"] .badge.seen { color: inherit; box-shadow: inset 0 0 0 1px currentColor; }
.sheet .node { padding: 7px 8px; font-size: 14.5px; }
.sheet .tree .kids .node { font-size: 14px; }
.sheet .caret { width: 28px; height: 38px; font-size: 11px; }
.sheet .caret-sp { width: 28px; }

/* desktop: tree-nav-06's aligned status column, added to 01's caret tree */
.side .tree-h, .side .node { --cols: minmax(0, 1fr) 72px 30px 30px; }
.side .tree-h {
  position: sticky; top: 0; z-index: 1;
  display: grid; grid-template-columns: var(--cols); align-items: center;
  padding: 4px 5px 4px 30px; margin-bottom: 2px;
  border-bottom: 1px solid var(--line); background: var(--bg);
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}
.side .tree-h span:not(:first-child) { text-align: center; }
.side .node { display: grid; grid-template-columns: var(--cols); column-gap: 0; padding-right: 4px; }
.side .node .sp { display: none; }
.side .node .c-ag:empty, .side .node .c-new:empty, .side .node .c-art:empty { display: inline-flex; }

/* ---------- lifecycle chips ---------- */
.life { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; line-height: 1.5; white-space: nowrap; color: var(--ink-3); }
.life.s-running { color: var(--accent); }
.life.s-finished { color: var(--ok); }
.life .el { font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }
/* A: dot + label (cards) */
.life.a i { flex: none; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; }
.life.a.s-running i { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.life.a.s-finished i { background: var(--ok); }
/* B: spinner / dashed ring / check (tree) */
.life.b i { flex: none; position: relative; width: 12px; height: 12px; border-radius: 50%; border: 1.5px dashed var(--ink-2); }
.life.b.s-running i { border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); }
.life.b.s-finished i { border: 0; background: var(--ok); }
.life.b.s-finished i::after { content: ""; position: absolute; left: 4px; top: 2px; width: 3px; height: 6px; border: solid var(--bg); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.life.gl { gap: 3px; }
.life.gl .el { font-size: 10.5px; font-weight: 650; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .life.b.s-running i { animation: lspin .9s linear infinite; }
  .life.a.s-running i { animation: lpulse 1.6s ease-in-out infinite; }
  @keyframes lspin { to { transform: rotate(360deg); } }
  @keyframes lpulse { 50% { opacity: .35; } }
}

/* ---------- badges, unread ---------- */
.badge {
  display: inline-block; flex: none;
  min-width: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.badge.seen { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent); }
.msg.unread .row::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.msg.unread .headline { font-weight: 650; }
.newline {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent);
}
.newline::before, .newline::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.count { font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; font-size: 11.5px; }

/* ---------- message additions: artifact kind, agent, path, tags ---------- */
.tag.k-artifact { color: var(--accent); background: var(--mine); border-color: var(--mine-line); }
.msg.is-art .row { border-left: 3px solid var(--accent); }
.art-inline-title { font-weight: 650; letter-spacing: -.01em; }
.art-inline-title::after { content: " ·"; color: var(--ink-3); font-weight: 500; }
.agent {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 10.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}
.row .agent { margin-left: 7px; vertical-align: 1px; }
.pl { display: inline-block; margin-right: 6px; font-size: 11.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.pl::before { content: "#"; color: var(--ink-3); font-weight: 500; }
.pl .s, .pl .sep { color: var(--ink-3); font-weight: 500; }
.run-h .pl, .grp-h .pl, .sec .pl { display: inline-flex; max-width: 100%; min-width: 0; }
.run-h .pl .s, .grp-h .pl .s, .sec .pl .s { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-h .pl .lf, .grp-h .pl .lf, .sec .pl .lf, .pl .sep { flex: none; }

.tg {
  display: inline-block;
  margin-left: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: 1px;
  white-space: nowrap;
}
.tg:hover { border-color: var(--ink-3); }
.tg.t-bug          { color: #8c1d18; background: #ffe0dd; border-color: #f2c0bb; }
.tg.t-needs-review { color: #8a4b00; background: #ffe9c2; border-color: #f0d09a; }
.tg.t-pick         { color: #145c39; background: #d6f3e4; border-color: #aee0c8; }
@media (prefers-color-scheme: dark) {
  .tg.t-bug          { color: #ffb0a6; background: #401a16; border-color: #5f2b25; }
  .tg.t-needs-review { color: #ffcd7a; background: #3d2c0d; border-color: #5b431a; }
  .tg.t-pick         { color: #8ae5b6; background: #103526; border-color: #1d5138; }
}
.tg[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tg .n { opacity: .7; font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------- links: web chips, and file:// with a copyable path ---------- */
.linkline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; max-width: 100%; margin-top: 4px; }
.linkline .chip { margin-top: 0; }
.chip.file::before { content: "▤"; }
.chip.unopened { border-color: var(--accent); font-weight: 700; }
.copy {
  flex: none; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
  padding: 2px 9px; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.copy:hover { border-color: var(--ink-3); color: var(--ink); }
.fpath {
  min-width: 0; flex: 1 1 auto; padding: 3px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-soft);
  font: 500 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2);
  overflow-wrap: anywhere; user-select: all; -webkit-user-select: all;
}

/* ---------- agent run card ---------- */
.run {
  align-self: stretch;
  margin: 4px 0;
  padding: 8px 11px 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.run.unread { border-color: var(--mine-line); }
.run.unread .run-sum { font-weight: 650; }
.run-h { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; row-gap: 3px; }
.run-h .pl { margin-right: 0; flex: 0 1 auto; }
.run-h .life, .run-h .agent, .run-h .newtag { flex: none; }
.run-h .time { margin-left: auto; flex: none; }
.newtag { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.run-sum {
  margin-top: 4px;
  font-size: 14.5px; letter-spacing: -.005em; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.run-f { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.run-f .chip, .run-f .linkline { margin: 0; max-width: 100%; }
.run-f .tg { margin-left: 0; }
.run-f .tgs { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.run-f .more { margin-left: auto; }
.run .detail { margin-top: 7px; }
.steps { margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 4px; list-style: none; }
.steps li { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; color: var(--ink-2); white-space: normal; }
.steps .time { margin-left: 0; flex: none; min-width: 58px; }
.steps .life { flex: none; }
.sub {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 7px; padding: 5px 0 1px 9px;
  border-left: 2px solid var(--line);
  font-size: 12.5px; color: var(--ink-2);
}
.sub .agent { font-size: 10px; }
.sub .txt { flex: 1 1 160px; min-width: 0; }
.sub .time { margin-left: auto; }
.sub .sub-arts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 5px; }
.sub .sub-arts .chip, .sub .sub-arts .linkline { margin: 0; }
.sub.unread .txt { color: var(--ink); }
.sub.unread .txt::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.subs { margin-left: 12px; }

/* ---------- view bar: Thread / Artifacts, Only here / + sub-topics ---------- */
.viewbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); flex: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; border-radius: 999px;
  padding: 3px 11px; font-size: 12px; font-weight: 600; color: var(--ink-2); line-height: 1.5; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button[aria-pressed="true"] .badge { background: var(--accent-ink); color: var(--accent); }
.seg .n { font-weight: 500; opacity: .75; font-variant-numeric: tabular-nums; }

.tagrow { display: flex; align-items: center; gap: 5px; padding: 6px 12px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; white-space: nowrap; scrollbar-width: none; background: var(--bg); }
.tagrow::-webkit-scrollbar { display: none; }
.tagrow .tg { margin-left: 0; font-size: 11.5px; padding: 1px 9px; flex: none; }
.tagrow .lead { flex: none; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-right: 2px; }

.filterbar {
  position: sticky; top: -10px; z-index: 2;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 2px 0 6px; padding: 7px 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
  background: var(--surface-2); font-size: 13px; color: var(--ink-2);
  box-shadow: 0 4px 10px -6px rgba(0, 0, 0, .18);
}
.filterbar .tg { margin-left: 0; }
.filterbar .sp { flex: 1; min-width: 60px; }
.empty2 { padding: 18px 14px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ---------- roll-up: one section per sub-topic ---------- */
.sec { margin: 6px 0 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.sec > summary { list-style: none; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 8px 11px; cursor: pointer; border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: "▶"; flex: none; font-size: 9px; color: var(--ink-3); transition: transform .12s; }
.sec[open] > summary::before { transform: rotate(90deg); }
.sec[open] > summary { border-bottom: 1px solid var(--line-soft); border-radius: var(--radius) var(--radius) 0 0; }
.sec > summary .pl { font-size: 12.5px; margin-right: 0; }
.sec > summary .sp { flex: 1; }
.sec > summary .badge { margin-left: 0; }
.sec > summary .time { margin-left: 0; }
.sec > summary .last { flex-basis: 100%; padding-left: 16px; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec[open] > summary .last { display: none; }
.sec .body { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px 8px; }
.sec .body .daysep { margin: 8px 0 4px; }

/* ---------- artifacts view ---------- */
.grp { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.grp-h { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 7px 12px 6px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.grp-h .pl { margin-right: 0; flex: 0 1 auto; overflow: hidden; }
.grp-h .count { flex: none; }
.grp-h .badge { margin-left: auto; }
.art-row { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px 10px; border-bottom: 1px solid var(--line-soft); }
.art-row:last-child { border-bottom: 0; }
.art-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.art-top .time { margin-left: auto; flex: none; }
.art-title { font-size: 14px; font-weight: 650; letter-spacing: -.01em; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; text-decoration: none; min-width: 0; }
a.art-title:hover { color: var(--accent); }
.art-row.unread .art-title::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 2px; }
.art-headline { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.art-link { display: flex; align-items: center; gap: 6px; margin-top: 3px; min-width: 0; }
.art-link .chip { margin-top: 0; }
.art-row .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.art-row .meta .tg { margin-left: 0; }

/* ---------- routine: is this channel wired to a Claude Code Routine? ---------- */
.rt-dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.rt-dot.s-ok { border-color: var(--ok); background: var(--ok); }
.rt-dot.s-fail { border-color: var(--danger); background: var(--danger); }
.rt-dot.s-never { border-color: var(--ink-3); background: var(--ink-3); }
.rt-dot.s-pending { border-color: var(--accent); background: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .rt-dot.s-pending { animation: lpulse 1.2s ease-in-out infinite; } }
.node .lbl .rt-dot { width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; border-width: 1.4px; }

.rtbar { border-bottom: 1px solid var(--line); background: var(--bg); }
.rt-sum {
  display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0;
  padding: 6px 12px; border: 0; background: none; text-align: left;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5;
}
.rt-sum:hover { background: var(--surface-2); }
.rt-sum b { flex: none; font-weight: 650; color: var(--ink); }
.rt-sum .rt-tail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-sum.s-fail .rt-tail { color: var(--danger); }
.rt-sum .sp { flex: 1; }
.rt-sum .rt-more { flex: none; font-size: 11.5px; font-weight: 600; color: var(--accent); }
.rt-panel { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; font-size: 12.5px; color: var(--ink-2); }
.rt-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-3); }
.rt-meta code, .rt-fires code { font: 500 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); overflow-wrap: anywhere; }
.rt-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rt-acts .hint { font-size: 11.5px; color: var(--ink-3); }
.iconbtn.warnbtn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.iconbtn:disabled { opacity: .5; cursor: default; }
.rt-checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.rt-checks li { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 6px; }
.rt-checks .ic { font-weight: 700; text-align: center; }
.rt-checks .l-ok .ic { color: var(--ok); }
.rt-checks .l-warn .ic { color: var(--accent); }
.rt-checks .l-fail .ic { color: var(--danger); }
.rt-checks b { font-weight: 600; color: var(--ink); }
.rt-checks .d { grid-column: 2; color: var(--ink-3); font-size: 11.5px; overflow-wrap: anywhere; }
.rt-confirm { margin: 0; border-left-color: var(--danger); display: flex; flex-direction: column; gap: 8px; }
.rt-confirm label { display: flex; align-items: flex-start; gap: 7px; color: var(--ink); font-weight: 550; }
.rt-confirm input { margin-top: 3px; }
.rt-result { padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rt-result.bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.rt-result a { color: var(--accent); font-weight: 600; }
.rt-fires ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.rt-fires h3 { margin: 0 0 2px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.rt-fires li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.rt-fires .time { margin-left: 0; min-width: 92px; }
.rt-fires .bad { color: var(--danger); }
.rt-fires a { color: var(--accent); font-weight: 600; font-size: 11.5px; }

/* ---------- @Bo: posts that need Bo's own call ---------- */
.tg.t-needs-bo { color: #8c1d18; background: #ffe0dd; border-color: #f2c0bb; font-weight: 700; }
@media (prefers-color-scheme: dark) { .tg.t-needs-bo { color: #ffb0a6; background: #401a16; border-color: #5f2b25; } }
.iconbtn.needs { color: #8c1d18; border-color: #f2c0bb; background: #ffe0dd; font-weight: 700; }
.iconbtn.needs .badge { margin-left: 6px; background: #8c1d18; color: #fff; }
.iconbtn.needs[aria-pressed="true"] { background: #8c1d18; border-color: #8c1d18; color: #fff; }
.iconbtn.needs[aria-pressed="true"] .badge { background: #fff; color: #8c1d18; }
@media (prefers-color-scheme: dark) {
  .iconbtn.needs { color: #ffb0a6; border-color: #5f2b25; background: #401a16; }
  .iconbtn.needs .badge { background: #ffb0a6; color: #401a16; }
  .iconbtn.needs[aria-pressed="true"] { background: #ffb0a6; border-color: #ffb0a6; color: #401a16; }
  .iconbtn.needs[aria-pressed="true"] .badge { background: #401a16; color: #ffb0a6; }
}
