/* TopVite AI Chat v2.0 - modern widget
   Every rule is prefixed with #tvac-widget so theme styles cannot leak in. */

#tvac-widget {
    --tvac-primary: #1e3a8a;
    --tvac-primary-light: #3b5bdb;
    --tvac-primary-dark: #142a66;
    --tvac-on: #fff;
    --tvac-rgb: 30, 58, 138;
    --tvac-grad: linear-gradient(135deg, var(--tvac-primary-light) 0%, var(--tvac-primary-dark) 100%);

    --tvac-bg: #ffffff;
    --tvac-surface: #f4f6fb;
    --tvac-bot: #ffffff;
    --tvac-text: #1b2133;
    --tvac-muted: #7b8497;
    --tvac-border: #e7eaf3;
    --tvac-accent: var(--tvac-primary);
    --tvac-chip-bg: rgba(var(--tvac-rgb), .07);
    --tvac-chip-border: rgba(var(--tvac-rgb), .22);
    --tvac-shadow: 0 28px 70px -14px rgba(18, 26, 60, .35), 0 10px 24px -10px rgba(18, 26, 60, .22);
    --tvac-radius: 26px;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    z-index: 999999;
    -webkit-font-smoothing: antialiased;
}

/* ---- Dark theme (forced, or automatic with the visitor's system) -------- */
#tvac-widget.tvac-theme-dark {
    --tvac-bg: #151a2a;
    --tvac-surface: #0e1220;
    --tvac-bot: #1f2640;
    --tvac-text: #edf0f9;
    --tvac-muted: #929cb3;
    --tvac-border: #2a3250;
    --tvac-accent: #b9c6ff;
    --tvac-chip-bg: rgba(255, 255, 255, .06);
    --tvac-chip-border: rgba(255, 255, 255, .18);
    --tvac-shadow: 0 28px 70px -14px rgba(0, 0, 0, .7), 0 10px 24px -10px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
    #tvac-widget.tvac-theme-auto {
        --tvac-bg: #151a2a;
        --tvac-surface: #0e1220;
        --tvac-bot: #1f2640;
        --tvac-text: #edf0f9;
        --tvac-muted: #929cb3;
        --tvac-border: #2a3250;
        --tvac-accent: #b9c6ff;
        --tvac-chip-bg: rgba(255, 255, 255, .06);
        --tvac-chip-border: rgba(255, 255, 255, .18);
        --tvac-shadow: 0 28px 70px -14px rgba(0, 0, 0, .7), 0 10px 24px -10px rgba(0, 0, 0, .5);
    }
}

#tvac-widget *,
#tvac-widget *::before,
#tvac-widget *::after { box-sizing: border-box; }

#tvac-widget button,
#tvac-widget input,
#tvac-widget textarea {
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
    text-shadow: none;
    margin: 0;
}

#tvac-widget [hidden] { display: none !important; }

/* ---- Main floating button ------------------------------------------------ */
#tvac-widget #tvac-toggle {
    position: fixed;
    bottom: 24px;
    width: 62px;
    height: 62px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--tvac-grad);
    color: var(--tvac-on);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px -6px rgba(var(--tvac-rgb), .55), 0 4px 10px rgba(0, 0, 0, .18);
    transition: transform .22s cubic-bezier(.3, 1.4, .5, 1), box-shadow .2s ease;
}
#tvac-widget #tvac-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--tvac-primary-light);
    opacity: .5;
    z-index: -1;
    animation: tvac-ring 2.8s ease-out infinite;
}
#tvac-widget.tvac-open #tvac-toggle::before,
#tvac-widget.tvac-seen #tvac-toggle::before { animation: none; opacity: 0; }
@keyframes tvac-ring {
    0% { transform: scale(1); opacity: .45; }
    70%, 100% { transform: scale(1.55); opacity: 0; }
}
#tvac-widget #tvac-toggle:hover { transform: scale(1.07); }
#tvac-widget #tvac-toggle:active { transform: scale(.96); }
#tvac-widget #tvac-toggle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

