.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;
}

.ai-chat {
    --chat-ink: #121725;
    --chat-muted: rgba(18, 23, 37, 0.68);
    --chat-soft: #f5f7fb;
    --chat-panel: #ffffff;
    --chat-line: rgba(18, 23, 37, 0.1);
    --chat-line-strong: rgba(18, 23, 37, 0.18);
    --chat-navy: #12304d;
    --chat-navy-deep: #0c2238;
    --chat-teal: #0f766e;
    --chat-teal-deep: #0a5f59;
    --chat-teal-soft: #e3f6f3;
    --chat-gold: #d4941d;
    --chat-shadow: 0 26px 72px rgba(10, 22, 36, 0.24);
    --chat-shadow-soft: 0 12px 26px rgba(10, 22, 36, 0.1);
    color: var(--chat-ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ai-chat *,
.ai-chat *::before,
.ai-chat *::after {
    box-sizing: border-box;
}

.ai-chat-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 220;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    max-width: calc(100vw - 2rem);
    min-height: 58px;
    padding: 0.55rem 1rem 0.55rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: var(--chat-navy);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 18px 38px rgba(18, 48, 77, 0.3);
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.ai-chat-fab:hover,
.ai-chat-fab:focus-visible {
    background: var(--chat-teal);
    transform: translateY(-2px);
    box-shadow: 0 22px 46px rgba(15, 118, 110, 0.28);
    outline: none;
}

.ai-chat-fab:active {
    transform: translateY(0);
}

.ai-chat--open .ai-chat-fab {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.ai-chat-fab__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.ai-chat-fab__icon {
    width: 21px;
    height: 21px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-fab__text {
    display: grid;
    gap: 0.08rem;
    min-width: 0;
    text-align: left;
}

.ai-chat-fab__label,
.ai-chat-fab__sub {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-fab__label {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
}

.ai-chat-fab__sub {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.7rem;
    font-weight: 700;
}

.ai-chat-panel {
    position: fixed;
    right: 1.5rem;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 220;
    display: flex;
    flex-direction: column;
    width: min(430px, calc(100vw - 2rem));
    height: min(720px, calc(100vh - 3rem));
    max-height: calc(100vh - 3rem);
    border: 1px solid var(--chat-line-strong);
    border-radius: 8px;
    background: var(--chat-panel);
    box-shadow: var(--chat-shadow);
    overflow: hidden;
    animation: ai-chat-rise 180ms ease both;
}

@supports (height: 100dvh) {
    .ai-chat-panel {
        height: min(720px, calc(100dvh - 3rem));
        max-height: calc(100dvh - 3rem);
    }
}

.ai-chat-panel[hidden] {
    display: none;
}

@keyframes ai-chat-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-header {
    flex: 0 0 auto;
    display: grid;
    gap: 0.68rem;
    padding: 0.86rem 0.9rem 0.78rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.9) 0%, rgba(18, 48, 77, 0.98) 58%, rgba(12, 34, 56, 1) 100%);
    color: #ffffff;
}

.ai-chat-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ai-chat-header__identity {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.ai-chat-header__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.ai-chat-header__badge svg {
    width: 20px;
    height: 20px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-header__subtitle {
    display: flex;
    align-items: center;
    gap: 0.38rem;
    margin: 0 0 0.25rem;
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.ai-chat-status-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 999px;
    background: #5eead4;
    box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.16);
}

.ai-chat-header__title {
    margin: 0;
    color: #ffffff;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
}

.ai-chat-header__summary {
    margin: 0;
    max-width: 38rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.78rem;
    line-height: 1.38;
}

.ai-chat-header__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ai-chat-header__facts span {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0.18rem 0.48rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.66rem;
    font-weight: 800;
    white-space: nowrap;
}

.ai-chat-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.ai-chat-close-btn:hover,
.ai-chat-close-btn:focus-visible {
    background: #ffffff;
    border-color: #ffffff;
    color: var(--chat-navy);
    transform: translateY(-1px);
    outline: none;
}

.ai-chat-close-btn svg {
    width: 19px;
    height: 19px;
    stroke-linecap: round;
}

.ai-chat-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.42rem;
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid var(--chat-line);
    background: #fbfcfd;
}

.ai-chat-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.38rem;
    min-width: 0;
    min-height: 36px;
    padding: 0.42rem 0.46rem;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--chat-ink);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.ai-chat-action svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-action span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-action:hover,
.ai-chat-action:focus-visible {
    border-color: rgba(15, 118, 110, 0.42);
    background: rgba(15, 118, 110, 0.08);
    color: var(--chat-teal);
    transform: translateY(-1px);
    outline: none;
}

.ai-chat-action--primary {
    border-color: var(--chat-teal-deep);
    background: var(--chat-teal-deep);
    color: #ffffff;
}

.ai-chat-action--primary:hover,
.ai-chat-action--primary:focus-visible {
    border-color: var(--chat-navy);
    background: var(--chat-navy);
    color: #ffffff;
}

.ai-chat-suggestions-container {
    flex: 0 0 auto;
    padding: 0.66rem 0.65rem 0.58rem;
    border-bottom: 1px solid var(--chat-line);
    background: #f7faf9;
    overflow: hidden;
}

.ai-chat-suggestions-container::-webkit-scrollbar,
.ai-chat-suggestions::-webkit-scrollbar,
.ai-chat-messages::-webkit-scrollbar,
.ai-chat-textarea::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ai-chat-suggestions-container::-webkit-scrollbar-track,
.ai-chat-suggestions::-webkit-scrollbar-track,
.ai-chat-messages::-webkit-scrollbar-track,
.ai-chat-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-suggestions-container::-webkit-scrollbar-thumb,
.ai-chat-suggestions::-webkit-scrollbar-thumb,
.ai-chat-messages::-webkit-scrollbar-thumb,
.ai-chat-textarea::-webkit-scrollbar-thumb {
    background: rgba(18, 23, 37, 0.18);
    border-radius: 999px;
}

.ai-chat-suggestions-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.ai-chat-suggestions-label {
    margin: 0;
    color: var(--chat-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.ai-chat-suggestions-heading span {
    color: rgba(18, 23, 37, 0.52);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.ai-chat-suggestions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(164px, 1fr);
    grid-template-rows: repeat(2, minmax(44px, auto));
    gap: 0.45rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.1rem;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(18, 23, 37, 0.22) transparent;
}

.ai-chat--active-conversation .ai-chat-header {
    gap: 0;
    padding-block: 0.72rem;
}

.ai-chat--active-conversation .ai-chat-header__summary,
.ai-chat--active-conversation .ai-chat-header__facts,
.ai-chat--active-conversation .ai-chat-suggestions-container {
    display: none;
}

.ai-chat-suggestion-btn {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    align-items: center;
    gap: 0.46rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.42rem 0.5rem;
    border: 1px solid rgba(18, 23, 37, 0.1);
    border-radius: 8px;
    background: #ffffff;
    color: var(--chat-ink);
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.ai-chat-suggestion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--chat-teal-soft);
    color: var(--chat-teal);
}

.ai-chat-suggestion-icon svg {
    width: 15px;
    height: 15px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-suggestion-btn > span:last-child {
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
}

.ai-chat-suggestion-btn:hover,
.ai-chat-suggestion-btn:focus-visible {
    border-color: rgba(15, 118, 110, 0.38);
    background: #f9fdfc;
    box-shadow: var(--chat-shadow-soft);
    transform: translateY(-1px);
    outline: none;
}

.ai-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.82rem;
    padding: 0.9rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ffffff;
    scroll-behavior: smooth;
}

.ai-chat-message {
    display: flex;
    flex-direction: column;
    gap: 0.36rem;
    animation: ai-chat-message-in 180ms ease both;
}

@keyframes ai-chat-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-message__meta {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    color: var(--chat-muted);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.ai-chat-message__time {
    color: rgba(18, 23, 37, 0.44);
    font-weight: 700;
    text-transform: none;
}

.ai-chat-message__bubble {
    max-width: 92%;
    width: fit-content;
    padding: 0.68rem 0.78rem;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    background: var(--chat-soft);
    color: var(--chat-ink);
    font-size: 0.86rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.ai-chat-message__bubble p {
    margin: 0;
}

.ai-chat-message__bubble p + p,
.ai-chat-message__bubble ul + p,
.ai-chat-message__bubble ol + p,
.ai-chat-message__bubble p + ul,
.ai-chat-message__bubble p + ol {
    margin-top: 0.55rem;
}

.ai-chat-message__bubble ul,
.ai-chat-message__bubble ol {
    margin: 0.42rem 0 0;
    padding-left: 1.05rem;
}

.ai-chat-message__bubble li + li {
    margin-top: 0.24rem;
}

.ai-chat-message__bubble a {
    color: inherit;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.ai-chat-message__tools {
    display: flex;
    gap: 0.35rem;
    max-width: 92%;
}

.ai-chat-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 28px;
    padding: 0.28rem 0.48rem;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--chat-muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.ai-chat-copy-btn:hover,
.ai-chat-copy-btn:focus-visible {
    border-color: rgba(15, 118, 110, 0.36);
    background: rgba(15, 118, 110, 0.07);
    color: var(--chat-teal);
    outline: none;
}

.ai-chat-copy-btn svg {
    width: 13px;
    height: 13px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-message--user {
    align-items: flex-end;
}

.ai-chat-message--user .ai-chat-message__meta {
    justify-content: flex-end;
    padding-right: 0.3rem;
}

.ai-chat-message--user .ai-chat-message__bubble {
    border-color: var(--chat-teal);
    background: var(--chat-teal);
    color: #ffffff;
}

.ai-chat-message--user .ai-chat-message__time {
    color: rgba(255, 255, 255, 0.7);
}

.ai-chat-message--assistant {
    align-items: flex-start;
}

.ai-chat-message--assistant .ai-chat-message__bubble {
    border-color: rgba(18, 48, 77, 0.12);
    background: #f8fbfc;
}

.ai-chat-typing {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    margin: 0 1rem 0.85rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    background: #ffffff;
}

.ai-chat-typing[hidden] {
    display: none;
}

.ai-chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--chat-teal);
    animation: ai-chat-typing 1.2s ease-in-out infinite;
}

.ai-chat-typing-dot:nth-child(2) {
    animation-delay: 140ms;
}

.ai-chat-typing-dot:nth-child(3) {
    animation-delay: 280ms;
}

@keyframes ai-chat-typing {
    0%, 70%, 100% {
        opacity: 0.45;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

.ai-chat-form {
    flex: 0 0 auto;
    padding: 0.72rem;
    border-top: 1px solid var(--chat-line);
    background: #ffffff;
}

.ai-chat-input-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: end;
    gap: 0.55rem;
}

.ai-chat-textarea {
    width: 100%;
    min-height: 42px;
    max-height: 124px;
    resize: none;
    border: 1px solid var(--chat-line-strong);
    border-radius: 8px;
    padding: 0.68rem 0.78rem;
    background: #ffffff;
    color: var(--chat-ink);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.ai-chat-textarea:focus {
    border-color: var(--chat-teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
    outline: none;
}

.ai-chat-textarea::placeholder {
    color: rgba(18, 23, 37, 0.5);
}

.ai-chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--chat-teal);
    border-radius: 8px;
    background: var(--chat-teal);
    color: #ffffff;
    cursor: pointer;
    padding: 0;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.ai-chat-send-btn svg {
    width: 18px;
    height: 18px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-send-btn:hover,
.ai-chat-send-btn:focus-visible {
    border-color: var(--chat-navy);
    background: var(--chat-navy);
    transform: translateY(-1px);
    outline: none;
}

.ai-chat-send-btn:disabled,
.ai-chat-textarea:disabled {
    cursor: wait;
    opacity: 0.62;
}

.ai-chat-disclaimer {
    margin: 0.48rem 0 0;
    color: rgba(18, 23, 37, 0.56);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.35;
}

@media (max-width: 768px) {
    .ai-chat-fab {
        right: 1rem;
        bottom: 1rem;
        min-height: 54px;
    }

    .ai-chat-panel {
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        width: auto;
        height: min(740px, calc(100vh - 1.5rem));
        max-height: calc(100vh - 1.5rem);
    }

    @supports (height: 100dvh) {
        .ai-chat-panel {
            height: min(740px, calc(100dvh - 1.5rem));
            max-height: calc(100dvh - 1.5rem);
        }
    }
}

@media (max-width: 520px) {
    .ai-chat-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .ai-chat-fab {
        right: 0.75rem;
        bottom: 0.75rem;
        width: 52px;
        min-width: 52px;
        min-height: 52px;
        padding: 0;
        border-radius: 999px;
    }

    .ai-chat-fab__mark {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .ai-chat-fab__text {
        display: none;
    }

    .ai-chat-panel {
        left: 0;
        right: 0;
        bottom: 0;
        top: max(0.7rem, env(safe-area-inset-top, 0px));
        width: auto;
        height: auto;
        max-height: none;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 8px 8px 0 0;
    }

    .ai-chat-header {
        gap: 0.58rem;
        padding: 0.74rem;
    }

    .ai-chat-header__badge {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .ai-chat-header__title {
        font-size: 0.92rem;
    }

    .ai-chat-header__summary {
        display: none;
    }

    .ai-chat-header__facts span {
        min-height: 22px;
        font-size: 0.66rem;
    }

    .ai-chat-suggestions-container {
        padding: 0.58rem 0.6rem 0.54rem;
    }

    .ai-chat-suggestions {
        grid-auto-columns: minmax(144px, 1fr);
        gap: 0.4rem;
    }

    .ai-chat-suggestion-btn {
        grid-template-columns: 24px minmax(0, 1fr);
        min-height: 44px;
        padding: 0.42rem 0.48rem;
        font-size: 0.74rem;
    }

    .ai-chat-suggestion-icon {
        width: 24px;
        height: 24px;
    }

    .ai-chat-suggestion-icon svg {
        width: 14px;
        height: 14px;
    }

    .ai-chat-messages {
        min-height: 0;
        padding: 0.78rem;
    }

    .ai-chat-message__bubble {
        max-width: 94%;
        font-size: 0.84rem;
    }

    .ai-chat-form {
        padding: 0.68rem;
    }
}

@media (max-width: 360px) {
    .ai-chat-action {
        gap: 0.25rem;
        padding-inline: 0.35rem;
        font-size: 0.7rem;
    }

    .ai-chat-header__facts span {
        font-size: 0.62rem;
    }

    .ai-chat-suggestions-heading span {
        display: none;
    }
}

@media (max-height: 620px) {
    .ai-chat-header__summary,
    .ai-chat-header__facts {
        display: none;
    }

    .ai-chat-header {
        gap: 0;
        padding-block: 0.72rem;
    }

    .ai-chat--active-conversation .ai-chat-actions {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat,
    .ai-chat *,
    .ai-chat *::before,
    .ai-chat *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
