html, body { 
  height: 100%;
  margin: 0; 
}

@font-face {
  font-family: 'nasalization';
  src: url('fonts/nasalization-rg.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body { 
  background-color: #000; 
  overflow: hidden; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Inter", sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

h1, h2, h4, h5, h6
#info-panel h1, #info-panel h2, #info-panel h4, #info-panel h5, #info-panel h6,
#panel-content h1, #panel-content h2, #panel-content h4, #panel-content h5, #panel-content h6,
#splash-text h1, #splash-text h2, #splash-text h3, #splash-text h4, #splash-text h5, #splash-text h6, #enter-button,
.control-section summary, .panel-btn {
  font-family: 'nasalization', sans-serif !important;
}


#3d-graph {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  /* Prevent the browser/OS from interpreting map gestures as scroll/pinch/pan. */
  touch-action: none;
  -ms-touch-action: none;
  overscroll-behavior: contain;
  min-width: 100%;
  min-height: 100%;
  z-index: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* three.js/ForceGraph3D typically appends a canvas and nested divs. */
#3d-graph canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}



.scene-container,
.scene-container canvas {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
}

  #info-panel {
    position: absolute;
    top: 0;
    left: -400px;
    width: 400px;
    max-width: 100lvw;
    height: 100dvh;

    background: rgba(0, 0, 0, 0.85);
    color: #888;
    padding: 10px;
    box-sizing: border-box;
    /* FIX: Allows the scrollbar and the handle to coexist [Conversation] */
    overflow: hidden;
    transition: left 1.5s ease;
    border-right: 1px solid #335577;
    z-index: 10;
    display: flex;
    flex-direction: column;
  }

  #info-panel > #node-info-container,
  #info-panel > #search-container,
  #info-panel > #editor-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }

  #resize-handle {
    position: absolute;
    top: 0;
    /* Position at panel width (400px) minus 5px offset to align with panel edge */
    left: 395px; 
    width: 15px;
    height: 100vh;
    cursor: col-resize;
    background: transparent; /* Invisible but functional */
    z-index: 9999; /* Above everything */
    display: none; /* Hidden by default */
  }


  #resize-handle:hover {
    background: transparent; /* No glow on hover */
    box-shadow: none;
  }

#info-panel.open { 
    left: 0; 
    z-index: 25;
  }

  #info-panel.open ~ #resize-handle {
    display: block; /* Show resize handle when panel is open */
  }

/* Re-introducing the Close Button (High visibility) [Query] */
  #close-panel {
    position: absolute;
    top: 2px;
    right: 3px;
    background: #00000000;
    border: 0px solid #335577;
    color: #990000;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    padding: 5px 10px;
    transition: color 0.2s, text-shadow 0.2s;
  }
  #close-panel:hover { color: #ff5c5c;  text-shadow: 0 0 8px #ff5c5c;}
  
/* Back Button - Top Left Corner */
  #back-btn {
    position: absolute;
    top: 2px;
    left: 4px;
    background: #00000000;
    border: 0px solid #335577;
    color: #5588CC;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    padding: 5px 10px;
    transition: color 0.2s, text-shadow 0.2s;
    display: none; /* Hidden until a node is selected */
  }
  #back-btn.visible { display: block; }
  #back-btn:hover { color: #FFF; text-shadow: 0 0 8px #ffffff; }
  #back-btn:disabled { color: #333; cursor: default; text-shadow: none; }

/* Forward — same horizontal line as back, centered on ~1/3 panel width */
  #forward-btn {
    position: absolute;
    top: 2px;
    left: calc(92% / 3);
    transform: translateX(-50%);
    background: #00000000;
    border: 0px solid #335577;
    color: #5588CC;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    padding: 5px 10px;
    transition: color 0.2s, text-shadow 0.2s;
    display: none;
  }
  #forward-btn.visible { display: block; }
  #forward-btn:hover:not(:disabled) { color: #FFF; text-shadow: 0 0 8px #ffffff; }
  #forward-btn:disabled { color: #333; cursor: default; text-shadow: none; }

  #info-panel h2 { 
    margin-top: 0;
    margin-bottom: 2px;
    margin-left: 0px;
    word-break: break-word; 
  }

