@keyframes aiw-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aiw-root,
.aiw-root * {
    box-sizing: border-box;
}

.aiw-root {
    --aiw-primary: #0039a6;
    --aiw-lime: #c7f33d;
    --aiw-uranium: #e1ebfe;
    --aiw-white: #ffffff;
    --aiw-black-night: #121619;
    --aiw-surface: var(--aiw-white);
    --aiw-surface-muted: #f3f6fc;
    --aiw-surface-soft: #eef3fb;
    --aiw-text: var(--aiw-black-night);
    --aiw-text-soft: rgba(18, 22, 25, 0.62);
    --aiw-line: rgba(0, 57, 166, 0.14);
    --aiw-line-strong: rgba(0, 57, 166, 0.3);
    --aiw-error-bg: #fff1f1;
    --aiw-error-text: #8f1d1d;
    --aiw-shadow: 0 18px 40px rgba(24, 54, 116, 0.12);
    --aiw-font-ui: "BotanikaDemi", "Botanika-Demi", "Botanika Demi", Aptos, "Segoe UI", sans-serif;
    --aiw-font-mono: "Botanika", "Botanika Mono", "Aptos Mono", Consolas, monospace;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--aiw-font-ui);
    color: var(--aiw-text);
}

.aiw-root--bottom-left {
    left: 24px;
    right: auto;
}

.aiw-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 10px 16px 10px 12px;
    border: 2px solid var(--aiw-primary);
    border-radius: 0;
    background: var(--aiw-white);
    color: var(--aiw-primary);
    font-family: var(--aiw-font-mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--aiw-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aiw-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 42px rgba(0, 57, 166, 0.25);
}

.aiw-root .aiw-toggle[aria-expanded="true"]:has(+ .aiw-panel--expanded) {
    display: none;
}

.aiw-toggle__dot {
    display: grid;
    grid-template-columns: repeat(4, 6px);
    gap: 5px;
    padding: 2px 0;
    flex: none;
}

.aiw-toggle__dot span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--aiw-primary);
}

.aiw-toggle__label {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.aiw-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 392px;
    height: min(680px, calc(100vh - 124px));
    height: min(680px, calc(100dvh - 124px));
    max-height: min(680px, calc(100vh - 124px));
    border-radius: 0;
    border: 1px solid rgba(0, 57, 166, 0.08);
    background: var(--aiw-surface);
    box-shadow: var(--aiw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.aiw-panel[hidden] {
    display: none;
}

.aiw-root--bottom-left .aiw-panel {
    left: 0;
    right: auto;
}

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

.aiw-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--aiw-line);
    background: var(--aiw-primary);
    color: var(--aiw-white);
    border-radius: 0;
}

.aiw-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aiw-kicker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.aiw-logo {
    display: grid;
    grid-template-columns: repeat(4, 8px);
    gap: 6px;
    flex: none;
}

.aiw-logo span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--aiw-white);
}

.aiw-labels {
    min-width: 0;
}

.aiw-overline {
    display: block;
    font-family: var(--aiw-font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.aiw-title {
    display: block;
    max-width: 100%;
    color: var(--aiw-white);
    font-family: "BotanikaBold", var(--aiw-font-ui);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.aiw-subtitle {
    margin-top: 2px;
    max-width: 250px;
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.76);
}

.aiw-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.aiw-close,
.aiw-expand {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 0;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--aiw-white);
}

.aiw-close:hover,
.aiw-expand:hover {
    background: rgba(255, 255, 255, 0.16);
}

.aiw-root button:focus-visible,
.aiw-root summary:focus-visible,
.aiw-root a:focus-visible {
    outline: 2px solid var(--aiw-primary);
    outline-offset: 3px;
}

.aiw-header button:focus-visible {
    outline-color: var(--aiw-white);
}

.aiw-form:focus-within {
    border-color: var(--aiw-primary);
    box-shadow: 0 0 0 2px var(--aiw-line);
}

.aiw-messages {
    flex: 1;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-anchor: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--aiw-surface);
}

