/* ===== Auttomaton Helper (contained) ===== */
#auttomaton-helper {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 999999;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

#auttomaton-helper * {
    box-sizing: border-box;
}

.ah-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* Squircle icon button */
.ah-fab {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 18px;
    /* squircle-ish */
    background: #1d1c57;
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
    transition: transform .18s ease, box-shadow .18s ease;
    outline: none;
}

.ah-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
}

.ah-fab:active {
    transform: translateY(0);
}

.ah-fab svg {
    width: 26px;
    height: 26px;
}

/* Balloon teaser */
.ah-balloon {
    display: none;
    max-width: 270px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.10);
    border-radius: 16px;
    padding: 10px 12px;
    color: #0f172a;
    font-size: 13px;
    line-height: 1.25;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.10);
    position: relative;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.ah-balloon.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ah-balloon::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: -8px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-right: 1px solid rgba(15, 23, 42, 0.10);
    border-bottom: 1px solid rgba(15, 23, 42, 0.10);
    transform: rotate(45deg);
}

.ah-balloon .ah-balloon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ah-close {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 8px;
    color: rgba(15, 23, 42, 0.55);
    font-size: 16px;
    line-height: 1;
}

.ah-close:hover {
    background: rgba(15, 23, 42, 0.06);
}

/* Chat panel */
.ah-panel {
    display: none;
    width: 320px;
    max-width: calc(100vw - 36px);
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.10);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.ah-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ah-header {
    padding: 12px 12px;
    background: #8280ff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ah-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ah-title strong {
    font-size: 13px;
    font-weight: 650;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ah-title span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.70);
}

.ah-min {
    border: 0;
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}

.ah-min:hover {
    background: rgba(255, 255, 255, 0.16);
}

.ah-body {
    padding: 12px;
    background: #f7f8fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(420px, 55vh);
    overflow: auto;
}

.ah-msg {
    display: inline-flex;
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.25;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.ah-msg.bot {
    align-self: flex-start;
    background: #ffffff;
    color: #0f172a;
    border-top-left-radius: 8px;
}

.ah-msg.user {
    align-self: flex-end;
    background: #0f172a;
    color: #fff;
    border-top-right-radius: 8px;
    border-color: rgba(255, 255, 255, 0.08);
}

.ah-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.ah-btn {
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: #ffffff;
    color: #0f172a;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.ah-btn:hover {
    background: rgba(15, 23, 42, 0.04);
    transform: translateY(-1px);
}

.ah-btn:active {
    transform: translateY(0);
}

.ah-btn.primary {
    background: #8280ff;
    border-color: #8280ff;
    color: #ffffff;
}

.ah-btn.primary:hover {
    background: #7573ff;
    border-color: #7573ff;
}

/* Typing dots */
.ah-typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
    align-self: flex-start;
    width: fit-content;
}

.ah-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.45);
    animation: ah-bounce 1.1s infinite ease-in-out;
}

.ah-dot:nth-child(2) {
    animation-delay: .15s;
}

.ah-dot:nth-child(3) {
    animation-delay: .30s;
}

@keyframes ah-bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .45;
    }

    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    .ah-fab,
    .ah-panel,
    .ah-balloon {
        transition: none;
    }

    .ah-dot {
        animation: none;
    }
}