/* ═══════════════════════════════════════════════════════════
   FRESH BAZAAR — COMMUNITY CHAT WIDGET
   Mobile-first • Customer-friendly • Built on the main design tokens
═══════════════════════════════════════════════════════════ */

.fb-chat {
    --fbc-green:        var(--green-600, #059669);
    --fbc-green-dk:     var(--green-700, #047857);
    --fbc-green-dkr:    var(--green-800, #065f46);
    --fbc-own:          var(--green-600, #059669);
    --fbc-own-text:     #ffffff;
    --fbc-other:        #ffffff;
    --fbc-other-text:   var(--dark, #0d1117);
    --fbc-bg:           #eef5f1;
    --fbc-border:       var(--border, #e5e7eb);
    --fbc-muted:        var(--muted, #6b7280);
    --fbc-radius:       var(--radius, 14px);
    --fbc-shadow:       0 24px 60px rgba(4,120,87,.18), 0 8px 24px rgba(15,23,42,.14);
    --fbc-launcher-z:   96;
    --fbc-panel-z:      9999;
    --fbc-backdrop-z:   9998;
    font-family: var(--font-body, 'Plus Jakarta Sans', system-ui, sans-serif);
}

/* CRITICAL: the [hidden] attribute must always win over the display:flex/grid/block
   rules below. Without this, elements like the image-preview overlay, the emoji /
   sticker trays, the reply bar, the typing row and the panel itself stay visible
   even when JS marks them hidden, because an author `display:` declaration beats
   the browser's default `[hidden] { display:none }`. This single rule restores the
   intended show/hide behaviour for every element in the widget. */
.fb-chat [hidden] { display: none !important; }

/* ─── LAUNCHER ───────────────────────────────────────────── */
.fb-chat-launcher {
    position: fixed;
    left: 20px;
    bottom: 24px;
    z-index: var(--fbc-launcher-z);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 54px;
    padding: 0 20px 0 15px;
    border: none;
    border-radius: var(--radius-full, 999px);
    background: linear-gradient(135deg, var(--fbc-green) 0%, var(--fbc-green-dk) 100%);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -.01em;
    box-shadow: 0 8px 22px rgba(4,120,87,.42), 0 2px 6px rgba(0,0,0,.12);
    transition: transform var(--dur-fast,160ms) var(--ease-spring, cubic-bezier(.34,1.56,.64,1)),
                box-shadow var(--dur-fast,160ms), filter var(--dur-fast,160ms);
}
.fb-chat-launcher:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow: 0 12px 30px rgba(4,120,87,.5), 0 3px 8px rgba(0,0,0,.14);
}
.fb-chat-launcher:active { transform: translateY(0) scale(.97); }
.fb-chat-launcher:focus-visible { outline: 3px solid rgba(4,120,87,.4); outline-offset: 3px; }
.fb-chat-launcher__icon { display: inline-flex; flex-shrink: 0; }
.fb-chat-launcher__label { white-space: nowrap; }
.fb-chat-launcher__badge {
    position: absolute;
    top: -5px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--orange, #f97316);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    border: 2px solid #fff;
}
/* Hide launcher while the panel is open (mobile feels cleaner). */
.fb-chat.is-open .fb-chat-launcher { opacity: 0; pointer-events: none; transform: scale(.6); }

/* ─── BACKDROP (mobile) ──────────────────────────────────── */
.fb-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--fbc-backdrop-z);
    background: rgba(8,20,15,.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--dur-base,240ms) var(--ease-out, ease);
}
.fb-chat.is-open .fb-chat-backdrop { opacity: 1; }

/* ─── PANEL ──────────────────────────────────────────────── */
.fb-chat-panel {
    position: fixed;
    left: 20px;
    bottom: 24px;
    z-index: var(--fbc-panel-z);
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 40px));
    height: min(640px, calc(100vh - 100px));
    background: var(--fbc-bg);
    border-radius: var(--radius-lg, 22px);
    box-shadow: var(--fbc-shadow);
    overflow: hidden;
    transform-origin: bottom left;
    opacity: 0;
    transform: translateY(16px) scale(.96);
    transition: opacity var(--dur-base,240ms) var(--ease-out, ease),
                transform var(--dur-base,240ms) var(--ease-spring, cubic-bezier(.34,1.56,.64,1));
}
.fb-chat.is-open .fb-chat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ─── HEADER ─────────────────────────────────────────────── */
.fb-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--fbc-green-dk) 0%, var(--fbc-green-dkr) 100%);
    color: #fff;
    flex-shrink: 0;
}
.fb-chat-head__id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.fb-chat-head__avatar {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    font-size: 22px;
    background: rgba(255,255,255,.16);
    border-radius: 50%;
    flex-shrink: 0;
}
.fb-chat-head__meta { min-width: 0; }
.fb-chat-head__title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-chat-head__status {
    margin: 2px 0 0;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255,255,255,.85);
    display: flex; align-items: center; gap: 6px;
}
.fb-chat-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74,222,128,.7);
    animation: fbcPulse 2s infinite;
}
@keyframes fbcPulse {
    0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
    70%  { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
    100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.fb-chat-head__close {
    flex-shrink: 0;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: #fff;
    transition: background var(--dur-fast,160ms);
}
.fb-chat-head__close:hover { background: rgba(255,255,255,.24); }
.fb-chat-head__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ─── PINNED / WELCOME ───────────────────────────────────── */
.fb-chat-pinned {
    flex-shrink: 0;
    padding: 10px 14px;
    background: var(--green-50, #ecfdf5);
    border-bottom: 1px solid var(--green-100, #d1fae5);
    font-size: 13px;
    color: var(--green-900, #064e3b);
    display: flex; flex-direction: column; gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}
.fb-chat-pinned__item { display: flex; gap: 7px; align-items: flex-start; line-height: 1.4; }
.fb-chat-pinned__item span:first-child { flex-shrink: 0; }
.fb-chat-pinned__welcome { font-weight: 600; }

/* ─── BODY / MESSAGES ────────────────────────────────────── */
.fb-chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 12px 6px;
    background:
        radial-gradient(circle at 18% 12%, rgba(16,185,129,.05), transparent 42%),
        radial-gradient(circle at 86% 78%, rgba(4,120,87,.05), transparent 40%),
        var(--fbc-bg);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.fb-chat-messages { display: flex; flex-direction: column; gap: 3px; }

.fb-chat-earlier {
    display: block;
    margin: 0 auto 12px;
    padding: 6px 16px;
    border: 1px solid var(--fbc-border);
    border-radius: 999px;
    background: #fff;
    color: var(--fbc-green-dk);
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,.05));
}
.fb-chat-earlier:hover { background: var(--green-50, #ecfdf5); }

.fb-chat-empty {
    text-align: center;
    color: var(--fbc-muted);
    padding: 40px 24px;
    font-size: 14px;
}
.fb-chat-empty__emoji { font-size: 40px; display: block; margin-bottom: 10px; }

/* ── Message row ── */
.fbc-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
    align-items: flex-end;
    position: relative;
    padding: 1px 0;
}
.fbc-msg.is-grouped { margin-top: -2px; }
.fbc-msg__avatar {
    width: 30px; height: 30px;
    flex-shrink: 0;
    display: grid; place-items: center;
    background: #fff;
    border: 1px solid var(--fbc-border);
    border-radius: 50%;
    font-size: 16px;
    align-self: flex-end;
}
.fbc-msg.is-grouped .fbc-msg__avatar { visibility: hidden; height: 0; }

.fbc-msg__col { display: flex; flex-direction: column; min-width: 0; max-width: 78%; }
.fbc-msg__name {
    font-size: 12px;
    font-weight: 700;
    color: var(--fbc-green-dk);
    margin: 0 0 2px 10px;
}
/* Show the sender's name once at the top of each run of messages, not on every
   consecutive bubble (cleaner, matches Slack/Discord/WhatsApp group style). */
.fbc-msg.is-grouped .fbc-msg__name { display: none; }
.fbc-bubble {
    position: relative;
    padding: 8px 11px 6px;
    background: var(--fbc-other);
    color: var(--fbc-other-text);
    border-radius: 16px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 1px rgba(15,23,42,.08);
    font-size: 14.5px;
    line-height: 1.42;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* Own messages (right aligned, green) */
.fbc-msg.is-mine { flex-direction: row-reverse; }
.fbc-msg.is-mine .fbc-msg__col { align-items: flex-end; }
/* Show your own name too (right-aligned) — in a community chat it's clearer when
   every message is attributed. Still hidden on grouped runs via the rule above. */
.fbc-msg.is-mine .fbc-msg__name { margin: 0 10px 2px 0; text-align: right; }
.fbc-msg.is-mine .fbc-bubble {
    background: var(--fbc-own);
    color: var(--fbc-own-text);
    border-radius: 16px;
    border-bottom-right-radius: 5px;
    border-bottom-left-radius: 16px;
}
.fbc-msg.is-mine .fbc-msg__avatar { display: none; }

/* Bubble footer (time + status) */
.fbc-bubble__foot {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    font-size: 10.5px;
    margin-top: 3px;
    opacity: .7;
}
.fbc-msg.is-mine .fbc-bubble__foot { color: rgba(255,255,255,.9); }
.fbc-bubble__time { white-space: nowrap; }
.fbc-bubble__pin { font-size: 10px; }

/* Reply quote inside a bubble */
.fbc-reply-quote {
    display: block;
    border-left: 3px solid var(--fbc-green);
    background: rgba(4,120,87,.08);
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 5px;
    font-size: 12.5px;
}
.fbc-msg.is-mine .fbc-reply-quote {
    border-left-color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.16);
}
.fbc-reply-quote strong { display: block; font-size: 11.5px; }
.fbc-reply-quote span { opacity: .85; }

/* Image messages */
.fbc-bubble.is-image { padding: 4px; }
.fbc-bubble.is-image img {
    border-radius: 12px;
    max-width: 240px;
    max-height: 300px;
    width: auto;
    cursor: zoom-in;
    display: block;
}
.fbc-bubble.is-image .fbc-caption { padding: 5px 7px 2px; }

/* Sticker messages */
.fbc-msg.is-sticker .fbc-bubble {
    background: transparent !important;
    box-shadow: none;
    padding: 2px 4px;
}
.fbc-sticker-emoji { font-size: 56px; line-height: 1; }
.fbc-sticker-img { max-width: 120px; max-height: 120px; }

/* System messages */
.fbc-system {
    align-self: center;
    margin: 6px auto;
    padding: 4px 12px;
    background: rgba(15,23,42,.06);
    color: var(--fbc-muted);
    border-radius: 999px;
    font-size: 12px;
    text-align: center;
    max-width: 85%;
}

/* Floating date separators — Today / Yesterday / date */
.fbc-date-sep {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
}
.fbc-date-sep span {
    padding: 4px 12px;
    background: rgba(255,255,255,.92);
    color: var(--fbc-muted);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: 0 1px 2px rgba(15,23,42,.08);
}

/* Emoji-only messages render large with no bubble chrome (WhatsApp style) */
.fbc-bubble.is-bigemoji {
    background: transparent !important;
    box-shadow: none;
    padding: 2px 4px;
    line-height: 1.1;
}
.fbc-bubble.is-bigemoji .fbc-bubble__foot { opacity: .6; }
.fbc-bubble.is-bigemoji-1 > span:first-child { font-size: 52px; }
.fbc-bubble.is-bigemoji-2 > span:first-child { font-size: 44px; }
.fbc-bubble.is-bigemoji-3 > span:first-child { font-size: 38px; }
.fbc-msg.is-mine .fbc-bubble.is-bigemoji { color: var(--fbc-other-text); }
.fbc-msg.is-mine .fbc-bubble.is-bigemoji .fbc-bubble__foot { color: var(--fbc-muted); }

/* Gentle entry animation for newly arriving messages (not on first load) */
@keyframes fbcMsgIn {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fbc-msg.is-new { animation: fbcMsgIn .26s var(--ease-out, ease) both; }

/* Deleted placeholder */
.fbc-bubble.is-deleted {
    font-style: italic;
    opacity: .7;
    background: transparent;
    border: 1px dashed var(--fbc-border);
    box-shadow: none;
}

/* Links inside messages */
.fbc-bubble a {
    color: var(--blue, #2563eb);
    text-decoration: underline;
    font-weight: 600;
    word-break: break-all;
}
.fbc-msg.is-mine .fbc-bubble a { color: #d7fbe9; }
.fbc-mention { font-weight: 700; color: var(--fbc-green-dk); }
.fbc-msg.is-mine .fbc-mention { color: #d7fbe9; }

/* Reactions */
.fbc-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 3px 0 2px;
}
.fbc-msg.is-mine .fbc-reactions { justify-content: flex-end; }
.fbc-react-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--fbc-border);
    font-size: 12px;
    font-weight: 600;
    color: var(--dark, #0d1117);
    cursor: pointer;
    transition: transform var(--dur-instant,80ms);
}
.fbc-react-chip:active { transform: scale(.9); }
.fbc-react-chip.is-mine {
    background: var(--green-100, #d1fae5);
    border-color: var(--green-300, #6ee7b7);
    color: var(--green-900, #064e3b);
}

/* Hover/long-press action bar */
.fbc-actions {
    position: absolute;
    top: -14px;
    display: flex;
    gap: 2px;
    padding: 3px;
    background: #fff;
    border: 1px solid var(--fbc-border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,.1));
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity var(--dur-fast,160ms), transform var(--dur-fast,160ms);
    z-index: 3;
}
.fbc-msg:not(.is-mine) .fbc-actions { left: 8px; }
.fbc-msg.is-mine .fbc-actions { right: 8px; }
.fbc-msg.show-actions .fbc-actions,
.fbc-msg:hover .fbc-actions { opacity: 1; pointer-events: auto; transform: translateY(0); }
.fbc-action-btn {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border: none; background: transparent;
    border-radius: 50%;
    font-size: 15px;
    color: var(--fbc-muted);
    cursor: pointer;
}
.fbc-action-btn:hover { background: var(--green-50, #ecfdf5); }
.fbc-action-btn.is-react { font-size: 16px; }

/* Mini emoji popover for reacting */
.fbc-react-pop {
    position: absolute;
    top: -46px;
    display: flex;
    gap: 2px;
    padding: 5px 7px;
    background: #fff;
    border: 1px solid var(--fbc-border);
    border-radius: 999px;
    box-shadow: var(--shadow, 0 6px 20px rgba(0,0,0,.15));
    z-index: 5;
}
.fbc-msg:not(.is-mine) .fbc-react-pop { left: 8px; }
.fbc-msg.is-mine .fbc-react-pop { right: 8px; }
.fbc-react-pop button {
    border: none; background: none; cursor: pointer;
    font-size: 20px; line-height: 1;
    padding: 2px; border-radius: 8px;
    transition: transform var(--dur-instant,80ms);
}
.fbc-react-pop button:hover { transform: scale(1.3); }

/* Sending / failed states */
.fbc-msg.is-sending .fbc-bubble { opacity: .65; }
.fbc-msg.is-failed .fbc-bubble { border: 1px solid var(--red, #dc2626); }
.fbc-retry {
    font-size: 11px; color: var(--red, #dc2626);
    cursor: pointer; text-decoration: underline; margin-left: 6px;
}

/* ─── JUMP-TO-LATEST PILL ────────────────────────────────── */
.fb-chat-jump {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 88px;
    z-index: 4;
    padding: 7px 14px;
    border: none;
    border-radius: 999px;
    background: var(--fbc-green-dk);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: var(--shadow, 0 6px 18px rgba(4,120,87,.4));
    animation: fbcJumpIn var(--dur-base,240ms) var(--ease-spring, ease);
}
@keyframes fbcJumpIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─── TYPING ─────────────────────────────────────────────── */
.fb-chat-typing {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 6px;
    font-size: 12.5px;
    color: var(--fbc-muted);
    background: var(--fbc-bg);
}
.fb-chat-typing__dots { display: inline-flex; gap: 3px; }
.fb-chat-typing__dots i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--fbc-green);
    animation: fbcTyping 1.2s infinite ease-in-out;
}
.fb-chat-typing__dots i:nth-child(2) { animation-delay: .2s; }
.fb-chat-typing__dots i:nth-child(3) { animation-delay: .4s; }
@keyframes fbcTyping { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ─── NOTICE ─────────────────────────────────────────────── */
.fb-chat-notice {
    flex-shrink: 0;
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    background: var(--yellow-50, #fffbeb);
    color: #92400e;
    border-top: 1px solid #fde68a;
}
.fb-chat-notice.is-info { background: var(--green-50, #ecfdf5); color: var(--green-900,#064e3b); border-top-color: var(--green-100,#d1fae5); }
.fb-chat-notice.is-danger { background: var(--red-50, #fef2f2); color: #991b1b; border-top-color: #fecaca; }
.fb-chat-notice a { color: var(--fbc-green-dk); font-weight: 800; text-decoration: underline; }
.fb-chat-notice.is-danger a { color: #991b1b; }

/* ─── REPLY PREVIEW ──────────────────────────────────────── */
.fb-chat-reply {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border-top: 1px solid var(--fbc-border);
}
.fb-chat-reply__inner { flex: 1; display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.fb-chat-reply__bar { width: 3px; border-radius: 3px; background: var(--fbc-green); flex-shrink: 0; }
.fb-chat-reply__text { min-width: 0; font-size: 12.5px; line-height: 1.35; }
.fb-chat-reply__text strong { display: block; color: var(--fbc-green-dk); font-size: 12px; }
.fb-chat-reply__text span { color: var(--fbc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.fb-chat-reply__cancel {
    border: none; background: none; cursor: pointer;
    color: var(--fbc-muted); font-size: 16px; padding: 4px 6px;
    flex-shrink: 0; border-radius: 6px;
}
.fb-chat-reply__cancel:hover { background: var(--light, #f8fafc); }

/* ─── TRAYS (emoji + sticker) ────────────────────────────── */
.fb-chat-tray {
    flex-shrink: 0;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--fbc-border);
    -webkit-overflow-scrolling: touch;
}
.fb-chat-emoji-tray {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.fb-chat-emoji-tray button {
    border: none; background: none; cursor: pointer;
    font-size: 22px; line-height: 1; padding: 6px 0; border-radius: 8px;
    transition: background var(--dur-instant,80ms), transform var(--dur-instant,80ms);
}
.fb-chat-emoji-tray button:hover { background: var(--green-50, #ecfdf5); transform: scale(1.15); }
.fb-chat-sticker-tray__group-title {
    font-size: 11px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .04em; color: var(--fbc-muted); margin: 4px 2px 8px;
}
.fb-chat-sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.fb-chat-sticker-grid button {
    border: 1px solid transparent; background: var(--light, #f8fafc); cursor: pointer;
    border-radius: 12px; padding: 8px 0; font-size: 34px; line-height: 1;
    display: grid; place-items: center; aspect-ratio: 1/1;
    transition: background var(--dur-fast,160ms), transform var(--dur-fast,160ms), border-color var(--dur-fast,160ms);
}
.fb-chat-sticker-grid button:hover { background: var(--green-50, #ecfdf5); border-color: var(--green-200,#a7f3d0); transform: translateY(-2px); }
.fb-chat-sticker-grid img { max-width: 56px; max-height: 56px; }
.fb-chat-tray__loading, .fb-chat-tray__empty { color: var(--fbc-muted); font-size: 13px; text-align: center; padding: 16px; }

/* ─── COMPOSER ───────────────────────────────────────────── */
.fb-chat-composer {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--fbc-border);
}
.fb-chat-composer__tools { display: flex; align-items: center; }
.fb-chat-tool {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border: none; background: none; cursor: pointer;
    border-radius: 50%;
    font-size: 21px;
    color: var(--fbc-muted);
    transition: background var(--dur-fast,160ms), color var(--dur-fast,160ms);
}
.fb-chat-tool:hover { background: var(--green-50, #ecfdf5); color: var(--fbc-green-dk); }
.fb-chat-tool.is-active { background: var(--green-100, #d1fae5); color: var(--fbc-green-dk); }
.fb-chat-tool:focus-visible { outline: 2px solid var(--fbc-green); outline-offset: 1px; }

.fb-chat-input {
    flex: 1;
    min-width: 0;
    max-height: 110px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1.5px solid var(--fbc-border);
    border-radius: 22px;
    background: var(--light, #f8fafc);
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color var(--dur-fast,160ms), background var(--dur-fast,160ms);
}
.fb-chat-input:focus { border-color: var(--fbc-green); background: #fff; }
.fb-chat-input:disabled { opacity: .6; cursor: not-allowed; }
.fb-chat-input::placeholder { color: var(--muted-lt, #9ca3af); }

.fb-chat-send {
    flex-shrink: 0;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fbc-green) 0%, var(--fbc-green-dk) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(4,120,87,.35);
    transition: transform var(--dur-fast,160ms) var(--ease-spring, ease), filter var(--dur-fast,160ms), opacity var(--dur-fast,160ms);
}
.fb-chat-send:hover:not(:disabled) { filter: brightness(1.06); transform: scale(1.06); }
.fb-chat-send:active:not(:disabled) { transform: scale(.92); }
.fb-chat-send:disabled { opacity: .4; cursor: default; box-shadow: none; }
.fb-chat-send svg { margin-left: -2px; }

/* ─── IMAGE PREVIEW ──────────────────────────────────────── */
.fb-chat-imgpreview {
    position: absolute;
    inset: 0;
    z-index: 6;
    background: rgba(8,20,15,.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
}
.fb-chat-imgpreview img { max-width: 100%; max-height: 70%; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.fb-chat-imgpreview__actions { display: flex; gap: 12px; }
.fb-chat-imgpreview__cancel, .fb-chat-imgpreview__send {
    padding: 11px 24px; border-radius: 999px; font-weight: 800; font-size: 14px; cursor: pointer; border: none;
}
.fb-chat-imgpreview__cancel { background: rgba(255,255,255,.18); color: #fff; }
.fb-chat-imgpreview__send { background: var(--fbc-green); color: #fff; box-shadow: 0 6px 18px rgba(4,120,87,.5); }

/* ─── FOOT ───────────────────────────────────────────────── */
.fb-chat-foot {
    flex-shrink: 0;
    margin: 0;
    padding: 5px 12px calc(5px + env(safe-area-inset-bottom, 0px));
    font-size: 10.5px;
    color: var(--fbc-muted);
    text-align: center;
    background: #fff;
    border-top: 1px solid var(--border-lt, #f3f4f6);
}

/* ─── SCROLLBARS (subtle) ────────────────────────────────── */
.fb-chat-body::-webkit-scrollbar,
.fb-chat-tray::-webkit-scrollbar,
.fb-chat-pinned::-webkit-scrollbar { width: 6px; }
.fb-chat-body::-webkit-scrollbar-thumb,
.fb-chat-tray::-webkit-scrollbar-thumb,
.fb-chat-pinned::-webkit-scrollbar-thumb { background: rgba(4,120,87,.22); border-radius: 999px; }

/* ═══════════ MOBILE: full-screen sheet ═══════════ */
@media (max-width: 600px) {
    .fb-chat-launcher {
        left: 14px;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        height: 50px;
        width: 50px;
        padding: 0;
        justify-content: center;
        gap: 0;
    }
    .fb-chat-launcher__label { display: none; }

    /* On checkout the bottom nav is hidden but a sticky CTA shows — lift above it. */
    body.is-checkout-page .fb-chat-launcher { bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }

    .fb-chat-panel {
        left: 0; right: 0; top: 0; bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        transform-origin: bottom center;
        transform: translateY(100%);
    }
    .fb-chat.is-open .fb-chat-panel { transform: translateY(0); }
    .fb-chat-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
    .fbc-msg__col { max-width: 82%; }
    .fb-chat-jump { bottom: 92px; }
    .fb-chat-emoji-tray { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 360px) {
    .fb-chat-emoji-tray { grid-template-columns: repeat(6, 1fr); }
    .fb-chat-sticker-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════ ACCESSIBILITY: reduced motion ═══════════ */
@media (prefers-reduced-motion: reduce) {
    .fb-chat-launcher, .fb-chat-panel, .fb-chat-backdrop,
    .fb-chat-send, .fb-chat-jump, .fbc-actions, .fb-chat-tool {
        transition: none !important;
        animation: none !important;
    }
    .fb-chat-dot, .fb-chat-typing__dots i { animation: none !important; }
    .fbc-msg.is-new { animation: none !important; }
    .fb-chat-panel { transform: none; }
    .fb-chat.is-open .fb-chat-panel { transform: none; }
}

/* Make sure the widget never blocks print */
@media print { .fb-chat { display: none !important; } }
