.expert-card {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: clip; /* clip visually like hidden, but does NOT create a scroll container — critical for touch scroll to reach children */
}

/* ── Combined Analysis: Monochromatic Sleek Header ── */
#combined-analysis-card .card-header {
    background: linear-gradient(120deg, var(--secondary) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border-color);
}

#combined-analysis-card .card-header i,
#combined-analysis-card .card-header svg {
    color: var(--accent) !important;
}

#combined-analysis-card .card-header h3 {
    color: var(--text-main) !important;
    font-weight: 700;
}

#combined-analysis-card .card-header .forensic-badge {
    background: var(--secondary);
    color: var(--text-main);
    border-color: var(--border-color);
}

#combined-analysis-card .card-header .forensic-badge i,
#combined-analysis-card .card-header .forensic-badge svg {
    color: var(--text-main) !important;
}


.expert-card .card-header {
    background: var(--secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.expert-card .card-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.expert-analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    padding: 2rem;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.expert-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    transition: background-color 0.2s;
}

.expert-item:hover {
    background-color: var(--secondary);
}

.expert-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.expert-item-header i {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.expert-narrative-bubble p {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    margin: 0;
    font-family: var(--font-sans);
}

.expert-narrative-bubble strong {
    color: var(--accent);
    font-weight: 600;
    background-color: var(--secondary);
    padding: 0 4px;
    border-radius: 4px;
}

.forensic-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #ecfdf5;
    color: #059669;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: auto;
    border: 1px solid #d1fae5;
}

@media (max-width: 900px) {
    .expert-analysis-grid {
        grid-template-columns: 1fr;
        padding: 1.25rem;
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    .expert-narrative-bubble p { font-size: 0.9rem; }
    .forensic-badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.5rem;
    }
}

.expert-tabs-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    min-height: 52px;
}

.expert-tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    white-space: nowrap;
    margin: 0;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s, color 0.2s;
}

.expert-tab-btn:hover {
    background: var(--secondary);
    color: var(--text-main);
}

.expert-tab-btn.active {
    background: var(--secondary);
    color: var(--accent);
    border-color: var(--border-color);
}

.expert-tab-btn i {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .expert-tabs-container {
        padding: 0.75rem 2.5rem;
        flex-wrap: nowrap;
    }

    .expert-tab-btn {
        display: none;
        border: none;
        background: transparent;
        font-size: 0.9rem;
        margin: 0 auto;
        pointer-events: auto; /* Changed from none to allow interaction */
    }

    .expert-tab-btn:hover {
        background: transparent;
        color: var(--accent);
    }

    .expert-tab-btn.active {
        display: flex;
        background: transparent;
        border-color: transparent;
    }
}

/* ── Reusable Horizontal Scroll Container for Forensic Data ── */
.forensic-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* Momentum scrolling for older iOS */
    overscroll-behavior-x: contain;   /* Prevent swipe-to-back browser gestures */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    touch-action: pan-x;               /* Explicitly allow horizontal touch, pass vertical to parent */
    position: relative;
    border-radius: 8px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    margin-top: 8px;
    will-change: scroll-position;      /* Hint for hardware acceleration */
}

.forensic-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.forensic-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.forensic-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

/* ── Mobile: Scroll Affordance (make scrollability discoverable) ── */
@media (max-width: 768px) {
    .forensic-scroll-container::-webkit-scrollbar {
        height: 4px;
        display: block; /* force visible on iOS/Android */
    }

    .forensic-scroll-container::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 10px;
        opacity: 1;
    }

    /* Right-edge gradient shadow: stays fixed while content scrolls,
       acting as a persistent indicator that content continues to the right.
       Uses the scroll-shadow technique with background-attachment:local/scroll. */
    .forensic-scroll-container {
        background:
            /* Fade-in mask on left when scrolled away from start */
            linear-gradient(to right, var(--bg-surface) 0%, transparent 24px),
            /* Persistent right-edge fade showing more content exists */
            linear-gradient(to left,  var(--bg-surface) 0%, transparent 40px),
            /* Actual content shadows for scroll position feedback */
            radial-gradient(farthest-side at 0%   50%, rgba(0,0,0,0.10), transparent) 0   50%,
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.10), transparent) 100% 50%,
            var(--bg-surface);
        background-repeat: no-repeat;
        background-size:
            24px 100%,
            40px 100%,
            14px 100%,
            14px 100%,
            auto;
        /* local = scroll with content (appears/disappears naturally)
           scroll = fixed relative to container (always visible) */
        background-attachment: local, local, scroll, scroll, local;
    }

    /* Swipe hint text shown at the bottom-right of open details on mobile */
    .expert-narrative-bubble details[open]::after {
        content: '\2194  swipe';
        display: block;
        text-align: right;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--accent);
        opacity: 0.6;
        margin-top: 4px;
        pointer-events: none;
    }
}

.expert-panes-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    overflow-anchor: none;
}

.expert-tab-pane {
    width: 100%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    transform: translateY(8px);
    min-width: 0;    /* prevent content from forcing pane to overflow parent */
    overflow: visible; /* allow children to scroll horizontally */
}

.expert-tab-pane.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    position: relative;
    transform: translateY(0);
}

/* Allow narrative bubble to contain scrollable tables without clipping */
.expert-narrative-bubble {
    overflow: visible;
    min-width: 0;
}

/* Ensure details/summary inside narrative never clip on mobile */
.expert-narrative-bubble details {
    overflow: visible;
}

.expert-narrative-bubble .forensic-scroll-container {
    max-width: 100%;
}

/* ── Forensic Reconstruction Panel Components ── */

/* Stats grid: uses auto columns so content determines width, no collapsing to fractions */
.forensic-stats-grid {
    display: grid;
    grid-template-columns: auto auto; /* auto = sized to content, not fractions */
    gap: 10px;
    font-size: 13px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    min-width: max-content; /* force container width = content width → triggers scroll */
    white-space: nowrap;
}

.forensic-stats-full-row {
    grid-column: 1 / -1;
}

/* Jump list: height-limited scrollable list of rows */
.timeline-jumps-list {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: visible;
    padding-right: 4px;
    min-width: max-content; /* grows to fit widest row */
}

/* Individual jump row: three-column flex layout, never wraps */
.forensic-jump-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 13px;
    min-width: max-content; /* each row stays on one line */
    white-space: nowrap;
}

/* Filename in jump row: fixed width, never clips with max-width: 40% */
.jump-filename {
    color: var(--text-muted);
    min-width: 120px;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Arrow + delta label in the middle */
.jump-delta {
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Section heading above the jump list */
.forensic-jumps-heading {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
    white-space: nowrap;
}

/* Narrative Bubble Support for DIV elements (same as P) */
.expert-narrative-bubble div {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    margin: 0;
    font-family: var(--font-sans);
}
@media (max-width: 640px) {
    .expert-narrative-bubble div { font-size: 0.9rem; }
}

/* Pulsing Tab Badge for Digital Integrity Warnings */
.tab-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
    display: inline-block;
    flex-shrink: 0;
}
.tab-badge.badge-warning {
    background-color: #ef4444; /* red */
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    animation: badge-pulse 2s infinite;
}
.tab-badge.badge-info {
    background-color: var(--accent);
}
@keyframes badge-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Integrity Alerts Styling */
.integrity-alerts-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.integrity-alerts-list li {
    font-size: 0.9rem;
    line-height: 1.65;
    display: block;
    color: var(--text-main);
}
.integrity-alerts-list li strong {
    font-weight: 600;
}
.integrity-alert-warning {
    color: var(--text-main);
}
.integrity-alert-info {
    color: var(--text-main);
}