#tvac-widget .tvac-icon-close { display: none; }
#tvac-widget.tvac-open .tvac-icon-open { display: none; }
#tvac-widget.tvac-open .tvac-icon-close { display: block; }

.tvac-position-right #tvac-toggle { right: 24px; }
.tvac-position-left #tvac-toggle { left: 24px; }

/* ---- Invitation bubble ---------------------------------------------------- */
#tvac-widget #tvac-bubble {
    position: fixed;
    bottom: 98px;
    max-width: min(270px, calc(100vw - 48px));
    display: flex;
    align-items: flex-start;
    background: var(--tvac-bg);
    color: var(--tvac-text);
    border-radius: 18px 18px 6px 18px;
    box-shadow: 0 14px 34px -8px rgba(18, 26, 60, .35), 0 2px 6px rgba(18, 26, 60, .08);
    animation: tvac-bubble-in .45s cubic-bezier(.3, 1.4, .5, 1);
    z-index: 999998;
}
.tvac-position-right #tvac-bubble { right: 24px; }
.tvac-position-left #tvac-bubble { left: 24px; border-radius: 18px 18px 18px 6px; }
@keyframes tvac-bubble-in { from { opacity: 0; transform: translateY(12px) scale(.9); } to { opacity: 1; transform: none; } }
#tvac-widget #tvac-bubble-text {
    flex: 1;
    background: none;
    border: 0;
    padding: 13px 8px 13px 16px;
    text-align: start;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: inherit;
    cursor: pointer;
}
#tvac-widget #tvac-bubble-close {
    background: none;
    border: 0;
    color: var(--tvac-muted);
    font-size: 20px;
    line-height: 1;
    padding: 8px 11px 8px 2px;
    cursor: pointer;
}
#tvac-widget #tvac-bubble-close:hover { color: var(--tvac-text); }

/* ---- Panel ---------------------------------------------------------------- */
#tvac-widget #tvac-panel {
    position: fixed;
    bottom: 100px;
    width: 392px;
    max-width: calc(100vw - 32px);
    height: 650px;
    max-height: calc(100vh - 124px);
    background: var(--tvac-bg);
    color: var(--tvac-text);
    border-radius: var(--tvac-radius);
    box-shadow: var(--tvac-shadow);
    border: 1px solid var(--tvac-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
    transform-origin: bottom right;
    animation: tvac-pop .26s cubic-bezier(.2, .9, .3, 1.15);
}
@supports (height: 100dvh) {
    #tvac-widget #tvac-panel { max-height: calc(100dvh - 124px); }
}
.tvac-position-right #tvac-panel { right: 24px; }
.tvac-position-left #tvac-panel { left: 24px; transform-origin: bottom left; }
#tvac-widget #tvac-panel[hidden] { display: none !important; }
@keyframes tvac-pop { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---- Header ---------------------------------------------------------------- */
#tvac-widget #tvac-header {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 18px 18px;
    color: var(--tvac-on);
    background:
        radial-gradient(120% 160% at 100% -30%, rgba(255, 255, 255, .28), transparent 55%),
        var(--tvac-grad);
}
#tvac-widget .tvac-avatar-wrap { position: relative; flex-shrink: 0; }
#tvac-widget .tvac-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    border: 2px solid rgba(255, 255, 255, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#tvac-widget .tvac-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#tvac-widget .tvac-dot {
    position: absolute;
    right: -1px;
    bottom: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
}
#tvac-widget.tvac-is-offline .tvac-dot { background: #f59e0b; }
#tvac-widget .tvac-header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#tvac-widget .tvac-header-title {
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#tvac-widget .tvac-header-status { font-size: 12.5px; opacity: .9; line-height: 1.3; }
#tvac-widget .tvac-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
#tvac-widget .tvac-header-actions button {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .17);
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, transform .15s ease;
}
#tvac-widget .tvac-header-actions button:hover { background: rgba(255, 255, 255, .32); transform: scale(1.06); }
#tvac-widget .tvac-header-actions svg { display: block; }
#tvac-widget:not(.tvac-muted) .tvac-mute-line { display: none; }
#tvac-widget.tvac-muted .tvac-wave { display: none; }