#info-panel h3 {
    color: #DDDDDD;
    font-size: 1.4em;
    font-weight: bold;
    margin-top: 14px;
    margin-bottom: 2px;
  }

  /* Tiering font for left panel tab labels */
  #info-panel .tab-btn {
    font-family: 'nasalization', sans-serif !important;
  }


/* Formatting for the new bold/heading logic */
  /* Ensures headings are bold and distinct [Query] */
  .major-heading { 
    color: #DDDDDD; 
    font-size: 1.4em; 
    font-weight: bold; 
    display: block; 
    margin-top: 15px; 
    border-bottom: 0px solid #333; 
  }
  /* Specifically styles the ## items as bold [Query] */
  .bold-item { 
    font-weight: bold; 
    color: #e0e0e0; 
  }
  /* External links should be clickable */
  #panel-content a, #splash-text a { color: #aaa; text-decoration: underline; cursor: pointer; }
  #panel-content a:hover, #splash-text a:hover { color: #00ffff; }

  /* Markdown links [label](URL) */
  .md-link {
    color: #66b3ff;
    text-decoration: underline;
    cursor: pointer;
  }
  .md-link:hover {
    color: #00ffff;
    text-shadow: 0 0 4px #00ffff;
  }
 /* Constraints for images in the Schematic [Source 9] */
  #panel-content img, #splash-text img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px 0;
    border-radius: 5px;
  }

  /* Rotating image container */
  .image-rotator {
    position: relative;
    width: 100%;
    height: auto;
    margin: 15px 0;
    border-radius: 5px;
    overflow: hidden;
  }

  #panel-content .rotating-image {
    width: 100%;
    height: auto;
    display: none;
    border-radius: 5px;
  }

  #panel-content .rotating-image.active {
    display: block;
  }

  /* Rotator controls */
  .image-rotator button {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
  }

  .image-rotator button:hover {
    opacity: 1;
  }

  .rotator-prev {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
  }

  .rotator-next {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }

  .rotator-play-pause {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Interactive link highlight effect [Source 5] */
  .node-link {
    color: #aaa;
    cursor: pointer;
    display: inline-block;
    padding: 2px 0;
    transition: color 0.2s, text-shadow 0.2s;
  }
  
  .node-link:hover {
    color: #00ffff !important;
    text-shadow: 0 0 8px #00ffff;
    text-decoration: underline;
  }

  /* List spacing for upstream requirements */
  .upstream-list {
    list-style-type: disc;
    list-style-position: inside;
    padding-left: 16px;
    margin-top: 6px;
    margin-bottom: 0;
  }

  /* Tighten vertical spacing between parent entries */
  .upstream-list > li {
    margin: 0 0 3px 0;
    padding: 0;
    line-height: 1.15;
  }

  /* Tighten spacing for parsed node info lists like "Required by:" */
  #panel-content ul {
    list-style-position: inside;
    padding-left: 16px;
    margin: 6px 0 0 0;
  }

  #panel-content ul li {
    margin: 0 0 3px 0;
    padding: 0;
    line-height: 1.15;
  }

  #panel-content .major-heading + ul {
    margin-top: 6px;
  }

  /* Reduce any extra space around bold headings */
  #info-panel h3 {
    margin-top: 14px;
    margin-bottom: 2px;
  }

  #info-panel h2 { 
    margin-top: 0;
    margin-bottom: 2px;
    color: #ffffff;
    text-shadow: 0 0 10px #ffffff;
  }

  /* Tab Navigation Styles */
  .tab-nav {
    display: flex;
    border-bottom: 1px solid #335577;
    margin-bottom: 5px;
  }
  
  .tab-btn {
    flex: 1;
    padding: 3px 2px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.95em;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
  }
  
  .tab-btn:hover {
    color: #aaa;
  }
  
  .tab-btn.active {
    color: #FFFFFF;
    text-shadow: 0 0 8px #AAA;
    border-bottom: 2px solid #5588CC;
  }
  
  /* Search Tab Content */
  #search-container {
    display: none;
  }
  
  #search-container.active {
    display: block;
  }
  
  #node-info-container {
    display: block;
    padding-left: 10px; /* enough to allow untruncated 10px <h2> heading glow */
    padding-right: 5px; /* enough to pad body text a bit from the scrollbar */
  }
  
  #node-info-container.hidden,
  #editor-container.hidden {
    display: none;
  }

  #editor-container {
    display: none;
  }

  #editor-container.active {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  
  #editor-container.active #edit-node-id {
    width: 100%;
    padding: 5px;
    margin: 0px 0 0px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #335577;
    color: #ccc;
    box-sizing: border-box;
  }
  
  .editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
  }
  
  .panel-btn {
    appearance: none;
    background: rgba(18, 24, 34, 0.96);
    border: 1px solid rgba(85, 136, 204, 0.22);
    color: #c8dcff;
    padding: 3px 3px;
    border-radius: 6px;
    cursor: pointer;
    min-width: 100px;
    font-size: 0.92em;
    font-weight: 600;
    transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.15s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  }
  
  .panel-btn:hover {
    background: rgba(28, 40, 60, 0.98);
    border-color: rgba(85, 136, 204, 0.55);
    box-shadow: 0 0 18px rgba(0, 168, 255, 0.28);
    transform: translateY(-1px);
  }
  
  .panel-btn:active {
    transform: translateY(0);
  }
  
  .panel-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  }
  
  .panel-btn.primary {
    background: linear-gradient(145deg, rgba(85, 136, 204, 0.25), rgba(26, 39, 61, 0.95));
    border-color: rgba(86, 162, 255, 0.9);
    color: #eff8ff;
  }
  
  .panel-btn.secondary {
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(83, 109, 148, 0.9);
    color: #c3d4f0;
  }
  
  #editor-container.active #edit-node-content {
    flex: 1 1 auto;
    width: 100%;
    box-sizing: border-box;
    min-height: 50px;
    padding: 5px;
    margin: 5px 0 5px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #335577;
    color: #ccc;
    font-family: inherit;
    font-size: inherit;
  }
  
  #editor-container.active #edit-suggestions-panel {
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
  }
  
  .search-input {
    width: 100%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #335577;
    color: #aaa;
    font-size: 0.9em;
    box-sizing: border-box;
    margin-bottom: 10px;
  }
  
  .search-input:focus {
    outline: none;
    border-color: #5588CC;
  }
  
  .search-results {
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
    /* Compact multi-column layout so many nodes fit at once */
    column-width: 220px;
    column-gap: 8px;
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
    padding-right: 6px;
  }
  
  .search-result-item {
    display: inline-block; /* allow column flow */
    width: 100%;
    padding: 4px 6px;
    margin: 2px 0;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid transparent;
    color: #bbb;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    font-size: 12px;
    line-height: 1.15;
    border-radius: 4px;
    box-sizing: border-box;
  }
  
  .search-result-item:hover {
    background: rgba(85, 136, 204, 0.2);
    border-color: #335577;
    color: #fff;
  }
  
  .search-result-item .node-name {
    font-weight: bold;
    font-size: 0.95em;
  }
  
  .search-result-item .node-tier {
    font-size: 0.75em;
    color: #666;
    margin-top: 2px;
  }

  #edit-suggestions-panel {
    margin-top: 20px;
    padding: 14px;
    background: rgba(22, 26, 34, 0.5);
    border: 1px solid #335577;
    border-radius: 8px;
  }

  #edit-suggestions-panel h3 {
    margin-top: 0;
  }

  .panel-input {
    width: 100%;
    padding: 8px;
    margin: 8px 0 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #335577;
    color: #ccc;
    box-sizing: border-box;
  }
  
  .suggestions-list {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 12px;
  }
  
  .suggestion-item {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(10, 15, 25, 0.85);
    border: 1px solid #223344;
    border-radius: 6px;
  }
  
  .suggestion-diff {
    margin-top: 6px;
    font-size: 0.9em;
    line-height: 1.4em;
  }
  
  .suggestion-label {
    color: #88c0d0;
    font-weight: bold;
  }

