:root {
  --chat-blue: var(--c-accent);
  --chat-blue-light: var(--c-accent-ink);
  --chat-bg: var(--c-bg);
  --chat-bg-raised: var(--c-surface);
  --chat-bg-hover: var(--c-raised);
  --chat-border: var(--c-line);
  --chat-text: var(--c-ink);
  --chat-text-sub: var(--c-ink2);
  --chat-text-muted: var(--c-ink3);
  --chat-radius: var(--r-card);
}
#chat-launcher {
  position: fixed; bottom: calc(28px + var(--nb-bottom-inset, 0px)); z-index: 480;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--c-on-accent, #fff); background: var(--c-accent);
  box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 8px 20px -6px rgb(var(--c-accent-rgb) / .55), 0 2px 6px rgb(0 0 0 / .3);
  transition: bottom .22s var(--ease-out), transform .16s var(--ease-out), opacity .16s, visibility .16s;
}
#chat-launcher:active { transform: scale(.94); }
@media (hover: hover) { #chat-launcher:hover { transform: translateY(-2px); } }
#chat-launcher > i { font-size: 1.25rem; line-height: 1; pointer-events: none; }
#chat-launcher .chat-launcher-badge {
  position: absolute; top: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  display: none; align-items: center; justify-content: center;
  background: var(--c-neg); color: #fff; font-size: .62rem; font-weight: 700; box-shadow: 0 0 0 2px var(--c-bg);
}
#chat-launcher .chat-launcher-badge.show { display: flex; }
html.annp-lock #chat-launcher, html.annp-lock #chat-peek-bubble, body.modal-open #chat-launcher { opacity: 0; visibility: hidden; pointer-events: none; }

#chat-peek-bubble {
  position: fixed; bottom: calc(30px + var(--nb-bottom-inset, 0px)); z-index: 479; max-width: 260px;
  padding: 10px 34px 10px 12px; display: none; cursor: pointer;
  background: var(--c-surface); border: 1px solid var(--c-line2); border-radius: var(--r-card);
  box-shadow: 0 12px 30px -8px rgb(0 0 0 / .45); transition: bottom .22s var(--ease-out);
  animation: chatPeekIn .24s var(--ease-out);
}
#chat-peek-bubble.show { display: block; }
#chat-peek-bubble .chat-peek-sender { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; font-size: var(--fs-2xs); font-weight: 600; color: var(--c-ink2); }
#chat-peek-bubble .chat-peek-sender::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c-pos); flex: none; }
#chat-peek-bubble .chat-peek-text { font-size: var(--fs-xs); line-height: 1.4; color: var(--c-ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#chat-peek-bubble .chat-peek-close { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: none; color: var(--c-ink3); display: grid; place-items: center; cursor: pointer; font-size: .7rem; }
@keyframes chatPeekIn { from { opacity: 0; transform: translateY(6px); } }

#chat-guest-modal-overlay { position: fixed; inset: 0; z-index: 999999; background: rgb(0 0 0 / .6); display: none; align-items: center; justify-content: center; padding: 16px; }
#chat-guest-modal-overlay.show { display: flex; }
#chat-guest-modal { position: relative; width: 100%; max-width: 340px; padding: var(--sp-5); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-sheet, 20px); box-shadow: 0 24px 60px rgb(0 0 0 / .45); animation: chatPeekIn .22s var(--ease-out); }
#chat-guest-modal h3 { margin: 0 0 4px; font: 600 var(--fs-md, 1rem)/1.3 var(--font-head); color: var(--c-ink); }
#chat-guest-modal p { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); line-height: 1.5; color: var(--c-ink2); }
#chat-guest-name-input { width: 100%; box-sizing: border-box; height: var(--ctl-h, 44px); padding: 0 12px; border-radius: var(--r-control); background: var(--c-raised); border: 1px solid var(--c-line); font-size: 1rem; color: var(--c-ink); outline: 0; }
#chat-guest-name-input:focus { border-color: var(--c-accent); }
#chat-guest-modal-continue { width: 100%; height: var(--ctl-h, 44px); margin-top: var(--sp-3); border: 0; border-radius: var(--r-control); background: var(--c-accent); color: var(--c-on-accent, #fff); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
#chat-guest-modal-continue:disabled { opacity: .45; cursor: not-allowed; }

