/* Ensure the chat widget is 100% dark fintech by default */
.ma-chat,
.ma-chat.ma-chat--dark,
.ma-chat.ma-chat--light {
    --ma-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ma-bg: #0B0E14 !important;
    --ma-surface: #111827 !important;
    --ma-surface-strong: #162032 !important;
    --ma-surface-soft: #1E293B !important;
    --ma-text: #F8FAFC !important;
    --ma-muted: #94A3B8 !important;
    --ma-border: rgba(255, 255, 255, 0.08) !important;
    --ma-primary: #10B981 !important;
    --ma-primary-strong: #059669 !important;
    --ma-accent: #10B981 !important;
    --ma-launcher-bg: #10B981 !important;
    --ma-launcher-icon: #FFFFFF !important;
    --ma-launcher-status: #10B981 !important;
    --ma-launcher-label-bg: #111827 !important;
    --ma-launcher-label-text: #F8FAFC !important;
    --ma-danger: #EF4444 !important;
    --ma-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
    --ma-shadow-soft: 0 12px 28px -5px rgba(0, 0, 0, 0.5) !important;
    --ma-radius: 14px;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    color: var(--ma-text);
    font-family: var(--ma-font-family);
    color-scheme: dark !important;
    overscroll-behavior: contain !important;
}

.ma-chat,
.ma-chat *,
.ma-chat *::before,
.ma-chat *::after {
    box-sizing: border-box;
}

.ma-chat-preview {
    --ma-font-family: Arial, Helvetica, sans-serif;
    --ma-bg: #f6f3ec;
    --ma-surface: #ffffff;
    --ma-text: #17211b;
    --ma-muted: #617066;
    --ma-border: #d8ded4;
    --ma-primary: #0e5f4f;
    --ma-radius: 8px;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background: var(--ma-bg);
    color: var(--ma-text);
    font-family: var(--ma-font-family);
}

.ma-chat-preview__hero {
    width: min(920px, 100%);
    padding: 48px;
    border: 1px solid var(--ma-border);
    background: var(--ma-surface);
    border-radius: var(--ma-radius);
    box-shadow: 0 16px 45px rgba(20, 31, 25, 0.08);
}

.ma-chat-preview__copy {
    max-width: 660px;
}

