:root {
    --ai-primary: #5756d6;
    --ai-primary-hover: #4645bd;
    --ai-bg: #ffffff;
    --ai-surface: #f7f7f8;
    --ai-border: #e7e7eb;
    --ai-text: #202123;
    --ai-muted: #6f7077;
    --ai-shadow: 0 20px 60px rgba(20, 20, 35, .22);
}

.ai-assistant { max-width: 980px; margin: 8px auto 36px; color: var(--ai-text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.ai-assistant__intro { padding: 28px; border-radius: 18px 18px 0 0; background: #202123; color: #fff; }
.ai-assistant__eyebrow { display: block; margin-bottom: 8px; color: #aaa9ee; font-size: 11px; font-weight: 700; letter-spacing: .13em; }
.ai-assistant h1 { margin: 0 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -.035em; }
.ai-assistant__intro p { margin: 0; color: #c8c8ce; font-size: 15px; }
.ai-assistant__open-hint { padding: 30px; margin: 0; border: 1px solid var(--ai-border); border-radius: 0 0 18px 18px; background: #fff; }

.ai-assistant-launcher { position: fixed; right: 26px; bottom: 25px; z-index: 1050; display: flex; gap: 9px; align-items: center; border: 0; border-radius: 999px; padding: 13px 18px; background: var(--ai-primary); color: #fff; font: 700 14px/1.2 Inter, ui-sans-serif, system-ui, sans-serif; box-shadow: 0 10px 30px rgba(87, 86, 214, .35); transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.ai-assistant-launcher:hover, .ai-assistant-launcher:focus { color: #fff; background: var(--ai-primary-hover); transform: translateY(-2px); box-shadow: 0 13px 36px rgba(87, 86, 214, .4); outline: 0; }
.ai-assistant-launcher__icon { display: grid; width: 21px; height: 21px; place-items: center; }
.ai-assistant-launcher__icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ai-assistant-modal { position: fixed; z-index: 1060; inset: 0; display: flex; justify-content: flex-end; visibility: hidden; pointer-events: none; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.ai-assistant-modal--open { visibility: visible; pointer-events: auto; }
.ai-assistant-modal__backdrop { position: absolute; inset: 0; background: rgba(16, 16, 24, 0); transition: background .22s ease; }
.ai-assistant-modal--open .ai-assistant-modal__backdrop { background: rgba(16, 16, 24, .28); }
.ai-assistant-modal__dialog { position: relative; display: flex; flex-direction: column; width: min(620px, 100%); height: 100vh; overflow: hidden; border-left: 1px solid rgba(0, 0, 0, .08); background: var(--ai-bg); box-shadow: var(--ai-shadow); transform: translateX(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.ai-assistant-modal--open .ai-assistant-modal__dialog { transform: translateX(0); }
.ai-assistant-modal__header { display: flex; min-height: 68px; justify-content: space-between; align-items: center; padding: 13px 16px 13px 20px; border-bottom: 1px solid var(--ai-border); background: rgba(255, 255, 255, .96); color: var(--ai-text); }
.ai-assistant-modal__header span, .ai-assistant-modal__header strong { display: block; }
.ai-assistant-modal__header span { color: var(--ai-muted); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.ai-assistant-modal__header strong { margin-top: 3px; font-size: 16px; letter-spacing: -.01em; }
.ai-assistant-modal__actions { display: flex; gap: 6px; align-items: center; }
.ai-assistant-modal__new { border: 1px solid var(--ai-border); border-radius: 9px; padding: 8px 11px; background: #fff; color: #404148; font-size: 12px; font-weight: 600; }
.ai-assistant-modal__new:hover, .ai-assistant-modal__new:focus { background: var(--ai-surface); outline: 0; }
.ai-assistant-modal__close { width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: #6c6d73; font-size: 26px; font-weight: 300; line-height: 1; }
.ai-assistant-modal__close:hover, .ai-assistant-modal__close:focus { background: var(--ai-surface); color: #202123; outline: 0; }

.ai-chat { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; background: var(--ai-bg); }
.ai-chat__messages { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 22px 14px; overscroll-behavior: contain; scrollbar-color: #d6d6dc transparent; scrollbar-width: thin; }
.ai-chat__welcome { display: flex; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; padding: 30px 16px 72px; text-align: center; }
.ai-chat__welcome-mark { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: 18px; border: 1px solid rgba(255,255,255,.26); border-radius: 15px; background: linear-gradient(145deg, #6968e8, #4645b8); color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 9px 24px rgba(87, 86, 214, .28), inset 0 1px 0 rgba(255,255,255,.2); }
.ai-chat__welcome h2 { margin: 0 0 8px; color: var(--ai-text); font-size: 23px; font-weight: 700; letter-spacing: -.025em; }
.ai-chat__welcome p { max-width: 390px; margin: 0 0 24px; color: var(--ai-muted); font-size: 14px; line-height: 1.5; }
.ai-chat__suggestions { display: grid; width: 100%; max-width: 440px; gap: 9px; }
.ai-chat__suggestions button { position: relative; border: 1px solid var(--ai-border); border-radius: 12px; padding: 12px 38px 12px 14px; background: #fff; color: #393a40; font-size: 13px; text-align: left; transition: background .14s, border-color .14s; }
.ai-chat__suggestions button::after { position: absolute; top: 50%; right: 14px; content: '→'; color: #a1a1aa; transform: translateY(-50%); }
.ai-chat__suggestions button:hover, .ai-chat__suggestions button:focus { border-color: #cfcfe0; background: var(--ai-surface); outline: 0; }
.ai-chat__suggestions code { padding: 1px 4px; border-radius: 4px; background: #f0f0f3; color: #4b4a9d; }

.ai-message { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 12px; align-items: start; width: 100%; max-width: 526px; margin: 0 auto 26px; }
.ai-message--user { grid-template-columns: minmax(0, 1fr) 32px; }
.ai-message__avatar { display: grid; grid-column: 1; grid-row: 1; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: linear-gradient(145deg, #6968e8, #4645b8); color: #fff; font-size: 12px; font-weight: 800; box-shadow: 0 3px 10px rgba(87,86,214,.2); }
.ai-message--user .ai-message__avatar { grid-column: 2; background: #eeeeF2; color: #66676d; box-shadow: none; font-size: 8px; letter-spacing: -.02em; }
.ai-message__content { grid-column: 2; min-width: 0; width: 100%; padding-top: 1px; }
.ai-message--user .ai-message__content { display: flex; grid-column: 1; flex-direction: column; align-items: flex-end; }
.ai-message__author { height: 19px; margin-bottom: 3px; color: #777880; font-size: 11px; font-weight: 650; line-height: 16px; }
.ai-message--assistant .ai-message__author { color: #4d4c97; }
.ai-message--user .ai-message__author { padding-right: 2px; text-align: right; }
.ai-message__body { width: 100%; color: var(--ai-text); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message--user .ai-message__body { width: auto; max-width: 88%; padding: 10px 14px; border: 1px solid #e6e6eb; border-radius: 15px 5px 15px 15px; background: #f3f3f5; line-height: 1.5; text-align: left; }
.ai-message--loading .ai-message__body { min-height: 34px; }
.ai-thinking { display: flex; gap: 11px; align-items: center; min-height: 32px; color: var(--ai-muted); }
.ai-thinking__ring { position: relative; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 50%; background: conic-gradient(from 20deg, transparent 0 22%, #9998ed 44%, #5756d6 72%, transparent 94%); animation: ai-spin .9s linear infinite; }
.ai-thinking__ring::after { position: absolute; inset: 4px; border-radius: 50%; content: ''; background: #fff; }
.ai-thinking__label { background: linear-gradient(90deg, #888991 0%, #888991 32%, #4f4e99 48%, #888991 64%, #888991 100%); background-size: 220% 100%; color: transparent; font-size: 13px; font-weight: 550; -webkit-background-clip: text; background-clip: text; animation: ai-shimmer 1.7s ease-in-out infinite; }

.ai-message__sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.ai-message__sources > span { flex: 0 0 100%; color: var(--ai-muted); font-size: 11px; font-weight: 600; }
.ai-message__sources a { max-width: 100%; overflow: hidden; border: 1px solid var(--ai-border); border-radius: 999px; padding: 5px 9px; background: #fafafa; color: #5554a7; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.ai-message__sources a:hover { border-color: #cfcfe0; background: #f4f4fa; color: #3e3d8c; text-decoration: none; }
.ai-message__feedback { display: flex; gap: 3px; align-items: center; min-height: 29px; margin-top: 8px; color: var(--ai-muted); font-size: 11px; }
.ai-message__feedback button { width: 29px; height: 29px; border: 0; border-radius: 7px; background: transparent; filter: grayscale(1); font-size: 13px; opacity: .65; }
.ai-message__feedback button:hover, .ai-message__feedback button.is-selected { background: var(--ai-surface); filter: none; opacity: 1; }
.ai-message__feedback button:disabled { cursor: default; }
.ai-message__feedback[data-error]::after { content: attr(data-error); color: #b42318; }
.ai-feedback-comment { display: flex; gap: 7px; align-items: flex-end; margin-top: 6px; }
.ai-feedback-comment textarea { flex: 1; min-height: 52px; resize: vertical; border: 1px solid var(--ai-border); border-radius: 9px; padding: 8px 10px; outline: 0; color: var(--ai-text); font-size: 12px; }
.ai-feedback-comment textarea:focus { border-color: #aeadde; box-shadow: 0 0 0 3px rgba(87, 86, 214, .1); }
.ai-feedback-comment button { border: 0; border-radius: 8px; padding: 8px 10px; background: var(--ai-primary); color: #fff; font-size: 11px; font-weight: 700; }
.ai-feedback-comment span { color: #39734d; font-size: 12px; }

.ai-chat__composer { display: flex; width: calc(100% - 36px); max-width: 540px; gap: 8px; align-items: flex-end; margin: 0 auto; border: 1px solid #d9d9df; border-radius: 16px; padding: 7px 7px 7px 13px; background: #fff; box-shadow: 0 7px 24px rgba(25, 25, 35, .08); }
.ai-chat__composer:focus-within { border-color: #b9b8df; box-shadow: 0 7px 24px rgba(25, 25, 35, .08), 0 0 0 3px rgba(87, 86, 214, .08); }
.ai-chat__composer textarea { width: 100%; min-height: 36px; max-height: 150px; resize: none; border: 0; padding: 8px 3px 6px; outline: 0; color: var(--ai-text); background: transparent; font-family: inherit; font-size: 14px; line-height: 1.45; }
.ai-chat__composer textarea::placeholder { color: #a2a2aa; }
.ai-chat__send { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 10px; padding: 0; background: var(--ai-primary); color: #fff; transition: background .14s, transform .14s; }
.ai-chat__send:hover, .ai-chat__send:focus { background: var(--ai-primary-hover); color: #fff; outline: 0; }
.ai-chat__send:active { transform: scale(.96); }
.ai-chat__send:disabled { background: #c7c7cf; cursor: wait; }
.ai-chat__hint { margin: 0; padding: 8px 18px 13px; color: #9a9aa2; font-size: 10px; text-align: center; }
.ai-knowledge-article { max-width: 960px; margin: 0 auto 50px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-shimmer { 0% { background-position: 110% 0; } 100% { background-position: -110% 0; } }

@media (max-width: 650px) {
    .ai-assistant-launcher { right: 15px; bottom: 15px; }
    .ai-assistant-modal__dialog { width: 100%; }
    .ai-assistant-modal__header { padding-left: 15px; }
    .ai-assistant-modal__new { padding: 7px 9px; }
    .ai-chat__messages { padding: 18px 14px 12px; }
    .ai-chat__welcome { padding-bottom: 40px; }
    .ai-message { grid-template-columns: 29px minmax(0, 1fr); column-gap: 9px; }
    .ai-message--user { grid-template-columns: minmax(0, 1fr) 29px; }
    .ai-message__avatar { width: 29px; height: 29px; }
    .ai-chat__composer { width: calc(100% - 24px); }
}
