:root {
  --bg: #ffffff;
  --bg-2: #f7f7f6;
  --bg-3: #efefed;
  --line: #e9e9e6;
  --line-2: #dcdcd8;
  --fg: #111111;
  --fg-2: #55554f;
  --fg-3: #8e8e88;
  --accent: #111111;
  --on-accent: #ffffff;
  --attn: #b45309;
  --attn-soft: #fbf3e8;
  --ok: #15803d;
  --term-bg: #fbfbfa;
  --term-fg: #1b1b1b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.05), 0 18px 48px rgba(0,0,0,.10);
  --side-w: 300px;
  --col: 780px; /* the conversation column */
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, "MesloLGS NF", "Symbols Nerd Font Mono", Menlo, Consolas, monospace;
  --vh: 100dvh;
  color-scheme: light;
}
/* Dark: follows the system unless the viewer picked a theme (偏好设置). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --bg-2: #131315;
    --bg-3: #1c1c1f;
    --line: #232326;
    --line-2: #313135;
    --fg: #ededeb;
    --fg-2: #a6a6a0;
    --fg-3: #6d6d68;
    --accent: #f2f2f0;
    --on-accent: #0b0b0c;
    --attn: #f0a24a;
    --attn-soft: #21190f;
    --ok: #4ade80;
    --term-bg: #0f0f11;
    --term-fg: #e6e6e3;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 18px 48px rgba(0,0,0,.55);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .brand img, :root:not([data-theme="light"]) .blank img, :root:not([data-theme="light"]) .login-mark, :root:not([data-theme="light"]) .nav-ico img, :root:not([data-theme="light"]) .avatar img { filter: invert(1); }
}
:root[data-theme="dark"] {
  --bg: #0b0b0c;
  --bg-2: #131315;
  --bg-3: #1c1c1f;
  --line: #232326;
  --line-2: #313135;
  --fg: #ededeb;
  --fg-2: #a6a6a0;
  --fg-3: #6d6d68;
  --accent: #f2f2f0;
  --on-accent: #0b0b0c;
  --attn: #f0a24a;
  --attn-soft: #21190f;
  --ok: #4ade80;
  --term-bg: #0f0f11;
  --term-fg: #e6e6e3;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 18px 48px rgba(0,0,0,.55);
  color-scheme: dark;
}
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .blank img, :root[data-theme="dark"] .login-mark, :root[data-theme="dark"] .nav-ico img, :root[data-theme="dark"] .avatar img { filter: invert(1); }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--fg-3); }
.mono { font-family: var(--mono); }
a { color: inherit; }

/* ─── controls ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--bg); font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:hover { background: var(--bg-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--fg); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: var(--fg-2); flex: none;
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }

input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--bg); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--fg-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 8%, transparent); }
input[type=checkbox] { width: auto; accent-color: var(--fg); }

/* ─── login ─── */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg-2); }
.login-card {
  width: min(360px, 100%); padding: 36px 28px 28px; text-align: center; display: grid; gap: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.login-mark { width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 16px; border: 1px solid var(--line); }
.login-card h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 8px; }
.login-error { color: var(--attn); min-height: 1.5em; margin: 0 !important; font-size: 13px; }

/* ─── layout ─── */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: var(--vh); }
/* Phones: when the keyboard opens, the browser scrolls the page under the
   visible area. Pin the app to that area so the input stays in view. */
@media (pointer: coarse) {
  .app { position: fixed; top: 0; left: 0; right: 0; transform: translateY(var(--vtop, 0px)); }
  /* Below 16px, iOS zooms the page in on focus. */
  input, textarea, select, .composer textarea { font-size: 16px; }
}
.side {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--bg-2); padding-top: env(safe-area-inset-top);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 10px 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); }

.side-nav { display: grid; gap: 2px; padding: 4px 8px 6px; }
.nav-item, .item {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; text-decoration: none; transition: background .12s;
}
.nav-item:hover, .item:hover { background: var(--bg-3); }
.nav-item.active, .item.active { background: var(--bg); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); }
.nav-ico { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--fg-2); }
.nav-ico img { width: 22px; height: 22px; }
.nav-ico svg { width: 16px; height: 16px; }
.body { min-width: 0; }
.name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 12px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-family: var(--mono); }
.count-pill { font: 600 11px/1 var(--sans); padding: 4px 7px; border-radius: 999px; background: var(--fg); color: var(--bg); }

.side-scroll { flex: 1; overflow: auto; padding: 0 8px 16px; border-top: 1px solid var(--line); margin-top: 4px; }
.group { margin-top: 14px; }
.group h2, .group summary {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-3); margin: 0; padding: 0 10px 6px; list-style: none;
}
.group summary { cursor: pointer; }
.group summary::-webkit-details-marker { display: none; }
.group summary h2 { padding: 0; display: inline; }
.count { font-weight: 500; margin-left: 4px; }
.list { list-style: none; margin: 0; padding: 0; }
.empty-hint { margin: 2px 10px; color: var(--fg-3); font-size: 13px; }
.item .glyph { width: 26px; height: 22px; display: grid; place-items: center; color: var(--fg-2); }
.item .glyph svg { width: 18px; height: 18px; }
.attn .item { background: var(--attn-soft); }
.tag { font: 500 10px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--fg-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 5px; }

.side-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px 10px 18px; border-top: 1px solid var(--line); font-size: 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.foot-status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.foot-status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; }
.conn.on { background: var(--ok); }
.conn.off { background: var(--attn); }

/* ─── status dots ─── */
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.unknown, .dot.shell, .dot.asleep, .dot.starting, .dot.gone { box-shadow: inset 0 0 0 1.5px var(--fg-3); }
.dot.done { background: var(--fg); }
.dot.failed { background: var(--fg-3); }
.dot.working, .dot.starting { box-shadow: inset 0 0 0 1.5px var(--fg); }
.dot.working::after, .dot.starting::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid transparent; border-top-color: var(--fg); animation: spin .9s linear infinite;
}
/* waiting: a dashed ring turning slowly, like a timer: nothing to do
   right now, something still running. */
.dot.waiting { box-sizing: border-box; border: 1.5px dashed var(--fg-3); animation: spin 6s linear infinite; }
.dot.blocked { background: var(--attn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--attn) 22%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }
/* How much a dot moves says how alive it is: spinning = busy, breathing =
   open and waiting (an agent at its prompt, an app session kept in the
   background), still ring = not running. Amber is the only colour: you. */
.dot.idle { background: var(--fg-3); animation: rest 3.2s ease-in-out infinite; }
@keyframes rest { 0%, 100% { opacity: .3; } 50% { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .dot.idle { animation: none; opacity: .6; } }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); white-space: nowrap; flex: none; }
.status.blocked { color: var(--attn); font-weight: 500; }

