:root {
  --bg: #0b0f14;
  --panel: #121820;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #5b8cff;
  --user: #1a2a44;
  --bot: #151c26;
  --border: #243041;
  --danger: #ff6b6b;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
#app { height: 100%; display: flex; flex-direction: column; max-width: 820px; margin: 0 auto; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand { display: flex; gap: 12px; align-items: center; }
.emoji { font-size: 28px; }
.title { font-weight: 650; font-size: 16px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ghost, .primary, #send {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; font: inherit;
}
.primary, #send { background: var(--accent); border-color: transparent; color: white; font-weight: 600; }
#send:disabled { opacity: 0.45; cursor: not-allowed; }
.thread { flex: 1; overflow: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 12px 14px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--user); }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--border); }
.msg.error { color: #ffd0d0; border-color: #5a2a2a; background: #2a1515; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.composer {
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--panel);
}
#input {
  flex: 1; resize: none; min-height: 44px; max-height: 160px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); padding: 12px; font: inherit; outline: none;
}
#input:focus { border-color: var(--accent); }
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--panel); color: var(--text); width: min(420px, 92vw); }
.sheet { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 18px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--bg); color: var(--text); font: inherit;
}
.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
