/* Native Newstyle AI chat — public storefront only.
   Variables live on :root because the launcher sits in .site-fab-stack, outside #ns-chat-root. */
:root {
    --ns-chat-accent: #0a84ff;
    --ns-chat-accent-hover: #066dd1;
    --ns-chat-accent-active: #0458ab;
    --ns-chat-accent-soft: #e8f2ff;
    --ns-chat-surface: #ffffff;
    --ns-chat-surface-soft: rgba(255, 255, 255, 0.78);
    --ns-chat-page: #f3f7fb;
    --ns-chat-border: rgba(148, 163, 184, 0.18);
    --ns-chat-text: #0f172a;
    --ns-chat-muted: #64748b;
    --ns-chat-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
    --ns-chat-z: 2147483000;
}

.ns-chat .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ns-chat__launcher {
    inline-size: var(--fab-size, 56px);
    block-size: var(--fab-size, 56px);
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #1695ff 0%, var(--ns-chat-accent) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(10, 132, 255, 0.34);
    z-index: var(--ns-chat-z);
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ns-chat__launcher::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.22);
    pointer-events: none;
}

.ns-chat__launcher:hover,
.ns-chat__launcher:focus-visible {
    background: linear-gradient(180deg, #35a2ff 0%, var(--ns-chat-accent-hover) 100%);
    color: #fff;
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 18px 34px rgba(10, 132, 255, 0.38);
    outline: 3px solid rgba(10, 132, 255, 0.18);
    outline-offset: 3px;
}

.site-fab-stack .ns-chat__launcher {
    position: relative !important;
    inset: auto !important;
    margin: 0 !important;
    flex-shrink: 0;
}

.ns-chat__launcher[aria-expanded="true"] {
    background: linear-gradient(180deg, #0a84ff 0%, var(--ns-chat-accent-active) 100%);
}

.ns-chat__panel {
    position: fixed;
    right: var(--fab-edge-x, 24px);
    inset-block-end: calc(var(--fab-edge-x, 24px) + (3 * var(--fab-size, 56px)) + (2 * var(--fab-gap, 12px)) + 12px);
    inline-size: min(408px, calc(100vw - 32px));
    block-size: min(640px, calc(100dvh - var(--fab-edge-x, 24px) - (3 * var(--fab-size, 56px)) - (2 * var(--fab-gap, 12px)) - 24px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.52), transparent 38%),
        linear-gradient(180deg, #f9fbff 0%, var(--ns-chat-page) 100%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--ns-chat-shadow);
    overflow: hidden;
    z-index: calc(var(--ns-chat-z) + 1);
    color: var(--ns-chat-text);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.ns-chat__panel[hidden] {
    display: none !important;
}

.ns-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 16px;
    background: linear-gradient(180deg, rgba(10, 132, 255, 0.98) 0%, rgba(7, 96, 197, 0.98) 100%);
    color: #fff;
}

.ns-chat__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-inline-size: 0;
}

.ns-chat__avatar {
    inline-size: 42px;
    block-size: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ns-chat__avatar svg {
    inline-size: 42px;
    block-size: 42px;
    display: block;
}

.ns-chat__identity-copy {
    min-inline-size: 0;
}

.ns-chat__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.ns-chat__subtitle {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.84);
}

.ns-chat__header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ns-chat__icon-btn {
    inline-size: 38px;
    block-size: 38px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.ns-chat__icon-btn:hover,
.ns-chat__icon-btn:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    outline: 2px solid rgba(255, 255, 255, 0.34);
    outline-offset: 2px;
}

.ns-chat__messages {
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}

.ns-chat__messages::-webkit-scrollbar {
    width: 8px;
}

.ns-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.28);
    border-radius: 999px;
}

.ns-chat__welcome {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.74) 100%);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 22px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.ns-chat__welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    inline-size: fit-content;
    max-inline-size: 100%;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--ns-chat-accent-soft);
    color: var(--ns-chat-accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.ns-chat__welcome-badge-icon {
    inline-size: 18px;
    block-size: 18px;
    display: inline-flex;
}

.ns-chat__welcome-badge-icon svg {
    inline-size: 100%;
    block-size: 100%;
}

.ns-chat__welcome-title {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--ns-chat-text);
}

.ns-chat__welcome-body {
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.75;
    color: var(--ns-chat-muted);
}

