.ip-pathie {
    position: fixed;
    z-index: 45;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    color: var(--ip-text);
    font: 400 .875rem/1.55 var(--ip-font);
}

.ip-pathie .ip-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

/* Signature Soft Lavender Identity when embedded on the public Landing Page */
.ip-landing .ip-pathie {
    color-scheme: light;
    --ip-font: "Be Vietnam Pro", Inter, system-ui, -apple-system, sans-serif;
    --ip-motion: 200ms cubic-bezier(.22, .68, .28, 1);
    --ip-panel: #FFFFFF;
    --ip-control: #FAF7FF;
    --ip-lavender: #EFE8FD;
    --ip-cream: #FFF4D9;
    --ip-border: #E2D8F5;
    --ip-control-border: #CBBCEB;
    --ip-primary: #8B5CF6;
    --ip-link: #5D3DB8;
    --ip-text: #27203B;
    --ip-muted: #61567B;
    --ip-fill: #6D44C8;
    --ip-fill-hover: #5B37AD;
    --ip-success: #229B78;
    --ip-success-text: #187457;
    --ip-warning: #D58A25;
    --ip-warning-text: #8B5414;
}

.ip-landing .ip-pathie-launcher {
    border-color: #C8B5F0;
    background: #EFE8FD;
    box-shadow: 0 10px 28px rgba(8, 5, 22, 0.48), 0 0 22px rgba(167, 139, 250, 0.34);
}

.ip-landing .ip-pathie-panel {
    border-color: #DDD2F4;
    box-shadow: 0 22px 58px rgba(4, 2, 14, 0.56);
}

.ip-landing .ip-pathie :is(h2, h3, h4) {
    color: var(--ip-text);
    letter-spacing: -0.015em;
}

.ip-landing .ip-pathie .ip-pathie-send {
    color: #FFFFFF;
}

.ip-landing .ip-pathie .ip-pathie-stop,
.ip-landing .ip-pathie .ip-pathie-icon-button,
.ip-landing .ip-pathie .ip-pathie-text-button,
.ip-landing .ip-pathie .ip-pathie-suggestions button {
    color: var(--ip-link);
}

.ip-landing .ip-pathie .ip-pathie-reference a {
    color: var(--ip-link);
}

.ip-pathie [hidden],
.ip-pathie[hidden] { display: none; }

.ip-pathie button,
.ip-pathie textarea { font: inherit; }

.ip-pathie button { cursor: pointer; }
.ip-pathie button:disabled { cursor: default; opacity: .55; }

.ip-pathie-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.ip-pathie-launcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 1px solid var(--ip-control-border);
    border-radius: 50%;
    background: var(--ip-lavender);
    box-shadow: 0 8px 24px rgba(4, 3, 14, 0.45);
}

.ip-pathie-launcher-dot {
    position: absolute;
    right: 1px;
    bottom: 2px;
    width: 13px;
    height: 13px;
    border: 2px solid var(--ip-panel);
    border-radius: 50%;
    background: var(--ip-success);
}

.ip-pathie-greeting {
    position: absolute;
    right: 69px;
    bottom: 3px;
    display: flex;
    align-items: flex-start;
    gap: .32rem;
    width: max-content;
    max-width: min(16.5rem, calc(100vw - 106px));
    padding: .5rem .45rem .5rem .75rem;
    border: 1px solid var(--ip-border);
    border-radius: 15px 15px 3px 15px;
    background: var(--ip-panel);
    color: var(--ip-text);
    box-shadow: 0 4px 15px rgba(87, 52, 73, 0.09);
    font-size: .77rem;
}

.ip-pathie-greeting p { margin: .3rem 0; }

.ip-pathie-icon-button {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ip-link);
}

.ip-pathie-icon-button:hover { border-color: var(--ip-control-border); background: var(--ip-panel); }
.ip-pathie-icon-button .ip-icon { width: 17px; height: 17px; }
.ip-pathie-greeting .ip-pathie-icon-button { width: 34px; height: 34px; }

.ip-pathie-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: min(420px, calc(100vw - 44px));
    height: min(600px, calc(100dvh - 112px));
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--ip-border);
    border-radius: 24px;
    background: var(--ip-panel);
    box-shadow: 0 15px 48px rgba(87, 52, 73, 0.16);
}

.ip-pathie-panel.is-expanded {
    width: min(665px, calc(100vw - 44px));
    height: min(770px, calc(100dvh - 112px));
}

.ip-pathie-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    padding: .75rem .8rem;
    background: var(--ip-lavender);
}

