/* static/js/reasoning-tree.css */
/* ARCHITECTURE: Styles for clinical reasoning tree visualization */
/* WHY: Visual clarity for diagnostic decision trees */
/* TRADEOFF: Additional CSS vs polished clinical UI */

/* =============================================================================
   RT DESIGN TOKENS — Phase 0 of the 2026-07-20 overhaul
   (docs/plans/2026-07-20-001-reasoning-tree-overhaul-plan.md)

   FIX (2026-07-20): This file previously styled everything via a --color-*
   token family that was defined NOWHERE in the app, so the hardcoded fallback
   hexes (Tailwind blue #3b82f6 on #1a1a1a) always won, in every theme. All
   color/typography now routes through --rt-* tokens.

   INTEGRATION (2026-08-19): --rt-* re-pointed Dark-Roast-first using chained
   fallbacks: var(--dr-*, var(--term-*, <dr-hex>)). On census the --dr-* layer
   is inert (gated on [data-theme="dark-roast"]), so the --term-* middle step
   resolves and the surface follows dr-compat + roast-ladder skins exactly as
   before — prod colors are unchanged. In DR-native hosts the --dr-* token wins;
   the hex (always the DR value) is the last-resort fallback. Semantic notes:
   - "active" hypotheses + selection use the theme accent (teal via dr-compat).
   - confirmed = gold (--term-status-ready / --dr-stable); superseded + RX/
     medication accents use the gold family (was #eab308 / magenta #f472b6).
   ============================================================================= */

.reasoning-tree-panel,
.reasoning-tree-tooltip,
.reasoning-tree-container,
.reasoning-tree-stats,
.reasoning-tree-controls,
.reasoning-tree-sidebar,
.evidence-panel,
prov,
.prov-tag,
#reasoningTreeToolbarToggle,
/* RT v3 surfaces (argument takeover + lane strip/drawer) share the same
   token block — their rules live in reasoning-tree-surfaces.css. */
