:root {
    --livechat-primary: #f97316;
    --livechat-primary-dark: #ea580c;
    --livechat-ink: #172033;
    --livechat-muted: #718096;
    --livechat-surface: #ffffff;
    --livechat-soft: #fff7ed;
    --livechat-border: #e8edf4;
}

.livechat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9998;
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(145deg, #fb923c, var(--livechat-primary-dark));
    box-shadow: 0 16px 35px rgba(234, 88, 12, .32);
    cursor: pointer;
    transition: transform .25s ease, border-radius .25s ease, box-shadow .25s ease;
}

.livechat-launcher:hover { transform: translateY(-3px); box-shadow: 0 20px 42px rgba(234, 88, 12, .4); }
.livechat-launcher.is-open { transform: rotate(6deg); border-radius: 50%; }
.livechat-launcher__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font: 700 11px/1 system-ui, sans-serif;
}
.livechat-launcher__badge.is-visible { display: flex; }

.livechat-panel {
    position: fixed;
    right: 22px;
    bottom: 98px;
    z-index: 9999;
    width: min(390px, calc(100vw - 24px));
    height: min(650px, calc(100vh - 122px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 28px;
    background: var(--livechat-surface);
    box-shadow: 0 30px 80px rgba(15, 23, 42, .22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(.96);
    transform-origin: right bottom;
    transition: opacity .24s ease, transform .24s ease, visibility .24s;
    font-family: Kanit, system-ui, sans-serif;
}
.livechat-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.livechat-panel__header {
    padding: 18px 18px 16px;
    display: flex;
    gap: 13px;
    align-items: center;
    color: #fff;
    background: radial-gradient(circle at 88% -20%, rgba(255,255,255,.28), transparent 40%), linear-gradient(135deg, #f97316, #ea580c);
}
.livechat-panel__avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.2); }
.livechat-panel__title { margin: 0; font-size: 16px; font-weight: 700; }
.livechat-panel__status { margin: 3px 0 0; display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .9; }
.livechat-panel__status-dot { width: 8px; height: 8px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 4px rgba(134,239,172,.18); }
.livechat-panel__close { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 12px; color: #fff; background: rgba(255,255,255,.15); cursor: pointer; }
.livechat-panel__messages { flex: 1; overflow-y: auto; padding: 18px; background: linear-gradient(180deg, #fffaf5 0%, #fff 28%); scroll-behavior: smooth; }
.livechat-day { margin: 4px auto 18px; width: max-content; padding: 6px 10px; border-radius: 999px; color: #8a5b35; background: #ffedd5; font-size: 11px; }
.livechat-message { display: flex; gap: 9px; align-items: flex-end; margin: 0 0 12px; animation: livechat-pop .25s ease both; }
.livechat-message.is-me { justify-content: flex-end; }
.livechat-message__bubble { max-width: 78%; padding: 10px 13px 7px; border: 1px solid var(--livechat-border); border-radius: 18px 18px 18px 6px; background: #fff; color: var(--livechat-ink); box-shadow: 0 5px 16px rgba(15,23,42,.05); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.livechat-message.is-me .livechat-message__bubble { border: 0; border-radius: 18px 18px 6px 18px; color: #fff; background: linear-gradient(145deg, #fb923c, #f97316); box-shadow: 0 8px 20px rgba(249,115,22,.2); }
.livechat-message__time { display: block; margin-top: 4px; color: #94a3b8; font-size: 10px; text-align: right; }
.livechat-message.is-me .livechat-message__time { color: rgba(255,255,255,.72); }
.livechat-typing { min-height: 28px; padding: 0 18px 4px; color: var(--livechat-muted); background: #fff; font-size: 12px; }
.livechat-typing__dots { display: inline-flex; gap: 3px; margin-left: 5px; }
.livechat-typing__dots i { width: 4px; height: 4px; border-radius: 50%; background: #f97316; animation: livechat-dot 1s infinite ease-in-out; }
.livechat-typing__dots i:nth-child(2) { animation-delay: .16s; }
.livechat-typing__dots i:nth-child(3) { animation-delay: .32s; }
.livechat-panel__composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px 14px; border-top: 1px solid var(--livechat-border); background: #fff; }
.livechat-panel__input { flex: 1; max-height: 92px; resize: none; border: 1px solid #dde4ee; border-radius: 17px; padding: 11px 13px; outline: none; color: var(--livechat-ink); background: #f8fafc; font: 14px/1.45 Kanit, system-ui, sans-serif; transition: border-color .2s, box-shadow .2s; }
.livechat-panel__input:focus { border-color: #fb923c; box-shadow: 0 0 0 4px rgba(249,115,22,.12); background: #fff; }
.livechat-panel__send { width: 44px; height: 44px; flex: 0 0 44px; border: 0; border-radius: 15px; color: #fff; background: var(--livechat-primary); cursor: pointer; box-shadow: 0 8px 18px rgba(249,115,22,.22); transition: transform .2s, opacity .2s; }
.livechat-panel__send:hover { transform: translateY(-2px); }
.livechat-panel__send:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.livechat-empty, .livechat-error { padding: 34px 20px; text-align: center; color: var(--livechat-muted); font-size: 13px; }

@keyframes livechat-pop { from { opacity: 0; transform: translateY(7px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes livechat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 575px) {
    .livechat-launcher { right: 14px; bottom: 14px; }
    .livechat-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; transform-origin: center bottom; }
}

@media (prefers-reduced-motion: reduce) {
    .livechat-panel, .livechat-launcher, .livechat-message { transition: none; animation: none; }
    .livechat-typing__dots i { animation: none; }
}

