.cee-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    margin: 0 !important;
    z-index: 99998;
    width: 60px;
    height: 60px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.cee-chat-launcher:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.05);
}

.cee-chat-launcher.cee-chat-hidden {
    opacity: 0;
    pointer-events: none;
}

/* Electro's "Scroll to Top" arrow (36px) sits where the launcher is; stack it
   12px above the launcher and center it over it. */
body:has(#cee-chat-launcher) .back-to-top-wrapper {
    right: 36px !important;
}

body:has(#cee-chat-launcher) .back-to-top-wrapper .back-to-top-link {
    top: calc(100vh - 132px) !important;
    top: calc(100dvh - 132px) !important;
}

.cee-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    margin: 0 !important;
    z-index: 99999;
    width: var(--cee-chat-width, 575px);
    min-width: 300px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.cee-chat-panel.cee-chat-open {
    transform: translateX(0);
}

/* layout="page": full-width chat inside the page content. */
.cee-chat-panel.cee-chat-inline {
    position: relative;
    top: auto;
    right: auto;
    z-index: auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 75vh;
    height: 75dvh;
    min-height: 340px;
    margin: 0 0 16px !important;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    transform: none;
    transition: none;
}

body.admin-bar .cee-chat-panel.cee-chat-inline {
    top: auto;
    height: 75vh;
    height: 75dvh;
}

/* The page title would push the full-page chat below the fold; the chat
   header names it instead. Kept for screen readers and SEO. */
body:has(.cee-chat-inline) .entry-header {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 768px) {
    .cee-chat-panel.cee-chat-inline {
        width: 100% !important;
        height: 80vh;
        height: 80dvh;
        min-height: 340px;
        border-radius: 0;
    }
}

body.admin-bar .cee-chat-panel {
    top: 32px;
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
}

@media (max-width: 782px) {
    body.admin-bar .cee-chat-panel {
        top: 46px;
        height: calc(100vh - 46px);
        height: calc(100dvh - 46px);
    }
}

.cee-chat-panel.cee-chat-resizing,
.cee-chat-panel.cee-chat-restoring {
    transition: none;
    user-select: none;
}

.cee-chat-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    z-index: 2;
}

.cee-chat-resizer:hover {
    background: rgba(0, 0, 0, 0.08);
}

.cee-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1f2937;
    color: #fff;
    flex-shrink: 0;
}

.cee-chat-title {
    font-size: 15px;
    font-weight: 600;
}

.cee-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
}

.cee-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cee-chat-header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cee-chat-restart {
    background: transparent;
    border: none;
    color: #fff;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.cee-chat-restart:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Spoken-answer volume slider + mute toggle (added by chat.js). */
.cee-chat-audio {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
}

.cee-chat-audio-toggle {
    background: transparent;
    border: none;
    color: #fff;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.cee-chat-audio-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cee-chat-audio-toggle[aria-pressed="true"] {
    opacity: 0.85;
}

.cee-chat-volume {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
    accent-color: #ffffff;
    cursor: pointer;
}

.cee-chat-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
}

.cee-chat-volume::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
}

.cee-chat-volume:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 4px;
}

@media (max-width: 400px) {
    .cee-chat-volume {
        width: 56px;
    }
}

.cee-chat-webchat {
    width: 100%;
    height: 100%;
}

.cee-chat-webchat.cee-chat-scroll-restoring .webchat__basic-transcript {
    visibility: hidden;
}

/* "Thinking" dots live inside the user's latest question bubble (chat.js
   adds .cee-chat-thinking); Web Chat's separate typing indicator is hidden. */
.cee-chat-webchat .webchat__typing-indicator {
    display: none !important;
}

.cee-chat-webchat .cee-chat-thinking .webchat__bubble__content::after {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    margin: 8px 0 2px 20px;
    border-radius: 50%;
    background: currentColor;
    color: rgba(255, 255, 255, 0.95);
    box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.35), 14px 0 0 0 rgba(255, 255, 255, 0.35);
    animation: cee-chat-thinking 1.2s infinite linear;
}

@keyframes cee-chat-thinking {
    0% { background: rgba(255, 255, 255, 0.35); box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.95), 14px 0 0 0 rgba(255, 255, 255, 0.35); }
    33% { background: rgba(255, 255, 255, 0.95); box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.35), 14px 0 0 0 rgba(255, 255, 255, 0.35); }
    66% { background: rgba(255, 255, 255, 0.35); box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.35), 14px 0 0 0 rgba(255, 255, 255, 0.95); }
    100% { background: rgba(255, 255, 255, 0.35); box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.95), 14px 0 0 0 rgba(255, 255, 255, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
    .cee-chat-webchat .cee-chat-thinking .webchat__bubble__content::after {
        animation: none;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: -14px 0 0 0 rgba(255, 255, 255, 0.95), 14px 0 0 0 rgba(255, 255, 255, 0.95);
    }
}

/* Web Chat renders regular DOM, so plain CSS overrides work too. */
.cee-chat-webchat .webchat__basic-transcript {
    padding-top: 8px;
}

/* Dark themes (e.g. Electro) set white text on tables, headings and links;
   keep agent answers dark on the light bubble. */
.cee-chat-webchat .webchat__bubble:not(.webchat__bubble--from-user) .webchat__bubble__content,
.cee-chat-webchat .webchat__bubble:not(.webchat__bubble--from-user) .webchat__bubble__content :is(p, li, span, strong, b, em, h1, h2, h3, h4, h5, h6, table, thead, tbody, tr, th, td, code, blockquote, button) {
    color: #242424 !important;
}

.cee-chat-webchat .webchat__bubble:not(.webchat__bubble--from-user) .webchat__bubble__content a {
    color: #242424 !important;
    text-decoration: underline;
}

/* Ensure send-box icons are white even if a theme recolors SVGs. */
.cee-chat-webchat .webchat__send-box button svg,
.cee-chat-webchat .webchat__send-box button svg * {
    fill: #ffffff !important;
}

/* Microphone button: same look as the send button, pulses while listening. */
.cee-chat-webchat .cee-chat-mic {
    position: relative;
}

.cee-chat-webchat .cee-chat-mic.cee-chat-mic--listening {
    animation: cee-chat-mic-pulse 1.2s ease-out infinite;
}

.cee-chat-webchat .cee-chat-mic.cee-chat-mic--listening svg {
    animation: cee-chat-mic-blink 1.2s ease-in-out infinite;
}

@keyframes cee-chat-mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(225, 31, 39, 0.7); }
    100% { box-shadow: 0 0 0 12px rgba(225, 31, 39, 0); }
}

@keyframes cee-chat-mic-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .cee-chat-webchat .cee-chat-mic.cee-chat-mic--listening,
    .cee-chat-webchat .cee-chat-mic.cee-chat-mic--listening svg {
        animation: none;
    }

    .cee-chat-webchat .cee-chat-mic.cee-chat-mic--listening {
        outline: 2px solid #ffffff;
        outline-offset: -4px;
    }
}

.cee-chat-error {
    padding: 16px;
    color: #b91c1c;
}

.cee-chat-body {
    flex: 1;
    overflow: hidden;
    padding-bottom: 20px;
    background: #fff;
}

@media (max-width: 768px) {
    .cee-chat-panel {
        width: 100vw !important;
        min-width: 0;
        max-width: none;
    }

    .cee-chat-resizer {
        display: none;
    }

    .cee-chat-close {
        font-size: 22px;
        padding: 8px 14px;
    }
}