/* ─── main ─── */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; min-height: 0; flex: 1; padding-top: env(safe-area-inset-top); }
.d-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 61px; }
.back { display: none; margin-left: -6px; }
.d-title { flex: 1; min-width: 0; }
.d-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.d-name > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-name > .kind, .d-name > .tag { flex: none; }
.kind { font: 500 11px/1 var(--mono); color: var(--fg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 6px; }
.kind:empty { display: none; }
.d-meta { display: flex; align-items: center; gap: 12px; margin-top: 2px; min-width: 0; font-size: 12px; }
.d-meta .mono { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-meta > * { white-space: nowrap; flex: none; }
.d-meta > .mono { flex: 0 1 auto; min-width: 0; }
@media (max-width: 700px) { #d-model { display: none; } }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-3); flex: none; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 13px; color: var(--fg-2); }
.seg button.on { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-sm); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 40px; z-index: 20; min-width: 190px; padding: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; }
.menu button:hover { background: var(--bg-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.danger { color: #c2410c; }

/* ─── viewer ─── */
.viewer { position: relative; flex: 1; min-height: 0; background: var(--term-bg); }
.viewer.chatbg { background: var(--bg); overflow: auto; }
.viewer > .screen, .viewer > .log, .viewer > .chat { display: none; }
.viewer[data-mode="screen"] > .screen, .viewer[data-mode="log"] > .log { display: block; }
.viewer[data-mode="chat"] > .chat { display: flex; }
.viewer[data-mode="chat"] { background: var(--bg); }
.viewer[data-mode="chat"] ~ .keys:not(.open) { display: none; }
.screen { position: absolute; inset: 0; overflow: auto; padding: 14px 16px; }
.screen .xterm { width: max-content; }
.screen .xterm-viewport { background: transparent !important; overflow: hidden !important; }
.log {
  position: absolute; inset: 0; margin: 0; overflow: auto; padding: 16px 18px 28px;
  font: 12.5px/1.6 var(--mono); color: var(--term-fg); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.jump {
  position: absolute; right: 16px; bottom: 16px; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg); box-shadow: var(--shadow);
}
.gone { position: absolute; inset: auto 0 0 0; padding: 10px; text-align: center; background: var(--attn-soft); color: var(--attn); font-size: 13px; }

/* ─── conversation ─── */
.chat { position: absolute; inset: 0; flex-direction: column; }
.thread {
  flex: 1; overflow: auto; overscroll-behavior: contain;
  padding: 32px max(20px, calc((100% - var(--col)) / 2)) 24px;
  display: flex; flex-direction: column; gap: 0;
}
/* Rhythm: a turn gets real space; quiet rows (tools, events) sit close. */
.thread > * + * { margin-top: 28px; }
.thread > .tools + .tools, .thread > .event + .event, .thread > .event + .needs { margin-top: 8px; }
.thread > .tools, .thread > * + .tools { margin-top: 14px; }
.thread > .tools + .msg, .thread > .tools + .say { margin-top: 22px; }
.chatbg .thread { overflow: visible; min-height: 100%; }
/* "还在跑" follows the last message instead of sitting at the bottom. */
.chatbg .thread:has(+ .working-row:not([hidden])) { min-height: 0; }
.thread-empty { margin: auto; text-align: center; color: var(--fg-3); font-size: 13px; }
.msg { max-width: 100%; min-width: 0; font-size: var(--msg-fs, 15px); line-height: 1.75; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end; max-width: min(84%, 620px); background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; line-height: 1.6;
}
.msg.assistant { align-self: stretch; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 1em; }
.msg.assistant h2, .msg.assistant h3, .msg.assistant h4 { font-size: 15.5px; font-weight: 600; margin: 1.5em 0 .5em; letter-spacing: -.01em; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 1em; padding-left: 1.3em; }
.msg.assistant li { margin: .4em 0; padding-left: .15em; }
.msg.assistant li::marker { color: var(--fg-3); }
.msg.assistant a { text-underline-offset: 2px; }
.msg code { font: .86em var(--mono); background: color-mix(in srgb, var(--bg-3) 55%, transparent); padding: .08em .3em; border-radius: 4px; }
.msg.user code { background: color-mix(in srgb, var(--on-accent) 14%, transparent); }
.msg pre { margin: .2em 0 1em; padding: 14px 16px; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; font: 12.5px/1.55 var(--mono); }
.msg pre code { background: none; padding: 0; font-size: inherit; }
.msg.assistant blockquote { margin: 0 0 .7em; padding-left: 12px; border-left: 2px solid var(--line-2); color: var(--fg-2); }

/* collie replies carry a small avatar */
/* hovering a message in Collie's chat shows its time beside it */
#v-collie .msg[data-time] { position: relative; }
#v-collie .msg[data-time]::after {
  content: attr(data-time); position: absolute; bottom: 4px; white-space: nowrap; pointer-events: none;
  font-size: 11px; color: var(--fg-3); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .12s;
}
#v-collie .msg.user[data-time]::after { right: calc(100% + 10px); }
#v-collie .msg[data-time]:hover::after, #v-collie .msg.show-time::after { opacity: 1; }
/* Phones: tap a message and its time shows on a line of its own under it. */
@media (hover: none) {
  #v-collie .msg[data-time]::after, #v-collie .say .msg[data-time]::after { position: static; display: none; width: auto; margin-top: 4px; font-size: 11px; text-align: inherit; opacity: 1; }
  #v-collie .msg.show-time::after, #v-collie .say .msg.show-time::after { display: block; }
  #v-collie .msg.user.show-time::after { color: inherit; opacity: .6; }
}
.mem-crew { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.mem-crew a { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-2); text-decoration: none; }
.mem-crew a[href]:hover { color: var(--fg); }
.mem-crew + .grow::before { content: "·"; margin-right: 8px; }
/* What a reply answers: one quiet line above it. */
#v-collie .re { display: block; max-width: 100%; margin: 0 0 6px; padding-left: 8px; border-left: 2px solid var(--line-2);
  font-size: 12px; line-height: 18px; color: var(--fg-3); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#v-collie .re-who { color: var(--fg-2); margin-right: 6px; }
#v-collie .msg.user .re { color: inherit; opacity: .6; border-left-color: currentColor; }
#v-collie .msg.user .re-who { color: inherit; }
/* Under a Collie message: copy, quote, its time. The row keeps its place
   and shows on hover; on a phone it opens when you tap the message. */
/* It takes no room of its own: it sits in the gap before the next item
   (and keeps its room only when a close follow-up message leaves no gap). */
.msg-acts { display: flex; align-items: center; gap: 2px; height: 24px; margin: 0 0 -24px -6px; color: var(--fg-3); position: relative; z-index: 1;
  opacity: 0; pointer-events: none; transition: opacity .12s; }
#v-collie .say:hover .msg-acts, #v-collie .msg.show-time .msg-acts { opacity: 1; pointer-events: auto; }
/* your own message: the row sits under the bubble's right edge */
#v-collie .mine { display: flex; flex-direction: column; align-items: flex-end; align-self: stretch; }
#v-collie .mine .msg-acts { justify-content: flex-end; margin: 2px -6px -26px 0; }
#v-collie .say:has(+ .say.cont) .msg-acts { margin-bottom: 0; }
#v-collie .mine .msg-acts .t { margin: 0 6px 0 0; }
#v-collie .mine:hover .msg-acts, #v-collie .mine .msg.show-time + .msg-acts { opacity: 1; pointer-events: auto; }
.msg-acts button { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; }
.msg-acts button:hover { background: var(--bg-2, rgba(127,127,127,.12)); color: var(--fg); }
.msg-acts svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg-acts .t { margin-left: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
@media (hover: none) {
  .msg-acts, #v-collie .mine .msg-acts { display: none; margin-bottom: 0; }
  #v-collie .msg.show-time .msg-acts, #v-collie .mine .msg.show-time + .msg-acts { display: flex; }
}
.re-draft { display: flex; align-items: center; gap: 6px; margin: 10px 12px 0; padding-left: 8px; border-left: 2px solid var(--line-2); font-size: 12px; line-height: 18px; color: var(--fg-3); min-width: 0; }
.re-draft[hidden] { display: none; }
.re-draft .re-who { flex: none; color: var(--fg-2); }
.re-draft .re-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.re-draft button { flex: none; border: 0; background: none; color: var(--fg-3); font-size: 15px; line-height: 1; padding: 0 4px; cursor: pointer; }
.re-draft button:hover { color: var(--fg); }
#v-collie a.re[href]:hover { color: var(--fg-2); border-left-color: var(--fg-3); }
#v-collie .msg.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 25%, transparent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.time-sep { margin: 18px 0 6px; text-align: center; font-size: 11px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.say { display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: start; }
.avatar { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; background: var(--bg); margin-top: 2px; }
.avatar img { width: 20px; height: 20px; }

.thread > .say.cont { margin-top: 10px; }
.say.cont .avatar { border-color: transparent; background: none; }

/* system events in the super-agent conversation: one quiet row each,
   lined up with the messages (dot under the avatar column) */
.event {
  align-self: stretch; display: grid; grid-template-columns: 26px auto minmax(0, 1fr); gap: 12px; align-items: center;
  margin-inline: -8px; padding: 3px 8px; border-radius: 8px; border: 1px solid transparent;
  font-size: 12.5px; color: var(--fg-3); text-decoration: none; min-width: 0;
}
.event > .dot { justify-self: center; }
a.event:hover { background: var(--bg-2); color: var(--fg); }
.event span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event.error {
  align-items: start; border-radius: 12px; padding: 8px;
  color: var(--attn); border-color: color-mix(in srgb, var(--attn) 30%, var(--line)); background: color-mix(in srgb, var(--attn) 6%, var(--bg));
}
.event.error span:last-child { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.event.error .dot { margin-top: 6px; }
.event.error .when { margin-top: 1px; }
.event .when { color: var(--fg-3); font-variant-numeric: tabular-nums; }

.tools { display: flex; flex-direction: column; gap: 0; align-self: stretch; }
.tool summary {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px; margin: 0 -8px;
  border-radius: 8px; cursor: pointer; list-style: none; color: var(--fg-3); font-size: 13px; line-height: 1.6;
}
.tool summary::-webkit-details-marker { display: none; }
.tool summary:hover { background: var(--bg-2); }
.tool summary::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--fg-3); flex: none; }
.tool.err summary::before { background: var(--attn); }
.tool.pending summary::before { background: none; box-shadow: inset 0 0 0 1.5px var(--fg-3); }
.tool .tname { font-weight: 500; color: var(--fg-2); flex: none; }
.tool .targ { font: 12px var(--mono); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tool pre {
  margin: 4px 0 8px 13px; padding: 10px 12px; max-height: 280px; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  font: 12px/1.5 var(--mono); color: var(--fg-2); white-space: pre-wrap; word-break: break-word;
}
.termcard {
  margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--term-bg);
  font: 12.5px/1.6 var(--mono); color: var(--term-fg); white-space: pre-wrap; word-break: break-word;
}
.fallback-note { font-size: 12px; color: var(--fg-3); text-align: center; }

.live { padding: 0 max(20px, calc((100% - var(--col)) / 2)) 14px; }
.live-working { display: flex; gap: 10px; align-items: flex-start; color: var(--fg-3); font-size: 12px; }
.live-working .dot { margin-top: 5px; }
.live-working .meta { flex: none; font: 11px/18px var(--mono); color: var(--fg-3); opacity: .8; font-variant-numeric: tabular-nums; }
.live-working pre { margin: 0; flex: 1; min-width: 0; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow: hidden; max-height: 4.5em; }

/* ─── approval: a calm decision sheet ─── */
.ask {
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: rise .22s ease-out;
}
.ask-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; font-size: 12px; color: var(--fg-3); }
.ask-head .who { color: var(--fg-2); font-weight: 500; }
.ask-head .spacer { flex: 1; }
.ask-head button { border: 0; background: none; color: var(--fg-3); font-size: 12px; padding: 2px 4px; }
.ask-head button:hover { color: var(--fg); }
.ask-q { padding: 10px 18px 16px; }
.ask-q .q { font-size: 16px; font-weight: 600; letter-spacing: -.01em; line-height: 1.45; text-wrap: pretty; }
.ask-q .ctx { margin-top: 8px; max-height: 32vh; overflow: auto; color: var(--fg-2); font-size: 13.5px; line-height: 1.65; overflow-wrap: anywhere; }
.ask-q .ctx p { margin: 0 0 6px; text-wrap: pretty; }
.ask-q .ctx p:last-child, .ask-q .ctx pre:last-child { margin-bottom: 0; }
.ask-q .ctx-code { margin: 2px 0 8px; padding: 7px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); font: 12.5px/1.5 var(--mono); color: var(--fg); white-space: pre-wrap; word-break: break-all; }
.ask-raw { margin: 0 16px 12px; padding: 10px 12px; max-height: 30vh; overflow: auto; border-radius: 10px; background: var(--term-bg); border: 1px solid var(--line); font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.choices { border-top: 1px solid var(--line); }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 14px;
  transition: background .12s;
}
.choice:last-child { border-bottom: 0; }
.choice:hover { background: var(--bg-2); }
.choice:active { background: var(--bg-3); }
.choice .n { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--line-2); font: 500 11px var(--mono); color: var(--fg-2); }
.choice .l { flex: 1; min-width: 0; }
.choice .l .d { display: block; margin-top: 2px; font-size: 12.5px; color: var(--fg-3); font-weight: 400; }
.choice .hint { font-size: 11px; color: var(--fg-3); }
.choice.current .n { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.choice.current .l { font-weight: 500; }
.ask-keys { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-2); }
.ask-keys button {
  height: 32px; min-width: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg); font-size: 13px; color: var(--fg-2);
}
.ask-keys button.go { margin-left: auto; background: var(--fg); border-color: var(--fg); color: var(--bg); font-weight: 500; }
.ask-keys button:hover { color: var(--fg); }
.ask-keys button.go:hover { color: var(--bg); opacity: .9; }

