.acw-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#acwRoot,
#acwRoot * {
    box-sizing: border-box;
}

.acw-toggle {
    position: relative;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: #00bbbd;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    font-size: 24px;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.acw-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.acw-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.acw-toggle:focus-visible,
.acw-send:focus-visible,
.acw-input:focus-visible {
    outline: 2px solid #00bbbd;
    outline-offset: 2px;
}

.acw-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: min(420px, calc(100vw - 24px));
    max-height: 520px;
    border: 1px solid #dce6f0;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transform-origin: right bottom;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.acw-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.acw-header {
    padding: 14px 16px;
    background: #00bbbd;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.01em;
}

.acw-messages {
    padding: 16px;
    background: linear-gradient(180deg, #f6fbfb 0%, #f4f7fa 100%);
    overflow-y: auto;
    min-height: 220px;
    max-height: 340px;
}

.acw-message {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.acw-message:last-child {
    margin-bottom: 0;
}

.acw-message p {
    position: relative;
    margin: 0;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.acw-message-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
}

.acw-bubble-wrap {
    max-width: calc(100% - 36px);
    position: relative;
}

.acw-message-meta {
    margin: 0 0 4px 2px;
    font-size: 12px;
    line-height: 1.2;
    color: #7f8c99;
    letter-spacing: 0.01em;
}

.acw-message-source {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.4;
    color: #768391;
}

.acw-message-source a {
    color: #00bbbd;
    text-decoration: underline;
    word-break: break-all;
}

.acw-message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #d9ecec;
    border-radius: 10px;
    background: #f7fcfc;
}

#acwRoot .acw-message-suggestions .acw-quick-btn {
    border: 1px solid #9fdfe0;
    background: #fff;
    color: #006d6f;
    border-radius: 999px;
    padding: 8px 12px;
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease,
        color 0.2s ease, transform 0.15s ease;
}

#acwRoot .acw-message-suggestions .acw-quick-btn:hover {
    background: #e9fbfb;
    border-color: #00bbbd;
    color: #005c5e;
    transform: translateY(-1px);
}

#acwRoot .acw-message-suggestions .acw-quick-btn:focus-visible {
    outline: 2px solid #00bbbd;
    outline-offset: 2px;
}

.acw-message.-bot p {
    background: #fff;
    border: 1px solid #dbe4ee;
    color: #223042;
    border-bottom-left-radius: 0;
}

.acw-message.-bot .acw-message-icon {
    background: #e8f7f7;
    color: #007f81;
}

.acw-message.-user {
    justify-content: flex-end;
}

.acw-message.-user p {
    background: #00bbbd;
    color: #fff;
    border-bottom-right-radius: 0;
}

.acw-message.-user .acw-message-icon {
    order: 2;
    background: rgba(0, 187, 189, 0.16);
    color: #007f81;
}

.acw-message.-user .acw-bubble-wrap {
    order: 1;
}

.acw-message.-user .acw-message-meta {
    text-align: right;
    margin: 0 2px 4px 0;
}


.acw-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.acw-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 2px 0 12px 42px;
    color: #7f8c99;
    font-size: 12px;
}

.acw-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #98a6b5;
    animation: acwTypingPulse 1s infinite ease-in-out;
}

.acw-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.acw-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

.acw-typing-text {
    margin-left: 3px;
}

@keyframes acwTypingPulse {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

#acwRoot .acw-quick-questions .acw-quick-btn {
    border: 1px solid #b9e9ea;
    background: #ffffff;
    color: #007f81;
    border-radius: 999px;
    padding: 8px 12px;
    margin: 0;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#acwRoot .acw-quick-questions .acw-quick-btn:hover {
    background: #e9fbfb;
    border-color: #00bbbd;
    color: #006d6f;
}

.acw-form {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #e5edf5;
    background: #fff;
}

#acwRoot .acw-form .acw-input[type="text"] {
    flex: 1;
    width: 100%;
    margin: 0;
    border: 1px solid #ccd8e6;
    border-radius: 10px;
    padding: 15px 17px;
    font-size: 15px;
    line-height: 1.4;
    background: #fff;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#acwRoot .acw-form .acw-input[type="text"]::placeholder {
    color: #8b97a4;
}

#acwRoot .acw-form .acw-input[type="text"]:focus {
    border-color: #00bbbd;
    box-shadow: 0 0 0 3px rgba(0, 187, 189, 0.18);
    outline: none;
}

#acwRoot .acw-form .acw-send {
    border: 0;
    margin: 0;
    line-height: 1;
    border-radius: 10px;
    background: #00bbbd;
    color: #fff;
    padding: 0 16px;
    min-width: 60px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 700;
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.acw-send:hover:not(:disabled) {
    background: #00a9ab;
    transform: translateY(-1px);
}

.acw-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.acw-form-link {
    color: #00bbbd;
    text-decoration: underline;
}

@media (max-width: 480px) {
    .acw-root {
        right: 12px;
        bottom: 12px;
    }

    .acw-panel {
        right: 0;
        width: min(420px, calc(100vw - 20px));
    }
}