/* Control Panel Styles */
  #control-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    width: 175px;
  }
  
/* Search Button - Top Left Corner */
  #search-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    background: rgba(0, 0, 0, 0);
    border: 0px solid #335577;
    color: #5588CC;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s, text-shadow 0.2s, opacity 0.3s;
  }
  #search-btn:hover { background: transparent; color: #FFF; text-shadow: 0 0 8px #ffffff; }
  
/* Hide search button when left panel is open */
  #search-btn.hidden {
    opacity: 0;
  }
/* Control Panel */
  #controls-content {
    display: block;
    position: relative;
    /* Outer container box removed to eliminate the large wrapper around controls */
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    color: #ccc;
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    box-shadow: none;
  }

/* Debug HUD: hide only (do not remove DOM or break camera orientation logic) */
  /* Most browsers */
  #controls-content details.control-section:has(#hud-apply-btn) {
    display: none;
  }

  /* Reduce font size for Debug HUD contents to keep it compact */
  #controls-content details.control-section:has(#hud-apply-btn),
  #controls-content details.control-section:has(#hud-apply-btn) * {
    font-size: 0.93em;
    line-height: 1.1;
  }

  /* Fallback: hide the debug controls/table elements by id */
  #hud-cam-x, #hud-cam-y, #hud-cam-z,
  #hud-apply-btn, #hud-sync-btn, 
  #hud-cam-roll, #hud-cam-pitch, #hud-cam-yaw,
  #hud-target-x, #hud-target-y, #hud-target-z,
  #hud-offset-x {
    display: none;
  }

  /* When dev toggle is enabled, override the hard-hide rules */
  #controls-content.debug-visible details.control-section:has(#hud-apply-btn) {
    display: block !important;
  }
  #controls-content.debug-visible #hud-cam-x,
  #controls-content.debug-visible #hud-cam-y,
  #controls-content.debug-visible #hud-cam-z,
  #controls-content.debug-visible #hud-apply-btn,
  #controls-content.debug-visible #hud-sync-btn,
  #controls-content.debug-visible #hud-cam-roll,
  #controls-content.debug-visible #hud-cam-pitch,
  #controls-content.debug-visible #hud-cam-yaw,
  #controls-content.debug-visible #hud-target-x,
  #controls-content.debug-visible #hud-target-y,
  #controls-content.debug-visible #hud-target-z,
  #controls-content.debug-visible #hud-offset-x {
    display: table-cell !important;
  }

  /* HUD buttons are inside a <td>, so force them to behave */
  #controls-content.debug-visible #hud-apply-btn,
  #controls-content.debug-visible #hud-sync-btn {
    display: inline-block !important;
  }


  /* Invisible-but-clickable dev toggle button in Edit Node tab */
  .dev-debug-toggle-btn {
    width: 50px;
    min-width: 10px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(0,0,0,0);
    background: rgba(0,0,0,0);
    color: rgba(0,0,0,0);
    opacity: 0;
    box-shadow: none;
    cursor: pointer;
  }
  .dev-debug-toggle-btn:focus-visible {
    outline: none;
    box-shadow: none;
  }




  #controls-content.open { 
    max-height: calc(100vh - 20px);
  }
  #controls-content .control-toggle {
    display: block;
    margin-bottom: 0;
