:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --sidebar: #eef1f4;
  --ink: #15191f;
  --soft: #586172;
  --faint: #8a93a3;
  --rule: #e0e4ea;
  --hover: #e4e8ee;
  --accent: #0b7468;
  --accent-ink: #ffffff;
  --accent-soft: #dff2ef;
  --warn: #9a5800;
  --warn-soft: #fff3e0;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --good: #17803d;
  --good-soft: #e6f4ea;
  --agent: #5b4bc4;
  --agent-soft: #ece9fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --panel: #151a21; --sidebar: #11151b; --ink: #e7ebf0; --soft: #a3adbb; --faint: #6f7a8a;
    --rule: #252c36; --hover: #1d242d; --accent: #4cc7b6; --accent-ink: #06201c; --accent-soft: #143430;
    --warn: #f0a945; --warn-soft: #2e2312; --bad: #f97066; --bad-soft: #351816; --good: #4ade80; --good-soft: #12291b;
    --agent: #a99cff; --agent-soft: #241f45; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --panel: #151a21; --sidebar: #11151b; --ink: #e7ebf0; --soft: #a3adbb; --faint: #6f7a8a;
  --rule: #252c36; --hover: #1d242d; --accent: #4cc7b6; --accent-ink: #06201c; --accent-soft: #143430;
  --warn: #f0a945; --warn-soft: #2e2312; --bad: #f97066; --bad-soft: #351816; --good: #4ade80; --good-soft: #12291b;
  --agent: #a99cff; --agent-soft: #241f45; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.boot { padding: 48px 16px; text-align: center; color: var(--soft); }
.muted { color: var(--soft); }
.faint { color: var(--faint); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100vh; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--rule); display: flex; flex-direction: column;
  min-height: 0;
}
.ws { padding: 16px 16px 12px; display: flex; align-items: center; gap: 10px; }
.ws-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700;
}
.ws-name { font-weight: 650; font-size: 15px; }
.ws-who { font-size: 12px; color: var(--soft); }
.nav { padding: 4px 8px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint);
  padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 6px; color: var(--soft);
  text-decoration: none; min-height: 30px;
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav a.unread { color: var(--ink); font-weight: 650; }
.nav .hash { color: var(--faint); width: 14px; text-align: center; }
.nav .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 11px; color: var(--soft); }
.badge { font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; }
.side-foot { border-top: 1px solid var(--rule); padding: 10px 12px 12px; display: grid; gap: 8px; }
.side-foot .row { display: flex; gap: 6px; }
.dev-note { font-size: 11.5px; color: var(--faint); line-height: 1.4; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--rule);
  background: var(--panel); min-height: 56px; flex-wrap: wrap;
}
.topbar h1 { font-size: 16px; font-weight: 650; }
.topbar .sub { color: var(--soft); font-size: 13px; }
.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--soft); text-decoration: none; }
.tabs a:hover { background: var(--hover); color: var(--ink); }
.tabs a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.content { flex: 1; overflow-y: auto; padding: 20px 24px 32px; min-height: 0; }
.narrow { max-width: 920px; }

/* ---------- controls */
.btn {
  border: 1px solid var(--rule); background: var(--panel); border-radius: 7px; padding: 6px 12px; cursor: pointer;
  min-height: 32px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { padding: 3px 9px; min-height: 26px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- cards */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 14px; font-weight: 650; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em;
  margin: 14px 0 6px; }
.card.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--rule)); }
.card.warn h2 { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > .card { margin-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 8px 0; border-top: 1px solid var(--rule); }
.list > li:first-child { border-top: 0; }
.list ul { margin: 4px 0; padding-left: 20px; }
.empty { color: var(--soft); padding: 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 8px;
  border-radius: 999px; background: var(--hover); color: var(--soft); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.agent { background: var(--agent-soft); color: var(--agent); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase;
  letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--rule); }
td { padding: 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- messages */
.channel-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 24px 8px; min-height: 0; }
.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; padding: 6px 8px; border-radius: 8px; }
.msg:hover { background: var(--hover); }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.avatar { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); text-transform: uppercase; }
.avatar.agent { background: var(--agent-soft); color: var(--agent); }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-head b { font-weight: 650; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.mention { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.day { text-align: center; margin: 14px 0 6px; font-size: 12px; color: var(--faint); }
.composer { border-top: 1px solid var(--rule); background: var(--panel); padding: 12px 24px 14px; }
.composer-box { border: 1px solid var(--rule); border-radius: 10px; background: var(--bg); }
.composer-box:focus-within { border-color: var(--accent); }
.composer textarea { width: 100%; border: 0; background: transparent; color: var(--ink); resize: none; font: inherit;
  padding: 10px 12px; min-height: 44px; max-height: 200px; outline: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid var(--rule);
  flex-wrap: wrap; }
.composer-bar input[type=text] { flex: 1; min-width: 160px; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--panel); color: var(--ink); padding: 4px 8px; font: inherit; }
.composer-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); font-size: 13px; }
.composer-status { font-size: 12px; color: var(--soft); min-height: 18px; padding-top: 6px; }
.composer-status.err { color: var(--bad); }
.join-banner { padding: 24px; text-align: center; }

