/**
 * MST Messenger - Frontend Styles v3.0.0
 * Popup чат на странице тура - УЛУЧШЕННЫЙ ДИЗАЙН
 * Author: Telegram @l1ghtsun
 */

/* =====================================
   CSS VARIABLES - Modern Design System
   ===================================== */
:root {
    /* Primary brand colors */
    --mst-chat-primary: #9952E0;
    --mst-chat-primary-light: #B87FED;
    --mst-chat-primary-dark: #7A3DB8;
    --mst-chat-primary-glow: rgba(153, 82, 224, 0.25);

    /* Backgrounds */
    --mst-chat-bg: #ffffff;
    --mst-chat-bg-secondary: #F8FAFC;
    --mst-chat-bg-tertiary: #F1F5F9;

    /* Text */
    --mst-chat-text: #0F172A;
    --mst-chat-text-secondary: #475569;
    --mst-chat-text-muted: #94A3B8;

    /* Borders & Dividers */
    --mst-chat-border: #E2E8F0;
    --mst-chat-border-light: #F1F5F9;

    /* Message bubbles */
    --mst-chat-message-user: #F1F5F9;
    --mst-chat-message-guide: linear-gradient(135deg, #9952E0 0%, #7A3DB8 100%);

    /* Status colors */
    --mst-chat-success: #10B981;
    --mst-chat-success-bg: #ECFDF5;
    --mst-chat-error: #EF4444;
    --mst-chat-error-bg: #FEF2F2;
    --mst-chat-warning: #F59E0B;

    /* Shadows */
    --mst-chat-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --mst-chat-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --mst-chat-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --mst-chat-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --mst-chat-shadow-glow: 0 0 40px rgba(153, 82, 224, 0.3);

    /* Border radius */
    --mst-chat-radius: 20px;
    --mst-chat-radius-lg: 24px;
    --mst-chat-radius-md: 16px;
    --mst-chat-radius-sm: 12px;

    /* Transitions */
    --mst-chat-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --mst-chat-transition-fast: all 0.15s ease;

    /* FIXED: dynamic bottom offset for mobile sticky bars */
    --mst-chat-bottom-obstruction: 0px;
}

/* =====================================
   TRIGGER BUTTON (Floating) - Premium look
   ===================================== */
.mst-chat-trigger {
    position: fixed;
    bottom: calc(24px + var(--mst-chat-bottom-obstruction, 0px) + env(safe-area-inset-bottom, 0px));
    right: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    background: var(--mst-chat-message-guide);
    color: #fff;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: var(--mst-chat-shadow-xl), var(--mst-chat-shadow-glow);
    transition: var(--mst-chat-transition);
    overflow: hidden;
}

.mst-chat-trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.mst-chat-trigger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 30px 60px -15px rgba(124, 58, 237, 0.4), var(--mst-chat-shadow-glow);
}

.mst-chat-trigger:active {
    transform: translateY(-1px) scale(0.98);
}

.mst-chat-trigger svg {
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.mst-chat-trigger-text {
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* FIXED: badge должен позиционироваться корректно на любых триггерах */
#mst-chat-trigger,
.mst-chat-trigger,
[data-mst-chat-trigger] {
    position: relative;
}

/* Notification badge on trigger */
.mst-chat-trigger-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    background: var(--mst-chat-error);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #fff;
    animation: mstBadgePulse 2s ease-in-out infinite;
}

@keyframes mstBadgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Hide trigger when popup is open */
.mst-chat-popup[style*="block"]~.mst-chat-trigger {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translateY(20px);
}

/* =====================================
   POPUP CONTAINER
   ===================================== */
.mst-chat-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mst-chat-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: mstChatFadeIn 0.25s ease-out;
}

/* CRITICAL FIX: In docked/draggable mode, popup container must NOT block page clicks */
.mst-chat-popup--docked,
.mst-chat-popup--draggable {
    pointer-events: none;
}

.mst-chat-popup--docked .mst-chat-modal,
.mst-chat-popup--draggable .mst-chat-modal {
    pointer-events: auto;
}

@keyframes mstChatFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* =====================================
   MODAL - Glass morphism design
   ===================================== */
.mst-chat-modal {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    background: var(--mst-chat-bg);
    border-radius: var(--mst-chat-radius-lg);
    box-shadow: var(--mst-chat-shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mstChatSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none;
    /* FIXED: min-height для предотвращения сжатия */
    min-height: 400px;
}

@keyframes mstChatSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =====================================
   HEADER - Clean White Design
   ===================================== */
.mst-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: var(--mst-chat-bg);
    color: var(--mst-chat-text);
    position: relative;
    border-bottom: 1px solid var(--mst-chat-border-light);
}

.mst-chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.mst-chat-avatar {
    width: 48px;
    height: 48px;
    background: var(--mst-chat-primary-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--mst-chat-primary-light);
    overflow: hidden;
    flex-shrink: 0;
}

.mst-chat-avatar svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.mst-chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mst-chat-header-text h3,
.mst-chat-header-text .mst-chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

/* =====================================
   RECENT NOTIFICATIONS BUTTON (header)
   ===================================== */
.mst-chat-recent-notifs-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
}

.mst-chat-recent-notifs-btn:hover {
    background: var(--mst-chat-primary-glow);
    color: var(--mst-chat-primary);
}

.mst-chat-notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    background: #EF4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--mst-chat-bg);
}

/* Notifications dropdown panel */
.mst-chat-notifs-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--mst-chat-bg);
    border: 1px solid var(--mst-chat-border);
    border-radius: var(--mst-chat-radius-sm);
    box-shadow: var(--mst-chat-shadow-xl);
    z-index: 10000;
    padding: 8px;
    animation: mstChatSlideUp 0.2s ease;
}

.mst-chat-notifs-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--mst-chat-text);
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--mst-chat-border-light);
    margin-bottom: 4px;
}

.mst-chat-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.15s ease;
    cursor: default;
}

.mst-chat-notif-item:hover {
    background: var(--mst-chat-bg-secondary);
}

.mst-chat-notif-item-icon {
    width: 32px;
    height: 32px;
    background: var(--mst-chat-primary-glow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mst-chat-primary);
    flex-shrink: 0;
}