/*    font-size: 0.95em; */
    color: #ddd;
  }

  /* Box styling for the top-level Visual Tiering checkbox to match collapsible headers */
  #controls-content .control-header-box {
    margin-bottom: 2px;
    border: 1px solid #335577;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.85);
    padding: 2px 2px;
  }



  #controls-content .control-header-box .control-toggle {
    margin-top: 0;
    margin-left: 0;
  }

  #controls-content .control-toggle input {
    margin-right: 6px;
  }

  #controls-content .control-note {
    display: block;
    margin-top: 0px;
    font-size: 0.82em;
    color: #8899aa;
  }
  .control-section {
    margin-top: 2px;
    border: 1px solid #335577;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.8);
    padding: 3px 3px;
  }
.control-section summary {
    cursor: pointer;
    list-style: none;
    padding: 0px;
    font-size: 0.98em;
    font-weight: bold;
    color: #999999;
    background: rgba(0, 0, 0, 0);
    border-radius: 6px;
    user-select: none;
    transition: color 0.25s ease, text-shadow 0.25s ease;
    text-shadow: 0 0 0px rgba(0, 255, 255, 0);
  }

.control-section summary:hover {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
  }

  /* Subtle fade/glow pulse to match other link hover effects */
  @keyframes linkFadeIn {
    from {
      text-shadow: 0 0 0px rgba(0, 255, 255, 0);
    }
    to {
      text-shadow: 0 0 10px #00ffff;
    }
  }





  .control-section summary::-webkit-details-marker,
  .control-section summary::marker {
    display: none;
  }
  .control-section summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
    color: #66d9ef;
  }
  .control-section[open] summary::before {
    transform: rotate(90deg);
  }
  .control-section > *:not(summary) {
    margin-left: 10px;
    margin-top: 8px;
  }
