/* ==========================================================================
   Constellation Map - Cybernetic Star Chart Design System
   ========================================================================== */

:root {
    /* Color Palette - Dark Constellation Theme (Default) */
    --bg-color: #020617;          /* Obsidian Space Background */
    --bg-gradient: radial-gradient(circle at center, #090d16 0%, #020617 50%, #000000 100%);
    --surface-color: rgba(15, 23, 42, 0.7); /* Translucent Charcoal */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(34, 211, 238, 0.5); /* Cyan Glow border */
    
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;    /* Slate-200 */
    --text-muted: #64748b;        /* Slate-500 */
    
    /* Accents */
    --primary: #8b5cf6;           /* Electric Violet Star */
    --secondary: #22d3ee;         /* Cyan Vector Path */
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary-glow: rgba(34, 211, 238, 0.4);
    --gradient-glow: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
    
    /* Star Chart Specific */
    --canvas-opacity: 0.8;
    --node-bg: #090d16;
    
    /* Typography */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-hud: 'Share Tech Mono', monospace;
    
    /* Layout & Spacing */
    --base-spacing: 8px;
    --max-width: 1200px;
    --reading-width: 720px;
    
    /* Shapes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-hud: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-node: 0 0 15px var(--secondary);
}

/* Light Theme Variables Override (Elegant Light Star Chart) */
body.light-theme {
    --bg-color: #f1f5f9;          /* Cartography Slate-100 */
    --bg-gradient: radial-gradient(circle at center, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
    --surface-color: rgba(255, 255, 255, 0.85); /* Translucent White */
    --border-color: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(109, 40, 217, 0.5); /* Violet Glow border */
    
    --text-primary: #0f172a;      /* Slate-900 */
    --text-secondary: #334155;    /* Slate-700 */
    --text-muted: #64748b;        /* Slate-500 */
    
    --primary: #6d28d9;           /* Deep Violet Star */
    --secondary: #0891b2;         /* Deep Cyan Vector Path */
    --primary-glow: rgba(109, 40, 217, 0.25);
    --secondary-glow: rgba(8, 145, 178, 0.25);
    --gradient-glow: linear-gradient(135deg, #6d28d9 0%, #0891b2 100%);
    
    --canvas-opacity: 0.5;
    --node-bg: #ffffff;
    
    --shadow-hud: 0 16px 40px rgba(15, 23, 42, 0.08);
    --shadow-node: 0 0 15px var(--primary);
}

/* ==========================================================================
   Base Reset
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-gradient);
    font-family: var(--font-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Canvas & SVG Engine Layout
   ========================================================================== */

#space-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: var(--canvas-opacity);
    transition: opacity 0.5s ease;
}

#constellation-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    overflow: visible;
    background-image: 
        radial-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 0),
        linear-gradient(to right, rgba(255, 255, 255, 0.006) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.006) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 40px 40px;
    background-position: center center;
    transition: opacity 0.5s ease;
}

body.light-theme #constellation-svg {
    background-image: 
        radial-gradient(rgba(109, 40, 217, 0.02) 1px, transparent 0),
        linear-gradient(to right, rgba(109, 40, 217, 0.008) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(109, 40, 217, 0.008) 1px, transparent 1px);
}

/* Constellation Interactive Elements */
.constellation-line {
    stroke: var(--secondary);
    stroke-width: 1px;
    stroke-dasharray: 4 4;
    opacity: 0.25;
    transition: all 0.5s ease;
    animation: flow-dash 20s linear infinite;
}

.constellation-line.active {
    stroke-dasharray: 8 4;
    stroke-width: 1.5px;
    opacity: 0.6;
    animation: flow-dash-active 6s linear infinite;
}

@keyframes flow-dash {
    to {
        stroke-dashoffset: -40;
    }
}

@keyframes flow-dash-active {
    to {
        stroke-dashoffset: -40;
    }
}

.constellation-node-group {
    cursor: pointer;
}

.constellation-orbit {
    fill: none;
    stroke: var(--border-color);
    stroke-dasharray: 2 6;
    stroke-width: 1px;
}

.constellation-glow {
    fill: var(--primary);
    opacity: 0.15;
    transition: all 0.4s ease;
}

.constellation-node-group:hover .constellation-glow,
.constellation-node-group.active .constellation-glow,
.constellation-node-group.hover-active .constellation-glow {
    opacity: 0.35;
    r: 28;
    animation: breathing-glow 2s ease-in-out infinite alternate;
}

@keyframes breathing-glow {
    0% { r: 20; opacity: 0.2; }
    100% { r: 30; opacity: 0.45; }
}

