/* css/style.css */

/* --- DEFENSIVE RULE FOR TOP SPACE --- */
.main-content > *:first-child {
    margin-top: 0 !important;
}

:root {
    --font-primary: 'Roboto', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
    --font-secondary: 'Roboto Slab', serif;
    
    /* Sidebar Width Configuration - Dynamic Variables */
    --sidebar-width-expanded: clamp(260px, 22vw, 320px);
    --sidebar-width-collapsed: 72px;
    --sidebar-width: var(--sidebar-width-expanded); /* Default state */

    --color-tool-1: #2ecc71; --bg-tool-1: #eafaf1;
    --color-tool-2: #3498db; --bg-tool-2: #eaf3f9;
    --color-tool-3: #f1c40f; --bg-tool-3: #fef9e7;
    --color-tool-4: #e67e22; --bg-tool-4: #fdebd0;
    --color-tool-5: #9b59b6; --bg-tool-5: #f4eef6;
    --color-tool-6: #e74c3c; --bg-tool-6: #fbeee6;
    --color-tool-7: #f39c12; --bg-tool-7: #fdf2cc;
    --color-tool-8: #1abc9c; --bg-tool-8: #e8f8f5;
    --color-tool-9: #d35400; --bg-tool-9: #fbeee6;
    --color-tool-10: #7f8c8d; --bg-tool-10: #f2f4f4;
    
    --theme-blueprint: #1f6fb2; --theme-workshop: #27ae60;
    --theme-critique: #e67e22; --theme-council: #8e44ad;

    --color-text-primary: #333;
    --color-text-secondary: #6c7a7b;
    --color-text-headings: #2c3e50;
    --color-text-light: #ecf0f1;
    --color-text-on-highlight: #ffffff;

    --color-background: #f4f6f9;
    --color-card: #ffffff;
    --color-sidebar-bg: #2c3e50;
    
    --color-highlight: #1f6fb2;
    --color-warning: #e74c3c;
    --color-border: #e0e0e0;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 20px rgba(0,0,0,0.12);

    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px;
    
    --radius-1: 4px; --radius-2: 8px; --radius-3: 12px;
    
    --highlight-color: var(--color-highlight);
    --card-bg-color: var(--color-card);
    --primary-line-color: var(--color-highlight);
    --secondary-line-color: #7f8c8d;
    
    accent-color: var(--color-highlight);

    /* Domain-specific colors for concept cloud filtering */
    --domain-science: #2196f3;
    --domain-business: #4caf50;
    --domain-humanities: #9c27b0;
    --domain-arts: #ff9800;
    --domain-culture: #f44336;
    --domain-pedagogy: #006400;
    --domain-general: #7f8c8d;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

.dashboard-container {
    min-height: calc(var(--vh, 1vh) * 100);
    display: grid;
    /* Updated to use dynamic variable for collapse animation */
    grid-template-columns: var(--sidebar-width) 1fr;
    transition: grid-template-columns 0.3s ease;
}

.main-content { 
    display: flex;
    flex-direction: column;
    padding: clamp(24px, 3vw, 48px); 
    min-width: 0;
}

/* Generic spacing for children */
.main-content > * + * { 
    margin-top: clamp(16px, 2.5vh, 28px); 
}

/* --- FIX: TIGHTEN HEADER SPACING --- */
/* Override generic spacing specifically between breadcrumbs and the view container */
.main-content > .breadcrumb-nav + .view-container {
    margin-top: var(--space-3) !important;
}

.main-content > .view-container { 
    display: none; 
}
.main-content > .view-container.active-view {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
#nodes-view .node-explorer-container,
#modalities-view .modality-explorer-container,
#planner-view.active-view,
#pathways-view.active-view {
    flex-grow: 1;
}
.planner-main-content {
    min-height: 0;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

body {
    font-family: var(--font-primary);
    font-size: clamp(16px, 1.1vw + 12px, 18px);
    line-height: 1.6;
    background-color: var(--color-background); color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
}

h1, h2, h3, h4 { font-family: var(--font-secondary); color: var(--color-text-headings); }

/* --- FIX: REMOVE DEFAULT H1 MARGIN --- */
h1 { 
    font-weight: 600; 
    font-size: clamp(1.9rem, 1.5vw + 1.3rem, 2.6rem); 
    line-height: 1.15; 
    margin-top: 0; 
}

h2 { font-weight: 600; font-size: clamp(1.4rem, 1vw + 1.1rem, 2rem); }
h3 { font-weight: 600; font-size: clamp(1.1rem, 0.6vw + 1rem, 1.4rem); }
p, li { max-width: 70ch; }

.skip-link { position: absolute; top: -40px; left: 0; background: var(--color-text-headings); color: white; padding: var(--space-2) var(--space-3); text-decoration: none; z-index: 9999; transition: top 0.2s ease-in-out; }
.skip-link:focus { top: 0; }

/* --- SIDEBAR STYLES --- */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-sidebar-bg); 
    color: var(--color-text-light);
    padding: var(--space-6); 
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll during transition */
    display: flex; 
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    overscroll-behavior-y: contain;
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    position: relative;
    top: auto;
    right: auto;
    margin: 0 auto var(--space-4) auto;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1002;
}

.sidebar-collapse-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-light);
    border-color: var(--color-text-light);
}