#controls-content h4 { margin: 5px 0 2px 0; color: #5588CC; }
#controls-content label {
    display: block;
    margin-top: 3px;
    font-size: 0.92em;
    line-height: 1.0;
  }
  #controls-content input[type="range"] {
    width: 100%;
    margin-top: 8px;
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    background: transparent;
    cursor: pointer;
  }

  /* Node spacing slider (custom grey bar + blue fill) */
  #controls-content .node-spacing-slider {
    position: relative;
    width: 95%;
    margin-top: 10px;
    height: 14px;
    box-sizing: border-box;
    cursor: ew-resize;
    user-select: none;
    outline: none;
  }

  #controls-content .node-spacing-slider-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(60, 70, 90, 0.65);
    border: 1px solid rgba(85, 136, 204, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  }

  #controls-content .node-spacing-slider-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(0, 200, 255, 0.85), rgba(85, 136, 204, 0.95));
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.18), inset 0 0 0 1px rgba(255,255,255,0.10);
  }

  #controls-content .node-spacing-slider:focus-visible {
    box-shadow: 0 0 0 2px rgba(85, 136, 204, 0.55);
    border-radius: 8px;
  }

  /* Cursor hints */
  #controls-content .node-spacing-slider.cursor-left {
    cursor: w-resize;
  }

  #controls-content .node-spacing-slider.cursor-right {
    cursor: e-resize;
  }

  /* Legacy-style: grey track with blue fill. */
  #controls-content input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(60, 70, 90, 0.65);
    border: 1px solid rgba(85, 136, 204, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  }

  /* Blue "fill" is emulated by styling the thumb only a bit; the actual fill is driven
     by the browser. If you want true fill, we can implement a custom div-based slider later. */
  #controls-content input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0, 200, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.35), 0 0 0 4px rgba(0, 200, 255, 0.08);
    margin-top: -4px; /* centers thumb on 6px track */
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }

  #controls-content input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: 0 0 14px rgba(0, 200, 255, 0.45), 0 0 0 6px rgba(0, 200, 255, 0.12);
  }

  #controls-content input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(60, 70, 90, 0.65);
    border: 1px solid rgba(85, 136, 204, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  }

  #controls-content input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0, 200, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.35), 0 0 0 4px rgba(0, 200, 255, 0.08);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }

  #controls-content input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.1);
    box-shadow: 0 0 14px rgba(0, 200, 255, 0.45), 0 0 0 6px rgba(0, 200, 255, 0.12);
  }

  /* Modern slider styling (WebKit/Blink + Firefox) */
  #controls-content input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(51, 85, 119, 0.45);
    border: 1px solid rgba(85, 136, 204, 0.25);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  }

  #controls-content input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.95), rgba(85, 136, 204, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.25), 0 0 0 4px rgba(0, 255, 255, 0.08);
    margin-top: -6px; /* centers thumb on 6px track */
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  #controls-content input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.06);
    box-shadow: 0 0 18px rgba(0, 255, 255, 0.32), 0 0 0 6px rgba(0, 255, 255, 0.10);
  }

  #controls-content input[type="range"]:focus-visible {
    outline: none;
  }

  #controls-content input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.45), 0 0 0 7px rgba(0, 255, 255, 0.16);
  }

  #controls-content input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(51, 85, 119, 0.45);
    border: 1px solid rgba(85, 136, 204, 0.25);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  }

  #controls-content input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.95), rgba(85, 136, 204, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.25), 0 0 0 4px rgba(0, 255, 255, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  #controls-content input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.06);
    box-shadow: 0 0 18px rgba(0, 255, 255, 0.32), 0 0 0 6px rgba(0, 255, 255, 0.10);
  }
