


.mirage-chatbot,
.mirage-chatbot__launcher {
    
    --chatbot-primary: var(--primary, #2563eb);
    --chatbot-primary-rgb: var(--primary-rgb, 37, 99, 235);
    --chatbot-primary-dark: var(--primary-dark, #1d4ed8);
    
    
    --chatbot-bg: var(--bg-900, #0f172a);
    --chatbot-surface: #1e293b;
    --chatbot-surface-2: #334155;
    --chatbot-surface-3: #475569;
    
    
    --chatbot-fg: var(--fg, #f8fafc);
    --chatbot-muted: var(--muted, #94a3b8);
    --chatbot-on-surface: #f1f5f9;
    --chatbot-on-surface-2: #cbd5e1;
    
    
    --chatbot-border: rgba(255, 255, 255, 0.1);
    --chatbot-border-2: rgba(255, 255, 255, 0.15);
    
    
    --chatbot-online: #22c55e;
    --chatbot-error: #ef4444;
    
    
    --chatbot-radius: 1rem;
    --chatbot-radius-sm: 0.5rem;
    --chatbot-radius-lg: 1.25rem;
    --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    
    
    --chatbot-font: Arial, 'Helvetica Neue', Helvetica, 'Segoe UI', sans-serif;
}


@media (prefers-color-scheme: light) {
    .mirage-chatbot,
    .mirage-chatbot__launcher {
        --chatbot-bg: #f8fafc;
        --chatbot-surface: #ffffff;
        --chatbot-surface-2: #f1f5f9;
        --chatbot-surface-3: #e2e8f0;
        --chatbot-fg: #0f172a;
        --chatbot-muted: #64748b;
        --chatbot-on-surface: #1e293b;
        --chatbot-on-surface-2: #475569;
        --chatbot-border: rgba(15, 23, 42, 0.1);
        --chatbot-border-2: rgba(15, 23, 42, 0.15);
        --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    }
}


[data-theme="light"] .mirage-chatbot,
[data-theme="light"] .mirage-chatbot__launcher {
    --chatbot-bg: #f8fafc;
    --chatbot-surface: #ffffff;
    --chatbot-surface-2: #f1f5f9;
    --chatbot-surface-3: #e2e8f0;
    --chatbot-fg: #0f172a;
    --chatbot-muted: #64748b;
    --chatbot-on-surface: #1e293b;
    --chatbot-on-surface-2: #475569;
    --chatbot-border: rgba(15, 23, 42, 0.1);
    --chatbot-border-2: rgba(15, 23, 42, 0.15);
    --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .mirage-chatbot,
[data-theme="dark"] .mirage-chatbot__launcher {
    --chatbot-bg: #0f172a;
    --chatbot-surface: #1e293b;
    --chatbot-surface-2: #334155;
    --chatbot-surface-3: #475569;
    --chatbot-fg: #f8fafc;
    --chatbot-muted: #94a3b8;
    --chatbot-on-surface: #f1f5f9;
    --chatbot-on-surface-2: #cbd5e1;
    --chatbot-border: rgba(255, 255, 255, 0.1);
    --chatbot-border-2: rgba(255, 255, 255, 0.15);
    --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}


.mirage-chatbot {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    width: 380px;
    max-width: calc(100vw - 3rem);
    height: 600px;
    max-height: calc(100vh - 8rem);
    max-height: calc(100dvh - 8rem); /* 2026-08-29: keyboard-aware where supported */
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius-lg);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: var(--chatbot-font);
    border: 1px solid var(--chatbot-border);
}


.mirage-chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--chatbot-surface);
    border-bottom: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.mirage-chatbot__header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mirage-chatbot__avatar-wrap {
    position: relative;
}

.mirage-chatbot__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.mirage-chatbot__status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--chatbot-online);
    border: 2px solid var(--chatbot-surface);
    border-radius: 50%;
}

.mirage-chatbot__header-info {
    display: flex;
    flex-direction: column;
}

.mirage-chatbot__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--chatbot-fg);
    margin: 0;
    line-height: 1.2;
}

.mirage-chatbot__subtitle {
    font-size: 0.75rem;
    color: var(--chatbot-muted);
}

.mirage-chatbot__icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--chatbot-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chatbot-muted);
    transition: background 0.15s, color 0.15s;
}

.mirage-chatbot__icon-btn:hover {
    background: var(--chatbot-surface-2);
    color: var(--chatbot-fg);
}

.mirage-chatbot__icon-btn:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 2px;
}


.mirage-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.mirage-chatbot__messages::-webkit-scrollbar {
    width: 6px;
}

.mirage-chatbot__messages::-webkit-scrollbar-track {
    background: transparent;
}

.mirage-chatbot__messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border-2);
    border-radius: 3px;
}

.mirage-chatbot__messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-muted);
}


.mirage-chatbot__message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: chatbot-message-in 0.2s ease-out;
}

@keyframes chatbot-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mirage-chatbot__message--user {
    align-self: flex-end;
}

.mirage-chatbot__message--assistant {
    align-self: flex-start;
}


.mirage-chatbot__message--loading {
    display: flex;
}

.mirage-chatbot__bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--chatbot-radius);
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}