.sidebar-header { text-align: center; margin-bottom: var(--space-4); }
.sidebar-header h2 { color: #fff; font-size: 1.4rem; margin: 0; }
.sidebar-header p { font-size: 0.9em; color: #b7c3cd; margin-top: 5px; }
.sidebar nav { flex-grow: 1; }

/* Nav Section Headers */
.nav-section {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-section:last-child {
    border-bottom: none;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #b7c3cd;
    letter-spacing: 0.08em;
    opacity: 0.85;
    margin: var(--space-4) 0 var(--space-2) 0;
    display: flex;
    align-items: center;
    height: 24px;
    white-space: nowrap;
}

/* Default: Hide the icon, show the text */
.nav-section-title .section-icon {
    display: none;
}
.nav-section-title .section-text {
    display: block;
}

.sidebar nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar nav a { display: flex; align-items: center; padding: var(--space-3) var(--space-4); color: var(--color-text-light); text-decoration: none; border-radius: var(--radius-2); transition: background-color 0.2s ease; font-weight: 500; font-size: 0.95rem; gap: 15px; position: relative; }
.sidebar nav a:hover { background-color: rgba(255,255,255,0.1); }
.sidebar nav a:focus-visible { 
    outline: 3px solid var(--color-highlight); 
    outline-offset: 2px; 
    background-color: rgba(255,255,255,0.15); 
    box-shadow: inset 0 0 0 3px var(--color-sidebar-bg);
}
.sidebar nav  a.active { background-color: var(--color-highlight); color: var(--color-text-on-highlight); }
.sidebar .tool-swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.sidebar .nav-item-number { flex-shrink: 0; width: 24px; text-align: right; color: #b7c3cd; }
.sidebar nav a.active .nav-item-number { color: var(--color-text-light); }
.sidebar .nav-icon { width: 16px; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: var(--space-5); border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-toggle-group { display: flex; flex-direction: column; gap: var(--space-3); }
.sidebar-toggle .switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.sidebar-toggle .switch input { opacity: 0; width: 0; height: 0; }
.sidebar-toggle .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #556678; transition: .4s; border-radius: 22px; }
.sidebar-toggle .slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
.sidebar-toggle input:checked + .slider { background-color: var(--color-highlight); }
.sidebar-toggle input:checked + .slider:before { transform: translateX(18px); }

/* --- EXPANDED STATE (DEFAULT) --- */
/* Hide the icon-only elements by default */
.sidebar-logo-icon { display: none; }
.stance-switch .stance-icon { display: none; }
.stance-switch .stance-text { display: inline; }

/* --- COLLAPSED SIDEBAR STATE --- */

/* 1. Trigger the width change */
body.sidebar-collapsed {
    --sidebar-width: var(--sidebar-width-collapsed);
}

/* 2. Reset Padding for Centering */
body.sidebar-collapsed .sidebar {
    padding-left: 0;
    padding-right: 0;
}
body.sidebar-collapsed .sidebar > div {
    width: 100%;
}

/* 3. Rotate the button */
body.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* 4. Header Transformation */
body.sidebar-collapsed .sidebar-header-text { display: none; }
body.sidebar-collapsed .sidebar-logo-icon { 
    display: block; 
    font-size: 1.8rem; 
    color: var(--color-highlight); 
    margin: 0 auto var(--space-4) auto;
    text-align: center;
}

/* 5. Stance Switch Transformation */
body.sidebar-collapsed .stance-switch {
    flex-direction: column; /* Stack buttons vertically */
    border: none; /* Remove border in mini mode for cleaner look */
    gap: 10px;
}
body.sidebar-collapsed .stance-switch button {
    padding: 10px;
    border-radius: 50%; /* Make them circular */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border: 1px solid var(--color-border);
}
body.sidebar-collapsed .stance-switch .stance-text { display: none; }
body.sidebar-collapsed .stance-switch .stance-icon { 
    display: block; 
    font-size: 1.1rem;
}

/* 6. Section Headers Transformation */
body.sidebar-collapsed .nav-section-title {
    justify-content: center; /* Center the icon */
    margin-bottom: var(--space-3);
    padding: 0;
}
body.sidebar-collapsed .nav-section-title .section-text { display: none; }
body.sidebar-collapsed .nav-section-title .section-icon { 
    display: block; 
    font-size: 1rem; 
    color: var(--color-highlight);
    opacity: 1;
    cursor: help;
}

/* 7. Footer Transformation */
body.sidebar-collapsed .sidebar-footer {
    display: none;
    opacity: 0;
}

/* 8. Navigation Items Transformation */
body.sidebar-collapsed .sidebar nav a {
    justify-content: center;
    padding: var(--space-3) 0;
}

body.sidebar-collapsed .sidebar nav a .nav-item-number {
    display: none;
}

/* 9. Handle Link Text & Tooltips */
/* Hide the text span by default in collapsed mode */
body.sidebar-collapsed .sidebar nav a span:not(.tool-swatch) {
    display: none;
}

/* Show text as a tooltip on hover */
body.sidebar-collapsed .sidebar nav a:hover span:not(.tool-swatch) {
    display: block;
    position: absolute;
    left: calc(var(--sidebar-width-collapsed) + 10px);
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 2000;
    font-size: 0.9rem;
    pointer-events: none; /* Prevent tooltip from catching mouse events */
}

/* Add a little arrow to the tooltip */
body.sidebar-collapsed .sidebar nav a:hover span:not(.tool-swatch)::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--color-sidebar-bg) transparent transparent;
}

/* Tooltip for Section Headers (Collapsed Mode) */
body.sidebar-collapsed .nav-section-title:hover {
    position: relative;
}

body.sidebar-collapsed .nav-section-title:hover::after {
    content: attr(title); /* Uses the title attribute from HTML */
    position: absolute;
    left: calc(var(--sidebar-width-collapsed) - 10px);
    top: -5px;
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 2001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.1);
}

/* --- GENERAL UI ELEMENTS --- */

.card { background-color: var(--color-card); padding: var(--space-6); border-radius: var(--radius-2); border: 1px solid var(--color-border); box-shadow: var(--shadow-md); margin-bottom: var(--space-6); }
.card.full-width { max-width: none; }

.tool-header-block {
    background-color: color-mix(in oklab, var(--color-highlight) 5%, var(--color-card));
    padding: var(--space-6);
    border-radius: var(--radius-2);
    margin-bottom: var(--space-5);
    border-left: 5px solid var(--color-highlight);
}
.tool-header-block h1 {
    margin: 0;
}
.tool-header-block .key-question {
    margin: var(--space-2) 0 0 0;
    font-size: clamp(1.2rem, 0.5vw + 1rem, 1.5rem); 
    font-style: italic; 
    color: var(--color-text-secondary);
}

.summary-card { padding: var(--space-5); border-radius: var(--radius-2); margin-bottom: var(--space-6); border-left: 5px solid var(--bg-ref-color); background: color-mix(in oklab, var(--bg-ref-color) 10%, var(--color-card)); }
.summary-card[data-tool-id="tool1"] { --bg-ref-color: var(--color-tool-1); }
.summary-card[data-tool-id="tool2"] { --bg-ref-color: var(--color-tool-2); }
.summary-card[data-tool-id="tool3"] { --bg-ref-color: var(--color-tool-3); }
.summary-card[data-tool-id="tool4"] { --bg-ref-color: var(--color-tool-4); }
.summary-card[data-tool-id="tool5"] { --bg-ref-color: var(--color-tool-5); }
.summary-card[data-tool-id="tool6"] { --bg-ref-color: var(--color-tool-6); }
.summary-card[data-tool-id="tool7"] { --bg-ref-color: var(--color-tool-7); }
.summary-card[data-tool-id="tool8"] { --bg-ref-color: var(--color-tool-8); }
.summary-card[data-tool-id="tool9"] { --bg-ref-color: var(--color-tool-9); }
.summary-card[data-tool-id="tool10"] { --bg-ref-color: var(--color-tool-10); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.summary-grid > div { min-width: 0; }
.summary-grid h4 { font-family: var(--font-secondary); font-size: 1.1em; margin: 0 0 12px 0; border-bottom: 1px solid rgba(0,0,0,0.15); padding-bottom: 8px; }
.summary-grid ul { list-style: none; padding: 0; margin: 0; }
.summary-grid li { margin-bottom: 4px; }
.summary-grid-full-span { grid-column: 1 / -1; }

.perspectives-container { margin-bottom: var(--space-6); }
.perspectives-nav { 
    display: flex; 
    flex-wrap: wrap; /* Allow wrapping to multiple rows */
    gap: var(--space-2); 
    border-bottom: 2px solid var(--color-border); 
    margin-bottom: var(--space-5); 
    padding-bottom: var(--space-2); /* Add padding so bottom row doesn't touch border */
    justify-content: flex-start; /* Align items to the left */
}

/* Ensure buttons maintain their size but can shrink slightly if needed on mobile */
.perspectives-nav button { 
    flex: 1 1 150px; /* Grow to fill space, shrink if needed, base width 150px */
    min-width: 140px; /* Prevent getting too squished */
    max-width: 200px; /* Prevent getting too wide on large screens */
    height: 60px;    
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    
    /* Styling */
    padding: var(--space-2); 
    border: 1px solid var(--color-border); 
    border-bottom: none; 
    background: #f0f0f0; 
    cursor: pointer; 
    font-weight: 600; 
    font-family: var(--font-secondary); 
    border-radius: var(--radius-1) var(--radius-1) 0 0; 
    transition: all 0.2s ease; 
    color: var(--color-text-headings); 
    font-size: 0.85rem; 
    line-height: 1.2;   
}

.perspectives-nav button { 
    /* Uniform Sizing */
    flex: 0 0 160px; /* Don't grow, don't shrink, fixed basis */
    width: 160px;    /* Explicit width */
    height: 60px;    /* Explicit height */
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    
    /* Styling */
    padding: var(--space-2); 
    border: 1px solid var(--color-border); /* Add border for definition */
    border-bottom: none; /* Connect to content */
    background: #f0f0f0; 
    cursor: pointer; 
    font-weight: 600; 
    font-family: var(--font-secondary); 
    border-radius: var(--radius-1) var(--radius-1) 0 0; 
    transition: all 0.2s ease; 
    color: var(--color-text-headings); 
    font-size: 0.85rem; /* Slightly smaller font to fit text */
    line-height: 1.2;   /* Tighter line height for wrapping */
}

.perspectives-nav button span {
    /* Ensure text wraps nicely */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal; /* Allow wrapping */
}

.perspectives-nav button:hover {
    background-color: #e0e0e0;
}

.perspectives-nav button.active { 
    background: var(--color-text-headings); 
    color: white; 
    border-color: var(--color-text-headings);
    transform: translateY(2px); /* Visual connection to content */
}

/* Dark Mode Adjustment */
body.dark-mode-active .perspectives-nav button { 
    background-color: #2c3e50; 
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

body.dark-mode-active .perspectives-nav button.active { 
    background: var(--color-highlight); 
    color: var(--color-text-on-highlight);
    border-color: var(--color-highlight);
}
.perspectives-nav button.active { background: var(--color-text-headings); color: white; }
.perspective-content { display: none; }
.perspective-content.active { display: block; }

.accordion-group { display: flex; flex-direction: column; gap: var(--space-3); }
.accordion-item { border: 1px solid var(--color-border); border-radius: var(--radius-2); margin-bottom: 10px; overflow: hidden; }
.accordion-header { background-color: #f9f9f9; padding: 15px; cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; align-items: center; width: 100%; border: none; text-align: left; font-size: 1em; font-family: var(--font-secondary); transition: background-color 0.2s ease; min-height: 44px; color: var(--color-text-headings); }
.accordion-header:hover { background-color: #f0f0f0; }
.accordion-title-group { display: flex; align-items: center; gap: 12px; }
.accordion-icon { transition: transform 0.3s ease; flex-shrink: 0; }
.accordion-item.active .accordion-icon { transform: rotate(180deg); }
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}
.accordion-content-inner { padding: 20px; }

.stance-switch { display: flex; border: 1px solid #556678; border-radius: var(--radius-1); overflow: hidden; margin-bottom: var(--space-4); }
.stance-switch button { flex: 1; padding: var(--space-2) var(--space-3); background-color: transparent; color: var(--color-text-light); border: none; cursor: pointer; font-weight: 500; font-size: 0.9em; transition: all 0.2s ease; }
.stance-switch button.active { background-color: var(--color-highlight); color: var(--color-text-on-highlight); }
.key-deliverables { display: block; padding: var(--space-3); margin-bottom: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-2); background: var(--color-background); font-size: 0.9em; }

.persona-switch { 
    display: flex; 
    border: 1px solid var(--color-border); 
    border-radius: var(--radius-1); 
    overflow: hidden;
    width: fit-content;
}
.persona-switch button { 
    padding: var(--space-2) var(--space-3); 
    background-color: var(--color-card); 
    color: var(--color-text-headings); 
    border: none; 
    cursor: pointer; 
    font-weight: 500; 
    font-size: 0.9em; 
    transition: all 0.2s ease; 
}
.persona-switch button:first-child {
    border-right: 1px solid var(--color-border);
}
.persona-switch button.active { 
    background-color: var(--color-highlight); 
    color: var(--color-text-on-highlight); 
}

.uid-tag { font-size: 0.7em; color: var(--color-text-secondary); opacity: 0.8; margin-left: auto; padding-left: 10px; font-family: monospace; }
#mini-map-container { position: fixed; bottom: 10px; right: 20px; z-index: 999; display: flex; gap: 4px; background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(8px); padding: 6px; border-radius: 99px; box-shadow: var(--shadow-md); border: 1px solid rgba(0, 0, 0, 0.1); }
.mini-map-segment { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; transition: all 0.2s ease; border: 2px solid transparent; }
.mini-map-segment:hover { transform: scale(1.2); }
.mini-map-segment.active-tool { box-shadow: 0 0 0 3px var(--color-highlight); }

.practitioner-plan {
    padding-left: var(--space-5);
}
.practitioner-plan li {
    margin-bottom: var(--space-4);
}
.practitioner-plan li::marker {
    font-family: var(--font-family-serif);
    font-weight: bold;
    color: var(--color-highlight);
}

body.high-contrast-mode { --color-background: #000; --color-card: #000; color: #fff; --color-text-headings: #fff; --color-text-secondary: #eee; --color-border: #fff; --color-highlight: #0ff; --shadow-md: 0 0 0 1px #fff; --color-text-primary: #fff; }
body.high-contrast-mode .sidebar { background-color: #000; border-right: 1px solid #fff; }
body.high-contrast-mode a { color: #0ff; }

body.reader-mode .sidebar, body.reader-mode #mini-map-container, body.reader-mode .menu-toggle { display: none !important; }
body.reader-mode .main-content { margin-left: 0; max-width: 800px; margin: 0 auto;
    display: block !important;
}
#exit-reader-mode-btn { display: none; position: fixed; top: 20px; right: 20px; z-index: 10001; }
body.reader-mode #exit-reader-mode-btn { display: inline-block; }

.menu-toggle { display: none; }
@media (max-width: 1024px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        height: 100vh;
        top: 0;
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        grid-column: 1 / -1;
    }
    .menu-toggle { display: flex; align-items: center; justify-content: center; position: fixed; top: 15px; left: 15px; z-index: 1001; background: var(--color-text-headings); color: white; border: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 1.4em; }
    
    /* Hide collapse button on mobile */
    .sidebar-collapse-btn {
        display: none;
    }
}

#welcome-view .card { text-align: center; }
.welcome-header { max-width: 70ch; margin: 0 auto var(--space-7) auto; }
.welcome-actions { display: flex; justify-content: center; gap: var(--space-5); flex-wrap: wrap; }
.welcome-action-card { background-color: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-2); padding: var(--space-5); text-decoration: none; color: inherit; min-width: 260px; flex: 1; max-width: 320px; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.welcome-action-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.welcome-action-card .resource-icon { font-size: 2em; margin-bottom: var(--space-3); color: var(--color-highlight); }
.welcome-action-card h4 { margin: 0 0 var(--space-2) 0; }
.welcome-action-card p { margin: 0 auto; color: var(--color-text-secondary); }

.workflow-container { 
    display: flex; 
    /* overflow-x: auto; <-- REMOVED: The wrapper handles scroll now */
    padding: 20px; 
    gap: 20px; 
    /* scrollbar-width: thin; <-- REMOVED */
    min-width: max-content; /* ADDED: Forces container to be full width of content */
}
.workflow-stage { flex: 0 0 300px; padding: 20px; border-radius: 8px; background-color: var(--color-card); border-top: 5px solid; cursor: pointer; transition: all 0.2s ease; }
.workflow-stage:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.workflow-stage__title { font-family: var(--font-secondary); font-size: 1.5em; margin: 0 0 10px 0; }
.workflow-stage__deliverable { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 0.9em; margin-bottom: 15px; color: var(--color-highlight); }
.workflow-stage__principle { font-size: 0.95em; color: var(--color-text-secondary); }

.glossary-list dt { font-weight: 700; color: var(--color-text-headings); font-size: 1.1em; }
.glossary-list dd { margin-left: 20px; margin-bottom: 20px; padding-left: 15px; border-left: 3px solid var(--color-text-light); }
.rubric-family { margin-bottom: 40px; }
.rubric-family h3 { border-bottom: 2px solid #eee; padding-bottom: 10px; }
.rubric-family table th,
.rubric-family table td {
    border: 1px solid var(--color-border);
    padding: var(--space-3); 
    vertical-align: top;
}
.bibliography-rationale { margin-top: var(--space-2); padding-left: var(--space-4); border-left: 3px solid color-mix(in oklab, var(--color-highlight) 80%, transparent); font-size: 0.9em; color: var(--color-text-secondary); font-style: italic; }
.cynefin-summary-box { padding: var(--space-5); border-radius: var(--radius-2); margin-bottom: var(--space-6); border-left: 5px solid var(--color-tool-10); background: color-mix(in oklab, var(--color-tool-10) 10%, var(--color-card)); }
.cynefin-summary-box h4 { margin-top: 0; color: var(--color-tool-10); font-size: 1.2em; }

.dominant-score { font-weight: 700; background-color: color-mix(in oklab, var(--color-tool-3) 25%, transparent); }
body.dark-mode-active .dominant-score { background-color: color-mix(in oklab, var(--color-tool-3) 35%, transparent); }

.back-to-top { position: fixed; bottom: 20px; right: 20px; z-index: 999; width: 44px; height: 44px; border-radius: 50%; background-color: var(--color-highlight); color: white; border: none; cursor: pointer; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; display: flex; align-items: center; justify-content: center; font-size: 1.2em; box-shadow: var(--shadow-md); }
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background-color: color-mix(in oklab, var(--color-highlight) 85%, black); transform: scale(1.1); }
.back-to-top:focus-visible { outline: 3px solid var(--color-border); outline-offset: 2px; }
.shortcuts-modal { border: 1px solid var(--color-border); border-radius: var(--radius-2); padding: var(--space-6); box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 500px; }
.shortcuts-modal::backdrop { background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px); }
.shortcuts-content { position: relative; }
.shortcuts-content h2 { margin: 0 0 var(--space-4) 0; }
.shortcuts-content h3 { margin: var(--space-4) 0 var(--space-2) 0; font-size: 1.1em; }
.shortcut-list { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.shortcut-item { display: flex; align-items: center; gap: var(--space-3); }
.shortcut-item kbd { background-color: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-1); padding: 4px 8px; font-family: monospace; font-size: 0.85em; font-weight: bold; white-space: nowrap; }
.close-modal { position: absolute; top: 10px; right: 10px; background: none; border: none; font-size: 1.5em; cursor: pointer; color: var(--color-text-secondary); }
.close-modal:hover { color: var(--color-text-headings); }
body.dark-mode-active .shortcuts-modal { background-color: var(--color-card); }

/* --- FIX: TIGHTEN BREADCRUMB SPACING --- */
.breadcrumb-nav { 
    margin-bottom: var(--space-2); 
    padding: var(--space-3) 0; 
    border-bottom: 1px solid var(--color-border); 
}

.breadcrumb-list { display: flex; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; gap: var(--space-2); }
.breadcrumb-list li { display: flex; align-items: center; gap: var(--space-2); }
.breadcrumb-list li:not(:last-child)::after { content: "/"; color: var(--color-text-secondary); }
.breadcrumb-list a { color: var(--color-highlight); text-decoration: none; font-weight: 500; }
.breadcrumb-list a:hover { text-decoration: underline; }
.breadcrumb-list a:focus-visible { outline: 2px solid var(--color-highlight); outline-offset: 2px; }
.breadcrumb-list li:last-child span { color: var(--color-text-headings); font-weight: 600; }

.glossary-tool-container { margin-top: var(--space-5); }
.glossary-search input[type="search"] { width: 100%; padding: var(--space-4); font-size: 1.2rem; border: 1px solid var(--color-border); border-radius: var(--radius-1); margin-bottom: var(--space-6); }
.glossary-results { display: grid; grid-template-columns: 1fr; gap: var(--space-5); }
.glossary-entry { background-color: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-2); padding: var(--space-5); }
.glossary-entry h3 { margin-top: 0; font-size: 1.4em; color: var(--color-highlight); border-bottom: 2px solid var(--color-border); padding-bottom: var(--space-3); margin-bottom: var(--space-4); }
.glossary-entry-details p { margin: 0 0 var(--space-3) 0; }
.glossary-entry-details h4 { margin-top: var(--space-5); margin-bottom: var(--space-3); font-size: 1.1em; }
.translation-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.translation-list li { background-color: var(--color-card); padding: var(--space-3); border-radius: var(--radius-1); border-left: 3px solid var(--color-text-secondary); }
.translation-list li strong { display: block; font-size: 0.85em; color: var(--color-text-secondary); text-transform: uppercase; }

.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-5); }
.resource-card { background-color: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-2); padding: var(--space-5); text-decoration: none; color: inherit; transition: transform 0.2s ease, box-shadow 0.2s ease; display: block; }
.resource-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.resource-card .resource-icon { font-size: 2em; margin-bottom: var(--space-3); color: var(--color-highlight); }
.resource-card h4 { margin: 0 0 var(--space-2) 0; }
.resource-card p { margin: 0; color: var(--color-text-secondary); font-size: 0.95em; }
.log-entry { margin-bottom: var(--space-6); padding-bottom: var(--space-5); border-bottom: 1px solid var(--color-border); }
.log-entry-answer { background-color: var(--color-background); padding: var(--space-4); border-radius: var(--radius-1); margin-top: var(--space-3); white-space: pre-wrap; font-family: var(--font-secondary); }
#export-log-btn { padding: var(--space-3) var(--space-4); border: 1px solid var(--color-highlight); background-color: var(--color-highlight); color: white; border-radius: var(--radius-1); cursor: pointer; font-weight: 500; transition: all 0.2s ease; }
#export-log-btn:hover { background-color: color-mix(in oklab, var(--color-highlight) 85%, black); }

.skeleton-card { padding: var(--space-6); border-radius: var(--radius-2); background: var(--color-card); border: 1px solid var(--color-border); margin-bottom: var(--space-6); }
.skeleton { 
    background-color: var(--color-border);
    border-radius: var(--radius-1); 
    height: 1em; 
    margin-bottom: var(--space-3);
    animation: deepmind-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.skeleton-title { height: 1.5em; width: 60%; margin-bottom: var(--space-4); }
.skeleton-text { height: 1em; width: 100%; }

@keyframes deepmind-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .5;
  }
}

@media (prefers-reduced-motion: reduce) { 
    .skeleton { 
        animation: none; 
        background: var(--color-background); 
    } 
}

.welcome-hub-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    margin-top: var(--space-6);
}
.welcome-choice-card {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-3);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: all 0.3s ease;
}
.welcome-choice-card.is-recommended {
    border-color: var(--color-highlight);
    box-shadow: 0 0 20px color-mix(in oklab, var(--color-highlight) 20%, transparent);
    transform: scale(1.02);
}
.welcome-choice-content {
    flex-grow: 1;
}
.welcome-choice-icon {
    font-size: 3rem;
    color: var(--color-highlight);
    margin-bottom: var(--space-4);
}
.welcome-choice-card h2 {
    font-size: 1.8rem;
    margin: 0 0 var(--space-3) 0;
}
.welcome-choice-card p {
    color: var(--color-text-secondary);
    max-width: 45ch;
    margin: 0 auto;
}
.welcome-choice-button {
    display: inline-block;
    margin-top: var(--space-6);
    padding: var(--space-4) var(--space-6);
    background-color: var(--color-highlight);
    color: var(--color-text-on-highlight);
    text-decoration: none;
    font-weight: 700;
    border-radius: var(--radius-2);
    transition: background-color 0.2s ease;
}
.welcome-choice-button:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 85%, black);
}