.constellation-ring {
    fill: none;
    stroke: var(--secondary);
    stroke-width: 1px;
    stroke-dasharray: 4 2;
    opacity: 0.35;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.constellation-node-group:hover .constellation-ring,
.constellation-node-group.hover-active .constellation-ring {
    stroke: var(--primary);
    opacity: 0.85;
    r: 18;
    animation: rotation-spin 8s linear infinite;
}

.constellation-node-group.active .constellation-ring {
    stroke: var(--primary);
    opacity: 0.9;
    r: 22;
    stroke-dasharray: 6 3;
    animation: rotation-spin 12s linear infinite reverse;
}

@keyframes rotation-spin {
    100% { transform: rotate(360deg); }
}

.constellation-node {
    fill: var(--node-bg);
    stroke: var(--secondary);
    stroke-width: 1.5px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.constellation-node-group:hover .constellation-node,
.constellation-node-group.hover-active .constellation-node {
    stroke: var(--primary);
    stroke-width: 2.5px;
    r: 8;
    filter: drop-shadow(0 0 10px var(--primary));
}

.constellation-node-group.active .constellation-node {
    stroke: var(--primary);
    fill: var(--primary);
    stroke-width: 2.5px;
    r: 9;
    filter: drop-shadow(0 0 14px var(--primary));
}

.constellation-label {
    font-family: var(--font-hud);
    font-size: 11px;
    fill: var(--text-muted);
    letter-spacing: 0.08em;
    pointer-events: none;
    opacity: 0;              /* HIDE BY DEFAULT to clean up overlap */
    transition: all 0.3s ease;
}

.constellation-node-group:hover .constellation-label,
.constellation-node-group.active .constellation-label,
.constellation-node-group.hover-active .constellation-label {
    opacity: 1;              /* Show on hover or when list sync is active */
    fill: var(--text-primary);
    font-weight: 600;
}

/* ==========================================================================
   HUD Layout Elements
   ========================================================================== */

/* HUD Panels Glassmorphism Base style */
.hud-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-hud);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar HUD Directory Styles */
#hud-sidebar {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 380px;
    height: calc(100vh - 128px);
    z-index: 3;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(34, 211, 238, 0.15);
    background: linear-gradient(135deg, rgba(10, 15, 30, 0.85) 0%, rgba(3, 7, 18, 0.95) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(34, 211, 238, 0.03);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

body.light-theme #hud-sidebar {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(241, 245, 249, 0.95) 100%);
    border-color: rgba(109, 40, 217, 0.15);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08), inset 0 0 20px rgba(109, 40, 217, 0.02);
}

/* Cyber header accent line */
#hud-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-glow);
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.header-main {
    font-family: var(--font-hud);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.1em;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.header-sub {
    font-family: var(--font-hud);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.sidebar-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

/* Hide scrollbars but support scroll */
.sidebar-list::-webkit-scrollbar {
    width: 4px;
}
.sidebar-list::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
.sidebar-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.sidebar-item {
    position: relative;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.01);
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

body.light-theme .sidebar-item {
    background-color: rgba(0, 0, 0, 0.01);
}

/* Sliding side indicator */
.sidebar-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--gradient-glow);
    border-radius: var(--radius-full);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.sidebar-item:hover::before, .sidebar-item.hover-active::before {
    transform: translateY(-50%) scaleY(1);
}

.sidebar-item.active::before {
    transform: translateY(-50%) scaleY(1);
    height: 80%;
    background: var(--secondary);
}

.sidebar-item:hover, .sidebar-item.hover-active {
    background-color: rgba(139, 92, 246, 0.04);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 10px rgba(139, 92, 246, 0.08);
    transform: translateX(4px);
}

.sidebar-item.active {
    border-color: var(--secondary);
    background-color: rgba(34, 211, 238, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 12px rgba(34, 211, 238, 0.15);
    transform: translateX(6px);
}

.sidebar-item-title {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.sidebar-item:hover .sidebar-item-title, 
.sidebar-item.hover-active .sidebar-item-title {
    color: var(--primary);
}

.sidebar-item.active .sidebar-item-title {
    color: var(--secondary);
}

.sidebar-item-meta {
    font-family: var(--font-hud);
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-tag {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.03);
}

body.light-theme .sidebar-tag {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Floating Tooltip info card */
#hud-tooltip {
    position: fixed;
    z-index: 10;
    padding: 16px 20px;
    width: 280px;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -15px; /* Offset from mouse */
}

#hud-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.tooltip-hidden {
    opacity: 0;
    visibility: hidden;
    margin-top: 0px !important;
}

.tooltip-title {
    font-family: var(--font-heading);
    font-size: 16px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.tooltip-meta {
    font-family: var(--font-hud);
    font-size: 11px;
    color: var(--primary);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.tooltip-excerpt {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Bottom HUD Control Panel */
.hud-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: calc(100% - 48px);
    max-width: var(--max-width);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(34, 211, 238, 0.15);
    background: linear-gradient(90deg, rgba(10, 15, 30, 0.9) 0%, rgba(3, 7, 18, 0.95) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(34, 211, 238, 0.03);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
}

body.light-theme .hud-panel {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.98) 100%);
    border-color: rgba(109, 40, 217, 0.15);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08), inset 0 0 20px rgba(109, 40, 217, 0.02);
}

.hud-panel:hover {
    border-color: rgba(34, 211, 238, 0.3);
}

.hud-brand {
    display: flex;
    align-items: center;
}

.hud-logo {
    font-family: var(--font-hud);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.1em;
    display: flex;
    gap: 8px;
}

.logo-core {
    color: var(--text-primary);
}

.logo-suffix {
    color: var(--secondary);
    opacity: 0.8;
}

/* Center controls (Filters & Search) */
.hud-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.hud-search-wrapper {
    position: relative;
}

.hud-input {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-hud);
    font-size: 12px;
    padding: 8px 16px;
    width: 200px;
    transition: all 0.3s ease;
}

body.light-theme .hud-input {
    background-color: rgba(0, 0, 0, 0.03);
}

.hud-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.hud-tags {
    display: flex;
    gap: 10px;
}

.hud-tag-btn {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-hud);
    font-size: 11px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.05em;
}