.mirage-chatbot__bubble--compact {
    padding: 0.4rem 0.7rem;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.mirage-chatbot__message--user .mirage-chatbot__bubble {
    background: var(--chatbot-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.mirage-chatbot__message--assistant .mirage-chatbot__bubble {
    background: var(--chatbot-surface);
    color: var(--chatbot-on-surface);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chatbot-border);
}

.mirage-chatbot__bubble p {
    margin: 0 0 0.5rem;
}

.mirage-chatbot__bubble p:last-child {
    margin-bottom: 0;
}

.mirage-chatbot__bubble strong {
    font-weight: 600;
}

.mirage-chatbot__bubble em {
    font-style: italic;
}

.mirage-chatbot__bubble a {
    color: var(--chatbot-primary);
    text-decoration: underline;
}

.mirage-chatbot__bubble a:hover {
    color: var(--chatbot-primary-dark);
}

.mirage-chatbot__msg-meta {
    font-size: 0.625rem;
    color: var(--chatbot-muted);
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.mirage-chatbot__message--user .mirage-chatbot__msg-meta {
    text-align: right;
}


.mirage-chatbot__typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: var(--chatbot-surface);
    border-radius: var(--chatbot-radius);
    border: 1px solid var(--chatbot-border);
    width: fit-content;
}

.mirage-chatbot__typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-muted);
    border-radius: 50%;
    animation: chatbot-typing 1.4s infinite ease-in-out both;
}

.mirage-chatbot__typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.mirage-chatbot__typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes chatbot-typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}


.mirage-chatbot__input-area {
    padding: 0.75rem;
    background: var(--chatbot-surface);
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.mirage-chatbot__quick-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.mirage-chatbot__quick-btn {
    width: 32px;
    height: 32px;
}

.mirage-chatbot__quick-divider {
    flex: 1;
}

.mirage-chatbot__quick-phrase {
    font-size: 0.75rem;
    color: var(--chatbot-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--chatbot-radius-sm);
    transition: background 0.15s;
}

.mirage-chatbot__quick-phrase:hover {
    background: var(--chatbot-surface-2);
}

.mirage-chatbot__form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mirage-chatbot__input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--chatbot-surface-2);
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    padding: 0.5rem;
    transition: border-color 0.15s;
}

.mirage-chatbot__input-wrap:focus-within {
    border-color: var(--chatbot-primary);
}

.mirage-chatbot__input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--chatbot-fg);
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    padding: 0.25rem;
    line-height: 1.5;
}

.mirage-chatbot__input::placeholder {
    color: var(--chatbot-muted);
}

.mirage-chatbot__input:focus {
    outline: none;
}

.mirage-chatbot__send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--chatbot-primary);
    border-radius: var(--chatbot-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

.mirage-chatbot__send-btn:hover {
    background: var(--chatbot-primary-dark);
}

.mirage-chatbot__send-btn:active {
    transform: scale(0.95);
}

.mirage-chatbot__send-btn:disabled {
    background: var(--chatbot-surface-3);
    cursor: not-allowed;
}


.mirage-chatbot__qp-popup {
    position: absolute;
    bottom: 100%;
    left: 0.75rem;
    right: 0.75rem;
    background: var(--chatbot-surface);
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    margin-bottom: 0.5rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.mirage-chatbot__qp-popup.active {
    display: block;
}

.mirage-chatbot__qp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--chatbot-border);
    position: sticky;
    top: 0;
    background: var(--chatbot-surface);
}

.mirage-chatbot__qp-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--chatbot-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mirage-chatbot__qp-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--chatbot-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: var(--chatbot-radius-sm);
}

.mirage-chatbot__qp-close:hover {
    background: var(--chatbot-surface-2);
    color: var(--chatbot-fg);
}

.mirage-chatbot__qp-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mirage-chatbot__qp-item {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--chatbot-radius-sm);
    color: var(--chatbot-on-surface);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.mirage-chatbot__qp-item:hover {
    background: var(--chatbot-surface-2);
}

.mirage-chatbot__qp-item:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: -2px;
}


.mirage-chatbot__launcher {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(var(--chatbot-primary-rgb), 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background 0.15s;
    z-index: 9998;
}


body.has-pwa-install-banner .mirage-chatbot__launcher {
    translate: 0 calc(-1 * var(--pwa-install-offset, 0px));
}

.mirage-chatbot__launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(var(--chatbot-primary-rgb), 0.5);
    background: var(--chatbot-primary-dark);
}

.mirage-chatbot__launcher:active {
    transform: scale(0.95);
}

.mirage-chatbot__launcher:focus {
    outline: 2px solid var(--chatbot-primary);
    outline-offset: 4px;
}

.mirage-chatbot__launcher.open {
    display: none;
}

.mirage-chatbot__launcher.hidden {
    display: none !important;
}


@media (max-width: 480px) {
    .mirage-chatbot {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        height: 100dvh;     /* 2026-08-29: track the visual viewport so the input row */
        max-height: 100dvh; /* stays above the on-screen keyboard */
        border-radius: 0;
    }
    
    .mirage-chatbot__launcher {
        bottom: 1rem;
        right: 1rem;
    }
}


@media (prefers-reduced-motion: reduce) {
    .mirage-chatbot__message,
    .mirage-chatbot__typing-indicator span,
    .mirage-chatbot__send-btn,
    .mirage-chatbot__launcher {
        animation: none;
        transition: none;
    }
}

/* 2026-08-29: a focused input under 16px makes mobile Safari zoom the whole page —
   the "type in the chat and the view breaks" defect. Touch devices only; desktop keeps 14px. */
@media (pointer: coarse), (max-width: 767.98px) {
    .mirage-chatbot__input {
        font-size: 1rem;
    }
}


@media (prefers-contrast: high) {
    .mirage-chatbot__bubble {
        border-width: 2px;
    }
    
    .mirage-chatbot__send-btn {
        border: 2px solid currentColor;
    }
}


.mirage-chatbot__disclosure {
  margin: 0 0 6px;
  padding: 6px 10px 0;
  font-size: 0.72rem;
  line-height: 1.45;
  opacity: 0.75;
}
.mirage-chatbot__disclosure a {
  color: inherit;
  text-decoration: underline;
}
@media (prefers-reduced-motion: reduce) {
  .mirage-chatbot__disclosure { transition: none; }
}
