/* ================================================================
   WebAI Assistant — Premium B&W Chat Widget
   Design: minimalist luxury-tech · Linear / Vercel / Apple HIG
   ================================================================ */

/* ── Design tokens (scoped — zero global conflicts) ────────────── */
#webai-chat-root {

  /* Core palette */
  --w-ink:        #0B0F19;
  --w-ink-2:      #3F4553;
  --w-ink-3:      #8A909F;
  --w-ink-4:      #B8BDC8;
  --w-paper:      #FFFFFF;
  --w-paper-2:    #F5F7FA;
  --w-paper-3:    #ECEFF4;
  --w-paper-4:    #E2E6ED;

  /* Bubble colours */
  --w-bubble-ai:  #F8F9FB;
  --w-bubble-ai-b:#ECEFF3;
  --w-bubble-usr: #0B0F19;
  --w-bubble-usr-t:#FFFFFF;

  /* Surfaces */
  --w-win-bg:     rgba(255,255,255,0.92);
  --w-hdr-bg:     rgba(255,255,255,0.96);
  --w-inp-bg:     #F5F7FA;
  --w-inp-b:      #E2E6ED;
  --w-code-bg:    #0B0F19;
  --w-code-t:     #E2E6ED;

  /* Shadow / border */
  --w-shadow:     0 20px 60px rgba(0,0,0,.10), 0 4px 16px rgba(0,0,0,.06);
  --w-border:     rgba(0,0,0,.08);
  --w-border-2:   rgba(0,0,0,.12);

  /* Sizes */
  --w-fab:        52px;
  --w-win-w:      420px;
  --w-radius:     24px;
  --w-z:          9000;

  /* Typography */
  --w-font-h:  'Space Grotesk','Inter',sans-serif;
  --w-font-b:  'Inter','Helvetica Neue',sans-serif;

  /* Transitions */
  --w-t:  200ms ease;
  --w-tl: 300ms cubic-bezier(.16,1,.3,1);
}

/* Dark-mode overrides */
[data-theme="dark"] #webai-chat-root {
  --w-ink:        #EAEAEA;
  --w-ink-2:      #A0A0A8;
  --w-ink-3:      #66666A;
  --w-ink-4:      #44444A;
  --w-paper:      #111113;
  --w-paper-2:    #18181B;
  --w-paper-3:    #1E1E22;
  --w-paper-4:    #27272C;

  --w-bubble-ai:  rgba(255,255,255,.05);
  --w-bubble-ai-b:rgba(255,255,255,.08);
  --w-bubble-usr: #FFFFFF;
  --w-bubble-usr-t:#0B0F19;

  --w-win-bg:     rgba(14,14,18,.94);
  --w-hdr-bg:     rgba(14,14,18,.96);
  --w-inp-bg:     rgba(255,255,255,.05);
  --w-inp-b:      rgba(255,255,255,.10);
  --w-code-bg:    rgba(0,0,0,.45);
  --w-code-t:     #A0A0A8;

  --w-shadow:     0 20px 60px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.3);
  --w-border:     rgba(255,255,255,.07);
  --w-border-2:   rgba(255,255,255,.12);
}

/* ── Scoped reset ─────────────────────────────────────────────── */
#webai-chat-root,
#webai-chat-root * {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#webai-chat-root button {
  margin: 0; padding: 0;
  cursor: pointer;
  font-family: var(--w-font-b);
  background: none; border: none; outline: none;
}

#webai-chat-root textarea {
  font-family: var(--w-font-b);
}

/* ================================================================
   FAB — Floating Action Button
   ================================================================ */
#webai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width:  var(--w-fab);
  height: var(--w-fab);
  border-radius: 50%;
  background: var(--w-ink);
  border: 1px solid var(--w-border-2);
  box-shadow: 0 8px 28px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
  cursor: pointer;
  z-index: var(--w-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--w-tl), box-shadow var(--w-tl), background var(--w-t);
  outline: none;
  overflow: hidden;
}

/* Dark mode: white FAB, dark icon */
[data-theme="dark"] #webai-fab {
  background: #FFFFFF;
  border-color: rgba(0,0,0,.12);
}

