.message-delivered {
    color: var(--white);
}

/* =====================================================
   OMNICHANNEL — Merge Suggestion Banner

   Card layout: header (icon + title + score + close) → body (two
   customer cards joined by an arrow) → footer (criterion + accept).
   Themed via tokens so the same markup paints right in light & dark.
   ===================================================== */
.merge-suggestion-banner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    margin: 10px 12px;
    background: var(--card-bg-gradient, var(--white));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-subtle, 0 1px 2px rgba(0,0,0,0.05));
    font-size: 13px;
    color: var(--text-primary);
    position: relative;
    z-index: 10;
    animation: mergeSlideIn .25s ease;
}
@keyframes mergeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header row ── */
.merge-banner-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.merge-banner-head__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--bg-secondary, var(--color-cloud-canvas));
    color: var(--text-primary);
    font-size: 14px;
    flex-shrink: 0;
}
.merge-banner-head__title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.merge-banner-head__score {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-secondary, var(--color-cloud-canvas));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.merge-banner-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    transition: background 0.12s ease, color 0.12s ease;
    flex-shrink: 0;
}
.merge-banner-dismiss:hover {
    background: var(--bg-secondary, var(--color-cloud-canvas));
    color: var(--text-primary);
}

/* ── Body: two stacked customer cards joined by an arrow ── */
.merge-banner-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.merge-banner-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}
.merge-banner-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary, var(--color-cloud-canvas));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 0;
}
.merge-banner-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--card-bg-gradient, var(--white));
    color: var(--text-primary);
    font-size: 13px;
    flex-shrink: 0;
}
.merge-banner-card__name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}
.merge-banner-pair__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 18px;
    margin: -2px 0 -2px 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Meta row: criterion label ── */
.merge-banner-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.merge-banner-meta i { font-size: 12px; }

/* ── Footer: accept button ── */
.merge-banner-foot {
    display: flex;
    justify-content: flex-end;
}
.merge-banner-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.12s ease, transform 0.12s ease;
    font-family: inherit;
}
.merge-banner-btn:active { transform: scale(0.97); }
.merge-banner-accept {
    background: var(--primary-color);
    color: var(--white);
}
.merge-banner-accept:hover { opacity: 0.9; }

