:root {
  color-scheme: dark;
  --bg: #0e0e12; --panel: #15151b; --raised: #1c1c24; --border: #2a2a35; --border-soft: #20202a;
  --text: #ececf1; --text-2: #b4b4c0; --text-3: #7d7d8c;
  --accent: #a78bfa; --accent-ink: #1a1030;
  --working: #60a5fa; --attention: #f59e0b; --ready: #34d399; --idle: #7d7d8c; --error: #f87171;
  --add: #34d399; --del: #f87171; --add-bg: rgba(52,211,153,.12); --del-bg: rgba(248,113,113,.12);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #fbfbfc; --panel: #ffffff; --raised: #f2f2f6; --border: #dedee5; --border-soft: #ebebf0;
    --text: #17171c; --text-2: #4a4a56; --text-3: #7b7b88; --accent: #7655d9; --accent-ink: #ffffff;
    --working: #2563eb; --attention: #b45309; --ready: #059669; --error: #dc2626;
    --add: #047857; --del: #b91c1c; --add-bg: rgba(5,150,105,.1); --del-bg: rgba(220,38,38,.09);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); }
#root { height: 100%; display: flex; flex-direction: column; }
.app { height: 100%; display: flex; flex-direction: column; }

/* ---- shared bits */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); font-weight: 500; font-size: 13px; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--text-3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--error); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--idle); display: inline-block; }
.dot.working { background: var(--working); } .dot.attention { background: var(--attention); } .dot.ready { background: var(--ready); } .dot.error { background: var(--error); }
.badge .bt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
header.bar .badge { min-width: 0; flex: 0 1 auto; }
header.bar .btn, header.bar .brand, header.bar .avatar { flex: none; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--raised); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.muted { color: var(--text-3); } .small { font-size: 12px; } .ital { font-style: italic; }
.mono { font-family: var(--mono); font-size: 12px; }
.r { text-align: right; } .attn { color: var(--attention); }
.spacer { flex: 1; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { resize: vertical; }
.track { height: 5px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.track.thin { height: 4px; }
.track.inline { display: inline-block; width: 60px; vertical-align: middle; }
.track .fill, .fill { height: 100%; background: var(--accent); display: block; }
.fill.hot { background: var(--attention); }
.empty { color: var(--text-3); padding: 14px; }

/* ---- full-screen messages: sign in, not connected */
.center { flex: 1; display: grid; place-items: center; padding: 24px; }
.card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.card h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--text-2); }
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px/1 var(--mono); }
.brand svg { width: 28px; height: 28px; }
.code { font: 700 30px/1 var(--mono); letter-spacing: .12em; text-align: center; padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px dashed var(--border); user-select: all; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }

/* ---- top bar and shell */
header.bar { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 14px; min-width: 0; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--panel); flex: none; }
header.bar .brand { font-size: 16px; } header.bar .brand svg { width: 22px; height: 22px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--raised); }
.shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 1fr; position: relative; }
.main { overflow: auto; min-width: 0; }
.backdrop { display: none; }
.fab { display: none; }

