:root {
  --bg-color: #050505;
  --panel-bg: rgba(15, 15, 15, 0.8);
  --accent-cyan: #00f2ff;
  --accent-red: #ff003c;
  --accent-amber: #ffb400;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --border-glow: rgba(0, 242, 255, 0.3);
  --font-main: 'Inter', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  max-width: 100%;
}

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(0, 150, 255, 0.05) 0%, transparent 70%),
    url('https://www.transparenttextures.com/patterns/stardust.png');
  color: var(--text-primary);
  font-family: var(--font-main);
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 80px 1fr;
}

/* --- SCANLINES & NOISE --- */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), 
              linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 2px, 3px 100%;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.15;
}

@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

.scan-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 20px;
  background: linear-gradient(to bottom, transparent, rgba(0, 242, 255, 0.1), transparent);
  animation: scanline 8s linear infinite;
  pointer-events: none;
  z-index: 1001;
}

/* --- HEADER --- */
header {
  grid-column: 1 / -1;
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  padding: 0 40px;
  justify-content: space-between;
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
  z-index: 100;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  letter-spacing: 3px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-cyan);
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 12px;
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  border-radius: 4px;
  text-transform: uppercase;
}

/* --- SIDEBAR --- */
aside {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-glow);
  padding: 30px;
  overflow-y: auto;
}

nav h3 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 15px;
  margin-top: 30px;
  letter-spacing: 2px;
}

nav ul {
  list-style: none;
}

nav li {
  margin-bottom: 8px;
}

nav a {
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
  border-left: 2px solid transparent;
}

nav a:hover, nav a.active {
  background: rgba(0, 242, 255, 0.1);
  color: var(--accent-cyan);
  border-left: 2px solid var(--accent-cyan);
  padding-left: 20px;
}

/* --- SUBMENU SYSTEM --- */
.submenu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.submenu-header a {
  flex-grow: 1;
  border-left: none; /* Handled by submenu-header padding */
}

.submenu-header:hover, .submenu-header.active {
  background: rgba(0, 242, 255, 0.1);
}

.submenu-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0 15px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.submenu-toggle::before {
  content: "[+]";
}

.has-submenu.open .submenu-toggle::before {
  content: "[-]";
  color: var(--accent-cyan);
}

.submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
  padding-left: 15px;
  margin-top: 5px;
  border-left: 1px solid rgba(0, 242, 255, 0.1);
}

.has-submenu.open .submenu {
  max-height: 1000px;
  transition: max-height 0.5s ease-in-out;
}

.submenu li a {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 10px;
}

.submenu li a:hover, .submenu li a.active {
  color: var(--accent-cyan);
  background: transparent;
  padding-left: 15px;
  border-left: 1px solid var(--accent-cyan);
}

/* --- MAIN CONTENT --- */
main {
  padding: 40px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  width: 100%;
}

.content-panel {
  max-width: 900px;
  margin: 0 auto;
  background: var(--panel-bg);
  padding: 40px;
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Decorative corners */
.content-panel::before, .content-panel::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-cyan);
}

.content-panel::before { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.content-panel::after { bottom: -2px; right: -2px; border-left: none; border-top: none; }

/* Markdown Styles */
#content h1 {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 2rem;
  margin-bottom: 25px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(0, 242, 255, 0.2);
  padding-bottom: 8px;
  overflow-wrap: break-word;
}

#content h2 {
  color: var(--accent-amber);
  margin-top: 2.6rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 1.5rem;
}

#content h3 {
  color: var(--accent-cyan);
  margin-top: 2.2rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 1.25rem;
  letter-spacing: 1px;
}

#content h4 {
  color: var(--text-primary);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 1.1rem;
  border-left: 3px solid var(--accent-cyan);
  padding-left: 12px;
}

#content p {
  line-height: 1.6;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

#content ul, #content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.8rem;
}

#content li {
  margin-bottom: 0.75rem;
  line-height: 1.62;
}

#content li ul, #content li ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

#content code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 255, 0.1);
  font-size: 0.9em;
}

#content pre {
  background: rgba(0, 0, 0, 0.6);
  padding: 24px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 2rem;
  border: 1px solid rgba(0, 242, 255, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 242, 255, 0.05);
}

#content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

#content th {
  background: rgba(0, 242, 255, 0.1);
  color: var(--accent-cyan);
  text-align: left;
  padding: 12px;
  border-bottom: 2px solid var(--accent-cyan);
}

#content td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-variant-numeric: tabular-nums;
}

