.rtcs-chat,
.rtcs-chat * {
    box-sizing: border-box;
}

.rtcs-chat {
    --chat-red: #ff2436;
    --chat-red-dark: #8f0015;
    --chat-blue: #62f4ff;
    --chat-ink: #05070c;
    --chat-panel: #090d16;
    --chat-panel-2: #101725;
    --chat-text: #f5f7fb;
    --chat-muted: #9ba8bd;
    --chat-border: rgba(255, 255, 255, .13);
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 200;
    direction: ltr;
    color: var(--chat-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rtcs-chat button,
.rtcs-chat input,
.rtcs-chat textarea,
.rtcs-chat select {
    font: inherit;
}

.rtcs-chat button {
    cursor: pointer;
}

.rtcs-chat__launcher {
    position: relative;
    min-width: 158px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 18px 0 10px;
    border: 1px solid rgba(255, 51, 69, .65);
    border-radius: 999px;
    background: linear-gradient(135deg, #ec1029, #850013);
    color: #fff;
    box-shadow: 0 14px 42px rgba(0, 0, 0, .48), 0 0 28px rgba(255, 36, 54, .23);
    font-weight: 900;
    letter-spacing: .01em;
    transition: transform .2s ease, box-shadow .2s ease, opacity .18s ease;
}

.rtcs-chat__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .55), 0 0 34px rgba(255, 36, 54, .35);
}

.rtcs-chat.is-open .rtcs-chat__launcher {
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px) scale(.96);
}

.rtcs-chat__launcher-mark,
.rtcs-chat__avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 50%;
    background: #090a0f;
}

.rtcs-chat__launcher-mark {
    width: 40px;
    height: 40px;
}

.rtcs-chat__launcher-mark img,
.rtcs-chat__avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.rtcs-chat__launcher-pulse {
    position: absolute;
    top: 2px;
    right: 5px;
    width: 10px;
    height: 10px;
    border: 2px solid #10131b;
    border-radius: 50%;
    background: #3ef28c;
    box-shadow: 0 0 13px rgba(62, 242, 140, .8);
}

.rtcs-chat__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(420px, calc(100vw - 24px));
    height: min(720px, calc(100dvh - 112px));
    min-height: 480px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 24px;
    background:
        radial-gradient(circle at 10% 0, rgba(255, 36, 54, .18), transparent 220px),
        linear-gradient(180deg, rgba(13, 18, 30, .985), rgba(5, 7, 12, .99));
    box-shadow: 0 30px 90px rgba(0, 0, 0, .66), 0 0 0 1px rgba(255, 36, 54, .08) inset;
    transform-origin: right bottom;
    animation: rtcs-chat-enter .24s ease both;
}

.rtcs-chat__panel[hidden] {
    display: none;
}

.rtcs-chat__panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .22;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to bottom, #000, transparent 60%);
}

.rtcs-chat__header {
    position: relative;
    z-index: 1;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 15px;
    border-bottom: 1px solid var(--chat-border);
    background: rgba(6, 9, 15, .72);
    backdrop-filter: blur(18px);
}

.rtcs-chat__identity {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.rtcs-chat__avatar {
    width: 44px;
    height: 44px;
    box-shadow: 0 0 20px rgba(255, 36, 54, .2);
}

.rtcs-chat__identity strong,
.rtcs-chat__identity span {
    display: block;
}

.rtcs-chat__identity strong {
    overflow: hidden;
    color: #fff;
    font-size: .96rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rtcs-chat__identity span {
    margin-top: 3px;
    color: var(--chat-muted);
    font-size: .72rem;
}

.rtcs-chat__identity i {
    width: 7px;
    height: 7px;
    display: inline-block;
    margin-right: 4px;
    border-radius: 50%;
    background: #3ef28c;
    box-shadow: 0 0 9px rgba(62, 242, 140, .85);
}

.rtcs-chat__header-actions {
    display: flex;
    gap: 5px;
}

.rtcs-chat__header-actions button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: #cbd3e1;
}

.rtcs-chat__header-actions button:hover {
    border-color: var(--chat-border);
    background: rgba(255,255,255,.07);
    color: #fff;
}

.rtcs-chat__header-actions svg,
.rtcs-chat__composer svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rtcs-chat__messages {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 15px 22px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 36, 54, .65) rgba(255,255,255,.04);
}

