.portfolio-chat {
    --chat-primary: #182235;
    --chat-accent: #5268e8;
    --chat-surface: #ffffff;
    --chat-text: #202938;
    --chat-muted: #718096;
    --chat-border: #e6eaf0;

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    font-family: inherit;
    color: var(--chat-text);
}

.portfolio-chat *,
.portfolio-chat *::before,
.portfolio-chat *::after {
    box-sizing: border-box;
}

.portfolio-chat [hidden] {
    display: none !important;
}

.portfolio-chat button,
.portfolio-chat textarea {
    font: inherit;
}

.portfolio-chat button {
    background: #5C3D93;
    cursor: pointer;
}

.portfolio-chat__launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 58px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    background: var(--chat-primary);
    color: #fff;
    box-shadow: 0 8px 28px rgb(24 34 53 / 24%);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.portfolio-chat__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgb(24 34 53 / 30%);
}

.portfolio-chat__launcher svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portfolio-chat__launcher-label {
    font-size: 15px;
    font-weight: 600;
}

.portfolio-chat__window {
    position: absolute;
    right: 0;
    bottom: -24px;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(410px, calc(100dvh - 48px));
    min-height: 350px;

    padding-top: 0 !important;
    padding-bottom: 0 !important;

    overflow: hidden;
    background: #f8f9fc;

    border: 1px solid var(--chat-border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 16px 60px rgb(15 23 42 / 18%);
    animation: portfolio-chat-enter 180ms ease-out;
}

.portfolio-chat__header {

    margin-top: 0 !important;
    border-radius: 17px 17px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    background: #5C3D93;
    color: #fff;
}

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

.portfolio-chat__avatar {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    background: rgb(255 255 255 / 13%);
    font-size: 25px;
}

.portfolio-chat__identity h2 {
    margin: 0 0 4px;
    color: inherit;
    font-size: 16px;
    font-weight: 650;
    line-height: 1.3;
}

.portfolio-chat__identity p {
    margin: 0;
    color: rgb(255 255 255 / 75%);
    font-size: 12px;
    line-height: 1.4;
}

.portfolio-chat__minimize {
    display: grid;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 8px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
}

.portfolio-chat__minimize:hover {
    background: rgb(255 255 255 / 12%);
}

.portfolio-chat__minimize svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.portfolio-chat__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 16px;
    background: #f8f9fc;
    overscroll-behavior: contain;
}

.portfolio-chat__message {
    display: flex;
    width: 100%;
}

.portfolio-chat__message--user {
    justify-content: flex-end;
}

.portfolio-chat__message--assistant {
    justify-content: flex-start;
}

.portfolio-chat__bubble {
    max-width: 88%;
    padding: 10px 10px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.55;
}

.portfolio-chat__message--assistant .portfolio-chat__bubble {
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 5px;
    background: #fff;
}

.portfolio-chat__message--user .portfolio-chat__bubble {
    border-bottom-right-radius: 5px;
    background: var(--chat-accent);
    color: #fff;
}

.portfolio-chat__message--error .portfolio-chat__bubble {
    border-color: #f2c5c5;
    background: #fff5f5;
    color: #9b2525;
}

.portfolio-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 12px 14px 4px;
    background: #fff;
}

.portfolio-chat__suggestions button {
    padding: 7px 10px;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    background: #fff;
    color: #45516a;
    font-size: 12px;
    transition: border-color 150ms ease, background 150ms ease;
}

.portfolio-chat__suggestions button:hover {
    border-color: var(--chat-accent);
    background: #f4f5ff;
}

.portfolio-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0 !important;
    padding: 12px 14px;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.portfolio-chat__form textarea {
    flex: 1;
    width: 0;
    max-height: 100px;
    min-height: 42px;
    padding: 12px;
    resize: none;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    outline: none;
    background: #f8f9fc;
    color: var(--chat-text);
    font-size: 14px;
    line-height: 1.4;
}

.portfolio-chat__form textarea:focus {
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 3px rgb(82 104 232 / 12%);
}

.portfolio-chat__form textarea:disabled {
    opacity: 0.7;
}

.portfolio-chat__form button {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 10px;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: var(--chat-accent);
    color: #fff;
}

.portfolio-chat__form button:hover {
    filter: brightness(1.08);
}

.portfolio-chat__form button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.portfolio-chat__form button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portfolio-chat__footer {
    margin: 0 !important;
    padding: 4px 12px 14px !important;
    background: #fff;
    color: var(--chat-muted);
    font-size: 10px;
    text-align: center;
}

.portfolio-chat__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@keyframes portfolio-chat-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 600px) {
    .portfolio-chat {
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .portfolio-chat__window {
        position: fixed;
        inset: 12px;
        width: auto;
        height: auto;
        min-height: 0;
        border-radius: 16px;
    }

    .portfolio-chat__header {
        padding: 14px;
    }

    .portfolio-chat__messages {
        padding: 16px 12px;
    }

    .portfolio-chat__launcher {
        min-height: 54px;
        padding: 0 18px;
    }

    .portfolio-chat__launcher-label {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .portfolio-chat *,
    .portfolio-chat *::before,
    .portfolio-chat *::after {
        animation: none !important;
        transition: none !important;
    }
}