/* ===== Theme Integration with Site Theme System ===== */
/* Maps to data-theme attribute on html element */

:root,
[data-theme="dark"] {
  --bg: #0f1220;
  --card: #171a2b;
  --text: #e8ecff;
  --muted: #b9c1ffcc;
  --accent: #7aa2ff;
  --accent-2: #d87bff;
  --border: #2a2f4a;
  --code-bg: #0b0e1a;
  --green: #6ee7b7;
  --yellow: #facc15;
  --red: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --container: 1080px;
  --header-h: 72px;
  --toc-w-expanded: 280px;
  --toc-w-collapsed: 44px;
  
  /* SVG diagram variables - dark theme */
  --svg-node-bg: #0e1326;
  --svg-node-stroke: #233045;
  --svg-node-hover: rgba(26,29,50,0.9);
  --svg-node-stroke-hover: #3a4470;
  --svg-text: #e6eaff;
  --svg-text-muted: #c7d0e8;
  --svg-legend-bg: rgba(23,26,43,.9);
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #555566cc;
  --accent: #4a7cd4;
  --accent-2: #9b59b6;
  --border: #d0d4dc;
  --code-bg: #f8fafc;  /* Light code background for light theme */
  --green: #2ecc71;
  --yellow: #f1c40f;
  --red: #e74c3c;
  --shadow: 0 10px 30px rgba(0,0,0,.1);
  
  /* SVG diagram variables - light theme */
  --svg-node-bg: #ffffff;
  --svg-node-stroke: rgba(74,124,212,0.3);
  --svg-node-hover: #f8fafc;
  --svg-node-stroke-hover: #4a7cd4;
  --svg-text: #1a1a2e;
  --svg-text-muted: #4b5563;
  --svg-legend-bg: rgba(248,250,252,.95);
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding-top: 80px; /* Space for fixed main navbar */
}

/* Ensure main navbar menu stays above sidebar backdrop on mobile */
.navbar {
  z-index: 1000 !important;
}

.nav-menu {
  z-index: 1001 !important;
}

/* ===== Global Custom Scrollbar ===== */
/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 162, 255, 0.5) transparent;
}

[data-theme="light"] {
  scrollbar-color: rgba(74, 124, 212, 0.5) transparent;
}

/* WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  border: 2px solid var(--bg);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8ab2ff, #e08bff);
  border: 2px solid var(--bg);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Light theme scrollbar adjustments */
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a7cd4, #9b59b6);
  border: 2px solid var(--bg);
  background-clip: padding-box;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #5a8ce4, #ab69c6);
  border: 2px solid var(--bg);
  background-clip: padding-box;
}

[data-theme="light"]::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a7cd4, #7c3aed);
  border: 3px solid var(--bg);
}

[data-theme="light"]::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #3a6cc4, #6c2add);
}

/* ===== CRITICAL FIX: Override main site's decorative classes =====
   Main site CSS uses .note for floating orange musical notes
   and .code for floating code snippets on the homepage.
   These conflict with actual content classes on this course page. */

.note,
p.note,
figcaption.note {
  position: static !important;
  animation: none !important;
  opacity: 1 !important;
  font-size: inherit !important;
  color: var(--accent) !important;
  text-shadow: none !important;
  filter: none !important;
  font-weight: normal !important;
  transform: none !important;
}

.code,
pre.code,
div.code {
  position: relative !important;
  animation: none !important;
  opacity: 1 !important;
  -webkit-text-fill-color: inherit !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  background: var(--code-bg) !important;
  color: var(--text) !important;
  transform: none !important;
}

[data-theme="dark"] body {
  background: radial-gradient(1200px 600px at 20% -10%, #1a1e33 0%, #0f1220 60%) fixed, var(--bg);
}

[data-theme="light"] body {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ed 100%) fixed;
}

body.modal-open{ overflow: hidden; }

/* Ensure all content has solid backgrounds to prevent bleed-through */
.card,
.http-figure,
section[id],
article[id] {
  position: relative;
}

/* Fix for floating text bug - ensure figcaption stays in place */
figcaption,
figcaption.note {
  position: relative !important;
  z-index: 1;
  background: inherit;
  transform: none !important;
  animation: none !important;
}

/* Ensure .note elements don't have weird rendering */
.note {
  position: relative;
  z-index: 1;
  contain: layout style paint;
}

/* Force http-figure to contain all children */
.http-figure {
  contain: layout style;
  overflow: visible;
}

.container{ max-width: var(--container); margin: 0 auto; padding: 0 20px; }

/* Fixed Language Toggle Button - above theme changer */
.language-toggle-btn {
  position: fixed;
  bottom: calc(2rem + 50px);
  right: 2rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 80px;
  height: 40px;
  background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
  backdrop-filter: blur(10px);
  border: 2px solid var(--accent);
  border-radius: 50px;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 
    inset 0 2px 8px rgba(0, 0, 0, 0.3),
    0 4px 12px rgba(139, 92, 246, 0.3);
}

.language-toggle-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.language-toggle-btn:active {
  transform: scale(0.95);
}

.language-toggle-btn .lang-flag {
  font-size: 1rem;
  line-height: 1;
}

.language-toggle-btn .lang-code {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Light theme */
[data-theme="light"] .language-toggle-btn {
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  border-color: var(--accent);
  color: #1a1a2e;
  box-shadow: 
    inset 0 2px 8px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .language-toggle-btn:hover {
  box-shadow: 0 6px 20px rgba(74, 124, 212, 0.4);
}

/* RTL Support - keep on right side */
html[dir="rtl"] .language-toggle-btn {
  right: 20px;
  left: auto;
}

html[dir="rtl"] .site-header .container {
  direction: rtl;
}

html[dir="rtl"] .sidebar-link svg {
  transform: scaleX(-1);
}

html[dir="rtl"] .flow-arrow {
  transform: scaleX(-1);
}

@media (max-width: 640px) {
  .language-toggle-btn {
    bottom: 70px;
    right: 15px;
    padding: 8px 10px;
    font-size: 12px;
  }
  
  .language-toggle-btn .lang-flag {
    font-size: 1.1rem;
  }
}

/* Course-specific header - directly below main navbar */
.site-header{
  position: relative;
  z-index: 10;
  background: rgba(15,18,32,.98); 
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin-top: 0;
}

[data-theme="light"] .site-header {
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid #e0e0e0;
}

/* Light theme footer */
[data-theme="light"] .footer {
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
}

[data-theme="light"] .footer-logo {
  background: linear-gradient(135deg, #4a7cd4 0%, #7aa2ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .footer-tagline {
  color: #555;
}

[data-theme="light"] .footer-course-subtitle {
  color: #777;
}

[data-theme="light"] .footer-column h4 {
  color: #333;
}

[data-theme="light"] .footer-column a {
  color: #666;
}

[data-theme="light"] .footer-column a:hover {
  color: #4a7cd4;
}

[data-theme="light"] .footer-bottom {
  border-top: 1px solid #e0e0e0;
  color: #888;
}

.site-header .container{ 
  position: relative;
  padding: 24px 20px; 
}

/* Course title and subtitle */
.site-header h1 { 
  margin: 0 0 8px; 
  font-size: clamp(24px, 2.6vw, 36px); 
  letter-spacing: .2px;
  color: var(--text);
}

.site-header .subtitle { 
  margin: 0 0 16px; 
  color: var(--muted);
  font-size: 1rem;
}
/* Mobile TOC toggle (shown on small screens) */
.mobile-toc-toggle{
  display: none;
  margin-top: 10px;
  appearance: none; border:1px solid var(--border); border-radius:10px;
  background: linear-gradient(180deg, #252a45, #1a1f36);
  color:#c7d2fe; font-size: 13px; padding: 7px 12px; cursor: pointer;
}

[data-theme="light"] .mobile-toc-toggle {
  background: linear-gradient(180deg, #ffffff, #f0f2f5);
  color: #4a5568;
}

.mobile-toc-toggle[aria-expanded="false"]{ color:#e8ecff; }

/* ===================================
   SIDEBAR NAVIGATION
   =================================== */

.sidebar-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: #111827;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
}

[data-theme="dark"] .sidebar-mobile-toggle {
    color: #f3f4f6;
}

.sidebar-mobile-toggle:hover {
    color: var(--accent);
}

/* Sidebar backdrop for mobile - only visible when sidebar is open */
.sidebar-backdrop {
    display: none;
}

/* Only show backdrop when body has sidebar-open class */
body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 80px;
    left: 280px; /* Start after the sidebar */
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.workshop-sidebar {
    position: fixed;
    top: 80px;
    left: 0;
    width: 280px;
    height: calc(100vh - 80px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.04);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 200;
    padding: 1.5rem 0;
    transition: transform 0.3s ease;
}

[data-theme="dark"] .workshop-sidebar {
    background: linear-gradient(180deg, rgba(15, 18, 32, 0.98) 0%, rgba(10, 12, 24, 0.98) 100%);
    border-right-color: rgba(122, 162, 255, 0.1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
}

/* Scrollbar styling - Firefox */
.workshop-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(122, 162, 255, 0.3) transparent;
}

[data-theme="light"] .workshop-sidebar {
    scrollbar-color: rgba(74, 124, 212, 0.3) transparent;
}

/* Scrollbar styling - WebKit (Chrome, Safari, Edge) */
.workshop-sidebar::-webkit-scrollbar {
    width: 8px;
}

.workshop-sidebar::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}

.workshop-sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(122, 162, 255, 0.4), rgba(216, 123, 255, 0.3));
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.workshop-sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(122, 162, 255, 0.6), rgba(216, 123, 255, 0.5));
    background-clip: padding-box;
}

/* Light mode scrollbar */
[data-theme="light"] .workshop-sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(74, 124, 212, 0.4), rgba(155, 89, 182, 0.3));
    background-clip: padding-box;
}

[data-theme="light"] .workshop-sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(74, 124, 212, 0.6), rgba(155, 89, 182, 0.5));
    background-clip: padding-box;
}

.sidebar-header {
    padding: 0 1.5rem 1.25rem;
    border-bottom: 2px solid rgba(122, 162, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.05), transparent);
    margin: -1.5rem -0rem 0;
    padding-top: 1.5rem;
}

[data-theme="dark"] .sidebar-header {
    border-bottom-color: rgba(122, 162, 255, 0.3);
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.08), transparent);
}

/* Course info section */
.sidebar-course-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
}

.sidebar-course-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: rgba(122, 162, 255, 0.15);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    width: fit-content;
}

.sidebar-course-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
    line-height: 1.3;
}

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
    color: var(--muted);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

[data-theme="dark"] .sidebar-header h3 {
    color: var(--muted);
}

.sidebar-nav {
    padding: 1.25rem 0;
}

/* Back to Teaching link */
.sidebar-link.back-to-course {
    margin: 0 1rem 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.1), rgba(122, 162, 255, 0.05));
    border: 1px solid rgba(122, 162, 255, 0.2);
    border-radius: 12px;
    border-left: 3px solid var(--accent);
    font-weight: 600;
    gap: 0.625rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(122, 162, 255, 0.08);
}

[data-theme="light"] .sidebar-link.back-to-course {
    background: linear-gradient(135deg, rgba(74, 124, 212, 0.08), rgba(74, 124, 212, 0.04));
    border-color: rgba(74, 124, 212, 0.2);
}

.sidebar-link.back-to-course:hover {
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.18), rgba(122, 162, 255, 0.12));
    border-color: rgba(122, 162, 255, 0.5);
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(122, 162, 255, 0.2);
}

.sidebar-link.back-to-course i {
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.sidebar-link.back-to-course:hover i {
    transform: translateX(-3px);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.5rem;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
}

[data-theme="dark"] .sidebar-link {
    color: #9ca3af;
}

.sidebar-link:hover {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.1), transparent);
    color: var(--accent);
    border-left-color: rgba(122, 162, 255, 0.4);
    padding-left: 1.75rem;
}

[data-theme="dark"] .sidebar-link:hover {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.18), transparent);
    color: #a5b4fc;
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.15), transparent);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
    padding-left: 1.75rem;
}

/* Active indicator glow */
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent), 0 0 20px rgba(122, 162, 255, 0.3);
    border-radius: 0 2px 2px 0;
}

[data-theme="dark"] .sidebar-link.active {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.22), transparent);
    color: #a5b4fc;
}

.sidebar-link .link-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #e5e7eb, #f3f4f6);
    color: #374151;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sidebar-link .link-number {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sidebar-link:hover .link-number {
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.2), rgba(122, 162, 255, 0.1));
    color: var(--accent);
    transform: scale(1.05);
}

[data-theme="dark"] .sidebar-link:hover .link-number {
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.3), rgba(122, 162, 255, 0.15));
    color: #a5b4fc;
}

.sidebar-link.active .link-number {
    background: linear-gradient(135deg, var(--accent), #5a8ff0);
    color: white;
    box-shadow: 0 3px 10px rgba(122, 162, 255, 0.4);
    transform: scale(1.05);
}

[data-theme="dark"] .sidebar-link.active .link-number {
    background: linear-gradient(135deg, var(--accent), #5a8ff0);
    box-shadow: 0 3px 12px rgba(122, 162, 255, 0.5);
}

.sidebar-section {
    margin: 1.5rem 0;
}

.sidebar-section .section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
}

.sidebar-section .section-title .section-icon {
    font-size: 1.1rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Section title decorative line */
.sidebar-section .section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.2), transparent);
    margin-left: 0.5rem;
}

[data-theme="dark"] .sidebar-section .section-title {
    color: #9ca3af;
}

[data-theme="dark"] .sidebar-section .section-title::after {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.3), transparent);
}

/* Module links (other pages) */
.sidebar-link.module-link {
    padding-left: 1.5rem;
    font-size: 0.9rem;
    color: #6b7280;
    position: relative;
}

[data-theme="dark"] .sidebar-link.module-link {
    color: #9ca3af;
}

.sidebar-link.module-link:hover {
    color: var(--accent);
    padding-left: 1.75rem;
}

.sidebar-link.module-link .link-emoji {
    font-size: 1rem;
}

.sidebar-footer {
    border-top: 1px solid rgba(122, 162, 255, 0.15);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    background: linear-gradient(180deg, transparent, rgba(122, 162, 255, 0.03));
}

[data-theme="dark"] .sidebar-footer {
    border-top-color: rgba(122, 162, 255, 0.2);
    background: linear-gradient(180deg, transparent, rgba(122, 162, 255, 0.05));
}

/* Module indicators with pulsing effect */
.module-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
    transition: all 0.3s ease;
}

.sidebar-link:hover .module-indicator {
    transform: scale(1.2);
    box-shadow: 0 0 10px currentColor;
}

