:root {
    /* Dark Theme Variables (Default) */
    --bg-base: #0a0c16;
    --bg-panel: #111525;
    --bg-elevated: #1a1f35;
    --bg-secondary: #1a1f35;
    --bg-glass: rgba(17, 21, 37, 0.7);
    --text-main: #e8edf5;
    --text-muted: #8892a8;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --border-color: #252b42;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, monospace;

    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* Animated gradient stops for color cycling */
    --cycle-1: #ff4466;
    --cycle-2: #ffcc22;
    --cycle-3: #44ff88;
    --cycle-4: #22ccff;
    --cycle-5: #8844ff;
    --cycle-6: #ff44cc;
}

body.light-theme {
    --bg-base: #f8fafc;
    --bg-panel: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-secondary: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent-primary: #2563eb;
    --accent-secondary: #7c3aed;
    --accent-glow: rgba(37, 99, 235, 0.3);
    --border-color: #e2e8f0;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* ── Global Animations ── */

@keyframes gradientCycle {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes gradientCycleSlow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes hueRotate {
    0%   { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.7; }
}

@keyframes borderGlow {
    0%, 100% { border-color: rgba(139, 92, 246, 0.3); }
    33%      { border-color: rgba(59, 130, 246, 0.4); }
    66%      { border-color: rgba(34, 204, 255, 0.3); }
}

@keyframes bgShift {
    0%   { background-position: 0% 0%; }
    25%  { background-position: 100% 0%; }
    50%  { background-position: 100% 100%; }
    75%  { background-position: 0% 100%; }
    100% { background-position: 0% 0%; }
}

@keyframes textGlow {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.5)); }
    33%      { filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.5)); }
    66%      { filter: drop-shadow(0 0 12px rgba(34, 204, 255, 0.5)); }
}

@keyframes cardShimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

a {
    text-decoration: none;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

/* ── Animated background ── */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow: visible;
    position: relative;
}

.app-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 10% 20%, rgba(139, 92, 246, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(34, 204, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 68, 102, 0.04) 0%, transparent 60%);
    animation: bgShift 30s ease-in-out infinite;
    background-size: 200% 200%;
    pointer-events: none;
    z-index: 0;
}

.app-container > * {
    position: relative;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    width: 320px;
    min-width: 320px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease, background-color 0.4s ease, border-color 0.4s ease;
    box-shadow: var(--shadow-sm);
    animation: borderGlow 8s ease-in-out infinite;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.4rem;
    background: linear-gradient(135deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff, #ff44cc, #ff4466);
    background-size: 300% 300%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.sidebar-header h2 a {
    -webkit-text-fill-color: transparent;
}

.version-badge {
    font-size: 0.55em;
    font-weight: 500;
    font-family: 'Fira Code', monospace;
    background: rgba(136, 68, 255, 0.15);
    color: var(--accent-color, #7c3aed);
    -webkit-text-fill-color: var(--accent-color, #7c3aed);
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: 0.02em;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--accent-primary);
    background-color: var(--bg-elevated);
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 20px;
    position: relative;
}

.mobile-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-main);
    position: absolute;
    transition: var(--transition);
    border-radius: 2px;
}
.mobile-toggle span:nth-child(1) { top: 0; }
.mobile-toggle span:nth-child(2) { top: 9px; }
.mobile-toggle span:nth-child(3) { top: 18px; }

.search-container {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px rgba(139, 92, 246, 0.15);
}

.package-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0 0 0;
    min-height: 0; /* allow flex child to shrink */
}