.sidebar-stuck-button {
    display: block;
    width: 100%;
    text-align: center;
    padding: var(--space-3);
    margin: var(--space-4) 0;
    border: 2px dashed color-mix(in oklab, var(--color-highlight) 50%, var(--color-sidebar-bg));
    background-color: color-mix(in oklab, var(--color-highlight) 20%, var(--color-sidebar-bg));
    color: var(--color-text-light);
    border-radius: var(--radius-2);
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}
.sidebar-stuck-button:hover {
    border-style: solid;
    border-color: var(--color-highlight);
    background-color: var(--color-highlight);
}
.sidebar-stuck-button i {
    margin-right: var(--space-2);
}

.overview-controls {
    margin-bottom: var(--space-5);
}
.overview-controls label {
    font-weight: 700;
    margin-right: var(--space-3);
}
#methodology-select {
    padding: var(--space-2) var(--space-3);
    font-size: 1rem;
    border-radius: var(--radius-1);
    border: 1px solid var(--color-border);
}
.workflow-container-wrapper {
    position: relative;
}
#overview-path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.internal-link {
    color: var(--color-highlight);
    text-decoration: none;
    border-bottom: 2px solid color-mix(in oklab, var(--color-highlight) 20%, transparent);
    font-weight: 600;
    transition: all 0.2s ease;
}
.internal-link:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 15%, transparent);
    border-bottom-color: var(--color-highlight);
}
.internal-link[data-link-type="node"] {
    cursor: pointer;
}

.jtbd-perspective-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}
.jtbd-perspective-content h3 {
    font-size: 1.2em;
    margin-bottom: var(--space-3);
    color: var(--color-text-headings);
}
.jtbd-perspective-content .jtbd-core-story p {
    font-size: 1.1em;
    font-style: italic;
    color: var(--color-text-secondary);
    margin: 0;
}
.node-explorer-controls { 
    display: flex; 
    gap: var(--space-4); 
    margin-bottom: var(--space-4); 
}
.node-explorer-controls input, 
.node-explorer-controls select { 
    width: 100%; 
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: var(--space-3);
    border-radius: var(--radius-1);
    font-size: 1rem;
    height: 42px;
}

.jtbd-forces-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}
.jtbd-force-card h4 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-2) 0;
    font-size: 1.1em;
}

.node-theme-filters { 
    margin-bottom: var(--space-4); 
}

.node-theme-filters .segmented-control {
    display: flex;
    background-color: var(--color-background);
    border-radius: var(--radius-1);
    overflow: hidden;
    border: 1px solid var(--color-border);
    width: fit-content; 
}

.node-theme-filters .theme-filter-btn {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: 0.2s ease-in-out;
    font-size: 0.9rem; 
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 500;
    border-right: 1px solid var(--color-border); 
}

.node-theme-filters .theme-filter-btn:last-child {
    border-right: none;
}

.node-theme-filters .theme-filter-btn:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 10%, transparent);
    color: var(--color-highlight);
}

.node-theme-filters .theme-filter-btn.active {
    background-color: var(--color-highlight);
    color: white;
}

body.dark-mode-active .node-theme-filters .theme-filter-btn {
    color: var(--color-text-secondary);
}
body.dark-mode-active .node-theme-filters .theme-filter-btn:hover {
    background-color: #2c3e50;
}
body.dark-mode-active .node-theme-filters .theme-filter-btn.active {
    background-color: var(--color-highlight);
    color: white;
}
.jtbd-force-card p {
    margin: 0;
    padding-left: calc(1em + var(--space-3));
    color: var(--color-text-secondary);
}
.jtbd-force-card.push h4 { color: var(--color-warning); }
.jtbd-force-card.pull h4 { color: var(--color-tool-1); }
.jtbd-force-card.habit h4 { color: var(--color-tool-7); }
.jtbd-force-card.anxiety h4 { color: var(--color-tool-5); }
.jtbd-persona-plan {
    background-color: var(--color-background);
    padding: var(--space-5);
    border-radius: var(--radius-2);
    border: 1px solid var(--color-border);
}
.jtbd-persona-plan h3 {
    margin-top: 0;
}
.jtbd-persona-plan ol {
    padding-left: var(--space-5);
}
.jtbd-persona-plan li {
    margin-bottom: var(--space-3);
}
.jtbd-persona-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.neuro-step-card { background-color: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-2); padding: var(--space-4); margin-bottom: var(--space-4); }
.neuro-step-card h4 { margin-top: 0; font-size: 1.1em; color: var(--color-highlight); }
.neuro-step-card p { margin-top: var(--space-2); margin-bottom: var(--space-4); font-size: 0.95em; }
.neuro-details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3) var(--space-4); font-size: 0.85em; color: var(--color-text-secondary); }
.neuro-details-grid code { background-color: color-mix(in oklab, var(--color-text-headings) 10%, transparent); padding: 2px 6px; border-radius: var(--radius-1); font-size: 0.9em; }
.confidence-tag { font-weight: bold; padding: 2px 8px; border-radius: 99px; font-size: 0.9em; text-transform: uppercase; }
.confidence-tier-1 { background-color: #27ae60; color: white; }
.confidence-tier-2 { background-color: #f39c12; color: white; }
.confidence-tier-3 { background-color: #c0392b; color: white; }

.node-modal {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    width: 90%;
    max-width: 700px;
    height: fit-content;
    max-height: 85vh;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-3);
    padding: 0;
    box-shadow: var(--shadow-lg);
    background-color: var(--color-card);
    color: var(--color-text-primary);
    z-index: 10000;
    overflow: hidden;
}
.node-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 85vh;
}
.node-modal-header {
    padding: var(--space-5) var(--space-6);
    padding-right: 60px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
    flex-shrink: 0;
}
.node-modal-body {
    padding: var(--space-5) var(--space-6);
    overflow-y: auto;
    flex-grow: 1;
}
.node-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}
.node-modal[open] {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.node-modal .close-modal {
    position: absolute;
    top: 50%;
    right: var(--space-5);
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.8em;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
}
.node-modal .close-modal:hover {
    color: var(--color-text-headings);
}
.node-modal h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.node-modal h4 {
    font-size: 0.9em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-2);
}
.node-modal .node-modal-body h4:first-of-type {
    margin-top: 0;
}
.modal-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    font-size: 0.95em;
}
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.tags-list span {
    background: var(--color-background);
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.9em;
}
.node-modal ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.node-modal ul li {
    background: var(--color-background);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-1);
    margin-bottom: var(--space-2);
    font-size: 0.95em;
}

.systems-lens-section {
    margin-top: var(--space-5);
}
.systems-lens-toggle {
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4);
    width: 100%;
    border-radius: var(--radius-1);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text-headings);
    text-align: left;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.systems-lens-toggle i {
    transition: transform 0.3s ease;
}
.systems-lens-content {
    display: none;
    margin-top: var(--space-4);
}
.systems-lens-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
}
.systems-lens-tab {
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-bottom: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius-1) var(--radius-1) 0 0;
    margin-bottom: -1px;
    background-color: transparent; 
}

.systems-lens-tab:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--color-text-headings);
}

body.dark-mode-active .systems-lens-tab:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--color-text-headings);
}
.systems-lens-tab.active {
    border-color: var(--color-border);
    background-color: var(--color-card);
    color: var(--color-highlight);
    border-bottom: 1px solid var(--color-card);
}
.systems-lens-tab-content {
    display: none;
}
.systems-lens-tab-content.active {
    display: block;
}
.systems-component-item {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-3);
}
.systems-component-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.systems-component-item h5 {
    margin: 0 0 var(--space-2) 0;
    font-size: 1.05em;
}
.domain-translations-toggle {
    font-size: 0.85em;
    color: var(--color-highlight);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    margin-top: var(--space-3);
    display: inline-block;
}
.domain-translations-content {
    display: none;
    margin-top: var(--space-3);
    font-size: 0.9em;
    padding-left: var(--space-4);
    border-left: 2px solid var(--color-border);
}
.domain-translations-content ul {
    padding: 0;
    margin: 0;
    list-style: none;
}
.domain-translations-content li {
    margin-bottom: var(--space-2);
    background: none;
    padding: 0;
}

#planner-view {
    padding: 0;
    margin: 0;
    background-color: var(--color-background);
}
#planner-view.active-view {
    display: flex;
    flex-direction: column;
    height: auto;
}
.planner-sticky-header {
    position: sticky;
    top: 0;
    background-color: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4) var(--space-6);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.planner-header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}
.planner-header-controls h1 {
    margin: 0;
    font-size: 1.5rem;
}
#domain-switcher-container label {
    font-weight: 500;
    margin-right: var(--space-3);
    color: var(--color-text-secondary);
}
#domain-switcher-container select {
    padding: var(--space-2) var(--space-3);
    font-size: 1rem;
    border-radius: var(--radius-1);
    border: 1px solid var(--color-border);
    background-color: var(--color-background);
}
.planner-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
#persistence-status {
    font-size: 0.85em;
    color: var(--color-text-secondary);
    font-style: italic;
    opacity: 0;
    transition: opacity 0.5s ease;
}
.planner-button {
    padding: var(--space-3) var(--space-4);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    background-color: var(--color-highlight);
    color: white;
    border: none;
    border-radius: var(--radius-1);
}
.planner-main-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-5);
    padding: var(--space-6);
    overflow-y: auto;
    flex-grow: 1;
}
.planner-body {
    min-width: 0;
}
.planner-challenge {
    font-style: italic;
    color: var(--color-text-secondary);
    margin-top: 0;
}
.planner-note {
    background-color: var(--color-background);
    padding: var(--space-4);
    border-left: 3px solid var(--color-tool-10);
    margin: var(--space-4) 0;
    font-size: 0.95em;
}
.planner-field {
    margin-bottom: var(--space-5);
}
.planner-field label {
    display: block;
    font-weight: 700;
    margin-bottom: var(--space-2);
}
.planner-textarea {
    width: 100%;
    padding: var(--space-3);
    font-family: var(--font-primary);
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
}
.planner-example {
    font-size: 0.85em;
    color: var(--color-text-secondary);
    margin-top: var(--space-2);
}
.domain-content {
    display: none;
}
#planner-view.domain-active-general .domain-content[data-domain="general"],
#planner-view.domain-active-science_and_engineering .domain-content[data-domain="science_and_engineering"],
#planner-view.domain-active-arts_and_design .domain-content[data-domain="arts_and_design"],
#planner-view.domain-active-humanities_and_ss .domain-content[data-domain="humanities_and_ss"],
#planner-view.domain-active-business_and_agile .domain-content[data-domain="business_and_agile"],
#planner-view.domain-active-culture_and_ethics .domain-content[data-domain="culture_and_ethics"],
#planner-view.domain-active-pedagogy_and_facilitation .domain-content[data-domain="pedagogy_and_facilitation"] {
    display: block;
}
#planner-minimap-container {
    width: 24px;
    height: fit-content;
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background-color: var(--color-card);
    padding: 4px;
    border-radius: var(--radius-1);
    border: 1px solid var(--color-border);
}
.minimap-segment {
    height: 40px;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.minimap-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0,0,0,0.2);
    transition: height 0.3s ease;
}
.minimap-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.minimap-dot.is-complete {
    opacity: 1;
}

/* --- PATHWAY EXPLORER STYLES --- */
#pathways-view .explorer-container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}
#pathways-view .explorer-header {
    margin-bottom: var(--space-6);
    flex-shrink: 0;
}
#pathways-view .explorer-header h1 {
    font-size: 2.5rem;
    margin-bottom: var(--space-2);
}
#pathways-view .explorer-header p {
    font-size: 1.1rem;
    max-width: 80ch;
}
#pathways-view .explorer-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-5);
    align-items: flex-end;
    background-color: var(--color-card);
    padding: var(--space-5);
    border-radius: var(--radius-2);
    margin-bottom: var(--space-5);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}
#pathways-view .control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
#pathways-view .control-group label, 
#pathways-view .control-group h4 {
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin: 0 0 0 var(--space-1);
}
#pathways-view #selected-domain-name {
    margin: 0 0 var(--space-2) var(--space-1);
    font-size: 1rem;
    font-weight: 500;
    min-height: 1.2em;
    color: var(--color-text-headings);
}
#pathways-view input[type="search"], 
#pathways-view select {
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: var(--space-3);
    border-radius: var(--radius-1);
    font-size: 1rem;
    height: 42px;
}
#pathways-view .segmented-control {
    display: flex;
    background-color: var(--color-background);
    border-radius: var(--radius-1);
    overflow: hidden;
    border: 1px solid var(--color-border);
}
#pathways-view .segmented-control .filter-btn {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: 0.2s ease-in-out;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-grow: 1;
    justify-content: center;
}
#pathways-view .segmented-control .filter-btn:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 10%, transparent);
}
#pathways-view .segmented-control .filter-btn.active {
    background-color: var(--color-highlight);
    color: white;
}

.pathway-matrix-wrapper {
    overflow-x: auto;
    flex-grow: 1;
    padding-bottom: var(--space-4);
}
.pathway-matrix {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 300px;
    gap: var(--space-4);
    min-width: fit-content;
    padding-top: var(--space-4);
}
.tool-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.tool-column-header {
    font-family: var(--font-secondary);
    font-weight: 700;
    padding: var(--space-3);
    background-color: var(--color-card);
    border-radius: var(--radius-1);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    border: 1px solid var(--color-border);
}
#pathways-view .accordion-item {
    background-color: var(--color-card);
    z-index: 1;
}
#pathways-view .accordion-item.active {
    z-index: 100;
}
#pathways-view .accordion-header {
    background-color: transparent;
}
#pathways-view .accordion-content-inner {
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-3);
}
.domain-icon {
    width: 1.2em;
    text-align: center;
}
.speculative-tag {
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--color-warning);
    color: white;
    padding: 2px 8px;
    border-radius: 99px;
    margin-left: auto;
}
.pathway-summary {
    font-style: italic;
    color: var(--color-text-secondary);
    font-size: 0.95em;
}
.pathway-details-grid {
    margin: var(--space-4) 0;
}
.citation-link {
    display: inline-block;
    margin-left: var(--space-2);
    color: var(--color-text-secondary);
    cursor: pointer;
    position: relative;
}
.citation-tooltip {
    visibility: hidden;
    width: 300px;
    background-color: var(--color-sidebar-bg);
    color: #fff;
    text-align: left;
    border-radius: var(--radius-2);
    padding: var(--space-3);
    position: absolute;
    z-index: 101;
    bottom: 125%;
    left: 50%;
    margin-left: -150px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    pointer-events: none; 
}
.citation-link:hover .citation-tooltip,
.citation-link:focus .citation-tooltip {
    visibility: visible;
    opacity: 1;
}

