:root {
    --primary: #3f7589;
    --primary-dark: #315f70;
    --primary-light: #6b96a6;

    --background: #f6f8f9;
    --surface: #ffffff;
    --surface-soft: #eef3f5;

    --text: #263238;
    --text-light: #66757d;

    --border: #d7e2e6;
    --shadow: rgba(47, 91, 108, .18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    background: transparent !important;
}

body {
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button {
    font: inherit;
    color: inherit;
}

#chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
}

.launcher-card {
    min-width: 230px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--shadow);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: .2s ease;
}

.launcher-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(47, 91, 108, .24);
}

.launcher-title {
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 15px;
    font-weight: 700;
}

.launcher-subtitle {
    color: var(--text-light);
    font-size: 13px;
}

#chat-button {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(47, 91, 108, .35);
    transition: .2s ease;
}

#chat-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(47, 91, 108, .42);
}

#chat-button:focus-visible,
.launcher-card:focus-visible {
    outline: 3px solid rgba(63, 117, 137, .30);
    outline-offset: 3px;
}

#chat-window {
    position: fixed;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: none;
    flex-direction: column;
    width: 390px;
    height: 620px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 22px 60px rgba(47, 91, 108, .25);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 78px;
    padding: 16px 18px;
    background: var(--primary);
    color: #fff;
}

.header-info {
    min-width: 0;
}

.header-title {
    margin-bottom: 3px;
    font-size: 17px;
    font-weight: 700;
}

.header-subtitle {
    color: rgba(255, 255, 255, .82);
    font-size: 13px;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-buttons button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: .2s ease;
}

.header-buttons button:hover {
    background: rgba(255, 255, 255, .2);
    transform: translateY(-1px);
}

.header-buttons button:focus-visible {
    outline: 3px solid rgba(255, 255, 255, .4);
    outline-offset: 2px;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: var(--background);
    scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
    width: 7px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #c3d2d8;
    border-radius: 20px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #aebfc6;
}

.bot-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 16px;
}

.bot-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
}

.bot-row > div:last-child {
    max-width: calc(100% - 43px);
}

.bot-bubble {
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px 16px 16px 16px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    box-shadow: 0 4px 14px rgba(47, 91, 108, .06);
}

.bot-bubble strong {
    color: var(--primary);
}

.bot-bubble a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.bot-bubble a:hover {
    text-decoration: underline;
}

.user-bubble {
    width: fit-content;
    max-width: 82%;
    margin: 0 0 16px auto;
    padding: 12px 15px;
    background: var(--primary);
    border-radius: 16px 6px 16px 16px;
    color: #fff;
    font-size: 14px;
    line-height: 1.45;
    box-shadow: 0 5px 14px rgba(47, 91, 108, .18);
}

.timestamp {
    margin-top: 5px;
    color: #87959b;
    font-size: 10px;
}

.user-bubble .timestamp {
    color: rgba(255, 255, 255, .72);
    text-align: right;
}

.menu-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 20px 43px;
}

.menu-buttons button {
    padding: 10px 18px;
    border: 1px solid var(--primary);
    border-radius: 999px;
    background: var(--surface);
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: .2s ease;
}

.menu-buttons button:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(47, 91, 108, .20);
}

.menu-buttons button:active {
    transform: scale(.98);
}

.menu-buttons button:focus-visible {
    outline: 3px solid rgba(63, 117, 137, .25);
    outline-offset: 2px;
}

@media (max-width: 520px) {
    #chat-launcher {
        right: 14px;
        bottom: 14px;
    }

    #chat-window {
        inset: 0;
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 0;
    }

    .chat-header {
        min-height: 74px;
        padding: 14px 16px;
    }

    #chat-messages {
        padding: 16px;
    }

    .menu-buttons {
        margin-left: 0;
    }

    .bot-row > div:last-child {
        max-width: calc(100% - 43px);
    }
}

@media (max-height: 700px) and (min-width: 521px) {
    #chat-window {
        height: calc(100vh - 48px);
    }
}