.chat-fab,
.chat-panel,
.chat-teaser {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-sizing: border-box;
}

.chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(145deg, #60a5fa 0%, #2563eb 58%, #1d4ed8 100%);
    box-shadow: 0 18px 48px rgba(37,99,235,.42), inset 0 1px 0 rgba(255,255,255,.24);
    cursor: pointer;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    transition: transform .22s ease, box-shadow .22s ease, border-radius .22s ease;
    text-indent: 0;
    overflow: visible;
}

.chat-fab::before,
.chat-fab::after { content: none; }
.chat-fab:hover { transform: translateY(-3px); box-shadow: 0 24px 62px rgba(37,99,235,.5); }
.chat-fab:active { transform: translateY(0) scale(.96); }
.chat-fab svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.chat-fab.is-open { border-radius: 50%; }

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 13px;
    height: 13px;
    border: 3px solid #0f172a;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34,197,94,.13);
}

.chat-teaser {
    position: fixed;
    right: 92px;
    bottom: 24px;
    z-index: 1199;
    width: min(310px, calc(100vw - 118px));
    padding: 13px 38px 13px 15px;
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 18px;
    color: #dbeafe;
    background: rgba(10,18,36,.95);
    box-shadow: 0 20px 56px rgba(2,6,23,.45);
    backdrop-filter: blur(18px);
    font-size: 13px;
    line-height: 1.45;
    opacity: 0;
    transform: translateY(8px) scale(.98);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.chat-teaser.is-visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; cursor: pointer; }
.chat-teaser-title { margin-bottom: 3px; color: #fff; font-size: 12px; font-weight: 800; }
.chat-teaser-close { position: absolute; top: 7px; right: 8px; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 9px; color: #94a3b8; background: transparent; cursor: pointer; font-size: 17px; }
.chat-teaser-close:hover { color: #fff; background: rgba(255,255,255,.08); }

.chat-panel {
    position: fixed;
    right: 22px;
    bottom: 92px;
    z-index: 1201;
    display: flex;
    flex-direction: column;
    width: 390px;
    max-width: calc(100vw - 44px);
    height: min(620px, calc(100vh - 126px));
    max-height: 620px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,.2);
    border-radius: 26px;
    color: #e2e8f0;
    background: #0b1222;
    box-shadow: 0 34px 100px rgba(2,6,23,.62), 0 0 0 1px rgba(255,255,255,.02) inset;
    opacity: 0;
    transform: translateY(18px) scale(.96);
    transform-origin: right bottom;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s cubic-bezier(.2,.8,.2,1);
}
.chat-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.chat-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 84px;
    padding: 16px 16px 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    background:
        radial-gradient(circle at 15% 0%, rgba(147,197,253,.28), transparent 46%),
        linear-gradient(135deg, #1e40af 0%, #2563eb 52%, #0f4fc7 100%);
}
.chat-header-main { display: flex; align-items: center; min-width: 0; gap: 12px; }
.chat-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.28); border-radius: 16px; color: #fff; background: rgba(255,255,255,.14); box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.chat-avatar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-heading { min-width: 0; }
.chat-title { display: block; color: #fff; font-size: 15px; font-weight: 850; letter-spacing: .01em; }
.chat-title::before { content: none; }
.chat-subtitle { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: rgba(239,246,255,.82); font-size: 11.5px; white-space: nowrap; }
.chat-online-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.16); }
.chat-close { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; color: #eff6ff; background: rgba(15,23,42,.16); cursor: pointer; font-size: 22px; line-height: 1; transition: background .18s ease, transform .18s ease; }
.chat-close:hover { background: rgba(15,23,42,.3); transform: rotate(3deg); }

.chat-handoff-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border-bottom: 1px solid rgba(34,197,94,.14);
    color: #bbf7d0;
    background: rgba(22,101,52,.16);
    font-size: 11.5px;
    line-height: 1.4;
}
.chat-handoff-status.is-visible { display: flex; }
.chat-handoff-status svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; }

