/* WAdash dashboard styles (loaded by index.html). */
        body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f0f2f5; margin: 0; padding: 20px; color: #333; }
        .container { max-width: 1200px; margin: 0 auto; display: none; }
        header {
            background: white; padding: 15px 25px; border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 20px;
            display: flex; justify-content: space-between; align-items: center;
            flex-wrap: wrap; gap: 12px;
        }
        h1 { margin: 0; font-size: 22px; color: #128c7e; }
        .header-right { display: flex; align-items: center; gap: 10px; }
        .user-badge { font-size: 14px; font-weight: 600; color: #475569; background: #edf2f7; padding: 6px 12px; border-radius: 6px; border: 0; cursor: pointer; font-family: inherit; min-height: 36px; }
        .user-badge:hover { background: #e2e8f0; }
        .user-menu-wrap { position: relative; display: inline-flex; }
        .user-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 1300; min-width: 240px; max-width: calc(100vw - 16px); background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column; }
        .user-menu[hidden] { display: none; }
        .user-menu button { text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; color: #1e293b; }
        .user-menu button:hover { background: #f1f5f9; }
        .user-menu .um-logout { color: #b91c1c; border-top: 1px solid #f1f5f9; border-radius: 0 0 8px 8px; margin-top: 4px; }
        .user-menu .um-line { font-size: 12px; color: #64748b; padding: 6px 12px 8px; border-bottom: 1px solid #f1f5f9; margin-bottom: 4px; }
        html.dark-ui .user-menu { background: var(--surface) !important; border-color: var(--border) !important; box-shadow: 0 12px 32px rgba(0,0,0,.55) !important; }
        html.dark-ui .user-menu .um-line { color: var(--muted) !important; border-color: var(--border) !important; }
        html.dark-ui .user-menu .um-logout { color: #fca5a5 !important; border-color: var(--border) !important; }
        .user-menu .um-line { overflow-wrap: anywhere; }
        html.dark-ui .user-menu button { color: var(--text) !important; }
        html.dark-ui .user-menu button:hover { background: var(--surface2) !important; }
        .session-picker { display: inline-flex; align-items: center; gap: 6px; background: #edf2f7; padding: 3px 4px 3px 10px; border-radius: 6px; font-size: 14px; }
        .session-picker select { padding: 4px 8px; border: 1px solid #cbd5e0; border-radius: 5px; background: #fff; font-size: 13px; font-weight: 600; color: #334155; max-width: 220px; outline: none; }
        .session-picker select:focus { border-color: #128c7e; }
        .session-cycle-btn { border: 0; background: transparent; padding: 3px 2px; font-size: 17px; line-height: 1; cursor: pointer; border-radius: 4px; }
        .session-cycle-btn:hover, .session-cycle-btn:focus-visible { background: rgba(18,140,126,.14); outline: 2px solid #128c7e; outline-offset: 1px; }
        .header-right { flex-wrap: wrap; }
        /* Collapsible header: user, Tools and Logout show only after clicking the title */
        #title-toggle { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 8px; }
        #title-toggle .title-caret { font-size: 13px; color: #94a3b8; transition: transform .15s; }
        header.expanded #title-toggle .title-caret { transform: rotate(180deg); }
        header:not(.expanded) .collapsible, header:not(.expanded) #tools-panel { display: none !important; }
        /* Session picker under the "Messages" title */
        /* Messages toolbar: one row on desktop, stacked neatly on small screens */
        .feed-card .feed-head { display: grid !important; grid-template-columns: auto auto 1fr auto auto auto auto;
            grid-template-areas: "title session . order layout view contacts"; align-items: center; gap: 8px 10px; }
        .fh-title { grid-area: title; white-space: nowrap; font-size: 20px; }
        .fh-session { grid-area: session; justify-self: start; min-width: 0; padding: 2px 3px 2px 6px !important; gap: 4px !important; }
        .fh-session select { padding: 4px 6px !important; font-size: 13px !important; max-width: 170px; min-width: 0; }
        .fh-session .session-cycle-btn { font-size: 15px; padding: 2px 1px; }
        .fh-layout { grid-area: layout; }
        .fh-order { grid-area: order; justify-self: end; display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 9px; border: 1px solid #cbd5e0;
            background: #fff; color: #334155; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
        .fh-order:hover { background: #f1f5f9; }
        .fh-order[hidden] { display: none !important; }
        html.dark-ui .fh-order { background: var(--surface, #0f172a) !important; color: var(--text) !important; border-color: var(--border) !important; }
        .feed-head > * { box-sizing: border-box; max-width: 100%; }
        .fh-view { grid-area: view; }
        .fh-contacts { grid-area: contacts; justify-self: end; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px;
            border: 1px solid #0e7490; background: #ecfeff; color: #0e7490; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
        .fh-contacts:hover { background: #cffafe; }
        .feed-head .view-switch button { height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
        html.dark-ui .fh-contacts { background: var(--surface, #0f172a) !important; color: #67e8f9 !important; border-color: #155e75 !important; }
        @media (max-width: 1079px) {
            .feed-card .feed-head { grid-template-columns: minmax(0, 1fr) auto auto;
                grid-template-areas: "title title contacts" "session order layout" "view view view"; }
            .fh-order span { display: none; }
            .fh-session { justify-self: stretch; }
            .fh-session select { max-width: none; flex: 1; width: 100%; }
            .fh-layout { justify-self: end; }
            .fh-view { display: flex !important; width: 100%; }
            .fh-view button { flex: 1; padding-left: 4px !important; padding-right: 4px !important; }
            .fh-title { font-size: 18px; }
        }
        @media (max-width: 380px) {
            .feed-card .feed-head { grid-template-areas: "title title contacts" "session session order" "layout layout layout" "view view view"; }
            .fh-layout { display: flex !important; width: 100%; justify-self: stretch; }
            .fh-layout button { flex: 1; }
            .fh-contacts span { display: none; }
        }
        /* Click the Messages title to compact or restore the feed toolbar. */
        .feed-card.toolbar-collapsed #layout-switch,
        .feed-card.toolbar-collapsed #view-switch,
        .feed-card.toolbar-collapsed #contacts-btn,
        .feed-card.toolbar-collapsed #feed-range,
        .feed-card.toolbar-collapsed .archive-banner-info { display: none !important; }
        #feed-title { cursor: pointer; user-select: none; }
        #feed-title:focus-visible { outline: 2px solid #128c7e; outline-offset: 3px; border-radius: 3px; }
        /* Feed range: archive note only after clicking the clock */
        .feed-range .range-icon { border: none; background: transparent; padding: 0 2px; font-size: 14px; cursor: pointer; border-radius: 4px; }
        .feed-range .range-icon:hover { background: rgba(18,140,126,.14); }
        /* Profile photo viewer */
        .conv-photo-clickable .avatar img, .chat-bubble .avatar img { cursor: zoom-in; }
        #photo-viewer { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; cursor: zoom-out; }
        #photo-viewer.show { display: flex; }
        #photo-viewer img { max-width: 92vw; max-height: 84vh; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5); background: #111; }
        #photo-viewer .pv-cap { color: #e2e8f0; font-size: 13px; text-align: center; }
        #photo-viewer .pv-cap a { color: #93c5fd; }
        /* Transcription state chip: in progress vs queued */
        .tr-state { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; margin-left: 4px; white-space: nowrap; vertical-align: middle; }
        .tr-state.active { background: #dcfce7; color: #166534; border: 1px solid #86efac; animation: tr-pulse 1.4s ease-in-out infinite; }
        .tr-state.queued { background: #f1f5f9; color: #475569; border: 1px dashed #94a3b8; }
        @keyframes tr-pulse { 50% { box-shadow: 0 0 0 3px rgba(34,197,94,.25); } }
        .transcript.tr-is-active .tr-icon { border-color: #22c55e; background: #f0fdf4; }
        html.dark-ui .tr-state.active { background: #14532d !important; color: #bbf7d0 !important; border-color: #166534 !important; }
        html.dark-ui .tr-state.queued { background: #1e293b !important; color: #cbd5e1 !important; border-color: #475569 !important; }
        .sys-stats { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: #334155; }
        .sys-stats span { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
        .sys-stats .hi { background: #fef3c7; border-color: #fcd34d; }
        .sys-stats .crit { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
        header:not(.expanded) .sys-stats { display: none !important; }
        html.dark-ui .sys-stats { color: var(--text) !important; }
        html.dark-ui .sys-stats span { background: var(--surface2, #1e293b) !important; border-color: var(--border, #334155) !important; color: var(--text, #e2e8f0) !important; }
        html.dark-ui .sys-stats .hi { background: #422006 !important; color: #fde68a !important; }
        html.dark-ui .sys-stats .crit { background: #450a0a !important; color: #fecaca !important; }
        .tr-mode-extra { margin: 4px 0 2px 26px; padding: 9px 11px; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; }
        .tr-mode-extra label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 13px; }
        .tr-mode-extra input { margin-top: 3px; }
        .tr-mode-extra small { display: block; color: #64748b; margin-top: 2px; }
        /* Compact toolbar: session · search · filter · ↻ · CSV on one line; two lines on phones */
        .ct-bar { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto auto;
            grid-template-areas: "session search book refresh export"; gap: 6px; align-items: center; padding: 10px 16px 4px; }
        .ct-bar > * { box-sizing: border-box; height: 30px; min-width: 0; }
        .ct-bar select, .ct-bar input { padding: 0 8px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 13px; background: #fff; }
        .ct-session-picker { grid-area: session; }
        #ct-search { grid-area: search; width: 100%; }
        #ct-book { grid-area: book; }
        #ct-refresh { grid-area: refresh; }
        #ct-export { grid-area: export; }
        .ct-icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 30px; padding: 0 8px;
            border: 1px solid #cbd5e0; background: #fff; color: #334155; border-radius: 6px; font-size: 13px; font-weight: 700; cursor: pointer; }
        .ct-icon-btn:hover { background: #f1f5f9; }
        #ct-refresh { font-size: 16px; }
        .ct-export { border-color: #15803d; color: #15803d; background: #f0fdf4; }
        .ct-export:hover { background: #dcfce7; }
        .ct-meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 0 16px 2px; min-height: 16px; }
        @media (max-width: 600px) {
            .ct-bar { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "session refresh export" "search search book"; }
            .ct-session-picker select { max-width: none; width: 100%; }
        }
        html.dark-ui .ct-icon-btn { background: var(--surface, #0f172a) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .ct-export { color: #86efac !important; border-color: #166534 !important; }
        .ct-bar .ct-session-picker { padding: 0 3px 0 6px; gap: 4px; }
        .ct-bar .ct-session-picker select { height: 24px; padding: 0 6px; font-weight: 600; border: 1px solid #cbd5e0; max-width: 150px; }
        .ct-count { font-size: 12px; color: #64748b; white-space: nowrap; }
        .ct-note { font-size: 12px; color: #92400e; }
        .ct-note:empty { display: none; }
        .ct-wrap { overflow: auto; padding: 6px 16px 16px; flex: 1; min-height: 200px; }
        .ct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
        .ct-table th { position: sticky; top: 0; background: #e2e8f0; text-align: left; padding: 7px 8px; cursor: pointer; white-space: nowrap; user-select: none; z-index: 1; }
        .ct-table th.sorted::after { content: " ▲"; font-size: 10px; }
        .ct-table th.sorted.desc::after { content: " ▼"; }
        .ct-table td { padding: 6px 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
        .ct-table tbody tr { cursor: pointer; }
        .ct-table tbody tr:hover { background: #f0fdf9; }
        .ct-table .ct-sub { display: block; font-size: 11px; color: #64748b; }
        .ct-table .ct-id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
        .ct-yes { color: #15803d; font-weight: 700; }
        .ct-no { color: #94a3b8; }
        html.dark-ui .ct-table th { background: var(--surface2, #1e293b) !important; color: var(--text) !important; }
        html.dark-ui .ct-table td { border-color: var(--border, #334155) !important; }
        html.dark-ui .ct-table tbody tr:hover { background: rgba(255,255,255,.05) !important; }
        html.dark-ui .ct-bar select, html.dark-ui .ct-bar input { background: var(--surface, #0f172a) !important; color: var(--text) !important; border-color: var(--border) !important; }
        /* While a pop-up is open the page behind must not scroll (also on phones). */
        html.modal-open, html.modal-open body { overflow: hidden !important; overscroll-behavior: none; }
        html.modal-open body { position: fixed; left: 0; right: 0; width: 100%; }
        .modal-overlay, #photo-viewer { overscroll-behavior: contain; touch-action: pan-x pan-y; }
        .modal-overlay *, #chat-thread-container { overscroll-behavior: contain; }
        .vcard-box { border: 1px solid #cbd5e0; border-radius: 10px; padding: 8px 10px; background: #f8fafc; max-width: 420px; margin-top: 4px; }
        .vc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
        .vc-label { font-size: 11px; font-weight: 700; color: #0e7490; text-transform: uppercase; letter-spacing: .03em; }
        .vc-raw-btn { border: 1px solid #cbd5e0; background: #fff; border-radius: 6px; font-size: 13px; padding: 1px 6px; cursor: pointer; opacity: .75; }
        .vc-raw-btn:hover, .vc-raw-btn.active { opacity: 1; background: #ecfeff; border-color: #0e7490; }
        .vc-card + .vc-card { border-top: 1px dashed #cbd5e0; margin-top: 8px; padding-top: 8px; }
        .vc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
        .vc-avatar { width: 34px; height: 34px; border-radius: 50%; background: #e2e8f0; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
        .vc-name { font-weight: 700; }
        .vc-sub { font-size: 12px; color: #64748b; }
        .vc-row { font-size: 13px; margin: 2px 0 0 42px; word-break: break-word; }
        .vc-row small { color: #64748b; }
        .vc-wa { color: #15803d !important; font-weight: 600; }
        .vc-note { white-space: pre-wrap; }
        .vc-raw { margin: 8px 0 0; padding: 8px; background: #0f172a; color: #e2e8f0; border-radius: 6px; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
        html.dark-ui .vcard-box { background: var(--surface2, #1e293b) !important; border-color: var(--border, #334155) !important; }
        html.dark-ui .vc-avatar { background: #334155 !important; }
        html.dark-ui .vc-raw-btn { background: var(--surface, #0f172a) !important; border-color: var(--border) !important; }
        html.dark-ui .vc-sub, html.dark-ui .vc-row small { color: #94a3b8 !important; }
        .tr-goto { border: none; background: none; padding: 0; font: inherit; color: #4f46e5; text-decoration: underline dotted; cursor: pointer; }
        .tr-goto:hover { color: #3730a3; text-decoration: underline; }
        html.dark-ui .tr-goto { color: #a5b4fc !important; }
        .msg-item.goto-flash, .chat-bubble.goto-flash { outline: 3px solid #6366f1; outline-offset: 2px; animation: goto-pulse 1s ease-in-out 3; }
        @keyframes goto-pulse { 50% { outline-color: transparent; } }
        .tr-cancel-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
        .tr-cancel-btn { background-color: #b91c1c !important; }
        .tr-cancel-btn:disabled { opacity: .6; cursor: wait; }
        html.dark-ui .tr-mode-extra { background: #3a2a0a !important; border-color: #a16207 !important; }
        html.dark-ui .tr-mode-extra small { color: #cbd5e1 !important; }
        .autoplay-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; cursor: pointer; }
        .filter-controls { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
        .filter-controls[hidden] { display: none; }
        /* when the tools panel is shown it takes the full header width, below the top row */
        .filter-controls:not([hidden]) { flex-basis: 100%; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e2e8f0; }
        .filter-group { display: flex; align-items: center; gap: 6px; font-weight: 500; }
        .filter-controls select, .filter-controls input {
            padding: 6px 12px; border-radius: 6px; border: 1px solid #cbd5e0;
            background-color: #fff; font-size: 14px; outline: none;
        }
        .filter-controls input:focus, .filter-controls select:focus { border-color: #128c7e; }

        .action-btn { background-color: #128c7e; color: white; border: none; padding: 7px 14px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color 0.2s; }
        .action-btn:hover { background-color: #0e6c61; }
        .clear-btn { background-color: #e53e3e; color: white; border: none; padding: 7px 14px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color 0.2s; }
        .clear-btn:hover { background-color: #c53030; }
        .logout-btn { background-color: #718096; color: white; border: none; padding: 7px 14px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
        .logout-btn:hover { background-color: #4a5568; }

        /* Connection status pill */
        .conn-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
        /* WhatsApp session health: colored names in the session drop-down + a status icon next to it */
        #session-filter option { color: #1e293b; }
        html.dark-ui #session-filter option { color: var(--text); }
        #session-filter option.sh-green, #session-filter.sh-green { color: #16a34a !important; }
        #session-filter option.sh-yellow, #session-filter option.sh-starting, #session-filter.sh-yellow, #session-filter.sh-starting { color: #ca8a04 !important; }
        #session-filter option.sh-red, #session-filter.sh-red { color: #dc2626 !important; }
        #session-filter option.sh-unknown, #session-filter.sh-unknown { color: #64748b !important; }
        .sess-health[hidden] { display: none !important; }
        .sess-health-wrap { position: relative; display: inline-flex; vertical-align: middle; margin-left: 6px; }
        .fh-title .sess-health-icon { font-size: 18px; }
        .sess-health-pop { white-space: normal; font-weight: 400; text-align: left; }
        .sess-health-icon { border: 0; background: none; font-size: 16px; line-height: 1; padding: 2px 3px; cursor: pointer; border-radius: 6px; }
        .sess-health-icon:hover { background: rgba(0,0,0,.06); }
        .sess-health-icon.is-bad { animation: sh-pulse 1.6s ease-in-out infinite; }
        @keyframes sh-pulse { 50% { transform: scale(1.18); } }
        .sess-health-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 1200; width: 320px; max-width: 80vw; background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 10px 12px; font-size: 13px; line-height: 1.45; }
        .sess-health-pop[hidden] { display: none; }
        .sess-health-pop .shp-row { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
        .sess-health-pop .shp-row:last-child { border-bottom: 0; }
        .sess-health-pop .shp-meta { color: #64748b; font-size: 12px; }
        .sess-health-pop .shp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
        .sess-health-pop .shp-actions button { margin-top: 0; }
        .shp-sync.busy { cursor: wait; background: #dbeafe !important; }
        .shp-sync.done { background: #dcfce7 !important; border-color: #86efac !important; }
        .shp-sync.error { background: #fee2e2 !important; border-color: #fca5a5 !important; }
        .shp-sync .sync-ico { display: inline-block; }
        .shp-sync.done .sync-ico, .shp-sync.error .sync-ico { display: none; }   /* the result text has its own ✓ / ⚠ */
        .shp-sync.busy .sync-ico { width: 10px; height: 10px; border: 2px solid rgba(37,99,235,.35); border-top-color: #2563eb; border-radius: 50%; font-size: 0; vertical-align: -1px; animation: sync-spin .8s linear infinite; }
        .sess-health-pop button { margin-top: 6px; font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid #cbd5e0; background: #f8fafc; cursor: pointer; }
        html.dark-ui .sess-health-pop { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .sess-health-pop .shp-row { border-color: var(--border) !important; }
        html.dark-ui .sess-health-pop button { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        /* (older) per-session badges in the header — no longer shown */
        .sess-health { display: inline-flex; gap: 6px; flex-wrap: wrap; vertical-align: middle; margin-left: 6px; }
        .sess-badge { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid transparent; cursor: default; white-space: nowrap; }
        .sess-badge.green { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
        .sess-badge.yellow, .sess-badge.starting { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
        .sess-badge.red { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
        .sess-badge.unknown { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
        body.is-admin .sess-badge { cursor: pointer; }
        .sess-badge small { font-weight: 400; opacity: .8; }
        .health-alert { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
        .health-alert[hidden] { display: none; }
        .health-alert .ha-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
        .health-alert .ha-row.yellow { color: #713f12; }
        .health-alert button { font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid #fca5a5; background: #fff; cursor: pointer; }
        html.dark-ui .health-alert { background: rgba(220,38,38,.14) !important; border-color: #7f1d1d !important; color: #fecaca !important; }
        html.dark-ui .health-alert button { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        .conn-pill.online { background: #d1fae5; color: #065f46; }
        .conn-pill.offline { background: #fed7d7; color: #9b2c2c; }
        .history-status { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; vertical-align: middle; background: #e2e8f0; color: #475569; }
        .history-status.loading { background: #fef3c7; color: #92400e; }
        .history-status.done { background: #d1fae5; color: #065f46; }
        .history-status.error { background: #fed7d7; color: #9b2c2c; }
        .history-status.is-hidden { display: none; }
        html.dark-ui .history-status { background: var(--surface3); color: var(--text); }
        html.dark-ui .history-status.loading { background: #78350f; color: #fef3c7; }
        html.dark-ui .history-status.done { background: #064e3b; color: #d1fae5; }
        html.dark-ui .history-status.error { background: #7f1d1d; color: #fee2e2; }

        /* Loading Progress Bar */
        #loading-bar-container { background: white; padding: 14px 20px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); margin-bottom: 20px; display: none; border-left: 5px solid #128c7e; }
        .loading-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: #128c7e; }
        .loading-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e0; border-top-color: #128c7e; border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: -2px; }
        @keyframes spin { to { transform: rotate(360deg); } }
        .progress-track { width: 100%; height: 8px; background-color: #e2e8f0; border-radius: 4px; overflow: hidden; }
        .progress-fill { height: 100%; width: 0%; background-color: #25d366; transition: width 0.15s ease-out; }

        /* Login Overlay */
        #login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(240, 242, 245, 0.98); display: flex; justify-content: center; align-items: center; z-index: 1000; }
        .login-card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); width: 320px; text-align: center; }
        .login-card h2 { margin-top: 0; color: #128c7e; margin-bottom: 20px; }
        .login-card input { width: 100%; padding: 10px; margin-bottom: 12px; border: 1px solid #cbd5e0; border-radius: 6px; box-sizing: border-box; }
        .login-card button { width: 100%; padding: 10px; background: #128c7e; color: white; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; }
        .login-card button:hover { background: #0e6c61; }
        .error-msg { color: #e53e3e; font-size: 13px; margin-top: 10px; display: none; }
        .login-divider { display: flex; align-items: center; gap: 10px; color: #a0aec0; font-size: 12px; margin: 14px 0; }
        .login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: #e2e8f0; }
        .google-btn { display: flex !important; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px; background: #fff !important; color: #3c4043 !important;
            border: 1px solid #dadce0 !important; border-radius: 6px; font-weight: 600; cursor: pointer; text-decoration: none; box-sizing: border-box; font-size: 14px; }
        .google-btn:hover { background: #f8fafc !important; }
        .admin-only { display: none !important; }
        body.is-admin .admin-only { display: inline-block !important; }
        .role-pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 4px; text-transform: uppercase; }
        .role-admin { background: #fde68a; color: #92400e; }
        .role-viewer { background: #e0e7ff; color: #3730a3; }
        .users-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
        .users-table th, .users-table td { text-align: left; padding: 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
        .users-table th { background: #f8fafc; color: #475569; font-weight: 600; }
        .users-table tr.is-disabled td { color: #a0aec0; }
        .user-actions button { margin-right: 6px; padding: 4px 10px !important; font-size: 12px !important; }
        .user-form { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px 16px; margin-top: 14px; font-size: 13px; }
        .user-form .row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
        .user-form label.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 200px; font-weight: 600; color: #475569; }
        .user-form input[type=text], .user-form input[type=email], .user-form input[type=password], .user-form select {
            padding: 7px 9px; border: 1px solid #cbd5e0; border-radius: 6px; font-weight: normal; font-size: 13px; }
        .user-form .hint { font-weight: normal; color: #94a3b8; font-size: 12px; }
        .session-box { border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; max-height: 170px; overflow-y: auto; }
        .session-box label { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-weight: normal; }
        .form-error { color: #e53e3e; margin: 6px 0; display: none; }

        .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
        .card { background: white; border-radius: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); padding: 20px; display: flex; flex-direction: column; height: 78vh; }
        .card h2 { margin-top: 0; border-bottom: 2px solid #f0f2f5; padding-bottom: 10px; font-size: 18px; color: #444; }
        .message-list { flex: 1; overflow-y: auto; padding-right: 5px; }
        .feed-card { height: 82vh; position: relative; }
        .jump-latest { position: absolute; right: 30px; bottom: 26px; z-index: 5; display: none; align-items: center; gap: 6px;
            background: #128c7e; color: #fff; border: none; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700;
            box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
        .jump-latest:hover { background: #0e6c61; }
        .jump-latest.show { display: inline-flex; }
        .jump-latest.has-new { background: #e53e3e; }
        .jump-latest.has-new:hover { background: #c53030; }
        .feed-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 2px solid #f0f2f5; padding-bottom: 10px; margin-bottom: 10px; }
        .feed-head h2 { border: none; margin: 0; padding: 0; }
        .view-switch { display: inline-flex; border: 1px solid #cbd5e0; border-radius: 8px; overflow: hidden; }
        .view-switch button { background: #fff; color: #4a5568; border: none; border-right: 1px solid #cbd5e0; padding: 5px 8px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
        .view-switch button:last-child { border-right: none; }
        .view-switch button:hover { background: #f0fdf9; }
        .view-switch button.active { background: #128c7e; color: #fff; }
        .unread-restore { padding: 7px 9px; border: 1px solid #cbd5e0; border-radius: 8px; background: #fff; color: #4a5568; font-size: 12px; max-width: 165px; }
        .unread-restore-btn { min-width: 34px; padding: 6px 9px; font-size: 18px; line-height: 1; background: #edf2f7; color: #4a5568; border: 1px solid #cbd5e0; }
        .unread-restore-btn:hover { background: #e2e8f0; }
        .chat-list { flex: 1; overflow-y: auto; }
        .chat-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
        .chat-row:hover { background: #f5f6f6; }
        .chat-row .avatar { width: 46px; height: 46px; font-size: 15px; margin-right: 0; }
        .chat-main { flex: 1; min-width: 0; }
        .chat-top, .chat-bottom { display: flex; align-items: center; gap: 8px; }
        .chat-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; color: #111b21; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .chat-time { font-size: 12px; color: #667781; white-space: nowrap; }
        .chat-time.unread { color: #25d366; font-weight: 600; }
        .chat-preview { flex: 1; min-width: 0; font-size: 13px; color: #667781; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
        .chat-badge { background: #25d366; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
        .chat-sess { font-size: 10px; background: #e2e8f0; color: #475569; border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
        .feed-empty { align-self: center; color: #94a3b8; font-size: 14px; margin-top: 30px; display: none; }
        .archive-banner { display: none; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
            background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font-size: 14px; }
.archive-banner.show { display: flex; }
        .feed-range { display: none; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: #475569; margin: -2px 0 10px; }
        .feed-range.show { display: flex; }
        .feed-range .older { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; border-radius: 999px; padding: 2px 10px; font-weight: 600; cursor: pointer; }
        .feed-range .older:hover { background: #ede9fe; }
        .feed-range .none { color: #94a3b8; }
        .feed-range .policy { flex-basis: 100%; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 12px; color: #334155; line-height: 1.5; }
        .feed-range .policy b { color: #0f172a; }
        html.dark-ui .feed-range .policy { background: var(--surface2) !important; color: inherit !important; border-color: var(--border) !important; }
        html.dark-ui .feed-range .policy b { color: inherit !important; }
        .archive-banner .pending { background: #fde68a; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; margin-left: 6px; }
        .feed-card.archive-mode .feed-list { background: #fffdf5; border-radius: 6px; }
        .archive-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 8px; background: #fff; cursor: pointer; }
        .archive-row:hover { border-color: #128c7e; background: #f0fdf9; }
        /* Webhook inspector */
        .wh-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid #e2e8f0; background: #fff; font-size: 13px; }
        .wh-toolbar select { padding: 5px 8px; border: 1px solid #cbd5e0; border-radius: 6px; }
        .wh-live { font-weight: 700; color: #065f46; }
        .wh-live.paused { color: #b45309; }
        .wh-list { flex: 1; overflow-y: auto; padding: 10px 14px; background: #f8fafc; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
        .wh-row { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 6px; }
        .wh-head { display: flex; gap: 8px; align-items: baseline; padding: 7px 10px; cursor: pointer; flex-wrap: wrap; }
        .wh-head:hover { background: #f0fdf9; }
        .wh-time { color: #64748b; }
        .wh-type { font-weight: 700; color: #1e293b; }
        .wh-meta { color: #475569; }
        .wh-prev { color: #0f766e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
        .wh-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; }
        .wh-stored { background: #d1fae5; color: #065f46; }
        .wh-media { background: #dbeafe; color: #1e40af; }
        .wh-duplicate { background: #e2e8f0; color: #475569; }
        .wh-ignored { background: #f1f5f9; color: #94a3b8; }
        .wh-media-unmatched { background: #fef3c7; color: #92400e; }
        .wh-rejected, .wh-error { background: #fed7d7; color: #9b2c2c; }
        .wh-body { display: none; border-top: 1px solid #e2e8f0; }
        .wh-row.open .wh-body { display: block; }
        .wh-body-tools { display: flex; justify-content: flex-end; gap: 6px; padding: 6px 8px; background: #1e293b; }
        .wh-copy { background: #334155; color: #e2e8f0; border: 1px solid #475569; border-radius: 5px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
        .wh-copy:hover { background: #475569; }
        .wh-copy:disabled { opacity: .5; cursor: default; }
        .wh-copy.ok { background: #065f46; border-color: #047857; }
        .wh-body pre { margin: 0; padding: 10px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all; background: #0f172a; color: #e2e8f0; border-radius: 0 0 6px 6px; }
        .feed-list { display: flex; flex-direction: column; }
        /* Skip layout/paint work for messages that are off screen (big speed-up with thousands of items). */
        .feed-list > .msg-item { content-visibility: auto; contain-intrinsic-size: auto 120px; }
        /* The instant preview shown right after a refresh isn't clickable until the real feed replaces it. */
        .feed-list.is-snapshot { pointer-events: none; }
        .msg-item { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
        /* Combined feed: incoming hugs the left, outgoing hugs the right. */
        .feed-list .msg-item { max-width: 78%; }
        .feed-list .msg-item.direction-in  { align-self: flex-start; margin-right: auto; }
        .feed-list .msg-item.direction-out { align-self: flex-end;   margin-left: auto; background: #e7ffdb; border-color: #c6f6d5; }
        .feed-list .msg-item.access-log-item { align-self: center; max-width: 92%; }
        @media (max-width: 640px) { .feed-list .msg-item { max-width: 92%; } }
        .msg-header { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 6px; color: #495057; align-items: center; }
        .msg-time { font-weight: normal; font-size: 11px; color: #6c757d; }
        .msg-body { word-break: break-word; white-space: pre-wrap; line-height: 1.4; }
        .url-container { margin-top: 8px; padding-top: 6px; border-top: 1px solid #e2e8f0; font-size: 13px; word-break: break-all; }
        .url-container a { color: #0066cc; text-decoration: none; font-weight: 500; }
        .media-container { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #dee2e6; }
        .media-preview { max-width: 100%; max-height: 250px; border-radius: 6px; display: block; border: 1px solid #cbd5e0; }
        .media-preview, .chat-media-preview, .profile-photo { cursor: zoom-in; }
        /* round icon buttons (search) */
        .round-btn { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; background: #475569; color: #fff; font-size: 13px; line-height: 26px; text-align: center; cursor: pointer; flex: none; vertical-align: middle; }
        .round-btn:hover { background: #334155; }
        /* smart search + media gallery panels */
        .panel-card { width: 760px; max-width: 94%; height: 82vh; }
        .panel-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
        .panel-bar input[type=search] { flex: 1; min-width: 180px; padding: 8px 10px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 14px; }
        .panel-scope { font-size: 12px; color: #475569; }
        .panel-body { flex: 1; overflow-y: auto; padding: 10px 14px; }
        .panel-note { color: #64748b; font-size: 13px; padding: 14px 4px; }
        .sr-row { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; }
        .sr-row:hover { border-color: #93c5fd; background: #f8fbff; }
        .sr-head { font-size: 12px; color: #475569; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 3px; }
        .sr-head b { color: #0f172a; font-size: 13px; }
        .sr-text { font-size: 14px; color: #1e293b; white-space: pre-wrap; word-break: break-word; }
        .sr-text mark { background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px; }
        .sr-fuzzy { background: #ede9fe; color: #5b21b6; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; }
        .sr-kind { background: #e0f2fe; color: #075985; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; }
        .mg-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
        .mg-tabs button { border: 1px solid #cbd5e0; background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
        .mg-tabs button.active { background: #075e54; color: #fff; border-color: #075e54; }
        .mg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
        .mg-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; overflow: clip; display: flex; flex-direction: column; }
        /* sent by me: WhatsApp-style green; received: white */
        .mg-card.mg-out { background: #e7f8dc; border-color: #a7d98c; }
        .mg-card.mg-out .mg-thumb.has-transcript { background: #f3fcec; }
        .mg-card.mg-out .mg-actions button, .mg-card.mg-out .mg-actions a { background: #f3fcec; border-color: #a7d98c; }
        .mg-legend { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
        .mg-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid #cbd5e0; background: #fff; }
        .mg-legend i.out { background: #e7f8dc; border-color: #a7d98c; }
        html.dark-ui .mg-card.mg-out, html.dark-ui .mg-card.mg-out .mg-thumb.has-transcript { background: var(--bubble-out) !important; border-color: #2f6b55 !important; }
        html.dark-ui .mg-card.mg-out .mg-actions button, html.dark-ui .mg-card.mg-out .mg-actions a { background: rgba(255,255,255,.08) !important; border-color: #2f6b55 !important; }
        html.dark-ui .mg-legend i { background: var(--surface2) !important; }
        html.dark-ui .mg-legend i.out { background: var(--bubble-out) !important; }
        .mg-thumb { height: 150px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; overflow: clip; position: relative; cursor: zoom-in; }
        .mg-thumb img, .mg-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
        .mg-thumb .pdf-preview { width: 100%; margin: 0; border: 0; border-radius: 0; height: 150px; min-height: 0; }
        .mg-thumb .file-ico { font-size: 40px; cursor: default; }
        .sr-section { font-size: 12px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .03em; margin: 4px 0 6px; }
        .sr-chat { display: flex; align-items: center; gap: 10px; }
        .sr-chat .sr-ico { font-size: 20px; flex: none; }
        .sr-chat .sr-ids { font-size: 12px; color: #64748b; }
        .sr-match { background: #dcfce7; color: #166534; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; }
        .activity-item .datatype-tag.access-tag { background: #ede9fe; color: #5b21b6; }
        .act-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
        .act-table th { position: sticky; top: 0; background: #e2e8f0; text-align: left; padding: 6px 8px; z-index: 1; }
        .act-table td { padding: 5px 8px; border-bottom: 1px solid #edf2f7; vertical-align: top; word-break: break-word; }
        .act-table td:first-child, .act-table td:nth-child(2), .act-table td:nth-child(3) { white-space: nowrap; }
        .act-table td:last-child { color: #64748b; font-size: 12px; white-space: nowrap; }
        html.dark-ui .act-table { background: var(--surface2) !important; }
        html.dark-ui .act-table th { background: var(--surface3) !important; color: var(--text) !important; }
        html.dark-ui .act-table td { border-color: var(--border) !important; }
        #slog-type, #slog-days, #slog-user { padding: 6px 8px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 13px; }
        .slog-src { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
        .slog-src.access { background: #fef3c7; color: #92400e; }
        .slog-src.activity { background: #ede9fe; color: #5b21b6; }
        .slog-fail td { background: #fff5f5; }
        html.dark-ui .slog-fail td { background: rgba(220,38,38,.12) !important; }
        #act-day, #act-user, #act-action { padding: 6px 8px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 13px; }
        /* text-only status: the text fills the tile */
        .st-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; color: #fff; background: #128c7e; font-size: 14px; line-height: 1.35; word-break: break-word; overflow: hidden; overflow: clip; }
        /* Tiles clip with overflow:clip, not hidden: an overflow:hidden box is a scroll container, and Chrome
           then caught the mouse wheel on each tile instead of scrolling the list (only the gaps scrolled). */
        /* audio with a transcript: the text fills the tile, the 🎤/🎵 icon becomes a small badge */
        .mg-thumb.has-transcript { background: #fff; align-items: flex-start; }
        .mg-transcript { position: absolute; top: 10px; left: 12px; right: 40px; margin: 0; padding: 0; color: #1e293b; font-size: 12.5px; line-height: 1.4; text-align: left; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; word-break: break-word; overflow: clip; }
        .mg-ico-badge { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(241,245,249,.95); box-shadow: 0 1px 3px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; font-size: 15px; }
        .mg-tr-btn { position: absolute; top: 40px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; background: #e0f2fe; box-shadow: 0 1px 3px rgba(0,0,0,.2); font-size: 14px; cursor: pointer; }
        .mg-tr-btn:hover { background: #bae6fd; }
        #transcript-pop { position: fixed; inset: 0; z-index: 2600; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(0,0,0,.45); }
        #transcript-pop .tp-card { background: #fff; color: #1e293b; width: 560px; max-width: 100%; max-height: 80vh; display: flex; flex-direction: column; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.3); overflow: hidden; }
        #transcript-pop .tp-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #e2e8f0; font-weight: 700; }
        #transcript-pop .tp-head small { font-weight: 400; color: #64748b; }
        #transcript-pop .tp-head .tp-close { margin-left: auto; background: none; border: 0; font-size: 20px; cursor: pointer; color: #475569; }
        #transcript-pop .tp-body { padding: 14px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 14px; }
        #transcript-pop .tp-foot { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-top: 1px solid #e2e8f0; font-size: 12px; color: #64748b; }
        #transcript-pop .tp-foot button { margin-left: auto; }
        html.dark-ui #transcript-pop .tp-card { background: var(--surface) !important; color: var(--text) !important; }
        html.dark-ui #transcript-pop .tp-head, html.dark-ui #transcript-pop .tp-foot { border-color: var(--border) !important; }
        html.dark-ui .mg-tr-btn { background: var(--surface3) !important; }
        html.dark-ui .mg-thumb.has-transcript { background: var(--surface2) !important; }
        html.dark-ui .mg-transcript { color: var(--text) !important; }
        html.dark-ui .mg-ico-badge { background: var(--surface3) !important; }
        .mg-thumb.no-open { cursor: default; }
        .mg-meta { padding: 6px 8px; font-size: 11px; color: #475569; line-height: 1.35; word-break: break-word; }
        .mg-meta b { color: #0f172a; font-size: 12px; }
        .mg-meta audio { width: 100%; height: 30px; margin-top: 4px; }
        .mg-actions { display: flex; gap: 4px; padding: 0 8px 8px; flex-wrap: wrap; }
        .mg-actions button, .mg-actions a { font-size: 11px; padding: 3px 7px; border-radius: 5px; border: 1px solid #cbd5e0; background: #f8fafc; color: #1e293b; cursor: pointer; text-decoration: none; }
        .mg-actions button:hover, .mg-actions a:hover { background: #e2e8f0; }
        .chat-bubble.flash-hit { outline: 3px solid #f59e0b; outline-offset: 2px; }
        .conv-members-link { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
        .conv-members-link.active { font-weight: 700; }
        #image-viewer .viewer-zoom { display:none; position:absolute; top:14px; right:150px; background:rgba(255,255,255,.15); color:#fff; border:1px solid rgba(255,255,255,.35); border-radius:6px; padding:6px 12px; font-size:13px; font-weight:600; cursor:pointer; z-index:2; }
        #image-viewer .viewer-nav { display:none; position:fixed; top:50%; transform:translateY(-50%); width:46px; height:64px; border:0; border-radius:8px; background:rgba(255,255,255,.14); color:#fff; font-size:34px; line-height:1; cursor:pointer; z-index:3; }
        #image-viewer .viewer-nav:hover { background:rgba(255,255,255,.3); }
        #image-viewer .viewer-nav.prev { left:12px; } #image-viewer .viewer-nav.next { right:12px; }
        #image-viewer .viewer-nav:disabled { opacity:.25; cursor:default; }
        #image-viewer .viewer-count { display:none; position:fixed; bottom:14px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,.55); color:#fff; font-size:13px; padding:3px 12px; border-radius:999px; z-index:3; }
        #image-viewer.has-list .viewer-nav, #image-viewer.has-list .viewer-count { display:block; }
        #image-viewer.actual { overflow: auto; align-items: flex-start; justify-content: flex-start; cursor: default; }
        #image-viewer.actual img { max-width: none; max-height: none; cursor: zoom-out; }
        html.dark-ui .panel-bar { background: var(--surface) !important; border-color: var(--border) !important; }
        html.dark-ui .panel-bar input[type=search], html.dark-ui .mg-tabs button { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .mg-tabs button.active { background: #00a884 !important; color: #fff !important; }
        html.dark-ui .sr-row, html.dark-ui .mg-card, html.dark-ui .mg-actions button, html.dark-ui .mg-actions a { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .sr-head, html.dark-ui .mg-meta, html.dark-ui .panel-scope, html.dark-ui .panel-note { color: var(--muted) !important; }
        html.dark-ui .sr-head b, html.dark-ui .sr-text, html.dark-ui .mg-meta b { color: var(--text) !important; }
        html.dark-ui .sr-text mark { background: #854d0e !important; color: #fff !important; }
        html.dark-ui .mg-thumb { background: var(--surface3) !important; }
        .pdf-preview { display: block; position: relative; width: 220px; max-width: 100%; min-height: 48px; margin-bottom: 6px; border: 1px solid #cbd5e0; border-radius: 6px; background: #fff; overflow: hidden; overflow: clip; cursor: zoom-in; }
        .pdf-preview img { display: block; width: 100%; height: auto; }
        .pdf-preview .pdf-note { display: block; padding: 16px 8px; font-size: 12px; color: #64748b; text-align: center; }
        .pdf-preview.pdf-failed { cursor: default; min-height: 0; }
        .pdf-preview .pdf-pages { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
        .sync-btn { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; background: #2563eb; color: #fff; font-size: 15px; line-height: 26px; text-align: center; cursor: pointer; flex: none; vertical-align: middle; transition: background .2s; }
        .sync-btn:hover { background: #1d4ed8; }
        .sync-btn.busy { cursor: wait; }
        .sync-btn.done { background: #16a34a; }
        .sync-btn.error { background: #dc2626; }
        .sync-btn .sync-ico { display: inline-block; }
        .sync-btn.busy .sync-ico { width: 12px; height: 12px; margin-top: 7px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; font-size: 0; animation: sync-spin .8s linear infinite; }
        @keyframes sync-spin { to { transform: rotate(360deg); } }
        .sync-info { display: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
        .sync-info.show { display: inline-block; }
        .sync-info.busy { background: #dbeafe; color: #1e40af; }
        .sync-info.done { background: #dcfce7; color: #166534; }
        .sync-info.error { background: #fee2e2; color: #991b1b; white-space: normal; }
        .video-thumb { position: relative; display: inline-block; max-width: 100%; cursor: zoom-in; }
        .video-thumb video { pointer-events: none; }
        .video-thumb .video-play { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; padding-left: 4px; box-sizing: border-box; }
        .video-thumb:hover .video-play { background: rgba(0,0,0,.75); }
        .youtube-preview { display:flex; gap:10px; max-width:420px; margin-top:8px; padding:8px; border:1px solid #d1d5db; border-radius:9px; background:#fff; color:#1f2937; text-decoration:none; align-items:center; }
        .linked-media { display:flex; flex-direction:column; align-items:flex-start; gap:5px; margin:8px 0; max-width:100%; }
        .linked-media audio { width:min(420px, 100%); }
        .linked-media video { display:block; width:min(520px, 100%); max-height:320px; border-radius:8px; background:#000; }
        .youtube-embed { width:min(560px, 100%); }
        .youtube-embed iframe { display:block; width:100%; aspect-ratio:16/9; border:0; border-radius:8px; background:#000; }
        .msg-body, .chat-bubble { overflow-wrap:anywhere; }
        .youtube-preview:hover { border-color:#ef4444; background:#fef2f2; }
        .youtube-preview img { width:150px; max-width:42%; aspect-ratio:16/9; object-fit:cover; border-radius:6px; background:#e5e7eb; flex-shrink:0; }
        .youtube-preview-title { font-weight:700; font-size:13px; line-height:1.35; }
        .youtube-preview-author { display:block; color:#64748b; font-size:12px; margin-top:4px; }
        #image-viewer { position:fixed; inset:0; z-index:5000; display:none; align-items:center; justify-content:center; padding:24px; background:rgba(0,0,0,.92); cursor:zoom-out; }
        #image-viewer img { max-width:96vw; max-height:94vh; object-fit:contain; }
        #image-viewer video { display:none; max-width:96vw; max-height:94vh; background:#000; cursor:auto; }
        #image-viewer .viewer-fs { display:none; position:absolute; top:14px; right:14px; background:rgba(255,255,255,.15); color:#fff; border:1px solid rgba(255,255,255,.35); border-radius:6px; padding:6px 12px; font-size:13px; font-weight:600; cursor:pointer; }
        #image-viewer .viewer-fs:hover { background:rgba(255,255,255,.28); }
        #member-profile-modal { position:fixed; inset:0; z-index:4000; display:none; align-items:center; justify-content:center; padding:18px; background:rgba(0,0,0,.55); }
        #member-profile-card { width:min(440px,95vw); max-height:90vh; overflow:auto; background:#fff; color:#1e293b; border-radius:14px; padding:22px; box-shadow:0 12px 50px #0005; text-align:center; }
        #member-profile-card img { width:128px; height:128px; border-radius:50%; object-fit:cover; background:#e2e8f0; }
        .profile-modal-head { display:flex; justify-content:flex-end; margin:-12px -10px 6px; }
        .profile-close-btn { border:1px solid #cbd5e1; border-radius:7px; background:#f8fafc; color:#334155; padding:6px 11px; font-weight:600; cursor:pointer; }
        .profile-close-btn:hover { background:#e2e8f0; }
        .group-profile-trigger { cursor:pointer; }
        .group-profile-trigger:hover { text-decoration:underline; }
        .profile-fields { text-align:left; margin:18px 0; }
        .profile-field { padding:9px 2px; border-bottom:1px solid #e2e8f0; overflow-wrap:anywhere; }
        .profile-field b { display:block; font-size:11px; color:#64748b; text-transform:uppercase; margin-bottom:3px; }
        .profile-group-list { display:flex; flex-direction:column; gap:6px; margin-top:6px; }
        .profile-group-link { display:block; width:100%; padding:8px 10px; border:1px solid #e2e8f0; border-radius:7px; background:#f8fafc; color:#1e293b; text-align:left; cursor:pointer; overflow-wrap:anywhere; }
        .profile-group-link:hover { background:#eff6ff; border-color:#bfdbfe; }
        .instagram-embed { width:min(420px,100%); }
        .instagram-embed iframe { display:block; width:100%; height:560px; border:0; border-radius:10px; background:#f1f5f9; }
        .tiktok-embed { width:min(360px,100%); }
        .tiktok-embed iframe { display:block; width:100%; height:740px; max-height:78vh; border:0; border-radius:10px; background:#f1f5f9; }
        .facebook-embed { width:min(500px,100%); }
        .facebook-embed iframe { display:block; width:100%; height:620px; border:0; border-radius:10px; background:#f1f5f9; }
        .preview-original-url { margin:4px 0 10px; max-width:min(520px,100%); overflow-wrap:anywhere; font-size:12px; line-height:1.45; }
        .preview-original-url a { color:#2563eb; text-decoration:underline; }
        html.dark-ui .preview-original-url a { color:#93c5fd; }
        .audio-player { width: 100%; height: 38px; border-radius: 6px; display: block; }
        .direction-in { border-left: 4px solid #34b7f1; }
        .direction-out { border-left: 4px solid #25d366; }
        .session-tag { background-color: #e2e8f0; color: #4a5568; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: normal; }
        .datatype-tag { background-color: #feebc8; color: #744210; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: bold; text-transform: uppercase; }

        .msg-item.voice-note-item { background-color: #f0fdfa; border-color: #99f6e4; }
        .datatype-tag.voice-tag { background-color: #ccfbf1; color: #115e59; border: 1px solid #5eead4; }
        .datatype-tag.audio-tag { background-color: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }

        .msg-item.group-item { background-color: #f4fbf7 !important; border-color: #a7f3d0 !important; border-left: 5px solid #059669 !important; }
        .group-tag { background-color: #d1fae5 !important; color: #065f46 !important; border: 1px solid #6ee7b7 !important; font-weight: bold; }

        .msg-item[data-datatype="call"] { background-color: #f0f7ff; border-color: #bee3f8; }
        .msg-item[data-datatype="call"].direction-in { border-left: 5px solid #0088cc; }
        .msg-item[data-datatype="call"].direction-out { border-left: 5px solid #00a884; }
        .msg-item.status-update-item { background-color: #fcf4ff; border-color: #e9d8a6; border-left: 5px solid #9b59b6 !important; }
        .datatype-tag.status-tag, .msg-item[data-datatype="status_update"] .datatype-tag { background-color: #f3e8ff; color: #6b21a8; border: 1px solid #d8b4fe; }

        .msg-item.revoked-item { background-color: #fff5f5 !important; border-color: #feb2b2 !important; border-left: 5px solid #e53e3e !important; }
        .datatype-tag.edited-tag { background-color: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
        .edit-history { margin-top: 6px; padding: 6px 8px; background: #f1f5f9; border-radius: 6px; font-size: 12px; color: #475569; }
        .edit-history .edit-time { color: #94a3b8; }
        .wh-updated { background: #e0e7ff; color: #3730a3; }
        .datatype-tag.revoked-tag { background-color: #fed7d7 !important; color: #9b2c2c !important; border: 1px solid #feb2b2 !important; }

        .msg-item.access-log-item { background-color: #fffaf0; border-color: #feebc8; border-left: 5px solid #dd6b20 !important; }
        .datatype-tag.access-tag, .msg-item[data-datatype="access_log"] .datatype-tag { background-color: #feebc8; color: #9c4221; border: 1px solid #fbd38d; }

        .avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
            overflow: hidden; vertical-align: middle; margin-right: 8px; flex-shrink: 0; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .3px; user-select: none; }
        .avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #e2e8f0; }
        .call-icon { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; fill: currentColor; }
        .call-icon.in-voice { color: #0088cc; }
        .call-icon.out-voice { color: #00a884; }
        .call-icon.in-video { color: #805ad5; }
        .call-icon.out-video { color: #dd6b20; }

        .clickable-lid { color: #0066cc; text-decoration: underline; cursor: pointer; font-weight: 600; }
        .clickable-lid:hover { color: #004499; }

        .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: none; justify-content: center; align-items: center; z-index: 2000; }
        .modal-card { background: #efeae2; width: 800px; max-width: 90%; height: 80vh; border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 4px 20px rgba(0,0,0,0.2); overflow: hidden; }
        .modal-header { background: #075e54; color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; }
        .modal-header h3 { margin: 0; font-size: 18px; }
        .close-modal-btn { background: transparent; border: none; color: white; font-size: 20px; cursor: pointer; font-weight: bold; }
        .chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
        .chat-bubble { max-width: 70%; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.4; position: relative; word-break: break-word; }
        .chat-bubble.in { align-self: flex-start; background: white; border-top-left-radius: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
        .chat-bubble.out { align-self: flex-end; background: #dcf8c6; border-top-right-radius: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
        .chat-bubble.call-event-bubble { align-self: center; max-width: min(88%, 460px); background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; color: #1e3a8a; box-shadow: none; }
        .chat-bubble.call-event-bubble .bubble-sender { color: #1d4ed8; }
        .chat-bubble.call-event-bubble .chat-meta { color: #64748b; }
        .chat-bubble.revoked-bubble { background: #fff5f5 !important; border: 1px solid #feb2b2; color: #c53030; }
        .datatype-tag.archived-tag { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
        .archived-badge { display: inline-block; background-color: #fef3c7; color: #92400e; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; text-transform: uppercase; }
        body.is-admin .maintenance-menu .admin-only { display: block !important; }
        .datatype-tag.wadash-del-tag { background-color: #1e293b; color: #f8fafc; border: 1px solid #0f172a; }
        .wadash-del-badge { display: inline-block; background-color: #1e293b; color: #f8fafc; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; text-transform: uppercase; }
        .media-state { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; }
        .media-state.pending { background: #eff6ff; color: #1e40af; }
        .media-state.missing { background: #fef2f2; color: #991b1b; }
        .media-state button { font-size: 12px; padding: 2px 9px; border-radius: 6px; border: 1px solid currentColor; background: #fff; color: inherit; cursor: pointer; }
        html.dark-ui .media-state.pending { background: rgba(37,99,235,.15) !important; color: #bfdbfe !important; }
        html.dark-ui .media-state.missing { background: rgba(220,38,38,.15) !important; color: #fecaca !important; }
        html.dark-ui .media-state button { background: var(--surface2) !important; }
        button.tr-state.tr-prioritize { cursor: pointer; border: 1px dashed currentColor; font: inherit; }
        button.tr-state.tr-prioritize:hover { filter: brightness(.95); border-style: solid; }
        button.tr-state.tr-prioritize .tr-prio-hint { font-weight: 700; margin-left: 2px; }
        .mention-me { font-weight: 700; color: #0f766e; background: #ccfbf1; border-radius: 4px; padding: 0 3px; text-decoration: none; cursor: pointer; }
        .mention-me:hover { text-decoration: underline; }
        html.dark-ui .mention-me { color: #5eead4 !important; background: rgba(20,184,166,.15) !important; }
        .datatype-tag.fwd-tag { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; font-style: italic; }
        .datatype-tag.fwd-tag.many { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
        .fwd-line { font-size: 11.5px; font-style: italic; color: #64748b; margin: 0 0 3px; }
        .fwd-line.many { color: #9a3412; }
        html.dark-ui .fwd-line { color: var(--muted) !important; }
        html.dark-ui .fwd-line.many { color: #fdba74 !important; }
        .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
        .reactions[hidden] { display: none; }
        .reaction-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 1px 2px rgba(0,0,0,.06); font-size: 14px; line-height: 1.5; }
        .reaction-chip b { font-size: 11px; color: #475569; font-weight: 600; }
        html.dark-ui .reaction-chip { background: var(--surface2) !important; border-color: var(--border) !important; }
        html.dark-ui .reaction-chip b { color: var(--muted) !important; }
        .ack { font-size: 12px; font-weight: 700; letter-spacing: -2px; margin-left: 6px; white-space: nowrap; }
        .ack small { letter-spacing: 0; font-size: 9px; margin-left: 3px; }
        .ack.ack-wait, .ack.ack-err { letter-spacing: 0; font-weight: 400; }
        .ack.ack-sent, .ack.ack-deliv { color: #8696a0; }
        .ack.ack-read { color: #34b7f1; }
        .ack.ack-err { color: #dc2626; }
        /* While WAdash checks the sign-in (or can't be reached), the login form isn't shown: you may well be signed in. */
        #login-overlay .auth-wait { display: none; flex-direction: column; align-items: center; gap: 10px; padding: 18px 6px; color: #475569; text-align: center; }
        #login-overlay.checking .auth-wait { display: flex; }
        #login-overlay.checking .login-card > :not(.auth-wait) { display: none !important; }
        .auth-spin { width: 22px; height: 22px; border: 3px solid #cbd5e0; border-top-color: #075e54; border-radius: 50%; animation: sync-spin .8s linear infinite; }
        .link-qr-box { width: 264px; height: 264px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; }
        .link-qr-box img { width: 256px; height: 256px; image-rendering: pixelated; }
        .link-qr-box.linked { border-color: #86efac; background: #f0fdf4; font-size: 64px; }
        .link-steps { text-align: left; margin: 0; padding-left: 20px; font-size: 13px; color: #475569; line-height: 1.55; }
        html.dark-ui .link-steps { color: var(--muted) !important; }
        /* ── Maintenance window ── */
        .maint-card { width: 920px; max-width: 96%; height: 86vh; }
        .maint-card .modal-header { gap: 10px; }
        .maint-q { flex: 1; max-width: 280px; margin-left: auto; padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.4); font-size: 13px; }
        .maint-body { display: flex; flex-direction: column; gap: 14px; }
        .maint-body > * { flex-shrink: 0; }   /* sections keep their full height (they overlapped when squeezed) */
        .maint-sec h4 { margin: 0 0 8px; font-size: 14px; color: #0f172a; }
        .maint-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
        .maint-sec-head h4 { margin: 0; }
        .maint-sec-tools { display: inline-flex; gap: 6px; flex-wrap: wrap; }
        /* Square, colour-coded tiles: big targets for fingers, recognisable at a glance */
        .maint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
        .maint-tile { min-width: 0; overflow-wrap: anywhere; }
        .maint-tile { --tile: #475569; --tile-bg: #f1f5f9; aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
            padding: 14px 12px; border-radius: 16px; border: 2px solid color-mix(in srgb, var(--tile) 30%, transparent); background: var(--tile-bg); cursor: pointer; font: inherit; color: #1e293b;
            box-shadow: 0 1px 2px rgba(0,0,0,.06); transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
        .maint-tile:hover { border-color: var(--tile); box-shadow: 0 4px 14px color-mix(in srgb, var(--tile) 25%, transparent); }
        .maint-tile:active { transform: scale(.97); }
        .maint-tile:focus-visible { outline: 3px solid var(--tile); outline-offset: 2px; }
        .maint-tile .mt-ico { font-size: 34px; line-height: 1; width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: color-mix(in srgb, var(--tile) 16%, #fff); }
        .maint-tile b { font-size: 15px; color: var(--tile); line-height: 1.2; }
        .maint-tile small { font-size: 12px; color: #475569; line-height: 1.35; }
        #backfill-btn { --tile: #0f766e; --tile-bg: #f0fdfa; }
        #rescan-media-btn { --tile: #0369a1; --tile-bg: #f0f9ff; }
        #clean-media-btn { --tile: #c2410c; --tile-bg: #fff7ed; }
        #backups-btn { --tile: #1d4ed8; --tile-bg: #eff6ff; }
        #syslog-btn { --tile: #334155; --tile-bg: #f8fafc; }
        #activity-btn { --tile: #6d28d9; --tile-bg: #f5f3ff; }
        #webhooks-btn { --tile: #0e7490; --tile-bg: #ecfeff; }
        #alerts-btn { --tile: #15803d; --tile-bg: #f0fdf4; }
        #tasks-btn { --tile: #a16207; --tile-bg: #fefce8; }
        .task-sec { margin-bottom: 16px; }
        .task-sec h4 { margin: 0 0 6px; font-size: 14px; }
        .task-sec .task-sum { font-size: 12.5px; color: #64748b; margin-bottom: 6px; }
        .task-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 10px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
        .task-row .t-sub { color: #64748b; font-size: 12px; grid-column: 1 / -1; }
        .task-row .t-err { color: #b91c1c; font-size: 12px; grid-column: 1 / -1; word-break: break-word; }
        .task-row .t-when { white-space: nowrap; color: #334155; font-size: 12px; }
        .task-row.active { border-color: #93c5fd; background: #eff6ff; }
        html.dark-ui .task-row { background: var(--surface2) !important; border-color: var(--border) !important; }
        tr.slog-open td { cursor: pointer; }
        tr.slog-open:hover td { background: #f0f9ff; }
        tr.slog-open td:nth-child(4)::after, .act-table tr.slog-open td:nth-child(3)::after { content: ' ↗'; color: #0369a1; font-weight: 700; }
        #clear-btn.maint-tile { --tile: #b91c1c; --tile-bg: #fef2f2; }
        /* Phones: two even columns, tiles as tall as their content (not forced square), shorter texts */
        @media (max-width: 560px) {
            .maint-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
            .maint-tile { aspect-ratio: auto; min-height: 128px; padding: 12px 8px; border-radius: 14px; }
            .maint-tile .mt-ico { width: 48px; height: 48px; font-size: 28px; border-radius: 12px; }
            .maint-tile b { font-size: 14px; }
            .maint-tile small:not(.maint-auto) { display: none; }
            .maint-tile small.maint-auto { font-size: 11px; font-weight: 500; }
            .maint-card { height: 92vh; }
            .maint-card .modal-header { flex-wrap: wrap; }
            .maint-q { order: 3; max-width: none; flex-basis: 100%; margin-left: 0; }
        }
        .maint-tile small.maint-auto { margin-top: 3px; color: #0f766e; font-weight: 600; white-space: pre-line; }
        .maint-tile small.maint-auto:empty { display: none; }
        .maint-sec.danger h4 { color: #b91c1c; }
        .maint-mini { font-size: 13px; min-height: 38px; padding: 8px 14px; border-radius: 10px; border: 1px solid #cbd5e0; background: #fff; cursor: pointer; font-weight: 600; touch-action: manipulation; }
        .maint-mini:active { transform: scale(.97); }
        .maint-mini.add { background: #15803d; color: #fff; border-color: #15803d; }
        .maint-mini.warn { color: #b45309; } .maint-mini.danger { color: #b91c1c; border-color: #fecaca; }
        .maint-hint { font-size: 11.5px; color: #64748b; margin-top: 6px; }
        .sess-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; overflow: clip; font-size: 13px; }
        .sess-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
        .sess-table tr:last-child td { border-bottom: 0; }
        .sess-table .s-name b { font-size: 13.5px; }
        .sess-table .s-meta { color: #64748b; font-size: 12px; }
        .sess-table .s-actions { text-align: right; }
        .sess-table .s-actions .maint-mini { margin: 3px 0 3px 6px; }
        @media (max-width: 620px) { .sess-table tr { display: flex; flex-direction: column; } .sess-table .s-actions { text-align: left; } .sess-table .s-actions .maint-mini { margin: 3px 6px 3px 0; } }
        html.dark-ui .sess-table, html.dark-ui .maint-mini:not(.add) { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .maint-tile { background: color-mix(in srgb, var(--tile) 14%, var(--surface2)) !important; color: var(--text) !important; }
        html.dark-ui .maint-tile b { color: color-mix(in srgb, var(--tile) 55%, #fff) !important; }
        html.dark-ui .maint-tile small { color: var(--muted) !important; }
        html.dark-ui .maint-tile .mt-ico { background: color-mix(in srgb, var(--tile) 30%, transparent) !important; }
        html.dark-ui .maint-sec h4 { color: var(--text) !important; }
        html.dark-ui .sess-table td { border-color: var(--border) !important; }
        .wh-modes { display: inline-flex; border: 1px solid #cbd5e0; border-radius: 8px; overflow: hidden; overflow: clip; }
        .wh-mode { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: #334155; }
        .wh-mode.active { background: #075e54; color: #fff; }
        #wh-day { padding: 5px 8px; border: 1px solid #cbd5e0; border-radius: 6px; }
        html.dark-ui .wh-mode:not(.active) { background: var(--surface2) !important; color: var(--text) !important; }
        .recovered-icon { border: 1px solid #99f6e4; background: #ccfbf1; padding: 1px 5px; margin-left: 4px; border-radius: 999px; font-size: 11px; line-height: 1.2; cursor: pointer; vertical-align: middle; }
        .recovered-icon:hover { opacity: 1; transform: scale(1.15); }
        .info-pop { position: fixed; z-index: 6000; width: max-content; max-width: min(320px, calc(100vw - 16px)); background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 8px 10px; font-size: 12.5px; line-height: 1.45; white-space: pre-line; }
        .info-pop[hidden] { display: none; }
        .info-pop .ip-title { font-weight: 700; margin-bottom: 4px; }
        .info-pop .ip-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; white-space: nowrap; }
        .info-pop .ip-row b { font-weight: 500; color: #334155; }
        .info-pop .ip-row.hl { background: #fef9c3; border-radius: 4px; padding: 2px 4px; margin: 0 -4px; }
        .info-pop .ip-emoji { font-size: 15px; }
        .info-pop .ip-note { margin-top: 4px; font-size: 11.5px; color: #64748b; white-space: normal; }
        .info-pop .ack-read { color: #34b7f1; font-weight: 700; letter-spacing: -2px; }
        html.dark-ui .info-pop .ip-row b { color: var(--text) !important; }
        html.dark-ui .info-pop .ip-row.hl { background: rgba(250,204,21,.15) !important; }
        .ack, .reaction-chip { cursor: pointer; }
        html.dark-ui .info-pop { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
        .datatype-tag.recovered-tag { background-color: #ccfbf1; color: #115e59; border: 1px solid #99f6e4; }
        .recovered-badge { display: inline-block; background-color: #ccfbf1; color: #115e59; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; text-transform: uppercase; }
        .msg-del-actions { display: none; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
        body.delete-enabled .msg-del-actions { display: flex; }
        .msg-del-actions.pending { display: none !important; }
        .del-note { font-size: 11.5px; color: #94a3b8; font-style: italic; cursor: help; }   /* until WA-lib confirms the message can be reached */
        .msg-del-btn { background: #fff5f5; color: #9b2c2c; border: 1px solid #feb2b2; border-radius: 6px; padding: 3px 9px; font-size: 12px; font-weight: 600; cursor: pointer; }
        .msg-del-btn:hover { background: #fed7d7; }
        .msg-del-btn:disabled { opacity: .6; cursor: wait; }
        .revoked-badge { display: inline-block; background-color: #fed7d7; color: #9b2c2c; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; text-transform: uppercase; }
        .chat-meta { font-size: 10px; color: #888; margin-top: 4px; text-align: right; }
        .conv-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
        .conv-head .avatar { width: 38px; height: 38px; font-size: 14px; margin-right: 0; }
        .conv-sub { font-size: 12px; opacity: .8; margin-top: 2px; word-break: break-all; }
        .conv-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #f0f2f5; border-bottom: 1px solid #d1d7db; padding: 8px 20px; font-size: 13px; color: #334155; }
        .conv-name-row code { background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
        .conv-name-row input { flex: 1; min-width: 160px; padding: 6px 9px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 13px; }
.conv-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
        .conv-playing-voice { background: #dcfce7; border-color: #86efac; color: #166534; }
        .conv-playing-voice:hover { background: #bbf7d0; }
        .conv-playing-voice.is-pause { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
        .conv-playing-voice.is-pause:hover { background: #fde68a; }
        /* Gap separator between series of messages in the pop-up */
        .chat-gap { align-self: center; display: flex; align-items: center; gap: 10px; width: 100%; margin: 6px 0; font-size: 12px; color: #475569; }
        .chat-gap::before, .chat-gap::after { content: ""; flex: 1; border-top: 1px dashed #cbd5e0; }
        .chat-gap span { background: #e2e8f0; border-radius: 999px; padding: 3px 12px; font-weight: 600; white-space: nowrap; }
        .chat-gap.first span { background: #f1f5f9; font-weight: 500; }
        /* Voice note speed */
        .speed-set { display: inline-flex; border: 1px solid #cbd5e0; border-radius: 999px; overflow: hidden; }
        .speed-btn { border: none; background: transparent; color: #334155; font-size: 11px; font-weight: 600; padding: 2px 8px; cursor: pointer; }
        .speed-btn + .speed-btn { border-left: 1px solid #cbd5e0; }
        .speed-btn:hover { background: #f1f5f9; }
        .speed-btn.active { background: #0f766e; color: #fff; }
        html.dark-ui .chat-gap { color: var(--text, #e2e8f0); }
        html.dark-ui .chat-gap span { background: #334155 !important; color: #e2e8f0 !important; }
        html.dark-ui .chat-gap::before, html.dark-ui .chat-gap::after { border-color: #475569; }
        html.dark-ui .speed-set, html.dark-ui .speed-btn + .speed-btn { border-color: #475569 !important; }
        html.dark-ui .speed-btn { color: #cbd5e1 !important; background: transparent !important; }
        html.dark-ui .speed-btn.active { background: var(--accent, #0f766e) !important; color: #fff !important; }
        .chat-bubble.voice-note-focused { outline: 3px solid #16a34a; outline-offset: 2px; animation: voice-focus-pulse 1.2s ease-in-out 2; }
        @keyframes voice-focus-pulse { 50% { outline-color: transparent; } }
        .conv-members { background: #fff; border-bottom: 1px solid #d1d7db; max-height: 45vh; display: flex; flex-direction: column; }
        .conv-members-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; }
        .conv-members-top input { flex: 1; padding: 7px 10px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 13px; }
        .conv-members-top span { font-size: 12px; color: #64748b; white-space: nowrap; }
        .conv-members-desc { padding: 0 16px 6px; font-size: 12px; color: #64748b; white-space: pre-wrap; max-height: 60px; overflow-y: auto; }
        .conv-members-desc:empty { display: none; }
        .conv-members-list { overflow-y: auto; padding: 0 8px 8px; }
        .member-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
        .member-row:hover { background: #f0fdf9; }
        .member-row .avatar { width: 34px; height: 34px; margin-right: 0; font-size: 12px; }
        .member-name { font-weight: 600; font-size: 14px; color: #1e293b; }
        .member-id { font-size: 12px; color: #64748b; word-break: break-all; }
        .admin-badge { font-size: 10px; font-weight: 700; background: #dcfce7; color: #166534; border-radius: 999px; padding: 1px 7px; margin-left: 6px; text-transform: uppercase; }
        .transcript { margin-top: 0; font-size: 13px; display: inline-flex; align-items: center; position: relative; vertical-align: middle; }
        .transcript .tr-details { position: absolute; top: calc(100% + 5px); left: 0; min-width: 220px; max-width: min(420px, 80vw); z-index: 30; padding: 8px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
        .tr-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 27px; height: 25px; padding: 0 6px; border: 1px solid #e2e8f0; border-radius: 7px; background: #f8fafc; cursor: pointer; font-size: 14px; }
        .tr-icon:hover { background: #eef2ff; border-color: #c7d2fe; }
        .tr-details { margin-top: 6px; }
        .transcript:empty { display: none; }
        /* In the timeline the transcript opens inside the message (a floating box got cut off by the feed). */
        .feed-list .transcript { flex-wrap: wrap; max-width: 100%; }
        .feed-list .transcript .tr-details { position: static; flex-basis: 100%; min-width: 0; max-width: 100%; margin-top: 6px; box-shadow: none; }
        .tr-meta a.tr-popout { font-weight: 600; }
        /* in a conversation, a finished transcript sits under the player at full width */
        .transcript.in-chat { flex-wrap: wrap; flex-basis: 100%; max-width: 100%; }
        .transcript.in-chat .tr-details { position: static; flex-basis: 100%; min-width: 0; max-width: 100%; margin-top: 4px; box-shadow: none; }
        .tr-chat-toggle { cursor: pointer; font-weight: 600; }
        button.tr-chat-toggle.tr-show { border: 1px solid #cbd5e0; background: #fff; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; color: #475569; }
        html.dark-ui button.tr-chat-toggle.tr-show { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        .tr-btn { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
        .tr-btn:hover { background: #e0e7ff; }
        .tr-btn.tr-google { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
        .tr-text { cursor: pointer; }
        .tr-text { background: #f8fafc; border-left: 3px solid #818cf8; border-radius: 4px; padding: 6px 9px; white-space: pre-wrap; line-height: 1.45; color: #1e293b; }
        .tr-meta { font-size: 11px; color: #94a3b8; margin-top: 3px; }
        .tr-meta a { color: #6366f1; cursor: pointer; text-decoration: none; margin-left: 4px; }
        .tr-pending { color: #6366f1; font-style: italic; }
        .tr-progress { margin-top: 5px; min-width: 190px; max-width: 360px; }
        .tr-progress-head, .tr-progress-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: #64748b; }
        .tr-progress-head { margin-bottom: 5px; color: #4f46e5; font-weight: 600; }
        .tr-progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: #e2e8f0; }
        .tr-progress-fill { height: 100%; border-radius: 99px; background: #16a34a; transition: width .25s ease; }
        .tr-progress-fill.indeterminate { width: 35%; animation: tr-progress-slide 1.2s ease-in-out infinite alternate; }
        @keyframes tr-progress-slide { from { transform: translateX(0); } to { transform: translateX(185%); } }
        .tr-error { color: #b91c1c; }
        .engine-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 8px; background: #fff; cursor: pointer; }
        .engine-opt.unavailable { opacity: .6; }
        .engine-opt small { display: block; color: #64748b; margin-top: 2px; }
        .admin-badge.me-badge { background: #dbeafe; color: #1e40af; }
        .members-section { font-size: 12px; font-weight: 600; color: #64748b; padding: 10px 8px 4px; border-top: 1px solid #e2e8f0; margin-top: 6px; }
        .conv-edit-btn { background: rgba(255,255,255,.15); border: none; border-radius: 6px; padding: 3px 7px; font-size: 14px; cursor: pointer; line-height: 1.2; }
        .conv-edit-btn:hover, .conv-edit-btn.active { background: rgba(255,255,255,.3); }
        /* conversation actions (✏️ ⟳ 🔍 🖼️) are folded behind ⋯ until opened */
        /* conversation actions: a small vertical menu under ⋯ */
        .conv-tools-wrap { position: relative; display: inline-flex; }
        .conv-tools { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; flex-direction: column; align-items: stretch; gap: 2px;
            min-width: 190px; padding: 6px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
        .conv-tools.open { display: flex; }
        #conv-tools > button { display: flex !important; align-items: center; gap: 10px; width: 100%; height: auto; padding: 7px 10px; border-radius: 7px;
            background: transparent; color: #1e293b; font-size: 15px; line-height: 1.2; text-align: left; border: 0; cursor: pointer; }
        .conv-tools > button::after { content: attr(data-label); font-size: 13.5px; font-weight: 500; }
        .conv-tools > button:hover { background: #f1f5f9; }
        #conv-tools > button[style*="display: none"], #conv-tools > button[style*="display:none"] { display: none !important; }
        body:not(.is-admin) #conv-tools > #conv-sync-btn { display: none !important; }
        .conv-tools > #conv-sync-btn .sync-ico { width: 18px; text-align: center; color: #2563eb; }
        .conv-tools > #conv-sync-btn.busy .sync-ico { width: 12px; border-color: rgba(37,99,235,.35); border-top-color: #2563eb; margin-top: 0; }
        html.dark-ui .conv-tools { background: var(--surface) !important; border-color: var(--border) !important; }
        html.dark-ui .conv-tools > button { color: var(--text) !important; }
        html.dark-ui .conv-tools > button:hover { background: var(--surface2) !important; }
        .conv-tools-toggle { font-weight: 700; min-width: 30px; }
        .conv-status { font-size: 12px; font-weight: 600; }
        .conv-status.ok { color: #bbf7d0; }
        .conv-status.err { color: #fecaca; }
        .bubble-sender { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: bold; color: #075e54; margin-bottom: 3px; }
        .bubble-sender .avatar { width: 22px; height: 22px; font-size: 9px; margin-right: 0; }
        .chat-media-preview { max-width: 100%; max-height: 220px; border-radius: 6px; margin-top: 6px; display: block; border: 1px solid #cbd5e0; }

        /* Outgoing cards: accent line on the RIGHT edge (incoming keeps it on the left). */
        .feed-list .msg-item.direction-out { border-left: 1px solid #c6f6d5; border-right: 4px solid #25d366; }
        .feed-list .msg-item.direction-out[data-datatype="call"] { border-left: 1px solid #bee3f8; border-right: 5px solid #00a884; }
        .feed-list .msg-item.direction-out.group-item { border-left: 1px solid #a7f3d0 !important; border-right: 5px solid #059669 !important; }
        .feed-list .msg-item.direction-out.revoked-item { border-left: 1px solid #feb2b2 !important; border-right: 5px solid #e53e3e !important; }

        /* ═══════════════ COLOR SCHEMES ═══════════════
           Light = the original look (no overrides). Dark themes share the .dark-ui rules below and
           differ only in their variables. Ocean = light with blue accents. */
        html[data-theme="dark"] {
            --bg: #0f172a; --surface: #1e293b; --surface2: #273449; --surface3: #334155; --border: #334155;
            --text: #e2e8f0; --muted: #94a3b8; --accent: #10b981; --accent-hover: #059669; --link: #7dd3fc;
            --header: #0b3b36; --chat-bg: #111827; --bubble-in: #1e293b; --bubble-out: #14532d;
            --msg-in: #1e293b; --msg-out: #163a2c; --input: #0f172a;
        }
        html[data-theme="wa-dark"] {
            --bg: #0b141a; --surface: #111b21; --surface2: #202c33; --surface3: #2a3942; --border: #2a3942;
            --text: #e9edef; --muted: #8696a0; --accent: #00a884; --accent-hover: #06cf9c; --link: #53bdeb;
            --header: #202c33; --chat-bg: #0b141a; --bubble-in: #202c33; --bubble-out: #005c4b;
            --msg-in: #202c33; --msg-out: #005c4b; --input: #2a3942;
        }
        html.dark-ui { color-scheme: dark; }
        html.dark-ui body { background: var(--bg) !important; color: var(--text) !important; }
        html.dark-ui header, html.dark-ui .card, html.dark-ui .login-card, html.dark-ui #loading-bar-container,
        html.dark-ui .user-form, html.dark-ui .engine-opt, html.dark-ui .archive-row, html.dark-ui .wh-row,
        html.dark-ui .conv-members, html.dark-ui .users-table, html.dark-ui .wh-toolbar {
            background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; box-shadow: none !important;
        }
        html.dark-ui #login-overlay { background: var(--bg) !important; }
        html.dark-ui h1, html.dark-ui .login-card h2 { color: var(--accent) !important; }
        html.dark-ui .card h2, html.dark-ui .feed-head h2, html.dark-ui .msg-header, html.dark-ui .chat-title,
        html.dark-ui .member-name, html.dark-ui .wh-type, html.dark-ui .users-table td { color: var(--text) !important; }
        html.dark-ui .msg-time, html.dark-ui .chat-meta, html.dark-ui .chat-time:not(.unread), html.dark-ui .chat-preview,
        html.dark-ui .member-id, html.dark-ui .feed-range, html.dark-ui .tr-meta, html.dark-ui .wh-time, html.dark-ui .wh-meta,
        html.dark-ui .members-section, html.dark-ui .conv-members-top span, html.dark-ui .conv-members-desc,
        html.dark-ui .feed-empty, html.dark-ui .user-form .hint, html.dark-ui .engine-opt small,
        html.dark-ui .modal-card p, html.dark-ui .modal-card small { color: var(--muted) !important; }
        html.dark-ui .feed-head, html.dark-ui .card h2, html.dark-ui .filter-controls:not([hidden]) { border-color: var(--border) !important; }

        /* feed cards */
        html.dark-ui .msg-item { background: var(--msg-in) !important; border-color: var(--border) !important; color: var(--text) !important; }
        html.dark-ui .feed-list .msg-item.direction-out { background: var(--msg-out) !important; }
        html.dark-ui .msg-item.group-item { background: var(--msg-in) !important; }
        html.dark-ui .feed-list .msg-item.direction-out.group-item { background: var(--msg-out) !important; }
        html.dark-ui .msg-item.status-update-item { background: #2a1f33 !important; }
        html.dark-ui .msg-item.access-log-item { background: #2b2214 !important; }
        html.dark-ui .msg-item.revoked-item, html.dark-ui .chat-bubble.revoked-bubble { background: #3b1d22 !important; color: #fecaca !important; border-color: #7f1d1d !important; }
        html.dark-ui .url-container, html.dark-ui .media-container { border-color: var(--border) !important; }
        html.dark-ui .url-container a, html.dark-ui .clickable-lid { color: var(--link) !important; }
        html.dark-ui .session-tag, html.dark-ui .chat-sess, html.dark-ui .edit-history, html.dark-ui .tr-text,
        html.dark-ui .user-badge, html.dark-ui .session-picker { background: var(--surface2) !important; color: var(--text) !important; }
        html.dark-ui .feed-card.archive-mode .feed-list { background: #1f1a0e !important; }
        html.dark-ui .archive-banner { background: #2b2410 !important; color: #fcd34d !important; border-color: #78350f !important; }
        html.dark-ui .feed-range .older { background: #2e1f47 !important; color: #d8b4fe !important; border-color: #4c1d95 !important; }

        /* controls */
        html.dark-ui input, html.dark-ui select, html.dark-ui textarea {
            background: var(--input) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui input::placeholder { color: var(--muted) !important; }
        html.dark-ui .view-switch { border-color: var(--border) !important; }
        html.dark-ui .view-switch button { background: var(--surface) !important; color: var(--muted) !important; border-color: var(--border) !important; }
        html.dark-ui .view-switch button.active { background: var(--accent) !important; color: #fff !important; }
        html.dark-ui .action-btn:not([style*="background"]) { background: var(--accent) !important; }
        html.dark-ui .action-btn:not([style*="background"]):hover { background: var(--accent-hover) !important; }
        html.dark-ui .msg-del-btn { background: var(--surface2) !important; color: #fecaca !important; border-color: var(--border) !important; }
        html.dark-ui .tr-btn { background: var(--surface2) !important; color: #c7d2fe !important; border-color: var(--border) !important; }
        html.dark-ui .progress-track { background: var(--surface3) !important; }

        /* chat list */
        html.dark-ui .chat-row { border-color: var(--border) !important; }
        html.dark-ui .chat-row:hover, html.dark-ui .member-row:hover, html.dark-ui .archive-row:hover,
        html.dark-ui .wh-head:hover { background: var(--surface3) !important; }
        html.dark-ui .chat-badge, html.dark-ui .chat-time.unread { --x: 0; }
        html.dark-ui .chat-time.unread { color: var(--accent) !important; }
        html.dark-ui .chat-badge { background: var(--accent) !important; }

        /* conversation pop-up and other dialogs */
        html.dark-ui .modal-card { background: var(--chat-bg) !important; color: var(--text) !important; }
        html.dark-ui .modal-card[style*="background"] { background: var(--surface) !important; }
        html.dark-ui .modal-header { background: var(--header) !important; }
        html.dark-ui .chat-bubble.in { background: var(--bubble-in) !important; color: var(--text) !important; }
        html.dark-ui .chat-bubble.out { background: var(--bubble-out) !important; color: var(--text) !important; }
        html.dark-ui .bubble-sender { color: var(--accent) !important; }
        html.dark-ui .conv-name-row { background: var(--surface2) !important; color: var(--text) !important; border-color: var(--border) !important; }
        html.dark-ui .conv-name-row code { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text) !important; }
        html.dark-ui .users-table th { background: var(--surface2) !important; color: var(--muted) !important; }
        html.dark-ui .users-table th, html.dark-ui .users-table td { border-color: var(--border) !important; }
        html.dark-ui .wh-list { background: var(--bg) !important; }
        html.dark-ui .modal-card [style*="background:#fff"], html.dark-ui .modal-card [style*="background: #fff"] { background: var(--surface2) !important; }
        html.dark-ui [style*="color:#555"], html.dark-ui [style*="color:#666"], html.dark-ui [style*="color:#64748b"],
        html.dark-ui [style*="color:#94a3b8"], html.dark-ui [style*="color:#888"] { color: var(--muted) !important; }

        /* Ocean: light, with blue accents */
        html[data-theme="ocean"] body { background: #eef4fb !important; }
        html[data-theme="ocean"] h1 { color: #1d4ed8 !important; }
        html[data-theme="ocean"] .action-btn:not([style*="background"]), html[data-theme="ocean"] .view-switch button.active,
        html[data-theme="ocean"] .jump-latest:not(.has-new) { background: #2563eb !important; color: #fff !important; }
        html[data-theme="ocean"] .action-btn:not([style*="background"]):hover { background: #1d4ed8 !important; }
        html[data-theme="ocean"] .modal-header { background: #1e3a8a !important; }
        html[data-theme="ocean"] .modal-card:not([style*="background"]) { background: #e6eef8 !important; }
        html[data-theme="ocean"] .chat-bubble.out, html[data-theme="ocean"] .feed-list .msg-item.direction-out { background: #dbeafe !important; }
        html[data-theme="ocean"] .feed-list .msg-item.direction-out { border-right-color: #3b82f6 !important; }
        html[data-theme="ocean"] .chat-badge { background: #2563eb !important; }
        html[data-theme="ocean"] .chat-time.unread { color: #2563eb !important; }
        html[data-theme="ocean"] .bubble-sender { color: #1e40af !important; }
        html[data-theme="ocean"] #loading-bar-container { border-left-color: #2563eb !important; }

        .theme-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