/* ---- Offline banner -------------------------------------------------------- */
#tvac-widget #tvac-offline {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 16px;
    background: #fff6e0;
    color: #7a5200;
    font-size: 12.5px;
    line-height: 1.35;
}
#tvac-widget #tvac-offline-btn {
    flex-shrink: 0;
    background: #7a5200;
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
#tvac-widget.tvac-theme-dark #tvac-offline { background: #3a2f12; color: #ffd98a; }
#tvac-widget.tvac-theme-dark #tvac-offline-btn { background: #ffd98a; color: #3a2f12; }
@media (prefers-color-scheme: dark) {
    #tvac-widget.tvac-theme-auto #tvac-offline { background: #3a2f12; color: #ffd98a; }
    #tvac-widget.tvac-theme-auto #tvac-offline-btn { background: #ffd98a; color: #3a2f12; }
}

/* ---- Messages --------------------------------------------------------------- */
#tvac-widget #tvac-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 8px;
    background: var(--tvac-surface);
    scroll-behavior: smooth;
}
#tvac-widget #tvac-messages::-webkit-scrollbar { width: 6px; }
#tvac-widget #tvac-messages::-webkit-scrollbar-thumb { background: rgba(128, 138, 160, .35); border-radius: 6px; }

#tvac-widget .tvac-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
    direction: ltr;
    animation: tvac-msg-in .28s ease both;
}
@keyframes tvac-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#tvac-widget .tvac-msg-user { justify-content: flex-end; }

#tvac-widget .tvac-msg-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--tvac-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 18px;
}
#tvac-widget .tvac-msg-avatar svg { width: 16px; height: 16px; }
#tvac-widget .tvac-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
#tvac-widget .tvac-msg-human .tvac-msg-avatar { background: linear-gradient(135deg, #10b981, #047857); }

#tvac-widget .tvac-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    max-width: calc(100% - 40px);
}
#tvac-widget .tvac-msg-user .tvac-col { align-items: flex-end; max-width: 84%; }

#tvac-widget .tvac-bubble {
    max-width: 100%;
    padding: 11px 15px;
    border-radius: 20px 20px 20px 6px;
    background: var(--tvac-bot);
    color: var(--tvac-text);
    box-shadow: 0 1px 2px rgba(18, 26, 60, .06), 0 4px 12px -4px rgba(18, 26, 60, .1);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
#tvac-widget .tvac-msg-user .tvac-bubble {
    background: var(--tvac-grad);
    color: var(--tvac-on);
    border-radius: 20px 20px 6px 20px;
    box-shadow: 0 6px 16px -6px rgba(var(--tvac-rgb), .55);
}
#tvac-widget .tvac-msg-human .tvac-bubble {
    background: linear-gradient(135deg, #10b981, #047857);
    color: #fff;
}
#tvac-widget.tvac-rtl .tvac-bubble { direction: rtl; text-align: right; }

#tvac-widget .tvac-bubble p { margin: 0 0 8px; }
#tvac-widget .tvac-bubble p:last-child,
#tvac-widget .tvac-bubble ul:last-child,
#tvac-widget .tvac-bubble ol:last-child { margin-bottom: 0; }
#tvac-widget .tvac-bubble ul,
#tvac-widget .tvac-bubble ol { margin: 0 0 8px; padding-inline-start: 20px; }
#tvac-widget .tvac-bubble li { margin: 0 0 3px; padding: 0; }
#tvac-widget .tvac-bubble strong { font-weight: 700; }
#tvac-widget .tvac-bubble a { color: var(--tvac-accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
#tvac-widget .tvac-msg-user .tvac-bubble a,
#tvac-widget .tvac-msg-human .tvac-bubble a { color: inherit; }
#tvac-widget .tvac-agent-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .7px;
    opacity: .85;
    margin-bottom: 3px;
}