.ns-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ns-chat__chip {
    border: 1px solid rgba(10, 132, 255, 0.14);
    background: rgba(255, 255, 255, 0.88);
    color: var(--ns-chat-text);
    border-radius: 999px;
    padding: 10px 14px;
    font: inherit;
    font-size: 0.86rem;
    line-height: 1.2;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ns-chat__chip:hover,
.ns-chat__chip:focus-visible {
    background: var(--ns-chat-accent-soft);
    color: var(--ns-chat-accent-hover);
    border-color: rgba(10, 132, 255, 0.26);
    transform: translateY(-1px);
    outline: none;
}

.ns-chat__bubble {
    max-inline-size: min(86%, 310px);
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 0.94rem;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ns-chat__bubble--welcome {
    margin-block-start: -4px;
}

.ns-chat__bubble--assistant {
    align-self: flex-start;
    background: var(--ns-chat-surface-soft);
    color: var(--ns-chat-text);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-end-start-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.ns-chat__bubble--user {
    align-self: flex-end;
    background: linear-gradient(180deg, #1490ff 0%, var(--ns-chat-accent) 100%);
    color: #fff;
    border-end-end-radius: 8px;
    box-shadow: 0 12px 24px rgba(10, 132, 255, 0.18);
}

.ns-chat__typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 18px;
    border-end-start-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.ns-chat__typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ns-chat__typing-dots span {
    inline-size: 7px;
    block-size: 7px;
    border-radius: 50%;
    background: rgba(10, 132, 255, 0.65);
    animation: ns-chat-typing 1s infinite ease-in-out;
}

.ns-chat__typing-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.ns-chat__typing-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes ns-chat-typing {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.42;
    }
    40% {
        transform: translateY(-2px);
        opacity: 1;
    }
}

.ns-chat__status {
    min-block-size: 1.2rem;
    margin: 0 18px 6px;
    font-size: 0.8rem;
    color: #b42318;
}

.ns-chat__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    padding: 14px 18px 18px;
    background: rgba(255, 255, 255, 0.78);
    border-block-start: 1px solid rgba(148, 163, 184, 0.14);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ns-chat__input {
    min-block-size: 52px;
    max-block-size: 120px;
    inline-size: 100%;
    resize: none;
    border: 1px solid transparent;
    border-radius: 18px;
    padding: 14px 16px;
    font: inherit;
    line-height: 1.5;
    background: rgba(241, 245, 249, 0.92);
    color: var(--ns-chat-text);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.ns-chat__input::placeholder {
    color: #94a3b8;
}

.ns-chat__input:focus-visible {
    outline: none;
    border-color: rgba(10, 132, 255, 0.34);
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.14);
    background: #fff;
}

.ns-chat__input:disabled {
    opacity: 0.78;
}

.ns-chat__send {
    inline-size: 52px;
    block-size: 52px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(180deg, #1490ff 0%, var(--ns-chat-accent) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(10, 132, 255, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.ns-chat__send:hover:not(:disabled),
.ns-chat__send:focus-visible {
    background: linear-gradient(180deg, #35a2ff 0%, var(--ns-chat-accent-hover) 100%);
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(10, 132, 255, 0.22);
    outline: none;
}

.ns-chat__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.ns-chat__retry {
    margin: 0 18px 18px;
    inline-size: fit-content;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ns-chat-accent-hover);
    padding: 10px 14px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(10, 132, 255, 0.14);
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.ns-chat__retry:hover,
.ns-chat__retry:focus-visible {
    background: var(--ns-chat-accent-soft);
    border-color: rgba(10, 132, 255, 0.24);
    transform: translateY(-1px);
    outline: none;
}

@media (max-width: 991px) {
    .ns-chat__panel {
        inline-size: min(400px, calc(100vw - 20px));
        block-size: min(620px, calc(100dvh - var(--fab-edge-x, 24px) - (3 * var(--fab-size, 56px)) - (2 * var(--fab-gap, 12px)) - 20px));
    }
}

@media (max-width: 640px) {
    .ns-chat__launcher {
        inline-size: 52px;
        block-size: 52px;
        font-size: 1.15rem;
    }

    .ns-chat__panel {
        inset-inline: 8px;
        inset-block-end: calc(env(safe-area-inset-bottom, 0px) + 8px);
        inline-size: auto;
        block-size: min(78dvh, 720px);
        border-radius: 24px;
    }

    .ns-chat__header,
    .ns-chat__messages,
    .ns-chat__form {
        padding-inline: 14px;
    }

    .ns-chat__header {
        padding-block: 16px 14px;
    }

    .ns-chat__messages {
        padding-block: 14px;
    }

    .ns-chat__form {
        padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    .ns-chat__input {
        min-block-size: 48px;
        padding: 12px 14px;
    }

    .ns-chat__send {
        inline-size: 48px;
        block-size: 48px;
        border-radius: 14px;
    }

    .ns-chat__retry,
    .ns-chat__status {
        margin-inline: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ns-chat__launcher,
    .ns-chat__icon-btn,
    .ns-chat__chip,
    .ns-chat__send,
    .ns-chat__retry,
    .ns-chat__typing-dots span {
        animation: none !important;
        transition: none !important;
    }
}