.rtcs-chat__message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.rtcs-chat__message--user {
    justify-content: flex-end;
}

.rtcs-chat__message-avatar {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    flex: 0 0 28px;
    border: 1px solid rgba(255, 36, 54, .5);
    border-radius: 50%;
    background: rgba(255, 36, 54, .12);
    color: #fff;
    font-size: .72rem;
    font-weight: 900;
}

.rtcs-chat__bubble {
    max-width: min(84%, 330px);
    padding: 11px 13px;
    border: 1px solid var(--chat-border);
    border-radius: 17px 17px 17px 5px;
    background: linear-gradient(145deg, rgba(26, 34, 51, .96), rgba(13, 18, 29, .96));
    color: #e9edf5;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

.rtcs-chat__message--user .rtcs-chat__bubble {
    border-color: rgba(255, 36, 54, .45);
    border-radius: 17px 17px 5px 17px;
    background: linear-gradient(135deg, #cf1028, #8b0017);
    color: #fff;
}

.rtcs-chat__bubble p {
    margin: 0;
    color: inherit;
    font-size: .9rem;
    line-height: 1.52;
    white-space: pre-wrap;
}

.rtcs-chat__bubble p + p {
    margin-top: 8px;
}

.rtcs-chat__links,
.rtcs-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-left: 36px;
}

.rtcs-chat__links a,
.rtcs-chat__suggestions button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border: 1px solid rgba(98, 244, 255, .24);
    border-radius: 999px;
    background: rgba(98, 244, 255, .06);
    color: #c9f9ff;
    font-size: .76rem;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none;
}

.rtcs-chat__suggestions button:hover,
.rtcs-chat__links a:hover {
    border-color: rgba(98, 244, 255, .6);
    background: rgba(98, 244, 255, .12);
    color: #fff;
}

.rtcs-chat__typing {
    position: relative;
    z-index: 1;
    min-height: 28px;
    align-items: center;
    gap: 4px;
    padding: 3px 18px 7px 52px;
}

.rtcs-chat__typing:not([hidden]) {
    display: flex;
}

.rtcs-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-muted);
    animation: rtcs-chat-typing 1s ease-in-out infinite;
}

.rtcs-chat__typing span:nth-child(2) { animation-delay: .14s; }
.rtcs-chat__typing span:nth-child(3) { animation-delay: .28s; }

.rtcs-chat__composer {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: end;
    gap: 8px;
    margin: 0 12px;
    padding: 7px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 17px;
    background: rgba(255,255,255,.065);
}

.rtcs-chat__composer:focus-within {
    border-color: rgba(98, 244, 255, .65);
    box-shadow: 0 0 0 3px rgba(98, 244, 255, .08);
}

.rtcs-chat__composer textarea {
    width: 100%;
    max-height: 110px;
    resize: none;
    overflow-y: auto;
    padding: 9px 8px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #fff;
    font-size: .9rem;
    line-height: 1.35;
}

.rtcs-chat__composer textarea::placeholder {
    color: #8995a8;
}

.rtcs-chat__composer button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--chat-red), var(--chat-red-dark));
    color: #fff;
    box-shadow: 0 7px 18px rgba(255, 36, 54, .22);
}

.rtcs-chat__composer button:disabled {
    cursor: wait;
    opacity: .55;
}

.rtcs-chat__privacy {
    position: relative;
    z-index: 1;
    margin: 7px 14px 10px;
    color: #7f899a;
    font-size: .66rem;
    text-align: center;
}

.rtcs-chat__privacy a {
    color: #b8c3d6;
}