#tvac-widget .tvac-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    min-height: 22px;
    font-size: 11px;
    color: var(--tvac-muted);
}
#tvac-widget .tvac-fb {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--tvac-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: .75;
    transition: background .15s, color .15s, opacity .15s, transform .15s;
}
#tvac-widget .tvac-fb:hover { background: rgba(128, 138, 160, .18); opacity: 1; transform: scale(1.1); }
#tvac-widget .tvac-fb.is-on { opacity: 1; color: #fff; background: #22c55e; }
#tvac-widget .tvac-fb.tvac-fb-down.is-on { background: #ef4444; }
#tvac-widget .tvac-fb svg { display: block; }
#tvac-widget .tvac-thanks { font-size: 11px; color: var(--tvac-muted); margin-inline-start: 4px; }

/* ---- Product cards (carousel) ---------------------------------------------- */
#tvac-widget .tvac-products {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    margin-top: 8px;
    padding: 2px 2px 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    direction: ltr;
}
#tvac-widget .tvac-products::-webkit-scrollbar { height: 5px; }
#tvac-widget .tvac-products::-webkit-scrollbar-thumb { background: rgba(128, 138, 160, .4); border-radius: 5px; }
#tvac-widget .tvac-product {
    position: relative;
    flex: 0 0 172px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    background: var(--tvac-bot);
    border: 1px solid var(--tvac-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 6px 18px -8px rgba(18, 26, 60, .25);
    transition: transform .18s ease, box-shadow .18s ease;
}
#tvac-widget .tvac-product:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -8px rgba(18, 26, 60, .32); }
#tvac-widget.tvac-rtl .tvac-product { direction: rtl; text-align: right; }
#tvac-widget .tvac-product-img {
    display: block;
    width: 100%;
    height: 122px;
    background: var(--tvac-surface);
}
#tvac-widget .tvac-product-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#tvac-widget .tvac-badge-sale {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 999px;
    letter-spacing: .3px;
}
#tvac-widget .tvac-product-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 11px 11px; flex: 1; }
#tvac-widget .tvac-product-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.3;
    color: var(--tvac-text);
    text-decoration: none;
    min-height: 34px;
}
#tvac-widget .tvac-product-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-weight: 800; font-size: 14px; color: var(--tvac-accent); }
#tvac-widget .tvac-price-old { font-weight: 500; font-size: 12px; color: var(--tvac-muted); text-decoration: line-through; }
#tvac-widget .tvac-product-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
#tvac-widget .tvac-btn-cart,
#tvac-widget .tvac-btn-view {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: 0;
    transition: filter .15s ease, transform .15s ease;
}
#tvac-widget .tvac-btn-cart { background: var(--tvac-grad); color: var(--tvac-on); box-shadow: 0 6px 14px -6px rgba(var(--tvac-rgb), .6); }
#tvac-widget .tvac-btn-cart:hover { filter: brightness(1.1); }
#tvac-widget .tvac-btn-cart:active { transform: scale(.97); }
#tvac-widget .tvac-btn-cart[disabled] { opacity: .75; cursor: default; }
#tvac-widget .tvac-btn-cart.is-added { background: linear-gradient(135deg, #10b981, #047857); color: #fff; }
#tvac-widget .tvac-btn-cart.is-error { background: #ef4444; color: #fff; }
#tvac-widget .tvac-btn-view { background: var(--tvac-chip-bg); color: var(--tvac-accent); border: 1px solid var(--tvac-chip-border); }
#tvac-widget .tvac-btn-view:hover { filter: brightness(.97); }
#tvac-widget .tvac-oos { font-size: 11.5px; color: var(--tvac-muted); text-align: center; padding: 2px 0; }