.ip-pathie-avatar { flex: none; width: 45px; height: 45px; }
.ip-pathie-heading { flex: 1 1 0; min-width: 0; }
.ip-pathie-heading h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; }
.ip-pathie-heading p { margin: .1rem 0 0; color: var(--ip-muted); font-size: .72rem; line-height: 1.45; }
.ip-pathie-window-actions { display: flex; gap: .15rem; }

.ip-pathie-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 .45rem;
    padding: .2rem .72rem;
    border-bottom: 1px solid var(--ip-border);
}

.ip-pathie-connection {
    display: inline-flex;
    align-items: center;
    gap: .29rem;
    color: var(--ip-muted);
    font-size: .69rem;
    font-weight: 600;
    white-space: nowrap;
}

.ip-pathie-connection::before {
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    background: var(--ip-muted);
    content: "";
}

.ip-pathie-connection[data-state="ready"] { color: var(--ip-success-text); }
.ip-pathie-connection[data-state="ready"]::before { background: var(--ip-success); }
.ip-pathie-connection[data-state="unavailable"] { color: var(--ip-warning-text); }
.ip-pathie-connection[data-state="unavailable"]::before { background: var(--ip-warning); }
.ip-pathie-thread-actions { display: flex; gap: .1rem; }

.ip-pathie-text-button {
    min-height: 35px;
    padding: .3rem .36rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ip-link);
    font-size: .69rem !important;
    font-weight: 600 !important;
}

.ip-pathie-text-button:hover { background: var(--ip-lavender); }

.ip-pathie-scroll {
    min-width: 0;
    overflow: auto;
    padding: .75rem .85rem;
    overscroll-behavior: contain;
    scrollbar-color: var(--ip-control-border) transparent;
}

.ip-pathie-scroll:focus-visible { outline-offset: -2px; }
.ip-pathie-welcome { margin: .2rem auto 0; max-width: 26rem; text-align: center; }
.ip-pathie-welcome-avatar { display: block; margin: 0 auto .32rem; width: 68px; height: 68px; }
.ip-pathie-welcome h3 { margin: .12rem 0 .3rem; font-size: 1rem; }
.ip-pathie-welcome p { margin: .27rem auto; color: var(--ip-muted); font-size: .78rem; }
.ip-pathie-welcome .ip-pathie-tagline { color: var(--ip-link); font-size: .68rem; font-weight: 600; }
.ip-pathie-welcome .ip-pathie-suggestions-label { margin: .64rem auto .35rem; color: var(--ip-text); font-weight: 600; }

.ip-pathie-suggestions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .39rem;
    margin: 0 auto;
}

.ip-pathie-suggestions button {
    min-height: 44px;
    padding: .4rem .48rem;
    border: 1px solid var(--ip-border);
    border-radius: 11px;
    background: var(--ip-control);
    color: var(--ip-link);
    font-size: .72rem;
    text-align: left;
}

.ip-pathie-suggestions button:hover:not(:disabled) { border-color: var(--ip-primary); background: var(--ip-lavender); }
.ip-pathie-suggestions button:disabled { opacity: .65; cursor: default; }
.ip-pathie-followups .ip-pathie-suggestions { width: 100%; }
.ip-pathie-messages { display: grid; gap: .68rem; margin: 0; padding: 0; list-style: none; }
.ip-pathie-message { display: flex; gap: .4rem; align-items: flex-start; min-width: 0; }
.ip-pathie-message--user { justify-content: flex-end; }
.ip-pathie-bubble { max-width: calc(100% - 34px); min-width: 0; }
.ip-pathie-message--user .ip-pathie-bubble { max-width: 90%; }
.ip-pathie-message img { flex: none; width: 26px; height: 26px; }

.ip-pathie-answer,
.ip-pathie-question {
    padding: .6rem .72rem;
    border: 1px solid var(--ip-border);
    border-radius: 4px 13px 13px 13px;
    background: var(--ip-control);
    overflow-wrap: anywhere;
    font-size: .83rem;
}

.ip-pathie-question {
    border-color: transparent;
    border-radius: 13px 4px 13px 13px;
    background: var(--ip-lavender);
    white-space: pre-wrap;
}

.ip-pathie-answer[data-streaming] { white-space: pre-wrap; }
.ip-pathie-answer p { margin: 0 0 .5rem; white-space: pre-line; }
.ip-pathie-answer :is(ul, ol) { margin: .45rem 0; padding-inline-start: 1.2rem; }
.ip-pathie-answer :last-child { margin-bottom: 0; }
.ip-pathie-answer code { font-size: .95em; }

.ip-pathie-table-wrap { max-width: 100%; margin: .5rem 0; overflow: auto; }
.ip-pathie-table-wrap table { width: 100%; min-width: 35ch; border-collapse: collapse; }
.ip-pathie-table-wrap :is(th, td) { padding: .3rem .4rem; border: 1px solid var(--ip-border); text-align: left; }
.ip-pathie-table-wrap th { background: var(--ip-lavender); }