.ma-chat-preview__kicker {
    margin: 0 0 12px;
    color: var(--ma-primary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.ma-chat-preview__copy h1 {
    margin: 0 0 16px;
    font-size: clamp(32px, 5vw, 58px);
    line-height: 1.02;
    letter-spacing: 0;
}

.ma-chat-preview__copy p {
    margin: 0;
    color: var(--ma-muted);
    font-size: 17px;
    line-height: 1.7;
}

.ma-chat--bottom_left {
    right: auto;
    left: 24px;
}

.ma-chat--bottom_left .ma-chat__panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.ma-chat__bubble {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 60px;
    height: 60px;
    pointer-events: auto;
    border: 0;
    border-radius: 50%;
    background: var(--ma-launcher-bg);
    color: var(--ma-launcher-icon);
    cursor: pointer;
    box-shadow: var(--ma-shadow);
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.ma-chat--open {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ma-chat--open .ma-chat__bubble,
.ma-chat.ma-chat--open .ma-chat__bubble {
    display: none !important;
    pointer-events: none !important;
}

.ma-chat--open .ma-chat__drag-hint,
.ma-chat.ma-chat--open .ma-chat__drag-hint {
    display: none !important;
    pointer-events: none !important;
}


.ma-chat__bubble:hover,
.ma-chat__bubble:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 28px 80px rgba(14, 95, 79, 0.32);
}

.ma-chat__bubble-mark {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    font-size: 0;
    font-weight: 800;
    overflow: hidden;
    border-radius: 50%;
}

.ma-chat__bubble-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ma-chat__bubble-svg {
    width: 38px;
    height: 38px;
    display: block;
}

.ma-chat__tools {
    display: flex;
    justify-content: flex-start;
    padding: 0 16px 8px;
}

.ma-chat__upload {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 7px 10px;
    border: 1px solid var(--ma-border);
    border-radius: 999px;
    color: var(--ma-muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ma-chat__upload input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.ma-chat__bubble-mark {
    position: relative;
    font-size: 0 !important;
}

.ma-chat__bubble-mark::before {
    content: none !important;
    display: none !important;
}

.ma-chat__bubble-mark::after {
    content: none !important;
    display: none !important;
}

.ma-chat__bubble-pulse {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--ma-launcher-status);
}

/* Panel Body & Container */
.ma-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(var(--ma-launcher-size, 72px) + 16px);
    width: 400px;
    max-width: calc(100vw - 32px);
    height: min(680px, calc(100vh - var(--ma-launcher-size, 72px) - 56px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--ma-radius);
    background: #111827 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
    overscroll-behavior: contain !important;
    transform-origin: bottom right;
    animation: ma-panel-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ma-chat__panel[hidden] {
    display: none;
}

@keyframes ma-panel-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header Styling: Dark Sleek Gradient */
.ma-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #0F172A 0%, #162032 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.ma-chat.ma-chat--dark .ma-chat__header,
.ma-chat.ma-chat--light .ma-chat__header {
    background: linear-gradient(135deg, #0F172A 0%, #162032 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.ma-chat__brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ma-chat__logo {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ma-chat__logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ma-chat__brand h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600 !important;
    color: #F8FAFC !important;
    line-height: 1.25;
}

.ma-chat__brand p {
    margin: 3px 0 0;
    color: #94A3B8 !important;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ma-chat__brand p[data-chat-assistant-status]::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
    flex-shrink: 0;
}

.ma-chat__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Replace 'L' and 'X' circular buttons with modern dark glass buttons */
.ma-chat__icon-button {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #94A3B8 !important;
    border-radius: 8px !important;
    width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important; /* Hide any raw text fallback like 'L' or 'X' */
    transition: all 150ms ease !important;
    padding: 0;
    cursor: pointer;
}

.ma-chat__icon-button:hover,
.ma-chat.ma-chat--dark .ma-chat__icon-button:hover,
.ma-chat.ma-chat--dark .ma-chat__icon-button:focus-visible {
    background: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: #FFFFFF !important;
    transform: translateY(-1px) !important;
}

.ma-chat__header-svg {
    width: 16px !important;
    height: 16px !important;
    stroke: currentColor !important;
    pointer-events: none !important;
    display: block;
    margin: auto;
}

.ma-chat__handoff-notice {
    margin: 10px 0;
    padding: 12px 14px;
    border: 1px solid rgba(20, 230, 195, 0.35);
    border-radius: var(--ma-radius, 8px);
    background: rgba(20, 230, 195, 0.07);
    animation: ma-panel-in 200ms ease;
}

.ma-chat__handoff-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ma-chat__handoff-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #10b981;
}

.ma-chat__handoff-badge span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: ma-pulse-dot 1.6s infinite;
}

@keyframes ma-pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

.ma-chat__handoff-notice p {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ma-text);
}

.ma-chat__switch-ai-btn {
    align-self: flex-start;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ma-primary, #0e5f4f);
    background: var(--ma-surface);
    border: 1px solid var(--ma-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 150ms ease;
}

.ma-chat__switch-ai-btn:hover {
    background: var(--ma-primary, #0e5f4f);
    color: #ffffff;
    border-color: var(--ma-primary, #0e5f4f);
}

.ma-chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--ma-border) transparent;
    background: #0B0E14 !important;
    overscroll-behavior: contain !important;
}

.ma-chat__welcome {
    padding: 18px;
    border: 1px solid rgba(16, 185, 129, 0.22) !important;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.08) !important;
}

.ma-chat.ma-chat--dark .ma-chat__welcome,
.ma-chat.ma-chat--light .ma-chat__welcome {
    background: rgba(16, 185, 129, 0.08) !important;
    border-color: rgba(16, 185, 129, 0.22) !important;
}

.ma-chat__eyebrow {
    margin: 0 0 6px;
    color: var(--ma-primary);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ma-chat__welcome h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ma-text);
}

.ma-chat__welcome p:last-child {
    margin: 0;
    color: var(--ma-text);
    opacity: 0.92;
    font-size: 13.5px;
    line-height: 1.55;
}

/* Suggestion Chips / Quick Prompts */
.ma-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.ma-chat__suggestions button {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #E2E8F0 !important;
    border-radius: 20px !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    padding: 7px 14px !important;
    cursor: pointer;
    line-height: 1.3;
    transition: all 160ms ease !important;
}

.ma-chat__suggestions button:hover,
.ma-chat.ma-chat--dark .ma-chat__suggestions button:hover,
.ma-chat.ma-chat--dark .ma-chat__suggestions button:focus-visible,
.ma-chat.ma-chat--light .ma-chat__suggestions button:hover,
.ma-chat.ma-chat--light .ma-chat__suggestions button:focus-visible {
    border-color: #10B981 !important;
    color: #FFFFFF !important;
    background: rgba(16, 185, 129, 0.18) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}

.ma-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 13px;
    overscroll-behavior: contain !important;
}

.ma-chat__message {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: min(86%, 320px);
}

.ma-chat__message--user {
    align-self: flex-end;
}

.ma-chat__message--assistant,
.ma-chat__message--system {
    align-self: flex-start;
}

.ma-chat__bubble-text {
    padding: 12px 13px;
    border-radius: var(--ma-radius);
    color: var(--ma-text);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    box-shadow: 0 5px 18px rgba(17, 31, 27, 0.06);
}

/* Message Bubbles */
.ma-chat__message--user .ma-chat__bubble-text {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    color: #FFFFFF !important;
}

.ma-chat__message--assistant .ma-chat__bubble-text {
    background: #162032 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #F1F5F9 !important;
}

.ma-chat__message--system .ma-chat__bubble-text {
    border: 1px solid rgba(180, 35, 24, 0.28);
    background: rgba(180, 35, 24, 0.08);
    color: var(--ma-danger);
}

.ma-chat__bubble-text p {
    margin: 0 0 8px;
}

.ma-chat__bubble-text p:last-child,
.ma-chat__bubble-text ul:last-child,
.ma-chat__bubble-text ol:last-child {
    margin-bottom: 0;
}

.ma-chat__bubble-text ul,
.ma-chat__bubble-text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.ma-chat__bubble-text code {
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(97, 112, 102, 0.16);
}

.ma-chat__time {
    color: var(--ma-muted);
    font-size: 11px;
}

.ma-chat__message--user .ma-chat__time {
    text-align: right;
}

.ma-chat__typing {
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    color: var(--ma-muted);
    font-size: 12px;
}

.ma-chat__typing:not([hidden]) {
    display: flex;
}

.ma-chat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ma-primary);
    animation: ma-typing 900ms infinite ease-in-out;
}