/* ---- Quick replies ----------------------------------------------------------- */
#tvac-widget .tvac-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px 38px; direction: ltr; }
#tvac-widget.tvac-rtl .tvac-quick { margin: 2px 38px 14px 0; flex-direction: row-reverse; justify-content: flex-start; direction: rtl; }
#tvac-widget .tvac-chip {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--tvac-chip-border);
    background: var(--tvac-chip-bg);
    color: var(--tvac-accent);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    text-align: start;
    animation: tvac-msg-in .35s ease both;
    transition: background .15s, transform .15s, box-shadow .15s;
}
#tvac-widget .tvac-chip:hover { background: var(--tvac-grad); color: var(--tvac-on); border-color: transparent; transform: translateY(-1px); box-shadow: 0 8px 16px -8px rgba(var(--tvac-rgb), .6); }

/* ---- Typing indicator --------------------------------------------------------- */
#tvac-widget #tvac-typing {
    flex-shrink: 0;
    padding: 0 16px 10px 54px;
    background: var(--tvac-surface);
}
#tvac-widget #tvac-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-inline-end: 4px;
    border-radius: 50%;
    background: var(--tvac-muted);
    animation: tvac-blink 1.2s infinite;
}
#tvac-widget #tvac-typing span:nth-child(2) { animation-delay: .18s; }
#tvac-widget #tvac-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes tvac-blink {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}

/* ---- Sheets (order tracking / leave a message) ---------------------------------- */
#tvac-widget #tvac-track-form,
#tvac-widget #tvac-lead-form {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 14px 16px;
    background: var(--tvac-bg);
    border-top: 1px solid var(--tvac-border);
    animation: tvac-msg-in .22s ease both;
}
#tvac-widget .tvac-sheet-title { font-size: 14.5px; font-weight: 750; color: var(--tvac-text); }
#tvac-widget .tvac-sheet-intro { font-size: 12.5px; color: var(--tvac-muted); margin-top: -4px; }
#tvac-widget #tvac-track-form input,
#tvac-widget #tvac-lead-form input[type="text"],
#tvac-widget #tvac-lead-form input[type="email"],
#tvac-widget #tvac-lead-form textarea {
    width: 100%;
    height: 42px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--tvac-border);
    border-radius: 14px;
    background: var(--tvac-surface);
    color: var(--tvac-text);
    font-size: 14px;
    outline: none;
    box-shadow: none;
    transition: border-color .15s, box-shadow .15s;
}
#tvac-widget #tvac-lead-form textarea { height: 76px; min-height: 76px; padding: 10px 14px; resize: none; line-height: 1.4; }
#tvac-widget #tvac-track-form input:focus,
#tvac-widget #tvac-lead-form input:focus,
#tvac-widget #tvac-lead-form textarea:focus { border-color: var(--tvac-primary-light); box-shadow: 0 0 0 3px rgba(var(--tvac-rgb), .16); }
#tvac-widget .tvac-sheet-actions { display: flex; gap: 8px; }
#tvac-widget .tvac-btn-primary {
    flex: 1;
    padding: 11px;
    border: 0;
    border-radius: 14px;
    background: var(--tvac-grad);
    color: var(--tvac-on);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(var(--tvac-rgb), .65);
}
#tvac-widget .tvac-btn-primary:hover { filter: brightness(1.08); }
#tvac-widget .tvac-btn-primary[disabled] { opacity: .6; cursor: default; }
#tvac-widget .tvac-btn-ghost {
    padding: 11px 16px;
    border: 0;
    border-radius: 14px;
    background: var(--tvac-surface);
    color: var(--tvac-text);
    font-size: 14px;
    cursor: pointer;
}

