.sunder-chatbot-launcher {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 10020;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.5rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background: linear-gradient(135deg, #5b3aa6, #9d6bff);
    color: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    font-weight: 700;
}

.sunder-chatbot-launcher__logo,
.sunder-chatbot-panel__logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.sunder-chatbot-panel {
    position: fixed;
    right: 1rem;
    bottom: 4.2rem;
    z-index: 10021;
    width: min(420px, calc(100vw - 1rem));
    height: min(78vh, 760px);
    display: flex;
    flex-direction: column;
    border-radius: 1rem;
    overflow: hidden;
    background: var(--md-default-bg-color);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 22px 54px rgba(0,0,0,0.42);
}

.sunder-chatbot-panel[hidden] {
    display: none !important;
}

.sunder-chatbot-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, rgba(90,45,130,0.22), rgba(249,199,79,0.08));
}

.sunder-chatbot-panel__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sunder-chatbot-panel__title {
    font-weight: 700;
}

.sunder-chatbot-panel__subtitle {
    font-size: 0.8rem;
    opacity: 0.72;
}

.sunder-chatbot-iconbtn {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
}

.sunder-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.sunder-chatbot-msg {
    max-width: 92%;
    padding: 0.8rem 0.9rem;
    border-radius: 0.85rem;
    line-height: 1.5;
}

.sunder-chatbot-msg--user {
    align-self: flex-end;
    background: rgba(90,45,130,0.22);
}

.sunder-chatbot-msg--assistant {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
}

.sunder-chatbot-sources {
    margin-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.sunder-chatbot-source {
    display: inline-flex;
    align-items: center;
    padding: 0.10rem 0.25rem;
    border-radius: 999px;
    background: rgba(249,199,79,0.42);
    color: var(--md-accent-fg-color);
    font-size: 0.52rem;
    line-height: 0.9;
    text-decoration: none;
    white-space: normal;
    text-wrap: balance;
}

.sunder-chatbot-source:hover {
    background: rgba(249,199,79,0.47);
    border: 1px solid rgba(249,199,79,0.67);
}

.sunder-chatbot-input {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 0.85rem;
    background: rgba(0,0,0,0.05);
}

.sunder-chatbot-textarea {
    width: 100%;
    resize: none;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: var(--md-default-bg-color);
    color: inherit;
    border: 1px solid rgba(255,255,255,0.14);
    font: inherit;
    box-sizing: border-box;
}

.sunder-chatbot-input__footer {
    margin-top: 0.7rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.sunder-chatbot-modepicker {
    position: relative;
}

.sunder-chatbot-modebutton {
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.04);
    color: inherit;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.sunder-chatbot-mode-menu {
    position: absolute;
    bottom: calc(100% + 0.45rem);
    left: 0;
    min-width: 180px;
    border-radius: 0.8rem;
    overflow: hidden;
    background: var(--md-default-bg-color);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 16px 32px rgba(0,0,0,0.25);
}

.sunder-chatbot-mode-option {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: inherit;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
}

.sunder-chatbot-mode-option:hover {
    background: rgba(90,45,130,0.14);
}

.sunder-chatbot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.sunder-chatbot-chip {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: inherit;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}

.sunder-chatbot-msg--thinking {
    position: relative;
    overflow: hidden;
}

.sunder-chatbot-thinking {
    position: relative;
    display: inline-block;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.01em;
}

.sunder-chatbot-thinking::after {
    content: "";
    position: absolute;
    top: -0.08rem;
    bottom: -0.08rem;
    left: -1.6rem;
    width: 3.4rem;
    transform: translateX(-120%);
    background: linear-gradient(
        90deg,
        rgba(8, 12, 18, 0) 0%,
        rgba(8, 12, 18, 0.42) 18%,
        rgba(8, 12, 18, 0.82) 45%,
        rgba(8, 12, 18, 0.96) 55%,
        rgba(8, 12, 18, 0.82) 65%,
        rgba(8, 12, 18, 0.42) 82%,
        rgba(8, 12, 18, 0) 100%
    );
    animation: sunder-thinking-sweep 1.1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes sunder-thinking-sweep {
    0% {
        transform: translateX(-0.6rem);
    }
    100% {
        transform: translateX(4.6rem);
    }
}

@media (max-width: 900px), (pointer: coarse) {
    #sunder-chatbot-root {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .sunder-chatbot-launcher {
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        padding: 0.35rem 0.45rem;
    }

    .sunder-chatbot-panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: min(88dvh, 100dvh);
        max-height: 100dvh;
        border-radius: 1rem 1rem 0 0 ;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .sunder-chatbot-panel__header {
        padding: 0.65rem 0.75rem;
    }

    .sunder-chatbot-messages {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sunder-chatbot-msg {
        max-width: 100%;
        padding: 0.7rem 0.8rem;
    }

    .sunder-chatbot-input {
        padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .sunder-chatbot-input__footer {
        gap: 0.5rem;
    }

    .sunder-chatbot-modebutton {
        padding: 0.4rem 0.65rem;
    }
}

@media (max-width: 600px) {
    .sunder-chatbot-input__footer {
        align-items: center;
    }

    .sunder-chatbot-textarea {
        min-height: 5.25rem;
        font-size: 16px; /* avoids iOS zoom */
    }

    #sunder-chatbot-send {
        min-width: 6.25rem;
        padding-inline: 1rem;
    }

    .sunder-chatbot-chip {
        padding: 0.3rem 0.55rem;
        font-size: 0.82rem;
    }
}