.chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: Arial, sans-serif;
}

.chat-widget [hidden] {
    display: none;
}

.chat-toggle,
.chat-close,
.chat-form button {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.chat-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 0 20px;
    border-radius: 28px;
    background: #173f35;
    box-shadow: 0 8px 24px rgba(12, 35, 29, 0.25);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.chat-toggle:hover {
    background: #245b4b;
    transform: translateY(-2px);
}

.chat-toggle:focus-visible,
.chat-close:focus-visible,
.chat-form button:focus-visible,
.chat-form input:focus-visible {
    outline: 3px solid #c7953d;
    outline-offset: 3px;
}

.chat-toggle-icon {
    font-size: 1.25rem;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100vw - 32px));
    height: min(480px, calc(100vh - 110px));
    min-height: 320px;
    overflow: hidden;
    border: 1px solid #e4e8e2;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(12, 35, 29, 0.24);
}

.chat-header {
    position: static;
    top: auto;
    left: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: auto;
    height: auto;
    z-index: auto;
    padding: 18px 20px;
    border: 0;
    background: #173f35;
    color: #fff;
}

.chat-header h2 {
    margin: 0 0 4px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-header p {
    margin: 0;
    color: #e1e9e4;
    font-size: 0.78rem;
}

.chat-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 18px 14px;
    background: #f7f8f5;
}

.chat-message {
    max-width: 86%;
    margin: 0;
    padding: 11px 13px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.chat-message-assistant {
    align-self: flex-start;
    border: 1px solid #e5e9e3;
    border-bottom-left-radius: 4px;
    background: #fff;
    color: #26342e;
}

.chat-message-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: #e8f0e9;
    color: #173f35;
}

.chat-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e9e3;
    background: #fff;
}

.chat-form input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #d9dfd8;
    border-radius: 8px;
    color: #26342e;
    font: inherit;
}

.chat-form input::placeholder {
    color: #737d76;
}

.chat-form button {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    background: #bf1e2e;
    color: #fff;
    font-weight: 700;
    transition: background-color 0.2s ease;
}

.chat-form button:hover {
    background: #951522;
}

.chat-fallback {
    margin: 0;
    padding: 0 14px 14px;
    background: #fff;
    color: #59655e;
    font-size: 0.78rem;
    line-height: 1.5;
}

.chat-fallback a {
    color: #173f35;
    font-weight: 700;
}

.chat-fallback a:hover {
    color: #951522;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@media (max-width: 480px) {
    .chat-widget {
        right: 16px;
        bottom: 16px;
    }

    .chat-panel {
        height: min(480px, calc(100vh - 100px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-toggle {
        transition: none;
    }
}