#rtArgumentView,
.rt-lane-badge,
.rt-diff-strip,
.rt-diff-drawer {
    --rt-bg:            var(--dr-obsidian, var(--term-bg-surface, #160E08));
    --rt-bg-elevated:   var(--dr-espresso, var(--term-bg-elevated, #2A1C13));
    --rt-bg-hover:      var(--dr-crater-deep, var(--term-border-subtle, #3C2A21));
    --rt-border:        var(--dr-crater-deep, var(--term-border-default, #3C2A21));
    --rt-border-strong: var(--dr-crater, var(--term-border-strong, #5A453A));
    --rt-ink:           var(--dr-crema, var(--term-fg-primary, #FFF7EE));
    --rt-ink-secondary: var(--dr-mocha, var(--term-fg-secondary, #8B7355));
    --rt-ink-muted:     var(--dr-asparagus, var(--term-fg-muted, #6E8068));
    --rt-accent:        var(--dr-accent, var(--term-accent, #E69A4C));
    --rt-accent-dim:    var(--dr-amber-dim, var(--term-accent-dim, rgba(230, 154, 76, 0.40)));
    --rt-accent-subtle: var(--dr-amber-subtle, var(--term-accent-subtle, rgba(230, 154, 76, 0.10)));
    --rt-confirmed:     var(--dr-stable, var(--term-status-ready, #DAA520));
    --rt-deferred:      var(--dr-warning, var(--term-status-editing, #BFA162));
    --rt-superseded:    var(--dr-gold, var(--term-gold, #DAA520));
    --rt-refuting:      var(--dr-error, var(--term-status-error, #C75B39));
    --rt-gold:          var(--dr-gold, var(--term-gold, #DAA520));
    --rt-glow-accent:   var(--dr-glow-amber, var(--term-glow-accent, 0 0 10px rgba(230, 154, 76, 0.25), 0 0 24px rgba(230, 154, 76, 0.20)));
    --rt-glow-green:    var(--dr-glow-teal, var(--term-glow-green, 0 0 10px rgba(76, 196, 180, 0.25), 0 0 24px rgba(76, 196, 180, 0.20)));
    --rt-glow-amber:    var(--dr-glow-gold, var(--term-glow-amber, 0 0 10px rgba(218, 165, 32, 0.25), 0 0 24px rgba(218, 165, 32, 0.20)));
    --rt-shadow-modal:  var(--term-shadow-modal, 0 8px 32px rgba(0, 0, 0, 0.5));
    --rt-font-mono:     var(--dr-font-mono, var(--term-font-mono, 'Fira Code', 'SF Mono', monospace));
    --rt-font-body:     var(--dr-font-body, var(--term-font-body, 'DM Sans', 'Inter', sans-serif));
}

/* =============================================================================
   REASONING TREE SVG
   ============================================================================= */

/* FIX (2026-02-27): display:block prevents inline SVG gap; width:100% fills
   container so D3 tree uses full panel width instead of hardcoded 500px. */
.reasoning-tree-svg {
    display: block;
    width: 100%;
    background: var(--rt-bg);
    border-radius: 8px;
    overflow: hidden;
}

/* Links */
.reasoning-tree-svg .tree-link {
    transition: stroke 0.2s, opacity 0.2s, stroke-width 0.2s, stroke-dasharray 0.2s;
}

.reasoning-tree-svg .link-confirmed {
    stroke: var(--rt-confirmed);
}

.reasoning-tree-svg .link-pruned {
    stroke: var(--rt-ink-muted);
}

/* Nodes */
.reasoning-tree-svg .tree-node {
    transition: opacity 0.2s;
    outline: none; /* Custom focus ring below */
}

.reasoning-tree-svg .tree-node:hover .node-bg {
    stroke-width: 2px;
    filter: brightness(1.1);
}

.reasoning-tree-svg .status-badge {
    pointer-events: none;
}

/* ACCESSIBILITY: Focus ring for keyboard navigation */
.reasoning-tree-svg .tree-node:focus-visible .node-bg {
    stroke: var(--rt-accent) !important;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 4px rgba(0, 255, 208, 0.45));
}

.reasoning-tree-svg .tree-node.selected .node-bg {
    stroke: var(--rt-accent) !important;
    stroke-width: 3px;
}

.reasoning-tree-svg .node-title {
    font-family: var(--rt-font-mono);
    font-size: 11px;
    font-weight: 600;
}

/* Empty state */
.reasoning-tree-svg .empty-state {
    font-size: 14px;
    font-style: italic;
}

/* Loading state spinner */
@keyframes rt-spinner-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.reasoning-tree-svg .rt-spinner-circle {
    animation: rt-spinner-rotate 1s linear infinite;
    transform-origin: center center;
}

/* Error state */
.reasoning-tree-svg .error-state {
    font-size: 13px;
}

/* Reduced motion: disable transitions/animations in tree renderer */
@media (prefers-reduced-motion: reduce) {
    .reasoning-tree-svg * {
        transition: none !important;
    }

    .reasoning-tree-svg .rt-spinner-circle {
        animation: none !important;
    }
}

/* =============================================================================
   TOOLTIP
   ============================================================================= */

.reasoning-tree-tooltip {
    background: var(--rt-bg-elevated);
    border: 1px solid var(--rt-border-strong);
    border-radius: 8px;
    padding: 12px 16px;
    max-width: 300px;
    box-shadow: var(--rt-shadow-modal);
    z-index: 1000;
    font-size: 13px;
}

.reasoning-tree-tooltip .tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.reasoning-tree-tooltip .tooltip-header strong {
    color: var(--rt-ink);
}

.reasoning-tree-tooltip .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.reasoning-tree-tooltip .status-indicator.confirmed {
    background: var(--rt-confirmed);
    box-shadow: var(--rt-glow-green);
}

.reasoning-tree-tooltip .status-indicator.active {
    background: var(--rt-accent);
}

.reasoning-tree-tooltip .status-indicator.pruned {
    background: var(--rt-ink-muted);
}

.reasoning-tree-tooltip .status-indicator.deferred {
    background: var(--rt-deferred);
}

.reasoning-tree-tooltip .status-indicator.superseded {
    background: var(--rt-superseded);
    opacity: 0.75;
}

.reasoning-tree-tooltip .tooltip-reasoning {
    color: var(--rt-ink-secondary);
    font-size: 12px;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--rt-bg);
    border-radius: 4px;
}

.reasoning-tree-tooltip .tooltip-evidence {
    display: flex;
    gap: 12px;
    font-size: 12px;
    margin-bottom: 8px;
}

.reasoning-tree-tooltip .evidence-for {
    color: var(--rt-confirmed);
}

.reasoning-tree-tooltip .evidence-against {
    color: var(--rt-refuting);
}

.reasoning-tree-tooltip .tooltip-hint {
    font-size: 11px;
    color: var(--rt-ink-muted);
    font-style: italic;
}

/* =============================================================================
   EVIDENCE PANEL
   ============================================================================= */

.evidence-panel {
    background: var(--rt-bg);
    border: 1px solid var(--rt-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.evidence-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rt-border);
    background: var(--rt-bg-elevated);
}

.evidence-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--rt-ink);
    margin: 0;
}

.evidence-panel-close {
    background: transparent;
    border: none;
    color: var(--rt-ink-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.evidence-panel-close:hover {
    background: var(--rt-bg-hover);
    color: var(--rt-ink);
}

.evidence-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Empty state */
.evidence-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--rt-ink-muted);
}

.evidence-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.evidence-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* Node header in panel */
.evidence-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--rt-border);
}

.evidence-node-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.evidence-node-status.confirmed {
    background: var(--rt-confirmed);
    box-shadow: var(--rt-glow-green);
}

.evidence-node-status.active {
    background: var(--rt-accent);
}

.evidence-node-status.pruned {
    background: var(--rt-ink-muted);
}

.evidence-node-status.deferred {
    background: var(--rt-deferred);
}

.evidence-node-status.superseded {
    background: var(--rt-superseded);
    opacity: 0.75;
}

.evidence-node-name {
    font-weight: 600;
    color: var(--rt-ink);
    font-size: 14px;
}

/* Reasoning text */
.evidence-reasoning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: var(--rt-bg-elevated);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--rt-ink-secondary);
}

.evidence-reasoning i {
    color: var(--rt-accent);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Evidence sections */
.evidence-section {
    margin-bottom: 20px;
}

.evidence-section:last-child {
    margin-bottom: 0;
}

.evidence-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.evidence-source-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--rt-border);
    border-radius: 8px;
    padding: 8px;
}

.evidence-source-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rt-border);
    color: var(--rt-ink-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.evidence-source-group-header i {
    color: var(--rt-ink-muted);
}

.evidence-source-group-title {
    font-weight: 600;
}

.evidence-source-group-count {
    margin-left: auto;
    background: var(--rt-bg);
    border: 1px solid var(--rt-border);
    border-radius: 999px;
    padding: 1px 7px;
    color: var(--rt-ink-muted);
    font-size: 10px;
}

.evidence-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.evidence-section-supporting .evidence-section-header {
    color: var(--rt-confirmed);
}

.evidence-section-supporting .evidence-section-header i {
    color: var(--rt-confirmed);
}

.evidence-section-refuting .evidence-section-header {
    color: var(--rt-refuting);
}

.evidence-section-refuting .evidence-section-header i {
    color: var(--rt-refuting);
}

/* Evidence list */
.evidence-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.evidence-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--rt-bg-elevated);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border-left: 3px solid transparent;
}

.evidence-item:hover {
    background: var(--rt-bg-hover);
    transform: translateX(2px);
}

.evidence-item:active {
    transform: translateX(0);
}

.evidence-item-supporting {
    border-left-color: var(--rt-confirmed);
}

.evidence-item-refuting {
    border-left-color: var(--rt-refuting);
}

.evidence-item i:first-child {
    color: var(--rt-ink-muted);
    flex-shrink: 0;
    margin-top: 2px;
}

.evidence-content {
    flex: 1;
    min-width: 0;
}

.evidence-text {
    font-size: 13px;
    color: var(--rt-ink);
    line-height: 1.4;
}

.evidence-value-line {
    margin-bottom: 4px;
    line-height: 1.3;
}

.evidence-value-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--rt-ink-secondary);
}

.evidence-value-text {
    font-size: 13px;
    color: var(--rt-ink);
}

.evidence-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.evidence-when-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--rt-accent-subtle);
    border: 1px solid var(--rt-accent-dim);
    color: var(--rt-accent);
}

.evidence-source-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--rt-bg);
    border-radius: 4px;
    color: var(--rt-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* Rx / medication evidence — gold accent so drips/drugs read differently from
   diagnostic sources (LAB, VITAL, etc.). Added 2026-04-21 alongside
   EvidenceSource.RX; retoned 2026-07-20 from off-palette magenta #f472b6 to
   the terminal gold family. */
.evidence-source-badge-rx {
    color: var(--rt-gold);
    background: var(--term-gold-subtle, rgba(212, 168, 87, 0.10));
    border: 1px solid var(--term-gold-dim, rgba(212, 168, 87, 0.35));
    text-transform: none;
    letter-spacing: 0.02em;
}

.evidence-source-group-rx {
    border-color: var(--term-gold-dim, rgba(212, 168, 87, 0.35));
    background: var(--term-gold-ghost, rgba(212, 168, 87, 0.05));
}

.evidence-source-group-rx .evidence-source-group-header {
    color: var(--rt-gold);
    border-bottom-color: var(--term-gold-subtle, rgba(212, 168, 87, 0.10));
}

.evidence-source-group-rx .evidence-source-group-header i {
    color: var(--rt-gold);
}

.evidence-strength {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.evidence-strength-strong {
    color: var(--rt-confirmed);
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.12);
}

.evidence-strength-moderate {
    color: var(--rt-deferred);
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.12);
}

.evidence-strength-weak,
.evidence-strength-unknown {
    color: var(--rt-ink-muted);
    border-color: rgba(138, 130, 120, 0.35);
    background: rgba(138, 130, 120, 0.12);
}

.evidence-supports-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(160, 152, 136, 0.15);
    border: 1px solid rgba(160, 152, 136, 0.35);
    color: var(--rt-ink-muted);
}

.evidence-link-icon {
    color: var(--rt-ink-muted);
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.evidence-item:hover .evidence-link-icon {
    opacity: 1;
}

/* Confidence bar */
.evidence-confidence {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--rt-border);
}

.confidence-label {
    font-size: 12px;
    color: var(--rt-ink-muted);
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--rt-bg);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rt-accent), var(--rt-confirmed));
    border-radius: 3px;
    transition: width 0.3s ease-out;
}

.confidence-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--rt-ink);
    min-width: 36px;
    text-align: right;
}

/* Temporal info */
.evidence-temporal {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--rt-ink-muted);
    margin-top: 12px;
}

.evidence-temporal i {
    color: var(--rt-ink-muted);
}

/* =============================================================================
   PROSE HIGHLIGHT
   ============================================================================= */

.evidence-highlight {
    background: rgba(0, 255, 208, 0.18) !important;
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(0, 255, 208, 0.35);
    transition: background 0.3s, box-shadow 0.3s;
}

@keyframes evidence-pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(0, 255, 208, 0.35);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(0, 255, 208, 0.15);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(0, 255, 208, 0.35);
    }
}

/* =============================================================================
   LAYOUT CONTAINER
   ============================================================================= */

.reasoning-tree-container {
    display: flex;
    gap: 16px;
    height: 100%;
}

.reasoning-tree-view {
    flex: 1;
    min-width: 0;
}

.reasoning-tree-sidebar {
    width: 320px;
    flex-shrink: 0;
}

.reasoning-tree-sidebar.hidden {
    display: none;
}

/* Stats bar */
.reasoning-tree-stats {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: var(--rt-bg-elevated);
    border-radius: 8px;
    margin-bottom: 12px;
}

.reasoning-tree-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reasoning-tree-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--rt-ink);
}

.reasoning-tree-stat-label {
    font-size: 11px;
    color: var(--rt-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.reasoning-tree-stat.confirmed .reasoning-tree-stat-value {
    color: var(--rt-confirmed);
}

.reasoning-tree-stat.pruned .reasoning-tree-stat-value {
    color: var(--rt-ink-muted);
}

.reasoning-tree-stat.active .reasoning-tree-stat-value {
    color: var(--rt-accent);
}

/* Controls */
.reasoning-tree-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.reasoning-tree-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--rt-bg-elevated);
    border: 1px solid var(--rt-border);
    border-radius: 6px;
    color: var(--rt-ink-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.reasoning-tree-control-btn:hover {
    background: var(--rt-bg-hover);
    color: var(--rt-ink);
    border-color: var(--rt-border-strong);
}

.reasoning-tree-control-btn.active {
    background: var(--rt-accent-subtle);
    color: var(--rt-accent);
    border-color: var(--rt-accent-dim);
    box-shadow: var(--rt-glow-accent);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .reasoning-tree-container {
        flex-direction: column;
    }

    .reasoning-tree-sidebar {
        width: 100%;
        max-height: 300px;
    }

    .reasoning-tree-stats {
        flex-wrap: wrap;
    }
}

/* =============================================================================
   REASONING TREE PANEL (Census Integration)
   FIX (2026-02-27): Normal-flow dashboard section inside .sol-clinical-grid-container.
   WHY: position:sticky + 65vh made it a giant overlay that took over the entire
        dashboard. Now it's a normal block element — a collapsible section above
        the clinical grid, sized like any other dashboard panel.
   BEHAVIOR: Persists in dashboard when rail closes. Only cleared on patient switch
        or explicit close (X button). Scrolls naturally with dashboard content.
   ============================================================================= */

/* FIX (2026-02-27): Removed max-height:400px cap that strangled the tree into
   an unusable thumbnail. 65vh gives the doctor enough room to actually read
   the tree on any viewport while still leaving dashboard space below. */
.reasoning-tree-panel {
    position: relative;
    width: 100%;
    max-height: 65vh;
    margin-bottom: var(--sol-space-md, 12px);
    background: var(--rt-bg);
    border: 1px solid var(--rt-border);
    border-radius: 8px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Reset any stale inline styles from old positioning logic */
    left: unset !important;
    top: unset !important;
}

/* No longer using transform-based show/hide — using display: none/flex */
.reasoning-tree-panel.open {
    /* kept for backwards compat — no-op now */
}

.reasoning-tree-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rt-border);
    background: var(--rt-bg-elevated);
}

.reasoning-tree-header h4 {
    color: var(--rt-ink);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.reasoning-tree-header i {
    color: var(--rt-accent);
}

.reasoning-tree-badge {
    background: var(--rt-accent-subtle);
    color: var(--rt-accent);
    border: 1px solid var(--rt-accent-dim);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.reasoning-tree-toggle-btn {
    background: transparent;
    border: none;
    color: var(--rt-ink-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-left: auto;
    transition: background 0.15s, color 0.15s;
}

.reasoning-tree-toggle-btn:hover {
    background: var(--rt-bg-hover);
    color: var(--rt-ink);
}

.reasoning-tree-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex shrinking within max-height: 400px panel */
}

.reasoning-tree-body .reasoning-tree-container {
    flex: 1;
    min-height: 420px;
    overflow: auto;
}

.reasoning-tree-body .reasoning-tree-evidence {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
    border-top: 1px solid var(--rt-border);
}

.reasoning-tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
    color: var(--rt-ink-muted);
}

.reasoning-tree-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.reasoning-tree-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* =============================================================================
   PROVENANCE TAGS IN EDITOR (TipTap Extension)
   NOTE (2026-07-20): V3-era notes carry no <prov> tags (inline generation
   disabled 2026-04-04/09) — these rules only affect pre-April stored notes.
   Retoned to the terminal palette; slated for replacement by note-block
   anchoring in overhaul Phase 2.
   ============================================================================= */

prov,
.prov-tag {
    display: inline;
    background: rgba(0, 255, 208, 0.10);
    border-radius: 2px;
    padding: 0 2px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

prov:hover,
.prov-tag:hover {
    background: rgba(0, 255, 208, 0.18);
    box-shadow: 0 0 0 1px rgba(0, 255, 208, 0.35);
}

prov.highlighted,
.prov-tag.highlighted {
    background: rgba(0, 255, 208, 0.25);
    box-shadow: 0 0 0 2px rgba(0, 255, 208, 0.45);
    animation: evidence-pulse 1s ease-in-out;
}

/* Source-specific styling */
prov[src="labs"],
.prov-tag[data-src="labs"] {
    background: rgba(34, 197, 94, 0.15);
}

prov[src="labs"]:hover,
.prov-tag[data-src="labs"]:hover {
    background: rgba(34, 197, 94, 0.25);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
}

prov[src="vitals"],
.prov-tag[data-src="vitals"] {
    background: rgba(245, 158, 11, 0.15);
}

prov[src="vitals"]:hover,
.prov-tag[data-src="vitals"]:hover {
    background: rgba(245, 158, 11, 0.25);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.4);
}

prov[src="imaging"],
.prov-tag[data-src="imaging"] {
    background: rgba(212, 168, 87, 0.15);
}

prov[src="imaging"]:hover,
.prov-tag[data-src="imaging"]:hover {
    background: rgba(212, 168, 87, 0.25);
    box-shadow: 0 0 0 1px rgba(212, 168, 87, 0.4);
}

prov[src="micro"],
.prov-tag[data-src="micro"] {
    background: rgba(239, 68, 68, 0.12);
}

prov[src="micro"]:hover,
.prov-tag[data-src="micro"]:hover {
    background: rgba(239, 68, 68, 0.20);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}

prov[src="exam"],
.prov-tag[data-src="exam"] {
    background: rgba(0, 255, 208, 0.12);
}

prov[src="exam"]:hover,
.prov-tag[data-src="exam"]:hover {
    background: rgba(0, 255, 208, 0.20);
    box-shadow: 0 0 0 1px rgba(0, 255, 208, 0.35);
}

/* Evidence ID tooltip on hover: prefer v2 data-prov-id, fall back to chunk-id */
prov::after,
.prov-tag::after {
    content: attr(data-prov-id);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--rt-bg-elevated);
    color: var(--rt-ink-muted);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
}
/* v1 fallback: show chunk-id when data-prov-id not present */
prov:not([data-prov-id])::after,
.prov-tag:not([data-prov-id])::after {
    content: attr(chunk-id);
}

prov:hover::after,
.prov-tag:hover::after {
    opacity: 1;
}

/* ===== ITERATION 11: Toolbar Toggle Button ===== */

#reasoningTreeToolbarToggle.active {
    background: var(--rt-accent-subtle);
    color: var(--rt-accent);
}

