:root {
  --bg: #0b0b0d;
  --panel: #141418;
  --panel-2: #1c1c22;
  --line: #26262e;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --accent: #d4af37;
  --mine: #2a3550;
  --danger: #e5484d;
  --ok: #30a46c;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; height: 100dvh; }

/* The chat list, laid out like the old app's: the pinned bot as a large card on top, bots
   in groups ("Name · Title" over the last message, an unread dot on the right), Cyrus at
   the bottom with the settings button. */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 10px 0; display: flex; flex-direction: column; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 8px 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.brand .dot.on { background: var(--ok); }
.group { color: var(--muted); font-size: 13px; padding: 16px 10px 6px; }
.row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 9px 10px; border: 0; flex: none;
  background: none; border-radius: 12px; text-align: left; min-height: 60px; }
.row:hover, .row.active { background: var(--panel-2); }
.row.hero { flex-direction: column; gap: 6px; padding: 10px 8px 12px; margin-bottom: 6px; text-align: center;
  position: relative; }
.row.hero .who b, .row.hero .who small { text-align: center; }
.row.hero .unread { position: absolute; top: 14px; right: 14px; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: #2b2b35;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--accent); }
.avatar.big { width: 72px; height: 72px; font-size: 22px; }
.avatar.tiny { width: 26px; height: 26px; font-size: 10px; }
.avatar.ghost { visibility: hidden; }
.avatar.stack { background: none; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.avatar.stack span { width: 20px; height: 20px; border-radius: 50%; background: #2b2b35; display: grid;
  place-items: center; font-size: 8px; }
.who { min-width: 0; flex: 1; width: 100%; }
.who b, .who .line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.who .line b { display: inline; }
.who .title { color: var(--text); font-weight: 400; }
.who small { display: block; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.me { position: sticky; bottom: 0; margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px calc(env(safe-area-inset-bottom) + 12px); background: var(--panel); border-top: 1px solid var(--line); }
.me b { flex: 1; font-weight: 500; }
.me .avatar { width: 34px; height: 34px; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--panel-2); font-size: 17px; }

/* A chat: a centred pill with the bot's avatar and "Name · Title" on top, soft bubbles, a
   time line when the talk picks up again, and a rounded message box. */
.header { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg); min-height: 56px; }
.header .back { display: none; border: 0; background: none; font-size: 26px; line-height: 1; padding: 0 6px 0 0; }
.header .pill { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 999px;
  padding: 4px 14px 4px 4px; font-weight: 500; margin: 0 auto; min-width: 0; max-width: 100%; }
.header .pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .pill .avatar { width: 30px; height: 30px; font-size: 11px; }
.header .pill .avatar.stack span { width: 15px; height: 15px; font-size: 6px; }
.scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.scroll.chat { gap: 6px; padding: 16px 16px 20px; }
.when { align-self: center; color: var(--muted); font-size: 12.5px; padding: 10px 0 4px; }
.turn { display: flex; align-items: flex-end; gap: 8px; max-width: min(720px, 90%); }
.turn.named { margin-top: 6px; }
.turn .col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.from { font-size: 12.5px; padding-left: 4px; }
.from.c0 { color: #6cc5a0; } .from.c1 { color: #e0a458; } .from.c2 { color: #7aa7f0; } .from.c3 { color: #d987c1; }
.from.c4 { color: #c9b458; } .from.c5 { color: #8fd0e0; } .from.c6 { color: #e38a7a; } .from.c7 { color: #a99cf0; }
.msg { max-width: min(680px, 86%); padding: 10px 14px; border-radius: var(--radius); background: var(--panel-2);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; }
.turn .msg { max-width: 100%; }
.msg.mine { align-self: flex-end; background: var(--mine); border-radius: 20px; }
.msg.system, .msg.alert { align-self: center; background: none; color: var(--muted); font-size: 13px; }
.msg .meta { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.composer { padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); background: var(--bg); }
.composer .box { display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 5px 5px 5px 16px; }
.composer textarea { flex: 1; resize: none; min-height: 36px; max-height: 160px; border: 0; background: none;
  color: var(--text); padding: 8px 0; font: inherit; font-size: 16px; outline: none; }
.composer .send { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent);
  color: #111; font-size: 18px; font-weight: 700; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; background: var(--panel-2); font-weight: 600; }
.btn.primary { background: var(--accent); color: #111; }
.btn.danger { background: var(--danger); color: #fff; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.card.focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .what { margin: 10px 0; background: var(--bg); border-radius: 10px; padding: 10px; font-size: 13px; }
.card .what div { display: flex; gap: 8px; } .card .what dt { color: var(--muted); min-width: 70px; }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }
.muted { color: var(--muted); }
.note { background: var(--panel-2); border-radius: 12px; padding: 10px 14px; margin: 0; }
.center { margin: auto; max-width: 420px; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.center input { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; text-align: center; letter-spacing: .2em; }
.fp { font: 600 18px ui-monospace, Menlo, monospace; letter-spacing: .05em; color: var(--accent); }

/* Health, laid out like the old app's settings: a small label, then a rounded panel of rows. */
.sections { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 760px; margin: 0 auto; }
.section h4 { margin: 0 0 8px 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.section .panel { background: var(--panel-2); border-radius: 14px; overflow: hidden; }
.section .item { padding: 11px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  overflow-wrap: anywhere; }
.section .item + .item { border-top: 1px solid var(--line); }
.section .item.actions { justify-content: flex-start; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .main { display: none; }
  .header .back { display: block; }
  /* Signed out (sign-in, a new passkey) there is no list: the main area alone. */
  .app.signed-out .sidebar { display: none; }
  .app.signed-out .main { display: flex; }
}
.spacer { flex: 1; }
.header .pill + .spacer { flex: 0 0 26px; } /* balances the back button, so the pill is centred */
.what dd.value { font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.msg.untrusted { border-left: 3px solid #b8860b; }
.composer.muted { padding: 12px; font-size: 13px; }
.what dd.value { overflow: hidden; contain: paint; }
.card.small { padding: 8px 12px; }
.card h3, .card p, .card .muted { overflow: hidden; contain: paint; }
.btn.small { padding: 2px 8px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.card b { overflow: hidden; contain: paint; display: block; }
.section .panel .btn:not(.danger):not(.primary) { background: var(--bg); }