/* Inline merge confirm overlay */
.merge-inline-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.merge-inline-modal {
    background: var(--color-porcelain-surface);
    border-radius: 14px;
    padding: 20px;
    width: 360px;
    max-width: 95vw;
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.merge-inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 14px;
}
.merge-inline-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--color-deep-plum);
    padding: 2px;
}
.merge-inline-choices { display: flex; gap: 10px; margin-bottom: 16px; }
.merge-inline-choice {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--color-platinum-border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    transition: border-color .15s, background .15s;
}
.merge-inline-choice:hover { border-color: #3b82f6; background: #eff6ff; }
.merge-inline-choice.selected { border-color: #3b82f6; background: #eff6ff; }
.merge-inline-choice i { font-size: 20px; color: #3b82f6; }
.merge-inline-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Linked Channel Profiles (sidebar) ────────────────────── */
.linked-channel-profiles {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lcp-chip-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}
.lcp-chip-row .lcp-chip {
    flex: 1;
    min-width: 0;
}

.lcp-unlink-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fff5f5;
    color: #ef4444;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    padding: 0;
}
.lcp-unlink-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
}
.lcp-unlink-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.lcp-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border, var(--color-platinum-border));
    background: var(--bg-secondary, var(--color-cloud-canvas));
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, background .15s, box-shadow .15s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.lcp-chip:hover {
    border-color: var(--primary, #3b82f6);
    background: var(--primary-light, #eff6ff);
    box-shadow: 0 2px 8px rgba(59,130,246,.12);
    text-decoration: none;
    color: inherit;
}

.lcp-chip-icon {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.lcp-chip--whatsapp  .lcp-chip-icon { background:#dcfce7; color:#16a34a; }
.lcp-chip--instagram .lcp-chip-icon { background:#fce7f3; color:#be185d; }
.lcp-chip--facebook  .lcp-chip-icon { background:#dbeafe; color:#1d4ed8; }
.lcp-chip--telegram  .lcp-chip-icon { background:#e0f2fe; color:#0284c7; }
.lcp-chip--live-chat .lcp-chip-icon { background:#f3e8ff; color:#7c3aed; }
.lcp-chip--email     .lcp-chip-icon { background:#ede9fe; color:#6c5ce7; }

.lcp-chip-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.lcp-chip-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary, #111827);
}
.lcp-chip-id {
    font-size: 11px;
    color: var(--text-secondary, var(--color-deep-plum));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lcp-chip-ext {
    font-size: 12px;
    color: var(--text-secondary, var(--color-silver-detail));
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s;
}
.lcp-chip:hover .lcp-chip-ext { opacity: 1; }

/* ── Sidebar Merge Logs ────────────────────────────────────── */
.sml-list { display: flex; flex-direction: column; gap: 8px; }

.sml-item {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, var(--color-platinum-border));
    background: var(--bg-secondary, var(--color-cloud-canvas));
}
.sml-merged  { border-left: 3px solid #3b82f6; }
.sml-unlinked { border-left: 3px solid #f59e0b; }

.sml-icon {
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0; margin-top: 1px;
}
.sml-merged  .sml-icon { background: #dbeafe; color: #1d4ed8; }
.sml-unlinked .sml-icon { background: #fef3c7; color: #b45309; }

.sml-body { flex: 1; min-width: 0; }

.sml-title {
    display: flex; align-items: center; gap: 5px;
    flex-wrap: wrap; margin-bottom: 3px;
}
.sml-label {
    font-size: 10px; font-weight: 700; padding: 1px 7px;
    border-radius: 8px; letter-spacing: .3px;
}
.sml-label--merged   { background: #dbeafe; color: #1d4ed8; }
.sml-label--unlinked { background: #fef3c7; color: #b45309; }

.sml-sep { color: var(--text-secondary, var(--color-silver-detail)); font-size: 11px; }

.sml-names {
    font-size: 12px; color: var(--text-primary, #111827);
    display: flex; gap: 4px; flex-wrap: wrap;
    align-items: center; margin-bottom: 3px;
}
.sml-meta {
    font-size: 11px; color: var(--text-secondary, var(--color-silver-detail));
    display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
}

/* Small channel icon reuse */
.lcp-chip-icon--sm {
    width: 18px; height: 18px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px;
}


/* ═══════════════════════════════════════════════════════════
   SIDEBAR MERGE PANEL
   ═══════════════════════════════════════════════════════════ */

/* ── Trigger button ──────────────────────────────────────── */
.smp-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 12px auto 0;
    padding: 7px 20px;
    border-radius: 22px;
    border: none;
    background: var(--color-amethyst-strong);
    color: var(--color-porcelain-surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .2px;
    box-shadow: 0 2px 10px rgba(99,102,241,.30);
    transition: opacity .15s, box-shadow .15s, transform .12s;
}
.smp-trigger-btn:hover {
    opacity: .9;
    box-shadow: 0 4px 16px rgba(99,102,241,.40);
    transform: translateY(-1px);
}
.smp-trigger-btn i { font-size: 15px; }

/* Compact merge trigger (inline next to spam) */
.smp-trigger-btn--compact {
    margin: 0;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    gap: 5px;
    box-shadow: none;
    background: #2563eb;
    letter-spacing: 0;
    white-space: nowrap;
}
.smp-trigger-btn--compact:hover {
    opacity: 0.92;
    transform: none;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}
.smp-trigger-btn--compact i {
    font-size: 13px;
}
.smp-trigger-btn--compact .smp-trigger-label {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.smp-trigger-btn--compact .smp-count {
    padding: 0 5px;
    min-width: 16px;
    font-size: 9px;
    border-radius: 8px;
}

.smp-count {
    background: var(--color-porcelain-surface);
    color: var(--color-amethyst-strong);
    font-size: 10px;
    font-weight: 800;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 18px;
    text-align: center;
}

/* ── Panel container ─────────────────────────────────────── */
.smp-panel {
    display: block;
    flex-shrink: 0;
    margin: 10px 14px 4px;
    border-radius: 12px;
    background: var(--color-porcelain-surface);
    border: 1px solid var(--color-amethyst-soft);
    box-shadow: 0 6px 24px rgba(99,102,241,.13);
    overflow: hidden;
}

.smp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 13px;
    background: var(--color-amethyst-strong);
    border-bottom: 1px solid var(--color-amethyst-soft);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-amethyst-soft);
    letter-spacing: .1px;
}
.smp-panel-header i { font-size: 14px; margin-right: 4px; }

.smp-panel-close {
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-amethyst-strong); border: none; cursor: pointer;
    color: var(--color-amethyst-strong); font-size: 12px; padding: 0;
    transition: background .12s;
    flex-shrink: 0;
}
.smp-panel-close:hover { background: var(--color-amethyst-strong); }

/* ── Pair cards ──────────────────────────────────────────── */
#sidebarMergeCandidatesList {
    display: block;
    max-height: 300px;
    overflow-y: auto;
}

.smp-pair-card {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-cloud-canvas);
}
.smp-pair-card:last-child { border-bottom: none; }

/* Two accounts side by side */
.smp-pair-accounts {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.smp-pair-account {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-porcelain-surface);
    border: 1px solid var(--color-amethyst-soft);
    border-radius: 8px;
    padding: 6px 7px;
    text-decoration: none;
    color: inherit;
}
.smp-pair-account--link {
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.smp-pair-account--link:hover {
    border-color: var(--color-amethyst-strong);
    background: var(--color-amethyst-soft);
    color: inherit;
    text-decoration: none;
}
.smp-pair-ext {
    font-size: 11px;
    color: var(--color-amethyst-strong);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s;
}
.smp-pair-account--link:hover .smp-pair-ext { opacity: 1; }

.smp-pair-icon {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
    background: var(--color-cloud-canvas); color: var(--color-deep-plum);
}
.smp-pair-icon.lcp-chip--whatsapp  { background: #dcfce7; color: #16a34a; }
.smp-pair-icon.lcp-chip--instagram { background: #fce7f3; color: #be185d; }
.smp-pair-icon.lcp-chip--facebook  { background: #dbeafe; color: #1d4ed8; }
.smp-pair-icon.lcp-chip--telegram  { background: #e0f2fe; color: #0284c7; }
.smp-pair-icon.lcp-chip--live-chat { background: #f3e8ff; color: #7c3aed; }
.smp-pair-icon.lcp-chip--email     { background: #ede9fe; color: #6c5ce7; }

.smp-pair-meta { min-width: 0; }
.smp-pair-name {
    font-size: 11px; font-weight: 700;
    color: var(--text-primary, #111827);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.smp-pair-ch {
    font-size: 10px; color: var(--text-secondary, var(--color-silver-detail));
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.smp-pair-arrow {
    flex-shrink: 0;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-amethyst-soft); color: var(--color-amethyst-strong); font-size: 12px;
}

/* Footer row: match pill + select button */
.smp-pair-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.smp-match-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px; font-weight: 700;
    padding: 3px 10px; border-radius: 12px;
    color: var(--color-porcelain-surface);
    white-space: nowrap;
}
.smp-match-pill i { font-size: 12px; }

.smp-select-btn {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600;
    padding: 5px 12px; border-radius: 8px;
    border: none;
    background: var(--color-amethyst-strong);
    color: var(--color-porcelain-surface);
    cursor: pointer; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(99,102,241,.25);
    transition: opacity .12s, transform .12s;
}
.smp-select-btn:hover { opacity: .88; transform: translateY(-1px); }
.smp-select-btn i { font-size: 12px; }

/* ── Primary selector (step 2) ───────────────────────────── */
.smp-primary-select {
    padding: 12px 13px 10px;
    background: var(--color-porcelain-surface);
    border-top: 1px solid var(--color-amethyst-soft);
}
.smp-primary-label {
    font-size: 11px; font-weight: 700; letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--color-amethyst-strong);
    margin-bottom: 10px;
}
.smp-choices { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }

.smp-choice {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 10px;
    border: 2px solid var(--color-platinum-border);
    background: var(--color-porcelain-surface);
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.smp-choice:hover {
    border-color: var(--color-amethyst-strong);
    background: var(--color-amethyst-soft);
    box-shadow: var(--shadow-subtle);
}
.smp-choice.selected {
    border-color: var(--color-amethyst-strong);
    background: var(--color-amethyst-soft);
    box-shadow: 0 2px 10px rgba(99,102,241,.18);
}
.smp-choice.selected::after {
    content: "\eb4a"; /* ti-circle-check */
    font-family: "tabler-icons";
    color: var(--color-amethyst-strong);
    font-size: 16px;
    margin-left: auto;
}

.smp-choice-icon {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
    background: var(--color-cloud-canvas); color: var(--color-deep-plum);
}
.smp-choice-icon.lcp-chip--whatsapp  { background: #dcfce7; color: #16a34a; }
.smp-choice-icon.lcp-chip--instagram { background: #fce7f3; color: #be185d; }
.smp-choice-icon.lcp-chip--facebook  { background: #dbeafe; color: #1d4ed8; }
.smp-choice-icon.lcp-chip--telegram  { background: #e0f2fe; color: #0284c7; }
.smp-choice-icon.lcp-chip--live-chat { background: #f3e8ff; color: #7c3aed; }
.smp-choice-icon.lcp-chip--email     { background: #ede9fe; color: #6c5ce7; }

.smp-choice-info { flex: 1; min-width: 0; }
.smp-choice-name {
    font-size: 13px; font-weight: 600;
    color: var(--text-primary, #111827);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.smp-choice-ch {
    font-size: 11px; color: var(--text-secondary, var(--color-silver-detail)); margin-top: 1px;
}

.smp-actions {
    display: flex; justify-content: flex-end; gap: 7px;
}
.smp-actions .btn-secondary {
    border: 1.5px solid var(--color-platinum-border);
    background: var(--color-porcelain-surface);
    color: var(--color-deep-plum);
    font-size: 12px; font-weight: 600;
    padding: 5px 14px; border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}
.smp-actions .btn-secondary:hover { background: var(--color-cloud-canvas); }
.smp-actions .btn-primary {
    background: var(--color-amethyst-strong);
    color: var(--color-porcelain-surface); border: none;
    font-size: 12px; font-weight: 600;
    padding: 5px 16px; border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99,102,241,.25);
    transition: opacity .12s, transform .12s;
}
.smp-actions .btn-primary:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.smp-actions .btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── Dark-mode adjustments ────────────────────────────────────
   The brand-chip pastels above (.lcp-chip--whatsapp/.instagram/...)
   are hardcoded for light mode. In dark mode the light-pastel bg
   reads as a bright square on dark canvas with low text contrast,
   so we swap them for the gleap.css brand-tint tokens (which are
   tuned for the dark canvas) and keep the saturated brand glyph. */
[data-theme="dark"] .smp-pair-icon.lcp-chip--whatsapp,
[data-theme="dark"] .smp-choice-icon.lcp-chip--whatsapp {
    background: var(--brand-whatsapp-bg);
    color: var(--brand-whatsapp);
}
[data-theme="dark"] .smp-pair-icon.lcp-chip--instagram,
[data-theme="dark"] .smp-choice-icon.lcp-chip--instagram {
    background: var(--brand-instagram-bg);
    color: var(--brand-instagram);
}
[data-theme="dark"] .smp-pair-icon.lcp-chip--facebook,
[data-theme="dark"] .smp-choice-icon.lcp-chip--facebook {
    background: var(--brand-facebook-bg);
    color: var(--brand-facebook);
}
[data-theme="dark"] .smp-pair-icon.lcp-chip--telegram,
[data-theme="dark"] .smp-choice-icon.lcp-chip--telegram {
    background: var(--brand-telegram-bg);
    color: var(--brand-telegram);
}
[data-theme="dark"] .smp-pair-icon.lcp-chip--live-chat,
[data-theme="dark"] .smp-choice-icon.lcp-chip--live-chat {
    background: var(--brand-livechat-bg);
    color: var(--brand-livechat);
}

/* Panel header — light text on amethyst-strong reads fine in light
   mode; in dark mode the existing color (amethyst-soft) blends with
   the bg. Force a brighter foreground. */
[data-theme="dark"] .smp-panel-header {
    color: var(--color-porcelain-surface);
}
[data-theme="dark"] .smp-panel-close {
    color: var(--color-porcelain-surface);
    background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .smp-panel-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

/* Pair-account card border + meta text */
[data-theme="dark"] .smp-pair-account {
    border-color: var(--color-platinum-border);
}
[data-theme="dark"] .smp-pair-arrow {
    background: var(--color-amethyst-soft);
    color: var(--color-amethyst-strong);
}

/* Match pill text color (bg is set inline by JS using scoreColor) —
   keep white text so it's readable on whatever score bg is rendered. */
[data-theme="dark"] .smp-match-pill {
    color: #ffffff;
}


/* ═══════════════════════════════════════════════════════════
   MERGE HISTORY DRAWER
   ═══════════════════════════════════════════════════════════ */

/* History icon button in "Digər Kanallar" header */
.mh-drawer-trigger {
    background: none;
    border: 1px solid var(--border-color, var(--color-platinum-border));
    color: var(--text-secondary, var(--color-deep-plum));
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: color .15s, background .15s, border-color .15s;
    flex-shrink: 0;
}
.mh-drawer-trigger:hover {
    color: var(--color-amethyst-strong);
    background: var(--color-amethyst-soft);
    border-color: var(--color-amethyst-strong);
}

/* Overlay */
.mh-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.mh-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer panel */
.mh-drawer {
    position: fixed;
    top: 0; right: 0;
    width: 360px;
    max-width: 95vw;
    height: 100%;
    background: var(--color-porcelain-surface);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0,0,0,.15);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.mh-drawer--open {
    transform: translateX(0);
}

/* Header */
.mh-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-cloud-canvas);
    flex-shrink: 0;
    background: var(--color-amethyst-strong);
}
.mh-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-amethyst-soft);
}
.mh-drawer-title i { font-size: 18px; }
.mh-drawer-close {
    width: 30px; height: 30px; border-radius: 8px;
    border: none; background: var(--color-amethyst-soft);
    color: var(--color-ink-text); font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s;
}
.mh-drawer-close:hover { background: var(--color-amethyst-soft); }

/* Body */
.mh-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Loading / empty states */
.mh-loading, .mh-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--color-silver-detail);
    font-size: 13px;
}
.mh-loading i, .mh-empty i { font-size: 28px; }

/* Log list — vertical stack with breathing room between items.
   Items live inside #mergeHistoryList, not directly in .mh-drawer-body,
   so the parent's gap doesn't reach them. */
#mergeHistoryList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Log items */
.mh-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--color-cloud-canvas);
    background: var(--color-cloud-canvas);
}
.mh-item--merged  { border-color: #dbeafe; background: #f0f7ff; }
.mh-item--unlinked { border-color: #fef3c7; background: #fffbeb; }

.mh-item-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.mh-icon--merged   { background: #dbeafe; color: #2563eb; }
.mh-icon--unlinked { background: #fde68a; color: #92400e; }

.mh-item-body { flex: 1; min-width: 0; }

.mh-item-chips {
    display: flex; align-items: center; gap: 5px;
    flex-wrap: wrap; margin-bottom: 5px;
}
.mh-label {
    font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 8px; letter-spacing: .3px;
}
.mh-label--merged   { background: #dbeafe; color: #1d4ed8; }
.mh-label--unlinked { background: #fde68a; color: #92400e; }
.mh-sep { color: var(--color-silver-detail); font-size: 11px; }

.mh-item-names {
    font-size: 12px; color: #111827;
    display: flex; gap: 5px; flex-wrap: wrap;
    align-items: center; margin-bottom: 4px;
}
.mh-text-muted { color: var(--color-deep-plum); }

.mh-item-meta {
    font-size: 11px; color: var(--color-silver-detail);
    display: flex; align-items: center; gap: 4px;
}


/* ═══════════════════════════════════════════════════════════
   INSTAGRAM COMMENT BUBBLE
   Distinct visual treatment so comments are recognisable next
   to DMs in the same thread. Uses Instagram's brand tint as a
   left-edge accent + a small "Şərh" pill at the top.
   ═══════════════════════════════════════════════════════════ */

.message.message-ig-comment .message-content {
    border-left: 3px solid var(--brand-instagram, #E1306C);
    background: var(--brand-instagram-bg, rgba(225, 48, 108, 0.08));
    border-radius: 12px;
    padding: 10px 12px;
    max-width: 70%;
}

/* Outbound (our reply) gets a subtler treatment so it still reads
   as outgoing but stays linked visually to the comment thread. */
.message.outgoing.message-ig-comment .message-content {
    background: var(--color-amethyst-soft);
    border-left-color: var(--color-amethyst-strong);
    margin-left: auto;
}

.ig-comment-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--brand-instagram, #E1306C);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ig-comment-pill i { font-size: 12px; }

.message.outgoing.message-ig-comment .ig-comment-pill {
    background: var(--color-amethyst-strong);
}

.ig-comment-reply-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary, var(--color-silver-detail));
    margin-bottom: 4px;
    font-style: italic;
}
.ig-comment-reply-indicator i { font-size: 13px; }

.ig-comment-text {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-primary, var(--color-ink-text));
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ig-comment-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color, var(--color-platinum-border));
    margin-bottom: 4px;
}

.ig-comment-post-link,
.ig-comment-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ig-comment-post-link {
    background: transparent;
    color: var(--text-secondary, var(--color-silver-detail));
    border-color: var(--border-color, var(--color-platinum-border));
}
.ig-comment-post-link:hover {
    background: var(--color-cloud-canvas);
    color: var(--text-primary, var(--color-ink-text));
    text-decoration: none;
}

.ig-comment-reply-btn {
    background: var(--color-porcelain-surface);
    color: var(--brand-instagram, #E1306C);
    border-color: var(--brand-instagram-bg, rgba(225, 48, 108, 0.20));
    margin-left: auto;
}
.ig-comment-reply-btn:hover {
    background: var(--brand-instagram, #E1306C);
    color: #ffffff;
    border-color: var(--brand-instagram, #E1306C);
}

.ig-comment-post-link i,
.ig-comment-reply-btn i { font-size: 13px; }

/* ── Post-preview card (embedded inside the comment bubble) ──
   Compact 2-column layout: thumbnail on the left, caption snippet
   + meta on the right. The whole card is an anchor that opens the
   original post in a new tab — hover lifts the card slightly to
   signal interactivity. */
.ig-post-preview-card {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
    padding: 8px;
    margin: 6px 0 10px 0;
    background: var(--color-porcelain-surface);
    border: 1px solid var(--border-color, var(--color-platinum-border));
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    overflow: hidden;
}
.ig-post-preview-card:hover {
    border-color: var(--brand-instagram, #E1306C);
    box-shadow: var(--shadow-subtle);
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
}

.ig-post-preview-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-cloud-canvas);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ig-post-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Fallback when there's no thumbnail (carousel album, broken IG URL) */
.ig-post-preview-thumb--fallback {
    background: var(--brand-instagram-bg, rgba(225, 48, 108, 0.10));
    color: var(--brand-instagram, #E1306C);
    font-size: 28px;
}

/* VIDEO / REEL play-icon overlay */
.ig-post-preview-type-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.ig-post-preview-type-badge i { font-size: 12px; }

.ig-post-preview-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    gap: 4px;
}

.ig-post-preview-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--brand-instagram, #E1306C);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ig-post-preview-header i { font-size: 13px; }

.ig-post-preview-caption {
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--text-primary, var(--color-ink-text));
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.ig-post-preview-caption--muted {
    color: var(--text-secondary, var(--color-silver-detail));
    font-style: italic;
}

.ig-post-preview-footer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary, var(--color-silver-detail));
}
.ig-post-preview-footer i { font-size: 12px; }
.ig-post-preview-card:hover .ig-post-preview-footer {
    color: var(--brand-instagram, #E1306C);
}

/* ═══════════════════════════════════════════════════════════
   REPLY-TO-COMMENT BAR (above the chat input)
   Mirrors WhatsApp's quote-reply pattern: a slim bar pinned
   above the input with the comment preview and a × to cancel.
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   QUOTE-REPLY: per-message action button + reply-context bar.
   Mirrors WhatsApp's reply behavior — hover-reveal a reply
   button on each bubble; click pins the target above the input
   until the next send (or cancel).
   ═══════════════════════════════════════════════════════════ */

.message-content { position: relative; }

.message-action-reply {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
    color: var(--text-secondary, var(--color-silver-detail));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
    z-index: 2;
}
.message-action-reply i { font-size: 14px; line-height: 1; }

/* Outbound bubbles sit on the right — show the button on the left
   so it doesn't overlap the time/status row. Inbound bubbles get
   the button on the right. The button is anchored to touch the
   bubble edge (no gap) so the cursor never loses :hover while
   transiting from bubble → button. */
.message.outgoing .message-action-reply { left: -32px; }
.message.incoming .message-action-reply { right: -32px; }

/* Transparent hit-area bridge — a 14px wide invisible strip that
   sits in the space between the bubble and the button so any
   sliver of mouse-transit still keeps .message:hover alive. */
.message-action-reply::before {
    content: "";
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 14px;
}
.message.outgoing .message-action-reply::before { right: -10px; }
.message.incoming .message-action-reply::before { left: -10px; }

.message:hover .message-action-reply {
    opacity: 1;
    pointer-events: auto;
}
.message-action-reply:hover {
    background: var(--accent, var(--color-deep-plum));
    color: #fff;
    border-color: transparent;
}

/* Reply-context bar pinned above the chat input. */
.reply-to-message-bar {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 8px 12px;
    margin: 0 0 6px 0;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
    border-left: 3px solid var(--accent, var(--color-deep-plum));
    border-radius: 8px;
    animation: reply-bar-slide-in 0.18s ease-out;
}
.reply-to-message-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent, var(--color-deep-plum));
    font-size: 18px;
    flex-shrink: 0;
}
.reply-to-message-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.reply-to-message-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent, var(--color-deep-plum));
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.reply-to-message-text {
    font-size: 13px;
    color: var(--text-primary, var(--color-ink-text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-to-message-cancel {
    background: transparent;
    border: none;
    color: var(--text-secondary, var(--color-silver-detail));
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.reply-to-message-cancel:hover {
    background: var(--bg-secondary, var(--color-cloud-canvas));
    color: var(--text-primary, var(--color-ink-text));
}

.reply-to-comment-bar {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 8px 12px;
    margin: 0 0 6px 0;
    background: var(--brand-instagram-bg, rgba(225, 48, 108, 0.10));
    border-left: 3px solid var(--brand-instagram, #E1306C);
    border-radius: 8px;
    animation: reply-bar-slide-in 0.18s ease-out;
}

@keyframes reply-bar-slide-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.reply-to-comment-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-instagram, #E1306C);
    font-size: 18px;
    flex-shrink: 0;
}

.reply-to-comment-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reply-to-comment-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--brand-instagram, #E1306C);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.reply-to-comment-text {
    font-size: 13px;
    color: var(--text-primary, var(--color-ink-text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-to-comment-cancel {
    background: transparent;
    border: none;
    color: var(--text-secondary, var(--color-silver-detail));
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.reply-to-comment-cancel:hover {
    background: var(--color-cloud-canvas);
    color: var(--text-primary, var(--color-ink-text));
}
.reply-to-comment-cancel i { font-size: 16px; }

/* ─────────────────────────────────────────────────────────────
   Reply quote (DM-də mesajı işarələyib cavab yazıldıqda preview)
   Light/dark və incoming/outgoing baloncuqlarında oxunaqlı qalsın
   deyə rəng baloncuğun öz mətn rəngindən inherit olunur, fon
   isə qaranlıq tint (rgba black) — həm açıq yaşıl, həm tünd yaşıl
   üzərində kontrast saxlayır.
   ───────────────────────────────────────────────────────────── */
.message-reply-quote {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
    padding: 6px 10px;
    border-left: 3px solid currentColor;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.06);
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    transition: background 0.15s;
}
.message-reply-quote:hover {
    background: rgba(0, 0, 0, 0.10);
}

/* Incoming (ağ/açıq fon) — accent rənglə author, ikinci dərəcə muted text */
.message.incoming .message-reply-quote {
    border-left-color: var(--color-mocha-accent, #6b46c1);
}
.message.incoming .message-reply-quote-author {
    color: var(--color-mocha-accent, #6b46c1);
}
.message.incoming .message-reply-quote-text {
    color: var(--text-secondary, var(--color-silver-detail));
}

/* Outgoing (yaşıl baloncuq) — baloncuğun öz mətn rəngini miras alıb
   sadəcə opacity ilə hierarxiya yaradılır. Bu həm light mode-da
   (#d6e8d0 + tünd yaşıl mətn), həm dark mode-da (#1a3a2a + açıq mətn)
   düzgün kontrast verir. */
.message.outgoing .message-reply-quote {
    color: inherit;
}
.message.outgoing .message-reply-quote-author {
    color: inherit;
    opacity: 0.85;
}
.message.outgoing .message-reply-quote-text {
    color: inherit;
    opacity: 0.7;
}

.message-reply-quote-author {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-reply-quote-text {
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dark mode incoming baloncuq tünd canvas + açıq mətn —
   qaranlıq tint görünməz olur, daha açıq tint istifadə edilir. */
[data-theme="dark"] .message.incoming .message-reply-quote {
    background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .message.incoming .message-reply-quote:hover {
    background: rgba(255, 255, 255, 0.10);
}

/* Reply quote-a klik etdikdə hədəf mesajın qısa highlight-i */
@keyframes messageReplyFlash {
    0%   { box-shadow: 0 0 0 0 rgba(107, 70, 193, 0.45); }
    50%  { box-shadow: 0 0 0 6px rgba(107, 70, 193, 0.18); }
    100% { box-shadow: 0 0 0 0 rgba(107, 70, 193, 0); }
}
.message.message-reply-flash .message-content {
    animation: messageReplyFlash 1.4s ease-out;
}

/* ==========================================================================
   Email channel — message bubble + compose modal
   ========================================================================== */
.email-message .email-bubble {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.email-message.outgoing .email-bubble {
    background: #f5f3ff;
    border-color: #ddd6fe;
}
.email-message .email-header {
    border-bottom: 1px dashed #e5e7eb;
    padding-bottom: 8px;
    margin-bottom: 8px;
}
.email-message .email-subject {
    font-weight: 600;
    color: #111827;
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.email-message .email-subject i { color: #6c5ce7; }
.email-message .email-meta {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.55;
}
.email-message .email-meta strong { color: #111827; font-weight: 600; }
.email-message .email-preview {
    white-space: pre-wrap;
    word-break: break-word;
    color: #1f2937;
    line-height: 1.5;
    margin-bottom: 10px;
}
/* Rendered HTML preview — collapse default white-space, contain runaway sizes. */
.email-message .email-preview-html {
    white-space: normal;
    max-height: 360px;
    overflow: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}
.email-message .email-preview-html * { max-width: 100% !important; }
.email-message .email-preview-html img,
.email-message .email-preview-html table { max-width: 100% !important; height: auto; }
.email-message .email-preview-html blockquote {
    margin: 8px 0;
    padding-left: 10px;
    border-left: 3px solid #d1d5db;
    color: #6b7280;
}
.email-message .email-preview-html a { color: #2563eb; word-break: break-all; }
.email-message .email-preview-html p { margin: 0 0 8px; }
.email-message .email-preview-html br + br { display: none; }
.email-message .email-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.email-message .email-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f3f4f6;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 12px;
}
.email-message .email-attachment small { color: #6b7280; }
.email-message .email-actions {
    display: flex;
    gap: 8px;
    margin: 8px 0 6px;
}
.email-message .email-actions button {
    background: none;
    border: 1px solid #e5e7eb;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #4b5563;
}
.email-message .email-actions button:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}
.email-message .message-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    font-size: 11px;
    color: #6b7280;
}

/* CTA bar replacing the regular chat input for email conversations. */
.email-compose-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    margin: 12px 16px;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border: 1px solid #ddd6fe;
    border-radius: 12px;
}
.email-compose-cta-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4c1d95;
    font-size: 13px;
    line-height: 1.5;
}
.email-compose-cta-text i { font-size: 18px; color: #6c5ce7; flex-shrink: 0; }
.email-compose-cta .btn { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 600px) {
    .email-compose-cta { flex-direction: column; align-items: stretch; gap: 10px; }
    .email-compose-cta .btn { width: 100%; justify-content: center; }
}

/* ─── Email compose modal — redesigned, Gmail-style inline rows ──────────── */
.email-compose-container {
    width: min(720px, 92vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 32px 64px -12px rgba(15, 23, 42, 0.30), 0 8px 24px -8px rgba(15, 23, 42, 0.10);
}

.email-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}
.email-compose-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}
.email-compose-title-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    color: #6c5ce7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.email-compose-container .modal-close,
.email-fullview-container .modal-close {
    background: transparent;
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s;
    font-size: 18px;
}
/* Override the global `.modal-close i { color: white }` (defined unscoped
   in styles.css for the media preview modal) — without this the X icon is
   white on white and invisible. */
.email-compose-container .modal-close i,
.email-fullview-container .modal-close i {
    color: inherit;
    font-size: 18px;
}
.email-compose-container .modal-close:hover,
.email-fullview-container .modal-close:hover { background: #f1f5f9; color: #0f172a; }

.email-compose-body {
    overflow: auto;
    padding: 6px 22px 18px;
    flex: 1;
}

/* Inline field rows: label gutter on the left, value flex-grows */
.email-field-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    min-height: 44px;
}
.email-field-row:last-of-type { border-bottom: 0; }
.email-field-label {
    flex: 0 0 84px;
    padding-top: 9px;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.01em;
    margin: 0;
}
.email-field-value {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.email-field-input,
.email-field-select {
    flex: 1;
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: 0;
    padding: 9px 12px;
    background: #fff;
    font-size: 14px;
    color: #0f172a;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}
.email-field-input::placeholder { color: #94a3b8; }
.email-field-input:focus,
.email-field-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}
.email-field-input:read-only { color: #475569; cursor: default; background: #f8fafc; }
.email-field-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
    cursor: pointer;
}
.email-field-subject { font-weight: 500; }
.email-field-row-from { color: #475569; }

/* Cc / Bcc toggle chips, sitting at the end of the recipient row */
.email-cc-bcc-toggles {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
}
.email-toggle-link {
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    cursor: pointer;
    padding: 4px 10px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    transition: all .15s;
    letter-spacing: 0.02em;
}
.email-toggle-link:hover {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #e0e7ff;
}
.email-toggle-link.active {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

/* Chip-input inside compose modal — same bordered look as text inputs. */
.email-compose-body .email-chip-input {
    flex: 1;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 5px 10px;
    min-height: 40px;
    transition: border-color .15s, box-shadow .15s;
}
.email-compose-body .email-chip-input:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}
.email-compose-body .email-chip-input .email-chip-input-field {
    font-size: 14px;
    padding: 4px 2px;
}

/* Body editor + toolbar */
.email-compose-body-wrap {
    margin-top: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    overflow: hidden;
}
.email-compose-body-wrap:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}
.email-editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}
.email-tool-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #475569;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all .12s;
}
.email-tool-btn:hover { background: #eef2ff; color: #4338ca; }
.email-tool-btn.active {
    background: #e0e7ff;
    color: #4338ca;
    border-color: #c7d2fe;
}
.email-tool-divider {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
    margin: 0 4px;
}
.email-tool-select {
    height: 28px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 6px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    cursor: pointer;
    outline: 0;
    transition: border-color .12s;
}
.email-tool-select:hover { border-color: #c7d2fe; }
.email-tool-select:focus { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.18); }
.email-tool-color {
    position: relative;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    font-size: 15px;
    transition: background .12s;
}
.email-tool-color:hover { background: #eef2ff; color: #4338ca; }
.email-tool-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
}

.email-compose-body-editor {
    background: #fff;
    border: 0;
    padding: 14px 16px;
    line-height: 1.6;
    font-size: 14px;
    color: #0f172a;
    min-height: 200px;
    max-height: 380px;
    overflow: auto;
    transition: none;
}
.email-compose-body-editor:focus { outline: 0; }
.email-compose-body-editor:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}
.email-compose-body-editor blockquote {
    margin: 8px 0;
    border-left: 3px solid #cbd5e1;
    padding-left: 12px;
    color: #64748b;
    font-style: italic;
}

/* Attachments — drop-zone trigger style */
.email-attachments-zone { margin-top: 16px; }
.email-attachments-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1.5px dashed #cbd5e1;
    border-radius: 10px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.email-attachments-trigger:hover {
    border-color: #6366f1;
    color: #4338ca;
    background: #f5f3ff;
}
.email-attachments-trigger i { font-size: 16px; }
.email-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.email-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #334155;
}
.email-attachment-chip small { color: #94a3b8; font-weight: 500; }

/* Footer */
.email-compose-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid #f1f5f9;
    background: #fafbff;
}
.email-compose-footer .btn { padding: 9px 18px; font-size: 13.5px; }
.email-compose-footer .btn-primary {
    box-shadow: 0 4px 12px -2px rgba(108, 92, 231, 0.40);
}

@media (max-width: 640px) {
    .email-field-row { flex-direction: column; gap: 4px; min-height: 0; }
    .email-field-label { flex: 0 0 auto; padding-top: 0; }
    .email-field-value { width: 100%; }
}
.email-fullview-container { width: min(960px, 96vw); max-height: 90vh; display: flex; flex-direction: column; }
.email-fullview-container .modal-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.email-fullview-container #emailFullViewFrame { flex: 1; min-height: 400px; }

.email-fullview-attachments {
    border-top: 1px solid #e5e7eb;
    background: #fafbff;
    padding: 14px 20px 18px;
}
.email-fullview-attachments-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.email-fullview-attachments-header i { color: #6c5ce7; font-size: 14px; }
.email-fullview-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.email-fullview-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #334155;
    font-size: 13px;
    text-decoration: none;
    transition: all .15s;
    max-width: 320px;
}
.email-fullview-attachment:hover {
    border-color: #c7d2fe;
    background: #f5f3ff;
    color: #4338ca;
}
.email-fullview-attachment > i:first-child { color: #6c5ce7; font-size: 16px; flex-shrink: 0; }
.email-fullview-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.email-fullview-attachment small { color: #94a3b8; font-weight: 500; flex-shrink: 0; }
.email-fullview-attachment-action {
    color: #94a3b8;
    font-size: 15px;
    transition: color .12s;
}
.email-fullview-attachment:hover .email-fullview-attachment-action { color: #6c5ce7; }

/* Vertically center compose/full-view modals (global .modal-overlay aligns to top). */
.modal-overlay.email-modal-centered { align-items: center; }

/* Chip-input for To / Cc / Bcc */
.email-chip-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 38px;
    padding: 4px 6px;
    cursor: text;
}
.email-chip-input:focus-within {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}
.email-chip-input .email-chip-input-field {
    flex: 1;
    min-width: 120px;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 4px;
    font-size: 13px;
}
.email-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
}
.email-chip-remove {
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
}
.email-chip-remove:hover { color: #dc2626; }
.btn-link {
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Instagram story_mention bubble — small header above the screenshot
   so it's visually distinct from a plain image DM. */
.story-mention-message .story-mention-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    opacity: 0.7;
}
.story-mention-message .story-mention-header i { font-size: 14px; }

/* Instagram story_reply bubble — story thumbnail + the customer's reply
   text, so the agent sees which story was answered. */
.story-reply-message .story-reply-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    opacity: 0.7;
}
.story-reply-message .story-reply-header i { font-size: 14px; }
.story-reply-message .story-reply-body {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.story-reply-message .story-reply-thumb {
    flex: 0 0 auto;
    width: 54px;
    height: 96px;
    border-radius: 10px;
    overflow: hidden;
    border-left: 3px solid #c13584; /* Instagram accent */
    background: rgba(0, 0, 0, 0.05);
}
.story-reply-message .story-reply-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.story-reply-message .story-reply-text {
    margin: 0;
    align-self: center;
    word-break: break-word;
}