.package-list-container::-webkit-scrollbar {
    width: 6px;
}
.package-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.nav-section-title {
    padding: 0 24px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.nav-list {
    list-style: none;
    padding-bottom: 8px; /* space before sticky pagination */
}

.nav-item {
    padding: 14px 24px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, var(--accent-glow) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.nav-item:hover::before {
    opacity: 0.1;
}

.nav-item.active {
    background-color: var(--bg-elevated);
    border-left-color: var(--accent-primary);
}

.nav-item.active::before {
    opacity: 0.15;
}

.nav-item.graph-highlight {
    background-color: rgba(0, 212, 255, 0.18);
    border-left: 3px solid rgba(0, 212, 255, 0.9);
    box-shadow: inset 0 0 20px rgba(0, 212, 255, 0.08);
}

.nav-item.graph-highlight::before {
    opacity: 0.25;
}

.nav-item.graph-highlight .nav-item-title {
    color: #00d4ff;
}

.nav-item-content {
    position: relative;
    z-index: 1;
}

.nav-item-title {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.nav-item-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.nav-item-link:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.nav-item:hover .nav-item-title {
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 4s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-item.active .nav-item-title {
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 4s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ─── Score bar ─── */
.nav-item-score {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.score-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}
.score-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    min-width: 32px;
    text-align: right;
}
.nav-item-score[data-quality="unrated"] .score-bar-fill {
    background: #6b7280;
    opacity: 0.5;
}

/* ─── Standout packages ─── */
.nav-item.standout {
    border-left: 3px solid #fbbf24;
    background: linear-gradient(90deg, rgba(251,191,36,0.08), transparent);
}
.nav-item.standout .nav-item-title {
    color: #fbbf24;
}
.nav-item.standout .score-bar-fill {
    animation: scorePulse 2s ease-in-out infinite;
}
@keyframes scorePulse {
    0%, 100% { box-shadow: 0 0 4px rgba(251,191,36,0.3); }
    50% { box-shadow: 0 0 12px rgba(251,191,36,0.7); }
}

.nav-item-meta .domain-pill {
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
}

.nav-item-datetime {
    text-align: right;
    line-height: 1.3;
}

.nav-item-time {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Main Content */
.main-content {
    margin-left: 320px;
    width: calc(100% - 320px);
    min-height: 100vh;
    height: 100%;
    position: relative;
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 68, 102, 0.03) 0%, transparent 60%);
    background-attachment: fixed;
    background-size: 200% 200%;
    animation: bgShift 20s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
.welcome-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

#knowledge-graph-canvas, #backrooms-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    cursor: grab;
}
#knowledge-graph-canvas:active { cursor: grabbing; }

.welcome-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at center, rgba(4,2,10,0.2) 0%, rgba(4,2,10,0.6) 100%);
    z-index: 1;
    pointer-events: none;
}

.graph-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(10, 10, 26, 0.92);
    color: #e0e0ff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid rgba(120, 120, 255, 0.3);
    backdrop-filter: blur(4px);
    z-index: 10;
    transition: opacity 0.15s;
    max-width: 220px;
}
.graph-tooltip.tooltip-hidden { opacity: 0; pointer-events: none; }
.graph-tooltip .tooltip-title { font-weight: 600; margin-bottom: 2px; }
.graph-tooltip .tooltip-domain { color: #8888ff; font-size: 11px; }
.graph-tooltip .tooltip-score { color: #fbbf24; font-size: 11px; font-weight: 600; }
.graph-tooltip .tooltip-date { color: #666; font-size: 10px; }

.welcome-content {
    position: relative;
    z-index: 2;
    padding: 60px 40px;
    max-width: 700px;
    pointer-events: none;
}

.welcome-title {
    font-family: var(--font-heading);
    font-size: 6rem;
    font-weight: 900;
    margin: 0 0 10px 0;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #ff4466 0%, #ffcc22 18%, #44ff88 36%, #22ccff 54%, #8844ff 72%, #ff44cc 100%);
    background-size: 300% 300%;
    animation: gradientCycle 6s ease-in-out infinite, textGlow 4s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

@keyframes titleShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.welcome-subtitle {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    letter-spacing: 0.05em;
    background: linear-gradient(90deg, #ffcc22, #8844ff, #22ccff, #ff4466, #ffcc22);
    background-size: 300% 100%;
    animation: gradientCycle 8s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(139, 92, 246, 0.4));
}

@keyframes subtitleShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.welcome-tagline {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-style: italic;
    background: linear-gradient(90deg, #8892a8, #b4a0ff, #8892a8);
    background-size: 200% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 30px 0;
    letter-spacing: 0.08em;
}

.welcome-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    max-width: 620px;
}

.welcome-desc a, .welcome-footer a {
    pointer-events: auto;
    background: linear-gradient(90deg, #22ccff, #8844ff, #ff4466, #22ccff);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 500;
    transition: filter 0.3s;
}

.welcome-desc a:hover, .welcome-footer a:hover {
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
    text-decoration: none;
}

.welcome-footer {
    position: absolute;
    bottom: 20px;
    left: 0; right: 0;
    text-align: center;
    z-index: 2;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
}

.footer-separator {
    margin: 0 6px;
    opacity: 0.4;
}

/* Package View */
.package-view {
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 60px 48px;
    box-sizing: border-box;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.package-header {
    margin-bottom: 48px;
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    backdrop-filter: blur(10px);
}

.domain-tag {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(34, 204, 255, 0.2));
    background-size: 200% 200%;
    animation: gradientCycle 8s ease-in-out infinite;
    color: #b4a0ff;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.date-tag {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.time-tag {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

#pkg-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 40px;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, var(--text-main) 0%, #b4a0ff 30%, #22ccff 60%, var(--text-main) 100%);
    background-size: 300% 100%;
    animation: gradientCycle 10s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Tabs */
.tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 2px solid var(--bg-elevated);
    padding-bottom: 0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: var(--transition);
    position: relative;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-elevated);
}

.tab-btn.active {
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom-color: #8844ff;
}

.tab-content-container {
    padding-top: 40px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Markdown Typography */
.markdown-body {
    font-size: 1.15rem;
    color: var(--text-main);
    max-width: 100%;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    font-family: var(--font-heading);
    color: var(--text-main);
    margin-top: 2.5em;
    margin-bottom: 1em;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.markdown-body h1 {
    font-size: 2.5rem;
    border-bottom: 2px solid var(--bg-elevated);
    padding-bottom: 0.4em;
    margin-top: 0;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #22ccff, #8844ff, #ff4466);
    background-size: 300% 100%;
    animation: gradientCycle 8s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.markdown-body h2 {
    background: linear-gradient(90deg, #8844ff, #22ccff, #8844ff);
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.8rem;
}

.markdown-body h3 {
    background: linear-gradient(90deg, #44ff88, #22ccff, #44ff88);
    background-size: 200% 100%;
    animation: gradientCycle 7s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.4rem;
}

.markdown-body p {
    margin-bottom: 1.6em;
    color: var(--text-main);
    opacity: 0.9;
}

.markdown-body a {
    background: linear-gradient(90deg, #22ccff, #8844ff, #ff4466, #22ccff);
    background-size: 300% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 500;
    transition: filter 0.3s;
    text-decoration: none;
}

.markdown-body h1 .katex, .markdown-body h2 .katex, .markdown-body h3 .katex, .markdown-body h4 .katex, .markdown-body h5 .katex, .markdown-body h6 .katex,
.markdown-body h1 math, .markdown-body h2 math, .markdown-body h3 math, .markdown-body h4 math, .markdown-body h5 math, .markdown-body h6 math,
.markdown-body h1 .MathJax, .markdown-body h2 .MathJax, .markdown-body h3 .MathJax, .markdown-body h4 .MathJax, .markdown-body h5 .MathJax, .markdown-body h6 .MathJax,
.markdown-body a .katex, .markdown-body a math, .markdown-body a .MathJax {
    background: linear-gradient(90deg, #22ccff, #8844ff, #ff4466, #22ccff);
    background-size: 300% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.markdown-body h1 .katex *, .markdown-body h2 .katex *, .markdown-body h3 .katex *, .markdown-body h4 .katex *, .markdown-body h5 .katex *, .markdown-body h6 .katex *,
.markdown-body h1 math *, .markdown-body h2 math *, .markdown-body h3 math *, .markdown-body h4 math *, .markdown-body h5 math *, .markdown-body h6 math *,
.markdown-body h1 .MathJax *, .markdown-body h2 .MathJax *, .markdown-body h3 .MathJax *, .markdown-body h4 .MathJax *, .markdown-body h5 .MathJax *, .markdown-body h6 .MathJax *,
.markdown-body a .katex *, .markdown-body a math *, .markdown-body a .MathJax * {
    background: inherit !important;
    -webkit-background-clip: inherit !important;
    -webkit-text-fill-color: transparent !important;
}

.markdown-body a:hover {
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
}

.markdown-body blockquote {
    border-left: 4px solid transparent;
    border-image: linear-gradient(to bottom, #8844ff, #22ccff, #ff4466) 1;
    margin: 2em 0;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.08) 0%, transparent 100%);
    padding: 20px 24px;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: var(--text-muted);
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body pre {
    background-color: var(--bg-elevated);
    padding: 24px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 2em 0;
    border: 1px solid var(--border-color);
    border-image: initial;
    animation: borderGlow 6s ease-in-out infinite;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(34, 204, 255, 0.1));
    padding: 3px 8px;
    border-radius: 6px;
    color: #c4b5fd;
    -webkit-text-fill-color: initial;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    color: var(--text-main);
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.6em;
    padding-left: 1.5em;
}

.markdown-body li {
    margin-bottom: 0.5em;
}

/* Visualizations Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 32px;
}

.gallery-card {
    background-color: var(--bg-panel);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: var(--shadow-md);
    position: relative;
}

.gallery-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff, #ff44cc);
    background-size: 300% 100%;
    animation: gradientCycle 4s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-card:hover::after {
    opacity: 1;
}

.gallery-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.15), var(--shadow-lg);
    border-color: rgba(139, 92, 246, 0.4);
}

.gallery-img-container {
    width: 100%;
    height: 300px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px;
}

body.dark-theme .gallery-img-container {
    background-color: #ffffff;
}

body.light-theme .gallery-img-container {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.gallery-img-container img, .gallery-img-container svg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-info {
    padding: 24px;
}

.gallery-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--text-main), #b4a0ff, var(--text-main));
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Code & Algorithms Blocks */
.code-card {
    background-color: var(--bg-panel);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: borderGlow 8s ease-in-out infinite;
}

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

.code-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    background: linear-gradient(90deg, #22ccff, #8844ff, #22ccff);
    background-size: 200% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.code-card pre {
    margin: 0;
    padding: 24px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    background-color: var(--bg-panel);
    white-space: pre;
}

.code-card pre code {
    white-space: pre;
}

/* Lean proof cards — collapsible code blocks */
.code-container {
    background-color: var(--bg-panel);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: borderGlow 8s ease-in-out infinite;
}

body.light-theme .code-container {
    animation: none;
}

.code-container pre {
    margin: 0;
    padding: 24px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    background-color: var(--bg-panel);
    white-space: pre;
    overflow-y: auto;
}

body.light-theme .code-container pre {
    background-color: #f8fafc;
}

.code-container pre code {
    white-space: pre;
}

/* Interactive Runner */
.run-btn {
    background: linear-gradient(135deg, #8844ff, #22ccff);
    background-size: 200% 200%;
    animation: gradientCycle 4s ease-in-out infinite;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: filter 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.run-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.run-btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    animation: none;
    background-size: auto;
}

.lean-download-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: filter 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.lean-download-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
}

.code-editor {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-height: 300px;
    height: auto;
    padding: 20px 24px;
    background-color: var(--bg-panel);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-radius: 0;
    box-sizing: border-box;
    outline: none;
    resize: vertical;
    tab-size: 4;
}

.code-editor.collapsed {
    display: none;
}

.code-editor:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background-color: var(--bg-elevated);
}

body.light-theme .code-editor {
    background-color: #f8fafc;
    color: #0f172a;
    border-color: #e2e8f0;
}

body.light-theme .code-editor:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background-color: #ffffff;
}

.code-output {
    background-color: var(--bg-elevated);
    margin: 0 !important;
    border-top: 1px solid var(--border-color);
    color: var(--text-main);
    white-space: pre-wrap;
    min-height: 60px;
}

.code-output.error {
    color: #fca5a5 !important;
}

body.light-theme .code-output {
    background-color: var(--bg-elevated);
    color: var(--text-main);
}

body.light-theme .code-output.error {
    color: #dc2626 !important;
}

/* Visualization containers */
.viz-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.viz-container:hover {
    border-color: var(--accent-color, #7c3aed);
}

.viz-description {
    margin: 4px 0 8px;
    color: var(--text-muted);
    font-size: 0.9em;
}

.viz-generate-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%) !important;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
    transition: all 0.3s ease;
}

.viz-generate-btn:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.viz-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-style: italic;
}

.source-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82em;
    font-family: var(--font-sans);
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.source-toggle:hover {
    color: var(--text-main);
    border-color: var(--accent-color, #7c3aed);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(34, 204, 255, 0.1));
}

/* Interactive HTML demo frames */
.interactive-demo-frame {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.section-title {
    margin-bottom: 16px;
    color: var(--accent-color, #7c3aed);
    font-size: 1.2em;
    font-weight: 600;
}

/* KaTeX tweaks for light/dark mode */
.katex {
    color: var(--text-main);
    -webkit-text-fill-color: initial;
}

.code-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.gallery-img-container.viz-output-container {
    height: auto;
    min-height: 100px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.gallery-img-container.viz-output-container img {
    max-width: 100%;
    max-height: none;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        position: relative;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: 300px;
        max-width: 85vw;
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
        z-index: 300;
    }

    body.light-theme .sidebar {
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }

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

    /* Floating mobile menu button */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 250;
        width: 48px;
        height: 48px;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background-color: var(--bg-panel);
        backdrop-filter: blur(12px);
        cursor: pointer;
        gap: 5px;
        box-shadow: var(--shadow-md);
        transition: var(--transition);
    }

    .mobile-menu-btn:hover {
        background-color: var(--bg-elevated);
        border-color: var(--accent-primary);
    }

    .mobile-menu-btn span {
        display: block;
        width: 22px;
        height: 2px;
        background-color: var(--text-main);
        border-radius: 2px;
        transition: var(--transition);
    }

    /* Animate hamburger to X */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-btn.active span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Overlay behind sidebar on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 290;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.visible {
        display: block;
    }

    /* Hide the old mobile-toggle inside the sidebar header */
    .mobile-toggle {
        display: none !important;
    }

    .package-view {
        padding: 40px 20px;
    }

    .package-header {
        padding-top: 48px;
    }

    #pkg-title {
        font-size: 1.8rem;
    }

    .tabs-container {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        border-bottom: 2px solid var(--bg-elevated);
        padding-bottom: 4px;
    }

    .tabs-container::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .welcome-content {
        padding: 40px 20px;
    }

    .welcome-content h1 {
        font-size: 2rem;
    }

    .markdown-body {
        font-size: 1rem;
        overflow-x: auto;
    }

    .markdown-body h1 { font-size: 1.8rem; }
    .markdown-body h2 { font-size: 1.4rem; }
    .markdown-body h3 { font-size: 1.2rem; }

    .markdown-body table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .code-card pre {
        font-size: 0.82rem;
        padding: 16px;
    }

    .meta-tags {
        gap: 8px;
    }

    .tag {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    /* Mobile-responsive styles for code execution & interactive elements */
    .code-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 16px;
    }

    .code-header-buttons {
        width: 100%;
        justify-content: flex-end;
    }

    .code-editor {
        padding: 12px 16px;
        font-size: 0.85rem;
        min-height: 200px;
    }

    .code-output {
        padding: 12px 16px !important;
        font-size: 0.82rem;
    }

    .gallery-img-container.viz-output-container {
        padding: 12px;
    }
}

/* Very small screens (< 400px) */
@media (max-width: 400px) {
    .sidebar {
        width: 280px;
    }

    #pkg-title {
        font-size: 1.5rem;
    }

    .tab-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .welcome-content h1 {
        font-size: 1.6rem;
    }

    .package-view {
        padding: 24px 16px;
    }

    .gallery-img-container {
        height: 200px;
    }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Lightbox Modal */
.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.lightbox-content {
    position: relative;
    width: 90vw;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-img-container {
    width: 100%;
    max-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
    box-sizing: border-box;
}

.lightbox-img-container img, .lightbox-img-container svg {
    width: 100%;
    max-height: 75vh;
    object-fit: contain;
    display: block;
}

.lightbox-img-container img[src$=".svg"] {
    width: 100%;
    height: auto;
    max-height: 75vh;
}

.lightbox-caption {
    margin-top: 20px;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: -50px;
    background: none;
    border: none;
    color: #fff;
    font-size: 3rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}
.lightbox-close:hover { color: var(--accent-primary); }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 4rem;
    line-height: 1;
    padding: 0 15px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    user-select: none;
    backdrop-filter: blur(5px);
}

.lightbox-nav:hover { background: rgba(255,255,255,0.2); color: var(--accent-primary); }
.lightbox-prev { left: -80px; }
.lightbox-next { right: -80px; }

@media (max-width: 768px) {
    .lightbox-nav { font-size: 2.5rem; padding: 0 10px; }
    .lightbox-prev { left: -40px; }
    .lightbox-next { right: -40px; }
    .lightbox-close { right: 0; top: -50px; }
}

/* ── Future Directions Nav Link ── */

.nav-directions-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    margin-bottom: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-directions-link:hover {
    background: var(--bg-elevated);
}

.nav-directions-link.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(34, 204, 255, 0.3));
    color: #fff;
}

.nav-directions-link svg {
    flex-shrink: 0;
}

/* ── Directions View ── */

.directions-view {
    padding: 24px;
    max-width: 100%;
    margin: 0;
    animation: fadeIn 0.3s ease;
}

.directions-header {
    margin-bottom: 24px;
}

.directions-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff, #ff44cc);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 4px 0;
}

.directions-subtitle {
    background: linear-gradient(90deg, #8892a8, #b4a0ff, #8892a8);
    background-size: 200% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 0.95rem;
    margin: 0 0 20px 0;
}

.directions-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.directions-filters select,
.directions-filters input {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
}

.directions-filters select:focus,
.directions-filters input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.directions-filters input {
    flex: 1;
    min-width: 200px;
}

.directions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.directions-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 0.95rem;
}

.direction-card {
    background: var(--bg-elevated);
    border-radius: 8px;
    padding: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: default;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.direction-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff, #ff44cc);
    background-size: 300% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.direction-card:hover::before {
    opacity: 1;
}

.direction-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.12), var(--shadow-md);
    border-color: rgba(139, 92, 246, 0.3);
}

.direction-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.direction-card-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    transition: all 0.3s ease;
}

.direction-card:hover .direction-card-title {
    background: linear-gradient(90deg, #ff4466, #ffcc22, #44ff88, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 4s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.direction-card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.direction-priority-badge,
.direction-status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    color: #fff;
    white-space: nowrap;
}

.direction-priority-badge {
    background: linear-gradient(135deg, #8844ff, #22ccff);
    background-size: 200% 200%;
    animation: gradientCycle 6s ease-in-out infinite;
}

.direction-status-badge {
    background: linear-gradient(135deg, #44ff88, #22ccff);
    background-size: 200% 200%;
    animation: gradientCycle 5s ease-in-out infinite;
}

.direction-card-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.direction-domain-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-panel);
    color: var(--text-muted);
    white-space: nowrap;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.direction-card:hover .direction-domain-tag {
    border-color: rgba(139, 92, 246, 0.3);
    color: #b4a0ff;
}

.direction-card-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0 0 8px 0;
}

.direction-card-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.direction-card-full-desc {
    color: var(--text-main);
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 0 0 8px 0;
}

.direction-detail-row {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.direction-detail-row strong {
    color: var(--text-main);
}

.direction-card-expand {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.direction-card-expand:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(34, 204, 255, 0.2));
    border-color: rgba(139, 92, 246, 0.5);
}

/* ── Author Profile Popover ── */

.author-popover {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    width: 340px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: popoverFadeIn 0.2s ease;
}

@keyframes popoverFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.author-popover-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.author-popover-close:hover {
    color: var(--text-main);
}

.author-popover-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    background: var(--bg-panel);
    transition: background 0.2s;
}

.author-popover-header:hover {
    background: var(--border-color);
}

.author-popover-extlink {
    margin-left: auto;
    color: var(--text-muted);
    flex-shrink: 0;
}

.author-popover-header:hover .author-popover-extlink {
    color: var(--accent-primary);
}

.author-popover-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.author-popover-info h3 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    background: linear-gradient(90deg, #ff4466, #ffcc22, #22ccff, #8844ff);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.author-popover-handle {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.author-popover-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.author-popover-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--bg-panel);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background 0.2s, color 0.2s;
}

.author-popover-link:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.8), rgba(34, 204, 255, 0.8));
    color: #fff;
}

.author-popover-link svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .author-popover {
        width: calc(100vw - 32px);
        bottom: 48px;
    }
}