/* ---- sidebar */
.side { border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.navs { padding: 8px 0 4px; flex: none; }
.tree { flex: 1; min-height: 0; overflow: auto; padding-bottom: 8px; }
.section { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 14px; font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); flex: none; }
.ico { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); }
.ico:hover, .ico.on { background: var(--raised); color: var(--text); }
.row { display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 14px; cursor: pointer; border-left: 2px solid transparent; min-width: 0; }
.row:hover { background: var(--raised); }
.row.on { background: var(--raised); border-left-color: var(--accent); }
.row.nav b { font-weight: 500; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.row .t span { display: block; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t b span { display: inline; font-size: inherit; color: var(--text-3); }
.row .count { font: 11px/1 var(--mono); color: var(--text-3); flex: none; }
.row .count.hot { background: color-mix(in srgb, var(--attention) 22%, transparent); color: var(--attention); padding: 3px 6px; border-radius: 9px; }
.row .when { font: 11px/1 var(--mono); color: var(--text-3); flex: none; display: inline-flex; align-items: center; gap: 3px; }
.row.repo { padding-top: 9px; padding-bottom: 9px; color: var(--text-2); }
.row.repo b { font-size: 13px; }
.row.s { padding-left: 22px; }
.row.sa { padding-top: 5px; padding-bottom: 5px; }
.row.sa .t b { font-size: 12.5px; font-weight: 400; }
.row.dim { opacity: .6; }
.row.empty-row { padding-left: 36px; cursor: default; }
.row.empty-row:hover { background: none; }
.twisty { width: 14px; height: 14px; display: grid; place-items: center; flex: none; color: var(--text-3); }
.plan { flex: none; padding: 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.meter .ml { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
.meter .ml b { font: 600 11.5px/1 var(--mono); color: var(--text); }

/* ---- pages */
.pad { padding: 20px; display: flex; flex-direction: column; gap: 18px; max-width: 880px; width: 100%; margin: 0 auto; }
.pad.wide { max-width: 1100px; }
.pad h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.pad h2 { margin: 0; font-size: 15px; }
.ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .tl { font: 600 10.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.tile .tv { font: 600 24px/1.2 var(--mono); }
.tile .tv.working { color: var(--working); } .tile .tv.attention { color: var(--attention); } .tile .tv.ready { color: var(--ready); }
.tile .ts { font-size: 12px; color: var(--text-3); }
.tile .track { margin-top: 4px; }
.asks { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.asks.inline { padding: 12px 18px; flex: none; margin: 0; }
.ask { border: 1px solid color-mix(in srgb, var(--attention) 55%, var(--border)); background: color-mix(in srgb, var(--attention) 7%, var(--panel)); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.ask .who { font: 12px/1 var(--mono); color: var(--text-3); cursor: pointer; }
.ask .head { font-weight: 600; }
.ask pre { margin: 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; max-height: 200px; overflow: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.option { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.option:hover { background: var(--raised); }

/* ledger: the sessions table and the lists that look like it */
.ledger { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.segb { border: 0; background: transparent; padding: 3px 9px; border-radius: 6px; font-size: 12px; color: var(--text-2); }
.segb.on { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.lcols, .lrow { display: grid; grid-template-columns: 14px minmax(160px, 1.5fr) minmax(120px, 1.2fr) 90px 70px 120px; gap: 12px; align-items: center; padding: 0 14px; }
.lcols.api, .lrow.api { grid-template-columns: 14px minmax(160px, 1.5fr) minmax(120px, 1.2fr) 90px 70px 80px 120px; }
.lcols { height: 28px; border-top: 1px solid var(--border); font: 600 10.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.lrow { min-height: 52px; border-top: 1px solid var(--border-soft); cursor: pointer; padding-top: 6px; padding-bottom: 6px; }
.lrow:hover { background: var(--raised); }
.lrow.dim { opacity: .6; }
.lrow .lt { min-width: 0; display: flex; flex-direction: column; }
.lrow .lt b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .lt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lrow > span.small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow.arch { grid-template-columns: 14px minmax(0, 1fr) auto auto; }
.group .grow { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--raised); border-top: 1px solid var(--border); min-height: 36px; flex-wrap: wrap; }
.trow { display: grid; grid-template-columns: minmax(140px, 260px) 1fr 70px auto; gap: 14px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--border-soft); }
.trow b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- activity */
.activity .a { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border-soft); font-size: 13px; }
.activity .a .when { font: 11.5px/1.6 var(--mono); color: var(--text-3); }
.activity .a .fail { color: var(--error); }
.daylabel { font: 600 10.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 14px 0 6px; }

/* ---- a session */
.sess { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.stop { flex: none; }
.dhead { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dhead h2 { margin: 0; font-size: 16px; flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.dmeta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 7px 18px; border-bottom: 1px solid var(--border-soft); font-size: 12px; }
.dmeta .ctx { display: inline-flex; align-items: center; gap: 6px; }
.subs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--border-soft); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--raised); border-radius: 14px; padding: 3px 10px; font-size: 12px; max-width: 100%; }
.chip:hover { border-color: var(--text-3); }
.tx { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 820px; width: 100%; margin: 0 auto; }
.msg .name { font-size: 12px; font-weight: 600; color: var(--text-2); }
.msg.user .body { background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }
.msg .body p { margin: 0 0 8px; } .msg .body p:last-child { margin: 0; }
.msg .body pre { margin: 0; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 8px; overflow: auto; font-size: 12.5px; }
.msg .body code { background: var(--raised); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.msg .body pre code { background: none; padding: 0; }
.msg .body ul, .msg .body ol { margin: 0 0 8px; padding-left: 22px; }
.codebox { position: relative; margin: 6px 0; }
.codebox .copy { position: absolute; top: 6px; right: 6px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--raised); color: var(--text-2); font-size: 11.5px; opacity: 0; transition: opacity .12s; }
.codebox:hover .copy, .codebox .copy:focus { opacity: 1; }
@media (hover: none) { .codebox .copy { opacity: 1; } }
.step { max-width: 820px; width: 100%; margin: 0 auto; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--panel); font-size: 12.5px; overflow: hidden; }
.step .line { display: flex; gap: 8px; padding: 5px 10px; align-items: baseline; }
.step .line + .line { border-top: 1px solid var(--border-soft); }
.step .k { color: var(--text-3); min-width: 54px; }
.step .v { font-family: var(--mono); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .r { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
.step.ok .r { color: var(--add); } .step.bad .r { color: var(--del); }
.diff { font: 12px/1.55 var(--mono); border-top: 1px solid var(--border-soft); }
.diff div { padding: 0 10px; white-space: pre-wrap; word-break: break-all; }
.diff .add { background: var(--add-bg); } .diff .del { background: var(--del-bg); }
.note { max-width: 820px; width: 100%; margin: 0 auto; font-size: 12.5px; color: var(--text-3); }
.note.attention { color: var(--attention); } .note.error { color: var(--error); }
.composer { flex: none; padding: 10px 18px 14px; border-top: 1px solid var(--border); background: var(--panel); }
.composer .inner { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 40px; max-height: 160px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--border); padding: 9px 14px; border-radius: 10px; font-size: 13px; z-index: 80; max-width: 90vw; }
.toast.err { border-color: var(--error); color: var(--error); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 70; }
.modal .box { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 17px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }

/* ---- narrower screens */
@media (max-width: 1000px) { .hide-md { display: none !important; } .lcols, .lrow { grid-template-columns: 14px minmax(140px, 1fr) 90px 70px 120px; } .lcols.api, .lrow.api { grid-template-columns: 14px minmax(140px, 1fr) 90px 70px 80px 120px; } .tiles { grid-template-columns: repeat(2, 1fr); } .tile.wide { grid-column: span 2; } }

/* ---- phones: the sidebar is a drawer, opened with the floating button */
@media (max-width: 760px) {
  header.bar { gap: 8px; padding: 0 10px; }
  header.bar .avatar { display: none; }
  header.bar .btn.sm { padding: 0 8px; }
  /* Filters become pills in a row that scrolls sideways, instead of a boxed control that wraps. */
  .seg { background: none; border: 0; padding: 0; gap: 6px; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .seg::-webkit-scrollbar { display: none; }
  .segb { flex: none; white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px; font-size: 13px; background: var(--panel); color: var(--text-2); box-shadow: none; }
  .segb.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: none; }
  .segb.on .muted { color: inherit; opacity: .7; }
  .lhead { flex-direction: column; align-items: stretch; gap: 8px; }
  .ph .seg { margin-top: 4px; }
  .hide-sm { display: none !important; }
  .lcols, .lrow, .lcols.api, .lrow.api { grid-template-columns: 14px minmax(0, 1fr) 70px; }
  .lrow.arch { grid-template-columns: 14px minmax(0, 1fr) auto; }
  .lrow.arch > .small { display: none; }
  .trow { grid-template-columns: minmax(0, 1fr) 60px; } .trow .track, .trow .mono.muted { display: none; }
  .pad { padding: 14px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; top: 52px; bottom: 0; left: 0; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.45); }
  .shell.open .side { transform: none; }
  .backdrop { display: block; position: fixed; z-index: 55; inset: 52px 0 0 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .shell.open .backdrop { opacity: 1; pointer-events: auto; }
  .fab { display: grid; place-items: center; position: fixed; z-index: 65; left: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border); background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0,0,0,.45); }
  .plan { padding-bottom: 84px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .composer .inner { padding-left: 62px; }
  .tx, .dhead, .dmeta, .subs { padding-left: 14px; padding-right: 14px; }
}
