:root {
  --bg: #f5f6f8; --fg: #1b2230; --muted: #6a7385; --card: #fff; --line: #e1e5ec;
  --accent: #2f6fed; --ok: #1f9d55; --warn: #c27c0e; --bad: #c43d3d; --blue: #2f6fed;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151d; --fg: #e3e7ee; --muted: #8b94a6; --card: #1a202b; --line: #2a3242; --accent: #6b9bff; --blue: #6b9bff; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
code, pre { font-family: var(--mono); font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h2.inline { display: inline; }
h3 { font-size: 14px; margin: 14px 0 4px; color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; font-weight: normal; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: #151a24; color: #fff; }
.top a { color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.top nav { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.me { opacity: .7; }
main { max-width: 920px; margin: 0 auto; padding: 12px 16px calc(env(safe-area-inset-bottom) + 40px); }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; color: inherit; }
.card summary { cursor: pointer; font-weight: 600; }
.hero { text-align: center; padding: 60px 0; }
.hero h1 { font-size: 32px; }
.flash { background: #e7f3ec; color: #145a32; border-radius: 10px; padding: 10px 12px; }
.flash.err { background: #fbe9e9; color: #8a1f1f; }
@media (prefers-color-scheme: dark) { .flash { background: #173324; color: #b7e4c7; } .flash.err { background: #3a1c1c; color: #f2b8b8; } }
.boardhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 8px; margin: 8px 0; }
.tabs { display: flex; gap: 4px; }
.tabs a, .scopes a { padding: 6px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.scopes { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 6px 0; }
.scopes a { white-space: nowrap; color: var(--fg); }
.scopes a.sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: inherit; min-height: 44px; }
.row:last-child { border-bottom: 0; }
a.row:active { background: var(--line); }
.row .id { font-family: var(--mono); font-size: 13px; min-width: 52px; }
.row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 560px) { .row.job { flex-wrap: wrap; } .row.job .title { flex-basis: 100%; order: 3; white-space: normal; } }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--line); color: var(--fg); text-transform: lowercase; white-space: nowrap; }
.badge.ready { background: var(--blue); color: #fff; }
.badge.claimed, .badge.owned, .badge.running, .badge.sent { background: #e8a33a33; color: var(--warn); }
.badge.open, .badge.proposed, .badge.pending, .badge.starting { background: #2f6fed22; color: var(--accent); }
.badge.done, .badge.ok, .badge.closed { background: #1f9d5522; color: var(--ok); }
.badge.failed, .badge.handing-over { background: #c43d3d22; color: var(--bad); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on, .dot.active { background: var(--ok); }
.dot.idle { background: var(--warn); }
.dot.off, .dot.gone { background: var(--line); border: 1px solid var(--muted); }
.boardcard .line { display: flex; gap: 8px; align-items: center; }
.counts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.feed { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; max-height: 60vh; overflow: auto; }
.feed > div { padding: 3px 0; border-bottom: 1px dashed var(--line); word-break: break-word; }
.feed time { font-family: var(--mono); color: var(--muted); }
.feed .type { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.text { white-space: pre-wrap; word-break: break-word; }
.text.small { font-size: 12px; color: var(--muted); max-height: 9em; overflow: hidden; }
.note { background: #e8a33a22; padding: 8px 10px; border-radius: 8px; }
form.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
form.inline, div.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
div.inline label { flex-direction: row; align-items: center; }
input, select, textarea, button { font: inherit; font-size: 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 8px 10px; }
textarea { resize: vertical; }
button, .button { display: inline-block; background: var(--accent); color: #fff; border: 0; padding: 9px 16px; cursor: pointer; font-weight: 600; }
button.small { font-size: 13px; padding: 5px 10px; }
button.danger { background: var(--bad); }
button.primary { background: var(--ok); }
.actions { display: flex; flex-direction: column; gap: 6px; }
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 88%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: #2f6fed18; border-color: #2f6fed44; }
.msg.system { opacity: .8; font-size: 13px; }
.msg .head { font-size: 12px; color: var(--muted); }
.msg .head time { margin-left: 6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; background: var(--bg);
  padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px); }
.composer textarea, .composer input[name=text] { flex: 1; min-width: 200px; }
.term { background: #0c0f14; color: #d6dde8; padding: 10px; border-radius: 10px; font-size: 11.5px; line-height: 1.3; overflow-x: auto;
  white-space: pre; max-height: 70vh; overflow-y: auto; }
.transcript .entry { margin: 6px 0; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.transcript .who { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.transcript .entry.user { border-left: 3px solid var(--accent); }
.transcript .entry.assistant { border-left: 3px solid var(--ok); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--muted); }
details[open] > summary::before { content: "▾ "; }