.mst-chat-notif-item-content {
    flex: 1;
    min-width: 0;
}

.mst-chat-notif-item-text {
    font-size: 13px;
    line-height: 1.4;
    color: var(--mst-chat-text);
}

.mst-chat-notif-item-time {
    font-size: 11px;
    color: var(--mst-chat-text-muted);
    margin-top: 2px;
}

.mst-chat-notifs-empty {
    text-align: center;
    padding: 20px;
    color: var(--mst-chat-text-muted);
    font-size: 13px;
}

.mst-chat-guide-name {
    font-size: 13px;
    color: #c8c8c8;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Онлайн-статус индикатор - ДИНАМИЧЕСКИЙ */
.mst-chat-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.mst-chat-online-dot.online {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
    animation: mstOnlinePulse 2s ease-in-out infinite;
}

.mst-chat-online-dot.offline {
    background: #94A3B8;
    box-shadow: none;
}

@keyframes mstOnlinePulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
    }
}

.mst-chat-status-text {
    font-size: 11px;
    color: var(--mst-chat-text-muted);
    margin-left: 2px;
}

.mst-chat-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
    position: relative;
    z-index: 9999;
    /* FIXED: высокий z-index для мобильного */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mst-chat-close:hover {
    background: var(--mst-chat-border);
    color: var(--mst-chat-text);
    transform: rotate(90deg);
}

.mst-chat-close:active {
    transform: scale(0.95);
    background: var(--mst-chat-border);
}

/* =====================================
   TOUR INFO BAR
   ===================================== */
.mst-chat-tour-info {
    padding: 12px 20px;
    background: var(--mst-chat-bg-secondary);
    border-bottom: 1px solid var(--mst-chat-border-light);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mst-chat-tour-label {
    color: var(--mst-chat-text-muted);
    font-weight: 500;
}

.mst-chat-tour-title {
    color: var(--mst-chat-text);
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mst-chat-tour-icon {
    width: 28px;
    height: 28px;
    background: var(--mst-chat-primary-glow);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mst-chat-primary);
    flex-shrink: 0;
}

/* =====================================
   MESSAGES CONTAINER
   ===================================== */
.mst-chat-messages {
    flex: 1 1 0;
    min-height: 0;
    /* FIXED v5.5.1: critical for flex to allow shrinking in docked mode */
    max-height: none;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--mst-chat-bg);
}

/* Custom Scrollbar */
.mst-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.mst-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mst-chat-messages::-webkit-scrollbar-thumb {
    background: var(--mst-chat-border);
    border-radius: 3px;
}

.mst-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--mst-chat-text-muted);
}

/* Welcome Message */
.mst-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--mst-chat-text-secondary);
}

.mst-chat-welcome-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--mst-chat-primary-glow) 0%, rgba(124, 58, 237, 0.05) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mst-chat-primary);
    position: relative;
}

.mst-chat-welcome-icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px dashed var(--mst-chat-primary-light);
    opacity: 0.3;
    animation: mstWelcomeRotate 20s linear infinite;
}

@keyframes mstWelcomeRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.mst-chat-welcome h4 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--mst-chat-text);
}

.mst-chat-welcome p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    max-width: 280px;
    margin: 0 auto;
}

/* Message Bubbles */
.mst-chat-message {
    max-width: 85%;
    font-size: 14px;
    line-height: 1.55;
    animation: mstChatMessageIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* Guide/Admin message with avatar */
.mst-chat-message--guide,
.mst-chat-message--admin {
    align-self: flex-start;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.mst-chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid var(--mst-chat-primary-light);
}

.mst-chat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mst-chat-message-content {
    flex: 1;
}

.mst-chat-message-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--mst-chat-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Роль отвечающего (Админ/Гид) */
.mst-chat-sender-role {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 4px;
    color: #fff;
}

.mst-chat-sender-role--admin {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
}

.mst-chat-sender-role--guide {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

/* Order notification — жёлтая карточка с кнопкой "Посмотреть билет" */
.mst-chat-message--order-notification {
    align-self: center !important;
    width: 100%;
    max-width: 100%;
    padding: 0 16px;
    margin: 12px 0;
}

.mst-chat-order-notification-bubble {
    background: linear-gradient(135deg, #FEF9C3 0%, #FDE68A 100%);
    border: 2px solid #F59E0B;
    border-radius: var(--mst-chat-radius-md);
    padding: 18px 20px;
    color: #78350F;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
    text-align: center;
}

.mst-chat-order-notification-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.mst-chat-order-notification-bubble .mst-chat-msg-text {
    font-size: 13px;
    line-height: 1.6;
    color: #78350F;
}

.mst-chat-order-notification-bubble strong,
.mst-chat-order-notification-bubble b {
    color: #92400E;
}

.mst-chat-order-ticket-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 10px 22px;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: #fff !important;
    font-size: 14px;
    font-weight: 700;
    border-radius: 100px;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
    transition: all 0.2s ease;
}

.mst-chat-order-ticket-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.4);
    color: #fff !important;
}

.mst-chat-order-notification-bubble .mst-chat-message-time {
    color: #92400E;
    opacity: 0.6;
}

/* Уведомление о другом отвечающем */
.mst-chat-responder-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 8px 20px;
    background: linear-gradient(135deg, rgba(153, 82, 224, 0.1) 0%, rgba(124, 58, 237, 0.05) 100%);
    border: 1px solid rgba(153, 82, 224, 0.2);
    border-radius: var(--mst-chat-radius-sm);
    font-size: 12px;
    color: var(--mst-chat-primary);
    animation: mstNoticeSlideIn 0.3s ease-out;
}

.mst-chat-responder-notice svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

@keyframes mstNoticeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mst-chat-message-bubble {
    padding: 14px 18px;
    border-radius: var(--mst-chat-radius-md);
    background: var(--mst-chat-message-guide);
    color: #fff;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.mst-chat-message--user {
    align-self: flex-end;
}

.mst-chat-message--user .mst-chat-message-bubble {
    background: var(--mst-chat-message-user);
    color: var(--mst-chat-text);
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: var(--mst-chat-radius-md);
    box-shadow: none;
}

@keyframes mstChatMessageIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* New message highlight animation */
.mst-chat-message--new {
    animation: mstNewMessage 0.5s ease-out;
}