#chat-panel {
  position: fixed; bottom: calc(96px + var(--nb-bottom-inset, 0px)); z-index: 490;
  width: 384px; max-width: 100vw; height: 620px; max-height: 78vh; box-sizing: border-box;
  display: none; flex-direction: column; overflow: hidden; font-family: inherit;
  background: var(--c-bg); border: 1px solid var(--c-line2); border-radius: var(--r-sheet, 20px);
  box-shadow: 0 30px 70px -20px rgb(0 0 0 / .6), 0 8px 24px rgb(0 0 0 / .3);
  opacity: 0; transform: translateY(12px) scale(.98); transform-origin: bottom right;
  transition: opacity .2s var(--ease-out), transform .24s var(--ease-out);
}
#chat-panel[data-widget-pos="left"] { transform-origin: bottom left; }
#chat-panel.open { display: flex; z-index: 9999; }
#chat-panel.show { opacity: 1; transform: none; }
@media (min-width: 681px) { #chat-panel.open { bottom: 96px; max-height: min(78vh, calc(100vh - 116px)); } }
@media (prefers-reduced-motion: reduce) { #chat-panel { transform: none; transition: opacity .15s; } }

.chat-header { position: relative; flex: none; padding: 12px 14px 16px; overflow: hidden; border-bottom: 1px solid var(--c-line);
  background: radial-gradient(90% 120% at 100% 0%, rgb(var(--c-accent-rgb) / .22), transparent 62%), radial-gradient(circle, rgb(var(--c-accent-rgb) / .18) 1px, transparent 1.4px) 0 0/14px 14px, var(--c-surface); }
.chat-header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.chat-header-logo-row { display: flex; align-items: center; gap: 8px; }
.chat-header-logo { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; flex: none; }
.chat-header-title { font-size: var(--fs-sm); font-weight: 600; color: var(--c-ink); }
.chat-close-btn, .chat-chat-header-back, .chat-chat-header-close, .chat-sens-btn, .chat-chat-header-new, .chat-chat-header-switch-ai, .chat-chat-header-flag {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: none; color: var(--c-ink2);
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .85rem; transition: background .15s, color .15s; }
.chat-chat-header-close { display: none; }
@media (max-width: 680px) { .chat-chat-header-close { display: flex; } }
@media (hover: hover) { :is(.chat-close-btn, .chat-chat-header-back, .chat-chat-header-close, .chat-sens-btn, .chat-chat-header-new, .chat-chat-header-switch-ai, .chat-chat-header-flag):hover:not(:disabled) { background: var(--c-raised); color: var(--c-ink); } }
.chat-chat-header-switch-ai, .chat-chat-header-flag { margin-left: auto; }
.chat-chat-header-flag.flagged { color: var(--c-pos); cursor: default; }
.chat-chat-header-switch-ai:disabled { opacity: .5; cursor: default; }
.chat-header-art { position: absolute; right: 10px; bottom: 4px; pointer-events: none; }
.chat-header-art .il { display: block; }
.chat-header-greeting { max-width: 70%; margin: 0 0 2px; font: var(--display-wght, 700) 1.25rem/1.2 var(--font-head); color: var(--c-ink); text-wrap: balance; }
.chat-header-sub { max-width: 68%; font-size: var(--fs-xs); line-height: 1.45; color: var(--c-ink2); }

.chat-home-body { flex: 1; overflow-y: auto; padding: 12px; background: var(--c-bg); display: flex; flex-direction: column; gap: 10px; }
.chat-bot-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-card); transition: background .15s; }
.chat-bot-card:active { background: var(--c-raised); }
.chat-bot-avatar { position: relative; width: 36px; height: 36px; flex: none; border-radius: 50%; overflow: visible; }
.chat-bot-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.chat-bot-avatar::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-pos); box-shadow: 0 0 0 2px var(--c-surface); }
.chat-bot-card-name { font-size: var(--fs-sm); font-weight: 600; color: var(--c-ink); }
.chat-bot-card-sub { font-size: var(--fs-xs); color: var(--c-ink2); }
.chat-bot-card-time { flex: none; font-size: var(--fs-2xs); color: var(--c-ink3); }
.chat-header-sm { padding-bottom: 12px; }
.chat-header-sm .chat-header-top { margin-bottom: 0; }
.chat-header-sm .chat-header-greeting { max-width: none; margin: 0; font-size: 1.05rem; }
.chat-header-sm .chat-header-sub { max-width: none; margin-top: 4px; }
.chat-track-empty .il { display: block; margin: 0 auto 8px; }
.chat-cta-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; margin: 0; border: 0; border-radius: var(--r-control); background: var(--c-accent); color: var(--c-on-accent, #fff); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; transition: transform .12s var(--ease-out), filter .15s; }
.chat-cta-btn:active { transform: scale(.98); }
@media (hover: hover) { .chat-cta-btn:hover { filter: brightness(1.08); } }
.chat-cta-btn svg { width: 16px; height: 16px; }
.chat-quick { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-card); overflow: hidden; }
.chat-quick-card { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; margin: 0; cursor: pointer; background: none; border: 0; border-top: 1px solid var(--c-line); border-radius: 0; color: inherit; text-decoration: none; transition: background .15s; }
.chat-quick-card:first-child { border-top: 0; }
.chat-quick-card:active { background: var(--c-raised); }
@media (hover: hover) { .chat-quick-card:hover { background: color-mix(in srgb, var(--c-raised) 60%, transparent); } }
.chat-quick-card-icon { width: 24px; flex: none; display: grid; place-items: center; font-size: 1rem; color: var(--c-ink2); }
.chat-quick-pay .chat-quick-card-icon { color: var(--warn-fg, #d97706); }
.chat-quick-card-text { flex: 1; min-width: 0; }
.chat-quick-card-title { font-size: var(--fs-sm); font-weight: 500; color: var(--c-ink); }
.chat-quick-card-desc { font-size: var(--fs-xs); color: var(--c-ink3); }
.chat-quick-card svg.chevron { width: 12px; height: 12px; flex: none; color: var(--c-ink3); }
.chat-sla-note { display: flex; gap: 8px; align-items: flex-start; margin: 2px 2px 0; padding: 0; border: 0; background: none; font-size: var(--fs-xs); line-height: 1.5; color: var(--c-ink3); }
.chat-sla-note svg { flex: none; margin-top: 2px; color: var(--c-ink3); }
.chat-sla-note b { color: var(--c-ink2); font-weight: 600; }
.chat-sla-note a { color: var(--c-accent-ink); font-weight: 500; text-decoration: none; }
.chat-section-label { margin: 0 0 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--c-ink3); }

.chat-chat-header { flex: none; display: flex; align-items: center; gap: 4px; padding: 8px 6px 8px 4px; background: var(--c-surface); border-bottom: 1px solid var(--c-line); }
.chat-chat-header-avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--c-raised); }
.chat-chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-chat-header-avatar svg { width: 16px; height: 16px; }
.chat-chat-header-info { flex: 1; min-width: 0; margin-left: 4px; }
.chat-chat-header-name { font-size: var(--fs-sm); font-weight: 600; color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-chat-header-status { display: flex; align-items: center; gap: 5px; font-size: var(--fs-2xs); color: var(--c-ink2); white-space: nowrap; overflow: hidden; }
.chat-chat-header-status .dot { flex: none; }
#chatHeaderStatus { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-chat-header-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-pos); }
.chat-chat-header-rating { margin-top: 1px; display: flex; align-items: baseline; gap: 4px; font-size: var(--fs-2xs); }
.chat-chat-header-rating .num { color: var(--c-ink); font-weight: 600; }
.chat-chat-header-rating .stars { color: var(--c-warn); letter-spacing: 1px; }
.chat-mode { position: relative; isolation: isolate; margin-left: auto; flex: none; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--c-raised); border: 1px solid var(--c-line); }
/* The coloured side slides to whoever answers: AI or Team. */
.chat-mode::before { content: ""; position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px;
  background: var(--c-accent); box-shadow: 0 2px 8px rgb(var(--c-accent-rgb) / .35); transition: transform .3s cubic-bezier(.16,1,.3,1); }
