/* ===================================
   Module Page Styles
   JavaScript & Node.js Course
   Shared layout for all module pages
   =================================== */

/* === Course Color Palette Override ===
   Green-tinted palette for JS/Node.js course identity */
:root {
    --bg-primary: #0f1220;
    --bg-secondary: #171a2b;
    --bg-tertiary: #1a1f36;
    --bg-card: rgba(23, 26, 43, 0.8);
    --bg-card-hover: rgba(32, 36, 60, 0.95);

    --text-primary: #e8ecff;
    --text-secondary: #d4dbf9;
    --text-tertiary: #9ba3c2;

    --accent-primary: #7aa2ff;
    --accent-secondary: #6ee7b7;
    --accent-gradient: linear-gradient(135deg, #7aa2ff, #6ee7b7);
    --accent-js: #f7df1e;
    --accent-node: #68a063;

    --border-color: #2a2f4a;
    --border-hover: #3a4470;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

    --code-bg: #0b0e1a;
    --code-text: #e8ecff;
    --code-keyword: #c792ea;
    --code-string: #c3e88d;
    --code-number: #f78c6c;
    --code-function: #82aaff;
    --code-comment: #546e7a;

    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
}

[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #eef1f6;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;

    --text-primary: #1a1a2e;
    --text-secondary: #334155;
    --text-tertiary: #4a5568;

    --accent-primary: #2563eb;
    --accent-secondary: #059669;
    --accent-gradient: linear-gradient(135deg, #2563eb, #059669);
    --accent-js: #c9a90c;
    --accent-node: #3d8b37;

    --border-color: #cbd5e1;
    --border-hover: #94a3b8;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);

    --code-bg: #f1f5f9;
    --code-text: #1e293b;
    --code-keyword: #7c3aed;
    --code-string: #059669;
    --code-number: #ea580c;
    --code-function: #2563eb;
    --code-comment: #64748b;
}

/* === Reading Progress Bar === */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--accent-gradient);
    z-index: 10000;
    transition: width 0.1s linear;
}

/* === Module Header Bar === */
.module-header-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 2rem 0 1.5rem;
    margin-top: 70px;
}

[data-theme="light"] .module-header-bar {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.module-header-content {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

.module-badge-number {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #fff;
    background: var(--accent-gradient);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    margin-bottom: 0.5rem;
}

.module-header-bar h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.3rem;
}

.module-header-subtitle {
    font-size: 1.1rem;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.03em;
    margin: 0;
}

/* === Module Layout (Sidebar + Main) === */
.module-layout {
    display: flex;
    min-height: calc(100vh - 200px);
}

/* === Sidebar === */
.module-sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    width: 280px;
    height: calc(100vh - 70px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 100;
    padding: 1.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.module-sidebar::-webkit-scrollbar {
    width: 4px;
}
.module-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.module-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}
.sidebar-close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-header {
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.sidebar-course-badge {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-secondary);
    background: rgba(110, 231, 183, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    margin-bottom: 0.35rem;
}
[data-theme="light"] .sidebar-course-badge {
    background: rgba(5, 150, 105, 0.1);
}

.sidebar-course-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.25rem 0 0;
    line-height: 1.3;
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    line-height: 1.3;
}

.sidebar-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(122, 162, 255, 0.1);
    color: var(--accent-primary);
    font-weight: 500;
}

.sidebar-link .link-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.sidebar-link.active .link-number {
    background: var(--accent-primary);
    color: #fff;
}

.back-to-course {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

.back-to-course:hover {
    color: var(--accent-primary);
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
}

.sidebar-section-icon {
    font-size: 0.8rem;
}

/* Module links in sidebar */
.module-link {
    font-size: 0.8rem;
}

.module-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.module-dot--active {
    background: var(--accent-primary);
    box-shadow: 0 0 6px rgba(122, 162, 255, 0.4);
}

.module-dot--available {
    background: var(--accent-secondary);
}

.module-dot--locked {
    background: var(--border-color);
}

.sidebar-link.module-link.active-module {
    background: rgba(122, 162, 255, 0.08);
    color: var(--accent-primary);
    font-weight: 500;
}

.sidebar-link.module-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* === Main Content Area === */
.module-main {
    padding: 2rem 2rem 4rem;
    max-width: 900px;
    width: 100%;
    box-sizing: border-box;
    /* Center content in the space right of the 280px sidebar.
       Below 1180px viewport the content simply sits next to the sidebar. */
    margin-left: max(280px, calc(50vw - 310px));
    margin-right: auto;
}

/* === Lesson Cards === */
.lesson-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    margin-bottom: 2rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.lesson-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.lesson-card > h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem;
    line-height: 1.3;
}

