.ccbot-widget {
    position: fixed;
    bottom: calc(var(--ccbot-offset-bottom, 24px) + env(safe-area-inset-bottom, 0px));
    right: calc(var(--ccbot-offset-side, 24px) + env(safe-area-inset-right, 0px));
    z-index: 1000000;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    --ccbot-primary: #FF2F92;
    --ccbot-primary-dark: #C77DFF;
    --ccbot-accent: #f9c7d8;
    --ccbot-surface: #ffffff;
    --ccbot-surface-alt: #fff7fa;
    --ccbot-border: #f0d6e3;
    --ccbot-text: #2a1620;
    --ccbot-muted: #6b4b5a;
    --ccbot-shadow: 0 24px 60px rgba(67, 23, 43, 0.2);
    --ccbot-offset-bottom: 24px;
    --ccbot-offset-side: 24px;
    --ccbot-launcher-size: 52px;
    --ccbot-icon-size: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, bottom 0.28s ease, right 0.28s ease, left 0.28s ease;
}

.ccbot-widget.ccbot-ready {
    opacity: 1;
    pointer-events: auto;
}

.ccbot-widget[data-position="left"] {
    left: calc(var(--ccbot-offset-side, 24px) + env(safe-area-inset-left, 0px));
    right: auto;
}

.ccbot-widget[data-position="right"] {
    right: var(--ccbot-offset-side, 24px);
    left: auto;
}