.ma-chat__typing span:nth-child(2) {
    animation-delay: 120ms;
}

.ma-chat__typing span:nth-child(3) {
    animation-delay: 240ms;
}

.ma-chat__typing strong {
    font-weight: 400;
}

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

/* Textarea / Composer Area */
.ma-chat__form {
    padding: 12px 16px 14px;
    background: #111827 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.ma-chat.ma-chat--dark .ma-chat__form,
.ma-chat.ma-chat--light .ma-chat__form {
    background: #111827 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.ma-chat__form textarea {
    width: 100%;
    min-height: 46px;
    max-height: 120px;
    resize: none;
    padding: 11px 14px;
    background: #0B0E14 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #F8FAFC !important;
    border-radius: 10px !important;
    font: inherit;
    font-size: 13.5px !important;
    line-height: 1.45;
    outline: none;
    box-sizing: border-box;
    transition: all 160ms ease;
}

.ma-chat__form textarea::placeholder,
.ma-chat.ma-chat--dark .ma-chat__form textarea::placeholder,
.ma-chat.ma-chat--light .ma-chat__form textarea::placeholder {
    color: #64748B !important;
}

.ma-chat__form textarea:focus {
    border-color: #10B981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25) !important;
}

.ma-chat__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.ma-chat__footer span {
    color: var(--ma-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.ma-chat__tools {
    display: flex;
    align-items: center;
}

.ma-chat__attach-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ma-muted);
    background: var(--ma-surface-strong);
    border: 1px solid var(--ma-border);
    transition: all 150ms ease;
}

.ma-chat.ma-chat--dark .ma-chat__attach-trigger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.ma-chat__attach-trigger:hover {
    color: var(--ma-text);
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--ma-primary);
}

.ma-chat__attach-trigger svg {
    width: 17px;
    height: 17px;
}