#controls-content input[type="checkbox"] {
    --tcm-accent: #00ffff;
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    vertical-align: middle;
    border-radius: 4px;
    border: 1px solid rgba(85, 136, 204, 0.9);
    background: rgba(0,0,0,0.55);
    box-shadow:
      0 0 0 1px rgba(0,0,0,0.25) inset,
      0 0 10px rgba(0, 255, 255, 0.0);
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    position: relative;
  }

  #controls-content input[type="checkbox"]:hover {
    border-color: rgba(0, 255, 255, 0.55);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.15);
  }

  #controls-content input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow:
      0 0 0 2px rgba(0, 255, 255, 0.35),
      0 0 18px rgba(0, 255, 255, 0.18);
  }

  #controls-content input[type="checkbox"]:checked {
    border-color: rgba(0, 255, 255, 0.95);
    background: rgba(0, 255, 255, 0.14);
    box-shadow: 0 0 16px rgba(0, 255, 255, 0.25);
  }

  #controls-content input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 3px;
    background:
      linear-gradient(180deg, rgba(0, 255, 255, 0.85), rgba(85, 136, 204, 0.85));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
    clip-path: polygon(14% 52%, 0% 64%, 44% 100%, 100% 18%, 86% 6%, 44% 74%);
  }

  /* Debug HUD: hide number input stepper arrows (user can type number directly) */
  #controls-content input[type="number"]{
    appearance: textfield;
    -moz-appearance: textfield;
  }
  #controls-content input[type="number"]::-webkit-outer-spin-button,
  #controls-content input[type="number"]::-webkit-inner-spin-button{
    -webkit-appearance: none;
    margin: 0;
  }


  #controls-content select {
    accent-color: #00ffff;
    background: rgba(0,0,0,0.4);
    border: 1px solid #335577;
    color: #ccc;
    padding: 2px 5px;
    font-size: 0.85em;
  }
  #controls-content input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
  }

  /* Spectrum legend hidden unless Spectrum scheme is selected */
  #spectrum-key.spectrum-hidden {
    display: none;
  }

  /* Social Propensity legend hidden unless Propensity scheme is selected */
  #social-propensity-key.spectrum-hidden {
    display: none;
  }

  /* Complexity legend hidden unless Complexity scheme is selected */
  #complexity-key.spectrum-hidden {
    display: none;
  }

  /* Ensure Social Propensity key is visible by default; JS will toggle the hidden class */
  #social-propensity-key {
    display: block;
  }

  .color-key {
    position: relative;
    margin: 4px 0 8px 12px;
    font-size: 0.85em;
    line-height: 1.45;
  }

  .color-key-entries {
    padding-right: 24px;
  }

  .color-key-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 1px;
  }

  .color-swatch {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 1.15em;
    line-height: 1;
    cursor: pointer;
    border-radius: 2px;
    transition: transform 0.15s ease, filter 0.15s ease;
  }

  .color-swatch:hover {
    transform: scale(1.15);
    filter: brightness(1.25);
  }

  .color-swatch:focus-visible {
    outline: 1px solid #50f2ff;
    outline-offset: 2px;
  }

  .color-key-label {
    color: #aaa;
  }

  .color-key-reset {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 3px;
    background: rgba(0, 20, 30, 0.9);
    color: #88aacc;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .color-key.is-customized:hover .color-key-reset,
  .color-key.is-customized:focus-within .color-key-reset {
    opacity: 1;
    pointer-events: auto;
  }

  .color-key-reset:hover {
    color: #50f2ff;
    border-color: #335577;
  }

  .highlight-color-picker-input {
    position: fixed;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: 0;
    padding: 0;
  }





  #controls-content label.radio-option {
    display: block;
    margin-top: 6px;
    cursor: pointer;
  }
  #controls-content label.radio-option .radio-text {
    display: block;
    padding: 3px 3px;
    border-left: 4px solid transparent;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    color: #ccc;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }
  #controls-content label.radio-option:hover .radio-text {
    background: rgba(255,255,255,0.08);
  }
  #controls-content label.radio-option input[type="radio"]:checked + .radio-text {
    border-left-color: #50f2ff;
    background: rgba(80,242,255,0.12);
    color: #fff;
  }