.hud-tag-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.hud-tag-btn.active {
    border-color: var(--secondary);
    color: var(--secondary);
    background-color: rgba(34, 211, 238, 0.1);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}

/* Right HUD stats details */
.hud-utils {
    display: flex;
    align-items: center;
    gap: 20px;
}

.hud-util-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.hud-util-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: rgba(139, 92, 246, 0.05);
}

body.light-theme .sun-icon { display: block; }
body.light-theme .moon-icon { display: none; }
body.dark-theme .sun-icon { display: none; }
body.dark-theme .moon-icon { display: block; }

.hud-coordinate-info {
    font-family: var(--font-hud);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Slide-in Article Sheet
   ========================================================================== */

#reader-sheet {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    z-index: 100;
    background-color: var(--surface-color);
    backdrop-filter: blur(25px);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-hud);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
    display: flex;
    flex-direction: column;
    visibility: visible;
}

#reader-sheet.reader-hidden {
    transform: translateX(100%);
    visibility: hidden;
}

/* Reader active overrides to slide sidebar, bottom bar away and fade out star globe background */
body.reader-active #hud-sidebar {
    transform: translateX(-110%);
}

body.reader-active .hud-panel {
    transform: translate(-50%, 150px);
}

body.reader-active #constellation-svg,
body.reader-active #space-canvas {
    opacity: 0 !important;
    pointer-events: none !important;
}

.reader-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(25px);
    transition: all 0.3s ease;
    z-index: 10;
}

.reader-close-btn:hover {
    color: var(--text-primary);
    background-color: rgba(139, 92, 246, 0.05);
}

/* Top indicator bar */
.reader-scrollbar-progress {
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.04);
}

#reader-progress-bar {
    width: 0%;
    height: 100%;
    background: var(--gradient-glow);
    transition: width 0.1s linear;
}

/* Side Sheet Content Layout (Two-column) */
.reader-layout {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 240px 1fr;
    overflow: hidden;
}

.reader-toc-sidebar {
    border-right: 1px solid var(--border-color);
    padding: 48px 24px;
    overflow-y: auto;
}

.reader-toc-title {
    font-family: var(--font-hud);
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 20px;
    font-weight: 600;
}

