:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e3e5ea;
  --accent: #1f6feb;
  --user: #1f6feb;
  --user-text: #ffffff;
  --error: #c62828;
  --tool: #eef1f5;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --panel: #1e2128;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --line: #2c3039;
    --accent: #7cc4ff;
    --user: #2b5fb4;
    --tool: #252932;
    --error: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
header h1 { font-size: 17px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button, select, textarea, input { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 8px 14px; min-height: 40px; cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { button.primary { color: #0b1220; } }
button:disabled { opacity: 0.5; }
.scroll { flex: 1; overflow-y: auto; padding: 12px; }
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 24px; text-align: center; }
.muted { color: var(--muted); font-size: 14px; }
.error-text { color: var(--error); }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list a {
  display: block; padding: 12px; margin-bottom: 8px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: inherit; text-decoration: none;
}
ul.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--tool); color: var(--muted); }
.running-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2ea043; margin-right: 6px; }
form.new { display: flex; flex-direction: column; gap: 14px; }
form.new label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
fieldset.agents { display: flex; gap: 8px; border: 0; margin: 0; padding: 0; }
fieldset.agents legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.agents button[aria-pressed="true"] { border-color: var(--accent); outline: 2px solid var(--accent); }
select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel);
}
textarea { resize: none; min-height: 44px; max-height: 40dvh; }
.msg { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg.user {
  margin-left: 15%; padding: 9px 12px; border-radius: 14px 14px 4px 14px;
  background: var(--user); color: var(--user-text);
}
.msg.text { padding: 2px 2px; }
.msg.error { color: var(--error); font-size: 14px; }
details.tool { margin: 0 0 8px; background: var(--tool); border-radius: 10px; font-size: 13px; }
details.tool summary { padding: 7px 10px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.tool summary .name { font-weight: 600; margin-right: 6px; }
details.tool.failed summary .name { color: var(--error); }
details.tool pre { margin: 0; padding: 8px 10px; max-height: 50dvh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--line); }
.status { color: var(--muted); font-size: 13px; margin: 4px 2px 10px; }
.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--line); background: var(--panel);
}
.resume { font-size: 12px; padding: 8px 12px; border-top: 1px solid var(--line); }
.resume code { user-select: all; overflow-wrap: anywhere; }
