:root {
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #eae4ef;
  color: #f5f3f6;
  --surface: #19181d;
  --panel: #242329;
  --line: #38363f;
  --muted: #b8b3bf;
  --accent: #d0bcff;
  --error: #ffb4ac;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: grid; justify-items: center; min-height: 100dvh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.shell { width: 100%; max-width: 500px; height: 100vh; height: 100dvh; min-height: 300px; background: var(--surface); display: flex; flex-direction: column; }
header { flex: none; display: grid; justify-items: center; padding: 22px 16px 13px; }
.agent { display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 12px; border: 1px solid var(--line); border-radius: 26px; background: var(--panel); }
.avatar { display: grid; place-items: center; flex: none; width: 41px; height: 41px; overflow: hidden; border-radius: 50%; background: #54446d; color: #f5eaff; font-weight: 750; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.agent strong, .agent span { display: block; overflow-wrap: anywhere; }
.agent strong { font-size: .92rem; }
.agent span { font-size: .76rem; margin-top: 3px; color: var(--muted); }
.status { min-height: 18px; margin: 7px 0 0; color: var(--muted); font-size: .75rem; }
.status[data-connected=true] { color: #a3d7b8; }
.entry { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr; overflow: auto; padding: 16px 24px 24px; }
.entry form { align-self: center; display: grid; gap: 12px; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.025em; }
label { font-size: .89rem; font-weight: 550; }
.entry input { width: 100%; min-height: 49px; border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px; color: inherit; background: var(--panel); }
.primary { border: 0; border-radius: 13px; background: var(--accent); color: #28173f; padding: 12px 18px; min-height: 46px; font-weight: 750; }
.chat { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.history { min-height: 0; flex: 1; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 4px 16px 20px; scrollbar-color: #5d5866 transparent; }
.older { display: block; margin: 0 auto 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); padding: 7px 12px; font-size: .77rem; }
.greeting { display: flex; align-items: center; gap: 8px; margin: 10px 0 19px; font-size: .87rem; color: var(--muted); }
.greeting p { margin: 0; overflow-wrap: anywhere; }
.small-avatar { width: 25px; height: 25px; font-size: .73rem; }
.messages { display: flex; flex-direction: column; gap: 13px; }
.message { display: flex; align-items: flex-start; gap: 8px; max-width: 86%; align-self: flex-start; }
.message > .avatar { margin-top: 4px; }
.message.mine { align-self: flex-end; flex-direction: row-reverse; }
.mine > .avatar { background: #393345; }
.message-content { min-width: 0; }
.bubble { color: inherit; background: #2a292f; padding: 9px 12px; border-radius: 15px 15px 15px 4px; overflow-wrap: anywhere; white-space: pre-wrap; font-size: .91rem; line-height: 1.42; }
.mine .bubble { background: #493866; border-radius: 15px 15px 4px 15px; }
.bubble.retracted { color: var(--muted); font-style: italic; }
.bubble img { display: block; width: min(235px, 62vw); max-width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #17161b; border-radius: 9px; }
.image-link { display: block; }
.image-link + span { display: block; margin-top: 8px; }
.message-meta { color: var(--muted); font-size: .68rem; margin: 4px 3px 0; }
.mine .message-meta { text-align: right; }
footer { flex: none; border-top: 1px solid var(--line); padding: 9px 12px max(12px, env(safe-area-inset-bottom)); }
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; display: flex; align-items: flex-end; gap: 7px; padding: 5px; }
.composer button { border: 0; flex: none; width: 39px; height: 39px; border-radius: 50%; background: #393640; color: #f3ebff; font-size: 1.25rem; }
.composer button[type=submit] { background: var(--accent); color: #28173f; }
.composer textarea { display: block; min-width: 0; width: 100%; resize: none; border: 0; outline: none; color: inherit; background: transparent; min-height: 39px; padding: 9px 2px; }
.composer:focus-within { border-color: #a798b6; }
.error { margin: 0; color: var(--error); font-size: .79rem; overflow-wrap: anywhere; }
.error:not(:empty) { margin: 5px 4px; }
.loading { margin: auto; padding: 16px; text-align: center; color: var(--muted); }
.loading button { margin: 10px auto 0; display: block; }
@media (min-width: 560px) { .shell { margin: 16px 0; height: calc(100dvh - 32px); border-radius: 18px; box-shadow: 0 12px 48px #22163134; } }