/* attention cards in the Collie conversation */
.needs { display: grid; gap: 8px; }
.need {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none;
}
.need .body { flex: 1; min-width: 0; }
.need .body .name { font-size: 13px; }
.need .body .sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.need .go { font-size: 12px; color: var(--fg-2); flex: none; margin-left: 8px; white-space: nowrap; }
.need:hover .go { color: var(--fg); }

/* crew strip: active workers */
.crew { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.crew::-webkit-scrollbar { display: none; }
.crew:empty { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; text-decoration: none; background: var(--bg);
}
.chip:hover { border-color: var(--line-2); }
.chip .k { color: var(--fg-3); font-family: var(--mono); font-size: 11px; }

/* empty state for Collie */
.hello { margin: auto; max-width: 520px; text-align: center; padding: 24px 8px; }
.hello img { width: 64px; height: 64px; border-radius: 16px; border: 1px solid var(--line); }
.hello h3 { margin: 16px 0 6px; font-size: 18px; letter-spacing: -.01em; }
.hello p { margin: 0 0 18px; color: var(--fg-3); line-height: 1.7; }
.ideas { display: grid; gap: 8px; text-align: left; }
.ideas button {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 11px 14px; text-align: left;
  color: var(--fg-2); font-size: 13px; transition: border-color .15s, color .15s;
}
.ideas button:hover { border-color: var(--line-2); color: var(--fg); }

/* key bar */
.keys { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); }
.keys::-webkit-scrollbar { display: none; }
.keys button {
  flex: none; min-width: 38px; height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--bg); font: 500 12px/1 var(--mono); color: var(--fg-2);
}
.keys button:hover { color: var(--fg); border-color: var(--fg-3); }
.keys button:active { background: var(--bg-3); }