@keyframes mstNewMessage {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    50% {
        transform: translateY(-5px) scale(1.02);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.mst-chat-message-time {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.65;
}

/* =====================================
   FORM - Clean and modern
   ===================================== */
.mst-chat-form {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--mst-chat-border-light);
    background: var(--mst-chat-bg-secondary);
    /* FIXED: Форма не должна сжиматься */
    flex-shrink: 0;
}

.mst-chat-guest-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    padding: 16px;
    background: var(--mst-chat-bg);
    border-radius: var(--mst-chat-radius-md);
    border: 1px solid var(--mst-chat-border-light);
    box-shadow: var(--mst-chat-shadow-sm);
}

/* Override theme input styles (XStore, Divi, etc.) */
.mst-chat-popup .mst-chat-input,
.mst-chat-popup .mst-chat-textarea,
.mst-chat-form .mst-chat-input,
.mst-chat-form .mst-chat-textarea {
    width: 100% !important;
    height: auto !important;
    min-height: unset !important;
    max-height: unset !important;
    padding: 13px 16px !important;
    border: 1.5px solid var(--mst-chat-border) !important;
    border-radius: var(--mst-chat-radius-sm) !important;
    font-size: 15px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-weight: 400 !important;
    line-height: 1.5 !important;
    color: var(--mst-chat-text) !important;
    background: var(--mst-chat-bg-secondary) !important;
    transition: var(--mst-chat-transition-fast) !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    letter-spacing: 0 !important;
}

.mst-chat-popup .mst-chat-guest-fields .mst-chat-input,
.mst-chat-form .mst-chat-guest-fields .mst-chat-input {
    padding: 13px 16px !important;
    border-radius: var(--mst-chat-radius-sm) !important;
    font-size: 15px !important;
    background: var(--mst-chat-bg-tertiary) !important;
    border: 1.5px solid transparent !important;
}

.mst-chat-popup .mst-chat-guest-fields .mst-chat-input:focus,
.mst-chat-form .mst-chat-guest-fields .mst-chat-input:focus {
    background: var(--mst-chat-bg) !important;
    border-color: var(--mst-chat-primary) !important;
    box-shadow: 0 0 0 3px var(--mst-chat-primary-glow) !important;
}

.mst-chat-popup .mst-chat-input:focus,
.mst-chat-popup .mst-chat-textarea:focus,
.mst-chat-form .mst-chat-input:focus,
.mst-chat-form .mst-chat-textarea:focus {
    outline: none !important;
    border-color: var(--mst-chat-primary) !important;
    box-shadow: 0 0 0 3px var(--mst-chat-primary-glow) !important;
    background: var(--mst-chat-bg) !important;
}

.mst-chat-popup .mst-chat-input::placeholder,
.mst-chat-popup .mst-chat-textarea::placeholder,
.mst-chat-form .mst-chat-input::placeholder,
.mst-chat-form .mst-chat-textarea::placeholder {
    color: var(--mst-chat-text-muted) !important;
    font-weight: 400 !important;
    opacity: 1 !important;
}

.mst-chat-textarea {
    resize: none;
    min-height: 80px;
}

.mst-chat-message-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Кнопки действий (attach + submit) */
.mst-chat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mst-chat-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--mst-chat-radius-sm);
    background: var(--mst-chat-bg);
    border: 1.5px solid var(--mst-chat-border);
    cursor: pointer;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
    flex-shrink: 0;
}

.mst-chat-attach-btn:hover {
    background: var(--mst-chat-bg-tertiary);
    color: var(--mst-chat-primary);
    border-color: var(--mst-chat-primary);
}

.mst-chat-actions .mst-chat-submit {
    flex: 1;
}

/* Превью загружаемого изображения — FIXED: фиксированные размеры */
.mst-chat-image-preview {
    position: relative;
    display: inline-block;
    margin-top: 8px;
    width: 80px;
    height: 80px;
    border-radius: var(--mst-chat-radius-sm);
    overflow: hidden;
    border: 2px solid var(--mst-chat-primary);
    flex-shrink: 0;
}

.mst-chat-image-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
}

.mst-chat-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--mst-chat-transition-fast);
}

.mst-chat-preview-remove:hover {
    background: var(--mst-chat-error);
}

/* Изображение в сообщении — FIXED: фиксированные размеры */
.mst-chat-message-image {
    width: 180px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--mst-chat-radius-sm);
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
}

.mst-chat-message-image:hover {
    transform: scale(1.02);
}

/* Валидация контакта */
.mst-chat-popup .mst-chat-input.error,
.mst-chat-form .mst-chat-input.error {
    border-color: var(--mst-chat-error) !important;
    background: var(--mst-chat-error-bg) !important;
}

.mst-chat-email-hint,
.mst-chat-contact-hint {
    font-size: 11px;
    color: var(--mst-chat-error);
    margin-top: -4px;
    margin-bottom: 4px;
}

/* Logged in user info */
.mst-chat-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--mst-chat-bg);
    border-radius: var(--mst-chat-radius-sm);
    border: 1px solid var(--mst-chat-border-light);
}

.mst-chat-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--mst-chat-message-guide);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.mst-chat-user-name {
    color: var(--mst-chat-text);
    font-weight: 600;
    font-size: 14px;
}

.mst-chat-user-email {
    color: var(--mst-chat-text-muted);
    font-size: 12px;
}

/* Submit Button */
.mst-chat-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    background: var(--mst-chat-message-guide);
    color: #fff;
    border: none;
    border-radius: var(--mst-chat-radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--mst-chat-transition);
    position: relative;
    overflow: hidden;
}

.mst-chat-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.mst-chat-submit:hover::before {
    left: 100%;
}

.mst-chat-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.35);
}

.mst-chat-submit:active {
    transform: translateY(0);
}

.mst-chat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.mst-chat-submit:disabled::before {
    display: none;
}

/* =====================================
   STATUS MESSAGES
   ===================================== */
