:root {
    --ma-ai-ink: #172033;
    --ma-ai-muted: #68728a;
    --ma-ai-line: rgba(83, 96, 131, .14);
    --ma-ai-blue: #4f68ff;
    --ma-ai-violet: #7d54ff;
    --ma-ai-surface: rgba(255, 255, 255, .94);
}

#maFloat {
    align-items: center;
    bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    position: fixed;
    right: 22px;
    z-index: 10020;
}

#maFloat .mf-btn {
    align-items: center;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 14px 34px rgba(36, 50, 94, .24), 0 3px 10px rgba(39, 50, 85, .12);
    color: #fff;
    cursor: pointer;
    display: flex;
    height: 52px;
    justify-content: center;
    position: relative;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease;
    width: 52px;
}

#maFloat .mf-btn:hover {
    box-shadow: 0 18px 40px rgba(36, 50, 94, .3), 0 4px 12px rgba(39, 50, 85, .16);
    transform: translateY(-3px);
}

#maFloat .mf-wa { background: #25d366; }
#maFloat.ma-ai-open .mf-wa {
    opacity: 0;
    pointer-events: none;
    transform: scale(.72);
}

#maFloat .mf-chat {
    background: linear-gradient(135deg, var(--ma-ai-blue), var(--ma-ai-violet));
    font-size: 18px;
    isolation: isolate;
}

#maFloat .mf-chat::before {
    background: linear-gradient(135deg, rgba(79, 104, 255, .28), rgba(125, 84, 255, .22));
    border-radius: inherit;
    content: "";
    inset: -6px;
    position: absolute;
    animation: maAiPulse 2.4s ease-out infinite;
    z-index: -1;
}

#maFloat .mf-badge {
    background: #35df9b;
    border: 2px solid #fff;
    border-radius: 50%;
    height: 11px;
    position: absolute;
    right: 1px;
    top: 1px;
    width: 11px;
}

.ma-ai-panel {
    backdrop-filter: blur(20px);
    background: var(--ma-ai-surface);
    border: 1px solid rgba(255, 255, 255, .86);
    border-radius: 24px;
    bottom: 88px;
    box-shadow: 0 30px 90px rgba(23, 32, 51, .24), 0 8px 28px rgba(48, 61, 101, .14);
    color: var(--ma-ai-ink);
    display: flex;
    flex-direction: column;
    height: min(620px, calc(100vh - 116px));
    max-height: 720px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    position: fixed;
    right: 22px;
    transform: translateY(18px) scale(.97);
    transform-origin: bottom right;
    transition: opacity .2s ease, transform .22s ease;
    width: min(410px, calc(100vw - 32px));
    z-index: 10019;
}

.ma-ai-panel[hidden] { display: none !important; }