.lesson-card > h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem;
}

.lesson-card > p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 1rem;
}

.lesson-card > p:last-child {
    margin-bottom: 0;
}

.lesson-card strong {
    color: var(--text-primary);
    font-weight: 600;
}

.lesson-card em {
    color: var(--accent-primary);
    font-style: italic;
}

.lesson-card code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    color: var(--accent-primary);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Reset inline code styling inside code blocks */
.code-block code,
.code-block pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: inherit;
}

/* === Syntax Highlighting (code blocks) === */
.code-block .hl-keyword  { color: #c792ea; font-weight: 600; }
.code-block .hl-string   { color: #c3e88d; }
.code-block .hl-number   { color: #f78c6c; }
.code-block .hl-comment  { color: #546e7a; font-style: italic; }
.code-block .hl-function { color: #82aaff; }
.code-block .hl-builtin  { color: #89ddff; }
.code-block .hl-operator { color: #89ddff; }
.code-block .hl-punct    { color: #89ddff; opacity: 0.7; }

/* Light theme syntax highlighting */
[data-theme="light"] .code-block .hl-keyword  { color: #7c3aed; }
[data-theme="light"] .code-block .hl-string   { color: #059669; }
[data-theme="light"] .code-block .hl-number   { color: #ea580c; }
[data-theme="light"] .code-block .hl-comment  { color: #64748b; }
[data-theme="light"] .code-block .hl-function { color: #2563eb; }
[data-theme="light"] .code-block .hl-builtin  { color: #0891b2; }
[data-theme="light"] .code-block .hl-operator { color: #0891b2; }
[data-theme="light"] .code-block .hl-punct    { color: #64748b; opacity: 0.8; }

/* === Diagram Box === */
.diagram-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.diagram-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 1rem;
    text-align: center;
}

/* === Code Blocks === */
.code-block {
    background: #0b0e1a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin: 1rem 0;
    overflow-x: auto;
    position: relative;
}

[data-theme="light"] .code-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.code-block pre {
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e8ecff;
    white-space: pre;
    tab-size: 2;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}

[data-theme="light"] .code-block pre {
    color: #1e293b;
}

.code-block .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.code-block .code-lang {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-secondary);
    background: rgba(110, 231, 183, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.code-block .copy-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-tertiary);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: inherit;
    transition: all 0.2s;
}

.code-block .copy-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.code-block .copy-btn.copied {
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

/* Code block action buttons bar */
.code-block .code-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .code-block .code-actions {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.code-block .code-actions button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-tertiary);
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.code-block .code-actions button svg {
    flex-shrink: 0;
}

.code-block .code-actions .copy-btn:hover {
    background: rgba(122, 162, 255, 0.1);
    color: #7aa2ff;
    border-color: rgba(122, 162, 255, 0.35);
}

.code-block .code-actions .copy-btn.copied {
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
    background: rgba(110, 231, 183, 0.1);
}

.code-block .code-actions .try-btn {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.code-block .code-actions .try-btn:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.5);
    color: #4ade80;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

[data-theme="light"] .code-block .code-actions .copy-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.3);
}

[data-theme="light"] .code-block .code-actions .try-btn {
    color: #16a34a;
    border-color: rgba(22, 163, 74, 0.3);
}

[data-theme="light"] .code-block .code-actions .try-btn:hover {
    background: rgba(22, 163, 74, 0.08);
    border-color: rgba(22, 163, 74, 0.45);
    color: #15803d;
}

/* Syntax Highlighting */
.code-block .keyword { color: var(--code-keyword); }
.code-block .string { color: var(--code-string); }
.code-block .number { color: var(--code-number); }
.code-block .function { color: var(--code-function); }
.code-block .comment { color: var(--code-comment); font-style: italic; }
.code-block .operator { color: #89ddff; }
.code-block .punctuation { color: var(--text-tertiary); }

/* === Terminal/Output Block === */
.terminal-block {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #c9d1d9;
    overflow-x: auto;
}

[data-theme="light"] .terminal-block {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="light"] .terminal-block .prompt { color: #93bbfc; }
[data-theme="light"] .terminal-block .output { color: #b0bec5; }
[data-theme="light"] .terminal-block .success { color: #6ee7b7; }
[data-theme="light"] .terminal-block .error { color: #fca5a5; }

.terminal-block .prompt {
    color: #58a6ff;
    user-select: none;
}

.terminal-block .output {
    color: #8b949e;
}

.terminal-block .success {
    color: #3fb950;
}

.terminal-block .error {
    color: #f85149;
}

/* === Info Cards === */
.info-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin: 1rem 0;
}

.info-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.info-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.info-card--blue {
    border-left: 3px solid var(--accent-primary);
    background: rgba(122, 162, 255, 0.05);
}

.info-card--green {
    border-left: 3px solid var(--accent-secondary);
    background: rgba(110, 231, 183, 0.05);
}

.info-card--yellow {
    border-left: 3px solid var(--accent-js);
    background: rgba(247, 223, 30, 0.05);
}

.info-card--orange {
    border-left: 3px solid #f97316;
    background: rgba(249, 115, 22, 0.05);
}

.info-card--red {
    border-left: 3px solid #f87171;
    background: rgba(248, 113, 113, 0.05);
}

.info-card--purple {
    border-left: 3px solid #a78bfa;
    background: rgba(167, 139, 250, 0.05);
}

/* === Callout Boxes === */
.callout-box {
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    border-left: 4px solid;
}

.callout-box h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.4rem;
}

.callout-box p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-size: 0.92rem;
}

.callout-box--tip {
    border-color: var(--accent-secondary);
    background: rgba(110, 231, 183, 0.06);
}
.callout-box--tip h4 { color: var(--accent-secondary); }

.callout-box--warning {
    border-color: var(--accent-js);
    background: rgba(247, 223, 30, 0.06);
}
.callout-box--warning h4 { color: var(--accent-js); }

.callout-box--info {
    border-color: var(--accent-primary);
    background: rgba(122, 162, 255, 0.06);
}
.callout-box--info h4 { color: var(--accent-primary); }

.callout-box--danger {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.06);
}
.callout-box--danger h4 { color: #f87171; }

[data-theme="light"] .callout-box--danger {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.05);
}
[data-theme="light"] .callout-box--danger h4 { color: #dc2626; }

/* === Two Column Layout === */
.two-column-cards,
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.25rem 0;
}

/* === Learning Objectives === */
.learning-objectives {
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.08), rgba(110, 231, 183, 0.08));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.learning-objectives h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.learning-objectives ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.learning-objectives li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.learning-objectives li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-secondary);
    font-weight: 700;
}

/* === Info Table === */
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.info-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
}

.info-table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: top;
}

.info-table tr:hover td {
    background: var(--bg-card-hover);
}

/* === Badge (status code table) === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1;
}

/* === Summary Grid === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.summary-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.summary-emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.summary-item h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.summary-item strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.summary-item p {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
}

/* === Next Module Box === */
.next-module-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-top: 2.5rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
}

.next-module-box::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

.next-module-box:hover::before {
    opacity: 1;
}

.next-module-box:hover {
    border-color: transparent;
    box-shadow: 0 8px 32px rgba(122, 162, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

/* Number badge on the left */
.next-module-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 80px;
    align-self: stretch;
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.12), rgba(110, 231, 183, 0.12));
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-primary);
    letter-spacing: -0.02em;
    border-right: 1px solid var(--border-color);
    transition: all 0.4s;
}

.next-module-box:hover .next-module-badge {
    background: linear-gradient(135deg, rgba(122, 162, 255, 0.2), rgba(110, 231, 183, 0.2));
}

/* Content area */
.next-module-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.25rem 0;
}

.next-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-primary);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Progress bar inside label */
.next-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
}

.next-progress-track {
    width: 60px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.next-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.6s ease;
}

.next-progress-text {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.next-module-box h3,
.next-module-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.next-module-box h3 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s;
}

.next-module-box:hover h3 a {
    color: var(--accent-primary);
}

.next-module-box h3 a:hover {
    color: var(--accent-primary);
}

.next-module-box > p,
.next-module-content p {
    color: var(--text-tertiary);
    font-size: 0.88rem;
    margin: 0;
    line-height: 1.55;
}

/* Topic pills */
.next-module-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.next-topic-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(122, 162, 255, 0.1);
    color: var(--accent-primary);
    border-radius: 99px;
    border: 1px solid rgba(122, 162, 255, 0.15);
    letter-spacing: 0.01em;
    transition: all 0.3s;
}

.next-module-box:hover .next-topic-pill {
    background: rgba(122, 162, 255, 0.18);
    border-color: rgba(122, 162, 255, 0.3);
}

/* Arrow on the right */
.next-module-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 56px;
    align-self: stretch;
    font-size: 1.5rem;
    color: var(--accent-primary);
    opacity: 0.5;
    transition: all 0.4s;
    border-left: 1px solid var(--border-color);
}

.next-module-box:hover .next-module-arrow {
    opacity: 1;
    transform: translateX(3px);
}

/* === Congrats box (Module 6 end) === */
.next-module-box.congrats-box {
    background: linear-gradient(135deg, rgba(110, 231, 183, 0.12), rgba(122, 162, 255, 0.12));
    border-color: rgba(110, 231, 183, 0.25);
    cursor: default;
}

.next-module-box.congrats-box::before { display: none; }

.next-module-box.congrats-box:hover {
    transform: none;
    box-shadow: 0 4px 24px rgba(110, 231, 183, 0.12);
    border-color: rgba(110, 231, 183, 0.4);
}

.congrats-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 80px;
    align-self: stretch;
    background: linear-gradient(135deg, rgba(110, 231, 183, 0.15), rgba(122, 162, 255, 0.15));
    font-size: 2.2rem;
    border-right: 1px solid rgba(110, 231, 183, 0.2);
}