.ma-chat__footer button {
    min-width: 78px;
    height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: #10b981;
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    transition: all 150ms ease;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ma-chat__footer button:hover,
.ma-chat__footer button:focus-visible {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.ma-chat__footer button:disabled,
.ma-chat__form textarea:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.ma-chat__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ma-chat__noscript {
    position: fixed;
    right: 24px;
    bottom: 24px;
    padding: 12px 14px;
    border-radius: var(--ma-radius);
    background: var(--ma-danger);
    color: #ffffff;
}

@media (max-width: 560px) {
    .ma-chat-preview {
        padding: 18px;
        align-items: start;
    }

    .ma-chat-preview__hero {
        padding: 28px;
    }

    .ma-chat {
        right: 8px;
        bottom: 8px;
    }

    .ma-chat--bottom_left {
        right: auto;
        left: max(12px, env(safe-area-inset-left));
    }

    .ma-chat__panel {
        position: fixed;
        top: max(12px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
        left: max(12px, env(safe-area-inset-left));
        width: auto;
        height: auto;
        max-width: none;
        border-radius: 18px;
    }

    .ma-chat__bubble {
        width: 60px;
        height: 60px;
    }


    .ma-chat__header {
        padding: 14px;
    }

    .ma-chat__body {
        padding: 14px;
    }

    .ma-chat__message {
        max-width: 92%;
    }
}

.ma-chat__icon-button--end {
    color: var(--ma-muted);
}

.ma-chat__icon-button--end:hover,
.ma-chat__icon-button--end:focus-visible {
    border-color: var(--ma-danger);
    color: var(--ma-danger);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.14);
}

.ma-chat__jump-latest {
    position: absolute;
    bottom: 92px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--ma-border);
    border-radius: 999px;
    background: var(--ma-surface);
    color: var(--ma-primary);
    font-family: var(--ma-font-family);
    font-size: 13px;
    font-weight: 700;
    box-shadow: var(--ma-shadow-soft);
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
    animation: ma-jump-in 180ms ease-out;
}

.ma-chat__jump-latest[hidden] {
    display: none !important;
}

.ma-chat__jump-latest:hover,
.ma-chat__jump-latest:focus-visible {
    background: var(--ma-surface-soft);
    box-shadow: var(--ma-shadow);
    transform: translateX(-50%) translateY(-2px);
}

@keyframes ma-jump-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.ma-chat__confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(17, 23, 20, 0.65);
    backdrop-filter: blur(3px);
    animation: ma-fade-in 180ms ease-out;
}

.ma-chat__confirm-overlay[hidden] {
    display: none !important;
}

@keyframes ma-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ma-chat__confirm-card {
    width: 100%;
    max-width: 320px;
    padding: 22px 20px;
    border: 1px solid var(--ma-border);
    border-radius: calc(var(--ma-radius) + 4px);
    background: var(--ma-surface);
    box-shadow: var(--ma-shadow);
    text-align: center;
}

.ma-chat__confirm-card h4 {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ma-text);
}

.ma-chat__confirm-card p {
    margin: 0 0 18px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ma-muted);
}

.ma-chat__confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ma-chat__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--ma-radius);
    font-family: var(--ma-font-family);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.ma-chat__btn:hover,
.ma-chat__btn:focus-visible {
    transform: translateY(-1px);
}

.ma-chat__btn--primary {
    background: var(--ma-primary);
    color: #ffffff;
}

.ma-chat__btn--primary:hover,
.ma-chat__btn--primary:focus-visible {
    background: var(--ma-primary-strong);
}

.ma-chat__btn--danger {
    background: var(--ma-danger);
    color: #ffffff;
}

.ma-chat__btn--danger:hover,
.ma-chat__btn--danger:focus-visible {
    background: color-mix(in srgb, var(--ma-danger) 85%, black);
}

.ma-chat__btn--ghost {
    border-color: var(--ma-border);
    background: var(--ma-surface);
    color: var(--ma-text);
}

.ma-chat__btn--ghost:hover,
.ma-chat__btn--ghost:focus-visible {
    background: var(--ma-surface-soft);
}

.ma-chat__ended-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 18px 0 6px;
    padding: 16px;
    border: 1px dashed var(--ma-border);
    border-radius: var(--ma-radius);
    background: var(--ma-surface-soft);
    text-align: center;
    animation: ma-fade-in 200ms ease-out;
}

.ma-chat__ended-banner p {
    margin: 0;
    color: var(--ma-muted);
    font-size: 13px;
    font-weight: 600;
}

.ma-chat__attachment-dock {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    background: var(--ma-surface);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    animation: ma-dock-in 180ms ease-out;
}

.ma-chat__attachment-dock[hidden] {
    display: none;
}

@keyframes ma-dock-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ma-chat__attachment-dock-thumb {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--ma-border);
    background: var(--ma-surface-strong);
}