#controls-content select {
    margin-left: 5px;
  }
  
  /* Depth selects for Independent flow mode */
  .depth-select {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #335577;
    color: #ccc;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    min-width: 45px;
    accent-color: #00ffff;
  }
  
  .depth-select:focus {
    outline: none;
    border-color: #5588CC;
    box-shadow: 0 0 5px rgba(85, 136, 204, 0.5);
  }
  
  .depth-select option {
    background: #000;
    color: #ccc;
  }
  
  /* Flow table layout */
  .flow-table {
    width: 80%;
    border-collapse: collapse;
    margin-top: 2px;
  }
  
  .flow-table td {
    padding: 1px 0;
    vertical-align: middle;
  }
  
  .flow-label {
    text-align: right;
    padding-right: 10px;
    white-space: nowrap;
    width: 50%;
    font-weight: normal;
  }
  
  .flow-controls {
    text-align: left;
    width: 50%;
  }
  
  .flow-controls label {
    margin-right: 15px;
    white-space: nowrap;
  }
  
  /* Loading Overlay Styles */
  #loading-overlay {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 0px solid #5588CC;
    border-radius: 5px;
    padding: 20px 30px;
    color: #5588CC;
    font-size: 1.2em;
    /* Lower than splash so it can render "below" when splash is enabled */
    z-index: 50;
    text-align: center;
  }
  #loading-overlay.active { display: block; }
  #loading-overlay .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #5588CC;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
  }
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  /* Splash Screen Styles */
  #boot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgb(0, 0, 0);
    z-index: 100; /* above graph, below existing splash (100) */
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    opacity: 0;
  }

  #boot-overlay.run-boot-overlay {
    animation: bootOverlaySequence 2s ease-in-out forwards;
  }

  @keyframes bootOverlaySequence {
    0% { opacity: 1; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { opacity: 0; }
  }

  #boot-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
  }

  .boot-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #5588CC;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: bootSpin 1.5s linear infinite;
  }  

  @keyframes bootSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  .boot-loading-text {
    color: #5588CC;
    font-size: 1.2em;
    font-family: monospace;
    letter-spacing: 0.2px;
    /* Fade text in a touch quicker than the overlay */
    animation: bootTextInOut 1.75s ease-in-out forwards;
  }

  @keyframes bootTextInOut {
    0% { opacity: 0; transform: translateY(4px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; }
    100% { opacity: 0; }
  }

  #splash-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh;

    background: rgba(0, 0, 0, 0.4); color: #888; z-index: 90;
    display: flex; justify-content: center; align-items: center;
    /* Start hidden; JS will set opacity to 1 to fade in on load */
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: auto;
  }

  #splash-content {
    max-width: 900px; width: 80lvw; max-height: 95dvh; overflow-y: auto;

    padding: 8px 35px 10px; border: 2px solid #335577; background: #000;
    border-radius: 10px; box-shadow: 0 0 20px #335577;
  }
#close-splash,
#enter-button {
    display: none;
}

#enter-button {
    display: block; margin: 30px auto 0; padding: 5px 10px;
    background: transparent; border: 0px solid #335577; color: #5588CC;
    font-size: 1.2em; cursor: pointer; text-transform: uppercase; 
    transition: color 0.2s, text-shadow 0.2s;
  }
  #enter-button:hover { color: #ffffff; text-shadow: 0 0 10px #ffffff; }
/* Close button for splash screen - positioned relative to splash-content dialogue box */
  #close-splash {
    position: absolute;
    top: 8px;
    right: 9px;
    background: transparent;
    border: 0px;
    color: #990000;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0px 5px;
    z-index: 5;
    transition: color 0.2s, text-shadow 0.2s;
  }
  
  /* Ensure splash-content has position for the close button to be relative to */
  #splash-content {
    position: relative;
  }
  #close-splash:hover { color: #ff5c5c; text-shadow: 0 0 8px #ff5c5c; }
/* Ensure images in the splash follow the same rules as the panel */
  #splash-content img { max-width: 100%; border-radius: 5px; margin-top: 15px; }