.aiw-message {
    flex-shrink: 0;
    overflow-wrap: anywhere;
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    animation: aiw-fade-in 0.16s ease-out;
    white-space: pre-wrap;
    border: 1px solid transparent;
    color: var(--aiw-text);
}

.aiw-message--assistant {
    align-self: flex-start;
    background: #f5f6f8;
    border-color: rgba(18, 22, 25, 0.08);
    border-bottom-left-radius: 4px;
}

.aiw-message--user {
    align-self: flex-end;
    background: var(--aiw-uranium);
    border-color: rgba(0, 57, 166, 0.1);
    border-bottom-right-radius: 4px;
}

.aiw-message--error {
    align-self: flex-start;
    background: var(--aiw-error-bg);
    color: var(--aiw-error-text);
    border-color: rgba(143, 29, 29, 0.22);
}

.aiw-message--loading {
    background: transparent;
    border-color: transparent;
    padding: 8px 0;
    color: var(--aiw-primary);
    white-space: normal;
}

.aiw-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: normal;
}

.aiw-loading__mascot {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    /* Unchanged FEI loading.gif from stubarag-frontend: the blink is in its frames. */
    background: url("agent-kovac-loading.gif") center / contain no-repeat;
}

.aiw-loading__text {
    font-family: var(--aiw-font-ui);
    line-height: 1.5;
    /* LoadingIndicator.vue shimmer, using the stu-fei-blue skin colors. */
    background: linear-gradient(90deg, var(--aiw-primary) 0%, #1058de 25%, #aea4ff 50%, #1058de 75%, var(--aiw-primary) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: aiw-loading-shimmer 2s ease-in-out infinite;
}

.aiw-message__content > :first-child {
    margin-top: 0;
}

.aiw-message__content > :last-child {
    margin-bottom: 0;
}

.aiw-message__content h1,
.aiw-message__content h2,
.aiw-message__content h3,
.aiw-message__content h4 {
    margin: 0 0 10px;
    color: var(--aiw-primary);
    font-family: "BotanikaBold", var(--aiw-font-ui);
    font-weight: 700;
    line-height: 1.2;
}

.aiw-message__content h1 {
    font-size: 20px;
}

.aiw-message__content h2 {
    font-size: 18px;
}

.aiw-message__content h3,
.aiw-message__content h4 {
    font-size: 16px;
}

.aiw-message__content p,
.aiw-message__content ul,
.aiw-message__content ol,
.aiw-message__content pre,
.aiw-message__content blockquote {
    margin: 0 0 10px;
}

.aiw-message__content ul,
.aiw-message__content ol {
    padding-left: 18px;
}

.aiw-message__content li + li {
    margin-top: 4px;
}

.aiw-message__content a {
    color: var(--aiw-primary);
}

.aiw-message__content code {
    padding: 1px 5px;
    border-radius: 0;
    background: rgba(0, 57, 166, 0.08);
    font-family: var(--aiw-font-mono);
    font-size: 0.92em;
}

.aiw-message__content pre {
    overflow-x: auto;
    padding: 10px 12px;
    border-radius: 0;
    background: rgba(0, 57, 166, 0.06);
}

.aiw-message__content pre code {
    padding: 0;
    background: transparent;
}

.aiw-message__content blockquote {
    padding-left: 12px;
    border-left: 3px solid rgba(0, 57, 166, 0.28);
    color: var(--aiw-text-soft);
}

.aiw-footer {
    flex-shrink: 0;
    padding: 12px;
    border-top: 1px solid var(--aiw-line);
    background: var(--aiw-surface);
    border-radius: 0;
}

.aiw-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px;
    border: 1px solid rgba(0, 57, 166, 0.08);
    border-radius: 0;
    background: var(--aiw-white);
    box-shadow: 0 10px 30px rgba(24, 54, 116, 0.08);
}

.aiw-input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--aiw-text);
    font-family: var(--aiw-font-ui);
    font-size: 16px;
    outline: none;
}