.rtcs-chat__lead-form {
    width: calc(100% - 36px);
    align-self: center;
    margin: 3px 0 4px 36px;
    padding: 15px;
    border: 1px solid rgba(255, 36, 54, .4);
    border-radius: 17px;
    background: linear-gradient(145deg, rgba(31, 13, 20, .97), rgba(10, 13, 21, .98));
    box-shadow: 0 14px 36px rgba(0,0,0,.26);
}

.rtcs-chat__lead-head > span {
    color: var(--chat-red);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.rtcs-chat__lead-head strong {
    display: block;
    margin-top: 4px;
    color: #fff;
    font-size: 1rem;
}

.rtcs-chat__lead-head p {
    margin: 6px 0 13px;
    color: var(--chat-muted);
    font-size: .75rem;
    line-height: 1.45;
}

.rtcs-chat__lead-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.rtcs-chat__lead-grid label {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.rtcs-chat__lead-grid label > span {
    color: #cad2df;
    font-size: .7rem;
    font-weight: 750;
}

.rtcs-chat__lead-grid input,
.rtcs-chat__lead-grid textarea,
.rtcs-chat__lead-grid select {
    width: 100%;
    min-height: 40px;
    padding: 8px 9px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 9px;
    outline: 0;
    background: #0b101b;
    color: #fff;
    font-size: .78rem;
}

.rtcs-chat__lead-grid textarea {
    min-height: 86px;
    resize: vertical;
}

.rtcs-chat__lead-grid input:focus,
.rtcs-chat__lead-grid textarea:focus,
.rtcs-chat__lead-grid select:focus {
    border-color: var(--chat-blue);
    box-shadow: 0 0 0 3px rgba(98,244,255,.08);
}

.rtcs-chat__lead-wide {
    grid-column: 1 / -1;
}

.rtcs-chat__lead-consent {
    display: flex !important;
    grid-template-columns: none !important;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px !important;
}

.rtcs-chat__lead-consent input {
    width: 24px;
    min-height: 24px;
    flex: 0 0 24px;
    padding: 0;
    accent-color: var(--chat-red);
}

.rtcs-chat__lead-consent span {
    line-height: 1.35;
}

.rtcs-chat__lead-trap {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.rtcs-chat__lead-submit {
    width: 100%;
    min-height: 43px;
    margin-top: 12px;
    border: 1px solid rgba(255, 55, 71, .65);
    border-radius: 10px;
    background: linear-gradient(135deg, var(--chat-red), var(--chat-red-dark));
    color: #fff;
    font-size: .8rem;
    font-weight: 900;
}

.rtcs-chat__lead-status {
    min-height: 1em;
    margin: 8px 0 0;
    color: #cbd3e1;
    font-size: .72rem;
    line-height: 1.4;
}

.rtcs-chat__lead-status.is-error {
    color: #ff9aa6;
}

@keyframes rtcs-chat-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes rtcs-chat-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 560px) {
    .rtcs-chat {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
    }

    .rtcs-chat__launcher {
        min-width: 58px;
        width: 58px;
        padding: 0;
    }

    .rtcs-chat__launcher-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .rtcs-chat__panel {
        position: fixed;
        inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        width: auto;
        height: auto;
        min-height: 0;
        border-radius: 20px;
        transform-origin: right bottom;
    }

    .rtcs-chat__bubble {
        max-width: 88%;
    }

    .rtcs-chat__lead-grid {
        grid-template-columns: 1fr;
    }

    .rtcs-chat__lead-wide {
        grid-column: auto;
    }
}

@media (max-height: 620px) and (min-width: 561px) {
    .rtcs-chat__panel {
        height: calc(100dvh - 28px);
        min-height: 0;
        bottom: 0;
    }
}

@media (min-width: 2200px) and (min-height: 1200px) {
    .rtcs-chat {
        right: 34px;
        bottom: 34px;
    }

    .rtcs-chat__panel {
        width: 500px;
        height: 800px;
        bottom: 84px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rtcs-chat__panel,
    .rtcs-chat__typing span {
        animation: none !important;
    }

    .rtcs-chat__launcher {
        transition: none;
    }
}
