* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: transparent; color: #111827;
  font: 14.5px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
:root { --c: #1F5FAE; --line: #E5E7EB; --muted: #6B7280; --soft: #F3F4F6; }

/* launcher */
#fab { position: absolute; bottom: 14px; right: 14px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--c); color: #fff;
  cursor: pointer; box-shadow: 0 8px 24px rgba(17,24,39,.18), 0 2px 6px rgba(17,24,39,.12); display: grid; place-items: center;
  transition: transform .15s ease; }
#fab:hover { transform: scale(1.05); }
body.left #fab { right: auto; left: 14px; }
#badge { position: absolute; top: 0; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #EF4444; color: #fff;
  font-size: 11px; font-weight: 600; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; }

/* panel */
#panel { position: absolute; inset: 0; background: #fff; border-radius: 18px; overflow: hidden; display: flex; flex-direction: column;
  border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(17,24,39,.18); }
@media (max-width: 519px) { #panel { border-radius: 0; border: 0; } }
header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.who { display: flex; align-items: center; gap: 10px; }
.who strong { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22C55E; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--c); color: #fff; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 15px; }
button.ghost { width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
button.ghost:hover { background: var(--soft); color: #111827; }

/* messages */
#log { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; scroll-behavior: smooth; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bot { align-self: flex-start; background: var(--soft); border-top-left-radius: 6px; }
.me { align-self: flex-end; background: var(--c); color: #fff; border-top-right-radius: 6px; }
.me img { max-width: 220px; border-radius: 10px; display: block; }
.me .tag { display: inline-flex; align-items: center; gap: 6px; opacity: .95; }
.msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg b, .msg strong { font-weight: 600; }
.typing { display: flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #9CA3AF; animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.btns button { border: 1px solid var(--line); color: #111827; background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font: inherit; font-size: 13.5px; text-align: left; transition: border-color .12s, color .12s; }
.btns button:hover { border-color: var(--c); color: var(--c); }
.btns button.icon { padding: 6px 10px; }
.btns button:disabled { opacity: .45; cursor: default; }
.note { align-self: center; font-size: 12px; color: var(--muted); text-align: center; padding: 4px 10px; background: var(--soft); border-radius: 999px; }

/* quick replies (menu) */
#chips { display: flex; gap: 6px; padding: 8px 14px 0; overflow-x: auto; background: #fff; scrollbar-width: none; }
#chips:empty { display: none; }
#chips button { flex: none; border: 1px solid var(--line); background: #fff; color: #374151; border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; }
#chips button:hover { border-color: var(--c); color: var(--c); }

/* composer */
form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 6px; background: #fff; }
.field { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; border: 1px solid var(--line); border-radius: 22px; padding: 4px 6px 4px 14px; background: #fff;
  transition: border-color .12s, box-shadow .12s; }
.field:focus-within { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 15%, transparent); }
textarea { flex: 1; min-width: 0; resize: none; border: 0; padding: 7px 0; font: inherit; max-height: 120px; outline: none; background: transparent; color: inherit; }
.tool { width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.tool:hover { background: var(--soft); color: #111827; }
.tool.rec { color: #EF4444; background: #FEF2F2; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.send { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: var(--c); color: #fff; cursor: pointer; display: grid; place-items: center; }
.send:disabled { opacity: .4; cursor: default; }
.foot { text-align: center; font-size: 11px; color: #9CA3AF; padding: 0 14px 10px; }
:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
textarea:focus-visible { outline: none; }

/* full-page chat (link, QR code, iframe embed): a centred chat card inside whatever box the website gives it */
body.standalone { background: #F3F4F6; }
body.standalone #fab, body.standalone #close { display: none !important; }
body.standalone #panel { inset: 16px; margin: 0 auto; max-width: 900px; border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(17,24,39,.04); }
@media (max-width: 519px) { body.standalone { background: #fff; } body.standalone #panel { inset: 0; border-radius: 0; border: 0; box-shadow: none; } }

/* slim scrollbar, close to the messages */
#log { scrollbar-width: thin; scrollbar-color: #D1D5DB transparent; }
#log::-webkit-scrollbar { width: 6px; }
#log::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
#log::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }
#log::-webkit-scrollbar-track { background: transparent; }