.mst-chat-status {
    padding: 14px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mst-chat-status--success {
    background: var(--mst-chat-success-bg);
    color: var(--mst-chat-success);
}

.mst-chat-status--success::before {
    content: '✓';
    font-weight: 700;
}

.mst-chat-status--error {
    background: var(--mst-chat-error-bg);
    color: var(--mst-chat-error);
}

.mst-chat-status--error::before {
    content: '!';
    font-weight: 700;
}

.mst-chat-status--loading {
    background: var(--mst-chat-bg-tertiary);
    color: var(--mst-chat-text-secondary);
}

/* =====================================
   TOAST NOTIFICATION v5.3.0 — Premium Design FIXED
   ===================================== */
.mst-chat-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 99998;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 48px 16px 18px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(226, 232, 240, 0.8);
    width: auto;
    min-width: 300px;
    max-width: 420px;
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    cursor: pointer;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: none;
}

/* Accent bar left */
.mst-chat-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--mst-chat-primary-light), var(--mst-chat-primary-dark));
    border-radius: 4px 0 0 4px;
}

/* Progress bar bottom */
.mst-chat-toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--mst-chat-primary), var(--mst-chat-primary-light));
    transform-origin: left;
    animation: mstToastProgress 10s linear forwards;
    opacity: 0;
}

.mst-chat-toast.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.mst-chat-toast.show::after {
    opacity: 0.6;
}

@keyframes mstToastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

.mst-chat-toast-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--mst-chat-message-guide);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(153, 82, 224, 0.3);
}

.mst-chat-toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mst-chat-toast-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--mst-chat-text);
    line-height: 1.3;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mst-chat-toast-message {
    font-size: 13px;
    color: var(--mst-chat-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.mst-chat-toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mst-chat-text-muted);
    transition: var(--mst-chat-transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.mst-chat-toast:hover .mst-chat-toast-close {
    opacity: 1;
}

.mst-chat-toast-close:hover {
    background: var(--mst-chat-border);
    color: var(--mst-chat-text);
}

/* =====================================
   TYPING INDICATOR
   ===================================== */
.mst-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--mst-chat-bg-tertiary);
    border-radius: var(--mst-chat-radius-md);
    border-bottom-left-radius: 6px;
    max-width: 100px;
    align-self: flex-start;
}

.mst-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--mst-chat-primary);
    border-radius: 50%;
    animation: mstTypingDot 1.4s ease-in-out infinite;
}

.mst-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.mst-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mstTypingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* =====================================
   LOADING SPINNER
   ===================================== */
.mst-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.mst-chat-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--mst-chat-border);
    border-top-color: var(--mst-chat-primary);
    border-radius: 50%;
    animation: mstSpin 0.8s linear infinite;
}

@keyframes mstSpin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================
   ERROR STATE
   ===================================== */
.mst-chat-error {
    text-align: center;
    padding: 30px 20px;
    color: var(--mst-chat-error);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.mst-chat-error-icon {
    width: 48px;
    height: 48px;
    background: var(--mst-chat-error-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =====================================
   MOBILE RESPONSIVE
   ===================================== */
@media (max-width: 480px) {
    .mst-chat-popup {
        padding: 0;
        align-items: flex-end;
    }

    .mst-chat-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--mst-chat-radius-lg) var(--mst-chat-radius-lg) 0 0;
    }

    .mst-chat-guest-fields {
        grid-template-columns: 1fr;
    }

    .mst-chat-trigger {
        bottom: calc(16px + var(--mst-chat-bottom-obstruction, 0px) + env(safe-area-inset-bottom, 0px));
        right: 16px;
    }

    .mst-chat-trigger-text {
        display: none;
    }

    .mst-chat-trigger {
        width: 60px;
        height: 60px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }

    .mst-chat-toast {
        left: 16px;
        right: 16px;
        top: 16px;
        width: auto;
        max-width: none;
        transform: translateY(calc(-100% - 20px));
        opacity: 0;
    }

    .mst-chat-toast.show {
        transform: translateY(0);
        opacity: 1;
    }
}

/* =====================================
   DARK MODE SUPPORT
   ===================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --mst-chat-bg: #1E293B;
        --mst-chat-bg-secondary: #0F172A;
        --mst-chat-bg-tertiary: #334155;
        --mst-chat-text: #F1F5F9;
        --mst-chat-text-secondary: #CBD5E1;
        --mst-chat-text-muted: #64748B;
        --mst-chat-border: #334155;
        --mst-chat-border-light: #1E293B;
        --mst-chat-message-user: #334155;
    }

    .mst-chat-toast {
        background: #1E293B;
        box-shadow: var(--mst-chat-shadow-xl), 0 0 0 1px #334155;
    }
}

/* =====================================
   RESPONSE STATISTICS - Время ответа гида
   ===================================== */
.mst-chat-response-stats {
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--mst-chat-bg-secondary);
    border-radius: var(--mst-chat-radius-sm);
    border: 1px solid var(--mst-chat-border-light);
}

.mst-chat-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--mst-chat-text-secondary);
}

.mst-chat-stats-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mst-chat-stats-dot--online {
    background: var(--mst-chat-success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: pulse-dot 2s infinite;
}

.mst-chat-stats-dot--offline {
    background: var(--mst-chat-text-muted);
}

.mst-chat-stats--online .mst-chat-stats-text {
    color: var(--mst-chat-success);
    font-weight: 500;
}

.mst-chat-stats--offline .mst-chat-stats-text {
    color: var(--mst-chat-text-muted);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* =====================================
   INTEGRATION: Hide trigger if external button exists
   ===================================== */
body:has([data-mst-chat-trigger]) .mst-chat-trigger {
    display: none;
}

/* =====================================
   ACCESSIBILITY
   ===================================== */
@media (prefers-reduced-motion: reduce) {

    .mst-chat-trigger,
    .mst-chat-modal,
    .mst-chat-message,
    .mst-chat-toast,
    .mst-chat-close,
    .mst-chat-stats-dot {
        transition: none;
        animation: none;
    }
}

/* Focus styles */
.mst-chat-input:focus-visible,
.mst-chat-textarea:focus-visible,
.mst-chat-submit:focus-visible,
.mst-chat-close:focus-visible {
    outline: 2px solid var(--mst-chat-primary);
    outline-offset: 2px;
}

/* =====================================
   CHAT HEADER ACTIONS
   ===================================== */
.mst-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mst-chat-header-actions>button {
    flex: 0 0 auto;
}

/* All Chats Button (grid icon) */
.mst-chat-all-chats-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
    position: relative;
    line-height: 1;
}

.mst-chat-all-chats-btn:hover {
    background: var(--mst-chat-primary-glow);
    color: var(--mst-chat-primary);
}

.mst-chat-all-chats-btn.active {
    background: var(--mst-chat-primary);
    color: #fff;
}

.mst-chat-all-chats-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.32);
    pointer-events: none;
}

