/* ═══════════════════════════════════════════════════════════════
   Medical Missionary — Naturopathic Consultation Styles
   ═══════════════════════════════════════════════════════════════ */

/* ─── Container ─────────────────────────────────────────────── */
.mm-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #f0f4f0 0%, #e4ebe4 100%);
    font-family: 'Inter', sans-serif;
    color: #333;
}

/* ─── Header ────────────────────────────────────────────────── */
.mm-header {
    background: linear-gradient(135deg, #1a4a2e 0%, #2d6b42 100%);
    color: white;
    padding: 16px 0 14px;
    text-align: center;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.mm-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

.mm-back-link {
    position: absolute;
    top: 0;
    left: 20px;
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    text-decoration: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.mm-back-link:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.mm-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mm-logo i {
    font-size: 24px;
    color: #8fd4a4;
}

.mm-logo h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
}

.mm-subtitle {
    font-size: 13px;
    opacity: 0.8;
    margin: 2px 0 0;
}

/* ─── Header Actions ─────────────────────────────────────────── */
.mm-header-actions {
    position: absolute;
    top: 6px;
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Reset / New Chat Button ───────────────────────────────── */
.mm-reset-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.mm-reset-btn:hover {
    background: rgba(255,255,255,0.25);
    color: white;
}

/* ─── Mode Toggle ───────────────────────────────────────────── */
.mm-mode-toggle {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.mm-mode-toggle:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.mm-mode-toggle.active {
    background: rgba(245, 158, 11, 0.9);
    border-color: rgba(245, 158, 11, 1);
    color: white;
}

/* ─── Disclaimer Banner ─────────────────────────────────────── */
.mm-disclaimer-banner {
    background: #fef3cd;
    border-bottom: 1px solid #ffc107;
    padding: 8px 20px;
    font-size: 12px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mm-disclaimer-banner i {
    flex-shrink: 0;
}

/* ─── Chat Area ─────────────────────────────────────────────── */
.mm-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px 16px;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ─── Messages ──────────────────────────────────────────────── */
.mm-message {
    margin-bottom: 16px;
    display: flex;
}

.mm-message-user {
    justify-content: flex-end;
}

.mm-message-assistant {
    justify-content: flex-start;
}

.mm-message-system {
    justify-content: center;
}

.mm-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 14.5px;
    word-wrap: break-word;
}

.mm-bubble-user {
    background: linear-gradient(135deg, #2d6b42, #3a8a56);
    color: white;
    border-bottom-right-radius: 4px;
}

.mm-bubble-assistant {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.mm-bubble-assistant p {
    margin: 0 0 10px;
}

.mm-bubble-assistant p:last-child {
    margin-bottom: 0;
}

.mm-bubble-assistant h2,
.mm-bubble-assistant h3 {
    margin: 18px 0 8px;
    color: #1a4a2e;
}

.mm-bubble-assistant h2:first-child,
.mm-bubble-assistant h3:first-child {
    margin-top: 0;
}

.mm-bubble-assistant h2 { font-size: 17px; }
.mm-bubble-assistant h3 { font-size: 15px; }

.mm-bubble-assistant ul,
.mm-bubble-assistant ol {
    margin: 8px 0;
    padding-left: 24px;
}

.mm-bubble-assistant li {
    margin-bottom: 4px;
}

.mm-bubble-assistant blockquote {
    border-left: 3px solid #2d6b42;
    margin: 10px 0;
    padding: 8px 14px;
    background: #f0f7f2;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #555;
}

.mm-bubble-assistant a {
    color: #2563eb;
    text-decoration: underline;
}

.mm-bubble-assistant strong {
    color: #1a4a2e;
}

.mm-bubble-assistant em {
    color: #666;
}

.mm-bubble-assistant hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

.mm-bubble-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-size: 13px;
    max-width: 70%;
    border-radius: 12px;
}

/* ─── Treatment Plan Sections ───────────────────────────────── */
.mm-section {
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0;
}

.section-plan-header { background: #ecfdf5; border-left: 4px solid #059669; }
.section-diet        { background: #fef9ef; border-left: 4px solid #d97706; }
.section-water       { background: #eff6ff; border-left: 4px solid #2563eb; }
.section-rest        { background: #f5f3ff; border-left: 4px solid #7c3aed; }
.section-exercise    { background: #ecfdf5; border-left: 4px solid #10b981; }
.section-air         { background: #f0f9ff; border-left: 4px solid #0ea5e9; }
.section-temperance  { background: #fff7ed; border-left: 4px solid #ea580c; }
.section-trust       { background: #fdf4ff; border-left: 4px solid #a855f7; }
.section-herbal      { background: #f0fdf4; border-left: 4px solid #16a34a; }
.section-conventional{ background: #f8fafc; border-left: 4px solid #64748b; }
.section-align       { background: #ecfdf5; border-left: 4px solid #059669; }
.section-differ      { background: #fff7ed; border-left: 4px solid #ea580c; }
.section-disclaimer  { background: #f8fafc; border-left: 4px solid #94a3b8; font-size: 13px; }

/* ─── Typing Indicator ──────────────────────────────────────── */
.mm-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.mm-typing-dots {
    display: flex;
    gap: 4px;
}

.mm-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2d6b42;
    opacity: 0.4;
    animation: mmTypingDot 1.4s infinite;
}

.mm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.mm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mmTypingDot {
    0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.2); }
}

.mm-typing-text {
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* ─── Input Bar ─────────────────────────────────────────────── */
.mm-input-bar {
    flex-shrink: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
}

.mm-input-wrap {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

#mm-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}

#mm-input:focus {
    border-color: #2d6b42;
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 107, 66, 0.1);
}

.mm-send-btn {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d6b42, #3a8a56);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mm-send-btn:hover {
    background: linear-gradient(135deg, #1a4a2e, #2d6b42);
    transform: scale(1.05);
}

.mm-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Citation Links ────────────────────────────────────────── */
.reference-link {
    color: #2d6b42;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.cite-ref-btn,
.verify-ref-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 3px;
    font-size: 12px;
    color: #999;
    transition: color 0.2s;
    vertical-align: middle;
}

.cite-ref-btn:hover { color: #2d6b42; }
.verify-ref-btn:hover { color: #2563eb; }

/* ─── Source Panel ──────────────────────────────────────────── */
.mm-source-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mm-source-panel.open {
    right: 0;
}

.mm-source-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.mm-source-panel-header h3 {
    margin: 0;
    font-size: 15px;
    color: #1a4a2e;
}

.mm-source-panel-actions {
    display: flex;
    gap: 8px;
}

.mm-source-cite-btn,
.mm-source-panel-close {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: all 0.2s;
    font-family: inherit;
}

.mm-source-cite-btn:hover,
.mm-source-panel-close:hover {
    background: #f3f4f6;
    color: #333;
}

.mm-source-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mm-source-title {
    font-size: 15px;
    margin-bottom: 16px;
    color: #1a4a2e;
}

.source-paragraph {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    color: #444;
}

.source-paragraph.highlight {
    background: #ecfdf5;
    border-left: 3px solid #059669;
}

.mm-source-loading,
.mm-source-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.mm-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #2d6b42;
    border-radius: 50%;
    animation: mmSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* ─── Citation Modal ────────────────────────────────────────── */
.mm-citation-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.mm-citation-modal.active {
    display: flex;
}

.mm-citation-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.mm-citation-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mm-citation-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1a4a2e;
}

.mm-citation-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 4px;
}

.mm-citation-ref-display {
    background: #f0f7f2;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 600;
    color: #1a4a2e;
    margin-bottom: 16px;
}

.mm-citation-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.mm-citation-tab {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}

.mm-citation-tab.active {
    background: #1a4a2e;
    color: white;
    border-color: #1a4a2e;
}

.mm-citation-format {
    display: none;
}

.mm-citation-format.active {
    display: block;
}

.mm-citation-text {
    background: #f9fafb;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 10px;
    border: 1px solid #e5e7eb;
}

.mm-citation-copy-btn {
    background: #1a4a2e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.2s;
}

.mm-citation-copy-btn:hover {
    background: #2d6b42;
}

.mm-citation-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}

.mm-citation-loading .mm-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin: 0;
}

.mm-citation-status {
    color: #991b1b;
    font-size: 13px;
    margin-top: 8px;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mm-header-inner { padding: 0 16px; }
    .mm-back-link { left: 12px; }

    .mm-header-actions {
        position: static;
        justify-content: center;
        margin: 10px auto 0;
    }

    .mm-bubble { max-width: 92%; }

    .mm-source-panel {
        width: 100%;
        right: -100%;
    }

    .mm-citation-modal-content {
        width: 95%;
        padding: 16px;
    }

    .mm-logo h1 { font-size: 19px; }
    .mm-subtitle { font-size: 12px; }
}

@media (max-width: 480px) {
    .mm-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    #mm-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .mm-send-btn {
        width: 42px;
        height: 42px;
    }
}

/* ─── Clinical Consultation Theme Overrides ─────────────────── */
:root {
    --mm-bg: #f4f7fb;
    --mm-surface: #ffffff;
    --mm-surface-alt: #f9fbff;
    --mm-border: #d8e1ec;
    --mm-text: #1f2a37;
    --mm-text-muted: #5b6878;
    --mm-primary: #1e5fae;
    --mm-primary-hover: #184f92;
    --mm-warning-bg: #fff8e6;
    --mm-warning-border: #f4d58d;
    --mm-warning-text: #7a5a11;
    --mm-danger: #b42318;
    --mm-shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
    --mm-radius: 12px;
}

.mm-container {
    background: var(--mm-bg);
    color: var(--mm-text);
}

.mm-header {
    background: var(--mm-surface);
    color: var(--mm-text);
    border-bottom: 1px solid var(--mm-border);
    box-shadow: none;
    padding: 14px 0 12px;
    text-align: left;
}

.mm-header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "back logo actions"
        ". subtitle actions";
    column-gap: 12px;
    row-gap: 3px;
    align-items: center;
}

.mm-back-link {
    position: static;
    grid-area: back;
    color: var(--mm-text-muted);
    margin-top: -1px;
}

.mm-back-link:hover {
    background: #eef4fc;
    color: var(--mm-primary);
}

.mm-logo {
    grid-area: logo;
    justify-content: flex-start;
}

.mm-logo i {
    color: var(--mm-primary);
}

.mm-logo h1 {
    font-size: 20px;
    color: #12263a;
}

.mm-subtitle {
    grid-area: subtitle;
    color: var(--mm-text-muted);
    opacity: 1;
    font-size: 13px;
    margin-left: 34px;
}

.mm-header-actions {
    position: static;
    grid-area: actions;
    justify-self: end;
    align-self: start;
    top: auto;
    right: auto;
    gap: 6px;
}

.mm-reset-btn {
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    color: var(--mm-text-muted);
    border-radius: 8px;
    font-size: 12px;
    padding: 6px 10px;
    line-height: 1.15;
    min-height: 32px;
}

.mm-reset-btn:hover {
    background: #f2f7ff;
    border-color: #bfd1e6;
    color: var(--mm-primary);
}

.mm-evidence-wrap {
    position: relative;
}

.mm-evidence-btn {
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    color: var(--mm-text-muted);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.15;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-family: inherit;
}

.mm-evidence-btn:hover,
.mm-evidence-btn.open {
    color: var(--mm-primary);
    border-color: #bfd1e6;
    background: #f2f7ff;
}

.mm-evidence-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 210px;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: 10px;
    box-shadow: var(--mm-shadow);
    padding: 8px;
    display: none;
    z-index: 20;
}

.mm-evidence-menu.open {
    display: block;
}

.mm-mode-toggle {
    width: 100%;
    justify-content: flex-start;
    border-radius: 8px;
    padding: 7px 9px;
    border: 1px solid var(--mm-border);
    color: var(--mm-text-muted);
    background: #f9fbff;
    font-size: 12px;
    min-height: 30px;
}

.mm-mode-toggle:hover {
    background: #eef4fc;
    color: var(--mm-primary);
}

.mm-mode-toggle.active {
    background: #e8f1ff;
    border-color: #bfd1e6;
    color: var(--mm-primary);
}

.mm-disclaimer-banner {
    background: var(--mm-warning-bg);
    border-bottom: 1px solid var(--mm-warning-border);
    color: var(--mm-warning-text);
    font-size: 12.5px;
    gap: 10px;
}

.mm-urgent-link {
    margin-left: auto;
    color: #9a3412;
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}

.mm-stage-strip {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mm-border);
    background: var(--mm-surface-alt);
    justify-content: center;
    flex-wrap: wrap;
}

.mm-stage {
    border: 1px solid var(--mm-border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--mm-text-muted);
    background: var(--mm-surface);
    font-weight: 600;
}

.mm-stage.active {
    color: var(--mm-primary);
    border-color: #b7cae2;
    background: #eaf2ff;
}

.mm-main-content {
    flex: 1;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    padding: 14px 16px 10px;
    box-sizing: border-box;
    min-height: 0;
}

.mm-chat-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mm-chat-area {
    max-width: none;
    margin: 0;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    background: var(--mm-surface);
    box-shadow: var(--mm-shadow);
    padding: 18px 14px 10px;
}

.mm-summary-card {
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    padding: 14px;
    box-shadow: var(--mm-shadow);
    align-self: start;
    position: sticky;
    top: 12px;
}

.mm-summary-card h3 {
    margin: 0 0 10px;
    color: #123252;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mm-summary-row {
    border-top: 1px solid #e7edf5;
    padding-top: 10px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mm-summary-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mm-text-muted);
    font-weight: 700;
}

.mm-summary-value {
    font-size: 13px;
    color: var(--mm-text);
    line-height: 1.45;
}

.mm-bubble {
    border-radius: 12px;
    font-size: 14.5px;
}

.mm-bubble-user {
    background: #eaf2ff;
    color: #15314f;
    border: 1px solid #cadcf5;
    border-bottom-right-radius: 4px;
}

.mm-bubble-assistant {
    border: 1px solid var(--mm-border);
    box-shadow: none;
}

.mm-bubble-assistant h2,
.mm-bubble-assistant h3,
.mm-bubble-assistant strong {
    color: #123252;
}

.mm-message {
    flex-wrap: wrap;
}

.mm-message-meta {
    margin-top: 6px;
    font-size: 11px;
    color: #7a8798;
    flex-basis: 100%;
}

.mm-message-assistant .mm-message-meta {
    margin-left: 6px;
}

.mm-message-user .mm-message-meta {
    margin-right: 6px;
    text-align: right;
}

.mm-typing-indicator {
    max-width: none;
    margin: 8px 0 0;
    padding: 0 8px;
}

.mm-typing-dots span {
    background: var(--mm-primary);
}

.mm-input-bar {
    border-top: 1px solid var(--mm-border);
    background: var(--mm-surface);
}

.mm-input-wrap {
    max-width: 1180px;
}

#mm-input {
    border: 1px solid var(--mm-border);
    background: #f8fbff;
    border-radius: 10px;
    min-height: 48px;
}

#mm-input:focus {
    border-color: #a7bfdc;
    box-shadow: 0 0 0 3px rgba(30, 95, 174, 0.14);
}

.mm-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--mm-primary);
}

.mm-send-btn:hover {
    background: var(--mm-primary-hover);
    transform: none;
}

.mm-upload-btn {
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    color: var(--mm-text-muted);
    border-radius: 10px;
    padding: 0 12px;
    min-height: 48px;
    font-size: 12.5px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.mm-upload-btn:hover {
    background: #eef4fc;
    border-color: #bfd1e6;
    color: var(--mm-primary);
}

.mm-file-input {
    display: none;
}

.mm-upload-note {
    font-size: 11.5px;
    color: var(--mm-text-muted);
    margin: 8px auto 0;
    max-width: 1180px;
}

.mm-attachments {
    max-width: 1180px;
    margin: 8px auto 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mm-attachment-chip {
    border: 1px solid var(--mm-border);
    background: var(--mm-surface-alt);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    color: #224260;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mm-attachment-chip .status {
    color: var(--mm-text-muted);
    font-size: 11px;
}

.mm-attachment-chip.uploading .status {
    color: #8a6d1f;
}

.mm-attachment-chip.error {
    border-color: #f1b3ab;
    background: #fff4f2;
    color: #7a271a;
}

.mm-attachment-remove {
    border: none;
    background: transparent;
    color: #9a6372;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.mm-upload-consent-content {
    max-width: 640px;
}

.mm-upload-consent-body {
    font-size: 13px;
    color: var(--mm-text);
}

.mm-upload-consent-body p {
    margin: 0 0 10px;
    line-height: 1.55;
}

.mm-upload-consent-body ul {
    margin: 0 0 12px 18px;
    padding: 0;
}

.mm-upload-consent-body li {
    margin-bottom: 6px;
}

.mm-consent-check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.mm-consent-check input {
    margin-top: 2px;
}

.mm-upload-consent-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.mm-upload-cancel-btn,
.mm-upload-accept-btn {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.mm-upload-cancel-btn {
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    color: var(--mm-text-muted);
}

.mm-upload-accept-btn {
    border: 1px solid var(--mm-primary);
    background: var(--mm-primary);
    color: #fff;
}

.mm-upload-accept-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.reference-link {
    color: var(--mm-primary);
}

.cite-ref-btn:hover { color: var(--mm-primary); }

.mm-urgent-alert {
    width: min(760px, 100%);
    background: #fff4f2;
    border: 1px solid #f1b3ab;
    border-left: 5px solid var(--mm-danger);
    border-radius: 10px;
    padding: 12px 14px;
    color: #7a271a;
    text-align: left;
    box-shadow: var(--mm-shadow);
}

.mm-urgent-alert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
}

.mm-urgent-alert p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.5;
}

.mm-urgent-alert-strong {
    font-weight: 700;
}

.mm-urgent-dismiss {
    border: 1px solid #e3978c;
    background: #fff;
    color: #7a271a;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.mm-urgent-dismiss:hover {
    background: #ffece8;
}

@media (max-width: 980px) {
    .mm-main-content {
        grid-template-columns: 1fr;
    }

    .mm-summary-card {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .mm-upload-btn span {
        display: none;
    }

    .mm-upload-btn {
        min-width: 48px;
        justify-content: center;
        padding: 0 10px;
    }

    .mm-urgent-link {
        margin-left: 0;
        white-space: normal;
    }

    .mm-disclaimer-banner {
        flex-wrap: wrap;
    }
}

@media (max-width: 520px) {
    .mm-header-inner {
        grid-template-columns: 1fr;
        grid-template-areas:
            "logo"
            "subtitle"
            "actions";
        row-gap: 8px;
    }

    .mm-back-link {
        display: none;
    }

    .mm-subtitle {
        margin-left: 0;
    }

    .mm-header-actions {
        justify-self: start;
        flex-wrap: wrap;
    }

    .mm-logo h1 {
        font-size: 17px;
    }

    .mm-evidence-menu {
        right: auto;
        left: 0;
    }
}

/* ─── Utility ───────────────────────────────────────────────── */
/* Author display rules below beat the UA [hidden] rule, so restate it. */
.mm-container [hidden],
.mm-citation-modal [hidden] {
    display: none !important;
}

.mm-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Focus visibility ──────────────────────────────────────── */
.mm-container a:focus-visible,
.mm-container button:focus-visible,
.mm-container input:focus-visible,
.mm-container select:focus-visible,
.mm-container textarea:focus-visible,
.mm-citation-modal button:focus-visible,
.mm-citation-modal input:focus-visible,
.mm-citation-modal select:focus-visible {
    outline: 3px solid #1e5fae;
    outline-offset: 2px;
    border-radius: 6px;
}

#mm-input:focus-visible {
    outline: 3px solid #1e5fae;
    outline-offset: 1px;
}

/* ─── Stage strip (ordered list semantics) ──────────────────── */
.mm-stage-nav {
    flex-shrink: 0;
}

.mm-stage-strip {
    list-style: none;
    margin: 0;
    padding: 12px 16px;
}

.mm-stage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mm-stage-strip-paused .mm-stage:not(.active) {
    opacity: 0.45;
}

.mm-stage-emergency {
    border-color: #f1b3ab;
    background: #fff4f2;
    color: #7a271a;
}

.mm-stage-emergency.active,
.mm-stage.mm-stage-emergency.active {
    background: var(--mm-danger);
    border-color: var(--mm-danger);
    color: #fff;
}

.mm-summary-value-alert {
    color: var(--mm-danger);
    font-weight: 700;
}

/* ─── Session notices ───────────────────────────────────────── */
.mm-session-notices:empty {
    display: none;
}

.mm-session-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    border-radius: var(--mm-radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: var(--mm-shadow);
    font-size: 13px;
    line-height: 1.5;
}

.mm-session-notice > i {
    margin-top: 2px;
    color: var(--mm-primary);
    flex-shrink: 0;
}

.mm-session-notice-text {
    flex: 1;
    min-width: 0;
}

.mm-session-notice-text strong {
    display: block;
    color: #123252;
    margin-bottom: 2px;
}

.mm-session-notice-text p {
    margin: 0;
    color: var(--mm-text-muted);
}

.mm-session-notice-success {
    border-color: #b7e0c4;
    background: #f2fbf5;
}

.mm-session-notice-success > i {
    color: #1c7a45;
}

.mm-session-notice-error {
    border-color: #f1b3ab;
    background: #fff4f2;
}

.mm-session-notice-error > i {
    color: var(--mm-danger);
}

.mm-session-notice-error .mm-session-notice-text p {
    color: #7a271a;
}

.mm-session-notice-action {
    border: 1px solid var(--mm-primary);
    background: var(--mm-primary);
    color: #fff;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    flex-shrink: 0;
}

.mm-session-notice-action:hover {
    background: var(--mm-primary-hover);
}

.mm-session-notice-dismiss {
    border: none;
    background: transparent;
    color: var(--mm-text-muted);
    cursor: pointer;
    font-size: 13px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
}

.mm-session-notice-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--mm-text);
}

/* ─── Upfront briefing ──────────────────────────────────────── */
.mm-briefing {
    border: 1px solid #c9dcf3;
    background: linear-gradient(180deg, #f6faff 0%, #eef5ff 100%);
    border-radius: var(--mm-radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--mm-shadow);
}

.mm-briefing-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mm-briefing-title {
    margin: 0;
    font-size: 13.5px;
    color: #123252;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mm-briefing-title i {
    color: var(--mm-primary);
}

.mm-briefing-toggle {
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    color: var(--mm-text-muted);
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    padding: 6px 12px;
    min-height: 32px;
    cursor: pointer;
}

.mm-briefing-toggle:hover {
    color: var(--mm-primary);
    border-color: #bfd1e6;
    background: #f2f7ff;
}

.mm-briefing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px 16px;
    margin: 10px 0 0;
}

.mm-briefing-item dt {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mm-text-muted);
    font-weight: 700;
    margin-bottom: 3px;
}

.mm-briefing-item dd {
    margin: 0;
    font-size: 13px;
    color: var(--mm-text);
    line-height: 1.45;
}

/* ─── Extraction confirmation card ──────────────────────────── */
.mm-extraction-card {
    width: min(760px, 100%);
    border: 1px solid var(--mm-border);
    border-left: 5px solid var(--mm-primary);
    background: var(--mm-surface);
    border-radius: var(--mm-radius);
    padding: 12px 14px;
    box-shadow: var(--mm-shadow);
    text-align: left;
}

.mm-extraction-unconfirmed {
    border-left-color: #d9a406;
    background: #fffdf5;
}

.mm-extraction-confirmed {
    border-left-color: #1c7a45;
    background: #f7fdf9;
}

.mm-extraction-discarded,
.mm-extraction-unreadable,
.mm-extraction-skipped {
    border-left-color: #94a3b8;
    background: #f8fafc;
}

.mm-extraction-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.mm-extraction-title {
    margin: 0;
    font-size: 13.5px;
    color: #123252;
    line-height: 1.45;
}

.mm-extraction-badge {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    padding: 4px 9px;
    background: #fdf3d5;
    color: #7a5a11;
    border: 1px solid #f0d79a;
}

.mm-extraction-confirmed .mm-extraction-badge {
    background: #e8f8ee;
    color: #14612f;
    border-color: #b7e0c4;
}

.mm-extraction-discarded .mm-extraction-badge,
.mm-extraction-unreadable .mm-extraction-badge,
.mm-extraction-skipped .mm-extraction-badge {
    background: #eef2f7;
    color: #475467;
    border-color: #d8e1ec;
}

.mm-extraction-meta {
    margin: 6px 0 10px;
    font-size: 11.5px;
    color: var(--mm-text-muted);
}

.mm-extraction-note,
.mm-extraction-warning {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--mm-text-muted);
}

.mm-extraction-warning {
    color: #7a5a11;
    font-weight: 600;
}

.mm-extraction-confirmed .mm-extraction-warning,
.mm-extraction-discarded .mm-extraction-warning {
    display: none;
}

.mm-analyte-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mm-analyte-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.9fr) minmax(0, 0.7fr) minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border: 1px solid #e7edf5;
    border-radius: 10px;
    background: var(--mm-surface-alt);
}

