/* ===== AILUNA chat widget ===== */

#ailunaChatRoot {
    --ac-navy: #0b1a3a;
    --ac-navy-2: #16204a;
    --ac-rose: #eab39d;
    --ac-rust: #b0664c;
    --ac-pearl: #f6f1ee;
    --ac-ink: #2b3252;
    --ac-muted: #6b7088;
    --ac-grad: linear-gradient(135deg, #f6c3cf 0%, #c9d4ff 100%);
    font-family: 'Nexa', sans-serif;
}

/* Keep the legacy scroll-to-top button clear of the badge. */
#scrollup {
    bottom: 96px !important;
    right: 30px !important;
}

/* ----- Floating badge ----- */
.ac-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1090;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 0;
    height: 60px;
    min-width: 60px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--ac-navy);
    color: #fff;
    box-shadow: 0 14px 34px -10px rgba(11, 26, 58, .65), 0 0 0 1px rgba(255, 255, 255, .18) inset;
    cursor: pointer;
    transition: transform .25s ease, box-shadow .25s ease;
}

.ac-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 38px -10px rgba(11, 26, 58, .7), 0 0 0 1px rgba(255, 255, 255, .28) inset;
}

.ac-fab:focus-visible {
    outline: 3px solid var(--ac-rose);
    outline-offset: 3px;
}

.ac-fab img {
    position: relative;
    z-index: 1;
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(160deg, #f6e6e9, #dfe6ff);
    border: 2px solid rgba(255, 255, 255, .85);
    box-sizing: border-box;
}

.ac-fab-ring {
    position: absolute;
    right: 0;
    top: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(234, 179, 157, .55);
    animation: ac-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

.ac-fab-dot {
    position: absolute;
    right: 3px;
    top: 3px;
    z-index: 2;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid var(--ac-navy);
}

.ac-fab-label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
    opacity: 0;
    transition: max-width .35s ease, opacity .25s ease, padding .35s ease;
}

.ac-fab:hover .ac-fab-label,
.ac-fab.is-expanded .ac-fab-label {
    max-width: 150px;
    padding-left: 20px;
    padding-right: 10px;
    opacity: 1;
}

.ac-fab.is-hidden {
    display: none;
}

@keyframes ac-pulse {
    0% { box-shadow: 0 0 0 0 rgba(234, 179, 157, .55); }
    70% { box-shadow: 0 0 0 14px rgba(234, 179, 157, 0); }
    100% { box-shadow: 0 0 0 0 rgba(234, 179, 157, 0); }
}

/* ----- Panel ----- */
.ac-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: 392px;
    max-width: calc(100vw - 32px);
    height: min(620px, calc(100vh - 48px));
    border-radius: 22px;
    background: var(--ac-pearl);
    box-shadow: 0 30px 70px -18px rgba(5, 23, 52, .55), 0 0 0 1px rgba(22, 32, 74, .08);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    pointer-events: none;
    visibility: hidden;
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.ac-panel.is-open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    visibility: visible;
    transition: opacity .22s ease, transform .22s ease;
}

.ac-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--ac-navy) 0%, var(--ac-navy-2) 100%);
    color: #fff;
}

.ac-head img {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(160deg, #f6e6e9, #dfe6ff);
    border: 2px solid rgba(255, 255, 255, .8);
}

.ac-head-text {
    flex: 1;
    min-width: 0;
}

.ac-title {
    margin: 0;
    font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: .02em;
    color: #fff;
}

.ac-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 11.5px;
    line-height: 1.2;
    color: rgba(255, 255, 255, .72);
}

.ac-sub::before {
    content: '';
    flex: 0 0 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
}

.ac-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
    transition: background .2s ease;
}

.ac-icon-btn:hover {
    background: rgba(255, 255, 255, .22);
}

.ac-icon-btn:focus-visible {
    outline: 2px solid var(--ac-rose);
    outline-offset: 2px;
}

.ac-icon-btn svg {
    width: 17px;
    height: 17px;
}

/* ----- Messages ----- */
.ac-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.ac-msg {
    display: flex;
    margin-bottom: 12px;
}

.ac-msg.is-user {
    justify-content: flex-end;
}

.ac-bubble {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 18px 18px 18px 6px;
    background: #fff;
    box-shadow: 0 6px 16px -10px rgba(22, 32, 74, .35);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
    color: var(--ac-ink);
    overflow-wrap: anywhere;
}