/* Make title stand out in splash - white accent with glow */
  #splash-text h2 { 
    color: #ffffff; 
    font-weight: bold;
    text-shadow: 0 0 10px #ffffff;
  }
#splash-text div { color: #bbb; }
  /* Splash loading spinner styles */
  #splash-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: #5588CC;
    font-size: 1.2em;
  }
  #splash-loading .splash-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #5588CC;
    border-top: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }

/* Status Area Styles */
  #status-area {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #335577;
    color: #888;
    padding: 10px 15px;
    font-size: 0.85em;
    border-radius: 5px;
    z-index: 15;
    font-family: monospace;
  }

  #status-area table {
    border-collapse: collapse;
    width: 100%;
  }

  #status-area td {
    padding: 2px 0;
  }

  #status-area .status-label {
    color: #666666;
    font-weight: bold;
    text-align: right;
    padding-right: 12px;
  }

  #status-area .status-label.energy-label {
    color: #5588CC !important;
  }

  #status-area[data-flow-mode="independent"] .energy-stats-separator,
  #status-area[data-flow-mode="independent"] .energy-stats-row {
    display: none;
  }

  #status-area .status-value {
    color: #00ffcc;
    text-align: left;
  }

  /* Custom colors for status values */
  #last-interface-update-value,
  #last-database-update-value {
    color: #999 !important;
  }

  #total-links-value,
  #total-nodes-value {
    color: #CCC !important;
  }

  #energy-nodes-value,
  #energy-cost-value {
    color: #008B8B !important;
  }

  /* Custom sleek scrollbars matching theme */
  /* Global scrollbar base */
  html, body {
    scrollbar-width: thin;
    scrollbar-color: #304d74 rgba(51, 85, 119, 0.3);
  }

  /* Webkit scrollbars */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: rgba(51, 85, 119, 0.15);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #0b121b, #061724);
    border-radius: 4px;
    border: 1px solid rgba(51, 85, 119, 0.3);
    transition: all 0.2s ease;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #004747, #123138);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
    border-color: rgba(0, 255, 255, 0.3);
  }

  ::-webkit-scrollbar-thumb:active {
    background: #004141;
    box-shadow: 0 0 12px rgba(0, 83, 83, 0.6);
  }

  /* Specific to scrollable panels/search/editor/splash */
  #info-panel *::-webkit-scrollbar,
  #search-results::-webkit-scrollbar,
  .suggestions-list::-webkit-scrollbar,
  #splash-content::-webkit-scrollbar,
  #edit-node-content::-webkit-scrollbar,
  #controls-content::-webkit-scrollbar {
    width: 6px;
  }

  #info-panel *::-webkit-scrollbar-track,
  #search-results::-webkit-scrollbar-track,
  .suggestions-list::-webkit-scrollbar-track,
  #splash-content::-webkit-scrollbar-track,
  #edit-node-content::-webkit-scrollbar-track {
    background: rgba(34, 52, 68, 0.247);
  }

  #info-panel *::-webkit-scrollbar-thumb,
  #search-results::-webkit-scrollbar-thumb,
  .suggestions-list::-webkit-scrollbar-thumb,
  #splash-content::-webkit-scrollbar-thumb,
  #edit-node-content::-webkit-scrollbar-thumb {
    background: #18273a;
    border-width: 0;
  }

  #info-panel *::-webkit-scrollbar-thumb:hover,
  #search-results::-webkit-scrollbar-thumb:hover,
  .suggestions-list::-webkit-scrollbar-thumb:hover,
  #splash-content::-webkit-scrollbar-thumb:hover,
  #edit-node-content::-webkit-scrollbar-thumb:hover,
  #controls-content::-webkit-scrollbar-thumb:hover {
    background: #00ffff;
    box-shadow: 0 0 6px rgba(0, 255, 255, 0.5);
  }

  /* Truncate external links in left panel to ~25 characters */
  #info-panel a[href^="http"],
  #info-panel a[href^="https"] {
    max-width: 25ch;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: bottom;
  }

  #info-panel a[href^="http"]:hover,
  #info-panel a[href^="https"]:hover {
    white-space: normal;
    max-width: none;
    overflow: visible;
    word-break: break-word;
  }

