.qa-agent {
    --qa-cream: #fffaf2;
    --qa-paper: #ffffff;
    --qa-sand: #e7d1b0;
    --qa-gold: #c59a5b;
    --qa-brown: #5b3b24;
    --qa-brown-deep: #352116;
    --qa-ink: #2c211a;
    --qa-muted: #7a6555;
    --qa-line: rgba(91, 59, 36, 0.16);
    --qa-shadow: 0 28px 80px rgba(55, 32, 18, 0.24);
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 9200;
    font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--qa-ink);
}

.qa-agent *,
.qa-agent *::before,
.qa-agent *::after {
    box-sizing: border-box;
}

.qa-agent__launcher {
    position: relative;
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border: 3px solid rgba(255, 250, 242, 0.96);
    border-radius: 999px;
    background: linear-gradient(145deg, #704a2f 0%, var(--qa-brown) 58%, #3f281a 100%);
    color: #fff8ed;
    box-shadow: 0 14px 36px rgba(65, 39, 22, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
    isolation: isolate;
}

.qa-agent__launcher::before {
    content: '';
    position: absolute;
    inset: -8px;
    z-index: -1;
    border: 1px solid rgba(197, 154, 91, 0.7);
    border-radius: inherit;
    animation: qa-agent-pulse 2.6s ease-out infinite;
}

.qa-agent__launcher:hover {
    transform: translateY(-3px) scale(1.025);
    box-shadow: 0 18px 44px rgba(65, 39, 22, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.qa-agent__launcher:focus-visible,
.qa-agent__close:focus-visible,
.qa-agent__send:focus-visible,
.qa-agent__quick:focus-visible,
.qa-agent__input:focus-visible {
    outline: 3px solid rgba(197, 154, 91, 0.5);
    outline-offset: 3px;
}

.qa-agent__launcher-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
}

.qa-agent__launcher-mark svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.qa-agent__online-dot {
    position: absolute;
    top: 2px;
    right: 3px;
    width: 14px;
    height: 14px;
    border: 3px solid #fffaf2;
    border-radius: 999px;
    background: #68a66b;
}

.qa-agent__panel {
    position: absolute;
    right: 0;
    bottom: 84px;
    width: min(390px, calc(100vw - 28px));
    height: min(640px, calc(100vh - 128px));
    min-height: 460px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    border: 1px solid rgba(91, 59, 36, 0.2);
    border-radius: 28px;
    background: rgba(255, 250, 242, 0.98);
    box-shadow: var(--qa-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.975);
    transform-origin: right bottom;
    transition: opacity 190ms ease, transform 220ms ease, visibility 190ms ease;
}

.qa-agent__panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.qa-agent__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 92px;
    padding: 17px 18px;
    overflow: hidden;
    color: #fffaf2;
    background: linear-gradient(125deg, #3d271a 0%, #5b3b24 54%, #7b5538 100%);
}

.qa-agent__header::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    top: -88px;
    right: 42px;
    border: 1px solid rgba(231, 209, 176, 0.25);
    border-radius: 999px;
}

.qa-agent__avatar {
    position: relative;
    z-index: 1;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 250, 242, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #efd9b8;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 25px;
    font-weight: 600;
}

.qa-agent__heading {
    position: relative;
    z-index: 1;
    min-width: 0;
    flex: 1;
}

.qa-agent__eyebrow {
    margin: 0 0 2px;
    color: #e7d1b0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.qa-agent__title {
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 23px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.qa-agent__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    color: rgba(255, 250, 242, 0.75);
    font-size: 11px;
}

.qa-agent__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #86bc82;
}

.qa-agent__close {
    position: relative;
    z-index: 2;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fffaf2;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.qa-agent__close:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: rotate(4deg);
}

.qa-agent__conversation {
    overflow-y: auto;
    padding: 20px 16px 12px;
    background:
        radial-gradient(circle at 100% 0, rgba(231, 209, 176, 0.26), transparent 32%),
        linear-gradient(180deg, #fffdf9 0%, #fffaf2 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(91, 59, 36, 0.25) transparent;
}

.qa-agent__message {
    display: flex;
    margin: 0 0 12px;
    animation: qa-agent-message-in 180ms ease both;
}

.qa-agent__message--user {
    justify-content: flex-end;
}

.qa-agent__bubble {
    max-width: 86%;
    padding: 12px 14px;
    border: 1px solid var(--qa-line);
    border-radius: 18px 18px 18px 6px;
    background: var(--qa-paper);
    box-shadow: 0 5px 16px rgba(74, 46, 27, 0.06);
    color: var(--qa-ink);
    font-size: 13px;
    line-height: 1.58;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.qa-agent__message--user .qa-agent__bubble {
    border-color: transparent;
    border-radius: 18px 18px 6px 18px;
    background: var(--qa-brown);
    color: #fffaf2;
    box-shadow: 0 7px 20px rgba(74, 46, 27, 0.18);
}

.qa-agent__bubble a {
    color: #855a35;
    font-weight: 600;
    text-underline-offset: 2px;
}

.qa-agent__quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 4px 0 15px;
}

.qa-agent__quick {
    border: 1px solid rgba(91, 59, 36, 0.2);
    border-radius: 999px;
    padding: 8px 11px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--qa-brown);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.qa-agent__quick:hover {
    border-color: var(--qa-gold);
    background: #fff;
    transform: translateY(-1px);
}

.qa-agent__typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 55px;
}

.qa-agent__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9b795a;
    animation: qa-agent-typing 1.1s ease-in-out infinite;
}