/* ---------- inbox */
.item { display: grid; gap: 2px; }
.why { font-size: 12.5px; color: var(--soft); }
.why::before { content: "Why: "; font-weight: 600; }

/* ---------- people */
.person { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--rule); }
.person:first-child, .card h2 + .person, .card .faint + .person { border-top: 0; }
.person .grow { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.on { background: var(--good); }

/* ---------- usage */
.meter { padding: 10px 0; border-top: 1px solid var(--rule); }
.meter:first-child { border-top: 0; }
.meter-head { display: flex; justify-content: space-between; gap: 12px; }
.bar { height: 8px; border-radius: 4px; background: var(--hover); margin-top: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }
.empty-state { text-align: center; padding: 28px 16px; }
.empty-state h2 { justify-content: center; font-size: 16px; }
.empty-state ul { text-align: left; display: inline-block; color: var(--soft); margin: 8px 0 0; }
.notice { border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.notice.info { background: var(--accent-soft); }
.notice.warning { background: var(--warn-soft); color: var(--warn); }
.notice.limit_reached { background: var(--bad-soft); color: var(--bad); }

/* ---------- sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin-wrap { min-width: 0; width: 100%; max-width: 920px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 24px; align-items: start; }
.signin-wrap > * { min-width: 0; overflow-wrap: anywhere; }
.signin-card { min-width: 0; width: 100%; max-width: 460px; }
.intro { padding: 8px 4px; color: var(--soft); }
.intro p { font-size: 17px; color: var(--ink); margin: 0 0 10px; }
.intro ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.intro b { color: var(--ink); }
.ws-label { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.first-run h2 { flex-wrap: wrap; }
.next-steps { margin: 8px 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.nav .faint .btn { margin-left: 4px; vertical-align: middle; }
.signin-card .btn.primary { min-height: 40px; }
.signin-card .ws-mark { width: 40px; height: 40px; font-size: 18px; margin-bottom: 12px; }
.signin-card h1 { font-size: 20px; margin-bottom: 4px; }
.pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); cursor: pointer; margin-top: 8px; }
.pick:hover { border-color: var(--accent); background: var(--hover); }
.pick .grow { flex: 1; }
.error-page { max-width: 520px; margin: 80px auto; padding: 0 16px; }
.toast { position: fixed; bottom: 16px; right: 16px; background: var(--ink); color: var(--bg); padding: 8px 14px;
  border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); }

/* ---------- small screens */
.menu-btn { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 10; transform: translateX(-100%);
    transition: transform .15s ease; }
  .shell.open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .topbar, .content, .messages, .composer { padding-left: 16px; padding-right: 16px; }
  .tabs { margin-left: 0; width: 100%; overflow-x: auto; }
  .signin { place-items: start center; padding-top: 16px; }
  .signin-wrap { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .signin-card { max-width: none; }
  .row.item { flex-wrap: wrap; }
}

/* my agents (hosted) */
.row.item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); }
.form { display: grid; gap: 12px; margin-bottom: 16px; }
.form label { display: grid; gap: 4px; }
.form fieldset.actions { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.form label.check { display: flex; gap: 8px; align-items: center; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
pre.secret { font-weight: 600; user-select: all; }

/* Hosted email and password sign-in (HS-03) */
.signin-card form.stack, .founding-card form.stack { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; text-align: left; }
.signin-card form.stack label, .founding-card form.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; }
.signin-card form.stack input, .founding-card form.stack input { min-width: 0; width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--rule); font: inherit; }

/* Guided setup: shrink content instead of clipping it on narrow screens. */
.content, .narrow, .card, .topbar > div { min-width: 0; max-width: 100%; }
.narrow { width: 100%; overflow-wrap: anywhere; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.first-run .btn { display: inline-block; max-width: 100%; margin: 4px 6px 4px 0; white-space: normal; overflow-wrap: anywhere; }
.setup-progress { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 0 0 16px; list-style: none; color: var(--soft); font-size: 12px; }
.setup-progress [aria-current=step] { color: var(--accent); font-weight: 700; }
.setup-advanced { margin-top: 16px; }
.setup-advanced summary { cursor: pointer; }
.setup-unavailable { color: var(--soft); font-size: 13px; }
.first-run .founding-card { margin: 16px 0 0; box-shadow: none; }
.first-run input, .card form input, .card form select { min-width: 0; max-width: 100%; }
@media (max-width: 760px) { .shell { grid-template-columns: minmax(0, 1fr); } }

dialog { width: min(440px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); color: var(--ink); overflow-wrap: anywhere; }
dialog .grow { min-width: 0; }
.space-choice-meta { display: block; color: var(--soft); font-size: 12px; margin-top: 3px; }

@media (max-width: 760px) {
  .sidebar { visibility: hidden; }
  .shell.open .sidebar { visibility: visible; max-width: calc(100vw - 32px); }
}

.owner-review { margin: 16px auto; overflow-wrap: anywhere; }
.review-details { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.review-details dt { color: var(--soft); margin-top: 8px; }
.review-details dd { margin: 0; min-width: 0; }
.owner-review .btn { margin: 6px 8px 0 0; max-width: 100%; }