@media (max-width: 768px) {
    .directions-view {
        padding: 16px;
    }

    .directions-header h1 {
        font-size: 1.4rem;
    }

    .directions-filters {
        flex-direction: column;
    }

    .directions-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Light theme overrides for gradient elements ── */
/* In light mode, use vibrant gradients that contrast well on white backgrounds. */
body.light-theme .nav-item:hover .nav-item-title,
body.light-theme .nav-item.active .nav-item-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #2563eb);
    background-clip: text;
}

body.light-theme .markdown-body h1,
body.light-theme .markdown-body h2,
body.light-theme .markdown-body h3 {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #1e293b, #7c3aed, #1e293b);
    background-size: 200% 100%;
    background-clip: text;
}

body.light-theme .markdown-body a {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    background-clip: text;
}

body.light-theme .direction-card:hover .direction-card-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #0284c7);
    background-clip: text;
}

body.light-theme .tabs-container {
    border-bottom-color: var(--border-color);
}

body.light-theme .tab-btn {
    color: #475569;
    background: rgba(241, 245, 249, 0.5);
}

body.light-theme .tab-btn:hover {
    color: #1e293b;
    background-color: #e2e8f0;
}

body.light-theme .tab-btn.active {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #2563eb);
    background-clip: text;
    border-bottom-color: #7c3aed;
}