.ac-msg.is-user .ac-bubble {
    border-radius: 18px 18px 6px 18px;
    background: var(--ac-navy-2);
    color: #fff;
    box-shadow: none;
}

.ac-msg.is-error .ac-bubble {
    background: #fff4f1;
    color: #8a3b27;
    border: 1px solid #f2c9bd;
}

/* The site's global p/li/a rules are larger than a chat bubble; pin the sizes explicitly. */
#ailunaChatRoot .ac-bubble,
#ailunaChatRoot .ac-bubble p,
#ailunaChatRoot .ac-bubble li,
#ailunaChatRoot .ac-bubble a,
#ailunaChatRoot .ac-bubble strong {
    font-family: 'Nexa', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    letter-spacing: 0;
}

#ailunaChatRoot .ac-bubble,
#ailunaChatRoot .ac-bubble p,
#ailunaChatRoot .ac-bubble li {
    font-weight: 400;
}

.ac-bubble p {
    margin: 0 0 8px;
}

.ac-bubble p:last-child {
    margin-bottom: 0;
}

.ac-bubble ul {
    margin: 4px 0 8px;
    padding-left: 18px;
    list-style: disc;
}

.ac-bubble li {
    margin-bottom: 3px;
}

.ac-bubble strong {
    font-weight: 700;
    color: inherit;
}

.ac-bubble a {
    color: var(--ac-rust);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ac-msg.is-user .ac-bubble a {
    color: var(--ac-rose);
}

.ac-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(22, 32, 74, .1);
}

.ac-links a {
    display: inline-block;
    padding: 4px 11px;
    border: 1px solid rgba(22, 32, 74, .2);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    text-decoration: none;
    color: var(--ac-navy-2);
    transition: background .2s ease, color .2s ease;
}

.ac-links a:hover {
    background: var(--ac-navy-2);
    color: #fff;
}

.ac-typing .ac-bubble {
    display: flex;
    gap: 5px;
    padding: 14px 16px;
}

.ac-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ac-muted);
    animation: ac-bounce 1.2s ease-in-out infinite;
}

.ac-typing i:nth-child(2) { animation-delay: .15s; }
.ac-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes ac-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.ac-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 2px 0 10px;
}

.ac-quick button {
    padding: 7px 13px;
    border: 1px solid rgba(176, 102, 76, .45);
    border-radius: 999px;
    background: #fff;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ac-rust);
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.ac-quick button:hover {
    background: var(--ac-rust);
    border-color: var(--ac-rust);
    color: #fff;
}

/* ----- Composer ----- */
.ac-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 6px;
    background: var(--ac-pearl);
}

.ac-input {
    flex: 1;
    min-height: 44px;
    max-height: 110px;
    padding: 11px 15px;
    border: 1px solid rgba(22, 32, 74, .16);
    border-radius: 22px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.4;
    color: var(--ac-ink);
    resize: none;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.ac-input:focus {
    border-color: var(--ac-rose);
    box-shadow: 0 0 0 3px rgba(234, 179, 157, .3);
}

.ac-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    line-height: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ac-grad);
    color: var(--ac-navy-2);
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
}

.ac-send:hover:not(:disabled) {
    transform: scale(1.06);
}

.ac-send:disabled {
    opacity: .45;
    cursor: default;
}

.ac-send svg {
    display: block;
    width: 19px;
    height: 19px;
}

.ac-note {
    padding: 0 16px 12px;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--ac-muted);
    background: var(--ac-pearl);
}

.ac-note a {
    color: var(--ac-rust);
    font-weight: 700;
}

/* ----- Mobile: badge shrinks, panel becomes a bottom sheet ----- */
@media (max-width: 640px) {
    #scrollup {
        bottom: 84px !important;
        right: 19px !important;
    }

    .ac-fab {
        right: 16px;
        bottom: 16px;
        height: 54px;
        min-width: 54px;
    }

    .ac-fab img,
    .ac-fab-ring {
        flex-basis: 54px;
        width: 54px;
        height: 54px;
    }

    .ac-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: min(86vh, 640px);
        height: min(86dvh, 640px);
        border-radius: 22px 22px 0 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .ac-input {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ac-fab-ring,
    .ac-typing i {
        animation: none;
    }

    .ac-panel,
    .ac-fab-label {
        transition: none;
    }
}