.reader-toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toc-link {
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.toc-link:hover, .toc-link.active {
    color: var(--primary);
    padding-left: 4px;
}

.toc-link.h3 {
    padding-left: 12px;
    font-size: 12px;
}

/* Main Post Reader viewport */
.reader-body-container {
    padding: 48px 64px 80px;
    overflow-y: auto;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.reader-header {
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.reader-meta {
    font-family: var(--font-hud);
    font-size: 12px;
    color: var(--primary);
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.reader-title {
    font-family: var(--font-heading);
    font-size: 40px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Rich Markdown Content Styling (Futuristic Reader)
   ========================================================================== */

.markdown-body {
    font-size: 16px;
    line-height: 1.85;
    color: var(--text-secondary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-top: 40px;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.markdown-body h1 {
    font-size: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.markdown-body h2 {
    font-size: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.markdown-body h2::before {
    content: '//';
    color: var(--secondary);
    font-family: var(--font-hud);
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 8px var(--secondary-glow);
}

.markdown-body h3 {
    font-size: 20px;
}

.markdown-body p {
    margin-bottom: 24px;
}

.markdown-body strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* Inline Code tags */
.markdown-body code {
    background-color: rgba(34, 211, 238, 0.05);
    border: 1px solid var(--border-color);
    color: var(--secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-family: var(--font-hud);
}

/* Blockquotes */
.markdown-body blockquote {
    margin: 36px 0;
    padding: 20px 24px;
    background-color: rgba(34, 211, 238, 0.02);
    border-left: 3px solid var(--secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    box-shadow: inset 5px 0 15px rgba(34, 211, 238, 0.01);
}

body.light-theme .markdown-body blockquote {
    background-color: rgba(109, 40, 217, 0.02);
    border-left-color: var(--primary);
}

.markdown-body blockquote p {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.6;
}

/* Pre-formatted Code blocks */
.markdown-body pre {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    overflow-x: auto;
    margin-bottom: 32px;
}

body.light-theme .markdown-body pre {
    background-color: #0f172a !important; /* Keep code blocks dark */
}

.markdown-body pre code {
    background-color: transparent;
    border: none;
    color: #f8fafc;
    padding: 0;
    font-size: 13px;
    font-family: Consolas, Monaco, monospace;
}

/* Copy buttons & Code window headers */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 10px 16px;
    font-family: var(--font-hud);
    font-size: 11px;
    color: var(--text-muted);
}

body.light-theme .code-block-header {
    background-color: #0b0f19; /* Keep code blocks dark for readability */
}

.code-window-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-window-controls .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.code-window-controls .dot.close { background-color: #ef4444; }
.code-window-controls .dot.minimize { background-color: #f59e0b; }
.code-window-controls .dot.expand { background-color: #10b981; }

.code-lang-label {
    margin-left: 10px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-hud);
    font-size: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-btn:hover {
    color: var(--secondary);
    border-color: var(--secondary);
    background-color: rgba(34, 211, 238, 0.08);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.25);
}

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.markdown-body li {
    margin-bottom: 8px;
}

/* Tables */
.markdown-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin-bottom: 32px;
    font-size: 14px;
}

.markdown-body th {
    font-family: var(--font-hud);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
    text-align: left;
    padding: 10px 14px;
}

.markdown-body td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
}

.markdown-body tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .markdown-body tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1024px) {
    #reader-sheet {
        max-width: 100%;
    }
    
    .reader-layout {
        grid-template-columns: 1fr;
    }
    
    .reader-toc-sidebar {
        display: none; /* Hide TOC on mobile side sheets */
    }
    
    .reader-body-container {
        padding: 80px 24px 60px;
    }
    
    .hud-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "brand utils"
            "controls controls";
        gap: 12px;
        padding: 12px 16px;
        bottom: 12px;
        width: calc(100% - 24px);
    }
    
    .hud-brand {
        grid-area: brand;
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }
    
    .hud-controls {
        grid-area: controls;
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .hud-search-wrapper, .hud-input {
        width: 100%;
    }
    
    .hud-tags {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .hud-utils {
        grid-area: utils;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
    }

    #hud-sidebar {
        position: fixed;
        top: auto;
        bottom: 162px;
        left: 12px;
        width: calc(100% - 24px);
        height: 35vh;
        z-index: 3;
    }

    #constellation-svg {
        display: block !important;
        opacity: 0.8 !important;
        pointer-events: auto !important;
    }
    
    #space-canvas {
        display: block !important;
        opacity: 0.8 !important;
        pointer-events: none !important;
    }
}

/* Image Responsive Rules & Zoomable Lightbox */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    display: block;
    margin: 24px auto;
    cursor: zoom-in;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.markdown-body img:hover {
    transform: scale(1.015);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

body.light-theme .markdown-body img {
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}
body.light-theme .markdown-body img:hover {
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

#lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 6, 23, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: zoom-out;
}

body.light-theme #lightbox-overlay {
    background-color: rgba(241, 245, 249, 0.95);
}

#lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

#lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light-theme #lightbox-img {
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
}

#lightbox-overlay.active #lightbox-img {
    transform: scale(1);
}