/* Light mode: dark FAB, white icon (explicit fallback) */
[data-theme="light"] #webai-fab {
  background: #0B0F19;
  border-color: rgba(255,255,255,.15);
}

#webai-fab:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 14px 40px rgba(0,0,0,.28), 0 4px 12px rgba(0,0,0,.16);
}

#webai-fab:active { transform: scale(.94); }

/* FAB icon crossfade */
#webai-fab .fab-icon {
  width: 20px; height: 20px;
  color: #FFFFFF;
  position: absolute;
  transition: opacity var(--w-t), transform var(--w-tl);
}

/* Dark mode: dark icon on white FAB */
[data-theme="dark"] #webai-fab .fab-icon { color: #0B0F19; }
/* Light mode: white icon on dark FAB */
[data-theme="light"] #webai-fab .fab-icon { color: #FFFFFF; }

#webai-fab .fab-icon-chat  { opacity:1; transform:rotate(0)     scale(1); }
#webai-fab .fab-icon-close { opacity:0; transform:rotate(-70deg) scale(.5); }

#webai-fab.chat-open .fab-icon-chat  { opacity:0; transform:rotate(70deg)  scale(.5); }
#webai-fab.chat-open .fab-icon-close { opacity:1; transform:rotate(0)       scale(1); }

/* Notification dot — monochrome */
#webai-fab .fab-notif {
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1.5px solid var(--w-ink);
  transition: opacity var(--w-t);
  pointer-events: none;
}

[data-theme="dark"] #webai-fab .fab-notif {
  background: #0B0F19;
  border-color: #FFFFFF;
}

#webai-fab.chat-open .fab-notif { opacity: 0; }

/* ================================================================
   Chat Window
   ================================================================ */
#webai-window {
  position: fixed;
  bottom: calc(var(--w-fab) + 16px);
  right: 28px;
  width: var(--w-win-w);
  max-width: calc(100vw - 24px);

  /* FIX: explicit height so flex child (#webai-messages) can shrink
     and scroll. Do NOT use min() inside a CSS variable — browsers
     don't evaluate math functions in custom property values. */
  height: 650px;
  max-height: calc(100vh - 110px);

  background: var(--w-win-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius);
  box-shadow: var(--w-shadow);

  z-index: calc(var(--w-z) - 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity var(--w-tl), transform var(--w-tl);
  will-change: opacity, transform;
}

#webai-window.chat-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────── */
#webai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 13px;
  border-bottom: 1px solid var(--w-border);
  background: var(--w-hdr-bg);
  flex-shrink: 0;
}

/* Small monochrome AI icon */
.webai-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 10px;
  background: var(--w-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

[data-theme="dark"] .webai-avatar { background: #FFFFFF; }

.webai-avatar svg {
  width: 16px; height: 16px;
  color: #FFFFFF;
}

[data-theme="dark"] .webai-avatar svg { color: #0B0F19; }

/* Subtle monochrome status dot */
.webai-avatar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--w-paper);
  border: 1.5px solid var(--w-paper);
  box-shadow: inset 0 0 0 2px var(--w-ink-2);
}

[data-theme="dark"] .webai-avatar::after {
  background: var(--w-paper);
  box-shadow: inset 0 0 0 2px #FFFFFF;
}

.webai-header-info { flex:1; min-width:0; }

.webai-header-name {
  font-family: var(--w-font-h);
  font-weight: 600;
  font-size: .86rem;
  color: var(--w-ink);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.webai-header-status {
  font-family: var(--w-font-b);
  font-size: .7rem;
  color: var(--w-ink-3);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

/* Tiny monochrome pulse dot for "Online" */
.webai-header-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--w-ink-2);
  flex-shrink: 0;
  animation: waiPulseStatus 3s ease infinite;
}

@keyframes waiPulseStatus {
  0%,100% { opacity:1; }
  50%      { opacity:.35; }
}

/* Header close button */
.webai-close-btn {
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 8px;
  border: 1px solid var(--w-border-2) !important;
  color: var(--w-ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: color var(--w-t), border-color var(--w-t), background var(--w-t);
}

.webai-close-btn:hover {
  color: var(--w-ink);
  border-color: var(--w-border-2) !important;
  background: var(--w-paper-3);
}

.webai-close-btn svg { width:13px; height:13px; }

/* ── Messages scroll area ────────────────────────────────────── */
#webai-messages {
  flex: 1 1 0;
  min-height: 0;          /* critical — lets flex child shrink */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#webai-messages::-webkit-scrollbar       { width: 3px; }
#webai-messages::-webkit-scrollbar-track { background: transparent; }
#webai-messages::-webkit-scrollbar-thumb {
  background: var(--w-paper-4);
  border-radius: 3px;
}

/* ── Message row ─────────────────────────────────────────────── */
.webai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
  min-width: 0;
  animation: waiSlideUp var(--w-tl) both;
}