.ma-ai-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ma-ai-panel .mc-head {
    align-items: center;
    background:
        radial-gradient(circle at 85% 10%, rgba(165, 144, 255, .45), transparent 35%),
        linear-gradient(135deg, #3e56e9, #7049e5);
    color: #fff;
    display: grid;
    gap: 11px;
    grid-template-columns: 42px 1fr 34px;
    padding: 18px 18px 17px;
}

.ma-ai-panel .av {
    align-items: center;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 14px;
    display: flex;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.ma-ai-panel .mc-identity { display: flex; flex-direction: column; gap: 3px; }
.ma-ai-panel .mc-identity b { font-size: 15px; letter-spacing: -.01em; }
.ma-ai-panel .mc-identity > span { color: rgba(255, 255, 255, .79); font-size: 11px; }
.ma-ai-panel .dot {
    background: #49efa9;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(73, 239, 169, .15);
    display: inline-block;
    height: 7px;
    margin-right: 5px;
    width: 7px;
}

.ma-ai-panel .cls {
    align-items: center;
    background: rgba(255, 255, 255, .12);
    border: 0;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.ma-ai-context {
    align-items: center;
    background: rgba(248, 249, 255, .92);
    border-bottom: 1px solid var(--ma-ai-line);
    color: var(--ma-ai-muted);
    display: flex;
    font-size: 10px;
    gap: 13px;
    padding: 9px 17px;
}

.ma-ai-context i { color: var(--ma-ai-blue); margin-right: 4px; }
.ma-ai-conversation {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}
.ma-ai-conversation[hidden],
.ma-ai-onboarding[hidden] { display: none !important; }

.ma-ai-onboarding {
    align-items: center;
    display: flex;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 25px 18px;
    text-align: center;
}
.ma-ai-welcome-icon {
    align-items: center;
    background: linear-gradient(135deg, rgba(79, 104, 255, .14), rgba(125, 84, 255, .17));
    border: 1px solid rgba(107, 87, 241, .14);
    border-radius: 18px;
    color: var(--ma-ai-violet);
    display: flex;
    flex: 0 0 54px;
    font-size: 20px;
    height: 54px;
    justify-content: center;
    width: 54px;
}
.ma-ai-kicker {
    color: var(--ma-ai-violet);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    margin: 13px 0 5px;
    text-transform: uppercase;
}
.ma-ai-onboarding h3 {
    color: var(--ma-ai-ink);
    font-size: 20px;
    letter-spacing: -.03em;
    margin: 0;
}
.ma-ai-welcome-copy {
    color: var(--ma-ai-muted);
    font-size: 11px;
    line-height: 1.55;
    margin: 8px 0 14px;
    max-width: 330px;
}
.ma-ai-profile-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 330px;
    text-align: left;
    width: 100%;
}
.ma-ai-profile-form > label:not(.ma-ai-consent) {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ma-ai-profile-form > label > span:first-child {
    color: #4d5770;
    font-size: 10px;
    font-weight: 800;
}
.ma-ai-profile-form input[type="text"],
.ma-ai-profile-form input[type="email"] {
    background: #f5f6fb;
    border: 1px solid #dfe3f0;
    border-radius: 12px;
    color: var(--ma-ai-ink);
    font: inherit;
    font-size: 12px;
    height: 42px;
    outline: 0;
    padding: 0 12px;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
    width: 100%;
}
.ma-ai-profile-form input[type="text"]:focus,
.ma-ai-profile-form input[type="email"]:focus {
    background: #fff;
    border-color: #8290f8;
    box-shadow: 0 0 0 3px rgba(79, 104, 255, .1);
}
.ma-ai-consent {
    align-items: flex-start;
    cursor: pointer;
    display: grid;
    gap: 8px;
    grid-template-columns: 16px 1fr;
    margin-top: 2px;
}
.ma-ai-consent input {
    accent-color: var(--ma-ai-blue);
    height: 15px;
    margin: 1px 0 0;
    width: 15px;
}
.ma-ai-consent > span {
    color: var(--ma-ai-muted) !important;
    font-size: 9px !important;
    font-weight: 500 !important;
    line-height: 1.45;
}
.ma-ai-consent a { color: #4b5fe6; font-weight: 800; }
.ma-ai-profile-error {
    color: #c23b55;
    display: none;
    font-size: 9px;
    line-height: 1.4;
    min-height: 13px;
}
.ma-ai-profile-error:not(:empty) { display: block; }
.ma-ai-profile-submit {
    align-items: center;
    background: linear-gradient(135deg, var(--ma-ai-blue), var(--ma-ai-violet));
    border: 0;
    border-radius: 12px;
    box-shadow: 0 9px 20px rgba(79, 104, 255, .2);
    color: #fff;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    gap: 8px;
    height: 42px;
    justify-content: center;
    margin-top: 1px;
    width: 100%;
}
.ma-ai-profile-submit:disabled { cursor: wait; opacity: .65; }
.ma-ai-profile-submit.loading i { animation: maAiSpin .8s linear infinite; }
.ma-ai-privacy-note {
    color: #929aab;
    font-size: 8.5px;
    margin: 12px 0 0;
}
.ma-ai-privacy-note i { color: #5e70eb; margin-right: 4px; }

.ma-ai-panel .mc-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 18px 16px 10px;
    scroll-behavior: smooth;
}

.ma-ai-panel .mc-body::-webkit-scrollbar { width: 6px; }
.ma-ai-panel .mc-body::-webkit-scrollbar-thumb { background: #d8dced; border-radius: 10px; }

.ma-ai-panel .mc-msg {
    animation: maAiMessage .24s ease both;
    font-size: 13px;
    line-height: 1.58;
    max-width: 88%;
}

.ma-ai-panel .mc-msg-content {
    border-radius: 17px;
    padding: 11px 13px;
    white-space: normal;
}

.ma-ai-panel .mc-bot { align-self: flex-start; }
.ma-ai-panel .mc-bot .mc-msg-content {
    background: #f1f3fb;
    border: 1px solid rgba(91, 103, 145, .08);
    border-bottom-left-radius: 6px;
    color: #283149;
}

.ma-ai-panel .mc-user { align-self: flex-end; }
.ma-ai-panel .mc-user .mc-msg-content {
    background: linear-gradient(135deg, var(--ma-ai-blue), var(--ma-ai-violet));
    border-bottom-right-radius: 6px;
    box-shadow: 0 7px 17px rgba(79, 104, 255, .2);
    color: #fff;
}

.ma-ai-panel .mc-msg a { color: #405be8; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.ma-ai-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ma-ai-sources a {
    background: #fff;
    border: 1px solid #dfe3f3;
    border-radius: 999px;
    color: #4e5b7e !important;
    font-size: 10px;
    font-weight: 700;
    max-width: 220px;
    overflow: hidden;
    padding: 5px 9px;
    text-decoration: none !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ma-ai-panel .mc-quick {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 7px 16px 9px;
    scrollbar-width: none;
}

.ma-ai-panel .mc-quick::-webkit-scrollbar { display: none; }
.ma-ai-panel .mc-quick button {
    background: #fff;
    border: 1px solid #dfe3f3;
    border-radius: 999px;
    color: #485675;
    cursor: pointer;
    flex: 0 0 auto;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    padding: 7px 10px;
    transition: border-color .18s ease, color .18s ease, transform .18s ease;
}

.ma-ai-panel .mc-quick button:hover {
    border-color: #8d9cff;
    color: var(--ma-ai-blue);
    transform: translateY(-1px);
}

.ma-ai-status {
    color: var(--ma-ai-muted);
    display: none;
    font-size: 10px;
    min-height: 15px;
    padding: 0 18px 4px;
}
.ma-ai-status.visible { display: block; }
.ma-ai-status.warning { color: #9c6300; }

.ma-ai-panel .mc-input {
    align-items: flex-end;
    background: #f6f7fc;
    border: 1px solid #e1e4f1;
    border-radius: 17px;
    display: flex;
    gap: 8px;
    margin: 0 13px 7px;
    padding: 7px 7px 7px 12px;
}

.ma-ai-panel .mc-input textarea {
    background: transparent;
    border: 0;
    color: var(--ma-ai-ink);
    flex: 1;
    font: inherit;
    font-size: 12px;
    line-height: 1.45;
    max-height: 96px;
    min-height: 34px;
    outline: 0;
    padding: 8px 0 6px;
    resize: none;
}

.ma-ai-panel .mc-input textarea::placeholder { color: #939caf; }
.ma-ai-panel .mc-input button {
    align-items: center;
    background: linear-gradient(135deg, var(--ma-ai-blue), var(--ma-ai-violet));
    border: 0;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex: 0 0 38px;
    height: 38px;
    justify-content: center;
}
.ma-ai-panel .mc-input button:disabled { cursor: wait; opacity: .55; }
#maAiWebsite { height: 0; left: -10000px; opacity: 0; position: absolute; width: 0; }

.ma-ai-disclaimer {
    color: #9199ab;
    font-size: 9px;
    margin: 0;
    padding: 0 16px 10px;
    text-align: center;
}

.ma-ai-typing {
    align-items: center;
    background: #f1f3fb;
    border-radius: 17px 17px 17px 6px;
    display: flex;
    gap: 4px;
    min-height: 36px;
    padding: 0 13px;
}
.ma-ai-typing span {
    animation: maAiDot 1.1s infinite ease-in-out;
    background: #8993b1;
    border-radius: 50%;
    height: 6px;
    width: 6px;
}
.ma-ai-typing span:nth-child(2) { animation-delay: .15s; }
.ma-ai-typing span:nth-child(3) { animation-delay: .3s; }

.sr-only {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@keyframes maAiPulse {
    0% { opacity: .8; transform: scale(.88); }
    70%, 100% { opacity: 0; transform: scale(1.28); }
}
@keyframes maAiMessage {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes maAiDot {
    0%, 65%, 100% { opacity: .35; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-3px); }
}
@keyframes maAiSpin {
    to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
    #maFloat { bottom: 15px; right: 14px; }
    #maFloat .mf-btn { height: 48px; width: 48px; }
    .ma-ai-panel {
        border-radius: 22px 22px 0 0;
        bottom: 0;
        height: min(680px, calc(100dvh - 34px));
        left: 0;
        max-height: none;
        right: 0;
        transform: translateY(22px);
        width: 100%;
    }
    .ma-ai-panel .mc-head { padding-top: max(17px, env(safe-area-inset-top)); }
    .ma-ai-onboarding { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
    .ma-ai-disclaimer { padding-bottom: max(9px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
    #maFloat .mf-chat::before,
    .ma-ai-panel .mc-msg,
    .ma-ai-typing span { animation: none !important; }
    .ma-ai-panel, #maFloat .mf-btn { transition: none !important; }
}

/* MA_AI_SUPPORT_BRIDGE_V1_20260809 */
.ma-ai-handoff {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 12px;
    align-items: center;
    margin: 0 14px 10px;
    padding: 12px;
    border: 1px solid rgba(95, 92, 197, .16);
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(243, 246, 255, .98), rgba(247, 241, 255, .98));
}
.ma-ai-handoff-copy { display: grid; gap: 2px; min-width: 0; }
.ma-ai-handoff-copy strong { color: #262b58; font-size: 11px; font-weight: 850; }
.ma-ai-handoff-copy span { color: #747a92; font-size: 9px; line-height: 1.4; }
.ma-ai-handoff-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid rgba(92, 73, 204, .17);
    border-radius: 10px;
    background: #fff;
    color: #5546b8;
    font: inherit;
    font-size: 9px;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 7px 18px rgba(55, 46, 130, .08);
}
.ma-ai-handoff-button:hover { border-color: rgba(92, 73, 204, .34); transform: translateY(-1px); }
.ma-ai-handoff-button.is-active { background: #eaf7f2; border-color: #bee8d9; color: #137257; }
.ma-ai-handoff-button:disabled { cursor: wait; opacity: .66; }
.ma-ai-handoff-status { grid-column: 1 / -1; min-height: 0; color: #6e7488; font-size: 9px; line-height: 1.4; }
.ma-ai-handoff-status:empty { display: none; }
.ma-ai-handoff-status.is-waiting { color: #9a5b00; }
.ma-ai-handoff-status.is-progress,.ma-ai-handoff-status.is-resolved { color: #147258; }
.ma-ai-handoff-status.is-error { color: #b12f43; }
.ma-ai-support-link { grid-column: 1 / -1; width: max-content; color: #5c4dc0; font-size: 9px; font-weight: 800; text-decoration: none; }
.ma-ai-support-link:hover { text-decoration: underline; }
.mc-msg.mc-admin { align-self: flex-start; max-width: 88%; }
.mc-msg.mc-admin .mc-msg-content { border: 1px solid #bde6d8; border-bottom-left-radius: 5px; background: #eaf9f4; color: #214c40; }
.ma-ai-admin-label { display: block; margin: 0 0 5px 5px; color: #20735d; font-size: 9px; font-weight: 900; }
#maAiLauncher.ma-ai-has-reply::after {
    content: "1";
    position: absolute;
    top: -5px;
    right: -4px;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 99px;
    background: #ef476f;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
}
@media (max-width: 560px) {
    .ma-ai-handoff { grid-template-columns: 1fr; }
    .ma-ai-handoff-button { width: 100%; }
}
