.chat-btn-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(76,175,80,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: chatBtnShake 2.5s ease-in-out infinite;
}
.chat-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(76,175,80,0.5); animation: none; }
.chat-btn.chat-open { animation: none; }
.chat-btn-curved {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 90px;
    height: 90px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: chatTextSpin 6s ease-in-out infinite;
    overflow: visible;
}
.chat-btn-curved text {
    font-size: 9px;
    font-weight: 700;
    fill: #388E3C;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.5px;
    text-transform: none;
}
.chat-btn-wrap.hidden .chat-btn-curved { display: none; }
@keyframes chatTextSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    83% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes chatBtnShake {
    0%, 100% { transform: rotate(0deg); }
    5% { transform: rotate(-12deg); }
    10% { transform: rotate(12deg); }
    15% { transform: rotate(-10deg); }
    20% { transform: rotate(10deg); }
    25% { transform: rotate(-6deg); }
    30% { transform: rotate(0deg); }
}
.chat-btn__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.chat-btn__badge.show { display: flex; }

.chat-box {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 340px;
    max-height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 9991;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.chat-box.open { display: flex; }

.chat-box__header {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-box__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.chat-box__info { flex: 1; }
.chat-box__name { font-weight: 600; font-size: 15px; }
.chat-box__status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; }
.chat-box__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #aaa;
    display: inline-block;
}
.chat-box__status-dot.online { background: #69f0ae; }
.chat-box__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
}
.chat-box__close:hover { opacity: 1; }

.chat-box__form {
    padding: 14px 16px;
    flex: 1;
    overflow-y: auto;
}
.chat-box__form h4 {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
.chat-box__form p {
    margin: 0 0 8px;
    font-size: 12px;
    color: #777;
}
.chat-box__form label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin-bottom: 2px;
}
.chat-box__form input,
.chat-box__form textarea,
.chat-box__form select {
    width: 100%;
    padding: 6px 10px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 6px;
    outline: none;
    transition: border 0.2s;
    font-family: inherit;
    background: #fff;
}
.chat-box__form input:focus,
.chat-box__form textarea:focus,
.chat-box__form select:focus { border-color: #4CAF50; }
.chat-box__form textarea { resize: none; height: 44px; }
.chat-box__form-submit {
    width: 100%;
    padding: 8px;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.chat-box__form-submit:hover { opacity: 0.9; }
.chat-box__form-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-box__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f7f5;
    min-height: 300px;
    max-height: 360px;
}
.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}
.chat-msg--visitor {
    align-self: flex-end;
    background: linear-gradient(135deg, #4CAF50, #43A047);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg--admin {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}
.chat-msg--system {
    align-self: center;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 20px;
    max-width: 90%;
    text-align: center;
}
.chat-msg__sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.85;
}
.chat-msg__time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 3px;
    text-align: right;
}
.chat-msg--admin .chat-msg__time { text-align: left; }

.chat-box__input {
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: flex-end;
}
.chat-box__input textarea {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13px;
    resize: none;
    height: 38px;
    max-height: 38px;
    overflow: hidden;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}
.chat-box__input textarea:focus { border-color: #4CAF50; }
.chat-box__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}
.chat-box__send:hover { opacity: 0.9; }
.chat-box__send:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-box__typing {
    padding: 6px 16px 8px;
    font-size: 12px;
    color: #888;
    font-style: italic;
    display: none;
    background: #f5f7f5;
    align-items: center;
    gap: 4px;
}
.chat-box__typing.show { display: flex; }
.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #999;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-box__end-chat {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 14px;
    display: none;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
    white-space: nowrap;
}
.chat-box__end-chat:hover { background: rgba(255,255,255,0.35); }

.chat-box__closed-banner {
    padding: 12px 16px;
    background: #fff3e0;
    color: #e65100;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    display: none;
}

.chat-box__feedback {
    padding: 0;
    display: none;
    background: #fff;
    overflow-y: auto;
    flex: 1;
    align-items: center;
    justify-content: center;
}
.chat-feedback {
    padding: 24px 20px;
    text-align: center;
    width: 100%;
}
.chat-feedback__title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}
.chat-feedback__subtitle {
    font-size: 12px;
    color: #888;
    margin-bottom: 16px;
}
.chat-feedback__stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}
.chat-feedback__star {
    font-size: 34px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    line-height: 1;
}
.chat-feedback__star:hover,
.chat-feedback__star.hover { color: #ffc107; transform: scale(1.15); }
.chat-feedback__star.active { color: #ffc107; }
.chat-feedback__label {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    min-height: 18px;
}
.chat-feedback__text {
    width: 100%;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    resize: none;
    outline: none;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.chat-feedback__text:focus { border-color: #4CAF50; }
.chat-feedback__submit {
    margin-top: 6px;
    margin-bottom: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
}
.chat-feedback__submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.chat-feedback__skip {
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: underline;
}
.chat-feedback__skip:hover { color: #666; }
.chat-feedback__thanks {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

@media (max-width: 480px) {
    .chat-box {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    .chat-btn-wrap { bottom: 12px; right: 12px; width: 74px; height: 74px; }
    .chat-btn { width: 50px; height: 50px; font-size: 20px; }
    .chat-btn-curved { width: 74px; height: 74px; }
    .chat-btn-curved text { font-size: 8px; }
}