.congrats-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem 1.5rem 1.5rem 0;
}

.congrats-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.congrats-content p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: 0;
    line-height: 1.55;
}

.congrats-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.3s, gap 0.3s;
}

.congrats-link:hover {
    color: var(--accent-primary);
    gap: 0.5rem;
}

/* === Comparison Table === */
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

.comparison-grid > .info-card {
    display: grid;
    grid-template-rows: auto auto 1fr;
    margin: 0;
}

.comparison-grid > .info-card > .code-block {
    margin: 0.5rem 0 0;
    align-self: stretch;
}

.comparison-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.comparison-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.comparison-card ul {
    margin: 0;
    padding-left: 1.25rem;
}

.comparison-card li {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    margin-bottom: 0.3rem;
}

/* === Steps / Process Flow === */
.steps-flow {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.step-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.step-item:hover {
    border-color: var(--border-hover);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-content h4,
.step-content strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}

.step-content p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0;
}

/* === Interactive Demo Container === */
.demo-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.demo-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.demo-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.demo-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.demo-btn.active {
    background: rgba(122, 162, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.demo-btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}
.demo-btn--primary:hover {
    opacity: 0.9;
    color: #fff;
}

/* === Lists inside lesson cards === */
.lesson-card ul,
.lesson-card ol {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}

.lesson-card li {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.35rem;
}

.lesson-card li strong {
    color: var(--text-primary);
}

.lesson-card li code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    color: var(--accent-primary);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

/* === SVG Diagrams === */
.diagram-svg {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: block;
}

.diagram-svg text {
    font-family: 'Inter', sans-serif;
    fill: var(--text-primary);
}

.diagram-svg .node-rect {
    fill: var(--bg-card);
    stroke: var(--border-color);
    stroke-width: 1.5;
    rx: 8;
}

.diagram-svg .node-rect:hover {
    stroke: var(--accent-primary);
    filter: drop-shadow(0 0 6px rgba(122, 162, 255, 0.3));
}

.diagram-svg .connector {
    stroke: var(--border-hover);
    stroke-width: 1.5;
    fill: none;
}

.diagram-svg .connector-arrow {
    fill: var(--border-hover);
}

/* ===================================
   ARCHITECTURE DIAGRAMS (arch-*)
   JS Overview & Node.js Overview
   =================================== */
.arch-diagram {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

[data-theme="light"] .arch-diagram {
    background: #edf2f7;
    border-color: rgba(0, 0, 0, 0.1);
}

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

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

/* Horizontal flow (JS Overview) */
.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 { border-color: #d97706; }
[data-theme="light"] .arch-box-blue   { border-color: #2563eb; }
[data-theme="light"] .arch-box-green  { border-color: #15803d; }
[data-theme="light"] .arch-box-purple { border-color: #7c3aed; }
[data-theme="light"] .arch-box-red    { border-color: #dc2626; }

[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: #d4dbf9;
    font-size: 10px;
}

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

.arch-arrow {
    color: #d4dbf9;
    font-size: 20px;
    text-align: center;
}

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

/* Concept cards (JS Overview bottom row) */
.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   { border-left-color: #2563eb; }
[data-theme="light"] .arch-concept-green  { border-left-color: #15803d; }
[data-theme="light"] .arch-concept-purple { border-left-color: #7c3aed; }
[data-theme="light"] .arch-concept-orange { border-left-color: #d97706; }

[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;
}

/* Vertical layout (Node.js Architecture) */
.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;
}

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

.arch-use-cases-label {
    color: #d4dbf9;
    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; }

/* Mobile responsive for arch diagrams */
@media (max-width: 640px) {
    .arch-flow {
        flex-direction: column;
        gap: 8px;
    }
    .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-vertical {
        max-width: 100%;
        gap: 4px;
        align-items: center;
    }
    .arch-vertical .arch-box {
        padding: 12px;
        width: 100%;
        max-width: 280px;
    }
    .arch-vertical > .arch-arrow {
        font-size: 20px;
        margin: 6px 0;
        color: #9ca3af;
        transform: none;
        text-align: center;
        width: 100%;
        display: block;
    }
}

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

.message-part {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    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-primary);
    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: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
    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(--text-tertiary);
    line-height: 1.4;
}

/* Light theme */
[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);
}

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

/* === Light Theme Component Overrides === */
[data-theme="light"] .diagram-box {
    background: #edf2f7;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .step-item {
    background: var(--bg-card);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .info-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .info-card--blue { background: rgba(59, 130, 246, 0.04); border-left-color: #2563eb; }
[data-theme="light"] .info-card--green { background: rgba(16, 185, 129, 0.04); border-left-color: #059669; }
[data-theme="light"] .info-card--yellow { background: rgba(234, 179, 8, 0.05); border-left-color: #ca8a04; }
[data-theme="light"] .info-card--orange { background: rgba(249, 115, 22, 0.04); border-left-color: #ea580c; }
[data-theme="light"] .info-card--red { background: rgba(239, 68, 68, 0.04); border-left-color: #dc2626; }
[data-theme="light"] .info-card--purple { background: rgba(124, 58, 237, 0.04); border-left-color: #7c3aed; }

[data-theme="light"] .summary-item {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .next-module-box {
    background: #ffffff;
    border-color: rgba(99, 102, 241, 0.12);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .next-module-box:hover {
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .next-module-badge {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(16, 185, 129, 0.08));
    border-right-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .next-module-box:hover .next-module-badge {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(16, 185, 129, 0.14));
}

[data-theme="light"] .next-topic-pill {
    background: rgba(99, 102, 241, 0.07);
    border-color: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

[data-theme="light"] .next-module-arrow {
    border-left-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .next-module-box.congrats-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(99, 102, 241, 0.06));
    border-color: rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .congrats-badge {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(99, 102, 241, 0.1));
    border-right-color: rgba(16, 185, 129, 0.12);
}

[data-theme="light"] .comparison-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .callout-box {
    background: #ffffff;
}

/* ===================================
   HTTP SIMULATION
   =================================== */

/* SVG theme variables */
:root {
    --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: #dde3f7;
    --svg-legend-bg: rgba(23, 26, 43, 0.9);
    --http-req-color: #4da3ff;
    --http-res-color: #5be37d;
}

[data-theme="light"] {
    --svg-node-bg: #ffffff;
    --svg-node-stroke: #94a3b8;
    --svg-node-hover: #f1f5f9;
    --svg-node-stroke-hover: #2563eb;
    --svg-text: #1e293b;
    --svg-text-muted: #64748b;
    --svg-legend-bg: rgba(248, 250, 252, 0.98);
}

/* Figure container */
.http-figure {
    display: block;
    margin: 1rem 0 0;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card, #0e1326);
    position: relative;
}

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

#http-topology-caption {
    position: static;
    display: block;
    opacity: 1;
    margin-top: 0.75rem;
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-tertiary);
    width: 100%;
    left: 0;
    text-align: justify;
}

[data-theme="light"] #http-topology-caption {
    color: #4b5563;
}

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

.http-svg .popover { pointer-events: all; }
.http-svg .sim-overlay { overflow: visible; }

.http-stage {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
}

.http-canvas { min-width: 0; }

/* Simulation controls */
.sim-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0.5rem 0 0.5rem;
    flex-wrap: wrap;
}

.sim-controls label {
    color: var(--text-tertiary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sim-controls select {
    appearance: none;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}

.sim-controls button {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.sim-controls button:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.sim-controls .spacer { flex: 1 1 auto; }

[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;
    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 */
.sim-caption {
    position: absolute;
    left: auto;
    top: 10px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
    max-width: 360px;
}

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

.http-figure .http-svg {
    margin-top: 42px;
}

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

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

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

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

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

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

/* Envelope (request/response packet) */
.http-svg .envelope { cursor: pointer; }
.http-svg .envelope .click-area { pointer-events: all; cursor: pointer; }
.http-svg .envelope .inner { pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.15s ease, filter 0.15s ease; }
.http-svg .envelope .body { pointer-events: none; }
.http-svg .envelope .flap { pointer-events: none; }

.http-svg .envelope .inner.appear {
    animation: env-pop 460ms cubic-bezier(0.2, 0.8, 0.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.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 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));
}

[data-theme="light"] .http-svg .envelope rect.body {
    fill: rgba(255, 255, 255, 0.98);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.http-svg .envelope path.flap { fill: currentColor; opacity: 0.85; }
.http-svg .envelope .env-icon { opacity: 0.9; }
.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(0.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, 0.4)); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35)); }
}

/* Construction spinner */
.http-svg .spinner { pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; animation: sim-spin 0.8s linear infinite; }
.http-svg .spinner .ring-bg { fill: none; stroke: rgba(230, 234, 255, 0.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 sim-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Flow visibility */
.http-svg .flow { transition: stroke-width 0.15s ease, opacity 0.15s ease; }
.http-svg .flow:hover { opacity: 0.95; }
.http-figure.flows-on-use .flow-label { display: none; }
.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; }
.http-figure.flows-on-use .legend .flow { opacity: 1 !important; pointer-events: auto; }

/* Node pulse animation */
@keyframes glowPulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(122, 162, 255, 0)); }
    50% { filter: drop-shadow(0 0 14px rgba(122, 162, 255, 0.7)); }
}

.http-svg .pulse rect {
    stroke: #3b82f6;
    stroke-width: 2.5;
    animation: glowPulse 0.8s ease-in-out infinite alternate;
}

/* HTML Popover */
.http-popover {
    position: fixed;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    background: rgba(15, 18, 32, 0.98);
    border: 2px solid #4a5578;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    cursor: move;
    z-index: 999999;
    pointer-events: all;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: #c7d0e8;
    font-size: 12px;
    line-height: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

[data-theme="light"] .http-popover {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    color: #1e293b;
}

.http-popover .popover-accent {
    position: absolute; top: 0; left: 0; right: 0;
    height: 4px; border-radius: 12px 12px 0 0;
}

.http-popover .popover-accent.req { background: #4da3ff; }
.http-popover .popover-accent.res { background: #5be37d; }

.http-popover .popover-close {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1); border: none;
    color: white; font-size: 20px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}

[data-theme="light"] .http-popover .popover-close {
    background: rgba(0, 0, 0, 0.05); color: #1e293b;
}

.http-popover .popover-close:hover {
    background: rgba(255, 59, 48, 0.8);
    color: white;
}

.http-popover .popover-content {
    margin-top: 12px; pointer-events: none;
    max-width: 100%; overflow-x: auto;
}

.http-popover .popover-title {
    color: white; font-size: 14px; font-weight: 700;
    margin-bottom: 8px; padding-right: 30px;
}

[data-theme="light"] .http-popover .popover-title { color: #0f172a; }

.http-popover .popover-line {
    white-space: pre-wrap; word-break: break-word; margin-bottom: 2px;
}

.http-popover .popover-line.empty { height: 12px; }

/* Responsive simulation adjustments */
@media (max-width: 640px) {
    .http-figure { padding: 0.75rem; }
    .http-figure .http-svg { margin-top: 56px; }
    .http-svg .label { font-size: 14px; }
    .http-svg .small { font-size: 11px; }
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

/* Tablet: Sidebar becomes drawer */
@media (max-width: 900px) {
    .module-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 500;
        padding-top: 2rem;
    }

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

    .sidebar-close-btn {
        display: block;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 499;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 1.5rem;
        left: 1.5rem;
        width: 48px;
        height: 48px;
        background: var(--accent-primary);
        color: #fff;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        z-index: 200;
        box-shadow: var(--shadow-md);
        transition: transform 0.2s;
    }

    .sidebar-mobile-toggle:hover {
        transform: scale(1.1);
    }

    .module-main {
        margin-left: 0;
        padding: 1.5rem 1rem 3rem;
    }

    .lesson-card {
        padding: 1.5rem 1.25rem;
    }
}

/* Desktop: hide mobile controls */
@media (min-width: 901px) {
    .sidebar-mobile-toggle {
        display: none;
    }

    .sidebar-backdrop {
        display: none;
    }
}

/* Small tablets / Large phones */
@media (max-width: 768px) {
    .module-header-bar {
        padding: 1.5rem 0 1rem;
    }

    .module-header-bar h1 {
        font-size: 1.6rem;
    }

    .two-column-cards,
    .two-col {
        grid-template-columns: 1fr;
    }

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

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

    .next-module-box {
        flex-direction: column;
        text-align: center;
    }

    .next-module-badge,
    .congrats-badge {
        width: 100%;
        height: 52px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .next-module-content,
    .congrats-content {
        padding: 1rem 1.25rem 1.25rem;
    }

    .next-module-topics {
        justify-content: center;
    }

    .next-module-arrow {
        width: 100%;
        height: 44px;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .next-module-box:hover .next-module-arrow {
        transform: translateX(0) translateY(2px);
    }

    .next-progress {
        margin-left: 0;
    }

    .next-label {
        justify-content: center;
    }
}

/* Phones */
@media (max-width: 480px) {
    .lesson-card {
        padding: 1.25rem 1rem;
        border-radius: 10px;
    }

    .lesson-card > h2 {
        font-size: 1.3rem;
    }

    .code-block {
        padding: 0.75rem;
        font-size: 0.78rem;
    }

    .diagram-box {
        padding: 1rem;
    }
}

/* Print styles */
@media print {
    .module-sidebar,
    .sidebar-mobile-toggle,
    .sidebar-backdrop,
    .reading-progress,
    .fixed-controls,
    .navbar,
    .next-module-box {
        display: none;
    }

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

    .lesson-card {
        break-inside: avoid;
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ===== HTTP COMMUNICATION EXAMPLES ===== */
.http-examples-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 24px 0;
}
.http-examples-grid > .http-example-card--response {
    grid-column: 1 / -1;
}

.http-example-card {
    border-radius: 14px;
    padding: 24px;
    border: 2px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}
.http-example-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}
.http-example-card:hover {
    transform: translateY(-2px);
}

/* GET card */
.http-example-card--get {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.04));
    border-color: rgba(34, 197, 94, 0.3);
}
.http-example-card--get::before { background: linear-gradient(90deg, #22c55e, #4ade80); }
.http-example-card--get:hover { box-shadow: 0 8px 24px rgba(34, 197, 94, 0.2); }

/* POST card */
.http-example-card--post {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.04));
    border-color: rgba(59, 130, 246, 0.3);
}
.http-example-card--post::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.http-example-card--post:hover { box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2); }

/* Response card */
.http-example-card--response {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(168, 85, 247, 0.04));
    border-color: rgba(168, 85, 247, 0.3);
}
.http-example-card--response::before { background: linear-gradient(90deg, #a855f7, #c084fc); }
.http-example-card--response:hover { box-shadow: 0 8px 24px rgba(168, 85, 247, 0.2); }

/* Card header row */
.http-example-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* Method badge */
.http-method-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}
.http-method-badge--get {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}
.http-method-badge--post {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}
.http-method-badge--response {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
}

/* Direction indicator */
.http-example-direction {
    font-size: 12px;
    color: rgba(200, 210, 230, 0.6);
    font-weight: 500;
}

/* Card titles & text */
.http-example-card h3 {
    font-size: 1.15rem;
    margin: 0 0 6px 0;
    color: var(--text);
}
.http-example-card p {
    font-size: 0.9rem;
    margin: 0 0 16px 0;
    color: var(--text-secondary, rgba(200, 210, 230, 0.7));
    line-height: 1.5;
}

/* Code area */
.http-example-code {
    background: #0b0e1a;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}
.http-example-code pre {
    margin: 0;
    padding: 18px 20px;
    background: transparent;
}
.http-example-code code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.75;
    color: #c7d0e8;
    background: none;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* Syntax-highlight spans */
.ex-start {
    display: block;
    color: #7dd3fc;
    font-weight: 700;
}
.ex-header {
    display: block;
    color: #a5b4c8;
}
.ex-sep {
    display: block;
    height: 8px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    margin-bottom: 4px;
}
.ex-body {
    display: block;
    color: #fbbf24;
    font-weight: 500;
}

/* Legend */
.http-examples-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 12px 0;
    font-size: 12px;
    color: rgba(200, 210, 230, 0.5);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.legend-dot--start { background: #7dd3fc; }
.legend-dot--header { background: #a5b4c8; }
.legend-dot--sep { background: rgba(255, 255, 255, 0.15); border: 1px dashed rgba(255, 255, 255, 0.3); }
.legend-dot--body { background: #fbbf24; }

/* ===== LIGHT THEME HTTP EXAMPLES ===== */
[data-theme="light"] .http-example-card--get {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.06), rgba(22, 163, 74, 0.02));
    border-color: rgba(22, 163, 74, 0.25);
}
[data-theme="light"] .http-example-card--get:hover {
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.1);
}
[data-theme="light"] .http-example-card--post {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.02));
    border-color: rgba(37, 99, 235, 0.25);
}
[data-theme="light"] .http-example-card--post:hover {
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.1);
}
[data-theme="light"] .http-example-card--response {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.06), rgba(147, 51, 234, 0.02));
    border-color: rgba(147, 51, 234, 0.25);
}
[data-theme="light"] .http-example-card--response:hover {
    box-shadow: 0 8px 24px rgba(147, 51, 234, 0.1);
}
[data-theme="light"] .http-method-badge--get {
    background: rgba(22, 163, 74, 0.1);
    color: #15803d;
    border-color: rgba(22, 163, 74, 0.25);
}
[data-theme="light"] .http-method-badge--post {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.25);
}
[data-theme="light"] .http-method-badge--response {
    background: rgba(147, 51, 234, 0.1);
    color: #7e22ce;
    border-color: rgba(147, 51, 234, 0.25);
}
[data-theme="light"] .http-example-direction {
    color: #94a3b8;
}
[data-theme="light"] .http-example-card h3 {
    color: #1e293b;
}
[data-theme="light"] .http-example-card p {
    color: #64748b;
}
[data-theme="light"] .http-example-code {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .http-example-code code {
    color: #334155;
}
[data-theme="light"] .ex-start {
    color: #0369a1;
}
[data-theme="light"] .ex-header {
    color: #64748b;
}
[data-theme="light"] .ex-sep {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .ex-body {
    color: #b45309;
}
[data-theme="light"] .http-examples-legend {
    color: #94a3b8;
}
[data-theme="light"] .legend-dot--start { background: #0369a1; }
[data-theme="light"] .legend-dot--header { background: #94a3b8; }
[data-theme="light"] .legend-dot--sep {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}
[data-theme="light"] .legend-dot--body { background: #b45309; }

/* ===== HTTP EXAMPLES RESPONSIVE ===== */
@media (max-width: 768px) {
    .http-examples-grid {
        grid-template-columns: 1fr;
    }
    .http-examples-grid > .http-example-card--response {
        grid-column: auto;
    }
    .http-example-card {
        padding: 18px;
    }
    .http-examples-legend {
        flex-wrap: wrap;
        gap: 12px;
    }
}
