.nai-panel {
    --nai-brand: #609bea;
    --nai-interact: #396fae;
    --nai-bubble: #eaf3ff;
    --nai-bg: #f7faff;
    --nai-card: #fff;
    --nai-text: #253449;
    --nai-muted: #52647a;
    --nai-line: #e1eaf5;
    --nai-success: #75b79e;
    --nai-error: #e58c8c;
    position: fixed;
    z-index: 1250;
    right: max(24px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 460px;
    max-width: calc(100vw - 48px);
    height: 680px;
    max-height: calc(100vh - 48px);
    max-height: calc(var(--nai-visible-height, 100vh) - 48px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--nai-line);
    border-radius: 24px;
    background: var(--nai-bg);
    color: var(--nai-text);
    box-shadow: 0 22px 64px #203b5726, 0 4px 12px #203b570d;
    font: 14px/1.65 system-ui, -apple-system, sans-serif;
    animation: nai-open 220ms ease-out;
}
.nai-panel[hidden], .nai-panel [hidden] { display: none !important; }
.nai-panel *, .nai-panel *::before, .nai-panel *::after { box-sizing: border-box; }
.nai-panel button {
    font: inherit;
    cursor: pointer;
    transition: background-color 140ms, transform 140ms;
}
.nai-panel button:active:not(:disabled) { transform: scale(.96); }
.nai-panel button:focus-visible, .nai-panel a:focus-visible { outline: 2px solid var(--nai-interact); outline-offset: 2px; }
.nai-panel svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nai-panel-header {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: none;
    padding: 12px 14px;
    border-bottom: 1px solid var(--nai-line);
    background: var(--nai-card);
}
.nai-header-avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--nai-bubble); }
.nai-identity { flex: 1; min-width: 0; margin-left: 3px; }
.nai-identity strong, .nai-availability { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nai-identity strong { font-size: 15px; }
.nai-availability { font-size: 12px; color: var(--nai-muted); }
.nai-availability::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: var(--nai-success); }
.nai-icon-button {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 38px;
    padding: 0;
    color: var(--nai-muted);
    background: transparent;
    border: 0;
    border-radius: 10px;
}
.nai-icon-button:hover { background: var(--nai-bubble); color: var(--nai-text); }
.nai-thread { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.nai-welcome { margin: auto 0; text-align: center; }
.nai-mascot { display: block; margin: 0 auto 7px; object-fit: contain; max-width: 100%; }
.nai-welcome h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.nai-welcome p { margin: 3px 0; }
.nai-welcome small, .nai-panel-footer small { color: var(--nai-muted); font-size: 12px; }
.nai-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 17px; }
.nai-action {
    min-width: 0;
    text-align: left;
    display: grid;
    justify-items: start;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid var(--nai-line);
    border-radius: 16px;
    background: var(--nai-card);
    color: var(--nai-text);
}
.nai-action:hover { background: var(--nai-bubble); }
.nai-action svg { color: var(--nai-interact); }
.nai-action small { overflow-wrap: anywhere; }
.nai-bubble {
    position: relative;
    flex: none;
    width: fit-content;
    min-width: 0;
    max-width: 85%;
    padding: 9px 12px;
    overflow-wrap: anywhere;
    border-radius: 16px 16px 16px 5px;
    background: var(--nai-bubble);
    animation: nai-open 150ms ease-out;
}
.nai-bubble.assistant { margin-left: 37px; align-self: flex-start; max-width: min(85%, calc(100% - 37px)); }
.nai-bubble.assistant::before, .nai-bubble.user::after {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--nai-line);
    background: var(--nai-card) url('/ai-shopping/assistant-avatar.jpeg') center / cover no-repeat;
}
.nai-bubble.assistant::before { left: -37px; }
.nai-bubble.user {
    margin-right: 37px;
    max-width: min(85%, calc(100% - 37px));
    align-self: flex-end;
    border-radius: 16px 16px 5px 16px;
    background: #dceafe;
    white-space: pre-wrap;
}
.nai-bubble.user::after {
    right: -37px;
    background-image: var(--nuaa-qq-avatar, none), url('/ai-shopping/guest-avatar.jpeg');
}
.nai-bubble p, .nai-bubble ol, .nai-bubble ul, .nai-bubble pre { margin: 0 0 5px; }
.nai-bubble :last-child { margin-bottom: 0; }
.nai-bubble ol, .nai-bubble ul { padding-left: 20px; }
.nai-bubble a { color: #295b99; text-decoration: underline; }
.nai-bubble code { border-radius: 4px; background: #fff9; padding: 0 3px; }
.nai-bubble pre { max-width: 100%; overflow: auto; padding: 6px; background: #fff9; border-radius: 8px; }
.nai-product-card, .nai-error { flex: none; min-width: 0; padding: 12px; border: 1px solid var(--nai-line); border-radius: 16px; background: var(--nai-card); overflow-wrap: anywhere; }
.nai-product-summary { display: flex; gap: 10px; align-items: flex-start; }
.nai-product-summary > div { min-width: 0; }
.nai-product-summary img { width: 58px; height: 58px; flex: 0 0 58px; object-fit: contain; border: 1px solid var(--nai-line); border-radius: 10px; }
.nai-product-summary h3, .nai-product-card p, .nai-error p { margin: 0 0 5px; }
.nai-product-summary strong { color: var(--nai-interact); }
.nai-product-summary small { margin-left: 8px; }
.nai-product-card details { margin: 5px 0; }
.nai-product-card button, .nai-error button, .nai-latest {
    color: #295b99;
    background: var(--nai-card);
    border: 1px solid var(--nai-line);
    border-radius: 12px;
    padding: 4px 10px;
}
.nai-error { border-color: var(--nai-error); }
.nai-thinking { color: var(--nai-muted); display: flex; align-items: center; gap: 6px; }
.nai-dots { display: inline-flex; align-items: center; gap: 3px; }
.nai-dots i { width: 5px; height: 5px; background: var(--nai-brand); border-radius: 50%; animation: nai-pulse 1s ease-in-out infinite; }
.nai-dots i:nth-child(2) { animation-delay: 120ms; }
.nai-dots i:nth-child(3) { animation-delay: 240ms; }
.nai-latest { align-self: center; flex: none; margin: 0 0 6px; }
.nai-panel-footer { flex: none; padding: 9px 13px 10px; text-align: center; background: var(--nai-bg); }
.nai-compose { display: flex; align-items: flex-end; gap: 6px; padding: 5px; background: var(--nai-card); border: 1px solid var(--nai-line); border-radius: 23px; }
.nai-compose:focus-within { border-color: var(--nai-brand); }
.nai-compose textarea {
    display: block;
    flex: 1;
    min-width: 0;
    max-height: 112px;
    min-height: 36px;
    padding: 7px 0 7px 9px;
    resize: none;
    overflow-y: auto;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--nai-text);
    font: inherit;
}
.nai-send { flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--nai-interact); color: #fff; }
.nai-send:disabled { cursor: default; color: #5b7796; background: #e5edf7; }
.nai-panel-footer small { display: block; margin-top: 4px; }
body #nuaa-helpdesk-launch, body .nai-launch:not([hidden]) {
    left: auto;
    right: max(24px, env(safe-area-inset-right));
    bottom: 188px;
    width: 58px !important;
    height: 58px !important;
    border: 1px solid #e1eaf5 !important;
    border-radius: 50% !important;
    background: #eaf3ff url('/ai-shopping/welcome-xiaoba.png') center / 92% no-repeat !important;
    box-shadow: 0 6px 20px #203b5726 !important;
    transition: transform 140ms;
}
body #nuaa-helpdesk-launch:hover, body .nai-launch:not([hidden]):hover { transform: scale(1.04); }
body #nuaa-helpdesk-launch:focus-visible, body .nai-launch:focus-visible { outline: 2px solid #396fae; outline-offset: 3px; }
@keyframes nai-open { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes nai-pulse { 50% { transform: translateY(-3px); opacity: .55; } }
@media (max-width: 600px) {
    .nai-panel {
        inset: auto 0 var(--nai-keyboard, 0px);
        width: 100%;
        max-width: none;
        height: 100vh;
        height: var(--nai-visible-height, 100dvh);
        max-height: none;
        border: 0;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .nai-panel-header { gap: 4px; padding: 8px 10px; }
    .nai-thread { padding: 12px; }
    .nai-panel-footer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    .nai-compose textarea { font-size: 16px; }
    body #nuaa-helpdesk-launch, body .nai-launch:not([hidden]) { right: max(14px, env(safe-area-inset-right)); bottom: calc(176px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
    .nai-panel, .nai-panel *, body #nuaa-helpdesk-launch, body .nai-launch { animation: none !important; transition: none !important; }
}

.nai-panel.nai-closing { pointer-events: none; animation: nai-close 170ms ease-in forwards; }
@keyframes nai-close { to { opacity: 0; transform: translateY(5px); } }