:root {
  --bg: #f6f3ef;
  --panel: #ffffff;
  --text: #222;
  --muted: #6b6b6b;
  --line: #e2ddd6;
  --user: #e9e4dc;
  --pill: #efe7da;
  --pill-text: #6a4a1e;
  --accent: #b23a3a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151a;
    --panel: #211e25;
    --text: #ece8e2;
    --muted: #a09a93;
    --line: #34303a;
    --user: #2d2933;
    --pill: #3a2f22;
    --pill-text: #f0cf9c;
    --accent: #e06565;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column;
  max-width: 820px; margin-inline: auto; padding: 0 16px;
  background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#sprite { width: 120px; height: auto; }
.title { flex: 1; min-width: 160px; }
h1 { margin: 0; font-size: 1.4rem; }
.title p { margin: 0; color: var(--muted); font-size: .9rem; }
.version { font-size: .9rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
select, textarea, button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
select { padding: 6px 8px; }

main { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 10px 14px; border-radius: 10px; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { background: var(--user); align-self: flex-end; max-width: 85%; white-space: pre-wrap; }
.msg.bot { background: var(--panel); border: 1px solid var(--line); }
.msg.bot p { margin: 0 0 .6em; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul { margin: .2em 0 .6em; padding-left: 1.3em; }
.msg.notice { color: var(--muted); font-style: italic; }
.msg.error { color: var(--accent); }
.meta { font-size: .75rem; color: var(--muted); margin-top: 6px; }
.typing { color: var(--muted); }

.pill {
  display: inline-block; vertical-align: baseline; margin: 0 2px;
  padding: 0 7px; border-radius: 999px; font-size: .72rem; line-height: 1.5;
  background: var(--pill); color: var(--pill-text); text-decoration: none; white-space: nowrap;
  max-width: 16em; overflow: hidden; text-overflow: ellipsis;
}
.pill:hover { text-decoration: underline; }

form { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 16px; border-top: 1px solid var(--line); }
form.dragging { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px; }
.row { display: flex; gap: 8px; }
.attach { display: flex; align-items: center; justify-content: center; width: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; font-size: 1.2rem; }
#attachment { position: relative; align-self: flex-start; }
#attachment img { max-height: 90px; max-width: 200px; border-radius: 6px; border: 1px solid var(--line); display: block; }
#attachment-remove { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; border-radius: 50%; line-height: 1; font-size: 14px; }
.msg.user img { display: block; max-width: 240px; max-height: 160px; border-radius: 6px; margin-bottom: 6px; }
.seen { font-size: .8rem; color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; margin-bottom: 8px; white-space: pre-wrap; }
textarea { flex: 1; resize: none; padding: 8px 10px; }
button { padding: 0 18px; background: var(--accent); color: #fff; border: none; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
