:root {
  --bg: #ffffff; --fg: #1d2330; --muted: #667085; --line: #e4e7ec; --me: #eef4ff; --bot: #f7f8fa;
  --accent: #2f6fed; --accent-fg: #fff; --danger: #c4320a; --ok: #12b76a; --warn-bg: #fff8e6; --warn: #8a5a00;
  --code: #f2f4f7;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171f; --fg: #e6e9ef; --muted: #98a2b3; --line: #2a303c; --me: #1d2a44; --bot: #1b1f29;
    --accent: #5b8cff; --accent-fg: #0b0e14; --danger: #ff7a59; --ok: #32d583; --warn-bg: #2b2412; --warn: #f5c451;
    --code: #222836; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.status { color: var(--muted); font-size: 13px; }
.card { padding: 20px 16px; }
h1 { font-size: 20px; margin: 0 0 8px; } h2 { font-size: 18px; } h3 { font-size: 15px; margin-top: 18px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 6px 16px; }
.button { display: inline-block; border: 1px solid var(--line); background: var(--bot); color: var(--fg); border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; }
.button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.button.danger { color: var(--danger); }
.button:disabled { opacity: .55; cursor: default; }
.link, .icon { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.icon { color: var(--muted); font-size: 13px; }
input, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
#chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chip { margin: 10px 16px 0; padding: 6px 10px; border-radius: 999px; background: var(--code); font-size: 13px; align-self: flex-start; }
.chip button { margin-left: 8px; }
.log { list-style: none; margin: 0; padding: 12px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 8px 12px; border-radius: 10px; max-width: 92%; overflow-wrap: anywhere; }
.msg.user { background: var(--me); align-self: flex-end; }
.msg.assistant { background: var(--bot); align-self: flex-start; }
.msg .meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin-bottom: 0; }
.msg pre { background: var(--code); padding: 8px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; }
.msg code { background: var(--code); padding: 0 3px; border-radius: 4px; font-size: 13px; }
.msg ul { margin: 0 0 6px; padding-left: 20px; }
.files a { display: inline-block; margin-right: 10px; font-size: 13px; }
.files img { max-width: 100%; border-radius: 6px; display: block; margin-top: 6px; }
.perm { border: 1px solid var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; align-self: stretch; }
.perm .tool { font-weight: 600; }
.perm pre { white-space: pre-wrap; max-height: 240px; overflow: auto; font-size: 12px; background: var(--bg); padding: 6px; border-radius: 6px; }
.perm .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.perm .done { color: var(--muted); font-size: 13px; }
.composer { display: flex; gap: 8px; padding: 10px 16px 4px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; }
ul.plain { padding-left: 18px; font-size: 13px; }
#enroll-form { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 480px) { .msg { max-width: 100%; } }