/* =====================================
   CONVERSATIONS LIST (Все чаты)
   ===================================== */
.mst-chat-conversations-list {
    flex: 1 1 0;
    min-height: 100px;
    overflow-y: auto;
    padding: 16px;
    background: var(--mst-chat-bg);
}

.mst-chat-conversations-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--mst-chat-border-light);
}

.mst-chat-conversations-list-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--mst-chat-text);
}

.mst-chat-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
}

.mst-chat-back-btn:hover {
    background: var(--mst-chat-border);
    color: var(--mst-chat-text);
}

.mst-chat-conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--mst-chat-bg-secondary);
    border-radius: var(--mst-chat-radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--mst-chat-transition-fast);
    border: 1px solid var(--mst-chat-border-light);
}

.mst-chat-conversation-item:hover {
    background: var(--mst-chat-bg-tertiary);
    border-color: var(--mst-chat-primary-light);
    transform: translateY(-1px);
}

.mst-chat-conversation-item.has-unread {
    background: linear-gradient(to right, rgba(153, 82, 224, 0.10), rgba(153, 82, 224, 0.03));
    border-left: 3px solid var(--mst-chat-primary);
    padding-left: 11px;
}

.mst-chat-conversation-item.has-unread .mst-chat-conversation-title {
    font-weight: 700;
}

.mst-chat-conversation-item.has-unread .mst-chat-conversation-time {
    color: var(--mst-chat-primary);
    font-weight: 600;
}

.mst-chat-conversation-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mst-chat-primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--mst-chat-primary-light);
}

.mst-chat-conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mst-chat-conversation-avatar svg {
    width: 20px;
    height: 20px;
    color: var(--mst-chat-primary);
}

.mst-chat-conversation-info {
    flex: 1;
    min-width: 0;
}

.mst-chat-conversation-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--mst-chat-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mst-chat-conversation-preview {
    font-size: 13px;
    color: var(--mst-chat-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mst-chat-conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.mst-chat-conversation-time {
    font-size: 11px;
    color: var(--mst-chat-text-muted);
}

.mst-chat-conversation-unread {
    min-width: 20px;
    height: 20px;
    background: var(--mst-chat-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.mst-chat-conversations-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--mst-chat-text-muted);
}

.mst-chat-conversations-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.mst-chat-conversations-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.mst-chat-login-required {
    text-align: center;
    padding: 40px 20px;
    color: var(--mst-chat-text-secondary);
}

.mst-chat-login-required a {
    color: var(--mst-chat-primary);
    text-decoration: underline;
}

/* Drag Handle */
.mst-chat-drag-handle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: grab;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
    line-height: 1;
}

.mst-chat-drag-handle:hover {
    background: var(--mst-chat-border);
    color: var(--mst-chat-text);
}

.mst-chat-drag-handle:active {
    cursor: grabbing;
}

.mst-chat-drag-handle svg circle {
    fill: currentColor;
}

/* Resize Toggle Button (вместо size-toggle) */
.mst-chat-resize-toggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mst-chat-text-secondary);
    transition: var(--mst-chat-transition-fast);
    line-height: 1;
}

.mst-chat-resize-toggle:hover {
    background: var(--mst-chat-border);
    color: var(--mst-chat-text);
}

.mst-chat-resize-toggle.active {
    background: var(--mst-chat-primary-glow);
    color: var(--mst-chat-primary);
}

/* DEPRECATED: Size dropdown - больше не используется */
.mst-chat-size-toggle,
.mst-chat-size-dropdown,
.mst-chat-size-option {
    display: none !important;
}

/* =====================================
   DOCKED MODE - Chat docked to right side (desktop)
   ===================================== */
.mst-chat-popup--docked {
    padding: 0;
    justify-content: flex-end;
    align-items: stretch;
}

.mst-chat-popup--docked .mst-chat-overlay {
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
}

.mst-chat-popup--docked .mst-chat-modal {
    max-width: 450px;
    min-width: 320px;
    max-height: none;
    height: 100vh;
    border-radius: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    animation: mstChatSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    /* FIXED v5.5.1: overflow-x hidden for resize, overflow-y visible for content */
    resize: horizontal;
    overflow: hidden;
    /* FIXED: flex контейнер */
    display: flex;
    flex-direction: column;
}

/* FIXED v5.5.1: Ensure messages area fills available space and is scrollable */
.mst-chat-popup--docked .mst-chat-messages {
    max-height: none;
    flex: 1 1 0;
    min-height: 0;
    /* Critical for flex shrinking */
    overflow-y: auto;
}

/* FIXED: Элементы внутри docked режима */
.mst-chat-popup--docked .mst-chat-header,
.mst-chat-popup--docked .mst-chat-tour-info {
    flex-shrink: 0;
}

.mst-chat-popup--docked .mst-chat-form {
    flex-shrink: 0;
}

/* Resizable mode - свободный resize мышью */
.mst-chat-popup--resizable .mst-chat-modal {
    position: fixed;
    resize: both;
    overflow: hidden;
    /* FIXED: hidden вместо auto - предотвращает обрезание */
    min-width: 320px;
    min-height: 400px;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--mst-chat-radius-lg);
    box-shadow: var(--mst-chat-shadow-xl);
    /* FIXED: flex контейнер для правильного распределения высоты */
    display: flex;
    flex-direction: column;
}

/* FIXED: Контент внутри resizable модала должен адаптироваться */
.mst-chat-popup--resizable .mst-chat-messages {
    flex: 1 1 0;
    min-height: 100px;
    max-height: none;
}

.mst-chat-popup--resizable .mst-chat-form {
    flex-shrink: 0;
}

@keyframes mstChatSlideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

/* Handled above in docked modal section */

/* Draggable state */
.mst-chat-popup--draggable {
    padding: 0;
}

.mst-chat-popup--draggable .mst-chat-overlay {
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
}