body.light-theme .tab-content-container {
    background-color: transparent;
}

body.light-theme #pkg-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #dc2626, #0284c7);
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .welcome-title,
body.light-theme .welcome-subtitle,
body.light-theme .welcome-tagline {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #dc2626, #0284c7);
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .sidebar-header h2 {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(135deg, #7c3aed, #0284c7);
    background-clip: text;
}

body.light-theme .sidebar-header h2 a {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(135deg, #7c3aed, #0284c7);
    background-clip: text;
}

body.light-theme .directions-header h1 {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #0284c7, #7c3aed);
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .code-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #0284c7, #7c3aed);
    background-clip: text;
}

body.light-theme .gallery-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #1e293b, #7c3aed, #1e293b);
    background-size: 200% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .direction-priority-badge {
    background: linear-gradient(135deg, #7c3aed, #0284c7);
    color: #fff;
    -webkit-text-fill-color: #fff;
}

body.light-theme .direction-status-badge {
    background: linear-gradient(135deg, #16a34a, #0284c7);
    color: #fff;
    -webkit-text-fill-color: #fff;
}

body.light-theme .domain-tag {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(2, 132, 199, 0.15));
    color: #7c3aed;
    -webkit-text-fill-color: #7c3aed;
}

body.light-theme .run-btn {
    background: linear-gradient(135deg, #7c3aed, #0284c7);
    color: #fff;
    -webkit-text-fill-color: #fff;
    animation: none;
    background-size: auto;
}

body.light-theme .lean-download-btn {
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    -webkit-text-fill-color: #fff;
}

body.light-theme .welcome-desc a,
body.light-theme .welcome-footer a {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #2563eb, #7c3aed, #dc2626);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .welcome-desc a:hover,
body.light-theme .welcome-footer a:hover {
    filter: brightness(1.2);
}

body.light-theme .author-popover-link:hover {
    background: linear-gradient(135deg, #7c3aed, #0284c7);
    color: #fff;
    -webkit-text-fill-color: #fff;
}

body.light-theme .author-popover-info h3 {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #dc2626, #eab308, #0284c7, #7c3aed);
    background-size: 300% 100%;
    animation: gradientCycle 6s ease-in-out infinite;
    background-clip: text;
}

body.light-theme #aether-toast .toast-title {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #0284c7, #7c3aed, #dc2626);
    background-clip: text;
}

body.light-theme .lightbox-caption {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #7c3aed, #0284c7);
    background-clip: text;
}

body.light-theme .directions-subtitle {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(90deg, #64748b, #7c3aed, #64748b);
    background-size: 200% 100%;
    animation: gradientCycle 5s ease-in-out infinite;
    background-clip: text;
}

body.light-theme .welcome-overlay {
    background: radial-gradient(ellipse at center, rgba(248, 250, 252, 0.2) 0%, rgba(241, 245, 249, 0.5) 100%);
}

body.light-theme .nav-item.graph-highlight {
    background-color: rgba(124, 58, 237, 0.08);
    border-left: 3px solid rgba(124, 58, 237, 0.6);
    box-shadow: none;
}

body.light-theme .nav-item.graph-highlight .nav-item-title {
    color: var(--accent-secondary);
}

body.light-theme .graph-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    border: 1px solid var(--border-color);
}

body.light-theme .app-container::before {
    background:
        radial-gradient(ellipse at 10% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(2, 132, 199, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(220, 38, 38, 0.03) 0%, transparent 60%);
}

body.light-theme .main-content {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    animation: none;
}

body.light-theme .sidebar {
    animation: none;
    border-right-color: var(--border-color);
}

body.light-theme .direction-card {
    border-color: var(--border-color);
}

body.light-theme .direction-card:hover {
    border-color: rgba(124, 58, 237, 0.3);
}

body.light-theme .markdown-body blockquote {
    border-left-color: transparent;
    border-image: linear-gradient(to bottom, #7c3aed, #0284c7, #dc2626) 1;
}

body.light-theme .markdown-body code {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(2, 132, 199, 0.08));
    color: #7c3aed;
    -webkit-text-fill-color: #7c3aed;
}

body.light-theme .code-card {
    animation: none;
}

body.light-theme .gallery-card::after {
    background: linear-gradient(90deg, #dc2626, #eab308, #16a34a, #0284c7, #7c3aed, #db2777);
}

body.light-theme .gallery-card:hover {
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.1), var(--shadow-lg);
    border-color: rgba(124, 58, 237, 0.3);
}

body.light-theme .tooltip-domain {
    color: var(--accent-secondary);
}

body.light-theme .tooltip-score {
    color: #d97706;
}

body.light-theme .tooltip-date {
    color: var(--text-muted);
}

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

/* ─── Toast Notification ─── */

#aether-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    max-width: 360px;
    padding: 16px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15), var(--shadow-lg);
    cursor: pointer;
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    backdrop-filter: blur(12px);
}

#aether-toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

#aether-toast .toast-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    background: linear-gradient(90deg, #22ccff, #8844ff, #ff4466);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

#aether-toast .toast-body {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    white-space: pre-line;
}

#aether-toast:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.25), var(--shadow-lg);
}

body.light-theme #aether-toast {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1), 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

body.light-theme #aether-toast .toast-body {
    color: #6b7280;
}
/* Future Directions tab — narrative section */
.directions-narrative {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.directions-section-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 1rem;
}

.view-all-directions-link {
    display: block;
    text-align: center;
    padding: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    margin-top: 0.5rem;
}

.view-all-directions-link:hover {
    text-decoration: underline;
}

.directions-package-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0 1rem;
}

/* Algorithms merged into Demos tab — separator */
.tab-pane .algorithms-list {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Lineage links in Future Directions tab */
.directions-lineage {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.lineage-chain {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.lineage-section {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
}

.lineage-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lineage-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.lineage-link:hover {
    text-decoration: underline;
}

.lineage-sep {
    color: var(--text-muted);
    margin: 0 0.15rem;
}

/* Sidebar sort and pagination controls */
.sidebar-controls {
    padding: 8px 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-controls select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.sidebar-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    background: var(--bg-panel);
    z-index: 10;
}

.page-btn {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.85rem;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.page-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
}

#page-indicator {
    color: var(--text-muted);
    font-size: 0.8rem;
    min-width: 60px;
    text-align: center;
}