.qa-agent__typing span:nth-child(2) { animation-delay: 120ms; }
.qa-agent__typing span:nth-child(3) { animation-delay: 240ms; }

.qa-agent__composer {
    padding: 12px 14px max(13px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--qa-line);
    background: rgba(255, 255, 255, 0.96);
}

.qa-agent__form {
    display: flex;
    align-items: flex-end;
    gap: 9px;
}

.qa-agent__input {
    width: 100%;
    min-height: 46px;
    max-height: 108px;
    resize: none;
    border: 1px solid rgba(91, 59, 36, 0.18);
    border-radius: 16px;
    padding: 12px 14px;
    background: #fffaf4;
    color: var(--qa-ink);
    font: inherit;
    font-size: 13px;
    line-height: 1.45;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.qa-agent__input::placeholder { color: #a18d7c; }

.qa-agent__input:focus {
    border-color: rgba(185, 139, 72, 0.72);
    box-shadow: 0 0 0 3px rgba(185, 139, 72, 0.1);
}

.qa-agent__send {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 15px;
    background: var(--qa-brown);
    color: #fffaf2;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.qa-agent__send:hover:not(:disabled) {
    background: var(--qa-brown-deep);
    transform: translateY(-1px);
}

.qa-agent__send:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.qa-agent__send svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.qa-agent__privacy {
    margin: 8px 3px 0;
    color: var(--qa-muted);
    font-size: 9.5px;
    line-height: 1.35;
    text-align: center;
}

@keyframes qa-agent-pulse {
    0% { opacity: 0.75; transform: scale(0.9); }
    70%, 100% { opacity: 0; transform: scale(1.18); }
}

@keyframes qa-agent-message-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes qa-agent-typing {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 560px) {
    .qa-agent {
        right: max(15px, env(safe-area-inset-right));
        bottom: max(15px, env(safe-area-inset-bottom));
    }

    .qa-agent__launcher {
        width: 62px;
        height: 62px;
    }

    .qa-agent__panel {
        position: fixed;
        inset: auto 8px 86px 8px;
        width: auto;
        height: min(680px, calc(100dvh - 106px));
        min-height: 420px;
        border-radius: 24px;
        transform-origin: center bottom;
    }
}

@media (max-height: 620px) and (min-width: 561px) {
    .qa-agent__panel {
        height: calc(100vh - 112px);
        min-height: 390px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qa-agent__launcher::before,
    .qa-agent__message,
    .qa-agent__typing span {
        animation: none;
    }

    .qa-agent__launcher,
    .qa-agent__panel,
    .qa-agent__close,
    .qa-agent__send,
    .qa-agent__quick {
        transition: none;
    }
}