@keyframes waiSlideUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}

.webai-msg.msg-ai   { flex-direction: row; }
.webai-msg.msg-user { flex-direction: row-reverse; }

/* Role spacing */
.webai-msg + .webai-msg { margin-top: 2px; }
.webai-msg.msg-ai  + .webai-msg.msg-user,
.webai-msg.msg-user + .webai-msg.msg-ai { margin-top: 10px; }

/* Small AI avatar beside bubbles — top-left aligned */
.msg-avatar {
  width: 24px; height: 24px; min-width: 24px;
  border-radius: 7px;
  background: var(--w-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;  /* FIX: anchor to TOP not bottom of row */
  margin-top: 4px;         /* small offset so it lines up with bubble top */
}

[data-theme="dark"] .msg-avatar { background: #FFFFFF; }

.msg-avatar svg {
  width: 12px; height: 12px;
  color: #FFFFFF;
}

[data-theme="dark"] .msg-avatar svg { color: #0B0F19; }

/* ── Message bubble ──────────────────────────────────────────────
   Overflow-proof rules (carried from the last fix):
   - display:block (block formatting context)
   - width:auto + max-width (no fit-content)
   - min-width:0 (flex child can shrink)
   - word-break + overflow-wrap (wrap long strings)
   - overflow:visible (lets pre scroll internally)
   ─────────────────────────────────────────────────────────────── */
.msg-bubble {
  display: block;
  min-width: 0;
  width: auto;
  max-width: 78%;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 10px 14px 8px;
  font-family: var(--w-font-b);
  font-size: .875rem;
  line-height: 1.62;
  color: var(--w-ink);
  overflow: visible;
  transition: background var(--w-t);
}

/* AI bubble — light card */
.webai-msg.msg-ai .msg-bubble {
  background: var(--w-bubble-ai);
  border: 1px solid var(--w-bubble-ai-b);
  border-radius: 6px 18px 18px 18px;
  color: var(--w-ink);
  max-width: calc(100% - 34px);
}

/* User bubble — dark solid */
.webai-msg.msg-user .msg-bubble {
  background: var(--w-bubble-usr);
  border: 1px solid transparent;
  border-radius: 18px 6px 18px 18px;
  color: var(--w-bubble-usr-t);
  max-width: 78%;
}

/* ── Content blocks ──────────────────────────────────────────── */
.msg-bubble p {
  display: block;
  margin: 0 0 .45em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble .wai-list {
  display: flex;
  flex-direction: column;
  gap: .22em;
  margin: .4em 0;
  padding: 0;
  list-style: none;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble .wai-list:last-child { margin-bottom: 0; }

.msg-bubble .wai-li {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble .wai-li::before {
  content: '–';
  font-size: .85rem;
  line-height: 1.7;
  flex-shrink: 0;
  min-width: 8px;
  opacity: .5;
}

.webai-msg.msg-user .msg-bubble .wai-li::before { opacity: .6; }

/* Bold / italic */
.msg-bubble strong { font-weight: 600; }
.msg-bubble em     { font-style: italic; opacity: .75; font-size: .82em; }

/* Inline code */
.msg-bubble code {
  font-family: 'Consolas','Courier New',monospace;
  font-size: .78em;
  background: rgba(0,0,0,.07);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.webai-msg.msg-user .msg-bubble code {
  background: rgba(255,255,255,.15);
}

/* Code block — scrollable, never overflows */
.msg-bubble pre {
  display: block;
  background: var(--w-code-bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin: .5em 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  box-sizing: border-box;
}

.msg-bubble pre code {
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: .78em;
  color: var(--w-code-t);
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* Links */
.msg-bubble a {
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  overflow-wrap: anywhere;
  color: inherit;
  opacity: .8;
}

.msg-bubble a:hover { opacity: 1; }

/* Timestamp */
.msg-time {
  display: block;
  font-size: .64rem;
  color: var(--w-ink-4);
  margin-top: 4px;
  line-height: 1;
  user-select: none;
  letter-spacing: .01em;
}

.webai-msg.msg-ai   .msg-time { text-align: left; }
.webai-msg.msg-user .msg-time { text-align: right; color: rgba(255,255,255,.4); }

/* ── Typing indicator ────────────────────────────────────────── */
#webai-typing {
  display: none;
  align-items: flex-start;  /* avatar aligns to top, matching AI messages */
  gap: 8px;
  padding: 2px 0 6px;
  flex-shrink: 0;
  animation: waiSlideUp var(--w-t) both;
}

#webai-typing.visible { display: flex; }

#webai-typing .msg-avatar {
  width: 24px; height: 24px; min-width: 24px;
  border-radius: 7px;
  background: var(--w-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-start;   /* top-aligned, matching AI message avatar */
  margin-top: 4px;
}

[data-theme="dark"]  #webai-typing .msg-avatar { background: #FFFFFF; }
[data-theme="light"] #webai-typing .msg-avatar { background: #0B0F19; }
#webai-typing .msg-avatar svg { width:12px; height:12px; color:#FFFFFF; }
[data-theme="dark"]  #webai-typing .msg-avatar svg { color:#0B0F19; }
[data-theme="light"] #webai-typing .msg-avatar svg { color:#FFFFFF; }

.typing-bubble {
  background: var(--w-bubble-ai);
  border: 1px solid var(--w-bubble-ai-b);
  border-radius: 6px 18px 18px 18px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--w-ink-3);
  flex-shrink: 0;
  animation: waiTyping 1.4s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

@keyframes waiTyping {
  0%,60%,100% { transform: translateY(0);    opacity:.35; }
  30%          { transform: translateY(-5px); opacity:1;   }
}

/* ── Welcome banner ──────────────────────────────────────────── */
.webai-welcome {
  text-align: center;
  padding: 8px 4px 6px;
  flex-shrink: 0;
  animation: waiSlideUp var(--w-tl) both;
}

.webai-welcome-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--w-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

[data-theme="dark"] .webai-welcome-icon { background: #FFFFFF; }

.webai-welcome-icon svg {
  width: 22px; height: 22px;
  color: #FFFFFF;
}

[data-theme="dark"] .webai-welcome-icon svg { color: #0B0F19; }

.webai-welcome h4 {
  font-family: var(--w-font-h);
  font-size: .95rem;
  font-weight: 600;
  color: var(--w-ink);
  margin: 0 0 4px;
  letter-spacing: -.015em;
}

.webai-welcome p {
  font-family: var(--w-font-b);
  font-size: .78rem;
  color: var(--w-ink-3);
  line-height: 1.5;
  max-width: 260px;
  margin: 0 auto;
}

/* Suggested prompt pills */
.webai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}

.webai-chip {
  background: var(--w-paper);
  border: 1px solid var(--w-paper-4);
  border-radius: 20px;
  padding: 6px 13px;
  font-family: var(--w-font-b);
  font-size: .76rem;
  font-weight: 500;
  color: var(--w-ink-2);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -.005em;
  transition: color var(--w-t), border-color var(--w-t), background var(--w-t), transform var(--w-t), box-shadow var(--w-t);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.webai-chip:hover {
  border-color: var(--w-ink);
  color: var(--w-ink);
  background: var(--w-paper);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,.10);
}

.webai-chip:active { transform: translateY(0); }

/* ================================================================
   Input Area — floating bar with integrated send button
   ================================================================ */
#webai-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--w-border);
  background: var(--w-hdr-bg);
  flex-shrink: 0;
}

/* The wrapper creates the floating bar */
.webai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0;
  background: var(--w-inp-bg);
  border: 1px solid var(--w-inp-b);
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
  transition: border-color var(--w-t), box-shadow var(--w-t);
  min-height: 52px;
}

.webai-input-wrap:focus-within {
  border-color: var(--w-ink-4);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

[data-theme="dark"] .webai-input-wrap:focus-within {
  border-color: rgba(255,255,255,.25);
  box-shadow: 0 0 0 3px rgba(255,255,255,.04);
}

#webai-input {
  flex: 1 1 0;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--w-font-b);
  font-size: .875rem;
  line-height: 1.45;
  color: var(--w-ink);
  max-height: 100px;
  min-height: 24px;
  padding: 5px 0;
  align-self: flex-end;
  overflow-y: auto;
  word-break: break-word;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: var(--w-paper-4) transparent;
}

#webai-input::placeholder {
  color: var(--w-ink-4);
  font-size: .84rem;
}

#webai-input::-webkit-scrollbar       { width: 3px; }
#webai-input::-webkit-scrollbar-track { background: transparent; }
#webai-input::-webkit-scrollbar-thumb { background: var(--w-paper-4); border-radius: 3px; }

/* Send button — inside the bar */
#webai-send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 11px;
  background: var(--w-ink);
  border: none !important;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  cursor: pointer;
  transition: background var(--w-t), transform var(--w-tl), opacity var(--w-t);
}

[data-theme="dark"] #webai-send-btn { background: #FFFFFF; color: #0B0F19; }

#webai-send-btn:hover { opacity: .82; transform: scale(1.04); }
#webai-send-btn:active { transform: scale(.94); }

#webai-send-btn:disabled {
  opacity: .28;
  cursor: not-allowed;
  transform: none;
}

#webai-send-btn svg { width:15px; height:15px; }

/* ── Footer ──────────────────────────────────────────────────── */
#webai-footer {
  text-align: center;
  padding: 5px 14px 8px;
  font-family: var(--w-font-b);
  font-size: .64rem;
  color: var(--w-ink-4);
  letter-spacing: .02em;
  user-select: none;
}

/* ================================================================
   Responsive breakpoints
   ================================================================ */

/* Large desktop (≥1400px) */
@media (min-width: 1400px) {
  #webai-chat-root { --w-win-w: 440px; }
}

/* Tablet (641–1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  #webai-chat-root { --w-win-w: 390px; }
  #webai-fab    { bottom:20px; right:20px; }
  #webai-window { right:20px; bottom:calc(var(--w-fab) + 14px); }
}

/* Small tablet / large phone (481–640px) */
@media (min-width: 481px) and (max-width: 640px) {
  #webai-window {
    right: 12px;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    bottom: calc(var(--w-fab) + 12px);
    border-radius: 20px;
  }
  #webai-fab { right:14px; bottom:14px; }
}

/* Mobile portrait (≤480px) — full-screen overlay */
@media (max-width: 480px) {
  #webai-window {
    position: fixed;
    inset: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    right: 0;
    bottom: 0;
    transform-origin: bottom center;
  }

  #webai-window:not(.chat-visible) {
    transform: translateY(20px) scale(.98);
  }

  #webai-fab { bottom:18px; right:18px; }
  #webai-fab.chat-open { display: none; }

  #webai-header {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-left: 14px;
    padding-right: 14px;
  }

  #webai-input-area {
    padding-left: 14px;
    padding-right: 14px;
  }

  #webai-input {
    font-size: 16px;
    max-height: 110px;
    min-height: 32px;
  }

  #webai-footer {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .webai-close-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
  }

  .webai-close-btn svg {
    width: 16px;
    height: 16px;
  }

  .webai-welcome p {
    max-width: 100%;
  }

  .webai-chip {
    font-size: .74rem;
    padding: 5px 11px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .webai-msg.msg-ai   .msg-bubble { max-width: calc(100% - 34px); }
  .webai-msg.msg-user .msg-bubble { max-width: 84%; }
}

/* Very small (≤320px) */
@media (max-width: 320px) {
  .msg-bubble { font-size: .84rem; }
  .webai-msg.msg-user .msg-bubble { max-width: 88%; }
}