.chat-mode.is-team::before { transform: translateX(100%); }
.chat-mode-btn { flex: 1 1 0; min-width: 50px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: var(--c-ink2); font-family: inherit; font-weight: 500; font-size: var(--fs-xs); line-height: 1; cursor: pointer; transition: color .2s; }
@media (max-width: 420px) { .chat-chat-header-back { width: 28px; } .chat-mode-btn { min-width: 40px; padding: 0 9px; } .chat-mode { padding: 2px; } .chat-mode::before { top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px); } }
.chat-mode-btn.on { color: var(--c-on-accent); font-weight: 600; cursor: default; }
@media (prefers-reduced-motion: reduce) { .chat-mode::before { transition: none; } }
.chat-mode-btn:disabled:not(.on) { opacity: .5; cursor: not-allowed; }

.chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; background: var(--c-bg); display: flex; flex-direction: column; gap: 10px; }
.chat-msg-meta { padding: 0 4px; font-size: var(--fs-2xs); font-weight: 500; color: var(--c-ink3); }
.chat-bubble { position: relative; padding: 9px 13px; border-radius: 18px; font-size: var(--fs-sm); line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.chat-msg-row.from-ai .chat-bubble, .chat-msg-row.from-admin .chat-bubble { background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line); border-bottom-left-radius: 6px; }
.chat-msg-row.from-visitor .chat-bubble { background: var(--c-accent); color: var(--c-on-accent, #fff); border: 0; border-bottom-right-radius: 6px; }
.chat-msg-row.from-visitor .chat-msg-bubble-stamp { color: inherit; opacity: .75; }
.chat-msg-row:is(.from-ai, .from-admin) .chat-bubble :is(.cf-link, .cf-ref) { color: var(--c-accent-ink); }
.chat-msg-row.from-system { align-self: center; max-width: 92%; }
.chat-msg-row.from-system .chat-bubble { padding: 2px 8px; background: none; border: 0; border-radius: 0; text-align: center; font-size: var(--fs-xs); font-style: normal; line-height: 1.45; color: var(--c-ink3); }
.chat-reply-quote { background: rgb(127 127 127 / .16); }

.chat-composer { flex: none; display: flex; align-items: flex-end; gap: 4px; max-width: 100%; box-sizing: border-box; overflow: hidden; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: var(--c-surface); border-top: 1px solid var(--c-line); }
.chat-composer textarea { flex: 1; min-width: 0; display: block; box-sizing: border-box; min-height: 40px; max-height: 118px; padding: 9px 14px; resize: none; overflow-y: auto; field-sizing: content; background: var(--c-raised); border: 1px solid transparent; border-radius: 20px; outline: 0; font: inherit; font-size: 1rem; line-height: 1.35; color: var(--c-ink); transition: border-color .15s; }
.chat-composer textarea::placeholder { color: var(--c-ink3); }
.chat-composer textarea:focus { border-color: var(--c-accent); }
.chat-send-btn, .chat-attach-btn, .chat-voice-btn { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s, transform .12s var(--ease-out); }
.chat-send-btn { margin-left: 2px; background: var(--c-accent); color: var(--c-on-accent, #fff); }
.chat-send-btn:active { transform: scale(.92); }
.chat-send-btn svg { width: 16px; height: 16px; }
.chat-attach-btn, .chat-voice-btn { background: none; color: var(--c-ink2); }
@media (hover: hover) { .chat-attach-btn:hover, .chat-voice-btn:hover { background: var(--c-raised); color: var(--c-ink); } }

.chat-bottomnav { flex: none; display: flex; background: var(--c-surface); border-top: 1px solid var(--c-line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.chat-nav-item { position: relative; flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 4px; border: 0; background: none; color: var(--c-ink3); font-family: inherit; cursor: pointer; transition: color .15s; }
.chat-nav-item svg { width: 20px; height: 20px; }
.chat-nav-item span { font-size: var(--fs-2xs); font-weight: 500; }
.chat-nav-item.active { color: var(--c-ink); }
.chat-nav-item.active::before { content: ''; position: absolute; top: 0; left: 50%; width: 20px; height: 2px; margin-left: -10px; border-radius: 0 0 2px 2px; background: var(--c-accent); }

#chat-launcher:hover { transform: scale(1.07); }

@keyframes chatNudge {
  0%, 100% { transform: translateY(0) rotate(0); }
  15%      { transform: translateY(-7px) rotate(-8deg); }
  30%      { transform: translateY(0)    rotate(7deg); }
  45%      { transform: translateY(-4px) rotate(-5deg); }
  60%      { transform: translateY(0)    rotate(0); }
}
#chat-launcher.chat-nudge { animation: chatNudge 1.1s ease-in-out 1; }
@media (prefers-reduced-motion: reduce) {
  #chat-launcher.chat-nudge { animation: none; }
}

@media (max-width: 680px) {

  #chat-launcher {
    bottom: max(85px, calc(var(--nb-bottom-inset, 0px) + 12px));
    width: 52px; height: 52px;
  }
}
#chat-peek-bubble .chat-peek-close:hover { background: var(--chat-blue); color: #fff; }
@keyframes chatPeekIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 680px) {
  #chat-peek-bubble { bottom: 85px; max-width: 210px; }
}
#chat-guest-modal-continue:not(:disabled):hover { background: var(--chat-blue-light); }
@keyframes chatGuestModalIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 680px) {
  #chat-panel {
    inset: 0 !important;
    bottom: 0 !important; right: 0 !important; left: 0 !important; top: 0 !important;
    width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; z-index: 700;
  }
  #chat-panel.kb-fit {
    top: var(--chat-vv-top, 0px) !important; bottom: auto !important;
    height: var(--chat-vv-h, 100%) !important; max-height: none;
  }
  #chat-panel.kb-open { box-shadow: 0 0 0 100vmax var(--chat-bg); }
  #chat-panel.kb-open .chat-bottomnav { display: none; }
}

@media (min-width: 681px) {
  #chat-panel.open {
    bottom: 120px;
    max-height: min(78vh, calc(100vh - 140px));
  }
}