/* --- EXPLORER VIEWS STYLES --- */

/* Visual Map Styles */
.map-grid-wrapper { overflow-x: auto; }
.map-grid { 
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: var(--space-5); 
    position: relative; 
    min-width: 1200px; 
}
.map-tool-card { 
    background-color: var(--color-card); 
    border-radius: var(--radius-2); 
    padding: var(--space-4); 
    border-left: 5px solid; 
    min-width: 200px; 
}
.map-tool-card h3 { margin: 0 0 var(--space-4) 0; }
.node-list-container ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.node-item { display: flex; align-items: center; gap: var(--space-3); font-size: 0.9em; transition: opacity 0.3s ease; }
.node-item.is-hidden { opacity: 0.2; }
#map-pathway-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; opacity: 0; transition: opacity 0.3s ease; }
#map-pathway-svg.visible { opacity: 1; }

/* Network Map Styles */
.network-horizon-container { 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-4); 
    position: relative; 
}
.method-row-container, .tool-row { 
    display: flex; 
    justify-content: space-between; 
    gap: var(--space-4); 
    flex-wrap: wrap; 
}
.method-sub-row { 
    display: flex; 
    flex: 1 1 48%; 
    justify-content: space-between; 
    gap: var(--space-4); 
}
.method-card, .tool-card { 
    border: 1px solid var(--color-border); 
    border-radius: var(--radius-2); 
    padding: var(--space-4); 
    text-align: center; 
    transition: all 0.2s ease; 
    background-color: var(--color-card); 
}
.tool-card {
    flex: 1 1 18%; 
    min-width: 120px; 
}
.method-card { 
    cursor: pointer;
    padding: var(--space-3); 
    font-size: 0.9em;
    flex: 1 1 18%; 
    min-width: 100px;
}
.method-card:hover { background-color: var(--color-background); }
.method-card.highlighted, .tool-card.highlighted { border-color: var(--highlight-color); box-shadow: 0 0 10px color-mix(in oklab, var(--highlight-color) 20%, transparent); }
.tool-card ul { list-style: none; padding: 0; margin-top: var(--space-3); font-size: 0.85em; text-align: left; }
#connection-svg { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: 10; 
}
#connection-svg line { transition: stroke-dashoffset 0.8s ease-out; }

/* Node Explorer Styles */
.node-explorer-container { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: var(--space-5); 
    flex-grow: 1; 
    min-height: 0; 
}
.node-map-area { display: flex; flex-direction: column; min-width: 0; }
.node-explorer-controls { display: flex; gap: var(--space-4); margin-bottom: var(--space-4); }
.node-explorer-controls input, .node-explorer-controls select { width: 100%; }
.node-theme-filters { margin-bottom: var(--space-4); }
.node-map-wrapper { overflow-x: auto; flex-grow: 1; }
.node-map { display: grid; grid-auto-flow: column; grid-auto-columns: 250px; gap: var(--space-4); position: relative; }
.node-card { width: 100%; text-align: left; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--color-border); border-left-width: 5px; border-radius: var(--radius-1); cursor: pointer; background-color: var(--color-card); transition: all 0.2s ease; }
.node-card:hover { background-color: var(--color-background); }
.node-card.is-active { border-color: var(--highlight-color); box-shadow: var(--shadow-sm); }
.node-card.is-hidden { display: none; }
.node-card.is-path-member { border-width: 2px; border-color: var(--color-highlight); }
#node-details-pane {
    display: none !important;
}
.node-details-placeholder { 
    display: none !important;
}

/* Modality Explorer Styles */
.modality-explorer-container { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); flex-grow: 1; min-height: 0; }
.modality-map-area { display: flex; flex-direction: column; gap: var(--space-5); }
.modality-group h3 { margin: 0 0 var(--space-3) 0; }
.modality-grid { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.modality-card { 
    padding: var(--space-2) var(--space-4); 
    font-size: 0.95rem; 
    border: 1px solid var(--color-border); 
    border-radius: var(--radius-1); 
    cursor: pointer; 
    background-color: var(--color-card); 
    transition: all 0.2s ease; 
    display: flex;
    align-items: center;
    gap: 8px;
}
.modality-card:hover { background-color: var(--color-background); }
.modality-card.active { background-color: var(--color-highlight); color: white; border-color: var(--color-highlight); }
.modality-details { background-color: var(--color-background); padding: var(--space-5); border-radius: var(--radius-2); }
.dependency-list { font-size: 0.9em; }
.dependency-list .strength { font-weight: bold; padding: 2px 6px; border-radius: 99px; font-size: 0.8em; }
.strength-Essential { background-color: var(--color-warning); color: white; }
.strength-Strong { background-color: var(--color-tool-3); color: var(--color-text-headings); }

.modality-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}
.sensory-icon { color: #2196f3; } 
.embodied-icon { color: #4caf50; } 
.symbolic-icon { color: #ff9800; } 
.cognitive-icon { color: #e74c3c; } 
.meta-icon { color: #9b59b6; } 
.modality-group h3 .sensory-icon { color: #2196f3; }
.modality-group h3 .embodied-icon { color: #4caf50; }
.modality-group h3 .symbolic-icon { color: #ff9800; }
.modality-group h3 .cognitive-icon { color: #e74c3c; }
.modality-group h3 .meta-icon { color: #9b59b6; }

/* --- LAYOUT RIGIDITY & OVERSCROLL FIXES --- */

html, body {
    overflow-x: hidden;
    overscroll-behavior-y: none; 
}

.sidebar {
    overscroll-behavior-y: contain;
}

body {
    overflow-wrap: break-word;
}
img, video, svg {
    max-width: 100%;
    height: auto;
}
.table-wrapper {
    overflow-x: auto; 
}

/* --- DARK MODE OVERRIDES --- */
body.dark-mode-active { 
    --color-background: #16202a; 
    --color-card: #202d3a; 
    --color-text-primary: #e1e1e1; 
    --color-text-secondary: #95a5a6; 
    --color-text-headings: #ecf0f1; 
    --color-border: #34495e; 
}
body.dark-mode-active ::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}
body.dark-mode-active .sidebar { 
    background-color: #202d3a; 
}
body.dark-mode-active .accordion-header { 
    background-color: #2c3e50; 
}
body.dark-mode-active .accordion-header:hover { 
    background-color: #34495e; 
}
body.dark-mode-active .perspectives-nav button { 
    background-color: #2c3e50; 
    color: var(--color-text-secondary);
}
body.dark-mode-active .perspectives-nav button.active { 
    background: var(--color-highlight); 
    color: var(--color-text-on-highlight);
    border-color: var(--color-highlight);
}
body.dark-mode-active table {
    color: var(--color-text-primary);
}
body.dark-mode-active .modality-card,
body.dark-mode-active .node-card,
body.dark-mode-active .node-details-placeholder,
body.dark-mode-active .tool-column-header {
    color: var(--color-text-primary);
}
body.dark-mode-active .modality-card.active {
    color: var(--color-text-on-highlight);
}
body.dark-mode-active input[type="search"], 
body.dark-mode-active select,
body.dark-mode-active textarea {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}
body.dark-mode-active .planner-sticky-header { 
    background-color: #1b2733; 
    border-bottom-color: var(--color-border); 
}
body.dark-mode-active #domain-switcher-container select { 
    background-color: #202d3a; 
    color: var(--color-text-light); 
}
body.dark-mode-active .planner-note { 
    background-color: #16202a; 
}
body.dark-mode-active #planner-minimap-container { 
    background-color: #1b2733; 
    border-color: var(--color-border); 
}
body.dark-mode-active #pathways-view .explorer-controls {
    background-color: var(--color-card);
    border-color: var(--color-border);
}
body.dark-mode-active #pathways-view .pathway-card {
    background-color: var(--color-background);
}
body.dark-mode-active #pathways-view .segmented-control {
    background-color: #16202a;
}
body.dark-mode-active .internal-link:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 25%, transparent);
}
body.dark-mode-active .theme-filter-btn {
    color: var(--color-text-secondary);
    background-color: transparent;
}
body.dark-mode-active .theme-filter-btn .theme-icon {
    color: var(--color-text-secondary) !important; 
}
body.dark-mode-active .theme-filter-btn:hover {
    background-color: #2c3e50;
}
body.dark-mode-active .theme-filter-btn.active {
    background-color: var(--color-highlight);
    border-color: var(--color-highlight);
}

/* --- GRAND SYNTHESIS TABLE FIXES --- */
#synthesis-table {
    width: 100%;
    table-layout: fixed; 
    border-collapse: collapse;
}

#synthesis-table th,
#synthesis-table td {
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    vertical-align: top;
    word-wrap: break-word; 
}

#synthesis-table th[data-col="tool"] { width: 12%; }
#synthesis-table th[data-col="genotype"] { width: 22%; }
#synthesis-table th[data-col="phenotypes"] { width: 22%; }
#synthesis-table th[data-col="dynamics"] { width: 14%; }
#synthesis-table th[data-col="explanation"] { width: 30%; }

body.dark-mode-active #synthesis-table th {
    background-color: #2c3e50;
}

/* --- DARK MODE SCROLLBAR STYLING --- */
body.dark-mode-active {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-background);
}

body.dark-mode-active ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.dark-mode-active ::-webkit-scrollbar-track {
  background: var(--color-background);
}

body.dark-mode-active ::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 10px;
  border: 2px solid var(--color-background);
}

body.dark-mode-active ::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-secondary);
}

body.dark-mode-active .sidebar {
    scrollbar-color: var(--color-border) var(--color-sidebar-bg);
}

body.dark-mode-active .sidebar::-webkit-scrollbar-track {
  background: var(--color-sidebar-bg);
}

body.dark-mode-active .sidebar::-webkit-scrollbar-thumb {
  border-color: var(--color-sidebar-bg);
}

/* --- DOMAIN CONCEPTS TAB --- */
.domain-concepts-container {
    margin-top: var(--space-5);
}

.domain-concepts-container > p {
    font-style: italic;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-5);
}

.variations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
}

.variation-card {
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-highlight); 
    border-radius: var(--radius-2);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    position: relative; 
}

.variation-card h5 {
    margin: 0 0 var(--space-2) 0;
    font-family: var(--font-secondary);
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid color-mix(in oklab, var(--color-border) 50%, transparent);
}

.variation-card p {
    margin: 0 0 var(--space-2) 0;
    font-size: 0.95em;
    color: var(--color-text-primary);
}

.variation-card p strong {
    color: var(--color-text-headings);
}

body.dark-mode-active .variation-card {
    background-color: var(--color-card); 
    border-color: var(--color-border);
}

body.dark-mode-active .variation-card h5 {
    color: var(--color-text-headings); 
    border-bottom-color: var(--color-border);
}

/* --- CONCEPT CLOUD TOGGLE AND HOVER --- */
.concept-cloud-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.concept-cloud-toggle-btn {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    background-color: var(--color-background);
    color: var(--color-text-secondary);
    border-radius: var(--radius-1);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.concept-cloud-toggle-btn:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 10%, transparent);
    color: var(--color-highlight);
}

.concept-cloud-toggle-btn.active {
    background-color: var(--color-highlight);
    color: var(--color-text-on-highlight);
    border-color: var(--color-highlight);
}

.concept-cloud-toggle-btn.active i {
    color: var(--color-text-on-highlight) !important; 
}

.concept-cloud-item {
    position: relative;
    display: inline-block;
    margin: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    font-size: 0.9em;
    cursor: help; 
    transition: all 0.2s ease;
    color: var(--color-text-primary);
}

.concept-cloud-item:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 10%, transparent);
    border-color: var(--color-highlight);
    box-shadow: var(--shadow-sm);
}

.concept-cloud-item.filtered-out {
    display: none; 
}

.concept-cloud-tooltip {
    visibility: hidden;
    width: 350px;
    background-color: var(--color-sidebar-bg);
    color: #fff;
    text-align: left;
    border-radius: var(--radius-2);
    padding: var(--space-3);
    position: absolute;
    z-index: 1000;
    bottom: 125%; 
    left: 50%;
    transform: translateX(-50%); 
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    pointer-events: none; 
}

.concept-cloud-tooltip::after {
    content: "";
    position: absolute;
    top: 100%; 
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--color-sidebar-bg) transparent transparent transparent;
}

.concept-cloud-item:hover .concept-cloud-tooltip,
.concept-cloud-item:focus .concept-cloud-tooltip {
    visibility: visible;
    opacity: 1;
}

body.dark-mode-active .concept-cloud-toggle-btn {
    background-color: var(--color-card);
    border-color: var(--color-border);
    color: var(--color-text-primary);
}
body.dark-mode-active .concept-cloud-toggle-btn:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 20%, transparent);
    color: var(--color-highlight);
}
body.dark-mode-active .concept-cloud-item {
    background-color: var(--color-card);
    border-color: var(--color-border);
    color: var(--color-text-primary);
}
body.dark-mode-active .concept-cloud-item:hover {
    background-color: color-mix(in oklab, var(--color-highlight) 20%, transparent);
    border-color: var(--color-highlight);
}

/* --- CONCEPT CLOUD & POPOVER STYLES --- */

.concept-cloud-wrapper {
    margin-top: var(--space-4);
    position: relative;
}

.concept-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.filter-chip {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    color: var(--color-text-secondary);
    font-family: var(--font-primary);
}

.filter-chip:hover {
    background: var(--color-card);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.filter-chip.active {
    background-color: var(--color-text-headings);
    color: var(--color-text-on-highlight);
    border-color: transparent;
    box-shadow: var(--shadow-sm);
}

.filter-chip[data-domain="Science"].active { background-color: var(--domain-science); }
.filter-chip[data-domain="Business"].active { background-color: var(--domain-business); }
.filter-chip[data-domain="Humanities"].active { background-color: var(--domain-humanities); }
.filter-chip[data-domain="Arts"].active { background-color: var(--domain-arts); }
.filter-chip[data-domain="Culture"].active { background-color: var(--domain-culture); }
.filter-chip[data-domain="Pedagogy"].active { background-color: var(--domain-pedagogy); }

.concept-bubbles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 60px;
}