/* --- HERO & MANUAL PHOTOS --- */
#content img[alt*="hero"] {
  display: block;
  margin: 2.5rem auto;
  max-width: 400px;
  border-radius: 8px;
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: rgba(0, 0, 0, 0.5);
}

#content img[alt*="hero"]:hover {
  transform: scale(1.02);
  box-shadow: 0 0 30px rgba(0, 242, 255, 0.4);
}

/* Specific scaling for manual items */
#content img[alt*="manual-hero"] {
  max-width: 320px;
}

#content hr {
  margin: 2.6rem 0;
  border: none;
  border-top: 1px solid rgba(0, 242, 255, 0.15);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* --- HERO SECTION --- */
#hero {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 50px;
}

.droid-render {
  max-width: 400px;
  filter: drop-shadow(0 0 20px rgba(0, 242, 255, 0.3));
  image-rendering: auto; /* High-res for actual photos */
}

/* --- LIGHTBOX MODAL --- */
.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-direction: column;
    gap: 15px;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#modal-img {
    max-width: 100%;
    max-height: 80vh;
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.3);
    border-radius: 4px;
}

.modal-caption {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 20px;
    border-radius: 4px;
}

.close-modal {
    position: absolute;
    top: 30px;
    right: 40px;
    color: var(--text-primary);
    font-size: 40px;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--accent-red);
    transform: scale(1.2);
}

/* Content Image Scaling */
.content-image, #content img {
    display: block;
    margin: 2rem auto;
    max-width: 500px;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-glow);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.content-image:hover, #content img:hover {
    filter: brightness(1.2);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.3);
}

/* Limit images in tables to be thumbnails */
#content table img {
    max-height: 120px;
    width: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: var(--accent-cyan); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-amber); }

/* --- GITHUB ALERTS --- */
.alert {
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 8px;
    border-left: 5px solid transparent;
    background: rgba(255, 255, 255, 0.05);
}