.aiw-send {
    flex: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    border-radius: 0;
    padding: 0;
    background: rgba(0, 57, 166, 0.45);
    color: var(--aiw-white);
    font-family: var(--aiw-font-mono);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
}

.aiw-send:disabled,
.aiw-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aiw-status {
    margin-top: 10px;
    font-family: var(--aiw-font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--aiw-text-soft);
    min-height: 18px;
}

.aiw-status:empty {
    display: none;
}

.aiw-root .aiw-panel.aiw-panel--expanded {
    position: fixed;
    top: auto;
    left: auto;
    right: 24px;
    bottom: 24px;
    width: clamp(440px, 35vw, 680px);
    max-width: calc(100vw - 48px);
    height: 88vh;
    height: 88dvh;
    max-height: none;
}

.aiw-panel--expanded .aiw-message {
    max-width: min(88%, 80ch);
}

.aiw-sources {
    margin-top: 12px;
    padding: 8px 10px;
    border: 1px solid var(--aiw-line);
    border-radius: 10px;
    background: var(--aiw-surface);
    font-size: 12px;
}

.aiw-sources summary {
    cursor: pointer;
    color: var(--aiw-primary);
}

@media (prefers-reduced-motion: reduce) {
    .aiw-loading__text,
    .aiw-message {
        animation: none;
    }
    .aiw-loading__mascot {
        background-image: url("agent-kovac.svg");
    }
    .aiw-loading__text {
        background: none;
        -webkit-text-fill-color: currentColor;
    }
    .aiw-panel,
    .aiw-toggle {
        transition: none;
    }
}

.aiw-message--options {
    align-self: flex-start;
    background: transparent;
    border: none;
    padding: 0;
}

.aiw-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aiw-option {
    border: 1px solid var(--aiw-line);
    background: var(--aiw-white);
    color: var(--aiw-primary);
    padding: 8px 10px;
    border-radius: 0;
    font-family: var(--aiw-font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}

.aiw-option:hover {
    background: var(--aiw-surface-muted);
}

.aiw-option--selected {
    background: var(--aiw-surface-muted);
    color: var(--aiw-primary);
    border-color: var(--aiw-primary);
}

.aiw-option--disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aiw-multi {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aiw-custom {
    display: flex;
    gap: 8px;
}

.aiw-custom input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--aiw-line);
    border-radius: 0;
    padding: 9px 10px;
    background: var(--aiw-white);
    font-family: var(--aiw-font-ui);
    font-size: 16px;
}

.aiw-custom button,
.aiw-confirm {
    border: 1px solid var(--aiw-primary);
    border-radius: 0;
    padding: 9px 12px;
    background: var(--aiw-white);
    color: var(--aiw-primary);
    font-family: var(--aiw-font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.aiw-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes aiw-loading-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@media (min-width: 601px) {
    .aiw-panel {
        width: min(420px, calc(100vw - 48px));
        border-radius: 12px;
    }

    .aiw-header {
        border-top-left-radius: inherit;
        border-top-right-radius: inherit;
    }

    .aiw-footer {
        border-bottom-left-radius: inherit;
        border-bottom-right-radius: inherit;
    }
}

@media (max-width: 600px) {
    .aiw-root .aiw-toggle[aria-expanded="true"] {
        display: none;
    }

    body.aiw-chat-open {
        overflow: hidden;
    }

    .aiw-root,
    .aiw-root--bottom-left {
        bottom: 12px;
    }

    .aiw-root {
        right: 12px;
        left: auto;
    }

    .aiw-root--bottom-left {
        left: 12px;
        right: auto;
    }

    .aiw-root .aiw-panel,
    .aiw-root .aiw-panel.aiw-panel--expanded {
        position: fixed;
        top: var(--aiw-viewport-top, 0px);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        height: var(--aiw-viewport-height, 100vh);
        max-height: none;
        border: none;
        transform: none;
    }

    .aiw-expand {
        display: none;
    }

    .aiw-header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .aiw-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .aiw-title {
        font-size: 16px;
    }

    .aiw-subtitle {
        max-width: none;
    }
}