.ccbot-launcher {
    background: linear-gradient(135deg, var(--ccbot-primary) 0%, var(--ccbot-primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0;
    cursor: pointer;
    box-shadow: var(--ccbot-shadow);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ccbot-launcher-size);
    height: var(--ccbot-launcher-size);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ccbot-widget[data-icon-style="plain"] .ccbot-launcher {
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
}

.ccbot-widget[data-icon-style="plain"] .ccbot-launcher-icon,
.ccbot-widget[data-icon-style="plain"] .ccbot-launcher-image {
    filter: drop-shadow(0 6px 12px rgba(67, 23, 43, 0.25));
}
.ccbot-launcher-icon {
    font-size: var(--ccbot-icon-size);
    font-weight: 600;
    line-height: 1;
}

.ccbot-launcher-image {
    width: var(--ccbot-icon-size);
    height: var(--ccbot-icon-size);
    object-fit: contain;
    display: block;
}

.ccbot-tooltip {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    background: #2f1b26;
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ccbot-launcher:hover .ccbot-tooltip,
.ccbot-launcher:focus .ccbot-tooltip,
.ccbot-launcher:focus-visible .ccbot-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ccbot-panel {
    width: min(400px, calc(100vw - 40px));
    height: min(600px, calc(var(--ccbot-vh, 1vh) * 100 - 40px));
    max-height: calc(var(--ccbot-vh, 1vh) * 100 - 40px);
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--ccbot-border);
    box-shadow: var(--ccbot-shadow);
    position: absolute;
    bottom: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform-origin: bottom right;
}

.ccbot-widget[data-position="left"] .ccbot-panel {
    left: 0;
    right: auto;
    transform-origin: bottom left;
}

.ccbot-widget[data-position="right"] .ccbot-panel {
    right: 0;
    left: auto;
}

.ccbot-widget[data-open="true"] .ccbot-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ccbot-widget[data-open="true"] .ccbot-launcher {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.9);
}

.ccbot-header {
    background: linear-gradient(135deg, var(--ccbot-primary-dark) 0%, var(--ccbot-primary) 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ccbot-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ccbot-clear {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.ccbot-clear:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ccbot-rowdy-toggle {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.ccbot-rowdy-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ccbot-rowdy-toggle.active {
    background: rgba(255, 255, 255, 0.9);
    color: var(--ccbot-primary);
    border-color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.ccbot-rowdy-toggle.active:hover {
    background: rgba(255, 255, 255, 1);
}

.ccbot-title {
    font-size: 15px;
    font-weight: 600;
}

.ccbot-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.ccbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--ccbot-surface-alt);
}

.ccbot-message {
    margin-bottom: 10px;
    display: flex;
}

.ccbot-message.user {
    justify-content: flex-end;
}

.ccbot-message .bubble {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 10px 24px rgba(67, 23, 43, 0.08);
}

.ccbot-message.user .bubble {
    background: var(--ccbot-primary-dark);
    color: #fff;
}

.ccbot-message.assistant .bubble {
    background: var(--ccbot-surface);
    color: var(--ccbot-text);
    border: 1px solid var(--ccbot-border);
}

.ccbot-message.assistant .bubble p {
    margin: 0 0 8px;
}

.ccbot-message.assistant .bubble p:last-child {
    margin-bottom: 0;
}

.ccbot-message.assistant .bubble h1,
.ccbot-message.assistant .bubble h2,
.ccbot-message.assistant .bubble h3 {
    margin: 8px 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ccbot-text);
}

.ccbot-message.assistant .bubble ul,
.ccbot-message.assistant .bubble ol {
    margin: 6px 0 8px 18px;
    padding: 0;
}

.ccbot-message.assistant .bubble li {
    margin-bottom: 4px;
}

.ccbot-message.assistant .bubble a {
    color: var(--ccbot-primary-dark);
    text-decoration: underline;
}

.ccbot-message.assistant .bubble code {
    background: #f2e4ec;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.ccbot-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ccbot-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ccbot-muted);
    animation: ccbot-typing 1.2s infinite ease-in-out;
}

.ccbot-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ccbot-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.ccbot-image {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--ccbot-border);
    background: var(--ccbot-surface);
}

.ccbot-image img {
    width: 130px;
    height: 130px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.ccbot-input {
    display: flex;
    border-top: 1px solid var(--ccbot-border);
    background: var(--ccbot-surface);
    padding: 12px;
    gap: 10px;
}

.ccbot-input input {
    flex: 1;
    border: 1px solid var(--ccbot-border);
    border-radius: 999px;
    padding: 12px 14px;
    font-size: 13px;
    outline: none;
    background: transparent;
    color: var(--ccbot-text);
}

.ccbot-input input:focus {
    border-color: var(--ccbot-primary);
    box-shadow: 0 0 0 3px rgba(255, 47, 146, 0.15);
}

.ccbot-input button {
    border: none;
    background: linear-gradient(135deg, var(--ccbot-primary) 0%, var(--ccbot-primary-dark) 100%);
    color: #fff;
    padding: 0 20px;
    cursor: pointer;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(255, 47, 146, 0.35);
}

.ccbot-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(255, 47, 146, 0.45);
}

.ccbot-disclaimer {
    font-size: 11px;
    color: var(--ccbot-muted);
    padding: 8px 12px 14px;
}

@keyframes ccbot-typing {
    0%,
    80%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .ccbot-widget {
        right: 12px;
        left: 12px;
    }

    .ccbot-panel {
        width: calc(100vw - 40px);
        right: auto;
        height: calc(var(--ccbot-vh, 1vh) * 100 - 40px);
        max-height: calc(var(--ccbot-vh, 1vh) * 100 - 40px);
    }
}

@media (max-width: 768px) {
    .ccbot-panel {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 20px);
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        left: calc(env(safe-area-inset-left, 0px) + 20px);
        right: calc(env(safe-area-inset-right, 0px) + 20px);
        width: auto;
        height: auto;
        max-height: none;
        border-radius: 18px;
        transform-origin: center;
    }

    .ccbot-widget[data-position="left"] .ccbot-panel,
    .ccbot-widget[data-position="right"] .ccbot-panel {
        left: calc(env(safe-area-inset-left, 0px) + 20px);
        right: calc(env(safe-area-inset-right, 0px) + 20px);
    }
}

html.ccbot-no-scroll,
body.ccbot-no-scroll {
    overflow: hidden;
}

body.ccbot-no-scroll {
    position: fixed;
    width: 100%;
    touch-action: none;
}