.module-indicator.module-js { 
    background: linear-gradient(135deg, #fbbf24, #f59e0b); 
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}
.module-indicator.module-browser { 
    background: linear-gradient(135deg, #3b82f6, #2563eb); 
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}
.module-indicator.module-node { 
    background: linear-gradient(135deg, #22c55e, #16a34a); 
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* ===================================
   MAIN CONTENT LAYOUT WITH SIDEBAR
   =================================== */

.course-layout {
    display: flex;
    min-height: calc(100vh - 80px);
}

.course-main {
    margin-left: 280px;
    flex: 1;
    min-width: 0;
    padding: 2rem 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar-mobile-toggle {
        display: flex;
        position: fixed;
        top: 92px;
        left: 1rem;
        z-index: 101;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: var(--card);
        border: 1px solid var(--border);
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    
    .workshop-sidebar {
        transform: translateX(-100%);
    }
    
    .workshop-sidebar.active {
        transform: translateX(0);
    }
    
    .course-main {
        margin-left: 0;
        padding: 1.5rem 0;
    }
    
    body.sidebar-open {
        overflow: hidden;
    }
}

/* Course section navigation */
.site-nav{ margin-top: 10px; display:flex; gap: 10px; flex-wrap: wrap; }
.site-nav a{ color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; border: 1px solid transparent; transition: all 0.2s ease; }
.site-nav a:hover{ color: var(--accent); background: rgba(122,162,255,.08); border-color: var(--border); }
.site-nav a[aria-current="page"]{ color: var(--accent); background: rgba(122,162,255,.12); border-color: var(--accent); }

.toc{ margin: 24px auto; background: rgba(23,26,43,.7); border:1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }

[data-theme="light"] .toc {
  background: rgba(255,255,255,.9);
}

.toc h2{ margin:0 0 8px; font-size: 18px; color: var(--muted); }
.toc ol{ margin:0; padding-left: 18px; }
.toc a{ color: var(--accent); text-decoration: none; }
.toc a:hover{ text-decoration: underline; }

.content{ display:block; gap: 22px; }
.card{
  background: linear-gradient(180deg, rgba(26,29,50,.7), rgba(19,22,38,.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  box-shadow: var(--shadow);
  animation: floatIn .5s ease;
}

[data-theme="light"] .card {
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(250,250,252,.9));
}

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

h2{ margin-top:0; font-size: clamp(20px, 2.2vw, 28px);}
h3{ margin-top:18px; font-size: clamp(18px, 2vw, 22px);}
h4{ margin-top:14px; font-size: 16px; color: var(--muted); }

.code{
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  padding-top: 40px; /* Space for buttons */
  overflow: visible; /* Allow buttons to be visible */
  margin: 10px 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px;
}
.code code{ 
  color: var(--text);
  display: block;
  overflow-x: auto; /* Scroll code content only */
}

/* Copy and Try-it buttons - positioned top-right inside code block */
.code .copy, 
.code .try-it,
pre.code > .copy,
pre.code > .try-it {
  position: absolute !important; 
  top: 8px !important;
  background: linear-gradient(180deg, #252a45, #1a1f36);
  color: #c7d2fe;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

[data-theme="light"] .code .copy,
[data-theme="light"] .code .try-it,
[data-theme="light"] pre.code > .copy,
[data-theme="light"] pre.code > .try-it {
  background: linear-gradient(180deg, #ffffff, #e2e8f0);
  color: #475569;
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.code .copy,
pre.code > .copy { 
  right: 8px !important; 
}

.code .copy:hover,
pre.code > .copy:hover {
  background: linear-gradient(180deg, #2d3454, #1f2640);
  transform: translateY(-1px);
}

[data-theme="light"] .code .copy:hover,
[data-theme="light"] pre.code > .copy:hover {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-color: #94a3b8;
}

.code .try-it,
pre.code > .try-it { 
  right: 65px !important; 
  background: linear-gradient(180deg, #065f46, #064e3b);
  color: #a7f3d0;
  font-weight: 600;
}

[data-theme="light"] .code .try-it,
[data-theme="light"] pre.code > .try-it {
  background: linear-gradient(180deg, #10b981, #059669);
  color: #ffffff;
  border-color: #059669;
}

.code .try-it:hover,
pre.code > .try-it:hover { 
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

[data-theme="light"] .code .try-it:hover,
[data-theme="light"] pre.code > .try-it:hover {
  box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}

.code .copy.copied,
pre.code > .copy.copied { 
  outline: 2px solid var(--green); 
}

.note, .warn{
  border-left: 4px solid var(--accent);
  background: rgba(122,162,255,.08);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0 14px;
}
.warn{
  border-left-color: var(--red);
  background: rgba(248,113,113,.08);
}

/* Diagram wrapper - Enhanced visual container */
.diagram-wrapper{
  position: relative;
  margin: 24px 0;
  padding: 32px 20px;
  background: linear-gradient(135deg, rgba(15,18,32,0.6), rgba(26,29,50,0.4));
  border: 1px solid rgba(122,162,255,0.15);
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3),
              inset 0 1px 0 rgba(255,255,255,0.03);
  backdrop-filter: blur(10px);
}

.diagram-wrapper::before{
  content: '';
  position: absolute;
  inset: 0;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(122,162,255,0.02) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(122,162,255,0.02) 20px);
  pointer-events: none;
  border-radius: 16px;
  opacity: 0.5;
}

.diagram-dom{
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.2));
  transition: opacity 0.6s ease;
}

@media (max-width: 760px){
  .diagram-wrapper{
    padding: 20px 12px;
    overflow-x: scroll;
  }
  .diagram-dom{
    min-width: 900px;
  }
}

/* Links & emphasis */
a{ color: var(--accent); }
strong{ color: #fff; }

/* Let CSS provide the offset only; JS will handle smooth animation for reliability */
html{ scroll-padding-top: calc(var(--header-h) + 12px); scroll-behavior: auto; }

@media (max-width: 760px){
  .toc ol{ padding-left: 14px; }
  .card{ padding: 18px; }
}

/* Small phones: tighten paddings and font sizes */
@media (max-width: 640px){
  .container{ padding: 0 14px; }
  .site-header .container{ padding: 16px 14px; }
  h1{ font-size: clamp(22px, 6.2vw, 30px); }
  .subtitle{ font-size: 14px; }
  .site-nav{ gap: 8px; }
  .site-nav a{ font-size: 14px; padding: 4px 8px; }
  .card{ padding: 16px; }
  pre.code{ font-size: 13px; }
}
/* Ultra narrow devices: further compress spacing and prevent horizontal overflow */
@media (max-width: 374px){
  .container{ padding: 0 10px; }
  .site-header .container{ padding: 14px 10px; }
  h1{ font-size: 22px; line-height: 1.25; }
  .subtitle{ font-size: 13px; }
  .site-nav a{ font-size: 13px; padding: 3px 6px; }
  .mobile-toc-toggle{ font-size: 12.5px; padding: 6px 10px; }
  .card{ padding: 14px 12px; }
  h2{ font-size: 20px; }
  h3{ font-size: 18px; }
  pre.code{ font-size: 12.5px; }
  .quick-grid{ grid-template-columns: 1fr; }
  .http-figure{ padding: .75rem .6rem; }
  /* Ensure SVG wraps without forcing wider layout */
  .http-svg{ max-width: 100%; }
  /* Prevent any accidental overflow */
  body, html{ overflow-x: hidden; }
}

/* New inline Run button */
.play-run{
  position:absolute; top:8px; right:70px;
  background: linear-gradient(180deg, #1f2b1f, #142314);
  color: #b7f0d1; border:1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px;
}
.play-run:hover{ filter: brightness(1.05); }

/* Interactive Code Playground - Full Screen Modal */
.playground-modal{
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition: background 0.4s cubic-bezier(0.22, 0.61, 0.36, 1),
              backdrop-filter 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.playground-modal.open{
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.playground-container{
  width: 95vw;
  max-width: 1600px;
  height: 90vh;
  max-height: 900px;
  background: linear-gradient(180deg, rgba(26,29,50,.98), rgba(19,22,38,.98));
  border: 2px solid rgba(122,162,255,0.3);
  border-radius: 16px;
  box-shadow: 0 25px 80px rgba(0,0,0,.6), 
              0 0 0 1px rgba(255,255,255,.05) inset,
              0 0 40px rgba(122,162,255,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.7) translateY(50px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.4s ease;
}

.playground-modal.open .playground-container{
  transform: scale(1) translateY(0);
  opacity: 1;
}

.playground-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: linear-gradient(180deg, rgba(35,48,70,0.6), rgba(26,29,50,0.4));
  border-bottom: 1px solid rgba(122,162,255,0.2);
  backdrop-filter: blur(10px);
}

.playground-title{
  font-weight: 700;
  color: #fff;
  font-size: 18px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.playground-title::before{
  content: "▶";
  color: #b7f0d1;
  font-size: 16px;
  animation: pulse-play 2s ease-in-out infinite;
}

@keyframes pulse-play{
  0%, 100%{ opacity: 1; transform: scale(1); }
  50%{ opacity: 0.6; transform: scale(0.9); }
}

.playground-actions{
  display: flex;
  gap: 12px;
  align-items: center;
}

.playground-btn{
  background: linear-gradient(180deg, #252a45, #1a1f36);
  color: #c7d2fe;
  border: 1px solid rgba(122,162,255,0.3);
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.playground-btn:hover{
  filter: brightness(1.2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(122,162,255,0.25);
}

.playground-btn.primary{
  background: linear-gradient(180deg, #1f3d1f, #142914);
  color: #b7f0d1;
  border-color: rgba(183,240,209,0.4);
}

.playground-btn.primary:hover{
  box-shadow: 0 6px 20px rgba(183,240,209,0.3);
}

.playground-btn.danger{
  background: linear-gradient(180deg, #3a1f26, #2a1418);
  color: #ffd0d0;
  border-color: rgba(255,113,113,0.3);
}

.playground-btn.danger:hover{
  box-shadow: 0 6px 20px rgba(248,113,113,0.25);
}

.playground-btn.close-btn{
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(60,35,45,0.8), rgba(45,25,35,0.8));
  border-color: rgba(248,113,113,0.4);
}

.playground-body{
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px 28px;
  overflow: hidden;
  min-height: 0;
}

/* Three-panel layout for browser preview */
.playground-body.three-panel{
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.playground-body.three-panel .editor-panel{
  grid-row: 1 / -1;
}

.playground-body.three-panel .preview-panel{
  grid-column: 2;
  grid-row: 1;
}

.playground-body.three-panel .console-panel{
  grid-column: 2;
  grid-row: 2;
}

.playground-panel{
  background: rgba(14,17,35,0.6);
  border: 1px solid rgba(122,162,255,0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

/* Browser Chrome Header */
.browser-chrome{
  background: linear-gradient(180deg, #e8e8e8, #d4d4d4);
  padding: 10px 14px;
  gap: 12px;
}

.browser-dots{
  display: flex;
  gap: 6px;
}

.browser-dots .dot{
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.browser-dots .dot.red{
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.2);
}

.browser-dots .dot.yellow{
  background: linear-gradient(135deg, #ffd93d, #f0c929);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.2);
}

.browser-dots .dot.green{
  background: linear-gradient(135deg, #6bcb77, #5ab868);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.2);
}

.browser-title-bar{
  flex: 1;
  background: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

.browser-title{
  font-size: 12px;
  color: #333;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* HTML Toggle Button */
.html-toggle{
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: auto;
  box-shadow: 
    0 4px 15px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  animation: pulse-glow 2s ease-in-out infinite;
}

.html-toggle::before{
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.3),
    transparent
  );
  transition: left 0.5s;
}

.html-toggle:hover::before{
  left: 100%;
}

.html-toggle:hover{
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(118, 75, 162, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.5);
}

.html-toggle:active{
  transform: translateY(0) scale(0.98);
  box-shadow: 
    0 2px 10px rgba(102, 126, 234, 0.4),
    inset 0 2px 4px rgba(0,0,0,0.2);
}

.html-toggle.active{
  background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
  box-shadow: 
    0 4px 20px rgba(0, 200, 83, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.4);
  animation: none;
}

.html-toggle.active:hover{
  background: linear-gradient(135deg, #00e676 0%, #69f0ae 100%);
  box-shadow: 
    0 8px 30px rgba(0, 230, 118, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.4);
}

@keyframes pulse-glow{
  0%, 100%{
    box-shadow: 
      0 4px 15px rgba(102, 126, 234, 0.4),
      inset 0 1px 0 rgba(255,255,255,0.2);
    transform: scale(1);
  }
  50%{
    box-shadow: 
      0 4px 25px rgba(118, 75, 162, 0.6),
      inset 0 1px 0 rgba(255,255,255,0.3);
    transform: scale(1.05);
  }
}

.html-toggle .toggle-icon{
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 16px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.html-toggle .toggle-label{
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.browser-preview-container{
  flex: 1;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.browser-preview-frame{
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* HTML Source View */
.html-source-view{
  display: none;
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 16px;
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}

/* HTML Syntax Highlighting */
.html-source-view .html-bracket{
  color: #6c7086;
}

.html-source-view .html-tag{
  color: #f38ba8;
}

.html-source-view .html-attr{
  color: #a6e3a1;
}

.html-source-view .html-equals{
  color: #6c7086;
}

.html-source-view .html-string{
  color: #f9e2af;
}

.html-source-view .html-text{
  color: #cdd6f4;
}

.html-source-view .html-comment{
  color: #6c7086;
  font-style: italic;
}

.html-source-view .html-error{
  color: #f38ba8;
}

.playground-panel-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(35,48,70,0.4);
  border-bottom: 1px solid rgba(122,162,255,0.15);
}

.playground-panel-title{
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.playground-editor{
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.playground-editor .code-input{
  display: none;
}

.playground-editor .CodeMirror{
  height: 100%;
  background: transparent;
  color: #e6eaff;
  font-size: 14.5px;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.playground-editor .CodeMirror-scroll{
  min-height: 100%;
}

.playground-editor .cm-s-material.CodeMirror{
  background: transparent;
}

.playground-editor .cm-s-material .CodeMirror-gutters{
  background: rgba(14,17,35,0.5);
  border-right: 1px solid rgba(122,162,255,0.15);
}

.playground-editor .CodeMirror-linenumbers{
  color: #6474a5;
}

.playground-output{
  flex: 1;
  overflow: auto;
  padding: 18px;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: #e6eaff;
  line-height: 1.6;
}

.playground-output::-webkit-scrollbar{
  width: 10px;
}

.playground-output::-webkit-scrollbar-track{
  background: rgba(14,17,35,0.5);
  border-radius: 6px;
}

.playground-output::-webkit-scrollbar-thumb{
  background: rgba(122,162,255,0.3);
  border-radius: 6px;
}

.playground-output::-webkit-scrollbar-thumb:hover{
  background: rgba(122,162,255,0.5);
}

.playground-output .line{
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(14,17,35,0.4);
  border-left: 3px solid transparent;
}

.playground-output .line.warn{
  color: #fbbf24;
  background: rgba(251,191,36,0.1);
  border-left-color: #fbbf24;
}

.playground-output .line.error{
  color: #f87171;
  background: rgba(248,113,113,0.1);
  border-left-color: #f87171;
}

.playground-output .line.info{
  color: #94a3b8;
  background: rgba(148,163,184,0.05);
  border-left-color: #475569;
}

.playground-output .line:last-child{
  margin-bottom: 0;
}

.playground-footer{
  padding: 16px 28px;
  background: linear-gradient(180deg, rgba(26,29,50,0.4), rgba(35,48,70,0.6));
  border-top: 1px solid rgba(122,162,255,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.playground-footer-info{
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  gap: 20px;
}

.playground-footer-hint{
  color: #94a3b8;
  font-size: 12px;
  font-style: italic;
}

.playground-footer-hint kbd{
  background: rgba(14,17,35,0.6);
  border: 1px solid rgba(122,162,255,0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  font-style: normal;
}

/* Mobile responsive */
@media (max-width: 860px){
  .playground-container{
    width: 98vw;
    height: 95vh;
  }
  
  .playground-body{
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  
  .playground-header,
  .playground-footer{
    padding: 16px;
  }
  
  .playground-actions{
    gap: 8px;
  }
  
  .playground-btn{
    padding: 8px 14px;
    font-size: 13px;
  }
  
  .playground-footer-info{
    flex-direction: column;
    gap: 8px;
  }
  
  .playground-footer-hint{
    display: none;
  }
}

@media (max-width: 640px){
  .playground-title{
    font-size: 16px;
  }
  
  .playground-btn{
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .playground-btn.close-btn{
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
}

/* Right drawer runner */
.runner-drawer{
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 38vw);
  transform: translateX(105%);
  transition: transform .32s cubic-bezier(.22,.61,.36,1);
  background: linear-gradient(180deg, rgba(26,29,50,.95), rgba(19,22,38,.95));
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
  z-index: 99999;
  display: flex; flex-direction: column;
}
.runner-drawer.open{ transform: translateX(0); }
.runner-drawer .drawer-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px; border-bottom:1px solid var(--border);
}
.runner-drawer .title{ font-weight:600; color:#fff; font-size:14px; letter-spacing:.2px; }
.runner-drawer .actions{ display:flex; gap:8px; }
.runner-drawer .btn{ background: linear-gradient(180deg, #252a45, #1a1f36); color:#c7d2fe; border:1px solid var(--border); border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; }
.runner-drawer .btn.primary{ background: linear-gradient(180deg, #1f2b1f, #142314); color:#b7f0d1; }
.runner-drawer .btn.danger{ background: linear-gradient(180deg, #3a1f26, #2a1418); color:#ffd0d0; }
.runner-drawer .drawer-body{ padding: 14px 16px; flex:1; display:grid; grid-template-columns: 1fr 1fr; gap: 12px; overflow:auto; grid-auto-rows: 1fr; }
.runner-drawer .editor{
  background: var(--code-bg); border:1px solid var(--border); border-radius:10px; padding:12px; display:flex; flex-direction:column; min-height: 220px;
}
.runner-drawer .editor .editor-header{ display:flex; justify-content:space-between; align-items:center; color: var(--muted); font-size:12px; margin-bottom:8px; }
.runner-drawer .editor .code-input{ display:none; }
.runner-drawer .editor .CodeMirror{
  /* Let the editor fill remaining space and scroll internally when needed */
  height: auto;
  flex: 1;
  border-radius: 8px;
  background: transparent;
  color: #e6eaff;
  font-size: 13.5px;
  padding: 12px 8px;
}
.runner-drawer .editor .CodeMirror-scroll{ min-height: 200px; padding: 8px 0; }
.runner-drawer .editor .cm-s-material.CodeMirror{ background: transparent; }
.runner-drawer .editor .cm-s-material .CodeMirror-gutters{ background: transparent; border-right: 1px solid var(--border); }
.runner-drawer .editor .CodeMirror-linenumbers{ color: #6474a5; }
.runner-drawer .output{
  background: var(--code-bg); border:1px solid var(--border); border-radius:10px; padding:12px; overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size:13.5px; color:#e6eaff;
}
.runner-drawer .line{ white-space: pre-wrap; word-break: break-word; margin:0 0 6px; }
.runner-drawer .line.warn{ color: var(--yellow); }
.runner-drawer .line.error{ color: var(--red); }
.runner-drawer .line.info{ color: var(--muted); }
.runner-drawer .drawer-footer{ padding: 10px 16px 14px; border-top:1px solid var(--border); color:var(--muted); font-size:12px; display:flex; justify-content:space-between; }

/* Static code blocks theme wrapper for runMode */
.code{ position: relative; }
.code code.cm-s-material{ display:block; }

@media (max-width: 860px){
  .runner-drawer{ width: 100vw; }
  .runner-drawer .drawer-body{ grid-template-columns: 1fr; grid-auto-rows: minmax(220px, 1fr); }
}

/* Layout: sticky sidebar TOC + content */
.layout{ display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
/* Make TOC fixed so it does not scroll with the page */
.toc{ position: fixed; top: calc(var(--header-h) + 12px); left: var(--container-left, 20px);
  align-self: start; max-height: calc(100vh - (var(--header-h) + 20px)); overflow: visible; display:flex; flex-direction: column; z-index: 30; }
.content{ margin-left: var(--toc-w-expanded); transition: margin-left .38s cubic-bezier(.22,.61,.36,1); }
.toc .toc-title{ display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; background: rgba(23,26,43,.9); padding-bottom: 6px; z-index: 1; }
.toc .toc-actions{ display:flex; gap:8px; align-items:center; }
.toc .toc-toggle{ display:none; }
.toc .toc-pin,
.toc .toc-hide{ display:inline-flex; appearance:none; border:1px solid var(--border); border-radius:8px; background: linear-gradient(180deg, #252a45, #1a1f36); color:#c7d2fe; font-size:12px; padding:6px 10px; cursor:pointer; }
.toc .toc-pin[aria-pressed="true"]{ outline: 2px solid var(--accent); color:#fff; }
.toc a.active{ color: #fff; font-weight: 600; text-decoration: none; }
.toc li{ margin: 4px 0; }
.toc ol ol{ margin-top: 4px; }
/* Only the list scrolls */
#toc-list{ flex: 1 1 auto; overflow: auto; }

/* Anchor offset handled by html{scroll-padding-top}; avoid double-offset */
[id]{ scroll-margin-top: 0; }

/* Responsive: stack layout, collapsible TOC */
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .toc{ position: relative; top: 0; left: 0; max-height: none; }
  .content{ margin-left: 0; }
  /* Show mobile toggle; allow hiding TOC fully when collapsed on mobile */
  .mobile-toc-toggle{ display: inline-flex; align-items:center; gap:6px; }
  body.toc-collapsed .toc{ display: none; }
}

/* Show pin/hide controls on desktop */
/* Pin/Hide are visible on all sizes */

/* Hide/Pin global behaviors */
/* Remove full hide behavior; instead convert hide to collapsed rail */
/* Legacy hidden state disabled: keep TOC rail visible */
body.toc-hidden .toc{ display: flex; }
body.toc-hidden .toc-restore{ display:none; }

/* Replace old bottom-left FAB with top-left restore button */
.toc-restore{
  position: fixed; top: calc(var(--header-h) + 10px); left: 16px; z-index: 100000;
  border:1px solid var(--border); border-radius: 999px;
  background: rgba(23,26,43,.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color:#e8ecff; padding: 8px 14px; font-size: 13px; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  outline: none; display:none;
}
.toc-restore:hover{ filter: brightness(1.08); }
.toc-restore:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 980px){
  /* If pinned on mobile, keep list open */
  body.toc-pinned .toc #toc-list{ display: block !important; }
}

/* Make the FAB more prominent and centered on small screens */
.http-figure{
  display:block;
  margin: 1rem 0 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg, #0e1326);
  position: relative; /* for caption overlay */
}

/* Only target the HTTP topology caption specifically */
#http-topology-caption {
  margin-top: 0.75rem;
  font-size: 0.9em;
  font-style: italic;
  color: var(--muted) !important;
  width: 100%;
  left: 0;
  text-align: justify;
}

.http-svg{ width: 100%; height: auto; display:block; }

/* Stage: diagram + HUD */
.http-stage{ display:grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
.http-canvas{ min-width: 0; }
@media (max-width: 980px){ .http-stage{ grid-template-columns: 1fr; } }

/* HUD */
/* HUD removed; details appear on interactive envelopes */

/* Quick reference grid (used to condense long prose) */
.quick-grid{ display:grid; gap:12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin:.5rem 0 0; }
.quick-grid .q{ background: var(--card, #0e1326); border:1px solid var(--border); border-radius:10px; padding:10px 12px; }
.quick-grid .q h4{ margin:0 0 6px; font-size:14px; color: var(--text); }
.quick-grid .q p{ margin:0; color: var(--muted); font-size:13px; }

/* Deep-dive CTA button */
.more-cta{ margin-top: 10px; }
.deep-trigger{
  appearance: none; border: 1px solid var(--border); border-radius: 999px;
  background: linear-gradient(180deg, #252a45, #1a1f36);
  color: #c7d2fe; font-size: 12.5px; padding: 7px 12px; cursor: pointer;
}
.deep-trigger:hover{ filter: brightness(1.08); color: #fff; }

/* Disable all hover transforms when modal is open to prevent interference */
body.modal-open *:not(.deep-modal):not(.deep-close) {
  transform: none !important;
}

/* =====================================================
   DEEP DIVE MODAL - BULLETPROOF CENTERING
   ===================================================== */
.deep-overlay{ 
  position: fixed !important; 
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important; 
  pointer-events: none;
  overflow: hidden;
  /* ALWAYS use flexbox centering - not just when open */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  isolation: isolate;
}
.deep-overlay[aria-hidden="true"]{ 
  visibility: hidden; 
}
.deep-overlay.open{ 
  pointer-events: auto; 
}

.deep-backdrop{
  position: fixed !important; 
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(6,8,16,.75) !important; 
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0; 
  transition: opacity .25s ease;
  z-index: 1;
}
.deep-overlay.open .deep-backdrop{ 
  opacity: 1; 
}

.deep-modal{
  position: relative !important;
  z-index: 2 !important;
  /* No margin:auto needed - flexbox centers it */
  width: min(920px, 90vw) !important; 
  max-height: calc(100vh - 80px) !important;
  display: flex !important; 
  flex-direction: column !important;
  background: linear-gradient(180deg, rgba(26,29,50,.98), rgba(16,19,35,.98)) !important;
  border: 1px solid var(--border) !important; 
  border-radius: 16px !important; 
  box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05) !important;
  opacity: 0; 
  transition: opacity .25s ease;
}

.deep-overlay.open .deep-modal{ 
  opacity: 1; 
}
.deep-header{ display:flex; align-items:center; justify-content:space-between; gap: 10px; padding: 12px 14px; border-bottom:1px solid var(--border); }
.deep-tabs{ display:flex; gap:6px; flex-wrap:wrap; }
.deep-tab{ appearance:none; border:1px solid var(--border); border-radius: 10px; padding:6px 10px; background: linear-gradient(180deg, #2a335b, #20274a); color:#dbe4ff; font-size:12.5px; cursor:pointer; transition: all 0.2s ease; }
.deep-tab:hover{ background: linear-gradient(180deg, #343d6b, #2a3358); }
.deep-tab[aria-selected="true"]{ outline: 2px solid var(--accent); color:#fff; }
.deep-close{ appearance:none; border:1px solid var(--border); border-radius: 10px; padding:6px 10px; background: linear-gradient(180deg, #3a1f26, #2a1418); color:#ffd0d0; cursor:pointer; transition: all 0.2s ease; }
.deep-close:hover{ background: linear-gradient(180deg, #4a2f36, #3a2428); transform: scale(1.05); }

/* Custom scrollbar for modal body */
.deep-body{ 
  padding: 12px 14px; 
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(255,255,255,0.1);
}

/* Webkit scrollbar styling */
.deep-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.deep-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  margin: 4px;
}

.deep-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.deep-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8ab2ff, #e08bff);
  background-clip: padding-box;
}

.deep-body::-webkit-scrollbar-corner {
  background: transparent;
}

/* Light theme scrollbar */
[data-theme="light"] .deep-body {
  scrollbar-color: #4a7cd4 rgba(0,0,0,0.08);
}

[data-theme="light"] .deep-body::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

[data-theme="light"] .deep-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a7cd4, #7c3aed);
  border: 2px solid transparent;
  background-clip: padding-box;
}

[data-theme="light"] .deep-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #3a6cc4, #6c2add);
  background-clip: padding-box;
}
.deep-panel {
  max-width: 100%;
  overflow: hidden;
}
.deep-panel h4{ margin: 6px 0 10px; }
.deep-panel h5{ margin: 8px 0 6px; font-size: 13.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.deep-panel ul{ margin: .25rem 0 .5rem 1.1rem; color: var(--fg-muted, #c7d0e8); }
.deep-panel ol{ margin: .25rem 0 .5rem 1.5rem; padding-left: 0.5rem; color: var(--fg-muted, #c7d0e8); }
.deep-panel li{ margin: 6px 0; }
.deep-panel .code{ margin-top: 8px; }

/* Deep content layout */
.deep-grid{ 
  display: grid; 
  gap: 10px; 
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  max-width: 100%;
  overflow: hidden;
}
.deep-section{ 
  background: rgba(23,26,43,.55); 
  border: 1px solid var(--border); 
  border-radius: 10px; 
  padding: 10px 12px;
  min-width: 0; /* Prevent grid blowout */
  overflow: hidden;
}
.deep-section .code{ 
  margin: 8px 0 0; 
  max-width: 100%;
  overflow-x: auto;
  font-size: 12px;
  padding: 10px;
}

/* Fix copy button overflow in modal panels: when copy button is a sibling of .code, don't absolutely position */
.deep-section > .copy{
  position: static;
  display: inline-flex;
  margin-top: 6px;
}

/* Prevent long inline code (e.g., /proc/sys/... paths) from overflowing modal */
.deep-panel :not(pre).code, /* safety if someone uses class="code" inline */
.deep-panel code{
  white-space: normal;
  overflow-wrap: anywhere; /* allow breaking long paths/urls */
  word-break: break-word;
  background: rgba(74, 124, 212, 0.15);
  border: 1px solid rgba(99, 141, 217, 0.3);
  border-radius: 4px;
  padding: 2px 6px;
  color: #8fb5ff;
  font-size: 0.9em;
  font-weight: 500;
}
/* Keep preformatted blocks unaffected */
.deep-panel pre.code{ 
  overflow-x: auto;
  max-width: 100%;
}
.deep-section pre.code{
  font-size: 11.5px;
  line-height: 1.45;
  padding: 10px;
  margin: 8px 0 0;
  background: rgba(11,14,26,.6);
}
.deep-panel pre.code code{
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  background: transparent; /* pre container styles already apply */
  border: 0; 
  padding: 12px 16px; 
  border-radius: 0;
}

/* Mini tabs inside deep panels */
.mini-tabs{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:8px; }
.mini-tab{ appearance:none; border:1px solid var(--border); border-radius: 8px; padding:6px 10px; background: linear-gradient(180deg, #252a45, #1a1f36); color:#c7d2fe; font-size:12px; cursor:pointer; }
.mini-tab[aria-selected="true"]{ outline: 2px solid var(--accent); color:#fff; }
.mini-panels .mini-panel[hidden]{ display:none; }

/* HTTP Message Structure Visual */
.http-message-structure {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.message-part {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.message-part:last-child {
  border-bottom: none;
}

.message-part:hover {
  background: rgba(122, 162, 255, 0.05);
}

.message-part.start-line {
  background: linear-gradient(90deg, rgba(110, 231, 183, 0.15), transparent);
  border-left: 4px solid #6ee7b7;
}

.message-part.headers {
  background: linear-gradient(90deg, rgba(122, 162, 255, 0.15), transparent);
  border-left: 4px solid #7aa2ff;
}

.message-part.empty-line {
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.15), transparent);
  border-left: 4px solid #facc15;
  padding: 0.75rem 1rem;
}

.message-part.body {
  background: linear-gradient(90deg, rgba(216, 123, 255, 0.15), transparent);
  border-left: 4px solid #d87bff;
}

.part-label {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
}

.message-part.start-line .part-label { color: #6ee7b7; }
.message-part.headers .part-label { color: #7aa2ff; }
.message-part.empty-line .part-label { color: #facc15; }
.message-part.body .part-label { color: #d87bff; }

.part-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.part-example {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  line-height: 1.5;
}

.part-example code {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-size: inherit;
  color: inherit;
}

.part-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Light theme adjustments */
[data-theme="light"] .http-message-structure {
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .message-part {
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-part.start-line {
  background: linear-gradient(90deg, rgba(46, 204, 113, 0.12), transparent);
  border-left-color: #2ecc71;
}

[data-theme="light"] .message-part.headers {
  background: linear-gradient(90deg, rgba(74, 124, 212, 0.12), transparent);
  border-left-color: #4a7cd4;
}

[data-theme="light"] .message-part.empty-line {
  background: linear-gradient(90deg, rgba(241, 196, 15, 0.12), transparent);
  border-left-color: #f1c40f;
}

[data-theme="light"] .message-part.body {
  background: linear-gradient(90deg, rgba(155, 89, 182, 0.12), transparent);
  border-left-color: #9b59b6;
}

[data-theme="light"] .message-part.start-line .part-label { color: #27ae60; }
[data-theme="light"] .message-part.headers .part-label { color: #2980b9; }
[data-theme="light"] .message-part.empty-line .part-label { color: #d4a017; }
[data-theme="light"] .message-part.body .part-label { color: #8e44ad; }

[data-theme="light"] .part-example {
  background: rgba(0, 0, 0, 0.05);
  color: #1a1a2e;
}

[data-theme="light"] .message-part:hover {
  background: rgba(74, 124, 212, 0.08);
}

/* Responsive */
@media (max-width: 600px) {
  .message-part {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .part-label {
    font-size: 0.8rem;
  }
}

/* Highlight parts of the HTTP message */
.ex-start{ display:block; color:#eaffff; font-weight:600; }
.ex-header{ display:block; color:#c7d0e8; }
.ex-sep{ display:block; height:10px; }
.ex-body{ display:block; color:#e6eaff; }
.pill{ display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; border:1px solid var(--border); background: rgba(23,26,43,.6); color:#c7d0e8; }
.pill.start{ color:#b7f0d1; border-color:#2a3f34; background: rgba(31,43,31,.5); }
.pill.header{ color:#dbe4ff; border-color:#2b3457; background: rgba(37,44,77,.5); }
.pill.body{ color:#ffd0ff; border-color:#4a2f58; background: rgba(60,33,70,.5); }

@media (max-width: 720px){
  .deep-modal{ 
    width: 95vw !important; 
    max-height: calc(100vh - 40px) !important;
  }
  .deep-tabs{ gap: 4px; }
  .deep-tab{ padding: 6px 8px; }
}

/* Details summary styling */
details.advanced{ margin-top:10px; }
details.advanced > summary{ cursor:pointer; color: var(--fg, #e6eaff); font-weight:600; margin-bottom:6px; }
details.advanced ul{ margin:.25rem 0 0 1.1rem; color: var(--fg-muted, #c7d0e8); }

/* Envelope icon (request/response packet) */
.http-svg .envelope{ cursor: pointer; }
.http-svg .envelope.hover .inner{ transform: scale(1.05); filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }
.http-svg .envelope.pinned .inner{ animation: pulse-pin 1.5s ease-in-out infinite; }
@keyframes pulse-pin{
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.http-svg .envelope .inner{ transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.15s ease, filter 0.15s ease; }
.http-svg .envelope .inner.appear{ animation: env-pop 460ms cubic-bezier(.2,.8,.2,1) both; }
.http-svg .envelope.docked .inner{ transform: scale(1.75); }
.http-svg .envelope.docked.hover .inner{ transform: scale(1.8); }
.http-svg .envelope rect.body{ 
  fill: rgba(15,18,32,0.95); 
  stroke: currentColor; 
  stroke-width: 1.5; 
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.http-svg .envelope path.flap{ fill: currentColor; opacity: .85; }
.http-svg .envelope .env-icon{ opacity: 0.9; pointer-events: none; }
.http-svg .envelope.req{ color: var(--http-req-color, #4da3ff); }
.http-svg .envelope.res{ color: var(--http-res-color, #5be37d); }

@keyframes env-pop{
  0%{ opacity: 0; transform: scale(.5) rotate(-12deg); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
  60%{ opacity: 1; transform: scale(1.12) rotate(3deg); filter: drop-shadow(0 3px 8px rgba(0,0,0,.4)); }
  100%{ opacity: 1; transform: scale(1) rotate(0deg); filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
}

/* Construction spinner (used during envelope creation) */
.http-svg .spinner{ pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; animation: spin 0.8s linear infinite; }
.http-svg .spinner .ring-bg{ fill: none; stroke: rgba(230,234,255,.2); stroke-width: 1.6; }
.http-svg .spinner .ring-fg{ fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 16 20; opacity: 0.9; }
@keyframes spin{ from{ transform: rotate(0deg);} to{ transform: rotate(360deg);} }

/* Improve hover discoverability (no JS needed) */
.http-svg .flow{ transition: stroke-width .15s ease, opacity .15s ease; }
.http-svg .flow:hover{ opacity: 0.95; }

/* Hide inline flow labels when flows are hidden (auto-reveal mode) */
.http-figure.flows-on-use .flow-label{ display:none; }

/* Auto-reveal mode: hide all flows until actively used by the simulation */
.http-figure.flows-on-use .flow{ opacity: 0 !important; pointer-events: none; }
.http-figure.flows-on-use .flow.active{ opacity: 1 !important; pointer-events: auto; }
.http-figure.flows-on-use svg.http-svg:hover .flow.active{ opacity: 1 !important; }
.http-figure.flows-on-use svg.http-svg:hover .flow:not(.active){ opacity: 0 !important; }
/* Ensure legend flows never dim on hover, even in auto-reveal */
.http-figure.flows-on-use svg.http-svg:hover .legend .flow{ opacity: 1 !important; }
/* Keep legend examples visible even in auto-reveal mode */
.http-figure.flows-on-use .legend .flow{ opacity: 1 !important; pointer-events: auto; }

/* ===================== Promise Lifecycle Diagram ===================== */
.promise-lifecycle-figure{
  background: linear-gradient(135deg, #171a2b 0%, #1a1f36 100%);
  border: 2px solid rgba(122, 162, 255, 0.3);
  border-radius: 20px;
  padding: 2rem;
  margin: 2rem 0;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Scenario Selection Buttons */
.promise-controls{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.12) 100%);
  border-radius: 16px;
  border: 2px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.promise-demo-btn {
  flex: 1 1 auto;
  min-width: 155px;
  padding: 1rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e0e7ff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  border: 2px solid rgba(59, 130, 246, 0.6);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.promise-demo-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.promise-demo-btn:hover::before {
  left: 100%;
}

.promise-demo-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.45), 0 0 0 1px rgba(96, 165, 250, 0.5);
  border-color: #60a5fa;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35) 0%, rgba(99, 102, 241, 0.35) 100%);
  color: #ffffff;
}

.promise-demo-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(59, 130, 246, 0.25);
}

.promise-demo-btn[data-scenario="reset"] {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.2) 0%, rgba(239, 68, 68, 0.2) 100%);
  border-color: rgba(248, 113, 113, 0.6);
  color: #fecaca;
  flex-basis: 100%;
  margin-top: 0.5rem;
}

.promise-demo-btn[data-scenario="reset"]:hover {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.35) 0%, rgba(239, 68, 68, 0.35) 100%);
  border-color: #fca5a5;
  box-shadow: 0 8px 24px rgba(248, 113, 113, 0.45), 0 0 0 1px rgba(252, 165, 165, 0.5);
  color: #ffffff;
}

/* Explanation Box */
.promise-explanation {
  margin-bottom: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
  border-left: 6px solid #fbbf24;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(251, 191, 36, 0.4);
  border-left: 6px solid #fbbf24;
  position: relative;
  overflow: hidden;
}

.promise-explanation::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.1));
  z-index: -1;
  filter: blur(8px);
}

.promise-explanation-title {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fde68a;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.02em;
}

.promise-explanation-text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #fef3c7;
  font-weight: 500;
}

/* Step Controls */
.promise-step-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.5rem;
  padding: 1.5rem 2rem;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  border-radius: 16px;
  border: 2px solid rgba(14, 165, 233, 0.5);
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.promise-playback-buttons {
  display: flex;
  gap: 1rem;
}

.promise-step-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
  color: #bae6fd;
  border: 2px solid rgba(14, 165, 233, 0.6);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.promise-step-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.5s;
}

.promise-step-btn:hover:not(:disabled)::before {
  left: 100%;
}

.promise-step-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.45), 0 0 0 1px rgba(56, 189, 248, 0.5);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.35) 0%, rgba(6, 182, 212, 0.35) 100%);
  border-color: #38bdf8;
  color: #ffffff;
}

.promise-step-btn:active:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(14, 165, 233, 0.25);
}

.promise-step-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.promise-btn-play {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.2) 100%);
  border-color: rgba(16, 185, 129, 0.6);
  color: #a7f3d0;
}

.promise-btn-play:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(5, 150, 105, 0.35) 100%);
  border-color: #34d399;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45), 0 0 0 1px rgba(52, 211, 153, 0.5);
}

.promise-btn-pause {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.2) 100%);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
}

.promise-btn-pause:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35) 0%, rgba(217, 119, 6, 0.35) 100%);
  border-color: #fbbf24;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.45), 0 0 0 1px rgba(251, 191, 36, 0.5);
}

.btn-icon {
  font-size: 1.2rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.btn-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Step Info */
.promise-step-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
}

.promise-step-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.promise-step-label {
  font-size: 1rem;
  font-weight: 700;
  color: #bae6fd;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.01em;
}

.promise-step-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.3) 0%, rgba(6, 182, 212, 0.3) 100%);
  border-radius: 10px;
  font-size: 1rem;
  border: 2px solid rgba(14, 165, 233, 0.6);
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  font-weight: 700;
}

.promise-step-num {
  color: #7dd3fc;
  font-size: 1.5rem;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  line-height: 1;
}

.promise-step-total {
  color: #38bdf8;
  font-size: 1.2rem;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  line-height: 1;
}

.promise-step-desc {
  margin: 0;
  font-size: 1rem;
  color: #e0f2fe;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  line-height: 1.5;
}

/* SVG Blur Effect */
.promise-diagram-container {
  position: relative;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(23, 26, 43, 0.6) 0%, rgba(26, 31, 54, 0.6) 100%);
  border-radius: 16px;
  border: 2px solid rgba(122, 162, 255, 0.2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.promise-svg {
  transition: filter 0.4s ease, opacity 0.4s ease, transform 0.4s ease;
}

.promise-diagram-container.blurred .promise-svg {
  filter: blur(10px);
  opacity: 0.25;
  transform: scale(0.98);
  pointer-events: none;
}

.promise-diagram-container.blurred::after {
  content: '👆 Select a scenario above to begin';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 700;
  color: #7dd3fc;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

  flex-wrap: wrap;
}

.promise-demo-btn{
  background: linear-gradient(180deg, #252a45, #1a1f36);
  color: #c7d2fe;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.promise-demo-btn:hover{
  background: linear-gradient(180deg, #2a3050, #1f2540);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.promise-demo-btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(180deg, #1a1d32, #16182a);
  border-color: #4a5568;
}

.promise-demo-btn:disabled:hover{
  transform: none;
  border-color: #4a5568;
  background: linear-gradient(180deg, #1a1d32, #16182a);
}

.promise-demo-btn:active{
  transform: translateY(0);
}

.promise-demo-btn.active{
  background: linear-gradient(180deg, var(--accent), #4a5fc1);
  color: white;
  border-color: var(--accent);
}

.promise-svg{
  width: 100%;
  height: auto;
  display: block;
}

.promise-svg .promise-state{
  transition: all 0.4s ease;
  transform-origin: center;
  opacity: 1;
}

.promise-svg .promise-state.active{
  filter: drop-shadow(0 0 16px rgba(122,162,255,0.7));
  animation: promisePulse 1.5s ease-in-out infinite;
  opacity: 1;
}

.promise-svg .promise-state.dimmed{
  opacity: 0.3;
  filter: grayscale(0.5);
}

.promise-svg .promise-state rect{
  transition: all 0.3s ease;
}

.promise-svg .promise-state.active rect{
  transform: scale(1.03);
  transform-origin: center;
  transform-box: fill-box;
}

.promise-svg .promise-handler{
  transition: all 0.4s ease;
  transform-origin: center;
  opacity: 1;
}

.promise-svg .promise-handler.active{
  filter: drop-shadow(0 0 14px rgba(91,227,125,0.6));
  animation: handlerGlow 1s ease-in-out;
  opacity: 1;
}

.promise-svg .promise-handler.dimmed{
  opacity: 0.25;
}

@keyframes handlerGlow{
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(91,227,125,0.4));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(91,227,125,0.9));
  }
}

.promise-svg .promise-flow{
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  opacity: 0;
  transition: stroke-dashoffset 1s ease-in-out, opacity 0.3s ease;
  marker-end: none;
}

/* Longer path needs larger dasharray */
.promise-svg .promise-flow[data-flow="chain-to-pending"]{
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
}

.promise-svg .promise-flow.animate{
  stroke-dashoffset: 0;
  opacity: 1;
  marker-end: none;
}

.promise-svg .promise-flow.complete{
  opacity: 0.85;
}

/* Show arrowheads only when animation completes */
.promise-svg .promise-flow[data-flow="resolve"].complete{
  marker-end: url(#arrow-success);
}

.promise-svg .promise-flow[data-flow="reject"].complete{
  marker-end: url(#arrow-error);
}

.promise-svg .promise-flow[data-flow="then"].complete{
  marker-end: url(#arrow-then);
}

.promise-svg .promise-flow[data-flow="catch"].complete{
  marker-end: url(#arrow-error);
}

.promise-svg .promise-flow[data-flow="chain-then"].complete{
  marker-end: url(#arrow-chain);
}

.promise-svg .promise-flow[data-flow="chain-to-pending"].complete{
  marker-end: url(#arrow-warning);
}

.promise-svg .promise-flow[data-flow="resolve-2"].complete{
  marker-end: url(#arrow-success);
}

.promise-svg .promise-flow[data-flow="then-2"].complete{
  marker-end: url(#arrow-then);
}

.promise-svg .promise-flow[data-flow="then-finally"].complete{
  marker-end: url(#arrow-finally);
}

.promise-svg .promise-flow[data-flow="catch-finally"].complete{
  marker-end: url(#arrow-finally);
}

.promise-svg .promise-label{
  opacity: 0;
  transition: opacity 0.4s ease;
  font-weight: 600;
}

.promise-svg .promise-value{
  opacity: 0;
  transition: opacity 0.3s ease;
  font-style: italic;
}

.promise-svg .promise-value.show{
  opacity: 1;
}

.promise-svg .promise-timing{
  opacity: 0;
  transition: opacity 0.4s ease;
  font-weight: 600;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.8));
}

/* Step controls */
.promise-step-controls{
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(23,26,43,0.8) 0%, rgba(26,31,54,0.6) 100%);
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid rgba(122,162,255,0.2);
}

.promise-step-controls.active{
  display: flex;
}

.promise-step-btn{
  padding: 6px 14px;
  background: linear-gradient(180deg, #2a3050, #1f2540);
  color: #94a3b8;
  border: 1px solid rgba(122,162,255,0.3);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.promise-step-btn:hover{
  background: linear-gradient(180deg, #2f3555, #24294a);
  border-color: var(--accent);
  color: #e6eaff;
}

.promise-step-btn:disabled{
  opacity: 0.4;
  cursor: not-allowed;
}

.promise-step-btn[data-action="play"].playing{
  background: linear-gradient(180deg, var(--accent), #4a5fc1);
  color: white;
}

.promise-step-info{
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-size: 13px;
  color: #94a3b8;
}

.promise-step-label{
  color: #64748b;
}

.promise-step-num{
  color: var(--accent);
  font-weight: 700;
}

.promise-step-total{
  color: #94a3b8;
}

.promise-step-desc{
  color: #e6eaff;
  font-weight: 500;
  min-width: 200px;
}

/* Inline code snippet (compact view) */
.promise-inline-code{
  background: rgba(15,18,30,0.6);
  border: 1px solid rgba(122,162,255,0.2);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  display: none;
  max-width: 100%;
  overflow-x: auto;
}

.promise-inline-code.active{
  display: block;
}

.promise-inline-code-content{
  color: #e2e8f0;
}

.promise-inline-code .code-snippet{
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Code toggle button */
.promise-code-toggle{
  margin-left: 0.5rem;
}

/* Code highlighting in panel */
.promise-code-content .code{
  position: relative;
}

.promise-code-content .code-line{
  display: block;
  padding: 6px 12px;
  margin: 2px 0;
  border-radius: 4px;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.promise-code-content .code-line.highlight{
  background: linear-gradient(90deg, rgba(122,162,255,0.25) 0%, rgba(122,162,255,0.1) 100%);
  border-left: 4px solid #7aa2ff;
  padding-left: 16px;
  margin-left: 0;
  box-shadow: 0 2px 8px rgba(122,162,255,0.3);
  transform: translateX(4px);
  font-weight: 500;
}

.promise-code-content .code-line.executed{
  background: rgba(91,227,125,0.08);
  border-left: 3px solid rgba(91,227,125,0.3);
  opacity: 0.7;
}

/* Syntax highlighting colors */
.promise-code-content .kw {
  color: #ff79c6; /* Keywords - pink */
  font-weight: 600;
}

.promise-code-content .str {
  color: #50fa7b; /* Strings - green */
}

.promise-code-content .cmt {
  color: #6272a4; /* Comments - gray-blue */
  font-style: italic;
}

.promise-code-content .num {
  color: #bd93f9; /* Numbers - purple */
}

.promise-code-content .method {
  color: #8be9fd; /* Methods - cyan */
  font-weight: 500;
}

.promise-code-content .fn {
  color: #ffb86c; /* Functions - orange */
  font-weight: 600;
}

.promise-code-content .op {
  color: #ff79c6; /* Operators - pink */
  font-weight: 500;
}

/* Syntax highlighting colors */
.promise-code-content .kw {
  color: #ff79c6; /* Keywords - pink */
  font-weight: 600;
}

.promise-code-content .str {
  color: #50fa7b; /* Strings - green */
}

.promise-code-content .cmt {
  color: #6272a4; /* Comments - gray-blue */
  font-style: italic;
}

.promise-code-content .num {
  color: #bd93f9; /* Numbers - purple */
}

.promise-code-content .method {
  color: #8be9fd; /* Methods - cyan */
  font-weight: 500;
}

.promise-code-content .fn {
  color: #ffb86c; /* Functions - orange */
  font-weight: 600;
}

.promise-code-content .op {
  color: #ff79c6; /* Operators - pink */
  font-weight: 500;
  opacity: 0.7;
}

.promise-svg .promise-label.show{
  opacity: 1;
  animation: labelPulse 0.5s ease-out;
}

@keyframes labelPulse{
  0% { 
    transform: scale(0.8);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
  }
  100% { 
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes promisePulse{
  0%, 100% { 
    filter: drop-shadow(0 0 8px rgba(122,162,255,0.4));
  }
  50% { 
    filter: drop-shadow(0 0 16px rgba(122,162,255,0.8));
  }
}

@media (max-width: 768px){
  .promise-lifecycle-figure{
    padding: 1rem;
  }
  
  .promise-controls{
    gap: 8px;
    padding: 1rem;
  }
  
  .promise-demo-btn{
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    min-width: 120px;
  }
  
  .promise-explanation{
    padding: 1.25rem;
  }
  
  .promise-explanation-title{
    font-size: 1.05rem;
  }
  
  .promise-explanation-text{
    font-size: 0.95rem;
  }
  
  .promise-step-controls{
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .promise-playback-buttons{
    justify-content: center;
    width: 100%;
  }
  
  .promise-step-btn{
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }
  
  .btn-icon{
    font-size: 1rem;
  }
  
  .btn-label{
    font-size: 0.85rem;
  }
  
  .promise-step-info{
    width: 100%;
  }
  
  .promise-step-progress{
    justify-content: center;
  }
  
  .promise-step-desc{
    text-align: center;
  }
  
  .promise-svg text{
    font-size: 13px !important;
  }
  
  .promise-svg .promise-label{
    font-size: 11px !important;
  }
}
}

/* Medium screens: smaller panel width */
@media (min-width: 641px) and (max-width: 1200px){
  .promise-code-panel.active{
    width: 350px;
  }
}

/* Promise scenario code sections */
.promise-scenario{
  margin: 1.5rem 0;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(23,26,43,0.6) 0%, rgba(26,31,54,0.4) 100%);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

.promise-scenario h5{
  margin: 0 0 0.75rem 0;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

.promise-scenario .code{
  margin: 0;
}

/* Small screen tweaks: slightly reduce figure height by allowing text wrap */
@media (max-width: 640px){
  .http-figure{ padding: .75rem; }
}
@media (max-width: 640px){
  .http-svg .label{ font-size: 14px !important; }
  .http-svg .small{ font-size: 11px !important; }
}
@media (max-width: 760px){
  .toc-fab{ left: 50%; transform: translateX(-50%); padding: 14px 18px; font-size: 14px; }
}

/* Simulation controls */
.sim-controls{ display:flex; gap:10px; align-items:center; margin:.5rem 0 .5rem; flex-wrap: wrap; }
.sim-controls label{ color: var(--muted); font-size: 13px; display:flex; align-items:center; gap:6px; }
.sim-controls select{ appearance:none; background: var(--card); color: var(--text); border:1px solid var(--border); border-radius:8px; padding:6px 10px; font-size: 13px; cursor: pointer; }
.sim-controls button{ background: var(--card); color: var(--text); border:1px solid var(--border); border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; transition: all 0.2s ease; }
.sim-controls button:hover{ border-color: var(--accent); color: var(--accent); }
.sim-controls .spacer{ flex:1 1 auto; }

/* Simulation caption HUD */
.sim-caption{
  position:absolute; left: auto; top: 10px; right: 12px;
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  pointer-events: none;
  z-index: 2;
  max-width: 360px;
}

/* Push SVG content down so caption never overlaps it */
.http-figure .http-svg{ margin-top: 42px; }
@media (max-width: 640px){
  .http-figure .http-svg{ margin-top: 56px; }
}

/* Pulse highlight for nodes while processing */
@keyframes glowPulse{
  0%, 100% { filter: drop-shadow(0 0 0 rgba(122,162,255,0.0)); }
  50% { filter: drop-shadow(0 0 14px rgba(122,162,255,0.7)); }
}
.http-svg .pulse rect{
  stroke: var(--accent);
  stroke-width: 2.5;
  animation: glowPulse 0.8s ease-in-out infinite alternate;
}

/* New: Desktop collapsed rail behavior (unpinned) */
@media (min-width: 981px){
  .toc{ width: var(--toc-w-expanded); transition: width .38s cubic-bezier(.22,.61,.36,1), opacity .3s ease; overflow: hidden; }
  body.toc-collapsed .toc{ width: var(--toc-w-collapsed); background: transparent; border: 0; padding: 0; margin: 0; border-radius: 0; box-shadow: none; opacity: .5; overflow: visible; }
  body.toc-collapsed .toc:hover{ opacity: .75; }
  body.toc-collapsed .toc{ cursor: pointer; }
  body.toc-collapsed .toc .toc-title{ padding: 0; margin: 0; justify-content: center; background: transparent; }
  body.toc-collapsed .toc .toc-title h2,
  body.toc-collapsed .toc #toc-list,
  body.toc-collapsed .toc .toc-hide{ display: none; }
  /* Show tiny label in collapsed mode for discoverability */
  /* Removed mini label; collapsed rail now shows only pin button */
  /* Adjust content offset based on collapsed state */
  body.toc-collapsed .content{ margin-left: var(--toc-w-collapsed); }
  .toc .toc-pin{ width: 32px; height: 32px; padding: 0; align-items: center; justify-content: center; transition: background .25s ease, color .25s ease; }
  .toc .toc-pin svg{ display:block; width: 18px; height: 18px; }
}

/* Pretty, minimal scrollbars (WebKit + Firefox) */
/* Firefox */
html{ scrollbar-width: thin; scrollbar-color: rgba(122,162,255,.45) rgba(26,29,50,.4); }

/* WebKit */
*::-webkit-scrollbar{ width: 10px; height: 10px; }
*::-webkit-scrollbar-track{ background: rgba(26,29,50,.35); border-radius: 10px; }
*::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg, #3a4470, #2a3054);
  border: 1px solid var(--border);
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover{ background: linear-gradient(180deg, #48538a, #34407a); }

/* Make key areas a bit slimmer */
.toc::-webkit-scrollbar,
.runner-drawer .output::-webkit-scrollbar,
.runner-drawer .editor .CodeMirror-scroll::-webkit-scrollbar,
pre.code::-webkit-scrollbar{ width: 8px; height: 8px; }

/* Subtle inner shadows for tracks to blend in */
.toc::-webkit-scrollbar-track,
.runner-drawer .output::-webkit-scrollbar-track,
.runner-drawer .editor .CodeMirror-scroll::-webkit-scrollbar-track,
pre.code::-webkit-scrollbar-track{
  background: rgba(23,26,43,.45);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* Rounded, higher-contrast thumbs on hover within content areas */
.toc::-webkit-scrollbar-thumb,
.runner-drawer .output::-webkit-scrollbar-thumb,
.runner-drawer .editor .CodeMirror-scroll::-webkit-scrollbar-thumb,
pre.code::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg, #465184, #343d66);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.toc::-webkit-scrollbar-thumb:hover,
.runner-drawer .output::-webkit-scrollbar-thumb:hover,
.runner-drawer .editor .CodeMirror-scroll::-webkit-scrollbar-thumb:hover,
pre.code::-webkit-scrollbar-thumb:hover{ background: linear-gradient(180deg, #56629b, #3d4980); }

/* ============================================
   Fetch Evolution - Compact Tabbed Section
   ============================================ */

/* Playground container */
.fetch-evolution-playground {
  background: linear-gradient(135deg, #1a1e2e, #232838);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  border: 2px solid rgba(77,144,254,0.3);
}

.playground-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.playground-results {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 13px;
}

.playground-results .result-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.playground-results .label {
  color: #6b7280;
  font-size: 11px;
}

.playground-results .result-item span:last-child {
  color: #7db3ff;
}

.playground-results .result-main span:last-child {
  color: #22c55e;
  font-size: 18px;
  font-weight: bold;
}

.playground-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.evo-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  color: white;
  transition: transform 0.1s, opacity 0.2s;
}

.evo-btn:hover { transform: translateY(-1px); }
.evo-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.evo-btn-red { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.evo-btn-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.evo-btn-green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.evo-btn-purple { background: linear-gradient(135deg, #a855f7, #9333ea); }

.playground-log {
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 10px;
  font-family: 'Fira Code', ui-monospace, monospace;
  font-size: 11px;
  color: #a0a0a0;
  max-height: 150px;
  overflow-y: auto;
}

/* Tabs Container */
.evo-tabs-container {
  background: linear-gradient(135deg, #1a1e2e, #232838);
  border-radius: 12px;
  margin: 16px 0;
  border: 1px solid var(--border);
  overflow: hidden;
}

.evo-tabs {
  display: flex;
  gap: 0;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}

.evo-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: #8892b0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.evo-tab:hover {
  color: #ccd6f6;
  background: rgba(255,255,255,0.03);
}

.evo-tab.active {
  color: #7db3ff;
  background: rgba(77,144,254,0.08);
  border-bottom-color: #7db3ff;
}

.evo-panels {
  padding: 0;
}

.evo-panel {
  display: none;
}

.evo-panel.active {
  display: block;
}

.evo-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.evo-panel-header.bad { background: rgba(239, 68, 68, 0.08); }
.evo-panel-header.ok { background: rgba(251, 191, 36, 0.08); }
.evo-panel-header.good { background: rgba(34, 197, 94, 0.08); }
.evo-panel-header.best { background: rgba(168, 85, 247, 0.08); }

.evo-verdict {
  font-weight: bold;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
}

.evo-panel-header.bad .evo-verdict { background: #ef4444; color: white; }
.evo-panel-header.ok .evo-verdict { background: #fbbf24; color: #1a1e2e; }
.evo-panel-header.good .evo-verdict { background: #22c55e; color: #1a1e2e; }
.evo-panel-header.best .evo-verdict { background: #a855f7; color: white; }

/* Sync Warning Banner */
.sync-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(185, 28, 28, 0.15));
  border: 2px solid #ef4444;
  border-left-width: 4px;
  margin: 0;
}

.sync-warning .warning-icon {
  font-size: 24px;
  line-height: 1;
  animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.sync-warning .warning-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sync-warning .warning-content strong {
  color: #ef4444;
  font-size: 14px;
}

.sync-warning .warning-content span {
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.4;
}

.evo-desc {
  color: #8892b0;
  font-size: 12px;
}

.evo-panel .code {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: none;
}

/* Summary row */
.evo-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 16px 0;
  padding: 16px;
  background: linear-gradient(135deg, #1a1e2e, #232838);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.evo-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #a0a0a0;
}

.evo-summary-item .icon {
  font-size: 16px;
}

.evo-summary-item strong {
  color: #ccd6f6;
}

@media (max-width: 640px) {
  .evo-tabs {
    flex-wrap: wrap;
  }
  .evo-tab {
    flex: 1 1 45%;
    padding: 10px 6px;
    font-size: 11px;
  }
  .playground-buttons {
    flex-direction: column;
  }
  .evo-btn {
    min-width: 100%;
  }
}

/* ===== Light Theme Additional Overrides ===== */
[data-theme="light"] strong {
  color: #1a1a2e;
}

[data-theme="light"] .diagram-wrapper {
  background: linear-gradient(135deg, rgba(245,247,250,0.9), rgba(250,250,252,0.9));
  border: 1px solid rgba(74,124,212,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

[data-theme="light"] .diagram-wrapper::before {
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(74,124,212,0.05) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(74,124,212,0.05) 20px);
}

[data-theme="light"] .evo-summary-item strong {
  color: #1a1a2e;
}

[data-theme="light"] .playground-modal {
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .note {
  background: rgba(74,124,212,.1);
}

[data-theme="light"] .warn {
  background: rgba(231,76,60,.1);
}

/* Light theme for HTTP simulation SVG colors */
[data-theme="light"] svg text {
  fill: var(--text);
}

[data-theme="light"] .http-figure {
  background: linear-gradient(135deg, rgba(245,247,250,0.9), rgba(250,250,252,0.9));
}

/* ===== Main Site Integration Overrides ===== */

/* WebGL canvas is not used on course pages - removed from HTML */

/* Ensure content is above any background */
.site-header,
.course-layout {
  position: relative;
  z-index: 1;
}

/* Footer should stay below fixed sidebar */
.footer {
  position: relative;
  z-index: 0;
}

/* Footer Course-specific subtitle */
.footer-course-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.course-main {
  background: transparent;
}

.card {
  background: var(--card) !important;
}

/* Fixed controls (theme toggle) positioning */
.fixed-controls {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
}

/* Ensure theme toggle matches language button size */
.fixed-controls .theme-toggle {
  width: 80px;
  height: 40px;
}

@media (max-width: 768px) {
  .fixed-controls {
    bottom: 80px; /* Above mobile bottom nav */
    right: 1rem;
  }
  
  .fixed-controls .theme-toggle {
    width: 70px;
    height: 36px;
  }
  
  .fixed-controls .theme-toggle-slider {
    width: 28px;
    height: 28px;
    top: 2px;
    left: 2px;
  }
  
  [data-theme="light"] .fixed-controls .theme-toggle-slider {
    left: calc(100% - 32px);
  }
  
  .language-toggle-btn {
    bottom: 130px !important; /* Above theme toggle */
    right: 1rem !important;
    width: 70px !important;
    height: 36px !important;
    font-size: 11px !important;
  }
  
  .language-toggle-btn .lang-flag {
    font-size: 0.9rem !important;
  }
  
  /* Hide top-left sidebar toggle on mobile - use bottom nav instead */
  .sidebar-mobile-toggle {
    display: none !important;
  }
}

/* Course header styling - below main navbar */
.site-header {
  background: rgba(15,18,32,.95) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

[data-theme="light"] .site-header {
  background: rgba(255,255,255,.95) !important;
  border-bottom: 1px solid #e0e0e0;
}

.site-header .container {
  padding: 20px;
}

.site-header h1 {
  color: var(--text);
  margin-bottom: 8px;
}

/* Course navigation tabs */
.site-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.site-nav a {
  display: inline-block;
  padding: 8px 16px;
  background: rgba(122,162,255,.1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.site-nav a:hover {
  background: rgba(122,162,255,.2);
  color: var(--accent);
  border-color: var(--accent);
}

.site-nav a[aria-current="page"] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

[data-theme="light"] .site-nav a {
  background: rgba(74,124,212,.08);
  border-color: #d0d4dc;
}

[data-theme="light"] .site-nav a:hover {
  background: rgba(74,124,212,.15);
}

[data-theme="light"] .site-nav a[aria-current="page"] {
  background: #4a7cd4;
  color: #ffffff;
}

/* =============================================
   COMPREHENSIVE LIGHT THEME OVERRIDES
   ============================================= */

/* Text colors */
[data-theme="light"] strong {
  color: #1a1a2e;
}

[data-theme="light"] a {
  color: #4a7cd4;
}

/* Playground Modal */
[data-theme="light"] .playground-modal.open {
  background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .playground-container {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.98));
  border-color: rgba(74,124,212,0.3);
  box-shadow: 0 25px 80px rgba(0,0,0,.15),
              0 0 0 1px rgba(0,0,0,.05) inset,
              0 0 40px rgba(74,124,212,0.1);
}

[data-theme="light"] .playground-header {
  background: linear-gradient(180deg, rgba(248,250,252,0.9), rgba(241,245,249,0.9));
  border-bottom-color: rgba(74,124,212,0.2);
}

[data-theme="light"] .playground-title {
  color: #1a1a2e;
}

[data-theme="light"] .playground-title::before {
  color: #22c55e;
}

[data-theme="light"] .playground-btn {
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  color: #374151;
  border-color: #d1d5db;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .playground-btn:hover {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-color: #9ca3af;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="light"] .playground-btn.primary {
  background: linear-gradient(180deg, #10b981, #059669);
  color: #ffffff;
  border-color: #059669;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

[data-theme="light"] .playground-btn.primary:hover {
  background: linear-gradient(180deg, #34d399, #10b981);
  box-shadow: 0 4px 16px rgba(16,185,129,0.4);
}

[data-theme="light"] .playground-btn.danger {
  background: linear-gradient(180deg, #f87171, #ef4444);
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

[data-theme="light"] .playground-btn.danger:hover {
  box-shadow: 0 4px 16px rgba(239,68,68,0.4);
}

[data-theme="light"] .playground-btn.close-btn {
  background: linear-gradient(180deg, #f87171, #ef4444);
  border-color: #ef4444;
  color: #ffffff;
}

[data-theme="light"] .playground-panel {
  background: #ffffff;
  border-color: rgba(74,124,212,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Playground Panel Header */
[data-theme="light"] .playground-panel-header {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-bottom-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .playground-panel-title {
  color: #475569;
}

/* Editor Panel - Light theme with readable code */
[data-theme="light"] .playground-editor,
[data-theme="light"] .editor-panel {
  background: #f8fafc !important;
}

[data-theme="light"] .playground-editor .CodeMirror,
[data-theme="light"] .playground-editor .cm-s-material.CodeMirror {
  background: #f8fafc !important;
  color: #1e293b !important;
}

[data-theme="light"] .playground-editor .cm-s-material .CodeMirror-gutters {
  background: #f1f5f9 !important;
  border-right: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .playground-editor .CodeMirror-linenumber {
  color: #94a3b8 !important;
}

/* Light theme syntax highlighting for playground editor */
[data-theme="light"] .playground-editor .cm-s-material .cm-keyword {
  color: #8b5cf6 !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-def {
  color: #2563eb !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-variable {
  color: #1e293b !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-variable-2 {
  color: #0891b2 !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-string {
  color: #16a34a !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-string-2 {
  color: #dc2626 !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-number {
  color: #ea580c !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-atom {
  color: #ea580c !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-operator {
  color: #64748b !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-property {
  color: #0284c7 !important;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-comment {
  color: #94a3b8 !important;
  font-style: italic;
}

[data-theme="light"] .playground-editor .cm-s-material .cm-builtin {
  color: #c026d3 !important;
}

/* CodeMirror cursor and selection for light mode */
[data-theme="light"] .playground-editor .CodeMirror-cursor {
  border-left-color: #1e293b !important;
}

[data-theme="light"] .playground-editor .CodeMirror-selected {
  background: rgba(74, 124, 212, 0.2) !important;
}

[data-theme="light"] .playground-editor .CodeMirror-activeline-background {
  background: rgba(74, 124, 212, 0.08) !important;
}

/* Console Output Panel - Keep dark for terminal feel */
[data-theme="light"] .console-panel {
  background: #ffffff;
}

[data-theme="light"] .console-output {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}

/* Browser Preview Panel */
[data-theme="light"] .preview-panel {
  background: #ffffff;
}

[data-theme="light"] .browser-chrome {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

[data-theme="light"] .browser-title-bar {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
}

[data-theme="light"] .browser-preview-container {
  background: #ffffff;
}

/* Keyboard shortcuts footer */
[data-theme="light"] .playground-footer {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-top-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .playground-footer kbd {
  background: #ffffff;
  color: #374151;
  border-color: #d1d5db;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Editor and Console panels */
[data-theme="light"] .panel-header {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom-color: rgba(74,124,212,0.15);
  color: #374151;
}

[data-theme="light"] .panel-title {
  color: #1a1a2e;
}

[data-theme="light"] .console-output {
  background: #1e293b;
}

/* Play/Run button */
[data-theme="light"] .play-run {
  background: linear-gradient(180deg, #d4edda, #c3e6cb);
  color: #155724;
}

/* Diagram wrapper */
[data-theme="light"] .diagram-wrapper {
  background: linear-gradient(135deg, rgba(248,250,252,0.9), rgba(241,245,249,0.9));
  border-color: rgba(74,124,212,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
}

[data-theme="light"] .diagram-wrapper::before {
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(74,124,212,0.04) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(74,124,212,0.04) 20px);
}

/* Quick grid cards */
[data-theme="light"] .quick-card {
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.95));
  border-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .quick-card h4 {
  color: #1a1a2e;
}

/* Deep dive modals */
[data-theme="light"] .deep-modal {
  background: #ffffff;
  border-color: rgba(74,124,212,0.2);
  box-shadow: 0 25px 80px rgba(0,0,0,0.12);
}

[data-theme="light"] .deep-modal .dm-header {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .deep-modal .dm-title {
  color: #1a1a2e;
}

[data-theme="light"] .deep-section {
  background: #f8fafc;
  border-color: rgba(74,124,212,0.1);
}

[data-theme="light"] .deep-section h5 {
  color: #1a1a2e;
}

/* Tabs */
[data-theme="light"] .deep-tabs button {
  background: rgba(248,250,252,0.8);
  color: #4b5563;
  border-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .deep-tabs button:hover {
  background: rgba(74,124,212,0.1);
  color: #4a7cd4;
}

[data-theme="light"] .deep-tabs button[aria-selected="true"] {
  background: #4a7cd4;
  color: #ffffff;
}

/* Example panels - dark background for code readability */
[data-theme="light"] .mini-panel {
  background: #1e293b;
  border-color: #334155;
}

/* HTTP Figure */
[data-theme="light"] .http-figure {
  background: linear-gradient(135deg, rgba(248,250,252,0.95), rgba(241,245,249,0.95));
  border-color: rgba(74,124,212,0.2);
}

[data-theme="light"] svg text {
  fill: #1a1a2e;
}

[data-theme="light"] svg .node rect {
  fill: rgba(248,250,252,0.9);
  stroke: rgba(74,124,212,0.3);
}

/* Simulation controls */
[data-theme="light"] .sim-controls button {
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  color: #374151;
  border-color: rgba(74,124,212,0.25);
}

[data-theme="light"] .sim-controls button:hover {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-color: #4a7cd4;
}

[data-theme="light"] .sim-controls select {
  background: #ffffff;
  color: #374151;
  border-color: rgba(74,124,212,0.25);
}

[data-theme="light"] .sim-controls label {
  color: #4b5563;
}

/* Simulation caption HUD */
[data-theme="light"] .sim-caption {
  background: rgba(248,250,252,.95);
  border-color: rgba(74,124,212,0.2);
  color: #374151;
}

/* HTTP Figure container */
[data-theme="light"] .http-figure {
  background: #ffffff !important;
  border-color: rgba(74,124,212,0.15) !important;
}

/* Note / figcaption styling */
[data-theme="light"] .http-figure .note,
[data-theme="light"] figcaption.note {
  background: rgba(74,124,212,0.06);
  border-left: 4px solid #4a7cd4;
  color: #374151;
}

/* Cards and content sections */
[data-theme="light"] .card {
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.95)) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

[data-theme="light"] section[id] {
  background: transparent;
}

/* Code block inline code */
[data-theme="light"] code:not([class]) {
  background: rgba(74,124,212,0.1);
  color: #1a1a2e;
}

/* Deep overlay */
[data-theme="light"] .deep-overlay .dm-backdrop {
  background: rgba(255,255,255,0.6);
}

/* Evolution summary */
[data-theme="light"] .evo-summary-item {
  background: rgba(248,250,252,0.9);
  border-color: rgba(74,124,212,0.15);
}

[data-theme="light"] .evo-summary-item strong {
  color: #1a1a2e;
}

/* Footer for light theme */
[data-theme="light"] footer {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-top: 1px solid #d0d4dc;
}

[data-theme="light"] footer p,
[data-theme="light"] footer a {
  color: #4b5563;
}

[data-theme="light"] footer a:hover {
  color: #4a7cd4;
}

[data-theme="light"] .playground-output {
  color: #1a1a2e;
  background: rgba(248,250,252,0.5);
}

[data-theme="light"] .runner-drawer .editor .CodeMirror-linenumbers {
  color: #9ca3af;
}

/* Browser preview panel */
[data-theme="light"] .browser-chrome {
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
}

/* WebGL canvas adjustment for light theme */
[data-theme="light"] #fluid-canvas {
  opacity: 0.3;
}

[data-theme="light"] #fluid-canvas.loaded {
  opacity: 0.25;
}

/* =============================================
   INLINE STYLE OVERRIDES FOR LIGHT THEME
   (Override hardcoded dark colors in HTML)
   ============================================= */

/* "What You'll Learn" section with inline styles */
[data-theme="light"] #intro > div[style*="linear-gradient"] {
  background: linear-gradient(135deg, #f8fafc, #eef2f7) !important;
  border-color: rgba(74,124,212,0.3) !important;
}

[data-theme="light"] #intro > div[style*="linear-gradient"] h4[style*="color"] {
  color: #4a7cd4 !important;
}

[data-theme="light"] #intro > div[style*="linear-gradient"] ul {
  color: #4b5563 !important;
}

[data-theme="light"] #intro > div[style*="linear-gradient"] div[style*="rgba(0,0,0,0.3)"] {
  background: rgba(74,124,212,0.1) !important;
}

[data-theme="light"] #intro > div[style*="linear-gradient"] h5[style*="color"] {
  color: #d97706 !important;
}

/* HTTP SVG light theme - override inline CSS vars */
[data-theme="light"] {
  --card-bg: #f8fafc;
  --fg: #1a1a2e;
  --fg-muted: #4b5563;
}

[data-theme="light"] .http-figure {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important;
  border-color: rgba(74,124,212,0.2) !important;
}

[data-theme="light"] .http-svg .node {
  fill: #ffffff !important;
  stroke: rgba(74,124,212,0.3) !important;
}

[data-theme="light"] .http-svg .node:hover {
  fill: #f8fafc !important;
  stroke: #4a7cd4 !important;
}

[data-theme="light"] .http-svg .label {
  fill: #1a1a2e !important;
}

[data-theme="light"] .http-svg .small {
  fill: #4b5563 !important;
}

[data-theme="light"] .http-svg text {
  fill: #1a1a2e;
}

[data-theme="light"] .http-svg .legend rect {
  fill: rgba(248,250,252,0.95) !important;
  stroke: rgba(74,124,212,0.2) !important;
}

/* Popover (envelope hover tooltip) in light theme */
[data-theme="light"] .http-svg .popover rect {
  fill: rgba(255,255,255,0.98) !important;
  stroke: rgba(74,124,212,0.3) !important;
}

[data-theme="light"] .http-svg .popover text {
  fill: #1a1a2e !important;
}

[data-theme="light"] .http-svg .popover text[font-weight="600"] {
  fill: #0f172a !important;
}

/* Quick grid cards in light theme */
[data-theme="light"] .quick-grid .q {
  background: #ffffff !important;
  border-color: rgba(74,124,212,0.15) !important;
}

[data-theme="light"] .quick-grid .q h4 {
  color: #1a1a2e !important;
}

[data-theme="light"] .quick-grid .q p {
  color: #4b5563 !important;
}

/* Deep trigger button */
[data-theme="light"] .deep-trigger {
  background: linear-gradient(180deg, #ffffff, #f1f5f9) !important;
  color: #4a7cd4 !important;
  border-color: rgba(74,124,212,0.25) !important;
}

[data-theme="light"] .deep-trigger:hover {
  color: #3b6fc4 !important;
}

/* Deep modal light theme - comprehensive overrides */
[data-theme="light"] .deep-modal {
  background: #ffffff !important;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05) !important;
}

[data-theme="light"] .deep-backdrop {
  background: rgba(0,0,0,0.5) !important;
}

[data-theme="light"] .deep-header {
  border-bottom-color: rgba(74,124,212,0.15) !important;
}

[data-theme="light"] .deep-tab {
  background: linear-gradient(180deg, #ffffff, #f1f5f9) !important;
  color: #4b5563 !important;
  border-color: rgba(74,124,212,0.2) !important;
}

[data-theme="light"] .deep-tab:hover {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0) !important;
  color: #4a7cd4 !important;
}

[data-theme="light"] .deep-tab[aria-selected="true"] {
  background: linear-gradient(180deg, #4a7cd4, #3b6fc4) !important;
  color: #ffffff !important;
  border-color: #4a7cd4 !important;
}

[data-theme="light"] .deep-close {
  background: linear-gradient(180deg, #fef2f2, #fee2e2) !important;
  color: #b91c1c !important;
  border-color: rgba(185, 28, 28, 0.25) !important;
}

[data-theme="light"] .deep-close:hover {
  background: linear-gradient(180deg, #fee2e2, #fecaca) !important;
}

[data-theme="light"] .deep-body {
  color: #374151 !important;
}

[data-theme="light"] .deep-panel h4 {
  color: #1a1a2e !important;
}

[data-theme="light"] .deep-panel h5 {
  color: #4b5563 !important;
}

[data-theme="light"] .deep-panel ul,
[data-theme="light"] .deep-panel li {
  color: #4b5563 !important;
}

[data-theme="light"] .deep-panel p {
  color: #374151 !important;
}

[data-theme="light"] .deep-section {
  background: #f8fafc !important;
  border-color: rgba(74,124,212,0.15) !important;
}

[data-theme="light"] .deep-section h5 {
  color: #1a1a2e !important;
}

[data-theme="light"] .deep-panel code,
[data-theme="light"] .deep-panel :not(pre).code {
  background: rgba(37, 99, 235, 0.15) !important;
  color: #1d4ed8 !important;
  border-color: rgba(37, 99, 235, 0.3) !important;
  font-weight: 600 !important;
}

[data-theme="light"] .deep-section pre.code {
  background: #1e293b !important;
  border-color: #334155 !important;
}

[data-theme="light"] .deep-section pre.code code {
  color: #e2e8f0 !important;
  background: transparent !important;
  border: none !important;
  padding: 12px 16px;
}

/* Mini tabs in deep panels */
[data-theme="light"] .mini-tab {
  background: linear-gradient(180deg, #ffffff, #f1f5f9) !important;
  color: #4b5563 !important;
  border-color: rgba(74,124,212,0.2) !important;
}

[data-theme="light"] .mini-tab:hover {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0) !important;
  color: #4a7cd4 !important;
}

[data-theme="light"] .mini-tab[aria-selected="true"] {
  background: linear-gradient(180deg, #4a7cd4, #3b6fc4) !important;
  color: #ffffff !important;
}

[data-theme="light"] .mini-panel {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}

/* HTTP message highlights in deep panels */
[data-theme="light"] .ex-start {
  color: #5eead4 !important;
}

[data-theme="light"] .ex-header {
  color: #94a3b8 !important;
}

[data-theme="light"] .ex-body {
  color: #fbbf24 !important;
}

/* Pills in deep panels */
[data-theme="light"] .pill {
  background: rgba(248,250,252,0.9) !important;
  color: #4b5563 !important;
  border-color: rgba(74,124,212,0.2) !important;
}

[data-theme="light"] .pill.start {
  background: rgba(16, 185, 129, 0.1) !important;
  color: #047857 !important;
  border-color: rgba(4, 120, 87, 0.3) !important;
}

[data-theme="light"] .pill.header {
  background: rgba(74, 124, 212, 0.1) !important;
  color: #3b6fc4 !important;
  border-color: rgba(74, 124, 212, 0.3) !important;
}

[data-theme="light"] .pill.body {
  background: rgba(168, 85, 247, 0.1) !important;
  color: #7c3aed !important;
  border-color: rgba(124, 58, 237, 0.3) !important;
}

/* Simulation caption */
[data-theme="light"] .sim-caption {
  color: #4b5563;
}

/* Note/figcaption in light theme */
[data-theme="light"] .note,
[data-theme="light"] figcaption.note {
  background: rgba(74,124,212,0.08) !important;
  color: #4b5563 !important;
  border-left-color: #4a7cd4 !important;
}

/* =============================================
   LEARNING GOALS SECTION STYLES
   ============================================= */

.learning-goals-box {
  background: linear-gradient(135deg, #1a1e2e, #232838);
  border-radius: 12px;
  padding: 24px;
  margin: 20px 0;
  border: 1px solid rgba(77,144,254,0.3);
}

[data-theme="light"] .learning-goals-box {
  background: linear-gradient(135deg, #f8fafc, #eef2f7);
  border-color: rgba(74,124,212,0.25);
}

.learning-goals-title {
  color: #7db3ff;
  margin: 0 0 16px 0;
  font-size: 16px;
}

[data-theme="light"] .learning-goals-title {
  color: #4a7cd4;
}

.learning-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.learning-card {
  border-radius: 10px;
  padding: 16px;
  border-width: 2px;
  border-style: solid;
}

.learning-card-blue {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

.learning-card-yellow {
  background: rgba(251, 191, 36, 0.1);
  border-color: #fbbf24;
}

.learning-card-green {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
}

.learning-card-purple {
  background: rgba(168, 85, 247, 0.1);
  border-color: #a855f7;
}

[data-theme="light"] .learning-card-blue {
  background: rgba(59, 130, 246, 0.08);
}

[data-theme="light"] .learning-card-yellow {
  background: rgba(251, 191, 36, 0.08);
}

[data-theme="light"] .learning-card-green {
  background: rgba(34, 197, 94, 0.08);
}

[data-theme="light"] .learning-card-purple {
  background: rgba(168, 85, 247, 0.08);
}

.learning-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.learning-icon {
  font-size: 28px;
}

.learning-card-title {
  font-weight: bold;
  font-size: 15px;
}

.learning-list {
  color: #b0c4de;
  font-size: 12px;
  margin: 0;
  padding-left: 20px;
}

[data-theme="light"] .learning-list {
  color: #4b5563;
}

.course-flow-box {
  margin-top: 20px;
  background: rgba(0,0,0,0.3);
  padding: 16px;
  border-radius: 8px;
}

[data-theme="light"] .course-flow-box {
  background: rgba(74,124,212,0.08);
}

.course-flow-title {
  color: #f59e0b;
  margin: 0 0 12px 0;
  font-size: 13px;
}

[data-theme="light"] .course-flow-title {
  color: #d97706;
}

.course-flow-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.flow-step {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.flow-step-blue {
  background: #3b82f6;
  color: white;
}

.flow-step-yellow {
  background: #fbbf24;
  color: #000;
}

.flow-step-green {
  background: #22c55e;
  color: #000;
}

.flow-step-purple {
  background: #a855f7;
  color: white;
}

.flow-arrow {
  color: #6b7280;
}

[data-theme="light"] .flow-arrow {
  color: #9ca3af;
}

/* Mobile responsive for course flow */
@media (max-width: 640px) {
  .course-flow-steps {
    flex-direction: column;
    gap: 6px;
  }
  
  .flow-arrow {
    transform: rotate(90deg);
    font-size: 14px;
    margin: 2px 0;
  }
  
  .flow-step {
    width: 100%;
    text-align: center;
    padding: 10px 16px;
    font-size: 12px;
  }
  
  .course-flow-box {
    padding: 14px;
  }
  
  .course-flow-title {
    text-align: center;
    font-size: 14px;
  }
}

/* =============================================
   ARCHITECTURE DIAGRAMS (JS Engine & Node.js)
   ============================================= */

.arch-diagram {
  background: linear-gradient(135deg, #1a1e2e, #232838);
  border-radius: 12px;
  padding: 24px;
  margin: 20px 0;
  border: 1px solid rgba(77,144,254,0.3);
}

[data-theme="light"] .arch-diagram {
  background: linear-gradient(135deg, #f8fafc, #eef2f7);
  border-color: rgba(74,124,212,0.25);
}

.arch-diagram-title {
  color: #7db3ff;
  margin: 0 0 16px 0;
  font-size: 16px;
}

[data-theme="light"] .arch-diagram-title {
  color: #4a7cd4;
}

.arch-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.arch-box {
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  min-width: 120px;
  border-width: 2px;
  border-style: solid;
}

.arch-box-yellow {
  background: rgba(251, 191, 36, 0.2);
  border-color: #fbbf24;
}

.arch-box-blue {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
}

.arch-box-green {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
}

.arch-box-purple {
  background: rgba(168, 85, 247, 0.2);
  border-color: #a855f7;
}

.arch-box-red {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.arch-box-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.arch-box-title {
  font-weight: bold;
  font-size: 13px;
}

.arch-box-yellow .arch-box-title { color: #fbbf24; }
.arch-box-blue .arch-box-title { color: #3b82f6; }
.arch-box-green .arch-box-title { color: #22c55e; }
.arch-box-purple .arch-box-title { color: #a855f7; }
.arch-box-red .arch-box-title { color: #ef4444; }

[data-theme="light"] .arch-box-yellow .arch-box-title { color: #b45309; }
[data-theme="light"] .arch-box-blue .arch-box-title { color: #1d4ed8; }
[data-theme="light"] .arch-box-green .arch-box-title { color: #15803d; }
[data-theme="light"] .arch-box-purple .arch-box-title { color: #7c3aed; }
[data-theme="light"] .arch-box-red .arch-box-title { color: #dc2626; }

.arch-box-subtitle {
  color: #6b7280;
  font-size: 10px;
}

[data-theme="light"] .arch-box-subtitle {
  color: #4b5563;
}

.arch-arrow {
  color: #6b7280;
  font-size: 20px;
}

[data-theme="light"] .arch-arrow {
  color: #9ca3af;
}

/* Mobile responsive for arch-flow diagrams */
@media (max-width: 640px) {
  .arch-flow {
    flex-direction: column;
    gap: 8px;
  }
  
  /* Only rotate arrows inside .arch-flow (horizontal → becomes vertical ↓) */
  .arch-flow > .arch-arrow {
    transform: rotate(90deg);
    font-size: 18px;
    margin: 4px 0;
  }
  
  .arch-box {
    width: 100%;
    max-width: 200px;
    padding: 14px;
    min-width: unset;
  }
  
  .arch-box-icon {
    font-size: 28px;
  }
  
  .arch-box-title {
    font-size: 14px;
  }
  
  .arch-box-subtitle {
    font-size: 11px;
  }
}

/* Concept cards in architecture diagrams */
.arch-concepts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.arch-concept {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 8px;
  border-left-width: 3px;
  border-left-style: solid;
}

[data-theme="light"] .arch-concept {
  background: rgba(255,255,255,0.7);
}

.arch-concept-blue { border-left-color: #3b82f6; }
.arch-concept-green { border-left-color: #22c55e; }
.arch-concept-purple { border-left-color: #a855f7; }
.arch-concept-orange { border-left-color: #f59e0b; }

.arch-concept-title {
  font-size: 11px;
  font-weight: bold;
}

.arch-concept-blue .arch-concept-title { color: #3b82f6; }
.arch-concept-green .arch-concept-title { color: #22c55e; }
.arch-concept-purple .arch-concept-title { color: #a855f7; }
.arch-concept-orange .arch-concept-title { color: #f59e0b; }

[data-theme="light"] .arch-concept-blue .arch-concept-title { color: #1d4ed8; }
[data-theme="light"] .arch-concept-green .arch-concept-title { color: #15803d; }
[data-theme="light"] .arch-concept-purple .arch-concept-title { color: #7c3aed; }
[data-theme="light"] .arch-concept-orange .arch-concept-title { color: #d97706; }

.arch-concept-desc {
  color: #b0c4de;
  font-size: 11px;
}

[data-theme="light"] .arch-concept-desc {
  color: #4b5563;
}

/* Use case tags */
.arch-use-cases {
  margin-top: 20px;
}

.arch-use-cases-label {
  color: #6b7280;
  font-size: 11px;
  text-align: center;
  margin-bottom: 8px;
}

[data-theme="light"] .arch-use-cases-label {
  color: #4b5563;
}

.arch-use-cases-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.arch-tag {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
}

.arch-tag-green {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.arch-tag-blue {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.arch-tag-purple {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.arch-tag-yellow {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

[data-theme="light"] .arch-tag-green { color: #15803d; }
[data-theme="light"] .arch-tag-blue { color: #1d4ed8; }
[data-theme="light"] .arch-tag-purple { color: #7c3aed; }
[data-theme="light"] .arch-tag-yellow { color: #b45309; }

/* Node.js architecture vertical layout */
.arch-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto;
}

.arch-vertical .arch-box {
  padding: 14px;
  border-radius: 8px;
}

.arch-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.arch-grid-2 .arch-box {
  padding: 12px;
}

.arch-grid-2 .arch-box-title {
  font-size: 12px;
}

/* Mobile responsive for Node.js architecture */
@media (max-width: 640px) {
  .arch-vertical {
    max-width: 100%;
    gap: 4px;
    align-items: center;
  }
  
  .arch-vertical .arch-box {
    padding: 12px;
    width: 100%;
    max-width: 280px;
  }
  
  /* Arrows in vertical layouts - already pointing down, just style them */
  .arch-vertical > .arch-arrow {
    font-size: 20px;
    margin: 6px 0;
    color: #9ca3af;
    transform: none; /* Don't rotate - already ↓ */
    text-align: center;
    width: 100%;
    display: block;
  }
  
  /* Keep V8 and libuv side by side on mobile */
  .arch-grid-2 {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    max-width: 280px;
    margin: 0 auto;
  }
  
  .arch-grid-2 .arch-box {
    padding: 10px 8px;
  }
  
  .arch-grid-2 .arch-box-title {
    font-size: 11px;
  }
  
  .arch-grid-2 .arch-box-subtitle {
    font-size: 9px;
  }
  
  .arch-use-cases {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
  }
  
  .arch-use-cases-list {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
  }
}

/* ===== ENHANCEMENTS ===== */

/* 1. Learning Card Hover Effects - MORE PROMINENT */
.learning-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              box-shadow 0.3s ease, 
              border-color 0.3s ease,
              background 0.3s ease;
  cursor: pointer;
}

.learning-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.learning-card-blue:hover {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.15) !important;
  box-shadow: 0 20px 40px rgba(59, 130, 246, 0.35), 0 0 0 1px rgba(59, 130, 246, 0.3);
}

.learning-card-yellow:hover {
  border-color: #fcd34d;
  background: rgba(251, 191, 36, 0.15) !important;
  box-shadow: 0 20px 40px rgba(251, 191, 36, 0.35), 0 0 0 1px rgba(251, 191, 36, 0.3);
}

.learning-card-green:hover {
  border-color: #4ade80;
  background: rgba(34, 197, 94, 0.15) !important;
  box-shadow: 0 20px 40px rgba(34, 197, 94, 0.35), 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.learning-card-purple:hover {
  border-color: #c084fc;
  background: rgba(168, 85, 247, 0.15) !important;
  box-shadow: 0 20px 40px rgba(168, 85, 247, 0.35), 0 0 0 1px rgba(168, 85, 247, 0.3);
}

[data-theme="light"] .learning-card:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .learning-card-blue:hover {
  box-shadow: 0 20px 40px rgba(59, 130, 246, 0.25), 0 0 0 1px rgba(59, 130, 246, 0.4);
}

[data-theme="light"] .learning-card-yellow:hover {
  box-shadow: 0 20px 40px rgba(251, 191, 36, 0.25), 0 0 0 1px rgba(251, 191, 36, 0.4);
}

[data-theme="light"] .learning-card-green:hover {
  box-shadow: 0 20px 40px rgba(34, 197, 94, 0.25), 0 0 0 1px rgba(34, 197, 94, 0.4);
}

[data-theme="light"] .learning-card-purple:hover {
  box-shadow: 0 20px 40px rgba(168, 85, 247, 0.25), 0 0 0 1px rgba(168, 85, 247, 0.4);
}

/* 2. Improved Sidebar Active State - MORE VISIBLE */
.course-toc a.active {
  position: relative;
  font-weight: 600 !important;
  color: var(--accent) !important;
}

.course-toc a.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent);
}

[data-theme="light"] .course-toc a.active::before {
  background: linear-gradient(180deg, #4a7cd4, #7c3aed);
  box-shadow: 0 0 8px rgba(74, 124, 212, 0.5);
}

/* Smooth sidebar link transitions */
.course-toc a {
  transition: color 0.2s ease, padding-left 0.2s ease, background 0.2s ease;
  border-radius: 4px;
  padding: 4px 8px;
  margin: -4px -8px;
}

.course-toc a:hover {
  padding-left: 12px;
  background: rgba(122, 162, 255, 0.1);
}

[data-theme="light"] .course-toc a:hover {
  background: rgba(74, 124, 212, 0.1);
}

/* 3. Enhanced Code Blocks */
pre, code {
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

pre {
  position: relative;
  border-left: 3px solid var(--accent);
}

pre:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] pre:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Code block language label */
pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--accent);
  color: white;
  border-radius: 0 var(--radius) 0 6px;
  opacity: 0.85;
}

[data-theme="light"] pre {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

/* 4. Card Hover Enhancement - MORE NOTICEABLE */
/* Only apply to cards that are not inside modals */
.card:not(.deep-modal .card):not(.deep-overlay .card) {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}

.card:not(.deep-modal .card):not(.deep-overlay .card):hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--accent);
  border-color: var(--accent);
}

[data-theme="light"] .card:not(.deep-modal .card):not(.deep-overlay .card):hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--accent);
}

/* 5. Focus States for Accessibility */
a:focus-visible,
button:focus-visible,
.toggle-theme:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* 6. Better Selection Styling */
::selection {
  background: var(--accent);
  color: white;
}

[data-theme="light"] ::selection {
  background: #4a7cd4;
  color: white;
}

/* 7. Smooth Icon Animations - MORE BOUNCE */
.learning-icon {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}

.learning-card:hover .learning-icon {
  transform: scale(1.25) rotate(-5deg);
}

/* 8. Button Hover Enhancements */
.btn {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(122, 162, 255, 0.4);
}

[data-theme="light"] .btn-primary:hover {
  box-shadow: 0 8px 20px rgba(74, 124, 212, 0.3);
}

/* 9. Deep Dive Button Enhancement */
.deep-toggle {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease !important;
}

.deep-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(122, 162, 255, 0.4);
}

/* 10. TOC Toggle Animation */
.toc-toggle {
  transition: transform 0.2s ease, background 0.2s ease;
}

.toc-toggle:hover {
  transform: scale(1.1);
  background: var(--accent);
}

/* ===== PRINT STYLES ===== */
@media print {
  /* Hide non-essential elements */
  .course-toc,
  .toc-toggle,
  nav,
  .toggle-theme,
  .deep-overlay,
  .deep-modal,
  .sidebar,
  footer,
  .course-flow-box,
  button {
    display: none !important;
  }
  
  /* Reset page layout */
  body {
    padding: 0 !important;
    background: white !important;
    color: black !important;
    font-size: 12pt !important;
  }
  
  main {
    margin: 0 !important;
    padding: 20px !important;
    max-width: 100% !important;
  }
  
  /* Make content readable */
  .card {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  h1, h2, h3 {
    color: black !important;
    page-break-after: avoid;
  }
  
  pre, code {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    color: black !important;
    font-size: 10pt !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
  }
  
  /* SVG diagrams - ensure visibility */
  svg {
    max-width: 100% !important;
  }
  
  svg text {
    fill: black !important;
  }
  
  svg rect, svg path {
    stroke: #333 !important;
  }
  
  /* Links - show URL */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
  }
  
  /* Page margins */
  @page {
    margin: 1.5cm;
  }
}

/* ===== ENHANCEMENT: Reading Progress Bar ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 9999;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px var(--accent);
}

/* ===== ENHANCEMENT: Breadcrumb Navigation ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb-separator {
  color: var(--muted);
  opacity: 0.5;
}

.breadcrumb-current {
  color: var(--accent);
  font-weight: 500;
}

/* ===== ENHANCEMENT: Section Navigation (Next/Prev) ===== */
.section-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.section-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  flex: 1;
  max-width: 45%;
}

.section-nav-btn:hover {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.1);
  transform: translateY(-2px);
}

.section-nav-btn.prev {
  justify-content: flex-start;
}

.section-nav-btn.next {
  justify-content: flex-end;
  margin-left: auto;
}

.section-nav-btn .nav-arrow {
  font-size: 1.25rem;
  color: var(--accent);
}

.section-nav-btn .nav-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
}

.section-nav-btn .nav-title {
  font-weight: 500;
}

.section-nav-btn .nav-content {
  display: flex;
  flex-direction: column;
}

/* ===== ENHANCEMENT: Reading Time Estimates ===== */
.reading-time {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.75rem;
  padding: 0.25rem 0.6rem;
  background: rgba(122, 162, 255, 0.1);
  border-radius: 20px;
}

.reading-time svg {
  width: 14px;
  height: 14px;
}

/* ===== ENHANCEMENT: Scroll Animations ===== */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll.delay-1 { transition-delay: 0.1s; }
.animate-on-scroll.delay-2 { transition-delay: 0.2s; }
.animate-on-scroll.delay-3 { transition-delay: 0.3s; }

/* ===== ENHANCEMENT: Section Completion Checkmarks ===== */
.sidebar-link.completed .link-number {
  background: var(--green) !important;
  color: transparent !important;
  position: relative;
}

.sidebar-link.completed .link-number::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: bold;
  color: #000;
}

.sidebar-link.completed .link-text {
  color: var(--green);
}

/* Progress indicator in sidebar header - consolidated */
.sidebar-progress {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-progress-bar-container {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.sidebar-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

.sidebar-progress-text {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  display: block;
}

/* ===== ENHANCEMENT: Copy Button Feedback ===== */
.copy {
  position: relative;
}

.copy.copied {
  background: var(--green) !important;
  color: #000 !important;
}

.copy.copied::after {
  content: 'Copied!';
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #000;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  animation: fadeInOut 1.5s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ===== ENHANCEMENT: Floating Controls Group ===== */
.floating-controls {
  position: fixed;
  right: 20px;
  bottom: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 998;
}

.floating-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.floating-btn:hover {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.1);
  color: var(--accent);
  transform: scale(1.1);
}

.floating-btn svg {
  width: 18px;
  height: 18px;
}

/* Font Size Controls */
.font-size-controls {
  display: none; /* Hidden - merged into floating controls */
}

.font-size-btn {
  font-weight: bold;
  font-size: 0.85rem;
}

/* Font size classes */
.font-size-small { font-size: 14px !important; }
.font-size-normal { font-size: 16px !important; }
.font-size-large { font-size: 18px !important; }
.font-size-xlarge { font-size: 20px !important; }

/* ===== ENHANCEMENT: Keyboard Shortcuts Modal ===== */
.keyboard-shortcuts-hint {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.75rem;
  font-size: 0.7rem;
  color: var(--muted);
  z-index: 998;
  opacity: 0.5;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.keyboard-shortcuts-hint:hover {
  opacity: 1;
  border-color: var(--accent);
}

.keyboard-shortcuts-hint kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-size: 0.65rem;
  margin-right: 0.25rem;
}

/* Hide on mobile */
@media (max-width: 768px) {
  .keyboard-shortcuts-hint {
    display: none;
  }
}

/* Keyboard shortcuts help modal */
.shortcuts-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  min-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.shortcuts-modal.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.shortcuts-modal h4 {
  margin: 0 0 1rem;
  color: var(--accent);
}

.shortcuts-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.shortcuts-modal-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-keys kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  margin-right: 0.25rem;
}

/* ===== ENHANCEMENT: Quick Jump Button (Hidden - use sidebar) ===== */
.quick-jump-btn {
  display: none;
}

.quick-jump-menu {
  display: none;
}

/* ===== ENHANCEMENT: Bottom Mobile Navigation ===== */
/* Hidden on desktop */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    z-index: 1000;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
  }
  
  .mobile-bottom-nav button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.2s;
  }
  
  .mobile-bottom-nav button:hover,
  .mobile-bottom-nav button.active {
    color: var(--accent);
  }
  
  .mobile-bottom-nav svg {
    width: 20px;
    height: 20px;
  }
  
  /* Adjust footer for bottom nav */
  .footer {
    margin-bottom: 60px;
  }
  
  /* Hide desktop-only controls on mobile */
  .font-size-controls,
  .keyboard-shortcuts-hint,
  .quick-jump-btn,
  .quick-jump-menu {
    display: none;
  }
}

/* ===== ENHANCEMENT: Scroll to Top Button ===== */
.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 220px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: var(--shadow);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  border-color: var(--accent);
  background: rgba(122, 162, 255, 0.1);
  transform: translateY(-3px);
}

/* ===== ENHANCEMENT: Glossary Tooltips ===== */
.glossary-term {
  border-bottom: 1px dashed var(--accent);
  cursor: help;
  position: relative;
}

.glossary-term:hover::after {
  content: attr(data-definition);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  max-width: 300px;
  white-space: normal;
  z-index: 100;
  box-shadow: var(--shadow);
}

@media (max-width: 768px) {
  .section-nav {
    flex-direction: column;
  }
  
  .section-nav-btn {
    max-width: 100%;
  }
  
  .breadcrumb {
    font-size: 0.75rem;
  }
}

/* ===== KEYBOARD SHORTCUTS MODAL ===== */
.keyboard-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}

.keyboard-modal.active {
  display: flex;
}

.keyboard-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(450px, 90vw);
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.keyboard-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.keyboard-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.keyboard-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.keyboard-modal-close:hover {
  color: var(--accent);
}

.keyboard-modal-body {
  padding: 1.5rem;
}

.shortcut-group {
  margin-bottom: 1.5rem;
}

.shortcut-group:last-child {
  margin-bottom: 0;
}

.shortcut-group h4 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

.shortcut-item kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .shortcut-item kbd {
  background: linear-gradient(180deg, #fff, #f0f0f0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.shortcut-item span {
  color: var(--text);
  font-size: 0.9rem;
}

/* ===== PLAYGROUND MODAL ===== */
.playground-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.playground-modal.active {
  display: flex;
}

.playground-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(900px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.playground-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.playground-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.playground-modal-header h3::before {
  content: '▶';
  color: var(--accent);
  font-size: 0.9rem;
}

.playground-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.2s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.playground-modal-close:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.playground-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.playground-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  min-height: 200px;
}

.playground-editor-header,
.playground-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playground-run-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.playground-run-btn:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.playground-run-btn:active {
  transform: translateY(0);
}

.playground-clear-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.playground-clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#playground-code {
  flex: 1;
  width: 100%;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: none;
  color: var(--text);
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

[data-theme="light"] #playground-code {
  background: rgba(0, 0, 0, 0.03);
}

#playground-code:focus {
  background: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] #playground-code:focus {
  background: rgba(0, 0, 0, 0.05);
}

.playground-output {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  max-height: 250px;
}

#playground-result {
  flex: 1;
  margin: 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  color: #a5d6a7;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="light"] #playground-result {
  background: rgba(0, 0, 0, 0.05);
  color: #2e7d32;
}

#playground-result .error {
  color: #ff6b6b;
}

#playground-result .log {
  color: #a5d6a7;
}

[data-theme="light"] #playground-result .log {
  color: #2e7d32;
}

#playground-result .warn {
  color: #ffd54f;
}

#playground-result .info {
  color: #64b5f6;
}

@media (max-width: 768px) {
  .playground-modal-content {
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }
  
  .playground-editor,
  .playground-output {
    min-height: 150px;
  }
}

/* =============================================
   LIGHT MODE - CODE SYNTAX HIGHLIGHTING
   True light theme with readable colors on light background
   ============================================= */

/* Code blocks get light background in light mode */
[data-theme="light"] pre.code {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

[data-theme="light"] pre.code code {
  background: transparent !important;
  color: #1e293b !important;
}

[data-theme="light"] .code {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

/* CodeMirror syntax highlighting - True Light Theme */
/* Optimized for light backgrounds with good contrast */
[data-theme="light"] .cm-s-material .cm-keyword {
  color: #8b5cf6 !important; /* Purple - keywords like const, let, function */
}

[data-theme="light"] .cm-s-material .cm-def {
  color: #2563eb !important; /* Blue - function/variable definitions */
}

[data-theme="light"] .cm-s-material .cm-variable {
  color: #1e293b !important; /* Dark text - variables */
}

[data-theme="light"] .cm-s-material .cm-variable-2 {
  color: #0891b2 !important; /* Teal - secondary variables */
}

[data-theme="light"] .cm-s-material .cm-variable-3,
[data-theme="light"] .cm-s-material .cm-type {
  color: #0d9488 !important; /* Teal - types */
}

[data-theme="light"] .cm-s-material .cm-string {
  color: #16a34a !important; /* Green - strings */
}

[data-theme="light"] .cm-s-material .cm-string-2 {
  color: #dc2626 !important; /* Red - template literals */
}

[data-theme="light"] .cm-s-material .cm-number {
  color: #ea580c !important; /* Orange - numbers */
}

[data-theme="light"] .cm-s-material .cm-atom {
  color: #ea580c !important; /* Orange - true, false, null, undefined */
}

[data-theme="light"] .cm-s-material .cm-operator {
  color: #64748b !important; /* Slate - operators */
}

[data-theme="light"] .cm-s-material .cm-property {
  color: #0284c7 !important; /* Sky blue - object properties */
}

[data-theme="light"] .cm-s-material .cm-comment {
  color: #94a3b8 !important; /* Muted gray - comments */
  font-style: italic;
}

[data-theme="light"] .cm-s-material .cm-builtin {
  color: #c026d3 !important; /* Fuchsia - built-in functions */
}

[data-theme="light"] .cm-s-material .cm-meta {
  color: #9333ea !important; /* Purple - meta info */
}

[data-theme="light"] .cm-s-material .cm-tag {
  color: #dc2626 !important; /* Red - HTML tags */
}

[data-theme="light"] .cm-s-material .cm-attribute {
  color: #ca8a04 !important; /* Amber - HTML attributes */
}

[data-theme="light"] .cm-s-material .cm-qualifier {
  color: #0d9488 !important; /* Teal - CSS qualifiers */
}

[data-theme="light"] .cm-s-material .cm-bracket {
  color: #475569 !important; /* Slate - brackets */
}

[data-theme="light"] .cm-s-material .cm-error {
  color: #dc2626 !important; /* Red - errors */
}

/* ===== Next Section CTA Component ===== */
.next-section-cta {
  position: relative;
  margin: 3rem 0 0;
  padding: 3rem 2rem;
  background: linear-gradient(135deg, 
    rgba(122, 162, 255, 0.08) 0%, 
    rgba(216, 123, 255, 0.08) 50%,
    rgba(122, 162, 255, 0.08) 100%);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.next-section-cta:hover {
  border-color: rgba(122, 162, 255, 0.4);
  transform: translateY(-4px);
  box-shadow: 
    0 20px 40px rgba(122, 162, 255, 0.15),
    0 0 60px rgba(216, 123, 255, 0.1);
}

.cta-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, 
    rgba(122, 162, 255, 0.15) 0%, 
    transparent 50%);
  animation: ctaGlowPulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ctaGlowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.cta-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.cta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1.5rem;
  animation: badgeBounce 2s ease-in-out infinite;
}

@keyframes badgeBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.badge-icon {
  font-size: 1rem;
}

.cta-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  margin: 0 0 1rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 50%, var(--accent-2) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleGradient 5s ease infinite;
}

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

.cta-description {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 auto 2rem;
  max-width: 500px;
  line-height: 1.6;
}

.cta-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.cta-feature {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(122, 162, 255, 0.1);
  border: 1px solid rgba(122, 162, 255, 0.2);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.3s ease;
}

.cta-feature:hover {
  background: rgba(122, 162, 255, 0.2);
  border-color: rgba(122, 162, 255, 0.4);
  transform: scale(1.05);
}

.feature-icon {
  font-size: 1.1rem;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 15px rgba(122, 162, 255, 0.3),
    0 0 0 0 rgba(122, 162, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.cta-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.3), 
    transparent);
  transition: left 0.5s ease;
}

.cta-button:hover::before {
  left: 100%;
}

.cta-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 8px 25px rgba(122, 162, 255, 0.4),
    0 0 40px rgba(216, 123, 255, 0.3);
}

.cta-button:active {
  transform: translateY(-1px) scale(1);
}

.cta-button-arrow {
  display: flex;
  align-items: center;
  transition: transform 0.3s ease;
}

.cta-button:hover .cta-button-arrow {
  transform: translateX(5px);
}

/* Floating Decorations */
.cta-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-icon {
  position: absolute;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-weight: 600;
  opacity: 0.15;
  animation: floatIcon 6s ease-in-out infinite;
}

.floating-icon.icon-1 {
  top: 15%;
  left: 10%;
  font-size: 2rem;
  color: var(--accent);
  animation-delay: 0s;
}

.floating-icon.icon-2 {
  top: 60%;
  right: 15%;
  font-size: 1.5rem;
  color: var(--accent-2);
  animation-delay: 2s;
}

.floating-icon.icon-3 {
  bottom: 20%;
  left: 20%;
  font-size: 1.2rem;
  color: var(--green);
  animation-delay: 4s;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-15px) rotate(5deg); }
  50% { transform: translateY(-5px) rotate(-3deg); }
  75% { transform: translateY(-20px) rotate(3deg); }
}

/* Light Theme Adjustments */
[data-theme="light"] .next-section-cta {
  background: linear-gradient(135deg, 
    rgba(74, 124, 212, 0.08) 0%, 
    rgba(155, 89, 182, 0.08) 50%,
    rgba(74, 124, 212, 0.08) 100%);
  border-color: rgba(74, 124, 212, 0.25);
}

[data-theme="light"] .next-section-cta:hover {
  border-color: rgba(74, 124, 212, 0.4);
  box-shadow: 
    0 20px 40px rgba(74, 124, 212, 0.12),
    0 0 60px rgba(155, 89, 182, 0.08);
}

[data-theme="light"] .cta-glow {
  background: radial-gradient(circle at center, 
    rgba(74, 124, 212, 0.1) 0%, 
    transparent 50%);
}

[data-theme="light"] .cta-feature {
  background: rgba(74, 124, 212, 0.08);
  border-color: rgba(74, 124, 212, 0.2);
}

[data-theme="light"] .cta-feature:hover {
  background: rgba(74, 124, 212, 0.15);
  border-color: rgba(74, 124, 212, 0.3);
}

[data-theme="light"] .cta-button {
  background: linear-gradient(135deg, #4a7cd4, #9b59b6);
  color: #ffffff;
  box-shadow: 
    0 4px 15px rgba(74, 124, 212, 0.25),
    0 0 0 0 rgba(74, 124, 212, 0.3);
}

[data-theme="light"] .cta-button:hover {
  box-shadow: 
    0 8px 25px rgba(74, 124, 212, 0.35),
    0 0 40px rgba(155, 89, 182, 0.2);
}

[data-theme="light"] .cta-button-text,
[data-theme="light"] .cta-button-arrow {
  color: #ffffff;
}

[data-theme="light"] .cta-button-arrow svg {
  stroke: #ffffff;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .next-section-cta {
    padding: 2rem 1.5rem;
    margin: 2rem 0 0;
  }
  
  .cta-features {
    flex-direction: column;
    align-items: center;
  }
  
  .cta-feature {
    width: 100%;
    max-width: 250px;
    justify-content: center;
  }
  
  .cta-button {
    width: 100%;
    justify-content: center;
    padding: 1rem 1.5rem;
  }
  
  .floating-icon {
    display: none;
  }
}

@media (max-width: 480px) {
  .cta-badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
  
  .cta-description {
    font-size: 1rem;
  }
  
  .cta-button {
    font-size: 1rem;
  }
}