.mm-analyte-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.mm-analyte-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mm-text-muted);
    font-weight: 700;
}

.mm-analyte-input,
.mm-analyte-select {
    border: 1px solid var(--mm-border);
    border-radius: 8px;
    padding: 8px 9px;
    font-size: 13px;
    font-family: inherit;
    color: var(--mm-text);
    background: #fff;
    min-height: 36px;
    width: 100%;
    box-sizing: border-box;
}

.mm-analyte-input[readonly] {
    background: #f2f5f9;
    color: #33465c;
}

.mm-analyte-flag {
    align-self: flex-start;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 999px;
    padding: 5px 10px;
    border: 1px solid #d8e1ec;
    background: #eef2f7;
    color: #475467;
}

.mm-analyte-flag-high { background: #fff1ea; border-color: #f6c6a8; color: #9a3412; }
.mm-analyte-flag-low { background: #eef4ff; border-color: #bfd1f5; color: #1e40af; }
.mm-analyte-flag-normal { background: #e8f8ee; border-color: #b7e0c4; color: #14612f; }
.mm-analyte-flag-critical { background: #fff1f0; border-color: #f1b3ab; color: #7a271a; }

.mm-analyte-select {
    display: none;
}

.mm-extraction-card.editing .mm-analyte-select {
    display: block;
}

.mm-extraction-card.editing .mm-analyte-flag {
    display: none;
}

.mm-extraction-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.mm-extraction-btn {
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    color: var(--mm-text);
}

.mm-extraction-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.mm-extraction-confirm {
    border-color: var(--mm-primary);
    background: var(--mm-primary);
    color: #fff;
}

.mm-extraction-confirm:hover:not(:disabled) {
    background: var(--mm-primary-hover);
}

.mm-extraction-edit:hover:not(:disabled),
.mm-extraction-discard:hover:not(:disabled) {
    background: #f2f7ff;
    border-color: #bfd1e6;
}

.mm-extraction-status {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--mm-text-muted);
    min-height: 1em;
}

.mm-extraction-status:empty {
    margin: 0;
    min-height: 0;
}

.mm-extraction-history-list {
    margin: 8px 0 0 18px;
    padding: 0;
    font-size: 12.5px;
    color: var(--mm-text-muted);
    line-height: 1.55;
}

/* ─── Emergency phase card ──────────────────────────────────── */
.mm-urgent-alert-phase {
    border-left-width: 6px;
}

.mm-urgent-alert-body p {
    margin: 0 0 8px;
    font-size: 13.5px;
    line-height: 1.55;
}

.mm-urgent-alert-body p:last-child {
    margin-bottom: 0;
}

.mm-urgent-alert-body ul,
.mm-urgent-alert-body ol {
    margin: 8px 0;
    padding-left: 22px;
    font-size: 13.5px;
}

/* ─── Generate plan now ─────────────────────────────────────── */
.mm-plan-now-wrap {
    max-width: 1180px;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mm-plan-now-btn {
    border: 1px solid var(--mm-primary);
    background: #eaf2ff;
    color: var(--mm-primary);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.mm-plan-now-btn:hover:not(:disabled) {
    background: var(--mm-primary);
    color: #fff;
}

.mm-plan-now-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.mm-plan-now-hint {
    font-size: 11.5px;
    color: var(--mm-text-muted);
    flex: 1;
    min-width: 200px;
}

/* ─── Disabled composer ─────────────────────────────────────── */
.mm-composer-disabled #mm-input {
    background: #eef2f7;
    color: var(--mm-text-muted);
    cursor: not-allowed;
}

.mm-composer-disabled .mm-send-btn,
.mm-composer-disabled .mm-upload-btn {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Export panel ──────────────────────────────────────────── */
.mm-export {
    border-top: 1px solid #e7edf5;
    margin-top: 14px;
    padding-top: 12px;
}

.mm-export-title {
    margin: 0 0 4px;
    font-size: 13px;
    color: #123252;
}

.mm-export-hint {
    margin: 0 0 10px;
    font-size: 11.5px;
    color: var(--mm-text-muted);
    line-height: 1.45;
}

.mm-export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mm-export-btn {
    border: 1px solid var(--mm-border);
    background: var(--mm-surface);
    color: var(--mm-text);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 1 1 auto;
    justify-content: center;
}

.mm-export-btn:hover {
    background: #f2f7ff;
    border-color: #bfd1e6;
    color: var(--mm-primary);
}

.mm-export-status {
    margin: 8px 0 0;
    font-size: 11.5px;
    color: #14612f;
}

.mm-export-status:empty {
    margin: 0;
}

/* ─── Citation icon hit areas (44px minimum target) ─────────── */
.cite-ref-btn,
.verify-ref-btn {
    position: relative;
    padding: 2px 4px;
    line-height: 1;
}

.cite-ref-btn::after,
.verify-ref-btn::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}

.verify-ref-btn.verified { color: #1c7a45; }
.verify-ref-btn.unverified { color: var(--mm-danger); }
.verify-ref-btn.verify-failed { color: #b45309; }

.mm-attachment-remove {
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
}

/* ─── Print scaffolding (screen) ────────────────────────────── */
.mm-print-header,
.mm-print-footer {
    display: none;
}

/* ─── Responsive additions ──────────────────────────────────── */
@media (max-width: 980px) {
    .mm-export-btn {
        flex: 0 1 auto;
    }
}

@media (max-width: 768px) {
    .mm-analyte-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .mm-briefing-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .mm-session-notice {
        flex-wrap: wrap;
    }

    .mm-session-notice-action {
        width: 100%;
    }

    .mm-plan-now-hint {
        min-width: 0;
        flex-basis: 100%;
    }
}

@media (max-width: 520px) {
    .mm-analyte-row {
        grid-template-columns: 1fr;
    }

    .mm-extraction-header {
        flex-direction: column;
        gap: 6px;
    }

    .mm-extraction-btn,
    .mm-export-btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .mm-briefing-head {
        align-items: flex-start;
    }
}

/* ─── Print styles ──────────────────────────────────────────── */
@media print {
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        background: #fff !important;
        color: #222 !important;
    }

    .mm-header,
    .mm-disclaimer-banner,
    .mm-stage-nav,
    .mm-session-notices,
    .mm-briefing,
    .mm-typing-indicator,
    .mm-input-bar,
    .mm-source-panel,
    .mm-citation-modal,
    .mm-export,
    .mm-urgent-dismiss,
    .cite-ref-btn,
    .verify-ref-btn {
        display: none !important;
    }

    .mm-print-header,
    .mm-print-footer {
        display: block !important;
    }

    .mm-print-header {
        border-bottom: 2px solid #333;
        margin-bottom: 16px;
        padding-bottom: 8px;
    }

    .mm-print-header h2 {
        margin: 0 0 4px;
        font-size: 18pt;
        color: #111 !important;
    }

    .mm-print-subtitle,
    .mm-print-date {
        margin: 0;
        font-size: 9pt;
        color: #444 !important;
    }

    .mm-print-footer {
        border-top: 2px solid #333;
        margin-top: 18px;
        padding-top: 8px;
        page-break-inside: avoid;
    }

    .mm-print-disclaimer {
        font-size: 9pt;
        line-height: 1.5;
        color: #222 !important;
        margin: 0 0 6px;
    }

    .mm-print-source {
        font-size: 8pt;
        color: #555 !important;
        margin: 0;
    }

    .mm-container {
        display: block !important;
        min-height: 0 !important;
        background: #fff !important;
    }

    .mm-main-content {
        display: block !important;
        max-width: none !important;
        padding: 0 !important;
    }

    .mm-chat-column {
        display: block !important;
    }

    .mm-chat-area {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .mm-message {
        display: block !important;
        page-break-inside: avoid;
        margin-bottom: 12px;
    }

    .mm-bubble {
        max-width: 100% !important;
        border: none !important;
        border-bottom: 1px solid #ddd !important;
        border-radius: 0 !important;
        background: #fff !important;
        color: #222 !important;
        padding: 0 0 8px !important;
        box-shadow: none !important;
    }

    .mm-message-meta {
        font-size: 8.5pt;
        color: #555 !important;
        font-weight: 700;
    }

    .mm-summary-card {
        position: static !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        margin-top: 14px;
    }

    .mm-extraction-card,
    .mm-urgent-alert {
        width: 100% !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    .mm-analyte-input,
    .mm-analyte-select {
        border: none !important;
        background: transparent !important;
        min-height: 0 !important;
        padding: 0 !important;
        font-size: 9pt;
    }
}