.chat-body {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 18px 15px;
    overflow: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 100% 0%, rgba(37,99,235,.09), transparent 35%),
        linear-gradient(180deg, #0b1222 0%, #0d1628 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(96,165,250,.35) transparent;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(96,165,250,.3); }

.chat-empty { align-self: stretch; padding: 15px; border: 1px solid rgba(96,165,250,.14); border-radius: 18px; color: #b8c7df; background: rgba(30,64,175,.08); font-size: 13px; line-height: 1.55; }
.chat-empty strong { display: block; margin-bottom: 4px; color: #eff6ff; font-size: 13px; }

.chat-message-row { display: flex; align-items: flex-end; gap: 8px; max-width: 92%; }
.chat-message-row.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-message-row.admin { align-self: flex-start; }
.chat-message-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 25px; height: 25px; border: 1px solid rgba(96,165,250,.22); border-radius: 9px; color: #93c5fd; background: rgba(37,99,235,.12); font-size: 11px; font-weight: 900; }
.chat-message-row.user .chat-message-avatar { display: none; }
.chat-msg { max-width: 100%; padding: 10px 12px 8px; border-radius: 17px; font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; white-space: normal; }
.chat-msg.admin { align-self: auto; border: 1px solid rgba(148,163,184,.14); border-bottom-left-radius: 6px; color: #e5edf9; background: #172136; box-shadow: 0 8px 24px rgba(2,6,23,.14); }
.chat-msg.user { align-self: auto; border: 1px solid rgba(255,255,255,.12); border-bottom-right-radius: 6px; color: #fff; background: linear-gradient(135deg, #3b82f6, #2563eb); box-shadow: 0 10px 28px rgba(37,99,235,.2); }
.chat-msg a { color: #93c5fd; font-weight: 700; text-decoration: underline; text-decoration-color: rgba(147,197,253,.42); text-underline-offset: 2px; }
.chat-msg.user a { color: #fff; text-decoration-color: rgba(255,255,255,.55); }
.chat-meta { margin-top: 5px; color: rgba(203,213,225,.54); font-size: 9.5px; line-height: 1; text-align: right; }
.chat-msg.user .chat-meta { color: rgba(255,255,255,.66); }

.chat-typing { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin-left: 33px; padding: 12px 14px; border: 1px solid rgba(148,163,184,.13); border-radius: 17px 17px 17px 6px; background: #172136; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: #93c5fd; opacity: .42; animation: chatTypingDot 1.05s ease-in-out infinite; }
.chat-typing span:nth-child(2) { animation-delay: .14s; }
.chat-typing span:nth-child(3) { animation-delay: .28s; }
@keyframes chatTypingDot { 0%,100% { transform: translateY(0); opacity:.35; } 50% { transform: translateY(-4px); opacity:1; } }

.chat-lead-form { position: relative; align-self: stretch; display: grid; gap: 9px; padding: 15px; border: 1px solid rgba(96,165,250,.25); border-radius: 19px; background: linear-gradient(145deg, rgba(30,64,175,.18), rgba(15,23,42,.78)); box-shadow: 0 16px 38px rgba(2,6,23,.22); }
.chat-lead-head { padding-right: 28px; }
.chat-lead-head strong { display: block; color: #eff6ff; font-size: 13px; }
.chat-lead-head span { display: block; margin-top: 3px; color: #9fb0ca; font-size: 11.5px; line-height: 1.45; }
.chat-lead-close { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 9px; color: #94a3b8; background: rgba(255,255,255,.04); cursor: pointer; font-size: 18px; }
.chat-lead-close:hover { color: #fff; background: rgba(255,255,255,.09); }
.chat-lead-form input { width: 100%; height: 41px; box-sizing: border-box; padding: 0 11px; border: 1px solid rgba(148,163,184,.18); border-radius: 12px; outline: 0; color: #f8fafc; background: rgba(8,15,29,.72); font: inherit; font-size: 12.5px; }
.chat-lead-form input:focus { border-color: rgba(96,165,250,.65); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.chat-lead-form button[type="submit"] { height: 41px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(135deg, #3b82f6, #2563eb); cursor: pointer; font-weight: 800; }
.chat-lead-form button:disabled { opacity: .6; cursor: wait; }
.chat-lead-status { min-height: 16px; color: #fca5a5; font-size: 11px; line-height: 1.4; }

.chat-composer { flex: 0 0 auto; padding: 11px 12px 10px; border-top: 1px solid rgba(148,163,184,.12); background: #0d1628; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid rgba(148,163,184,.18); border-radius: 17px; background: rgba(6,12,24,.62); transition: border-color .18s ease, box-shadow .18s ease; }
.chat-form:focus-within { border-color: rgba(96,165,250,.58); box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
.chat-input { flex: 1 1 auto; width: auto; min-width: 0; max-height: 105px; min-height: 38px; margin: 0; padding: 9px 0 7px; overflow-y: auto; resize: none; border: 0; outline: 0; color: #f8fafc; background: transparent; font: inherit; font-size: 13.5px; line-height: 1.45; }
.chat-input::placeholder { color: #71819b; }
.chat-send { display: grid; place-items: center; flex: 0 0 auto; width: 39px; height: 39px; margin: 0; padding: 0; border: 0; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #3b82f6, #2563eb); cursor: pointer; box-shadow: 0 8px 20px rgba(37,99,235,.25); transition: transform .18s ease, opacity .18s ease; }
.chat-send:hover { transform: translateY(-1px); }
.chat-send:disabled { opacity: .48; cursor: wait; transform: none; }
.chat-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-hint { padding-top: 7px; color: #66758e; font-size: 9.5px; line-height: 1.35; text-align: center; }

@media (max-width: 600px) {
    .chat-fab { right: 14px; bottom: 14px; width: 55px; height: 55px; border-radius: 18px; }
    .chat-teaser { right: 78px; bottom: 16px; max-width: calc(100vw - 94px); }
    .chat-panel { inset: auto 10px 80px 10px; width: auto; max-width: none; height: min(680px, calc(100dvh - 98px)); max-height: none; border-radius: 24px; transform-origin: center bottom; }
    .chat-header { min-height: 76px; padding: 13px 13px 13px 15px; }
    .chat-avatar { width: 41px; height: 41px; border-radius: 14px; }
    .chat-subtitle { white-space: normal; }
    .chat-body { padding: 15px 12px; }
    .chat-message-row { max-width: 95%; }
}

@media (max-width: 380px) {
    .chat-panel { left: 6px; right: 6px; bottom: 74px; height: calc(100dvh - 84px); border-radius: 21px; }
    .chat-title { font-size: 14px; }
    .chat-subtitle { font-size: 10.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-fab, .chat-panel, .chat-teaser, .chat-typing span { transition: none; animation: none; }
}