.chat-view { display: none; flex: 1; flex-direction: column; overflow: hidden; height: 100%; }
.chat-view.active { display: flex; }
.chat-close-btn:hover { background: rgba(255,255,255,0.25); }
.chat-bot-card:hover { background: var(--chat-bg-hover); }
.chat-bot-avatar svg { width: 20px; height: 20px; }
.chat-quick-card:hover { background: var(--chat-bg-hover); }
.chat-cta-btn:hover { background: var(--pos); }
.chat-chat-header-back:hover { background: rgba(255,255,255,0.25); }
.chat-sens-btn:hover { background: rgba(255,255,255,0.28); }
.chat-sens-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 12px 8px; padding: 9px 11px; border-radius: 12px;
  font-size: .72rem; line-height: 1.45; color: var(--chat-text); background: color-mix(in srgb,var(--neg) 10%,transparent); border: 1px solid color-mix(in srgb,var(--neg) 35%,transparent); }
.chat-sens-bar[hidden] { display: none; }
.chat-sens-bar.is-calm { background: var(--chat-bg-raised); border-color: var(--chat-border); }
.chat-sens-bar .csb-t { flex: 1 1 180px; }
.chat-sens-bar .csb-acts { display: flex; gap: 6px; margin-left: auto; }
.chat-sens-bar button { border: 1px solid var(--chat-border); background: var(--chat-bg-raised); color: var(--chat-text); font-weight: 600; font-size: .7rem; line-height: 1; font-family: inherit;
  padding: 8px 11px; min-height: 32px; border-radius: 999px; cursor: pointer; }
