.raro-ai-dock {
    position: fixed;
    right: 22px;
    bottom: 22px;
    /* Keep dialogs and their sticky action bars above the global assistant. */
    z-index: 30;
    display: grid;
    justify-items: end;
    gap: 10px;
}

.raro-ai-dock-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 17px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #712284, #9333ea);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 14px 34px rgba(76, 29, 149, .28);
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease;
}

.raro-ai-dock-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(76, 29, 149, .34);
}

body:has(.raro-module-home--analytics) .raro-ai-dock-trigger {
    border: 1px solid var(--raro-line);
    border-radius: 10px;
    color: var(--raro-text);
    background: var(--raro-surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
    font-weight: 500;
    transition: color 160ms cubic-bezier(.22, 1, .36, 1), background-color 160ms cubic-bezier(.22, 1, .36, 1), border-color 160ms cubic-bezier(.22, 1, .36, 1);
}

body:has(.raro-module-home--analytics) .raro-ai-dock-trigger:hover {
    border-color: color-mix(in srgb, var(--raro-text) 16%, var(--raro-line));
    color: var(--raro-accent);
    background: var(--raro-tint);
    box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
    transform: none;
}

.raro-ai-dock-trigger svg,
.raro-ai-dock-panel header svg,
.raro-ai-dock-composer svg {
    width: 18px;
    height: 18px;
}

.raro-ai-dock-panel {
    position: absolute;
    right: 0;
    bottom: 58px;
    display: flex;
    width: min(410px, calc(100vw - 28px));
    height: min(650px, calc(100vh - 110px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .3);
    border-radius: 22px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}

.dark .raro-ai-dock-panel {
    border-color: rgba(100, 116, 139, .4);
    background: #111827;
    color: #e5e7eb;
}

.raro-ai-dock-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #faf5ff, #f5f3ff);
}

.dark .raro-ai-dock-panel > header {
    border-color: #374151;
    background: linear-gradient(135deg, #2e1065, #1f2937);
}

.raro-ai-dock-panel > header > div:first-child {
    min-width: 0;
}

.raro-ai-dock-panel > header strong,
.raro-ai-dock-panel > header small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.raro-ai-dock-panel > header small {
    margin-top: 2px;
    color: #64748b;
    font-size: 11px;
}

.dark .raro-ai-dock-panel > header small {
    color: #c4b5fd;
}

.raro-ai-dock-panel > header > div:last-child {
    display: flex;
    align-items: center;
    gap: 4px;
}

.raro-ai-dock-panel > header a,
.raro-ai-dock-panel > header button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
}

.raro-ai-dock-panel > header :is(a, button):hover {
    background: rgba(113, 34, 132, .1);
    color: #712284;
}

.dark .raro-ai-dock-panel > header :is(a, button) {
    color: #ddd6fe;
}

select.raro-ai-dock-history {
    width: calc(100% - 28px);
    margin: 10px 14px 0;
}

.raro-ai-dock-history,
.raro-ai-dock-start select {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    padding: 9px 10px;
    color: #111827;
    font-size: 13px;
}

.raro-ai-dock-start select {
    width: 100%;
}

.dark :is(.raro-ai-dock-history, .raro-ai-dock-start select) {
    border-color: #4b5563;
    background: #1f2937;
    color: #f9fafb;
}

.raro-ai-dock-start {
    display: grid;
    align-content: center;
    justify-items: stretch;
    gap: 12px;
    flex: 1;
    padding: 28px;
    text-align: center;
}

.raro-ai-dock-start > svg {
    width: 42px;
    height: 42px;
    margin: 0 auto;
    color: #712284;
}

.raro-ai-dock-start small {
    color: #64748b;
    line-height: 1.45;
}

.raro-ai-dock-start label {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
}

.raro-ai-dock-start button {
    padding: 10px 14px;
    border: 0;
    border-radius: 11px;
    background: #712284;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.raro-ai-dock-messages {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 15px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.dark .raro-ai-dock-messages {
    background: #0f172a;
}

.raro-ai-dock-messages article {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 15px;
    background: #fff;
    color: #1f2937;
    font-size: 13px;
    line-height: 1.48;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
    overflow-wrap: anywhere;
}

.dark .raro-ai-dock-messages article {
    background: #1f2937;
    color: #f3f4f6;
}

.raro-ai-dock-messages article.is-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: #712284;
    color: #fff;
}

.raro-ai-dock-messages article.is-assistant {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.raro-ai-dock-messages article small {
    display: block;
    margin-bottom: 3px;
    font-size: 10px;
    font-weight: 800;
    opacity: .7;
}

.raro-ai-dock-messages article p {
    margin: 0;
    white-space: pre-wrap;
}

.raro-ai-dock-pending {
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: .76;
}

.raro-ai-dock-pending > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    color: #64748b;
    font-size: 11px;
}

.raro-ai-dock-pending i {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
    animation: raro-ai-thinking 1.15s infinite ease-in-out;
}

.raro-ai-dock-pending i:nth-child(2) { animation-delay: .15s; }
.raro-ai-dock-pending i:nth-child(3) { animation-delay: .3s; }

@keyframes raro-ai-thinking {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.raro-ai-dock-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.dark .raro-ai-dock-composer {
    border-color: #374151;
    background: #111827;
}

.raro-ai-dock-composer textarea {
    min-height: 42px;
    max-height: 112px;
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #fff;
    padding: 10px 12px;
    color: #111827;
    font-size: 13px;
    line-height: 1.35;
}

.dark .raro-ai-dock-composer textarea {
    border-color: #4b5563;
    background: #1f2937;
    color: #f9fafb;
}

.raro-ai-dock-composer button {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: #712284;
    color: #fff;
    cursor: pointer;
}

.raro-ai-dock-composer button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.raro-ai-dock-error,
.raro-ai-dock-closed {
    margin: 10px 14px;
    padding: 9px 11px;
    border-radius: 10px;
    font-size: 12px;
}

.raro-ai-dock-error {
    background: #fef2f2;
    color: #b91c1c;
}

.raro-ai-dock-closed {
    background: #f1f5f9;
    color: #475569;
    text-align: center;
}

@media (max-width: 640px) {
    .raro-ai-dock {
        right: 12px;
        bottom: 12px;
    }

    .raro-ai-dock-panel {
        position: fixed;
        right: 10px;
        bottom: 68px;
        width: calc(100vw - 20px);
        height: min(680px, calc(100dvh - 88px));
        border-radius: 18px;
    }
}
