.ded-ai-chat {
    max-width: 980px;
    margin: 24px auto;
    padding: 0 16px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ded-ai-chat-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 18px 20px 18px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(12, 94, 54, 0.12);
}

/* HEADER */

.ded-ai-chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.ded-ai-chat-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 20%, #fdfdfd, #e6f6ec);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid rgba(12, 94, 54, 0.18);
    flex-shrink: 0;
}

.ded-ai-chat-avatar img {
    width: 110%;
    height: auto;
}

.ded-ai-chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ded-ai-chat-title {
    font-weight: 600;
    font-size: 18px;
    color: #0b3b26;
}

.ded-ai-chat-subtitle {
    font-size: 13px;
    color: #55756a;
}

/* MESSAGES */

.ded-ai-chat-messages {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: #f8faf8;
    border: 1px dashed rgba(12, 94, 54, 0.08);
}

.ded-ai-chat-message {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
}

.ded-ai-chat-message + .ded-ai-chat-message {
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

.ded-ai-chat-message-user {
    color: #0b3b26;
    background: linear-gradient(90deg, rgba(219, 238, 228, 0.55), rgba(255, 255, 255, 0));
}

.ded-ai-chat-message-assistant {
    color: #17352a;
    background: linear-gradient(90deg, rgba(232, 247, 241, 0.9), rgba(255, 255, 255, 0));
}

/* STATUS "ИИ думает..." */

.ded-ai-chat-status {
    min-height: 18px;
    font-size: 12px;
    color: #2d8a57;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ded-ai-chat-status.active {
    opacity: 1;
}

.ded-ai-chat-status::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #2d8a57;
    border-top-color: transparent;
    animation: ded-ai-spin 0.8s linear infinite;
}

@keyframes ded-ai-spin {
    to {
        transform: rotate(360deg);
    }
}

/* FORM */

.ded-ai-chat-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ded-ai-chat-label {
    font-size: 13px;
    color: #4b6658;
}

.ded-ai-chat-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(12, 94, 54, 0.18);
    padding: 10px 12px;
    resize: vertical;
    min-height: 70px;
    font-size: 14px;
    font-family: inherit;
}

.ded-ai-chat-input:focus {
    outline: 2px solid rgba(12, 94, 54, 0.25);
    outline-offset: 1px;
}

/* BOTTOM ROW: TTS + BUTTONS */

.ded-ai-chat-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ded-ai-chat-tts {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #3f5f52;
    flex: 1 1 200px;
}

.ded-ai-chat-tts input {
    transform: translateY(1px);
}

.ded-ai-chat-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* BUTTONS */

.ded-ai-chat-btn {
    border-radius: 999px;
    border: 1px solid rgba(12, 94, 54, 0.18);
    padding: 8px 14px;
    background: #ffffff;
    font-size: 13px;
    cursor: pointer;
    color: #105637;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.ded-ai-chat-btn:hover {
    background: #ebf7ef;
    box-shadow: 0 2px 8px rgba(12, 94, 54, 0.12);
}

.ded-ai-chat-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.ded-ai-chat-send {
    background: #0f7b45;
    color: #ffffff;
    border-color: #0f7b45;
}

.ded-ai-chat-send:hover {
    background: #0c6a3a;
}

.ded-ai-chat-send:disabled {
    opacity: 0.6;
    cursor: default;
    box-shadow: none;
}

/* MOBILE */

@media (max-width: 640px) {
    .ded-ai-chat-card {
        padding: 14px 12px 14px;
    }

    .ded-ai-chat-header {
        align-items: flex-start;
    }

    .ded-ai-chat-bottom-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ded-ai-chat-buttons {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .ded-ai-chat-btn {
        flex: 0 0 auto;
    }
}