.chat-sens-bar button.csb-del { background: var(--neg); border-color: var(--neg); color: #fff; }
.chat-sens-bar button.csb-ask { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.chat-sens-bar button:disabled { opacity: .6; cursor: default; }
.chat-mode-btn:hover:not(:disabled):not(.on) { color: var(--c-ink); }
.chat-chat-header-new:hover { background: rgba(255,255,255,0.25); }
.chat-chat-header-switch-ai:hover:not(:disabled) { background: rgb(var(--blue-rgb) / .35); color: var(--blue-light); }
.chat-chat-header-flag:hover:not(:disabled) { background: color-mix(in srgb,var(--warn-fg) 35%,transparent); color: #fde68a; }
.chat-chat-header-flag:disabled { cursor: default; }
@media (max-width: 680px) { .chat-chat-header-close { display: flex; } }
.chat-msg-row { display: flex; flex-direction: column; gap: 3px; max-width: 86%; animation: chatMsgIn .25s ease; }
.chat-msg-row.from-visitor { align-self: flex-end; }
.chat-msg-row.from-ai, .chat-msg-row.from-admin { align-self: flex-start; }
.chat-msg-row.grouped { margin-top: -6px; }
.chat-msg-row.from-visitor .chat-msg-meta { text-align: right; }

.chat-upload-overlay {
  position: absolute; inset: 0; border-radius: 10px; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: rgba(5,8,20,.55); color: #fff;
}
.chat-upload-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: chatUploadSpin .8s linear infinite;
}
@keyframes chatUploadSpin { to { transform: rotate(360deg); } }
.chat-upload-pct { font-size: .68rem; font-weight: 700; }

.chat-msg-row:has(.cf-table-wrap, .cf-codeblock, .cf-callout) { max-width: 94%; }

.chat-human-check {
  align-self: center; width: min(320px, 100%); margin: 8px 0; padding: 12px;
  border: 1px solid var(--chat-border); border-radius: 12px; background: var(--chat-bg-hover); text-align: center;
}
.chat-human-check p { margin: 0 0 8px; font-size: .8rem; color: var(--chat-text-sub); }

.chat-msg-edited-tag { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .8; }

.chat-msg-bubble-stamp {
  display: block; margin-top: 4px; font-size: .62rem; opacity: .7; text-align: right;
  line-height: 1.3;
}

.chat-msg-actions {
  display: flex; gap: 4px; margin-top: 3px; opacity: 0;
  transition: opacity .15s ease; pointer-events: none;
}
.chat-msg-row.from-visitor .chat-msg-actions { justify-content: flex-end; }
.chat-msg-row:hover .chat-msg-actions,
.chat-msg-row:focus-within .chat-msg-actions { opacity: 1; pointer-events: auto; }
.chat-msg-action-btn {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  background: var(--chat-bg-hover); border: 1px solid var(--chat-border); border-radius: 50%;
  color: var(--chat-text-sub); font-size: .62rem; cursor: pointer; padding: 0;
  transition: background .15s, color .15s;
}
.chat-msg-action-btn:hover { background: var(--chat-bg-active, var(--chat-bg-hover)); color: var(--chat-text); }
.chat-msg-action-btn.copied { color: var(--pos); border-color: var(--pos); }
.chat-msg-action-btn:disabled { opacity: .5; cursor: default; }
@media (hover: hover) {
  .chat-msg-actions { position: absolute; bottom: -10px; left: 8px; margin: 0; z-index: 2; }
  .chat-msg-row.from-visitor .chat-msg-actions { left: auto; right: 8px; }
}
@media (hover: none) {
  .chat-msg-actions { display: none; }
  .chat-msg-row.chat-acts-open .chat-msg-actions { display: flex; opacity: 1; pointer-events: auto; }
  .chat-msg-row.chat-acts-open .chat-msg-action-btn { width: 30px; height: 30px; font-size: .7rem; }
}

.chat-msg-row { position: relative; touch-action: pan-y; }
.nb-swipe-reply-icon {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%; background: var(--chat-bg-hover);
  color: var(--chat-accent, var(--chat-blue)); display: flex; align-items: center; justify-content: center;
  font-size: .7rem; opacity: 0; pointer-events: none;
}
.chat-reply-quote-who { font-weight: 700; opacity: .85; }
.chat-reply-quote-snip { opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
@keyframes chatFlash { 0%, 100% { filter: none; } 35% { filter: brightness(1.35); } }

.chat-bubble.chat-flash,
.chat-msg-row.chat-flash .chat-bubble { animation: chatFlash .9s ease; }

.chat-reply-preview {
  display: none; align-items: center; gap: 8px; padding: 7px 12px;
  border-top: 1px solid var(--chat-border); background: var(--chat-bg-hover);
}
.chat-reply-preview > i { color: var(--chat-accent, var(--chat-blue)); font-size: .75rem; flex-shrink: 0; }
.chat-reply-preview-info { flex: 1; min-width: 0; }
.chat-reply-preview-who { font-size: .68rem; font-weight: 700; color: var(--chat-accent, var(--chat-blue)); }
.chat-reply-preview-snip { font-size: .72rem; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-preview-remove {
  background: none; border: none; color: var(--chat-text-sub); cursor: pointer; padding: 4px; flex-shrink: 0;
}

.chat-msg-edit-wrap { margin: 4px 0; display: flex; flex-direction: column; gap: 6px; }
.chat-msg-edit-input {
  width: 100%; min-height: 52px; resize: vertical; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.15); color: #fff;
  font-size: .8rem; font-family: inherit; padding: 6px 8px; line-height: 1.5;
}
.chat-msg-row.from-ai .chat-msg-edit-input, .chat-msg-row.from-admin .chat-msg-edit-input {
  background: var(--chat-bg); color: var(--chat-text); border-color: var(--chat-border);
}
.chat-msg-edit-actions { display: flex; justify-content: flex-end; gap: 6px; }
.chat-msg-edit-save, .chat-msg-edit-cancel {
  font-size: .65rem; font-weight: 700; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.chat-msg-edit-save { background: #fff; color: var(--blue-dark, #1d4ed8); }
.chat-msg-edit-save:disabled, .chat-msg-edit-cancel:disabled { opacity: .6; cursor: default; }
.chat-msg-edit-cancel { background: transparent; color: inherit; border-color: rgba(255,255,255,.4); }

.chat-typing-dots { display: inline-flex; gap: 3px; padding: 4px 2px; }
.chat-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--chat-text-muted);
  animation: chatTyping 1.2s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chatTyping { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes chatMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-seen-dot { align-self: flex-end; display: block; width: 16px; height: 16px; margin: 1px 2px 0 0; border-radius: 50%; overflow: hidden; background: #fff; box-shadow: 0 0 0 1.5px var(--nw-bg, #0b1220); animation: chatSeenIn .3s var(--ease-out, cubic-bezier(.23, 1, .32, 1)) both; }
.chat-seen-dot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-msg-row.chat-queued .chat-bubble { opacity: .6; }
.chat-msg-row.chat-queued::after { content: 'Sends after the reply'; align-self: flex-end; font-size: 11px; color: var(--chat-text-sub); }
@keyframes chatSeenIn { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.chat-seen-row {
  text-align: right; padding: 3px 16px; font-size: .6rem; color: var(--chat-text-muted);
  background: var(--chat-bg); flex-shrink: 0; border-top: 1px solid transparent;
}

.chat-inline-handoff {
  display: flex; justify-content: center; padding: 4px 14px 10px; flex-shrink: 0; background: var(--chat-bg);
}
.chat-inline-handoff button {
  display: flex; align-items: center; gap: 6px;
  background: var(--chat-bg-raised); border: 1px solid var(--chat-blue-light);
  color: var(--chat-blue-light); font-family: inherit; font-size: .74rem; font-weight: 700;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; transition: background .15s;
}
.chat-inline-handoff button:hover { background: var(--chat-bg-hover); }

.chat-feedback-wrap { align-self: center; margin: 2px 0 8px; }

.chat-feedback-chip {
  display: flex; align-items: center; gap: 6px; background: var(--chat-bg-raised);
  border: 1px solid var(--chat-border); border-radius: 999px; padding: 5px 12px;
  font-size: .7rem; font-weight: 600; color: var(--chat-text-sub); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chat-feedback-chip:hover { background: var(--chat-bg-hover); }
.chat-feedback-chip.rated { color: var(--chat-text); border-color: var(--warn-fg); }
.chat-feedback-chip-stars { color: var(--warn-fg); letter-spacing: 1px; font-size: .75rem; }
.chat-rate-ask {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 14px 6px;
  background: color-mix(in srgb,var(--warn-fg) 8%,transparent); border: 1px solid color-mix(in srgb,var(--warn-fg) 35%,transparent); border-radius: 14px;
}
.chat-rate-ask-t { font-size: .74rem; font-weight: 700; color: var(--chat-text); }
.chat-rate-ask-stars { display: flex; gap: 2px; }
.chat-rate-ask-stars button {
  background: none; border: 0; padding: 4px; min-width: 32px; min-height: 32px; cursor: pointer;
  font-size: 1.45rem; line-height: 1; color: color-mix(in srgb,var(--warn-fg) 45%,transparent); transition: color .12s, transform .12s;
}
.chat-rate-ask-stars:hover button { color: var(--warn-fg); }
.chat-rate-ask-stars button:hover ~ button { color: color-mix(in srgb,var(--warn-fg) 45%,transparent); }
.chat-rate-ask-stars button:hover { transform: scale(1.12); }
.chat-rate-ask.nudge { animation: chatRateNudge 1.2s ease 2; }
@keyframes chatRateNudge { 50% { box-shadow: 0 0 0 6px color-mix(in srgb,var(--warn-fg) 18%,transparent); border-color: var(--warn-fg); } }
@media (prefers-reduced-motion: reduce) { .chat-rate-ask.nudge { animation: none; } }

.chat-feedback-card {
  width: 260px; max-width: calc(100vw - 48px); margin: 0 auto;
  background: var(--chat-bg-raised); border: 1px solid var(--chat-border); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.chat-feedback-title { font-size: .82rem; font-weight: 700; color: var(--chat-text); text-align: center; }
.chat-feedback-stars { display: flex; justify-content: center; gap: 6px; }
.chat-feedback-star {
  background: none; border: none; cursor: pointer; padding: 2px; font-size: 1.3rem;
  color: var(--chat-border); transition: color .15s, transform .1s;
}
.chat-feedback-star:hover { transform: scale(1.12); }
.chat-feedback-star.selected { color: var(--warn-fg); }
.chat-feedback-comment {
  width: 100%; min-height: 52px; resize: vertical; border-radius: 8px;
  border: 1px solid var(--chat-border); background: var(--chat-bg); color: var(--chat-text);
  font-size: .78rem; font-family: inherit; padding: 8px 10px; line-height: 1.5;
}
.chat-feedback-actions { display: flex; justify-content: flex-end; gap: 8px; }
.chat-feedback-dismiss, .chat-feedback-submit, .chat-feedback-collapse {
  font-size: .72rem; font-weight: 700; padding: 6px 14px; border-radius: 999px; cursor: pointer; border: 1px solid transparent;
}
.chat-feedback-dismiss { background: transparent; color: var(--chat-text-sub); border-color: var(--chat-border); }
.chat-feedback-dismiss:hover { background: var(--chat-bg-hover); }
.chat-feedback-submit { background: var(--chat-blue); color: #fff; }
.chat-feedback-submit:disabled { opacity: .5; cursor: default; }
.chat-feedback-submit:not(:disabled):hover { background: var(--chat-blue-light); }
.chat-feedback-readonly-stars { text-align: center; color: var(--warn-fg); font-size: 1.1rem; letter-spacing: 2px; }
.chat-feedback-readonly-comment { font-size: .78rem; color: var(--chat-text-sub); font-style: italic; text-align: center; line-height: 1.4; }
.chat-feedback-collapse { align-self: center; background: transparent; color: var(--chat-text-sub); border-color: var(--chat-border); }
.chat-feedback-collapse:hover { background: var(--chat-bg-hover); }
.chat-send-btn:hover { background: var(--blue-dark, #1d4ed8); }
.chat-attach-btn:hover, .chat-voice-btn:hover { background: var(--chat-bg-hover); color: var(--chat-text); }
.chat-attach-btn svg, .chat-voice-btn svg { width: 16px; height: 16px; }
.chat-voice-btn.recording { background: var(--neg); border-color: var(--neg); color: #fff; animation: chatPulseRec 1.2s infinite; }
@keyframes chatPulseRec { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb,var(--neg) 50%,transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb,var(--neg) 0%,transparent); } }

.chat-secret-warn {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; flex-shrink: 0; box-sizing: border-box; max-width: 100%;
  border-top: 1px solid color-mix(in srgb,var(--warn-fg) 35%,transparent); background: color-mix(in srgb,var(--warn-fg) 9%,var(--chat-bg-raised));
  animation: chatSecretIn .18s ease-out;
}
.chat-secret-warn[hidden] { display: none; }
.chat-secret-warn > i { color: var(--warn-fg); font-size: .9rem; margin-top: 2px; flex-shrink: 0; }
.chat-secret-warn-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-secret-warn-text strong { font-size: .78rem; color: var(--chat-text); }
.chat-secret-warn-text span { font-size: .7rem; line-height: 1.4; color: var(--chat-text-sub); }
.chat-secret-warn-acts { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.chat-secret-warn-acts button { min-height: 32px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: .72rem; line-height: 1; font-family: inherit; cursor: pointer; white-space: nowrap; }
.chat-secret-edit { border: none; background: var(--chat-accent, var(--chat-blue)); color: #fff; }
.chat-secret-send { border: 1px solid var(--chat-border); background: transparent; color: var(--chat-text-sub); }
.chat-secret-send:hover { color: var(--chat-text); background: var(--chat-bg-hover); }
@keyframes chatSecretIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-secret-warn { animation: none; } }

.chat-attach-preview {
  display: none; align-items: center; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--chat-border); background: var(--chat-bg-raised); flex-shrink: 0;
  max-width: 100%; box-sizing: border-box;
}
.chat-attach-preview.show { display: flex; }
.chat-attach-preview-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--chat-bg-hover); flex-shrink: 0;
}
.chat-attach-preview-icon {
  width: 40px; height: 40px; border-radius: 8px; background: var(--chat-bg-hover); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--chat-text-sub); font-size: 1.1rem;
}
.chat-attach-preview-info { flex: 1; min-width: 0; }
.chat-attach-preview-name { font-size: .74rem; color: var(--chat-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-attach-preview-size { font-size: .64rem; color: var(--chat-text-muted); }
.chat-attach-preview-remove {
  width: 26px; height: 26px; border-radius: 50%; border: none; background: transparent;
  color: var(--chat-text-sub); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.chat-attach-preview-remove:hover { background: var(--chat-bg-hover); color: var(--neg); }

.chat-msg-attachment-img {
  max-width: 100%; max-height: 220px; border-radius: 10px; display: block; cursor: pointer; margin-bottom: 4px;
}
.chat-msg-attachment-video {
  max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin-bottom: 4px;
}
.chat-msg-attachment-audio { width: 220px; max-width: 100%; display: block; margin-bottom: 4px; height: 34px; }
.chat-msg-caption { margin-top: 2px; }

.chat-lightbox {
  position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.85);
  display: none; align-items: center; justify-content: center; padding: 30px;
  cursor: zoom-out;
}
.chat-lightbox.show { display: flex; }
.chat-lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

.chat-talk-human-link {
  text-align: center; padding: 8px; font-size: .68rem; color: var(--chat-text-muted);
  border-top: 1px solid var(--chat-border); flex-shrink: 0; background: var(--chat-bg);
  display: none;
}
.chat-talk-human-link button {
  background: none; border: none; color: var(--chat-blue-light); font-weight: 600; cursor: pointer;
  font-size: .68rem; font-family: inherit; text-decoration: underline;
}

.chat-help-body { flex: 1; overflow-y: auto; padding: 14px 16px; background: var(--chat-bg); }
.chat-faq-item {
  background: var(--chat-bg-raised); border: 1px solid var(--chat-border); border-radius: 10px;
  margin-bottom: 8px; overflow: hidden;
}
.chat-faq-q {
  padding: 11px 13px; font-size: .76rem; font-weight: 600; color: var(--chat-text);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.chat-faq-q svg { width: 12px; height: 12px; color: var(--chat-text-muted); flex-shrink: 0; transition: transform .2s; }
.chat-faq-item.open .chat-faq-q svg { transform: rotate(180deg); }
.chat-faq-a { padding: 0 13px; font-size: .72rem; color: var(--chat-text-sub); line-height: 1.6; max-height: 0; overflow: hidden; transition: max-height .2s ease, padding .2s ease; }
.chat-faq-item.open .chat-faq-a { padding: 0 13px 12px; max-height: 300px; }

.chat-track-body { flex: 1; overflow-y: auto; padding: 14px 16px; background: var(--chat-bg); }
.chat-track-input-row { display: flex; gap: 8px; margin-bottom: 14px; }
.chat-track-input-row input {
  flex: 1; background: var(--chat-bg-raised); border: 1px solid var(--chat-border);
  border-radius: 8px; padding: 9px 12px; font-size: .78rem; color: var(--chat-text); outline: none; font-family: inherit;
}
.chat-track-input-row input:focus { border-color: var(--chat-blue); }
.chat-track-input-row button {
  background: var(--chat-blue); color: #fff; border: none; border-radius: 8px; padding: 9px 16px;
  font-size: .76rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.chat-track-result { background: var(--chat-bg-raised); border: 1px solid var(--chat-border); border-radius: 10px; padding: 14px; display: none; }
.chat-track-result.show { display: block; }
.chat-track-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: .74rem; border-bottom: 1px solid var(--chat-border); }
.chat-track-row:last-child { border-bottom: none; }
.chat-track-row .lbl { color: var(--chat-text-muted); }
.chat-track-row .val { color: var(--chat-text); font-weight: 600; }
.chat-track-empty, .chat-track-error { text-align: center; padding: 30px 10px; color: var(--chat-text-muted); font-size: .76rem; }
.chat-status-pill { font-size: .62rem; font-weight: 700; padding: 2px 9px; border-radius: 99px;  }
.chat-status-pill.pending  { background: color-mix(in srgb,var(--warn-fg) 15%,transparent); color: var(--warn-fg); }
.chat-status-pill.completed{ background: color-mix(in srgb,var(--pos) 15%,transparent);  color: var(--pos); }
.chat-status-pill.failed   { background: color-mix(in srgb,var(--neg) 15%,transparent);  color: var(--neg); }
.chat-status-pill.refunded { background: rgb(var(--blue-rgb, 37 99 235) / .15); color: var(--blue-light); }

.chat-tickets-body { flex: 1; overflow-y: auto; padding: 10px 12px; background: var(--chat-bg); }
.chat-ticket-item {
  display: flex; gap: 10px; align-items: center; padding: 11px 10px; border-radius: 10px;
  cursor: pointer; transition: background .15s; margin-bottom: 4px;
}
.chat-ticket-item:hover { background: var(--chat-bg-hover); }
.chat-ticket-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--chat-bg-hover); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--chat-blue-light); }
.chat-ticket-avatar svg { width: 17px; height: 17px; }
.chat-ticket-text { flex: 1; min-width: 0; }
.chat-ticket-title { font-size: .76rem; font-weight: 700; color: var(--chat-text); display: flex; align-items: center; gap: 4px; }
.chat-ticket-preview { font-size: .68rem; color: var(--chat-text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-ticket-meta { text-align: right; flex-shrink: 0; }
.chat-ticket-time { font-size: .6rem; color: var(--chat-text-muted); }

.chat-tickets-header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 4px; flex-shrink: 0;
  border-bottom: 1px solid var(--chat-border);
  background: var(--chat-bg);
}
.chat-tickets-header-row .chat-tickets-title {
  font-size: .78rem; font-weight: 700; color: var(--chat-text);
}
.chat-new-chat-icon-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--chat-bg-raised); border: 1px solid var(--chat-border);
  color: var(--chat-blue-light); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-new-chat-icon-btn:hover { background: var(--chat-bg-hover); }
.chat-new-chat-icon-btn svg { width: 14px; height: 14px; }

.chat-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 30px; text-align: center; color: var(--chat-text-muted); gap: 8px; }
.chat-empty-state .il { display: block; }
.chat-empty-state p { font-size: var(--fs-sm); color: var(--c-ink2); max-width: 26ch; line-height: 1.45; }

.chat-rate-sheet { position: relative; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px 14px;
  background: var(--chat-bg-raised); border-top: 1px solid var(--chat-border); border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 30px rgba(0,0,0,.28); animation: chatSheetUp .32s cubic-bezier(.2,.8,.3,1); }
.chat-rate-sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--chat-border); }
.chat-rate-sheet.out { animation: chatSheetDown .18s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes chatSheetUp { from { clip-path: inset(100% 0 0 0); opacity: .3; } }
@keyframes chatSheetDown { to { clip-path: inset(100% 0 0 0); opacity: 0; } }
.chat-rate-sheet-x { position: absolute; top: 9px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--chat-bg-hover); color: var(--chat-text-sub); cursor: pointer; font-size: .8rem; }
.chat-rate-sheet-sub { margin-top: -6px; text-align: center; font-size: .7rem; color: var(--chat-text-sub); line-height: 1.4; padding: 0 24px; }
.chat-rate-sheet .chat-feedback-star { font-size: 2rem; line-height: 1; color: rgba(148,163,184,.45); }
.chat-rate-sheet .chat-feedback-star.selected { color: var(--warn-fg); }
@media (hover: hover) { .chat-rate-sheet .chat-feedback-stars:hover .chat-feedback-star { color: var(--warn-fg); } .chat-rate-sheet .chat-feedback-star:hover ~ .chat-feedback-star { color: rgba(148,163,184,.45); } }
.chat-rate-sheet .chat-feedback-actions > button { flex: 1; }
.chat-rate-sheet-done { padding: 22px 0; text-align: center; font-weight: 700; color: var(--warn-fg); animation: chatSheetUp .25s ease-out; }
.chat-feedback-wrap.on .chat-rate-ask { border-color: var(--warn-fg); box-shadow: 0 0 0 4px color-mix(in srgb,var(--warn-fg) 16%,transparent); }
@media (prefers-reduced-motion: reduce) { .chat-rate-sheet, .chat-rate-sheet.out, .chat-rate-sheet-done { animation: none; } }

#chat-launcher.cl-free { left: 0 !important; right: auto !important; top: 0 !important; bottom: auto !important;
  translate: calc(var(--clx, 0px) + var(--cl-tuck, 0px)) var(--cly, 0px); touch-action: none; }
#chat-launcher.cl-anim { transition: translate .5s cubic-bezier(.34,1.56,.64,1), opacity .3s, filter .3s, transform .2s ease, box-shadow .2s; }
#chat-launcher.cl-drag { transition: transform .15s ease, box-shadow .15s; transform: scale(1.12); box-shadow: 0 16px 36px rgb(var(--blue-rgb, 37 99 235) / .55); cursor: grabbing; }
#chat-launcher.cl-idle { --cl-tuck: 24px; opacity: .55; filter: saturate(.7); }
#chat-launcher.cl-idle.cl-left { --cl-tuck: -24px; }
#chat-launcher.cl-over { --cl-tuck: 34px; opacity: .72; }
#chat-launcher.cl-over.cl-left { --cl-tuck: -34px; }
#chat-launcher.cl-over:is(:hover, :focus-visible) { --cl-tuck: 0px; opacity: 1; }
#chat-launcher.cl-land { animation: clLand .55s ease; }
@keyframes clLand { 30% { transform: scale(1.16, .86); } 60% { transform: scale(.94, 1.07); } }
@media (prefers-reduced-motion: reduce) { #chat-launcher.cl-anim { transition: opacity .2s; } #chat-launcher.cl-land { animation: none; } }

html.nb-chat-full .hdr, html.nb-chat-full .bottom-nav, html.nb-chat-full .nb-sky, html.nb-chat-full .nbf-sky, html.nb-chat-full .nbf-fore,
html.nb-chat-full #main-content, html.nb-chat-full .footer, html.nb-chat-full #nb-bottom-stack, html.nb-chat-full #chat-launcher { visibility: hidden; }
html.nb-chat-full .nb-sky span { animation-play-state: paused; }
.chat-track-input-row input { height: 44px; padding: 0 12px; font-size: 1rem; border-radius: var(--r-control); }
.chat-track-input-row button { height: 44px; padding: 0 16px; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-control); }
/* While the page scrolls down the button steps aside, so it never sits on what is being read; it returns on scroll up or when scrolling stops. */
#chat-launcher.is-away { transform: scale(.6); opacity: 0; pointer-events: none; }
#chat-launcher { transition: bottom .22s var(--ease-out), transform .24s cubic-bezier(.22,1,.36,1), opacity .18s ease, visibility .16s; }
@media (prefers-reduced-motion: reduce) { #chat-launcher { transition: opacity .15s linear; } #chat-launcher.is-away { transform: none; } }
/* The app's chat bubble (/chat): only the conversation, edge to edge, nothing to close. */
html.nb-chat-only, html.nb-chat-only body { height: 100%; overflow: hidden; background: var(--c-bg); }
html.nb-chat-only #chat-launcher, html.nb-chat-only #chat-peek-bubble, html.nb-chat-only [data-chat-close] { display: none !important; }
html.nb-chat-only #chat-panel { display: flex; opacity: 1; transform: none; inset: 0 !important; width: 100%; height: 100%; max-width: none; max-height: none; border: 0; border-radius: 0; box-shadow: none; transition: none; }

.nb-clip { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--chat-border, var(--border)); background: var(--chat-bg-raised, var(--bg-raised)); flex-shrink: 0; }
.nb-clip[hidden] { display: none; }
.nb-clip-go { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--chat-border, var(--border)); border-radius: 12px; background: var(--chat-bg-hover, var(--bg-hover)); color: var(--chat-text, var(--text)); font-weight: 600; font-size: .84rem; line-height: 1.2; font-family: inherit; text-align: left; cursor: pointer; }
.nb-clip-go:active { transform: scale(.98); }
.nb-clip-ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--chat-accent, var(--chat-blue, var(--blue))); background: color-mix(in srgb, currentColor 14%, transparent); }
.nb-clip-ic svg { width: 16px; height: 16px; }
.nb-clip-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-clip-x { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--chat-text-sub, var(--text-sub)); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.nb-clip-x svg { width: 16px; height: 16px; }
.nb-clip-x:hover { background: var(--chat-bg-hover, var(--bg-hover)); }
.nb-tray { padding: 8px 12px 10px; border-top: 1px solid var(--chat-border, var(--border)); background: var(--chat-bg-raised, var(--bg-raised)); flex-shrink: 0; }
.nb-tray[hidden] { display: none; }
.nb-tray-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: .76rem; color: var(--chat-text-sub, var(--text-sub)); }
.nb-tray-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.nb-tray-clear { border: 0; background: none; padding: 4px 2px; color: var(--chat-text-sub, var(--text-sub)); font: inherit; font-weight: 600; cursor: pointer; }
.nb-tray-clear:hover { color: var(--c-neg, #ef4444); }
.nb-tray-row { display: flex; gap: 8px; overflow-x: auto; padding: 6px 6px 2px 0; scrollbar-width: none; overscroll-behavior-x: contain; }
.nb-tray-row::-webkit-scrollbar { display: none; }
.nb-tray-tile, .nb-tray-add { position: relative; flex: 0 0 64px; width: 64px; height: 64px; border-radius: 12px; }
.nb-tray-tile { overflow: visible; background: var(--chat-bg-hover, var(--bg-hover)); border: 1px solid var(--chat-border, var(--border)); }
.nb-tray-tile img, .nb-tray-tile video { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; display: block; }
.nb-tray-tile img { cursor: zoom-in; }
.nb-tray-ext { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; letter-spacing: .02em; color: var(--chat-text-sub, var(--text-sub)); }
.nb-tray-badge { position: absolute; left: 6px; bottom: 6px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #fff; background: rgba(0,0,0,.55); }
.nb-tray-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--chat-bg-raised, var(--bg-raised)); background: var(--chat-text, var(--text)); color: var(--chat-bg-raised, var(--bg-raised)); font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.nb-tray-x::after { content: ''; position: absolute; inset: -9px; }
.nb-tray-add { border: 1.5px dashed var(--chat-border-strong, var(--border-strong, var(--border))); background: none; color: var(--chat-text-sub, var(--text-sub)); font-size: 26px; font-weight: 300; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.nb-tray-add:hover { color: var(--chat-accent, var(--chat-blue, var(--blue))); border-color: currentColor; }
.nb-tray-st { position: absolute; inset: 0; border-radius: 11px; pointer-events: none; }
.nb-tray-st.wait { background: rgba(0,0,0,.35); }
.nb-tray-st.sending { background: rgba(0,0,0,.35); }
.nb-tray-st.sending::after { content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: nbTraySpin .8s linear infinite; }
.nb-tray-st.done { background: rgba(0,0,0,.25); }
.nb-tray-st.done::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; }
.nb-tray-st.fail { background: rgba(220,38,38,.55); }
.nb-tray-st.fail::after { content: '!'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 18px; }
@keyframes nbTraySpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nb-tray-st.sending::after { animation: none; } }
.chat-msg-row.nb-alb { margin-top: -7px; }
.chat-msg-row[data-img="1"]:has(+ .nb-alb) .chat-msg-bubble-stamp { display: none; }
.nb-alb .cf-img { max-width: 168px; max-height: 120px; object-fit: cover; }
.nb-drop-on { outline: 2px dashed var(--chat-accent, var(--chat-blue, var(--blue))); outline-offset: -6px; }
@media (prefers-reduced-motion: reduce) { .nb-clip-go:active { transform: none; } }
