/* === Meridian Chat Widget === */
.mt-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #06d6a0);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.mt-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.5);
}
.mt-chat-launcher svg { width: 26px; height: 26px; fill: #fff; }
.mt-chat-launcher[aria-expanded="true"] .mt-chat-icon-open { display: none; }
.mt-chat-launcher[aria-expanded="false"] .mt-chat-icon-close { display: none; }

.mt-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(13, 27, 42, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1a1a2e;
}
.mt-chat-panel.mt-open { display: flex; }

.mt-chat-header {
    background: linear-gradient(135deg, #0d1b2a, #1a2a3e);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.mt-chat-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}
.mt-chat-header .mt-chat-sub {
    font-size: 12px;
    opacity: 0.75;
    display: block;
    margin-top: 2px;
}
.mt-chat-reset {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.mt-chat-reset:hover { background: rgba(255,255,255,0.1); color: #fff; }

.mt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f9fc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mt-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.mt-msg-assistant {
    background: #fff;
    border: 1px solid #e5e8ef;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.mt-msg-user {
    background: linear-gradient(135deg, #6366f1, #06d6a0);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.mt-msg-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    align-self: flex-start;
    font-size: 13px;
}
.mt-msg a {
    color: #6366f1;
    text-decoration: underline;
}
.mt-msg-user a { color: #fff; }

.mt-typing {
    display: flex;
    gap: 4px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}
.mt-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: mt-bounce 1.2s infinite ease-in-out;
}
.mt-typing span:nth-child(2) { animation-delay: 0.15s; }
.mt-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mt-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.mt-chat-input {
    border-top: 1px solid #e5e8ef;
    padding: 12px;
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
.mt-chat-input textarea {
    flex: 1;
    border: 1px solid #e5e8ef;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    color: #1a1a2e;
    background: #f7f9fc;
}
.mt-chat-input textarea:focus {
    border-color: #6366f1;
    background: #fff;
}
.mt-chat-input button {
    background: linear-gradient(135deg, #6366f1, #06d6a0);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: opacity 0.2s;
}
.mt-chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }

.mt-chat-footer {
    padding: 6px 12px 10px;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    background: #fff;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .mt-chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .mt-chat-launcher { bottom: 16px; right: 16px; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .mt-chat-launcher,
    .mt-chat-panel,
    .mt-typing span { animation: none !important; transition: none !important; }
}

/* === Focus indicators (508) === */
.mt-chat-launcher:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.4);
}
.mt-chat-input textarea:focus-visible {
    outline: 3px solid #6366f1;
    outline-offset: -1px;
}
.mt-chat-input button:focus-visible {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
}
.mt-chat-reset:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* === Suggestion chips === */
.mt-suggest-chip {
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    color: #6366f1;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.mt-suggest-chip:hover {
    background: #f0f1ff;
    border-color: #6366f1;
}