.concept-bubble {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 0.9rem;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

.concept-bubble:hover {
    border-color: var(--color-highlight);
    color: var(--color-highlight);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.concept-bubble.hidden {
    display: none;
}

.concept-bubble.fade-in {
    animation: bubbleFadeIn 0.3s ease-in;
}

@keyframes bubbleFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.popover-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 2000; 
    opacity: 0;
    transition: opacity 0.2s ease;
}

.concept-popover {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -45%);
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    background-color: var(--color-card);
    border-radius: var(--radius-2);
    box-shadow: var(--shadow-lg);
    z-index: 2001; 
    overflow: hidden;
    opacity: 0;
    transition: all 0.2s ease;
    flex-direction: column;
}

.popover-overlay.visible, .concept-popover.visible {
    display: flex;
    opacity: 1;
}

.concept-popover.visible {
    transform: translate(-50%, -50%);
}

.popover-header {
    padding: var(--space-5);
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 6px solid var(--color-text-secondary); 
    flex-shrink: 0;
}

.popover-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--color-text-headings);
}

.popover-domain-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-left: 10px;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
}

.popover-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0 var(--space-2);
    line-height: 1;
}
.popover-close:hover { color: var(--color-warning); }

.popover-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex-grow: 1;
}

.data-section { margin-bottom: var(--space-5); }
.data-section:last-child { margin-bottom: 0; }

.data-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    font-weight: 700;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.data-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-primary);
}

.highlight-key { font-weight: 700; color: var(--color-text-headings); }

body.dark-mode-active .filter-chip {
    background-color: var(--color-card);
    color: var(--color-text-primary);
}
body.dark-mode-active .filter-chip:hover {
    background-color: var(--color-border);
}
body.dark-mode-active .popover-header {
    background-color: #1b2733; 
}
body.dark-mode-active .popover-domain-badge {
    background-color: rgba(255,255,255,0.1);
    color: var(--color-text-light);
}

.systems-lens-tab {
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-bottom: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius-1) var(--radius-1) 0 0;
    margin-bottom: -1px;
    background-color: transparent; 
}

.systems-lens-tab:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--color-text-headings);
}

body.dark-mode-active .systems-lens-tab:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--color-text-headings);
}

.neuro-sequence-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.step-link {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    padding: 2px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    color: var(--color-highlight);
    font-size: 0.85em;
    transition: all 0.2s;
}

.step-link:hover {
    background-color: var(--color-highlight);
    color: white;
}

.related-pathways-block {
    margin-top: 10px;
    font-size: 0.9em;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.related-pathways-block .label {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.pathway-tag {
    background-color: rgba(255,255,255,0.2);
    border: 1px solid rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text-primary);
    font-size: 0.85em;
}

.pathway-tag:hover {
    background-color: white;
    color: var(--color-highlight);
}

.related-pathways-container {
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
}

.related-pathways-details {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-1);
    overflow: hidden;
}

.related-pathways-summary {
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: var(--color-text-primary);
    list-style: none; 
    transition: background-color 0.2s ease;
}

.related-pathways-summary::-webkit-details-marker {
    display: none; 
}

.related-pathways-summary:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.related-pathways-summary .summary-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.related-pathways-details[open] .indicator-icon {
    transform: rotate(180deg);
}

.indicator-icon {
    transition: transform 0.2s ease;
    font-size: 0.8em;
    opacity: 0.7;
}

.related-pathways-list {
    padding: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background-color: rgba(255, 255, 255, 0.05);
}

.pathway-tag {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    padding: 4px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text-primary);
    font-size: 0.85em;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.pathway-tag:hover {
    border-color: var(--color-highlight);
    color: var(--color-highlight);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pathway-tag i {
    font-size: 0.8em;
    opacity: 0.7;
}

body.dark-mode-active .related-pathways-details {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: var(--color-border);
}
body.dark-mode-active .related-pathways-summary {
    color: var(--color-text-headings);
}
body.dark-mode-active .related-pathways-summary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}
body.dark-mode-active .pathway-tag {
    background-color: var(--color-background);
    color: var(--color-text-primary);
}
/* --- COLLAPSED SIDEBAR TOOLTIPS (UNIFIED) --- */

/* 1. Shared Tooltip Styles */
/* We define a variable for the left position to ensure alignment */
body.sidebar-collapsed {
    --tooltip-left: calc(var(--sidebar-width-collapsed) + 15px);
}

/* 2. Header Icon Tooltip */
body.sidebar-collapsed .sidebar-logo-icon {
    position: relative;
}
body.sidebar-collapsed .sidebar-logo-icon:hover::after {
    content: attr(title);
    position: absolute;
    left: 50px; /* Fixed offset relative to icon */
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    white-space: nowrap;
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.1);
    font-family: var(--font-primary);
    font-weight: 500;
}

/* 3. Stance Switch Tooltips */
/* Ensure the button is the positioning context */
body.sidebar-collapsed .stance-switch button {
    position: relative;
    overflow: visible;
}

/* Show the hidden text span as a tooltip on hover */
body.sidebar-collapsed .stance-switch button:hover .stance-text {
    display: block;
    position: absolute;
    left: var(--tooltip-left);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 3000;
    width: auto;
    height: auto;
    border: 1px solid rgba(255,255,255,0.1);
    text-align: left;
}

/* Add arrow to Stance Tooltip */
body.sidebar-collapsed .stance-switch button:hover .stance-text::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--color-sidebar-bg) transparent transparent;
}

/* 4. Section Header Tooltips */
body.sidebar-collapsed .nav-section-title {
    position: relative;
}
body.sidebar-collapsed .nav-section-title:hover::after {
    content: attr(title);
    position: absolute;
    left: var(--tooltip-left);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.1);
}
/* Arrow for Section Header */
body.sidebar-collapsed .nav-section-title:hover::before {
    content: "";
    position: absolute;
    left: calc(var(--tooltip-left) - 10px);
    top: 50%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--color-sidebar-bg) transparent transparent;
    z-index: 3000;
}

/* 5. Navigation Link Tooltips (Refined) */
/* Ensure the anchor is the positioning context */
body.sidebar-collapsed .sidebar nav a {
    position: relative;
    overflow: visible;
}

/* Show the hidden nav-text span as a tooltip */
body.sidebar-collapsed .sidebar nav a:hover .nav-text {
    display: block;
    position: absolute;
    left: var(--tooltip-left);
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-sidebar-bg);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 3000;
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Arrow for Nav Links */
body.sidebar-collapsed .sidebar nav a:hover .nav-text::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--color-sidebar-bg) transparent transparent;
}
/* --- HORIZONTAL SCROLL CONTROLS --- */

/* Wrapper to establish positioning context */
.scroll-wrapper-relative {
    position: relative;
    display: flex;
    flex-grow: 1;
    overflow: hidden; /* Hides the buttons if they stick out */
    border-radius: var(--radius-1);
    border: 1px solid var(--color-border);
}

/* The actual scrollable area */
.scroll-wrapper-relative .node-map-wrapper,
.scroll-wrapper-relative .map-grid-wrapper,
.scroll-wrapper-relative .pathway-matrix-wrapper { /* <--- ADDED THIS CLASS */
    overflow-x: auto;
    flex-grow: 1;
    scrollbar-width: none; /* Hide native scrollbar Firefox */
    -ms-overflow-style: none; /* Hide native scrollbar IE */
    scroll-behavior: smooth; /* Ensure smooth scrolling */
}

/* Hide native scrollbar Chrome/Safari */
.scroll-wrapper-relative .node-map-wrapper::-webkit-scrollbar,
.scroll-wrapper-relative .map-grid-wrapper::-webkit-scrollbar,
.scroll-wrapper-relative .pathway-matrix-wrapper::-webkit-scrollbar { /* <--- ADDED THIS CLASS */
    display: none;
}

/* The Scroll Paddles (Bars) */
.scroll-paddle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    background: rgba(0, 0, 0, 0.05); /* Subtle by default */
    border: none;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(2px);
}

.scroll-paddle:hover {
    background: rgba(0, 0, 0, 0.2); /* Darker on hover */
    color: var(--color-highlight);
    width: 50px; /* Slight expansion */
}

.scroll-paddle:active {
    background: var(--color-highlight);
    color: white;
}

.scroll-paddle.left {
    left: 0;
    border-right: 1px solid rgba(0,0,0,0.05);
}

.scroll-paddle.right {
    right: 0;
    border-left: 1px solid rgba(0,0,0,0.05);
}

/* Dark Mode Adjustments */
body.dark-mode-active .scroll-paddle {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
}
body.dark-mode-active .scroll-paddle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}
/* Add a stronger border or background when highlighted/locked */
.method-card.highlighted {
    border-color: var(--color-highlight);
    background-color: color-mix(in oklab, var(--color-highlight) 10%, var(--color-card));
    box-shadow: 0 0 0 2px var(--color-highlight); /* Outer ring for visibility */
    z-index: 2; /* Ensure it sits above lines if necessary */
}
/* --- NETWORK MAP INTERACTIVITY --- */

/* Interactive List Items in Tool Cards */
.tool-card ul li.network-node-link {
    cursor: pointer;
    padding: 2px 6px;
    margin: 0 -6px; /* Offset padding to align text */
    border-radius: 4px;
    transition: all 0.2s ease;
    display: block; /* Increase hit area */
}

.tool-card ul li.network-node-link:hover {
    background-color: var(--color-background);
    color: var(--color-highlight);
}

.uid-mono {
    font-family: monospace;
    opacity: 0.7;
    font-size: 0.9em;
    margin-right: 6px;
    display: inline-block;
    min-width: 24px;
}

/* Info Button for Method Cards */
.method-card {
    position: relative; /* Context for absolute button */
    padding-right: 32px; /* Make room for button */
}

.method-info-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.4;
    z-index: 5; /* Ensure it sits above card background */
}

.method-card:hover .method-info-btn {
    opacity: 1;
}

.method-info-btn:hover {
    background-color: rgba(0,0,0,0.1);
    color: var(--color-highlight);
    transform: scale(1.1);
}

body.dark-mode-active .method-info-btn:hover {
    background-color: rgba(255,255,255,0.1);
}
/* --- NETWORK MAP INTERACTIVITY --- */

/* Interactive List Items in Tool Cards */
.tool-card ul li.network-node-link {
    cursor: pointer;
    padding: 2px 6px;
    margin: 0 -6px; /* Offset padding to align text */
    border-radius: 4px;
    transition: all 0.2s ease;
    display: block; /* Increase hit area */
}

.tool-card ul li.network-node-link:hover {
    background-color: var(--color-background);
    color: var(--color-highlight);
}

.uid-mono {
    font-family: monospace;
    opacity: 0.7;
    font-size: 0.9em;
    margin-right: 6px;
    display: inline-block;
    min-width: 24px;
}

/* Info Button for Method Cards */
.method-card {
    position: relative; /* Context for absolute button */
    padding-right: 32px; /* Make room for button */
}

.method-info-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.4;
    z-index: 5; /* Ensure it sits above card background */
}

.method-card:hover .method-info-btn {
    opacity: 1;
}

.method-info-btn:hover {
    background-color: rgba(0,0,0,0.1);
    color: var(--color-highlight);
    transform: scale(1.1);
}

body.dark-mode-active .method-info-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Add a stronger border or background when highlighted/locked */
.method-card.highlighted {
    border-color: var(--color-highlight);
    background-color: color-mix(in oklab, var(--color-highlight) 10%, var(--color-card));
    box-shadow: 0 0 0 2px var(--color-highlight); /* Outer ring for visibility */
    z-index: 2; /* Ensure it sits above lines if necessary */
}
/* --- COGNITIVE EQUALIZER (V8) --- */

.equalizer-wrapper {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    padding: var(--space-5);
    margin-top: var(--space-4);
}

.equalizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 15px;
    flex-wrap: wrap;
    gap: 12px;
}

.domain-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.domain-pill {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-primary);
}

.domain-pill:hover { 
    background: color-mix(in oklab, var(--color-highlight) 10%, transparent);
    color: var(--color-highlight);
    border-color: var(--color-highlight);
}

.domain-pill.active {
    background: var(--color-text-headings);
    color: var(--color-card);
    border-color: var(--color-text-headings);
}

/* Chart Stage */
.chart-stage {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 250px; 
    padding-bottom: 20px;
    position: relative;
    border-bottom: 1px solid var(--color-border);
    margin-top: 10px;
    gap: 30px;
}

.modality-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    position: relative;
    height: 100%;
    padding: 0 4px;
}

.group-label {
    position: absolute;
    bottom: -25px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-secondary);
    border-top: 2px solid var(--color-border);
    padding-top: 4px;
}

.bar-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: 32px; 
    height: 100%;
    position: relative;
    cursor: pointer;
    z-index: 1;
}

.bar {
    width: 100%;
    background: var(--color-border); /* Inactive state */
    border-radius: 3px 3px 0 0;
    transition: height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    height: 0%;
    position: relative;
}

.bar-container:hover .bar {
    filter: brightness(1.1) saturate(1.2);
}

/* Tooltip */
.bar-tooltip {
    position: absolute;
    bottom: 100%; 
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background-color: var(--color-text-headings);
    color: var(--color-card);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    z-index: 100;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

.bar-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--color-text-headings) transparent transparent transparent;
}

.bar-container:hover .bar-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-10px);
}

/* Legend */
.legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    justify-content: center;
}

