.sfs-ai {
    --sfs-ink: #17233d;
    --sfs-navy: #192746;
    --sfs-accent: #673b27;
    --sfs-gold: #f7d594;
    --sfs-paper: #fffcf6;
    --sfs-line: #e7dfd1;
    --sfs-muted: #525c6b;
    color: var(--sfs-ink);
    direction: ltr;
    font: 400 15px/1.5 Inter, system-ui, 'Nirmala UI', sans-serif;
    text-align: start;
}

.sfs-ai *, .sfs-ai *::before, .sfs-ai *::after { box-sizing: border-box; }
.sfs-ai [hidden] { display: none !important; }
.sfs-ai button { cursor: pointer; font: inherit; margin: 0; text-transform: none; }
.sfs-ai button:disabled { cursor: wait; opacity: .65; }
.sfs-ai :is(button, a, input, [tabindex]):focus-visible { outline: 3px solid #a0561e; outline-offset: 3px; }

.sfs-ai--floating {
    position: fixed;
    inset-inline-end: max(22px, env(safe-area-inset-right));
    inset-block-end: max(22px, env(safe-area-inset-bottom));
    z-index: 9998;
}

.sfs-ai--inline { width: min(100%, 560px); margin: 1.5rem auto; }

.sfs-ai .sfs-ai__launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 10px 18px;
    color: var(--sfs-navy);
    background: var(--sfs-gold);
    border: 1px solid #b57b39;
    border-radius: 999px;
    box-shadow: 0 8px 24px #19274629;
    font-weight: 750;
}

.sfs-ai__panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 44px);
    max-height: calc(100dvh - 44px);
    overflow: hidden;
    background: var(--sfs-paper);
    border: 1px solid var(--sfs-line);
    border-radius: 23px;
    box-shadow: 0 18px 55px #19274629;
}

.sfs-ai--floating .sfs-ai__panel { width: min(390px, calc(100vw - 44px)); height: 560px; }
.sfs-ai--inline .sfs-ai__panel { height: 570px; max-height: none; }

.sfs-ai__header {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    padding: 14px 16px;
    color: white;
    background: linear-gradient(120deg, #283960 0%, var(--sfs-navy) 75%);
    border-bottom: 3px solid #d29b54;
}

.sfs-ai__crest {
    display: grid;
    flex: none;
    place-items: center;
    width: 43px;
    height: 43px;
    padding-top: 3px;
    color: var(--sfs-gold);
    background: #ffffff10;
    border: 1px solid #f7d59470;
    border-radius: 14px 14px 18px 18px;
}

.sfs-ai__identity { min-width: 0; flex: 1; }
.sfs-ai .sfs-ai__identity h2 { margin: 0; color: white; font: 700 19px/1.2 Inter, system-ui, sans-serif; letter-spacing: -.02em; }
.sfs-ai .sfs-ai__identity p { margin: 3px 0 0; color: #f8dbad; font-size: 12px; overflow-wrap: anywhere; }

.sfs-ai .sfs-ai__close {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0 0 2px;
    color: white;
    background: transparent;
    border: 1px solid #ffffff70;
    border-radius: 11px;
    font-size: 24px;
    line-height: 1;
}

.sfs-ai .sfs-ai__close:hover { background: #ffffff19; }
.sfs-ai .sfs-ai__close:focus-visible { outline-color: var(--sfs-gold); }

.sfs-ai__languages {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    gap: 4px;
    padding: 9px 15px;
    background: #fbf4e8;
    border-bottom: 1px solid var(--sfs-line);
}

.sfs-ai .sfs-ai__languages button {
    min-height: 32px;
    padding: 3px 12px;
    color: var(--sfs-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 650;
}

.sfs-ai .sfs-ai__languages button[aria-pressed='true'] { color: var(--sfs-navy); background: white; border-color: #dbccb4; }
.sfs-ai .sfs-ai__languages button:hover { color: var(--sfs-ink); border-color: #dbccb4; }

.sfs-ai__messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 11px;
    min-height: 0;
    padding: 15px;
    overflow: auto;
    overscroll-behavior: contain;
    background: linear-gradient(180deg, #fffcf6, #faf3e7);
}

.sfs-ai .sfs-ai__message {
    flex: none;
    max-width: 92%;
    margin: 0;
    padding: 9px 12px;
    color: var(--sfs-ink);
    background: white;
    border: 1px solid var(--sfs-line);
    border-radius: 4px 13px 13px 13px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.sfs-ai .sfs-ai__message--visitor { align-self: flex-end; color: white; background: var(--sfs-navy); border-color: var(--sfs-navy); border-radius: 13px 4px 13px 13px; }
.sfs-ai .sfs-ai__message p { margin: 0; }
.sfs-ai .sfs-ai__message .sfs-ai__source-label { margin-top: 9px; color: var(--sfs-muted); font-size: 12px; font-weight: 700; }
.sfs-ai .sfs-ai__message ul { margin: 3px 0 0; padding-inline-start: 1.2em; }
.sfs-ai .sfs-ai__message li { margin: 0; }
.sfs-ai a { color: var(--sfs-accent); text-decoration: underline; text-underline-offset: 2px; }

.sfs-ai__controls { flex: none; padding: 10px 13px; background: white; border-top: 1px solid var(--sfs-line); }
.sfs-ai__topics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.sfs-ai .sfs-ai__topics button { min-height: 30px; padding: 3px 10px; color: var(--sfs-accent); background: #fff8eb; border: 1px solid #e5d4b6; border-radius: 999px; font-size: 12px; font-weight: 650; }
.sfs-ai .sfs-ai__topics button:hover:not(:disabled) { background: #f8e8c9; }
.sfs-ai__form { display: flex; align-items: stretch; gap: 7px; margin: 0; }
.sfs-ai .sfs-ai__form input { flex: 1; min-width: 0; min-height: 42px; margin: 0; padding: 7px 11px; color: var(--sfs-ink); background: var(--sfs-paper); border: 1px solid #c8c3b9; border-radius: 10px; font: inherit; font-size: 16px; }
.sfs-ai .sfs-ai__form input::placeholder { color: var(--sfs-muted); }
.sfs-ai .sfs-ai__form button { display: grid; flex: none; place-items: center; width: 43px; padding: 0; color: white; background: var(--sfs-navy); border: 1px solid var(--sfs-navy); border-radius: 10px; }
.sfs-ai .sfs-ai__form button:hover:not(:disabled) { background: #324775; }
.sfs-ai .sfs-ai__status { margin: 4px 0 0; color: var(--sfs-accent); font-size: 12px; }
.sfs-ai .sfs-ai__status:empty { margin: 0; }
.sfs-ai .sfs-ai__notice { margin: 6px 0 0; color: var(--sfs-muted); font-size: 11px; line-height: 1.45; }
.sfs-ai__notice a { white-space: nowrap; }
.sfs-ai__sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 480px) {
    .sfs-ai--floating { inset-inline-end: max(10px, env(safe-area-inset-right)); inset-block-end: max(10px, env(safe-area-inset-bottom)); }
    .sfs-ai--floating .sfs-ai__panel { width: min(390px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); }
}

@media (max-height: 440px) {
    .sfs-ai--floating .sfs-ai__header { min-height: 54px; padding-block: 5px; }
    .sfs-ai--floating .sfs-ai__languages { padding-block: 3px; }
    .sfs-ai--floating .sfs-ai__controls { padding-block: 6px; }
    .sfs-ai--floating .sfs-ai__topics { display: none; }
}