/* ---- Action row (track order / leave a message) ---------------------------------- */
#tvac-widget #tvac-actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 8px 14px 0;
    background: var(--tvac-bg);
    border-top: 1px solid var(--tvac-border);
    overflow-x: auto;
}
#tvac-widget .tvac-action {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--tvac-border);
    border-radius: 999px;
    background: transparent;
    color: var(--tvac-text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
#tvac-widget .tvac-action:hover { border-color: var(--tvac-primary-light); color: var(--tvac-accent); background: var(--tvac-chip-bg); }

/* ---- Emoji picker ----------------------------------------------------------------- */
#tvac-widget #tvac-emoji {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px 12px;
    background: var(--tvac-bg);
    border-top: 1px solid var(--tvac-border);
    animation: tvac-msg-in .18s ease both;
}
#tvac-widget #tvac-emoji button {
    border: 0;
    background: transparent;
    font-size: 21px;
    line-height: 1;
    padding: 6px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s, transform .12s;
}
#tvac-widget #tvac-emoji button:hover { background: var(--tvac-surface); transform: scale(1.18); }

/* ---- Composer ----------------------------------------------------------------------- */
#tvac-widget #tvac-form {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px 6px;
    background: var(--tvac-bg);
}
#tvac-widget #tvac-emoji-btn {
    flex-shrink: 0;
    width: 40px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--tvac-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
}
#tvac-widget #tvac-emoji-btn:hover { color: var(--tvac-accent); background: var(--tvac-chip-bg); }
#tvac-widget #tvac-input {
    flex: 1;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    max-height: 110px;
    padding: 10px 16px;
    resize: none;
    overflow-y: auto;
    border: 1px solid transparent;
    border-radius: 22px;
    background: var(--tvac-surface);
    color: var(--tvac-text);
    font-size: 14.5px;
    line-height: 20px;
    outline: none;
    box-shadow: none;
    transition: border-color .15s, box-shadow .15s;
}
#tvac-widget #tvac-input::placeholder { color: var(--tvac-muted); }
#tvac-widget #tvac-input:focus { border-color: var(--tvac-primary-light); box-shadow: 0 0 0 3px rgba(var(--tvac-rgb), .16); }
#tvac-widget.tvac-rtl #tvac-input { direction: rtl; }
#tvac-widget #tvac-send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--tvac-grad);
    color: var(--tvac-on);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px -6px rgba(var(--tvac-rgb), .65);
    transition: transform .15s ease, filter .15s ease;
}
#tvac-widget #tvac-send:hover { transform: scale(1.08); filter: brightness(1.08); }
#tvac-widget #tvac-send:active { transform: scale(.94); }
#tvac-widget #tvac-send svg { display: block; margin-inline-end: 2px; }
#tvac-widget.tvac-rtl #tvac-send svg { transform: scaleX(-1); margin-inline-end: 0; margin-inline-start: 2px; }
#tvac-widget #tvac-send[disabled] { opacity: .55; cursor: default; transform: none; }

#tvac-widget .tvac-privacy {
    flex-shrink: 0;
    margin: 0;
    padding: 2px 16px 12px;
    font-size: 10.5px;
    line-height: 1.35;
    text-align: center;
    color: var(--tvac-muted);
    background: var(--tvac-bg);
}

/* ---- Floating contact menu ------------------------------------------------------------ */
#tvac-widget #tvac-fab-stack {
    position: fixed;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1;
}
.tvac-position-right #tvac-fab-stack { right: 31px; }
.tvac-position-left #tvac-fab-stack { left: 31px; }

#tvac-widget .tvac-fab-item {
    position: relative;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--tvac-grad);
    color: var(--tvac-on);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px -6px rgba(var(--tvac-rgb), .5), 0 2px 6px rgba(0, 0, 0, .15);
    text-decoration: none;
    opacity: 0;
    transform: translateY(14px) scale(.5);
    pointer-events: none;
    transition: opacity .2s ease, transform .22s cubic-bezier(.3, 1.4, .5, 1), box-shadow .15s ease;
}
#tvac-widget .tvac-fab-item img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
#tvac-widget .tvac-fab-item:hover { box-shadow: 0 12px 22px -6px rgba(var(--tvac-rgb), .6); transform: translateY(-2px) scale(1.07); }
#tvac-widget.tvac-menu-open .tvac-fab-item { opacity: 1; transform: none; pointer-events: auto; }
#tvac-widget.tvac-menu-open .tvac-fab-item:nth-child(1) { transition-delay: .16s; }
#tvac-widget.tvac-menu-open .tvac-fab-item:nth-child(2) { transition-delay: .12s; }
#tvac-widget.tvac-menu-open .tvac-fab-item:nth-child(3) { transition-delay: .08s; }
#tvac-widget.tvac-menu-open .tvac-fab-item:nth-child(4) { transition-delay: .04s; }
#tvac-widget.tvac-menu-open .tvac-fab-item:nth-child(5) { transition-delay: 0s; }