.legend-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-group h6 {
    margin: 0 0 4px 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    letter-spacing: 0.5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--color-text-primary);
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.insight-footer {
    margin-top: 20px;
    padding: 16px;
    background: var(--color-background);
    border-radius: 6px;
    border-left: 4px solid var(--color-highlight);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.insight-footer i { font-size: 1.1rem; color: var(--color-highlight); margin-top: 3px; }
.insight-text h5 { margin: 0 0 4px 0; font-size: 0.95rem; color: var(--color-text-headings); }
.insight-text p { margin: 0; font-size: 0.9rem; color: var(--color-text-secondary); line-height: 1.5; }

/* Add to css/style.css */

/* Network Reasoning Tags in Modal */
.connection-tag {
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.tag-primary {
    background-color: var(--color-highlight);
    color: white;
    border: 1px solid var(--color-highlight);
}

.tag-secondary {
    background-color: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-text-secondary);
}


.tag-tertiary {
    background-color: transparent;
    color: #95a5a6;
    border: 1px dotted #95a5a6;
}

.reasoning-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
/* --- MODALITY EXPLORER THEME COLORS --- */

/* Default (Light Mode) Variables */
:root {
    --modality-sensory-bg: rgba(33, 150, 243, 0.05);
    --modality-sensory-border: rgba(33, 150, 243, 0.2);
    --modality-sensory-text: #1976d2;

    --modality-embodied-bg: rgba(76, 175, 80, 0.05);
    --modality-embodied-border: rgba(76, 175, 80, 0.2);
    --modality-embodied-text: #2e7d32;

    --modality-symbolic-bg: rgba(255, 152, 0, 0.05);
    --modality-symbolic-border: rgba(255, 152, 0, 0.2);
    --modality-symbolic-text: #f57c00;

    --modality-cognitive-bg: rgba(231, 76, 60, 0.05);
    --modality-cognitive-border: rgba(231, 76, 60, 0.2);
    --modality-cognitive-text: #c0392b;

    --modality-meta-bg: rgba(155, 89, 182, 0.05);
    --modality-meta-border: rgba(155, 89, 182, 0.2);
    --modality-meta-text: #8e44ad;
}

/* Dark Mode Overrides */
body.dark-mode-active {
    --modality-sensory-bg: rgba(33, 150, 243, 0.15);
    --modality-sensory-border: rgba(33, 150, 243, 0.4);
    --modality-sensory-text: #64b5f6;

    --modality-embodied-bg: rgba(76, 175, 80, 0.15);
    --modality-embodied-border: rgba(76, 175, 80, 0.4);
    --modality-embodied-text: #81c784;

    --modality-symbolic-bg: rgba(255, 152, 0, 0.15);
    --modality-symbolic-border: rgba(255, 152, 0, 0.4);
    --modality-symbolic-text: #ffb74d;

    --modality-cognitive-bg: rgba(231, 76, 60, 0.15);
    --modality-cognitive-border: rgba(231, 76, 60, 0.4);
    --modality-cognitive-text: #e57373;

    --modality-meta-bg: rgba(155, 89, 182, 0.15);
    --modality-meta-border: rgba(155, 89, 182, 0.4);
    --modality-meta-text: #ba68c8;
}

/* Modality Group Card Classes */
.modality-group-card {
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s ease;
    border: 1px solid transparent;
    border-left-width: 4px;
}

.modality-group-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid;
}

/* Specific Group Styles */
.group-Sensory {
    background-color: var(--modality-sensory-bg);
    border-color: var(--modality-sensory-border);
    border-left-color: var(--modality-sensory-text);
}
.group-Sensory h3 { color: var(--modality-sensory-text); border-bottom-color: var(--modality-sensory-border); }
.group-Sensory .modality-card { border-color: var(--modality-sensory-border); }
.group-Sensory .modality-icon { color: var(--modality-sensory-text); }

.group-Embodied {
    background-color: var(--modality-embodied-bg);
    border-color: var(--modality-embodied-border);
    border-left-color: var(--modality-embodied-text);
}
.group-Embodied h3 { color: var(--modality-embodied-text); border-bottom-color: var(--modality-embodied-border); }
.group-Embodied .modality-card { border-color: var(--modality-embodied-border); }
.group-Embodied .modality-icon { color: var(--modality-embodied-text); }

.group-Symbolic {
    background-color: var(--modality-symbolic-bg);
    border-color: var(--modality-symbolic-border);
    border-left-color: var(--modality-symbolic-text);
}
.group-Symbolic h3 { color: var(--modality-symbolic-text); border-bottom-color: var(--modality-symbolic-border); }
.group-Symbolic .modality-card { border-color: var(--modality-symbolic-border); }
.group-Symbolic .modality-icon { color: var(--modality-symbolic-text); }

.group-Cognitive {
    background-color: var(--modality-cognitive-bg);
    border-color: var(--modality-cognitive-border);
    border-left-color: var(--modality-cognitive-text);
}
.group-Cognitive h3 { color: var(--modality-cognitive-text); border-bottom-color: var(--modality-cognitive-border); }
.group-Cognitive .modality-card { border-color: var(--modality-cognitive-border); }
.group-Cognitive .modality-icon { color: var(--modality-cognitive-text); }

.group-Meta {
    background-color: var(--modality-meta-bg);
    border-color: var(--modality-meta-border);
    border-left-color: var(--modality-meta-text);
}
.group-Meta h3 { color: var(--modality-meta-text); border-bottom-color: var(--modality-meta-border); }
.group-Meta .modality-card { border-color: var(--modality-meta-border); }
.group-Meta .modality-icon { color: var(--modality-meta-text); }
/* --- COMPARATIVE ANALYSIS STYLES --- */

.comparative-analysis-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.perspective-summary {
    font-size: 1.05em;
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    font-style: italic;
    border-left: 4px solid var(--color-highlight);
    padding-left: var(--space-4);
}

.selection-logic-note {
    background-color: rgba(0, 0, 0, 0.03);
    padding: var(--space-3);
    border-radius: var(--radius-1);
    font-size: 0.9em;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
}

/* Generic Tag/Badge for Accordion Headers */
.accordion-header .tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    margin-left: 10px;
    vertical-align: middle;
}

/* Dark Mode Overrides for New Elements */
body.dark-mode-active .selection-logic-note {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
}

body.dark-mode-active .accordion-header .tag {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-light);
    border-color: transparent;
}
/* --- COMPARATIVE ANALYSIS STYLES --- */

.comparative-analysis-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.perspective-summary {
    font-size: 1.05em;
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    font-style: italic;
    border-left: 4px solid var(--color-highlight);
    padding-left: var(--space-4);
}

.selection-logic-note {
    background-color: rgba(0, 0, 0, 0.03);
    padding: var(--space-4);
    border-radius: var(--radius-2);
    font-size: 0.95em;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-5);
    line-height: 1.5;
}

.selection-logic-note strong {
    color: var(--color-text-headings);
    display: block;
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

/* Comparison Accordion Styling */
.comparison-model-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.comparison-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.comparison-content-grid {
    display: grid;
    gap: var(--space-4);
}

.comparison-field {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: var(--space-3);
}

.comparison-field:last-child {
    border-bottom: none;
}

.comparison-label {
    font-size: 0.85em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    font-weight: 700;
    margin-bottom: var(--space-1);
    display: block;
}

.comparison-value {
    color: var(--color-text-primary);
    line-height: 1.6;
}

/* Dark Mode Overrides */
body.dark-mode-active .selection-logic-note {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

body.dark-mode-active .selection-logic-note strong {
    color: var(--color-text-headings);
}

body.dark-mode-active .comparison-tag {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-light);
    border-color: transparent;
}

body.dark-mode-active .comparison-field {
    border-bottom-color: rgba(255,255,255,0.05);
}
/* --- INTERACTIVE OVERVIEW V2 STYLES --- */

.overview-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-5);
    margin-bottom: var(--space-5);
    background-color: var(--color-card);
    padding: var(--space-4);
    border-radius: var(--radius-2);
    border: 1px solid var(--color-border);
}

.line-key {
    font-size: 0.85em;
    border-left: 1px solid var(--color-border);
    padding-left: var(--space-5);
}

.line-key h4 {
    margin: 0 0 var(--space-2) 0;
    font-size: 0.9em;
}

.line-key ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.line-key li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.line-key svg {
    flex-shrink: 0;
}

.line-key svg line, .line-key svg path {
    stroke: var(--color-text-secondary);
    stroke-width: 3;
    fill: none;
}

.line-key .type-iterative { stroke-dasharray: 4, 2; }
.line-key .type-exploratory { stroke-dasharray: 1, 3; stroke-linecap: round; }
.line-key .type-feedback_loop { stroke-dasharray: 5, 3; }

/* Corrected Layout for SVG Overlay */
.workflow-container-wrapper {
    overflow-x: auto;
    /* Ensure the wrapper takes up space but handles overflow */
    width: 100%; 
    position: relative;
}

.workflow-container {
    position: relative;
    display: flex;
    gap: 20px;
    padding: 20px;
    /* CRITICAL FIX: Ensure container is wide enough for all cards */
    min-width: max-content; 
    /* Ensure height accommodates cards + potential SVG arcs */
    min-height: 450px; 
    align-items: flex-start; /* Align cards to top */
}

#overview-path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
    z-index: 2;
    /* Ensure SVG doesn't block clicks on cards unless on a line */
    pointer-events: none; 
}

/* Re-enable pointer events for paths so tooltips work */
#overview-path-svg path, 
#overview-path-svg line {
    pointer-events: stroke;
}

.workflow-stage {
    position: relative;
    z-index: 1;
    /* Ensure cards have a fixed width so they don't squish */
    flex: 0 0 300px; 
    /* Ensure text wraps correctly inside the card */
    white-space: normal; 
}

/* SVG Line Styles */
.path-segment {
    cursor: help;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.path-segment:hover {
    opacity: 1;
    filter: drop-shadow(0 0 3px var(--color-highlight));
    stroke-width: 10 !important; /* Make hover effect more obvious */
}

.weight-primary { stroke-width: 8; }
.weight-secondary { stroke-width: 4; }
.weight-tertiary { stroke-width: 2; }

.type-iterative { stroke-dasharray: 8, 4; }
.type-exploratory { stroke-dasharray: 2, 5; stroke-linecap: round; }
.type-feedback_loop { stroke-dasharray: 10, 5; }

/* Tooltip */
.path-tooltip {
    position: fixed;
    background-color: var(--color-text-headings);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    max-width: 250px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 9999;
    box-shadow: var(--shadow-md);
}
/* --- GOVERNANCE ENGINE STYLES --- */
.governance-container { padding: 0; height: 100%; display: flex; flex-direction: column; }
.gov-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; background: var(--color-card); border-bottom: 1px solid var(--color-border); }
.gov-controls { display: flex; gap: 15px; align-items: center; }

.workflow-map { 
    display: flex; align-items: center; gap: 15px; overflow-x: auto; 
    padding: 30px; background: var(--color-background); border-bottom: 1px solid var(--color-border);
    min-height: 160px;
}

.tool-node {
    min-width: 140px; height: 90px; background: var(--color-card); border: 1px solid var(--color-border);
    border-radius: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center; padding: 10px; opacity: 0.8; transition: all 0.2s;
}
.tool-node:hover { opacity: 1; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tool-id { font-size: 0.7rem; font-weight: bold; color: var(--color-text-secondary); margin-bottom: 5px; }
.tool-name { font-weight: 700; font-size: 0.9rem; }

.gate-node {
    min-width: 40px; height: 40px; background: var(--color-card); border: 2px solid var(--color-text-secondary);
    transform: rotate(45deg); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; z-index: 10;
}
.gate-node i { transform: rotate(-45deg); font-size: 0.9rem; color: var(--color-text-secondary); }
.gate-node:hover { transform: rotate(45deg) scale(1.1); border-color: var(--color-highlight); }
.gate-node:hover i { color: var(--color-highlight); }
.gate-node.selected { background: var(--color-text-headings); border-color: var(--color-text-headings); }
.gate-node.selected i { color: white; }

.gov-dashboard { display: grid; grid-template-columns: 1fr; height: 100%; overflow: hidden; }
.icd-panel { padding: 30px; overflow-y: auto; background: var(--color-card); }

.icd-header { margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px solid var(--color-border); }
.icd-title { font-size: 1.4rem; font-weight: 800; color: var(--color-text-headings); margin: 0; }
.icd-subtitle { font-family: monospace; color: var(--color-text-secondary); font-size: 0.9rem; }

.persona-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.p-btn { 
    flex: 1; padding: 15px; border: 2px solid var(--color-border); background: var(--color-background);
    border-radius: 6px; cursor: pointer; text-align: left; transition: all 0.2s;
}
.p-btn.active { border-color: var(--color-highlight); background: var(--color-card); box-shadow: var(--shadow-sm); }

.data-block { margin-bottom: 25px; }
.data-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--color-text-secondary); font-weight: 700; margin-bottom: 8px; display: block; }
.payload-box { background: var(--color-background); border: 1px solid var(--color-border); border-radius: 6px; padding: 15px; font-family: monospace; font-size: 0.9rem; }
.criteria-list { list-style: none; padding: 0; margin: 0; }
.criteria-list li { padding: 10px; border-bottom: 1px solid var(--color-border); display: flex; gap: 10px; align-items: flex-start; }
.criteria-list li::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: var(--color-success); }