#reasoningTreeToolbarToggle.active i {
    color: var(--rt-accent);
}

/* =============================================================================
   V1.5 Phase 25: Bidirectional highlighting and orphan states
   ============================================================================= */

/* Pulse animation for bidirectional highlighting */
@keyframes prov-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.015);
        opacity: 0.97;
    }
}

/* Highlight class for bidirectional linking */
.prov-highlight {
    animation: prov-pulse 0.6s ease-in-out;
    animation-iteration-count: 1;
    background: rgba(0, 255, 208, 0.18) !important;
    box-shadow: 0 0 0 2px rgba(0, 255, 208, 0.35);
    border-radius: 2px;
    transition: background 0.3s, box-shadow 0.3s;
}

/* Orphan state: provenance tag in prose with no matching tree node */
.prov-orphan-prose {
    opacity: 0.5;
    filter: saturate(0.3);
    cursor: help;
}

/* Orphan state: tree node with no matching prose tag */
.prov-orphan-tree {
    opacity: 0.4;
    filter: grayscale(0.7);
}

/* Scroll margin for smooth scrolling to prov elements (fixed header clearance) */
prov,
.prov-tag {
    scroll-margin-top: 80px;
}

/* Reduced motion preference support */
@media (prefers-reduced-motion: reduce) {
    .prov-highlight {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* =============================================================================
   V1.5 Phase 26: Bidirectional UX - Glow Highlights
   ============================================================================= */

/*
 * Unified bidirectional highlight for prose <-> tree navigation
 * WHY: Same visual language both directions creates "connection" feeling
 * User decisions: instant, persistent, toggle, glow/shadow, accent hue, subtle pulse
 */

/* Glow highlight for prose prov tags and tree nodes */
.bidir-highlight {
    box-shadow:
        0 0 0 2px rgba(0, 255, 208, 0.55),
        0 0 12px 2px rgba(0, 255, 208, 0.30) !important;
    border-radius: 3px;
    background: rgba(0, 255, 208, 0.12) !important;
    transition: none; /* Instant - no fade-in per user decision */
}

/* Subtle pulse animation on first appearance to draw the eye */
@keyframes bidir-pulse {
    0% {
        box-shadow:
            0 0 0 2px rgba(0, 255, 208, 0.55),
            0 0 12px 2px rgba(0, 255, 208, 0.30);
    }
    50% {
        box-shadow:
            0 0 0 3px rgba(0, 255, 208, 0.75),
            0 0 20px 4px rgba(0, 255, 208, 0.40);
    }
    100% {
        box-shadow:
            0 0 0 2px rgba(0, 255, 208, 0.55),
            0 0 12px 2px rgba(0, 255, 208, 0.30);
    }
}

.bidir-highlight-pulse {
    animation: bidir-pulse 0.4s ease-out;
    animation-iteration-count: 1;
}

/* Tree node specific highlight (SVG rect needs different approach) */
.tree-node.bidir-highlight .node-bg {
    stroke: rgba(0, 255, 208, 0.75) !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 8px rgba(0, 255, 208, 0.45)) !important;
}

/* Scroll margin for smooth scrolling with header clearance */
.bidir-highlight {
    scroll-margin-top: 100px;
    scroll-margin-bottom: 40px;
}

/* Reduced motion preference - disable animation */
@media (prefers-reduced-motion: reduce) {
    .bidir-highlight-pulse {
        animation: none !important;
    }
}