.mst-chat-popup--draggable .mst-chat-modal {
    position: fixed;
    max-height: 80vh;
    border-radius: var(--mst-chat-radius-lg);
    box-shadow: var(--mst-chat-shadow-xl);
    transition: none;
    animation: none;
}

.mst-chat-popup--dragging .mst-chat-modal {
    cursor: grabbing;
    user-select: none;
}

/* Mode toggle button (legacy support) */
.mst-chat-mode-toggle {
    display: none;
}

/* =====================================
   MOBILE - Always fullscreen + Fix trigger position + FIXED CLOSE BUTTON
   ===================================== */
@media (max-width: 768px) {

    .mst-chat-popup,
    .mst-chat-popup--docked,
    .mst-chat-popup--resizable {
        padding: 0;
    }

    .mst-chat-popup .mst-chat-modal,
    .mst-chat-popup--docked .mst-chat-modal,
    .mst-chat-popup--resizable .mst-chat-modal {
        max-width: none;
        max-height: none;
        width: 100% !important;
        height: calc(100dvh - var(--mst-chat-bottom-obstruction, 0px) - env(safe-area-inset-bottom, 0px)) !important;
        border-radius: 0;
        resize: none;
        /* Disable resize on mobile */
    }

    .mst-chat-popup .mst-chat-messages,
    .mst-chat-popup--docked .mst-chat-messages {
        max-height: none;
        flex: 1;
        /* FIXED: динамический отступ снизу под любые нижние sticky-бары */
        padding-bottom: calc(16px + var(--mst-chat-bottom-obstruction, 0px) + env(safe-area-inset-bottom, 0px));
    }

    /* Hide desktop-only controls on mobile */
    .mst-chat-size-toggle,
    .mst-chat-drag-handle,
    .mst-chat-mode-toggle,
    .mst-chat-resize-toggle {
        display: none !important;
    }

    /* Conversations list on mobile */
    .mst-chat-conversations-list {
        padding-bottom: calc(16px + var(--mst-chat-bottom-obstruction, 0px) + env(safe-area-inset-bottom, 0px));
    }

    .mst-chat-popup .mst-chat-overlay,
    .mst-chat-popup--docked .mst-chat-overlay {
        display: none;
    }

    /* FIXED: Close button must be clickable on mobile */
    .mst-chat-close {
        z-index: 99999 !important;
        pointer-events: auto !important;
        min-width: 44px;
        min-height: 44px;
    }

    /* FIXED: Header must be above all content */
    .mst-chat-header {
        position: relative;
        z-index: 1000;
    }

    /* FIXED: trigger sits above any bottom bar */
    .mst-chat-trigger {
        bottom: calc(16px + var(--mst-chat-bottom-obstruction, 0px) + env(safe-area-inset-bottom, 0px));
        right: 16px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    }

    /* v5.1.0: Close button on mobile trigger */
    .mst-chat-trigger-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: -8px;
        left: -8px;
        width: 24px;
        height: 24px;
        background: rgba(0, 0, 0, 0.6);
        border: 2px solid #fff;
        border-radius: 50%;
        color: #fff;
        font-size: 12px;
        line-height: 1;
        cursor: pointer;
        z-index: 10;
        padding: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        transition: transform 0.15s ease, background 0.15s ease;
    }

    .mst-chat-trigger-close:hover {
        transform: scale(1.15);
        background: rgba(239, 68, 68, 0.9);
    }

    /* Hide close button on desktop */
    @media (min-width: 769px) {
        .mst-chat-trigger-close {
            display: none;
        }
    }

    /* Swipe dismiss animation */
    .mst-chat-trigger--swiping {
        transition: none !important;
    }

    .mst-chat-trigger--dismissed {
        transform: translateX(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Mobile toast notification - below header */
    .mst-chat-toast {
        top: 70px;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }

    /* Mobile: form should have padding for safe-area */
    .mst-chat-form {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* =====================================
   NOTIFICATION PERMISSION PROMPT v5.1.0
   FIXED: Позиция сверху-слева (как стандартный браузерный промпт)
   ===================================== */
.mst-chat-notif-prompt {
    position: fixed;
    top: 20px;
    left: 20px;
    right: auto;
    bottom: auto;
    z-index: 999999;
    max-width: 420px;
    pointer-events: auto;
    transform: translateX(-110%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mst-chat-notif-prompt.show {
    transform: translateX(0);
    opacity: 1;
}

.mst-chat-notif-prompt-content {
    max-width: 480px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.mst-chat-notif-prompt-icon {
    font-size: 32px;
    line-height: 1;
}

.mst-chat-notif-prompt-text {
    flex: 1;
    min-width: 200px;
}

.mst-chat-notif-prompt-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #0F172A;
    margin-bottom: 4px;
}

.mst-chat-notif-prompt-text p {
    margin: 0;
    font-size: 13px;
    color: #64748B;
    line-height: 1.4;
}

.mst-chat-notif-prompt-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.mst-chat-notif-allow {
    flex: 1;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--mst-chat-primary) 0%, var(--mst-chat-primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mst-chat-notif-allow:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(153, 82, 224, 0.3);
}

.mst-chat-notif-later {
    flex: 1;
    padding: 12px 20px;
    background: #F1F5F9;
    color: #475569;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mst-chat-notif-later:hover {
    background: #E2E8F0;
}

@media (min-width: 480px) {
    .mst-chat-notif-prompt-actions {
        width: auto;
        flex-direction: row;
    }

    .mst-chat-notif-allow,
    .mst-chat-notif-later {
        flex: none;
    }
}

/* =====================================
   GREETING SCREEN (Pre-chat questions)
   ===================================== */
.mst-chat-greeting {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.mst-greeting-inner {
    text-align: center;
    max-width: 340px;
    width: 100%;
}

.mst-greeting-emoji {
    font-size: 40px;
    margin-bottom: 8px;
    animation: mstGreetBounce 2s ease infinite;
}

@keyframes mstGreetBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.mst-greeting-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--mst-chat-text);
    margin: 0 0 4px;
}

.mst-greeting-subtitle {
    font-size: 13px;
    color: var(--mst-chat-text-secondary);
    margin: 0 0 20px;
    line-height: 1.4;
}

.mst-greeting-question {
    margin-bottom: 16px;
    text-align: left;
}

.mst-greeting-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--mst-chat-text);
    margin-bottom: 8px;
}

.mst-greeting-label svg {
    color: var(--mst-chat-primary);
    flex-shrink: 0;
}

.mst-greeting-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.mst-greeting-chip {
    padding: 10px 8px;
    border: 1.5px solid var(--mst-chat-border);
    border-radius: var(--mst-chat-radius-sm);
    background: var(--mst-chat-bg);
    color: var(--mst-chat-text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--mst-chat-transition-fast);
    text-align: center;
    line-height: 1.3;
}

.mst-greeting-chip:hover {
    border-color: var(--mst-chat-primary-light);
    background: rgba(153, 82, 224, 0.04);
}

.mst-greeting-chip.active {
    border-color: var(--mst-chat-primary);
    background: rgba(153, 82, 224, 0.08);
    color: var(--mst-chat-primary-dark);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--mst-chat-primary-light);
}

.mst-greeting-date-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--mst-chat-border);
    border-radius: var(--mst-chat-radius-sm);
    font-size: 14px;
    color: var(--mst-chat-text);
    background: var(--mst-chat-bg);
    transition: var(--mst-chat-transition-fast);
    outline: none;
}