/* Architecture Modal */
.hierarchy-grid { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 20px; margin-top: 20px; }
.chain-col { display: flex; flex-direction: column; gap: 15px; }
.chain-header { text-align: center; padding: 8px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px; border: 1px solid; }
.prog-header { background: #e8f6f3; color: #16a085; border-color: #16a085; }
.tech-header { background: #fdedec; color: #c0392b; border-color: #c0392b; }
.role-card { background: white; padding: 12px; border: 1px solid var(--color-border); border-radius: 6px; border-left: 4px solid; }
.role-title { display: block; font-weight: 700; font-size: 0.9rem; color: #333; }
.tension-zone { display: flex; flex-direction: column; justify-content: space-around; align-items: center; height: 100%; padding: 40px 0; }
.tension-line { width: 100%; height: 2px; background: #eee; }
.btn-close { padding: 8px 16px; background: #eee; border: none; border-radius: 4px; cursor: pointer; }

/* Theme Colors */
.theme-science { --color-highlight: #0b3d91; }
.theme-business { --color-highlight: #00a651; }
.theme-humanities { --color-highlight: #8e44ad; }
.theme-arts { --color-highlight: #e67e22; }
.theme-culture { --color-highlight: #c0392b; }
.theme-pedagogy { --color-highlight: #16a085; }
/* --- GOVERNANCE ENGINE DARK MODE OVERRIDES --- */
body.dark-mode-active .gov-header { 
    background: var(--color-card); 
    border-bottom-color: var(--color-border); 
}

body.dark-mode-active .workflow-map { 
    background: var(--color-background); 
    border-bottom-color: var(--color-border); 
}

body.dark-mode-active .tool-node { 
    background: var(--color-card); 
    border-color: var(--color-border); 
    color: var(--color-text-primary);
}

body.dark-mode-active .gate-node { 
    background: var(--color-card); 
    border-color: var(--color-text-secondary); 
}

body.dark-mode-active .gate-node i { 
    color: var(--color-text-secondary); 
}

body.dark-mode-active .gate-node:hover {
    border-color: var(--color-highlight);
}

body.dark-mode-active .gate-node.selected {
    background: var(--color-highlight);
    border-color: var(--color-highlight);
}

body.dark-mode-active .gate-node.selected i {
    color: white;
}

body.dark-mode-active .icd-panel { 
    background: var(--color-card); 
    color: var(--color-text-primary);
}

body.dark-mode-active .icd-header { 
    border-bottom-color: var(--color-border); 
}

body.dark-mode-active .payload-box { 
    background: var(--color-background); 
    border-color: var(--color-border); 
    color: var(--color-text-primary);
}

body.dark-mode-active .p-btn { 
    background: var(--color-background); 
    border-color: var(--color-border); 
    color: var(--color-text-primary); 
}

body.dark-mode-active .p-btn.active { 
    background: var(--color-card); 
    border-color: var(--color-highlight); 
    color: var(--color-text-headings);
}

body.dark-mode-active .p-btn strong {
    color: var(--color-text-headings);
}

body.dark-mode-active .checklist-item {
    background: var(--color-background);
    border-bottom-color: var(--color-border);
}

body.dark-mode-active .role-card { 
    background: var(--color-background); 
    border-color: var(--color-border); 
}

body.dark-mode-active .role-title { 
    color: var(--color-text-headings); 
}

body.dark-mode-active .role-desc { 
    color: var(--color-text-secondary); 
}

body.dark-mode-active .btn-close { 
    background: var(--color-border); 
    color: var(--color-text-primary); 
}

body.dark-mode-active .info-box {
    background: var(--color-background);
    color: var(--color-text-primary);
}
/* --- GOVERNANCE ENGINE MOBILE RESPONSIVENESS PATCH --- */

@media (max-width: 800px) {
    /* 1. Main Dashboard Stack (Side-by-Side to Top-and-Bottom) */
    .dashboard {
        grid-template-columns: 1fr;
    }

    /* Remove border that separates ICD panel from Auth panel */
    .icd-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    /* 2. Workflow Map Simplification */
    .workflow-map {
        /* Allow tools to wrap vertically instead of forcing horizontal overflow */
        flex-wrap: wrap;
        justify-content: flex-start;
        padding-bottom: 10px;
        min-height: auto; /* Remove fixed height constraint */
    }

    .tool-node {
        /* Allow cards to shrink slightly but maintain min width */
        min-width: 100px;
        flex-basis: 150px;
        height: 150px;
        margin-bottom: 0;
    }

    .gate-node {
        /* Adjust positioning to stack vertically */
        min-width: 30px;
        height: 30px;
        margin: 0 5px;
    }

    /* 3. Governance Hierarchy Stack */
    .hierarchy-grid {
        /* Change from 3-column (Left | Tension | Right) to 1-column (Stacking) */
        grid-template-columns: 1fr;
        gap: 10px;
        max-width: 100%;
    }

    .tension-zone {
        /* Hide the vertical tension line/labels as they clutter the mobile view */
        display: none;
    }

    /* Ensure role cards take up full width when stacked */
    .chain-col {
        width: 100%;
        gap: 8px;
    }

    /* Remove the double header on mobile (e.g., Program Authority & Technical Authority) */
    .chain-col:first-child .chain-header {
        margin-bottom: 0;
    }
    .chain-col:last-child .chain-header {
        margin-top: 15px;
        margin-bottom: 0;
    }
    
    /* Center text in headers */
    .gov-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}
/* --- END GOVERNANCE ENGINE MOBILE RESPONSIVENESS PATCH --- */
/* --- WELCOME PAGE MOBILE FIX (v4.5) --- */
@media (max-width: 768px) {
    /* 1. Fix the main welcome hub container */
    .welcome-hub-container {
        /* Switch from a 2-column grid to a single column stack */
        grid-template-columns: 1fr;
        gap: 20px; /* Reduce gap for mobile */
        margin-top: 20px;
    }

    /* 2. Ensure the cards themselves fill the width */
    .welcome-choice-card {
        width: 100%;
        max-width: 100%; /* Override the desktop max-width constraint */
        min-height: 300px; /* Ensure a minimum height for readability */
        padding: 25px;
    }

    /* 3. Adjust header font size for better fit */
    .welcome-choice-card h2 {
        font-size: 1.5rem;
    }
}
/* --- END WELCOME PAGE MOBILE FIX --- */

/* --- COGNITIVE EQUALIZER MOBILE FIX (v4.7 - Final) --- */
@media (max-width: 768px) {
    /* 1. Main Chart Stage Scaling (Reduced further) */
    .chart-stage {
        height: 180px; /* Reduced overall height */
        gap: 10px; /* Reduced gap between modality groups */
        padding-bottom: 10px;
    }

    /* 2. Modality Group Scaling */
    .modality-group {
        gap: 3px; /* Reduced gap between individual bars */
    }

    /* 3. Bar Container Scaling */
    .bar-container {
        width: 18px; /* Reduced fixed width of bars */
    }

    /* 4. Label Scaling */
    .group-label {
        font-size: 0.5rem; /* Shrink group labels further */
        bottom: -15px;
    }

    /* 5. Legend Container: Force Vertical Stacking */
    .legend-container {
        flex-direction: column; /* Stack groups vertically */
        align-items: flex-start; /* Align groups to the left */
        gap: 15px; /* Space between stacked groups */
        padding-top: 15px;
    }

    /* 6. Legend Group: Force Vertical Stacking of Items */
    .legend-group {
        flex-direction: column; /* Stack items vertically */
        align-items: flex-start;
        gap: 4px;
        width: 100%;
    }
    
    .legend-group h6 {
        font-size: 0.6rem; /* Shrink group header */
        width: 100%;
        margin-bottom: 5px;
    }

    .legend-item {
        font-size: 0.7rem; /* Shrink legend text */
    }
    
    /* 7. Domain Pills Scaling */
    .domain-pill {
        font-size: 0.65rem;
        padding: 3px 6px;
    }
}
/* --- END COGNITIVE EQUALIZER MOBILE FIX --- */
@media (max-width: 768px) {
    /* 1. Main Chart Stage Scaling */
    .chart-stage {
        height: 200px; /* Reduce overall height */
        gap: 15px; /* Reduce gap between modality groups */
        padding-bottom: 15px;
    }

    /* 2. Modality Group Scaling */
    .modality-group {
        gap: 4px; /* Reduce gap between individual bars */
    }

    /* 3. Bar Container Scaling */
    .bar-container {
        width: 20px; /* Reduce fixed width of bars */
    }

    /* 4. Label Scaling */
    .group-label {
        font-size: 0.55rem; /* Shrink group labels */
        bottom: -20px;
    }

    /* 5. Legend Scaling */
    .legend-container {
        gap: 10px; /* Reduce gap between legend groups */
        padding-top: 10px;
    }

    .legend-group {
        flex-direction: row; /* Change legend to row layout to save vertical space */
        flex-wrap: wrap;
        gap: 10px;
    }

    .legend-group h6 {
        width: 100%; /* Ensure header takes full width */
        margin-bottom: 0;
    }

    .legend-item {
        font-size: 0.7rem; /* Shrink legend text */
    }
    
    /* 6. Domain Pills Scaling */
    .domain-pill {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}
/* --- END COGNITIVE EQUALIZER MOBILE FIX --- */
/* --- NASA REGISTRY THEME (Light/Dark Mode) --- */
:root {
    --nasa-border: #0b3d91;
    --nasa-bg: #f0f4fa;
    --nasa-text: #0b3d91;
    --nasa-icon: #0b3d91;
    --nasa-code-bg: #0b3d91;
    --nasa-code-text: #ffffff;
    --nasa-quote-bg: #ffffff;
    --nasa-quote-text: #1a1a1a;
    --nasa-quote-border: rgba(11,61,145,0.2);
}

body.dark-mode-active {
    --nasa-border: #4fc3f7;       /* Light Blue */
    --nasa-bg: #1c2833;           /* Dark Blue-Grey */
    --nasa-text: #e1f5fe;         /* Off-white Blue */
    --nasa-icon: #4fc3f7;         /* Light Blue */
    --nasa-code-bg: #0277bd;      /* Medium Blue */
    --nasa-code-text: #ffffff;
    --nasa-quote-bg: #2c3e50;     /* Dark Card */
    --nasa-quote-text: #ecf0f1;
    --nasa-quote-border: rgba(79, 195, 247, 0.3);
}

.nasa-registry-view {
    border: 2px solid var(--nasa-border);
    background: var(--nasa-bg);
    color: var(--nasa-text);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.nasa-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--nasa-quote-border);
    padding-bottom: 10px;
}

.nasa-header i {
    font-size: 28px;
    color: var(--nasa-icon);
}

.nasa-header h4 {
    margin: 0;
    color: var(--nasa-text);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
}

.nasa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    font-size: 0.95em;
}

.nasa-code-tag {
    background: var(--nasa-code-bg);
    color: var(--nasa-code-text);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

.nasa-quote-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--nasa-quote-bg);
    border-radius: 6px;
    border-left: 4px solid var(--nasa-border);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.nasa-quote-label {
    margin: 0;
    font-size: 0.85em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.nasa-quote-text {
    margin: 0;
    color: var(--nasa-quote-text);
    line-height: 1.4;
    font-style: italic;
}

.nasa-glossary-link {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--nasa-border);
    cursor: help;
    color: inherit;
    font-weight: bold;
}

.nasa-glossary-link:hover {
    color: var(--color-highlight);
    text-decoration-style: solid;
}
/* --- NASA TOOLTIP STYLES --- */
.nasa-term {
    position: relative;
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--nasa-border);
    font-weight: bold;
    color: inherit;
}

.nasa-term:hover {
    color: var(--color-highlight);
    text-decoration-style: solid;
}

.nasa-term .tooltip-text {
    visibility: hidden;
    width: 280px;
    background-color: #2c3e50; /* Default Dark Background */
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 135%; /* Position above */
    left: 50%;
    margin-left: -140px; /* Center it */
    opacity: 0;
    transition: opacity 0.3s;
    font-weight: normal;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    pointer-events: none;
    white-space: normal; /* Ensure text wraps */
}

/* Tooltip Arrow */
.nasa-term .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

.nasa-term:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Dark Mode Adjustment for Tooltip */
body.dark-mode-active .nasa-term .tooltip-text {
    background-color: #f0f4fa;
    color: #0b3d91;
    border: 1px solid #0b3d91;
}
body.dark-mode-active .nasa-term .tooltip-text::after {
    border-color: #f0f4fa transparent transparent transparent;
}


/* --- FIX V6: OFFSET HUD (Avoids Sidebar) --- */
.tooltip, 
.citation-tooltip, 
.ref-tooltip,
[data-tooltip]::after {
    /* Break out of flow */
    position: fixed !important; 
    
    /* Position: Bottom, but shifted RIGHT to avoid sidebar */
    bottom: 20px !important;
    
    /* Center relative to the CONTENT area (assuming ~260px sidebar) */
    left: calc(50% + 130px) !important; 
    transform: translateX(-50%) !important;
    
    /* Reset others */
    top: auto !important;
    right: auto !important;
    margin: 0 !important;
    
    /* Sizing */
    width: auto !important;
    min-width: 300px !important;
    max-width: 600px !important; /* Slightly narrower for readability */
    max-height: 35vh !important;
    
    /* Visuals */
    background-color: #1a202c !important;
    color: #f7fafc !important;
    border: 2px solid #4fd1c5 !important;
    border-radius: 8px !important;
    padding: 15px 20px !important;
    box-shadow: 0 0 50px rgba(0,0,0,0.9) !important;
    z-index: 2147483647 !important;
    
    /* Text */
    white-space: normal !important;
    text-align: left !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    overflow-y: auto !important;
    pointer-events: none !important;
}

/* Hide arrow */
[data-tooltip]::before { display: none !important; }


/* --- FIX V7: RESPONSIVE GRAND SYNTHESIS TABLE --- */
@media screen and (max-width: 850px) {
    /* 1. Force table elements to stack vertically */
    #synthesis-table, 
    #synthesis-table thead, 
    #synthesis-table tbody, 
    #synthesis-table th, 
    #synthesis-table td, 
    #synthesis-table tr { 
        display: block !important; 
    }

    /* 2. Hide the original header row */
    #synthesis-table thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* 3. Style each row as a distinct card */
    #synthesis-table tr {
        margin-bottom: 2rem !important;
        border: 2px solid var(--color-border) !important;
        border-radius: 12px !important;
        background: var(--color-card) !important;
        padding: 10px !important;
        box-shadow: var(--shadow-md) !important;
    }

    /* 4. Style each cell to show its label on top */
    #synthesis-table td {
        border: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
        position: relative !important;
        padding: 40px 15px 15px 15px !important; /* Space at top for label */
        text-align: left !important;
        width: 100% !important;
    }

    #synthesis-table td:last-child {
        border-bottom: none !important;
    }

    /* 5. Inject the Column Name using the data-col-name attribute */
    #synthesis-table td:before {
        content: attr(data-col-name);
        position: absolute;
        top: 12px;
        left: 15px;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        font-weight: 800;
        color: var(--color-highlight);
        opacity: 0.8;
    }
    
    /* Special handling for the 'Tool' column to make it stand out */
    #synthesis-table td[data-col="tool"] {
        background: rgba(79, 209, 197, 0.1);
        border-radius: 8px 8px 0 0;
        font-size: 1.2rem;
        font-weight: bold;
    }
}


/* --- FIX V13: TOTAL MOBILE TOGGLE PURGE --- */
@media screen and (max-width: 768px) {
    /* 1. Hide EVERY toggle, switch, and mode selector in the entire sidebar */
    .sidebar .stance-switch,
    .sidebar .sidebar-toggle-group,
    .sidebar .persona-switch,
    .sidebar .toggle-container,
    .sidebar .mode-switch-wrapper,
    .sidebar [class*="toggle"],
    .sidebar [class*="switch"],
    .sidebar [class*="mode"],
    .sidebar label,
    .sidebar input[type="checkbox"],
    .sidebar-footer {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        pointer-events: none !important;
    }

    /* 2. Re-stabilize the Sidebar Header */
    .sidebar-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 40px 20px 20px 20px !important;
        text-align: center !important;
        min-height: 120px !important;
        position: relative !important;
    }

    /* 3. Isolate the Menu Button (Hamburger) in the Top Right */
    /* We target the specific ID and common classes to be certain */
    #sidebarCollapse,
    .sidebar-toggle,
    .menu-toggle {
        position: fixed !important; /* Fixed to viewport to stay on top */
        top: 15px !important;
        right: 15px !important;
        left: auto !important;
        display: flex !important;
        z-index: 2147483647 !important;
        background: var(--color-text-headings) !important;
        color: white !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
    }

    /* 4. Ensure the Title is clean and centered */
    .sidebar-header h1, 
    .brand-title,
    .sidebar-header h2 {
        font-size: 1.6rem !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.2 !important;
        color: white !important;
    }

    .sidebar-header p, 
    .brand-subtitle {
        margin-top: 10px !important;
        font-size: 0.9rem !important;
        opacity: 0.8 !important;
        color: #b7c3cd !important;
    }
}
/* --- GUIDED TOUR TOGGLE --- */
.sidebar-footer .sidebar-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    font-size: 0.85rem;
    color: #b7c3cd;
    border-top: 1px solid rgba(255,255,255,0.05);
}


/* --- FIX V14: FORCE MODALITY BARS TO FIT MOBILE --- */
@media screen and (max-width: 768px) {
    /* 1. Ensure the outer wrapper doesn't overflow */
    .equalizer-wrapper {
        padding: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* 2. Shrink the chart stage and adjust spacing */
    .chart-stage {
        width: 100% !important;
        height: 160px !important;
        gap: 4px !important; /* Tighten gap between groups */
        justify-content: space-between !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    /* 3. Shrink the modality groups */
    .modality-group {
        gap: 2px !important; /* Tighten gap between bars */
        flex: 1 !important;
        justify-content: center !important;
    }

    /* 4. Shrink individual bars to fit 15 across a small screen */
    .bar-container {
        width: 10px !important; /* Significant reduction in width */
        min-width: 8px !important;
    }

    /* 5. Adjust group labels to prevent overlap */
    .group-label {
        font-size: 0.5rem !important;
        bottom: -18px !important;
        letter-spacing: 0 !important;
    }

    /* 6. Ensure the legend doesn't push the width out */
    .legend-container {
        width: 100% !important;
        display: block !important;
    }
    
    .legend-group {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Two columns for legend items */
        gap: 5px !important;
        margin-bottom: 10px !important;
    }
}


/* --- FIX V15: MOBILE UX OPTIMIZATION --- */
@media screen and (max-width: 768px) {
    /* 1. Reduce wasted side-space */
    .main-content {
        padding: 15px 12px !important;
    }

    /* 2. Hide the Mini-map to clear the HUD area */
    

    /* 3. Increase Touch Targets (Fingers are bigger than cursors) */
    .sidebar nav a, 
    .accordion-header, 
    .welcome-choice-button {
        min-height: 48px !important; /* Apple/Google standard for touch */
    }

    /* 4. Fix Concept Cloud Bubbles (Prevent them from being tiny) */
    .concept-bubble {
        padding: 10px 16px !important;
        font-size: 1rem !important;
        margin: 4px !important;
    }

    /* 5. Ensure HUD Tooltip doesn't block the very bottom of the screen */
    .tooltip, .citation-tooltip, .ref-tooltip {
        bottom: 10px !important;
        width: 95vw !important;
    }
}


/* --- FIX V16: RESTORE MINI-MAP & ADJUST HUD POSITION --- */
@media screen and (max-width: 768px) {
    /* 1. Ensure Mini-map is visible and stays on top of the background but below tooltips */
    #mini-map-container, 
    .planner-minimap-container {
        display: flex !important;
        z-index: 1000 !important;
        bottom: 15px !important;
        right: 15px !important;
        transform: scale(0.9); /* Slightly smaller to feel more 'mobile-native' */
        background: rgba(255, 255, 255, 0.8) !important;
        backdrop-filter: blur(5px);
    }

    /* 2. Nudge the HUD Tooltip UP so it doesn't block the dots */
    .tooltip, 
    .citation-tooltip, 
    .ref-tooltip,
    [data-tooltip]::after {
        bottom: 80px !important; /* Lifted up to clear the dots */
        z-index: 2147483647 !important;
    }
}


/* --- MOBILE PERSPECTIVE GRID FIX (v29.0) --- */
/* Mitigates vertical scrolling fatigue by using a 2-column grid */
@media (max-width: 768px) {
    .perspectives-nav {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 12px; /* Mitigation 5: Fat Finger (Increased gap for touch targets) */
        width: 100%;
        margin-bottom: 15px;
    }

    .perspective-tab {
        width: 100% !important;
        min-height: 50px; /* Mitigation 5: Minimum touch target size */
        height: 100%; /* Mitigation 1: Tall Neighbor (Stretches to match tallest item in row) */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin: 0 !important;
        padding: 8px 4px !important; /* Reduced side padding to fit text */
        
        /* Mitigation 2: Squished Word (Handle long words gracefully) */
        hyphens: auto; 
        word-break: break-word; 
        font-size: 0.9rem;
        line-height: 1.2;
    }

    /* Mitigation 3: The Orphaned Button */
    /* If the last item is odd (leaving a gap), make it span the full width */
    .perspective-tab:last-child:nth-child(odd) {
        grid-column: span 2;
    }
}

/* Mitigation 2 (Edge Case): Ultra-small screens */
/* Revert to stack to prevent unreadable text on devices < 340px wide */
@media (max-width: 340px) {
    .perspectives-nav {
        grid-template-columns: 1fr !important;
    }
    .perspective-tab:last-child:nth-child(odd) {
        grid-column: auto;
    }
}

/* --- OMNIBUS UI UPGRADE (v31.0) --- */

/* Fix 1: Mobile Rescue (Tables to Cards) */
@media (max-width: 768px) {
    table, thead, tbody, th, td, tr { display: block !important; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { border: 1px solid #ccc; margin-bottom: 15px; border-radius: 8px; background: #fff; padding: 10px; }
    td { border: none; border-bottom: 1px solid #eee; position: relative; padding-left: 0 !important; text-align: left; display: block; margin-bottom: 5px; }
    td:before { display: block; font-weight: bold; color: #666; content: attr(data-col-name); margin-bottom: 2px; }
    .workflow-container { flex-direction: column !important; }
    .workflow-stage { width: 100% !important; margin-bottom: 20px; }
}

/* Fix 3: Context-Aware Nav */
.perspectives-nav { position: sticky; top: 0; z-index: 90; background: var(--color-background); padding: 10px 0; border-bottom: 1px solid var(--color-border); }
@media (max-width: 768px) {
    .perspectives-nav { position: fixed; bottom: 0; top: auto; left: 0; width: 100%; background: white; border-top: 1px solid #ccc; padding: 10px; display: flex; overflow-x: auto; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); z-index: 999; }
    .perspective-tab { flex: 0 0 auto; margin-right: 10px; font-size: 0.8rem; padding: 8px 12px; white-space: nowrap; }
    body { padding-bottom: 80px; } 
}

/* Fix 3: Toast Notifications */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; pointer-events: none; }
.toast { background: #333; color: white; padding: 12px 24px; border-radius: 4px; margin-bottom: 10px; animation: fadein 0.5s, fadeout 0.5s 2.5s forwards; opacity: 0; pointer-events: auto; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
@keyframes fadein { from {opacity: 0; transform: translateY(-20px);} to {opacity: 1; transform: translateY(0);} }
@keyframes fadeout { from {opacity: 1;} to {opacity: 0;} }

/* Fix 7: Scannable Meta (Sticky TOC) */
.meta-toc { position: fixed; top: 100px; right: 20px; width: 200px; background: #fff; padding: 15px; border-radius: 8px; font-size: 0.85rem; border: 1px solid #eee; box-shadow: 0 2px 5px rgba(0,0,0,0.05); max-height: 80vh; overflow-y: auto; }
.meta-toc h4 { margin-top: 0; margin-bottom: 10px; font-size: 0.9rem; color: #333; }
.meta-toc ul { list-style: none; padding: 0; margin: 0; }
.meta-toc li { margin-bottom: 8px; }
.meta-toc a { text-decoration: none; color: #666; display: block; }
.meta-toc a:hover { color: var(--color-highlight); }
@media (max-width: 1200px) { .meta-toc { display: none; } }

/* Fix 8: Tooltips */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: #333; color: #fff; padding: 5px 10px; border-radius: 4px; font-size: 0.75rem; white-space: nowrap; z-index: 1000; margin-bottom: 5px;
}

/* --- REVERT: MOBILE STACK LAYOUT (v31.1) --- */
/* Reverts 2-column grid back to single column to prevent screen occlusion */
@media (max-width: 768px) {
    .perspectives-nav {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 8px !important;
        position: static !important; /* Prevents it from floating over content */
        height: auto !important;
        overflow-y: visible !important;
        padding-bottom: 20px;
    }

    .perspective-tab {
        width: 100% !important;
        min-height: 45px !important;
        margin: 0 !important;
        text-align: center;
    }

    /* Reset any grid-specific spans */
    .perspective-tab:last-child:nth-child(odd) {
        grid-column: auto !important;
    }
}

/* --- FIX: COMPACT 2-COLUMN GRID (v32.0) --- */
/* Forces 2 columns but reduces size to prevent blocking the view */
@media (max-width: 768px) {
    .perspectives-nav {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Force 2 columns */
        gap: 6px !important; /* Tight gap to save space */
        margin-bottom: 10px !important;
        flex-direction: row !important; /* Override flex-col if present */
    }

    .perspective-tab {
        width: 100% !important;
        min-height: 35px !important; /* Much smaller minimum height */
        padding: 6px 2px !important; /* Minimal padding */
        font-size: 0.75rem !important; /* Compact font size */
        line-height: 1.1 !important; /* Tight line height */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        margin: 0 !important;
    }
    
    /* Make the last item span full width if there's an odd number */
    .perspective-tab:last-child:nth-child(odd) {
        grid-column: span 2 !important;
    }
}

/* --- RESCUE FIX v35.1: Interaction Safety --- */
#connection-svg {
    pointer-events: none !important; /* Ensure clicks pass through */
}
.method-card, .tool-card {
    cursor: pointer;
    z-index: 10; /* Ensure cards are above SVG */
    position: relative;
}

/* --- RESCUE FIX v36.0: Hard Reset --- */
#connection-svg {
    pointer-events: none !important;
    z-index: 0;
    position: absolute;
    top: 0;
    left: 0;
}
.method-card, .tool-card {
    cursor: pointer;
    z-index: 10;
    position: relative;
    user-select: none; /* Prevent text selection on rapid clicks */
}
#network-grid {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- RESCUE FIX v37.0: Stable Container --- */
#network-grid {
    position: relative;
    overflow: auto; /* Allow scrolling */
    width: 100%;
    height: auto;
    min-height: 600px; /* Ensure space for lines */
}

#connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none !important;
    z-index: 0;
    /* Width/Height set by JS once */
}

.method-row-container.single-row, .tool-row {
    position: relative;
    z-index: 1;
    width: max-content; /* Force container to expand to fit cards */
    padding: 20px;
}

/* --- RESCUE FIX v38.0: Positioning Context --- */
#network-grid {
    position: relative !important; /* Critical: Makes offsetLeft relative to this container */
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    min-height: 600px;
    display: block; /* Ensure it's a block for scrolling */
}

#connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none !important;
    z-index: 0;
}

.method-row-container.single-row, .tool-row {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    width: max-content; /* Force width to fit content */
}

.method-card, .tool-card {
    position: relative;
    z-index: 10;
    background: var(--color-card);
    cursor: pointer;
}
/* --- MOBILE TOOLTIP OVERFLOW FIX --- */
@media (max-width: 768px) {
    .citation-link { cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .citation-link .citation-tooltip {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        top: auto !important;
        transform: translateX(-50%) !important;
        width: 92vw !important;
        max-width: 450px !important;
        white-space: normal !important;
        z-index: 9999 !important; /* Below onboarding, above content */
        padding: 16px !important;
        background: #1a202c !important;
        border: 2px solid var(--color-highlight) !important;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5) !important;
        pointer-events: auto !important;
        visibility: hidden;
        opacity: 0;
        transition: all 0.2s ease-in-out;
        max-height: 40vh;
        overflow-y: auto;
    }
    .citation-link:focus .citation-tooltip,
    .citation-link:active .citation-tooltip {
        visibility: visible !important;
        opacity: 1 !important;
        bottom: 30px !important;
    }
    .citation-tooltip::before {
        content: "Source Detail";
        display: block;
        font-size: 0.65rem;
        font-weight: bold;
        text-transform: uppercase;
        color: var(--color-highlight);
        margin-bottom: 8px;
        opacity: 0.8;
    }
}



/* --- NETWORK MAP FINAL REPAIR v1.5 --- */
.network-horizon-container {
    position: relative !important;
    width: 100%;
    min-height: 1000px; /* Ensure height for drawing */
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

.method-row-container, .tool-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin-bottom: 60px;
}

.method-card, .tool-card {
    width: 220px;
    min-height: 100px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 15px;
    z-index: 10;
}

#connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}
/* --- GAME THEORY MATRIX STYLES (Injected) --- */
.matrix-container {
    display: grid;
    grid-template-columns: 120px 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
    background: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 8px;
}
.matrix-header { font-weight: bold; text-align: center; display: flex; align-items: center; justify-content: center; color: var(--color-text-secondary); font-size: 0.85rem; text-transform: uppercase; }
.matrix-cell {
    background: var(--color-card);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
}
.matrix-cell strong { display: block; margin-bottom: 5px; font-size: 1rem; }
.cell-win { background-color: rgba(39, 174, 96, 0.1); border-color: #27ae60; }
.cell-risk { background-color: rgba(243, 156, 18, 0.1); border-color: #f39c12; }
.cell-loss { background-color: rgba(192, 57, 43, 0.05); border-color: #c0392b; opacity: 0.8; }

/* Dark Mode Overrides */
body.dark-mode-active .cell-win { background-color: rgba(39, 174, 96, 0.2); }
body.dark-mode-active .cell-risk { background-color: rgba(243, 156, 18, 0.2); }
body.dark-mode-active .cell-loss { background-color: rgba(192, 57, 43, 0.2); }

.variations-table { width: 100%; font-size: 0.9rem; margin-top: 20px; border-collapse: collapse; }
.variations-table th { background: rgba(0,0,0,0.05); text-align: left; padding: 10px; border-bottom: 2px solid var(--color-border); }
.variations-table td { padding: 10px; border-bottom: 1px solid var(--color-border); }
body.dark-mode-active .variations-table th { background: rgba(255,255,255,0.05); }

/* --- MOBILE FIX FOR GAME THEORY MATRICES --- */
@media (max-width: 768px) {
    /* Force the matrix container to scroll horizontally if it overflows */
    .matrix-container {
        display: grid;
        /* Keep the 3-column layout but ensure it has a minimum width to be readable */
        min-width: 600px; 
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Wrap the matrix in a scrollable container if not already */
    .perspective-content {
        overflow-x: auto;
        width: 100%;
    }
    
    /* Ensure the scrollbar is visible/usable */
    .perspective-content::-webkit-scrollbar {
        height: 6px;
    }
    .perspective-content::-webkit-scrollbar-thumb {
        background: var(--color-border);
        border-radius: 3px;
    }
}

/* --- LANGUAGE TOGGLE STYLES --- */
.sidebar-stuck-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--white);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}
.sidebar-stuck-button:hover {
    background: var(--color-highlight);
    border-color: var(--color-highlight);
}