/* Hover tooltips */
#tvac-widget .tvac-fab-item::after,
#tvac-widget #tvac-toggle::after {
    content: attr(data-label);
    position: absolute;
    top: 50%;
    right: calc(100% + 12px);
    transform: translateY(-50%) translateX(4px);
    background: #1b2133;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    padding: 6px 11px;
    border-radius: 9px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 3;
}
.tvac-position-left .tvac-fab-item::after,
.tvac-position-left #tvac-toggle::after { right: auto; left: calc(100% + 12px); transform: translateY(-50%) translateX(-4px); }
#tvac-widget .tvac-fab-item:hover::after,
#tvac-widget #tvac-toggle:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
#tvac-widget.tvac-open #tvac-toggle::after { display: none; }

/* ---- Mobile: full screen -------------------------------------------------------------- */
@media (max-width: 480px) {
    #tvac-widget #tvac-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: 0;
        animation: tvac-slide-up .28s ease;
    }
    @supports (height: 100dvh) {
        #tvac-widget #tvac-panel { height: 100dvh; max-height: 100dvh; }
    }
    @keyframes tvac-slide-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
    #tvac-widget #tvac-header { padding-top: max(18px, env(safe-area-inset-top)); }
    #tvac-widget .tvac-privacy { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    #tvac-widget #tvac-input { font-size: 16px; } /* prevents iOS zoom on focus */
    #tvac-widget.tvac-open #tvac-toggle,
    #tvac-widget.tvac-open #tvac-fab-stack,
    #tvac-widget.tvac-open #tvac-bubble { display: none !important; }
    .tvac-position-right #tvac-toggle,
    .tvac-position-left #tvac-toggle { right: 16px; left: auto; bottom: 16px; }
    .tvac-position-right #tvac-fab-stack,
    .tvac-position-left #tvac-fab-stack { right: 23px; left: auto; bottom: 90px; }
    .tvac-position-right #tvac-bubble,
    .tvac-position-left #tvac-bubble { right: 16px; left: auto; bottom: 90px; }
    #tvac-widget .tvac-fab-item::after,
    #tvac-widget #tvac-toggle::after { display: none; }
}
html.tvac-lock, html.tvac-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
    #tvac-widget *, #tvac-widget *::before, #tvac-widget *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Floating hardening: never let a theme pin the widget in page flow ------------------- */
#tvac-widget #tvac-toggle { position: fixed !important; z-index: 999999 !important; }
#tvac-widget.tvac-position-right #tvac-toggle { right: 24px !important; left: auto !important; }
#tvac-widget.tvac-position-left #tvac-toggle { left: 24px !important; right: auto !important; }
#tvac-widget #tvac-panel { position: fixed !important; z-index: 999999 !important; }
#tvac-widget #tvac-fab-stack { position: fixed !important; z-index: 999998 !important; }
#tvac-widget #tvac-bubble { position: fixed !important; z-index: 999998 !important; }
@media (max-width: 480px) {
    #tvac-widget.tvac-position-right #tvac-toggle,
    #tvac-widget.tvac-position-left #tvac-toggle { right: 16px !important; left: auto !important; }
}

/* Manual pinning mode (last-resort self-healing): reset everything, the JS
   positions each element with inline styles. */
#tvac-widget.tvac-manual #tvac-toggle,
#tvac-widget.tvac-manual #tvac-panel,
#tvac-widget.tvac-manual #tvac-fab-stack,
#tvac-widget.tvac-manual #tvac-bubble {
    position: absolute !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
}