.mst-greeting-date-input:focus {
    border-color: var(--mst-chat-primary);
    box-shadow: 0 0 0 3px var(--mst-chat-primary-glow);
}

.mst-greeting-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.mst-greeting-go {
    padding: 12px 20px;
    background: var(--mst-chat-message-guide);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--mst-chat-transition);
    letter-spacing: 0.3px;
}

.mst-greeting-go:hover {
    transform: translateY(-1px);
    box-shadow: var(--mst-chat-shadow-glow);
}

.mst-greeting-go:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.mst-greeting-skip {
    padding: 8px;
    background: none;
    border: none;
    color: var(--mst-chat-text-muted);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mst-greeting-skip:hover {
    color: var(--mst-chat-text-secondary);
}

/* =====================================
   SYSTEM MESSAGES (Greeting info, Order notifications)
   ===================================== */
.mst-chat-message--system {
    display: flex;
    justify-content: center;
    align-self: center !important;
    max-width: 90% !important;
    padding: 4px 16px;
    margin: 12px auto;
    width: auto;
}

.mst-chat-system-bubble {
    background: linear-gradient(135deg, rgba(153, 82, 224, 0.08) 0%, rgba(153, 82, 224, 0.04) 100%);
    border: 1px solid rgba(153, 82, 224, 0.15);
    border-radius: 12px;
    padding: 10px 16px;
    max-width: 85%;
    font-size: 13px;
    line-height: 1.5;
    color: var(--mst-chat-text-secondary);
    text-align: center;
    white-space: pre-line;
}

.mst-chat-system-bubble strong {
    color: var(--mst-chat-primary);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.mst-chat-system-bubble .mst-chat-message-time {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--mst-chat-text-muted);
    text-align: center;
}

/* =====================================
   BOOKING CARD v8.0
   ===================================== */
.mst-chat-message--booking {
    display: flex;
    justify-content: center;
    align-self: center !important;
    max-width: 95% !important;
    padding: 4px 8px;
    margin: 12px auto;
    width: auto;
}

.mst-chat-booking-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.03) 100%);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 16px;
    padding: 16px 20px;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.5;
    color: var(--mst-chat-text);
}

.mst-booking-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #16a34a;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.mst-booking-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mst-booking-line {
    font-size: 13.5px;
    line-height: 1.6;
    padding: 1px 0;
}

.mst-booking-line--link {
    margin-top: 6px;
}

.mst-booking-ticket-link {
    color: var(--mst-chat-primary);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.mst-booking-ticket-link:hover {
    color: var(--mst-chat-primary-dark);
}

.mst-chat-booking-card .mst-chat-message-time {
    display: block;
    margin-top: 10px;
    font-size: 11px;
    color: var(--mst-chat-text-muted);
    text-align: right;
}

/* =====================================
   PHONE NUMBER BLUR v5.3.0
   ===================================== */
.mst-phone-blurred {
    filter: blur(5px);
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    display: inline;
    transition: filter 0.3s ease;
    background: rgba(153, 82, 224, 0.06);
    border-radius: 4px;
    padding: 0 2px;
}

.mst-phone-blur-wrapper {
    display: inline;
    position: relative;
    cursor: pointer;
}

.mst-phone-blur-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 8px 0;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.04));
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--mst-chat-text-secondary);
}

.mst-phone-blur-notice a {
    color: var(--mst-chat-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mst-phone-blur-notice svg {
    flex-shrink: 0;
    color: var(--mst-chat-warning);
}

/* =====================================
   CHAT CLOSED OVERLAY v5.3.0
   ===================================== */
.mst-chat-closed-overlay {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    gap: 12px;
}

.mst-chat-closed-overlay svg {
    color: var(--mst-chat-text-muted);
    opacity: 0.5;
}

.mst-chat-closed-overlay h4 {
    font-size: 17px;
    font-weight: 700;
    color: var(--mst-chat-text);
    margin: 0;
}

.mst-chat-closed-overlay p {
    font-size: 13px;
    color: var(--mst-chat-text-secondary);
    margin: 0;
    line-height: 1.5;
    max-width: 280px;
}

/* =====================================
   GREETING SCREEN
   ===================================== */
.mst-chat-greeting {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mst-chat-greeting-inner {
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.mst-chat-greeting-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 16px;
    overflow: hidden;
    border: 3px solid var(--mst-chat-primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mst-chat-bg-tertiary);
}

.mst-chat-greeting-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mst-chat-greeting-avatar svg {
    color: var(--mst-chat-text-muted);
}

.mst-chat-greeting-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--mst-chat-text);
    margin: 0 0 8px;
}

.mst-chat-greeting-text {
    font-size: 14px;
    color: var(--mst-chat-text-secondary);
    margin: 0 0 24px;
    line-height: 1.5;
}

.mst-chat-greeting-field {
    text-align: left;
    margin-bottom: 16px;
}

.mst-chat-greeting-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--mst-chat-text);
    margin-bottom: 8px;
}