/* composer: one box as wide as the conversation column */
.composer { padding: 6px max(12px, calc((100% - var(--col) - 24px) / 2)) 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.cbox {
  display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 18px; background: var(--bg);
  box-shadow: var(--shadow); transition: border-color .15s;
}
.cbox:focus-within { border-color: var(--fg-3); }
.composer.drop .cbox { border-color: var(--accent); border-style: dashed; }
.composer textarea {
  resize: none; max-height: calc(var(--vh) * .4); min-height: 44px; line-height: 1.5; padding: 12px 16px 4px;
  border: 0; border-radius: 18px; background: transparent; box-shadow: none; outline: none;
}
.cbar { display: flex; align-items: center; gap: 4px; padding: 4px 8px 8px; }
.cbar .spacer { flex: 1; }
/* The dispatch chips scroll sideways on narrow screens; send stays put. */
.cbar .chips { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; }
@media (max-width: 760px) { .cbar .chips { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); } }
.cbar .chips::-webkit-scrollbar { display: none; }
.cbar .chips > * { flex: none; }
.cbar > .send, .cbar > .attach { flex: none; }
.cbar .icon-btn { width: 32px; height: 32px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 10px 0; }
.file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 4px 4px 6px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); font-size: 12px; color: var(--fg-2);
}
.file img, .file svg { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: none; }
.file svg { padding: 4px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.file .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.file .fs { color: var(--fg-3); flex: none; }
.file.busy { opacity: .6; }
.file.err { border-color: color-mix(in srgb, var(--attn) 40%, var(--line)); }
.file.err .fs { color: var(--attn); }
.file button { border: 0; background: none; color: var(--fg-3); width: 20px; height: 20px; border-radius: 6px; font-size: 15px; line-height: 1; cursor: pointer; }
.file button:hover { background: var(--bg-3); color: var(--fg); }
.detail.shell .attach { display: none; }
.msg.user .att { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg.user .att span { font-size: 12.5px; padding: 2px 8px; border-radius: 8px; background: color-mix(in srgb, var(--on-accent) 14%, transparent); }
.send { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 0; background: var(--accent); color: var(--on-accent); transition: transform .1s, opacity .15s; }
.send svg { width: 17px; height: 17px; }
.send:active { transform: scale(.94); }
.send:disabled { opacity: .35; }
.kbd-toggle { display: none; align-self: center; }
.detail.chat-mode .kbd-toggle { display: inline-grid; }
.kbd-toggle.on { background: var(--bg-3); color: var(--fg); }

/* ─── automation ─── */
.tabs { display: flex; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--fg-2); font-size: 13px; }
.tabs button.on { background: var(--bg-3); color: var(--fg); font-weight: 500; }
.auto-body { flex: 1; overflow: auto; padding: 20px max(16px, calc((100% - 820px) / 2)) 40px; }
.panel-intro { margin: 0 0 16px; color: var(--fg-3); font-size: 13px; line-height: 1.7; }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); overflow: hidden; margin-bottom: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--fg-3); }
.row .meta b { color: var(--fg-2); font-weight: 500; font-family: var(--mono); }
.row .text { margin-top: 4px; font-size: 13px; color: var(--fg); white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row .right { font-size: 12px; color: var(--fg-3); white-space: nowrap; }
.badge { font: 500 11px/1 var(--sans); padding: 4px 7px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--fg-2); white-space: nowrap; }
.badge.queued { border-color: var(--fg); color: var(--fg); }
.badge.ignored { color: var(--fg-3); border-style: dashed; }
.badge.candidate { color: var(--attn); border-color: color-mix(in srgb, var(--attn) 40%, transparent); }
.empty-row { padding: 22px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
.form { display: grid; gap: 12px; padding: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.form label small { font-weight: 400; color: var(--fg-3); }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.code {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line);
  font: 12px/1.5 var(--mono); word-break: break-all;
}
.code span { flex: 1; min-width: 0; }
.policy { display: grid; grid-template-columns: 1.3fr 1fr 1.4fr auto; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.policy:last-child { border-bottom: 0; }
.policy input, .policy select, .policy .pick { padding: 7px 10px; font-size: 13px; }

/* ─── sheet ─── */
.sheet {
  width: min(560px, calc(100vw - 32px)); max-height: calc(var(--vh) - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--fg); box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgba(10,10,10,.28); backdrop-filter: blur(3px); }
.sheet form { display: flex; flex-direction: column; max-height: inherit; }
/* One scroller: the body. The dialog itself never scrolls (its border would
   otherwise make the form 2px too tall and add a second scrollbar). */
dialog.sheet[open] { display: flex; flex-direction: column; overflow: hidden; }
dialog.sheet > form { flex: 1 1 auto; min-height: 0; max-height: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.sheet-head h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.sheet-body { overflow: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sheet-note { margin: 0; padding: 0 20px 4px; font-size: 12px; line-height: 1.6; }
.sheet .field { padding: 10px 20px; }
/* file viewer: a third column on wide screens that grows open, full screen
   on narrow ones, sliding in from the right */
.app { transition: grid-template-columns .36s cubic-bezier(.32, .72, 0, 1); }
@media (min-width: 1001px) {
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr) 0px; }
  .app.has-file { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--file-w, 600px); }
}
body.dragging .app { transition: none; }
.filepane { position: relative; display: flex; justify-content: flex-end; min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--bg); }
.filepane[hidden] { display: none; }
.fv-inner { display: flex; flex-direction: column; flex: none; width: var(--file-w, 600px); height: 100%; }
.fv-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; }
.fv-grip:hover, body.dragging .fv-grip { background: linear-gradient(90deg, transparent 3px, var(--line-2) 3px, var(--line-2) 5px, transparent 5px); }
body.dragging { cursor: col-resize; user-select: none; }
.fv-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 4px 20px; }
.fv-head h3 { flex: 1; margin: 0; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-back { display: none; }
#fv-path { margin: 0; padding: 0 20px 10px; font: 11px/1.5 var(--mono); overflow-wrap: anywhere; border-bottom: 1px solid var(--line); }
.fv-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 20px 24px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.fv-md { max-width: none; background: none; padding: 0; }
.fv-pre { margin: 14px 0 0; font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.fv-img { padding-top: 16px; text-align: center; }
.fv-img img { max-width: 100%; height: auto; border-radius: 8px; }
.fv-note { margin: 16px 0 0; font-size: 13px; }
@media (max-width: 1000px) {
  .app.has-file { grid-template-columns: var(--side-w) 1fr; }
  .filepane { position: fixed; inset: 0; z-index: 50; border-left: 0; transform: translateX(100%);
    transition: transform .36s cubic-bezier(.32, .72, 0, 1); box-shadow: -12px 0 32px rgba(0,0,0,.08); }
  .app.has-file .filepane { transform: none; }
  .fv-inner { width: 100%; }
  .fv-grip, .fv-x { display: none; }
  .fv-back { display: inline-grid; }
  .fv-head { padding: 10px 12px 4px; gap: 4px; }
  .fv-head h3 { font-size: 16px; }
  #fv-path { padding: 0 16px 10px; }
  .fv-body { padding: 4px 16px 32px; }
}
@media (max-width: 760px) { .app.has-file { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .app, .filepane { transition: none !important; } }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.msg .thumbs:not(:first-child) { margin: 8px 0 2px; }
.thumb { display: block; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: rgba(127,127,127,.18); cursor: zoom-in; }
.thumb img { display: block; max-width: min(240px, 60vw); max-height: 180px; min-width: 64px; min-height: 48px; object-fit: cover; }
.thumb.broken::after { content: "图片读不到"; display: block; padding: 14px 16px; font-size: 12px; opacity: .7; }
.thumb.broken img { display: none; }
a.fpath { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 2px; cursor: pointer; }
a.fpath:hover { text-decoration-color: currentColor; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--fg-2); margin-bottom: 8px; }
.field small { display: block; margin-top: 6px; font-size: 12px; }
.kinds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 420px) { .kinds { grid-template-columns: repeat(2, 1fr); } }
.kind-card {
  position: relative; display: grid; justify-items: center; gap: 4px; padding: 16px 8px 12px;
  border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s;
}
.kind-card input { position: absolute; opacity: 0; pointer-events: none; }
.kind-card svg { width: 28px; height: 28px; stroke-width: 1.4; margin-bottom: 4px; }
.kind-card b { font-weight: 500; font-size: 13px; }
.kind-card small { margin: 0; font: 11px var(--mono); color: var(--fg-3); }
.kind-card.missing { opacity: .45; cursor: not-allowed; }
.kind-card.missing small { font-family: var(--sans); }
.kind-card:has(input:checked) { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.kind-card:hover { background: var(--bg-2); }
.dir { display: flex; gap: 6px; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.recent button { border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 3px 10px; font: 12px var(--mono); color: var(--fg-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirs { list-style: none; margin: 8px 0 0; padding: 4px; max-height: 172px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.dirs:empty { display: none; }
.dirs li { padding: 6px 10px; border-radius: 7px; cursor: pointer; font: 13px var(--mono); color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dirs li:hover { background: var(--bg-2); color: var(--fg); }
.dirs li::before { content: "▸ "; color: var(--fg-3); }
.form-error { margin: 0; padding: 0 20px; color: var(--attn); font-size: 13px; min-height: 1em; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 20px; border-top: 1px solid var(--line); background: var(--bg); }

/* ─── toasts ─── */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 12px; font-size: 13px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); animation: rise .2s ease-out; }
.toast.attn { background: var(--attn); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ─── responsive ─── */
@media (max-width: 1100px) { :root { --side-w: 268px; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { border-right: 0; }
  .main { display: none; }
  body.show-main .side { display: none; }
  body.show-main .main { display: flex; }
  .back { display: inline-grid; }
  .d-head { padding: 10px 12px; gap: 8px; }
  .seg button { padding: 5px 9px; }
  #detail .d-name > .kind, #detail .d-name > .tag { display: none; }
  .item, .nav-item { padding: 12px 10px; }
  .form-row, .policy { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .sheet-foot { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .kind-card { padding: 14px 4px 10px; }
  input, textarea, select { font-size: 16px; }
}

/* While a decision card is up, the raw terminal fallback would only repeat it. */
#thread.asking > .termcard, #thread.asking > .fallback-note { display: none; }

/* folded run of tool steps */
.toolrun > summary {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px; margin: 0 -8px; border-radius: 8px;
  cursor: pointer; list-style: none; color: var(--fg-3); font-size: 13px; line-height: 1.6;
}
.toolrun > summary::-webkit-details-marker { display: none; }
.toolrun > summary::before { content: "›"; width: 8px; flex: none; text-align: center; transition: transform .15s; }
.toolrun[open] > summary::before { transform: rotate(90deg); }
.toolrun > summary:hover { background: var(--bg-2); }
.toolrun .n { color: var(--fg-2); font-weight: 500; flex: none; }
.toolrun .targ { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.toolrun .errs { color: var(--attn); font-weight: 500; }
.toolrun-body { padding-left: 14px; border-left: 1px solid var(--line); margin: 2px 0 2px 3px; }

/* sidebar groups per computer */
.group h2 .dot { width: 6px; height: 6px; margin-right: 6px; vertical-align: 1px; }
.group h2 .tag, .meta .tag, .row .tag {
  font: 500 10px/1 var(--mono); text-transform: none; letter-spacing: 0; color: var(--fg-3);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 5px; margin-left: 6px;
}
a.foot-status { text-decoration: none; color: inherit; border-radius: 8px; padding: 4px 6px; margin: -4px -6px; }
a.foot-status:hover, a.foot-status.active { background: var(--bg-3); }

/* launcher: which computer */
.machine-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.machine-pick button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--fg); font-size: 14px;
}
.machine-pick button small { color: var(--fg-3); font: 11px var(--mono); }
.machine-pick button.on { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }

/* devices */
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pair-card { display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; }
.pair-card .card-h { margin-bottom: 0; }
.pair-card > *:not(.card-h) { margin-left: 18px; margin-right: 18px; }
.qr-wrap { display: grid; place-items: center; padding: 6px 0; }
.qr { width: 196px; height: 196px; image-rendering: pixelated; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 8px; }
.pair-hint { margin: 0; font-size: 13px; line-height: 1.6; color: var(--fg-2); }
.pair-hint b { color: var(--fg); font-variant-numeric: tabular-nums; }
.card > .pair-hint { padding: 12px 16px 4px; }
.card > .pair-hint.muted { padding: 0 16px 12px; color: var(--fg-3); font-size: 12px; }
.hub-add { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.hub-add input[name=link] { flex: 3 1 260px; min-width: 0; }
.hub-add input[name=name] { flex: 1 1 120px; min-width: 0; }
.rows:empty { display: none; }
.code.big span { white-space: normal; word-break: break-all; }
.addr-pick { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--fg-3); }
.addr-pick select, .addr-pick .pick { flex: 1; min-width: 0; font: 12px var(--mono); }
.dev-row { grid-template-columns: auto 1fr auto !important; align-items: center; }
.dev-row .text.mono { font: 12px var(--mono); color: var(--fg-3); }
/* a ghost button's padding would set its label in from the text above it */
.dev-row > .btn.ghost { margin-right: -13px; }
@media (max-width: 760px) {
  .pair-grid { grid-template-columns: 1fr; }
  .thread { padding: 22px 16px 18px; }
  .thread > * + * { margin-top: 22px; }
  .msg { font-size: var(--msg-fs-m, 15.5px); }
  .dev-row { grid-template-columns: auto 1fr auto !important; }
}
.dot.online { background: var(--ok); }
.dot.offline { box-shadow: inset 0 0 0 1.5px var(--fg-3); opacity: .6; }
.addr-pick { flex-direction: column; align-items: stretch; gap: 6px; }

:root[data-text="small"] { --msg-fs: 14px; --msg-fs-m: 14.5px; }
:root[data-text="large"] { --msg-fs: 17px; --msg-fs-m: 17px; }
:root[data-text="large"] .composer textarea { font-size: 16px; }

/* preferences */
.prefs { max-width: 680px; }
.pref { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--line); }
.card-h + .pref { border-top: 0; }
.pref .pl { min-width: 0; }
.pref .pl b { display: block; font-weight: 500; font-size: 14px; }
.pref .pl small { display: block; color: var(--fg-3); font-size: 12.5px; margin-top: 2px; line-height: 1.5; }
.pref .seg { flex: none; }
.pref .switch { flex: none; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; padding: 0; background: var(--line-2); transition: background .15s; cursor: pointer; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--on-accent); }
.theme-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--line-2); margin-right: 6px; vertical-align: -1px; }
.theme-swatch.light { background: #fff; }
.theme-swatch.dark { background: #0b0b0c; }
.theme-swatch.system { background: linear-gradient(135deg, #fff 50%, #0b0b0c 50%); }
@media (max-width: 760px) {
  .pref { flex-direction: column; align-items: stretch; gap: 10px; }
  .pref .seg { align-self: flex-start; }
  .pref .switch { align-self: flex-start; }
}

/* agents in other terminals */
.ext-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px max(20px, calc((100% - var(--col)) / 2)) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
.ext-bar p { margin: 0; flex: 1; min-width: 0; font-size: 13px; line-height: 1.6; color: var(--fg-3); }
.ext-bar .btn { flex: none; }
/* Nothing to say and no button: no bar. */
.ext-bar:has(> p:empty):not(:has(> .btn:not([hidden]))) { display: none; }
#v-ext .d-name .tag { font: 500 10px/1 var(--mono); color: var(--fg-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 5px; margin-left: 6px; }
@media (max-width: 760px) {
  .ext-bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}

@media (min-width: 1680px) { :root { --col: 880px; } }

/* ─── pickers (enhanced <select>) ─── */
select.picked { display: none; }
.pick {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 9px 10px 9px 12px; text-align: left;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--fg); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.pick:hover { border-color: var(--fg-3); }
.pick:focus-visible, .pick[aria-expanded="true"] { outline: none; border-color: var(--fg-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 8%, transparent); }
.pick .pv { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.pick .pt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .pc { width: 16px; height: 16px; flex: none; color: var(--fg-3); transition: transform .15s; }
.pick[aria-expanded="true"] .pc { transform: rotate(180deg); }
.pick .pi, .pick-pop .pi { width: 18px; height: 18px; display: grid; place-items: center; flex: none; color: var(--fg-2); }
.pick .pi svg, .pick-pop .pi svg { width: 16px; height: 16px; }
.pick:disabled { opacity: .5; cursor: default; }
/* the quiet chip in the composer bar */
.pick.chip { width: auto; max-width: 42vw; gap: 4px; padding: 5px 6px 5px 8px; border-color: transparent; border-radius: 999px; background: transparent; color: var(--fg-2); font-size: 13px; }
.pick.chip:hover, .pick.chip[aria-expanded="true"] { background: var(--bg-2); color: var(--fg); border-color: transparent; box-shadow: none; }
.pick.chip.changed { color: var(--fg); background: var(--bg-2); border-color: var(--line); }
.pick.chip .pc { width: 14px; height: 14px; }
.pick.chip .pi { width: 16px; height: 16px; }
.pick.chip .pi svg { width: 15px; height: 15px; }

.pick-pop {
  position: fixed; z-index: 70; max-width: min(360px, calc(100vw - 16px)); max-height: min(380px, 60vh); overflow: auto;
  padding: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pick-in .12s ease-out;
}
@keyframes pick-in { from { opacity: 0; transform: translateY(-3px); } }
.pick-pop .ph { padding: 8px 10px 6px; font-size: 12px; color: var(--fg-3); }
.po {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--fg); text-align: left; font-size: 14px; cursor: pointer; outline: none;
}
.po:hover, .po:focus-visible { background: var(--bg-2); }
.po:disabled { opacity: .45; cursor: default; }
.po .pl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.po .pl > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po small { font-size: 12px; color: var(--fg-3); }
.po .ck { width: 16px; height: 16px; flex: none; color: var(--fg); visibility: hidden; }
.po.on .ck { visibility: visible; }
.po.on { font-weight: 500; }
.pick-back { position: fixed; inset: 0; z-index: 69; background: rgba(0, 0, 0, .28); animation: pick-fade .15s; }
@keyframes pick-fade { from { opacity: 0; } }
.pick-pop.sheet {
  left: 0; right: 0; bottom: 0; top: auto; max-width: none; max-height: 70dvh; border-radius: 18px 18px 0 0; border-bottom: 0;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); animation: pick-up .2s ease-out;
}
.pick-pop.sheet .ph { padding: 10px 12px 8px; font-size: 13px; }
.pick-pop.sheet .po { padding: 13px 12px; font-size: 15.5px; }
@keyframes pick-up { from { transform: translateY(24px); opacity: 0; } }

/* ended sessions in the sidebar read quieter */
.item.ended .name { color: var(--fg-2); }
.item.ended .glyph { opacity: .7; }
.kind:empty { display: none; }

/* a terminal takes a plain command line: one full-width row, monospace */
.detail:not(.chat-mode) .composer { padding: 8px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.detail:not(.chat-mode) .cbox { flex-direction: row; flex-wrap: wrap; align-items: center; border-radius: 12px; box-shadow: none; }
.detail:not(.chat-mode) .cbox .files { width: 100%; }
.detail:not(.chat-mode) .composer textarea { flex: 1; min-width: 0; min-height: 40px; padding: 9px 12px; font: 13px/1.5 var(--mono); }
.detail:not(.chat-mode) .cbar { padding: 0 5px 0 0; }
.detail:not(.chat-mode) .cbar .spacer { display: none; }

/* Collie's context gauge in its header */
#router-ctx.warn { color: var(--attn, #b7791f); }

/* memory tab */
.mem-dream { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 13px; color: var(--fg-2); }
.mem-dream .grow, .mem-head .grow, .mem-fold .grow, .mem-edit .grow { flex: 1; min-width: 0; }
.mem-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mem-load { border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; }
.mem-load .warn { color: var(--attn); }
.mem-name { flex: none; color: var(--fg-2); font-size: 12px; }
.mem-h .muted { font-weight: 400; margin-left: 8px; }
.mem-tools { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; font-size: 12px; }
.mem-tools .grow { flex: 1; }
.mem-body { padding: 14px 18px 16px; font-size: 14px; line-height: 1.7; }
.mem-body h1 { font-size: 16px; font-weight: 600; margin: 0 0 .6em; }
.mem-body h2 { font-size: 14px !important; margin: 1.2em 0 .4em !important; color: var(--fg-2); }
.mem-edit { padding: 12px 16px 14px; }
.mem-edit textarea { width: 100%; min-height: 360px; resize: vertical; font: 13px/1.6 var(--mono); padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2, var(--bg)); color: inherit; }
.mem-edit .form-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mem-h { margin: 22px 0 8px; font-size: 13px; font-weight: 600; color: var(--fg-2); }
.mem-fold + .mem-fold { border-top: 1px solid var(--line); }
.mem-fold > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; font-size: 13px; list-style: none; }
.mem-fold > summary::-webkit-details-marker { display: none; }
.mem-fold > summary .grow { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-fold[open] > summary .grow { white-space: normal; }
.mem-fold > .mem-body { border-top: 1px solid var(--line); }

/* talking to an agent outside herdr */
#v-ext .composer { padding-bottom: 6px; }
#x-composer .x-hint { font-size: 12px; padding-left: 8px; }

/* settings: one card per topic */
.settings { display: grid; gap: 14px; }
.set-sec { margin: 0; padding: 18px 20px 20px; display: grid; gap: 14px; overflow: visible; }
.set-sec header h4 { margin: 0; font-size: 14px; font-weight: 600; }
.set-sec header p { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: var(--fg-3); }
.set-sec header code { font: 12px var(--mono); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.set-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.set-sec label { display: grid; gap: 6px; align-content: start; font-size: 12px; font-weight: 600; color: var(--fg-2); min-width: 0; }
.set-sec label small { font-weight: 400; color: var(--fg-3); line-height: 1.5; }
.set-sec .check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; }
.set-adv > summary { cursor: pointer; font-size: 12px; color: var(--fg-3); list-style: none; }
.set-adv > summary::-webkit-details-marker { display: none; }
.set-adv > summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
.set-adv[open] > summary::before { transform: rotate(90deg); }
.set-adv[open] > label { margin-top: 10px; }
.set-actions { position: sticky; bottom: -40px; z-index: 5; display: flex; align-items: center; gap: 8px; margin: 0 -4px; padding: 12px 4px 52px; margin-bottom: -40px; background: var(--bg); border-top: 1px solid var(--line); }
.set-actions .grow { flex: 1; }
.set-grid .span2 { grid-column: span 2; }
.set-grid .span3 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .set-grid, .set-grid.three { grid-template-columns: minmax(0, 1fr); }
  .set-grid .span2, .set-grid .span3 { grid-column: auto; }
  .set-sec { padding: 16px; }
}

/* Collie's own model in its header; the composer's dispatch target */
#router-model:empty { display: none; }
#router-model .pending { all: unset; cursor: pointer; color: var(--warn, #b26b00); margin-left: 4px; }
#router-model .pending:hover { text-decoration: underline; }
.cbar-label { font-size: 12px; color: var(--fg-3); padding: 0 2px 0 4px; white-space: nowrap; cursor: default; }

/* new timer: choose, don't type */
.tm-form { gap: 14px; }
.tm-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.tm-lab { width: 64px; flex: none; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.tm-when > [hidden] { display: none !important; }
.tm-when input[type=time], .tm-when input[type=datetime-local], .tm-every input { width: auto; }
.tm-when input[type=time] { width: 120px; }
.tm-every { display: inline-flex; align-items: center; gap: 8px; }
.tm-every input { width: 80px; }
.tm-every select { width: auto; }
.tm-once { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tm-days { display: inline-flex; gap: 6px; }
.tm-days button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg); font-size: 13px; color: var(--fg-2); }
.tm-days button.on { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip-btn { border: 1px solid var(--line-2); background: var(--bg); border-radius: 999px; padding: 5px 11px; font-size: 12px; color: var(--fg-2); }
.chip-btn:hover, .tm-days button:hover { border-color: var(--fg-3); }
.tm-text { display: flex !important; align-items: flex-start; gap: 12px; }
.tm-text .tm-lab { padding-top: 10px; }
.tm-text textarea { flex: 1; min-width: 0; }
.tm-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 2px; }
.tm-target { display: inline-flex !important; align-items: center; gap: 12px; white-space: nowrap; flex: none; }
.tm-target .pick, .tm-target select { min-width: 140px; }
.tm-sum { flex: 1; min-width: 0; font-size: 13px; text-align: right; }
.tm-sum.err { color: var(--attn, #c2410c); }
@media (max-width: 760px) {
  .tm-lab { width: auto; }
  .tm-when .tm-lab { display: none; }
  .tm-text { flex-direction: column; gap: 6px; }
  .tm-text .tm-lab { padding-top: 0; }
  .tm-text textarea { width: 100%; }
  .tm-sum { text-align: left; flex-basis: 100%; order: 3; }
}

/* sidebar: the desktop apps' resting conversations, folded after a few */
.more-row { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 6px 10px 6px 42px; font-size: 12px; color: var(--fg-3); border-radius: 8px; }
.more-row:hover { color: var(--fg-2); background: var(--bg-3); }

/* a newer web app is on the hub */
#update-bar { position: fixed; z-index: 80; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); border: 0; border-radius: 999px; padding: 8px 16px; background: var(--fg); color: var(--bg); font-size: 13px; box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,.15)); animation: rise .2s; }

/* a desktop/terminal session that is still running, at the end of its thread */
.working-row { display: flex; align-items: center; gap: 8px; margin-top: -12px; padding: 0 max(20px, calc((100% - var(--col)) / 2)) 24px; font-size: 13px; color: var(--fg-3); }
.working-row.working { animation: workpulse 1.6s ease-in-out infinite; }
@keyframes workpulse { 50% { opacity: .55; } }

/* markdown tables in replies: rules between rows, no grid; scroll sideways on narrow screens */
.md-table { overflow-x: auto; margin: 14px 0; -webkit-overflow-scrolling: touch; }
.md-table table { border-collapse: collapse; min-width: 100%; font-size: 14px; line-height: 1.6; }
.md-table th, .md-table td { padding: 10px 24px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); min-width: 5em; max-width: 24em; overflow-wrap: normal; word-break: normal; }
.md-table th:last-child, .md-table td:last-child { padding-right: 0; }
.md-table th { font-weight: 600; white-space: nowrap; border-bottom-color: var(--line-2); padding-top: 4px; }
.md-table tbody tr:last-child td { border-bottom: 0; }
.md-table code { white-space: nowrap; }

/* "最近": where the running sessions end and the resting ones begin */
.list .sublabel { font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--fg-3); padding: 12px 10px 4px; margin-top: 4px; border-top: 1px solid var(--line); }

/* "加载更早的消息" at the top of a long conversation */
/* Older messages come in by themselves when you scroll to the top; this is
   the quiet line while they load. */
.thread > .earlier-row { text-align: center; margin: 0 0 4px; padding: 6px 0; font-size: 12px; color: var(--fg-3); }

/* "在这台电脑的 Collie app 里打开": above the sidebar footer */
.local-app { display: flex; align-items: center; gap: 4px; margin: 0 10px 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.local-app[hidden] { display: none; }
.local-app a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-2); text-decoration: none; }
.local-app a:hover { color: var(--fg); }
.local-app a svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; }
.local-app a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.local-app .icon-btn svg { width: 14px; height: 14px; }

/* screen mode: the terminal itself takes the typing, so no composer */
.viewer[data-mode="screen"] ~ .composer { display: none; }
.viewer[data-mode="screen"] ~ .keys { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.viewer:not([data-mode="screen"]) ~ .keys .screen-only { display: none; }
.keys .screen-only[hidden] { display: none; }
.keys #term-kbd svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; vertical-align: middle; }
.viewer.typing[data-mode="screen"] { box-shadow: inset 0 0 0 1.5px var(--accent); }
.viewer.typing ~ .keys #term-kbd { color: var(--accent); border-color: var(--accent); }
.screen { cursor: text; }
.screen-hint {
  display: none; position: absolute; right: 14px; bottom: 12px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; color: var(--fg-3); background: var(--bg); border: 1px solid var(--line); pointer-events: none;
}
.viewer[data-mode="screen"]:not(.typing) > .screen-hint { display: block; }
@media (max-width: 760px) { .screen { padding: 8px 10px; } }
/* xterm parks its input at the cursor, which Collie never places (herdr
   doesn't report it): keep it in the corner so it neither widens the scroll
   area nor scrolls the screen sideways when the keyboard opens */
.screen .xterm-helper-textarea { left: 0 !important; top: 0 !important; }

/* a stuck agent's dialog, answered from Collie's conversation */
.needs .ask { margin-top: 10px; }
.needs .ask-head a { font-size: 12px; color: var(--fg-3); text-decoration: none; }
.needs .ask-head a:hover { color: var(--fg); }
.event:has(> .wstate) { grid-template-columns: 26px auto minmax(0, 1fr) auto; }
.event:has(> .wstate) > span:nth-child(3) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event > .wstate { font-size: 12px; color: var(--fg-3); white-space: nowrap; }

/* sidebar: Collie's agents among yours */
/* A long name gives way, not the badge after it. */
.item .name:has(.by-collie) { display: flex; align-items: center; }
.item .name .nm { min-width: 0; margin-right: 6px; overflow: hidden; text-overflow: ellipsis; }
.item .name .by-collie { flex: none; margin-left: auto; /* all badges line up at the right */ padding: 0 5px; border: 1px solid var(--line-2); border-radius: 5px; font: 500 10.5px/16px var(--sans, inherit); color: var(--fg-3); vertical-align: 1px; white-space: nowrap; }
.list .empty-hint { list-style: none; padding: 4px 0; }
.fold-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 10px; background: none; color: var(--fg-3); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.fold-row:hover { background: var(--bg-3); color: var(--fg-2); }
.fold-row svg { width: 14px; height: 14px; margin: 0 6px 0 6px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.fold-row.open svg { transform: rotate(90deg); }

/* scrollbars: thin and quiet; the sidebar's shows only while you're on it */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.side-scroll { scrollbar-color: transparent transparent; transition: scrollbar-color .2s; }
.side-scroll:hover, .side-scroll:focus-within { scrollbar-color: var(--line-2) transparent; }

/* a question to you inside a session's thread */
.ask-card { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 8px; }
.ask-card.open { border-color: color-mix(in srgb, var(--attn) 45%, var(--line)); }
.ask-card .recap { color: var(--fg-2); font-size: 13px; }
.ask-card .q { display: flex; align-items: baseline; gap: 8px; font-weight: 500; }
.ask-card .q .dot { transform: translateY(-1px); }
.ask-card .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-card .opt { font-size: 12.5px; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 6px; color: var(--fg-2); }
.ask-card .answer { font-size: 13px; color: var(--fg-2); white-space: pre-wrap; }
.ask-card .where { font-size: 12px; color: var(--fg-3); }

/* a thread loading for the first time: the shape of a conversation */
.thread-skel { display: grid; gap: 14px; padding: 8px 0; margin-top: auto; }
.thread-skel .sk { height: 14px; border-radius: 7px; background: var(--line); animation: sk 1.4s ease-in-out infinite; }
.thread-skel .sk.user { justify-self: end; width: 38%; height: 34px; border-radius: 14px; }
.thread-skel .sk.user.short { width: 22%; }
.thread-skel .sk.a { width: 86%; }
.thread-skel .sk.a.short { width: 58%; }
.thread-skel .sk.tools { width: 30%; height: 10px; opacity: .7; }
.thread-skel .sk:nth-child(2n) { animation-delay: .15s; }
@keyframes sk { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .thread-skel .sk { animation: none; } }
.recap-note { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--line-2); color: var(--fg-2); font-size: 13px; }
.ask-card .where { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.model-row { display: flex; gap: 8px; flex-wrap: wrap; }
.model-row > * { flex: 1 1 160px; min-width: 0; }

.update-note { flex: none; font: 500 11px/1 var(--sans); padding: 3px 6px; border-radius: 6px; color: var(--attn); border: 1px solid color-mix(in srgb, var(--attn) 40%, transparent); }
.tag.attn { color: var(--attn); border-color: color-mix(in srgb, var(--attn) 40%, transparent); }
.update-cmd { margin-top: 6px; }
.update-cmd .pair-hint { margin: 0 0 4px; }

/* demo only */
.demo-badge { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 999; font: 500 12px/1 var(--sans); padding: 7px 10px; border-radius: 999px; background: var(--fg); color: var(--bg); text-decoration: none; opacity: .85; }
.demo-badge:hover { opacity: 1; }