.ma-chat__attachment-dock-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ma-chat__attachment-dock-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ma-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ma-chat__attachment-dock-meta {
    font-size: 11px;
    color: var(--ma-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ma-chat__attachment-dock-status {
    font-weight: 600;
}

.ma-chat__attachment-dock-status--uploading {
    color: var(--ma-accent, #c88a2a);
    animation: ma-pulse 1.2s infinite ease-in-out;
}

.ma-chat__attachment-dock-status--error {
    color: var(--ma-danger, #ef4444);
}

.ma-chat__attachment-dock-status--ready {
    color: var(--ma-primary, #0e5f4f);
}

.ma-chat__attachment-dock-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ma-chat__attachment-dock-btn {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--ma-border);
    background: var(--ma-surface-strong);
    color: var(--ma-text);
    cursor: pointer;
    transition: all 140ms ease;
}

.ma-chat__attachment-dock-btn:hover {
    background: var(--ma-surface-soft);
    border-color: var(--ma-primary);
}

.ma-chat__attachment-dock-remove {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--ma-muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 140ms ease;
}

.ma-chat__attachment-dock-remove:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--ma-danger, #ef4444);
}

.ma-chat__attach-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius);
    background: var(--ma-surface);
    color: var(--ma-muted);
    cursor: pointer;
    transition: all 150ms ease;
}

.ma-chat__attach-trigger:hover,
.ma-chat__attach-trigger:focus-visible {
    color: var(--ma-primary);
    border-color: var(--ma-primary);
    background: var(--ma-surface-soft);
}

.ma-chat__attach-trigger svg {
    width: 18px;
    height: 18px;
}

.ma-chat__msg-attachment {
    display: block;
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--ma-border);
    background: var(--ma-surface);
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
    text-decoration: none;
}

.ma-chat__msg-attachment:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.ma-chat__msg-attachment img {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 200px;
    object-fit: cover;
    background: var(--ma-surface-strong);
}

.ma-chat__msg-attachment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 11px;
    background: var(--ma-surface-strong);
    color: var(--ma-muted);
    border-top: 1px solid var(--ma-border);
}

.ma-chat__msg-attachment-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    font-weight: 500;
}

.ma-chat__lightbox {
    position: absolute;
    inset: 0;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 15, 20, 0.88);
    backdrop-filter: blur(4px);
    animation: ma-fade-in 160ms ease-out;
}

.ma-chat__lightbox[hidden] {
    display: none;
}

.ma-chat__lightbox-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 140ms ease;
}

.ma-chat__lightbox-close:hover {
    background: var(--ma-danger, #ef4444);
    border-color: var(--ma-danger, #ef4444);
}

.ma-chat__lightbox-img {
    max-width: 92%;
    max-height: 82%;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ma-chat__lightbox-caption {
    margin-top: 10px;
    color: #ffffff;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ma-chat__attachment-dock-progress {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.ma-chat__attachment-dock-bar {
    height: 100%;
    width: 0%;
    background: var(--ma-primary, #0e5f4f);
    border-radius: 2px;
    transition: width 140ms ease;
}

.ma-chat__attachment-dock-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: var(--ma-surface-strong);
    border: 1px solid var(--ma-border);
    color: var(--ma-primary);
    font-size: 20px;
}

.ma-chat__msg-video {
    display: block;
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--ma-border);
    background: #000000;
    max-width: 320px;
}

.ma-chat__msg-video video {
    display: block;
    width: 100%;
    max-height: 220px;
    border-radius: 8px 8px 0 0;
    outline: none;
}

.ma-chat__lightbox-video {
    max-width: 92%;
    max-height: 82%;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    outline: none;
}

@keyframes ma-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .ma-chat,
    .ma-chat *,
    .ma-chat *::before,
    .ma-chat *::after {
        animation-duration: 1ms !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

:root {
    --ma-bottom-nav-height: 70px;
    --ma-mobile-bottom-offset: calc(var(--ma-bottom-nav-height) + max(16px, env(safe-area-inset-bottom, 0px)));
}

.ma-chat {
    touch-action: none;
}

.ma-chat__bubble {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.ma-chat--dragging .ma-chat__bubble {
    cursor: grabbing !important;
    transition: none !important;
    transform: scale(1.06) !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.32) !important;
}

.ma-chat--snapping {
    transition: left 300ms cubic-bezier(0.2, 0.8, 0.2, 1), top 300ms cubic-bezier(0.2, 0.8, 0.2, 1), right 300ms cubic-bezier(0.2, 0.8, 0.2, 1), bottom 300ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.ma-chat__drag-hint {
    position: absolute;
    bottom: 72px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    background: var(--ma-surface-strong, #1f2c27);
    color: var(--ma-text, #ffffff);
    border: 1px solid var(--ma-border, #34463d);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    animation: ma-hint-pop 260ms cubic-bezier(0.2, 0.9, 0.3, 1);
    z-index: 1001;
}

.ma-chat__drag-hint--fade {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 300ms ease, transform 300ms ease;
}

@keyframes ma-hint-pop {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ma-chat--bottom_left .ma-chat__bubble {
    right: auto;
    left: 8px;
}