.mst-greeting-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mst-greeting-chip {
    padding: 8px 16px;
    border: 1.5px solid var(--mst-chat-border);
    border-radius: 100px;
    background: var(--mst-chat-bg);
    color: var(--mst-chat-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--mst-chat-transition-fast);
}

.mst-greeting-chip:hover {
    border-color: var(--mst-chat-primary-light);
    background: var(--mst-chat-primary-glow);
}

.mst-greeting-chip.active {
    border-color: var(--mst-chat-primary);
    background: var(--mst-chat-primary);
    color: #fff;
}

.mst-chat-greeting-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 20px;
}

.mst-greeting-skip {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--mst-chat-text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--mst-chat-transition-fast);
}

.mst-greeting-skip:hover {
    color: var(--mst-chat-text-secondary);
}

/* =====================================
   CONTACT METHOD ICONS v5.8.0 — Icon-only with hover tooltips
   ===================================== */
.mst-chat-contact-wrap {
    margin-top: 0;
}

.mst-chat-contact-icons {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.mst-chat-contact-icon {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid transparent;
    border-radius: 10px;
    background: var(--mst-chat-bg-tertiary);
    color: var(--mst-chat-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mst-chat-contact-icon:hover {
    border-color: var(--mst-chat-primary-light);
    color: var(--mst-chat-primary);
    background: rgba(153, 82, 224, 0.04);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153, 82, 224, 0.12);
}

/* Tooltip on hover */
.mst-chat-contact-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    white-space: nowrap;
    padding: 8px 14px;
    background: var(--mst-chat-text);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Tooltip arrow */
.mst-chat-contact-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--mst-chat-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.mst-chat-contact-icon:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mst-chat-contact-icon:hover::before {
    opacity: 1;
}

/* Active states — branded colors */
.mst-chat-contact-icon.active {
    border-color: var(--mst-chat-primary);
    background: rgba(153, 82, 224, 0.08);
    color: var(--mst-chat-primary);
}

.mst-chat-contact-icon.active[data-type="whatsapp"] {
    border-color: #25D366;
    background: rgba(37, 211, 102, 0.08);
    color: #128C7E;
}

.mst-chat-contact-icon.active[data-type="telegram"] {
    border-color: #0088cc;
    background: rgba(0, 136, 204, 0.08);
    color: #0088cc;
}

.mst-chat-contact-icon.active[data-type="phone"] {
    border-color: var(--mst-chat-primary);
    background: rgba(153, 82, 224, 0.08);
    color: var(--mst-chat-primary);
}

.mst-chat-contact-icon svg {
    flex-shrink: 0;
}

/* Mobile: tooltip shows above (may need left-align) */
@media (max-width: 480px) {
    .mst-chat-contact-icon::after {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* =====================================
   TRIP EDIT BAR
   ===================================== */
.mst-trip-edit-bar {
    padding: 6px 12px;
    border-bottom: 1px solid var(--mst-chat-border-light, #F1F5F9);
    background: var(--mst-chat-bg-secondary, #F8FAFC);
}

.mst-trip-edit-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--mst-chat-primary, #9952E0);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.mst-trip-edit-toggle:hover {
    opacity: 0.8;
}

.mst-trip-edit-form {
    margin-top: 6px;
}

.mst-trip-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mst-trip-edit-row label {
    font-size: 12px;
    color: var(--mst-chat-text-secondary, #475569);
    font-weight: 500;
}

.mst-trip-edit-row select,
.mst-trip-edit-row input[type="date"] {
    padding: 4px 8px;
    border: 1px solid var(--mst-chat-border, #E2E8F0);
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
}

.mst-trip-edit-save {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: var(--mst-chat-primary, #9952E0);
    color: #fff;
    cursor: pointer;
}

.mst-trip-edit-save:hover {
    opacity: 0.85;
}

/* v10.0: MODERN MST-STYLE CARDS (FINAL FIX) */
.mst-modern-card {
    background: #ffffff !important;
    border: 1px solid #EBEBEB !important;
    border-radius: 16px !important;
    padding: 20px !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.06) !important;
    margin: 12px 0 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif !important;
    width: 100% !important;
    max-width: 320px !important;
    border-left: none !important; /* FORCED REMOVAL */
}

.mst-modern-card--success,
.mst-modern-card--warning {
    border-left: none !important; /* NO ACCENT BARS */
}

.mst-card-header {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
}

.mst-card-header.success { color: #00A699 !important; }
.mst-card-header.warning { color: #FF5A5F !important; }

.mst-card-row {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    padding: 8px 0 !important;
    border-bottom: 1px solid #F0F0F0 !important;
    font-size: 14px !important;
    gap: 12px !important;
}

.mst-card-row:last-of-type { border-bottom: none !important; }

.mst-card-label {
    color: #484848 !important; /* Darker for readability */
    font-weight: 500 !important;
    min-width: 90px !important;
    flex-shrink: 0 !important;
}

.mst-card-value {
    color: #222222 !important;
    font-weight: 700 !important;
    text-align: left !important;
    flex: 1 !important;
}

.mst-card-comment {
    margin-top: 14px !important;
    padding: 14px !important;
    background: #F7F7F7 !important;
    border-radius: 12px !important;
}

.mst-card-comment-label {
    font-size: 10px !important;
    text-transform: uppercase !important;
    color: #717171 !important;
    margin-bottom: 6px !important;
    font-weight: 800 !important;
    display: block !important;
}

.mst-card-btn-primary {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background: rgba(153, 82, 224, 0.08) !important;
    color: #9952E0 !important;
    padding: 14px !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    text-decoration: none !important;
    margin-top: 16px !important;
    transition: all 0.2s ease !important;
    border: 1px solid rgba(153, 82, 224, 0.15) !important;
}

.mst-card-btn-primary:hover {
    background: rgba(153, 82, 224, 0.15) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(153, 82, 224, 0.1) !important;
}

/* Fix text leveling in chat bubbles */
.mst-chat-message-bubble {
    border-radius: 18px !important;
    padding: 12px 18px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
}

.mst-chat-message--user .mst-chat-message-bubble {
    background: #ffffff !important;
    color: #222222 !important;
    border: 1px solid #EBEBEB !important;
}

.mst-chat-message--guide .mst-chat-message-bubble {
    background: #9952E0 !important;
    color: #ffffff !important;
}

