:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202e;
  --muted: #5d6b7e;
  --line: #dde3ea;
  --brand: #0b6e4f;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ec;
  --in: #ffffff;
  --out: #dff3e7;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --bad-bg: #fde6e6;
  --bad-ink: #8a1c1c;
  --ok-bg: #e3f3ec;
  --ok-ink: #0b5a41;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d;
    --panel: #18212b;
    --ink: #e8edf3;
    --muted: #9aa8b8;
    --line: #2a3644;
    --brand: #2fa37d;
    --brand-ink: #06140f;
    --brand-soft: #173a2e;
    --in: #212c38;
    --out: #1c4636;
    --warn-bg: #3d3212;
    --warn-ink: #f2d98a;
    --bad-bg: #432020;
    --bad-ink: #f3b4b4;
    --ok-bg: #173a2e;
    --ok-ink: #a6e3cb;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* sign-in and setup */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; }
.card.wide { max-width: 720px; }
.field { display: block; margin: 0 0 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; min-height: 44px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--brand); border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: transparent; color: var(--brand); }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.danger { background: transparent; border-color: var(--bad-ink); color: var(--bad-ink); }
.btn.tiny { padding: 3px 9px; font-size: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notice { padding: 10px 12px; border-radius: 8px; margin: 0 0 14px; font-size: 14px; }
.notice.bad { background: var(--bad-bg); color: var(--bad-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }

/* shell */
.shell { display: grid; grid-template-columns: 210px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 10px; gap: 2px; }
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 2px; color: var(--brand); }
.biz { padding: 0 10px 14px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.nav { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav:hover { background: var(--bg); }
.nav.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .spacer { flex: 1; }
.who { padding: 10px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.main { overflow: auto; padding: 22px 26px; min-width: 0; }
.main.flush { padding: 0; overflow: hidden; }
.devtag { display: inline-block; margin: 0 10px 12px; padding: 2px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12px; font-weight: 600; }

/* inbox */
.inbox { display: grid; grid-template-columns: 300px 1fr 270px; height: 100%; }
.list { border-right: 1px solid var(--line); overflow: auto; background: var(--panel); }
.list header, .thread header, .info header { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.conv { display: block; width: 100%; text-align: left; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--brand-soft); }
.conv .name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.conv .snippet { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: min(72%, 560px); padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--in); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: var(--out); }
.msg .meta { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: normal; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; background: var(--panel); }
.composer .row { align-items: flex-end; flex-wrap: nowrap; }
.composer textarea { flex: 1; }
.composer .opts { margin-bottom: 8px; }
.composer select { width: auto; }
.info { border-left: 1px solid var(--line); overflow: auto; background: var(--panel); }
.info .body { padding: 14px 16px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 24px; }

/* tables and pages */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .k { color: var(--muted); font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; max-width: 640px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
input.tick { width: auto; }
dialog.dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 20px; width: calc(100% - 32px); max-width: 440px; }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg-actions { margin-top: 14px; }
input[type=file] { margin: 0 0 14px; }
.row > .field { flex: 1; min-width: 180px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .biz, .who, .side .spacer, .devtag { display: none; }
  .brand { padding: 0 8px; }
  .nav { padding: 7px 9px; }
  .main { padding: 16px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-open .list { display: none; }
  .inbox:not(.has-open) .thread, .info { display: none; }
}