.ip-pathie-references { display: grid; gap: .3rem; margin-top: .43rem; }
.ip-pathie-references h4 { margin: 0; color: var(--ip-muted); font-size: .69rem; }
.ip-pathie-reference { padding: .37rem .48rem; border: 1px solid var(--ip-border); border-radius: 9px; font-size: .72rem; }
.ip-pathie-reference :is(a, strong) { font-weight: 600; }
.ip-pathie-reference p { margin: .14rem 0 0; color: var(--ip-muted); }
.ip-pathie-reference a:hover { text-decoration: underline; }

.ip-pathie-transcript-actions { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .1rem; }
.ip-pathie-transcript-actions button { text-align: left; }

.ip-pathie-typing {
    display: flex;
    gap: .4rem;
    align-items: center;
    color: var(--ip-muted);
    font-size: .75rem;
}

.ip-pathie-typing-dots { display: flex; flex: none; gap: 3px; }

.ip-pathie-typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--ip-primary);
    animation: ip-pathie-dot 900ms ease-in-out infinite alternate;
}

.ip-pathie-typing-dots span:nth-child(2) { animation-delay: 150ms; }
.ip-pathie-typing-dots span:nth-child(3) { animation-delay: 300ms; }
@keyframes ip-pathie-dot { from { opacity: .4; } to { opacity: 1; } }

.ip-pathie-service-note,
.ip-pathie-message-note {
    padding: .45rem .58rem;
    border-radius: 9px;
    background: var(--ip-cream);
    color: var(--ip-warning-text);
    font-size: .75rem;
}

.ip-pathie-service-note { margin-bottom: .65rem; }
.ip-pathie-message-note { margin: .31rem 0 0; }

.ip-pathie-composer {
    padding: .6rem .75rem;
    border-top: 1px solid var(--ip-border);
    background: var(--ip-panel);
}

.ip-pathie-compose-row { display: flex; gap: .4rem; align-items: flex-end; }

.ip-pathie textarea {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    max-height: 6.5rem;
    padding: .57rem .7rem;
    resize: none;
    border: 1px solid var(--ip-control-border);
    border-radius: 17px;
    background: var(--ip-control);
    color: var(--ip-text);
    line-height: 1.45;
}

.ip-pathie textarea::placeholder { color: var(--ip-muted); }

.ip-pathie-send {
    display: inline-grid;
    flex: 0 0 44px;
    place-items: center;
    height: 44px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 15px;
    background: var(--ip-fill);
    color: #fff;
}

.ip-pathie-send:hover:not(:disabled) { background: var(--ip-fill-hover); }
.ip-pathie-send .ip-icon { width: 18px; height: 18px; }
.ip-pathie-stop { border-color: var(--ip-control-border); background: var(--ip-lavender); color: var(--ip-link); }
.ip-pathie-stop:hover:not(:disabled) { border-color: var(--ip-primary); background: var(--ip-lavender); }
.ip-pathie-feedback { margin: .3rem 0 0; color: var(--ip-muted); font-size: .69rem; }
.ip-pathie-feedback:empty { margin: 0; }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .ip-pathie-launcher { transition: transform var(--ip-motion); }
    .ip-pathie-launcher:hover { transform: scale(1.055); }
}

@media (prefers-reduced-motion: reduce) {
    .ip-pathie-typing-dots span { animation: none; }
}

@media (max-width: 610px) {
    .ip-pathie {
        right: max(13px, env(safe-area-inset-right));
        bottom: max(13px, env(safe-area-inset-bottom));
    }

    .ip-pathie.is-open { inset: auto 0 var(--ip-pathie-keyboard-offset, 0px); }
    .ip-pathie.is-open .ip-pathie-launcher { display: none; }

    .ip-pathie-panel,
    .ip-pathie-panel.is-expanded {
        position: static;
        width: 100%;
        height: min(680px, calc(var(--ip-pathie-viewport-height, 100dvh) - 10px));
        border-radius: 24px 24px 0 0;
    }

    .ip-pathie-panel.is-expanded { height: calc(var(--ip-pathie-viewport-height, 100dvh) - 2px); }
    .ip-pathie-composer { padding-bottom: max(.6rem, env(safe-area-inset-bottom)); }
    .ip-pathie textarea { font-size: 16px; }
}

@media (max-width: 360px) {
    .ip-pathie-greeting { right: 0; bottom: 69px; max-width: min(15rem, calc(100vw - 35px)); }
    .ip-pathie-suggestions { grid-template-columns: minmax(0, 1fr); }
}