.alert-tip { border-left-color: #3fb950; background: rgba(63, 185, 80, 0.1); }
.alert-important { border-left-color: #a371f7; background: rgba(163, 113, 247, 0.1); }
.alert-warning { border-left-color: #d29922; background: rgba(210, 153, 34, 0.1); }
.alert-caution { border-left-color: #f85149; background: rgba(248, 81, 73, 0.1); }
.alert-note { border-left-color: #58a6ff; background: rgba(88, 166, 255, 0.1); }

.alert strong {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- INTERACTIVE MERMAID HUD --- */
.mermaid {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(0, 242, 255, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 242, 255, 0.05);
}

.mermaid .node rect, .mermaid .node circle, .mermaid .node polygon {
    stroke-width: 2px !important;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Hover effects for interactive nodes */
.mermaid .node:hover rect, .mermaid .node:hover circle, .mermaid .node:hover polygon {
    filter: brightness(1.2) drop-shadow(0 0 8px var(--accent-cyan));
    stroke: var(--accent-cyan) !important;
}

.mermaid .label {
    font-family: var(--font-mono) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}

.mermaid .edgePath path {
    stroke: rgba(0, 242, 255, 0.4) !important;
    stroke-width: 2px !important;
}

.mermaid .marker {
    fill: rgba(0, 242, 255, 0.4) !important;
}

/* --- ADVANCED INTERACTION: CONNECTION TRACING --- */

/* High-Fidelity Connection Glow */
.mermaid .flowchart-link:hover path {
  stroke: var(--accent-cyan) !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 8px var(--accent-cyan));
  transition: all 0.2s ease-in-out;
  cursor: crosshair;
}

/* Trace Arrowheads on Hover */
.mermaid .flowchart-link:hover .marker {
  fill: var(--accent-cyan) !important;
  stroke: var(--accent-cyan) !important;
}

/* Dim non-hovered paths for tracing clarity */
.mermaid svg:hover .flowchart-link:not(:hover) path {
  opacity: 0.15;
  transition: opacity 0.4s ease;
}

/* Node Hover Glow Enhancements */
.mermaid .node:hover rect, .mermaid .node:hover circle, .mermaid .node:hover polygon {
  stroke-width: 4px !important;
  box-shadow: 0 0 15px var(--accent-cyan);
}

/* --- NEURAL CONNECTOME HUD MODAL --- */
.connectome-modal {
    display: none;
    position: fixed;
    z-index: 2500;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 5, 5, 0.9);
    backdrop-filter: blur(15px);
    justify-content: center;
    align-items: center;
}

.connectome-content {
    background: rgba(15, 15, 15, 0.95);
    width: 600px;
    max-width: 90%;
    border: 2px solid var(--accent-cyan);
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
    padding: 30px;
    position: relative;
    overflow: hidden;
}

#connectome-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(0, 242, 255, 0.2);
    padding-bottom: 15px;
}

#connectome-title {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    font-size: 1.1rem;
    letter-spacing: 2px;
}

#connectome-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.close-connectome {
    position: absolute;
    top: 30px;
    right: 40px;
    color: var(--text-primary);
    font-size: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-connectome:hover {
    color: var(--accent-cyan);
    transform: rotate(90deg);
}

.connectome-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    animation: scan-left-right 4s linear infinite;
}

@keyframes scan-left-right {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
/* --- MOBILE MENU TOGGLE --- */
#mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1002;
}

#mobile-menu-toggle span {
    width: 100%;
    height: 2px;
    background-color: var(--accent-cyan);
    transition: all 0.3s ease;
    box-shadow: 0 0 5px var(--accent-cyan);
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 900px) {
    body {
        display: block;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    header {
        position: sticky;
        top: 0;
        height: 60px;
        padding: 0 15px;
        z-index: 1001;
    }

    .logo-text {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }

    @media (max-width: 450px) {
        .logo-text {
            font-size: 0.85rem;
            letter-spacing: 0;
        }
    }

    .header-info {
        display: none;
    }

    #mobile-menu-toggle {
        display: flex;
    }

    /* Sidebar as mobile overlay */
    aside {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        background: rgba(5, 5, 5, 0.98);
        padding: 20px;
        border-right: none;
        border-bottom: 2px solid var(--accent-cyan);
    }

    body.sidebar-open {
        overflow: hidden; /* Prevent scrolling background when menu is open */
    }

    body.sidebar-open aside {
        transform: translateX(0);
    }

    /* Hamburger Animation */
    body.sidebar-open #mobile-menu-toggle span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
    body.sidebar-open #mobile-menu-toggle span:nth-child(2) { opacity: 0; }
    body.sidebar-open #mobile-menu-toggle span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

    main {
        padding: 10px;
        width: 100%;
        overflow-x: hidden;
    }

    .content-panel {
        margin: 10px 0;
        padding: 15px;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #content h1 {
        font-size: 1.5rem;
    }

    .droid-render {
        max-width: 80%;
    }

    /* Table Responsiveness */
    #content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

}

/* GitHub-Style Interactive Diagrams */
.mermaid {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 500px;
    background: rgba(13, 17, 23, 0.4) !important;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.mermaid:hover {
    border-color: var(--accent-cyan);
}

.mermaid svg {
    cursor: grab !important;
    width: 100% !important;
    height: 100% !important;
}

.mermaid svg:active {
    cursor: grabbing !important;
}

/* Bottom-Right Navigation Cluster */
.diagram-nav-cluster {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-rows: repeat(3, 28px);
    gap: 4px;
    z-index: 1000;
    padding: 6px;
    background: #21262d;
    border: 1px solid rgba(240, 246, 252, 0.1);
    border-radius: 6px;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.mermaid:hover .diagram-nav-cluster,
.mermaid:hover .diagram-fs-btn {
    opacity: 1;
    transform: translateY(0);
}

.toolbar-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: #c9d1d9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s ease;
    border-radius: 4px;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Top-Right Fullscreen Button */
.diagram-fs-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 32px;
    height: 32px;
    background: #21262d;
    border: 1px solid rgba(240, 246, 252, 0.1);
    border-radius: 6px;
    color: #c9d1d9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.diagram-fs-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.toolbar-btn svg, .diagram-fs-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.toolbar-spacer {
    pointer-events: none;
}

/* --- ADVANCED INTERACTION: CONNECTION TRACING --- */

/* High-Fidelity Connection Glow */
.mermaid .flowchart-link:hover path {
  stroke: var(--accent-cyan) !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 8px var(--accent-cyan));
  transition: all 0.2s ease-in-out;
  cursor: crosshair;
}

/* Trace Arrowheads on Hover */
.mermaid .flowchart-link:hover .marker {
  fill: var(--accent-cyan) !important;
  stroke: var(--accent-cyan) !important;
}

/* Dim non-hovered paths for tracing clarity */
.mermaid svg:hover .flowchart-link:not(:hover) path {
  opacity: 0.15;
  transition: opacity 0.4s ease;
}

/* Node Hover Glow Enhancements */
.mermaid .node:hover rect, .mermaid .node:hover circle, .mermaid .node:hover polygon {
  stroke-width: 4px !important;
  box-shadow: 0 0 15px var(--accent-cyan);
}
