:root {
    --bg-primary: #000000;
    --bg-secondary: #080808;
    --bg-tertiary: #111111;
    --text-primary: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(200, 200, 210, 0.7);
    --text-muted: rgba(180, 180, 190, 0.4);
    --silver: #c0c0c8;
    --silver-dim: rgba(192, 192, 200, 0.5);
    --accent: linear-gradient(135deg, #a8b4c4 0%, #d4dae4 50%, #8a9aaa 100%);
    --accent-solid: #b8c4d4;
    --accent-glow: rgba(184, 196, 212, 0.06);
    --success: #6ee7a0;
    --success-bg: rgba(110, 231, 160, 0.04);
    --warning: #fcd34d;
    --warning-bg: rgba(252, 211, 77, 0.04);
    --border: rgba(255, 255, 255, 0.03);
    --border-subtle: rgba(255, 255, 255, 0.015);
    --code-bg: #050505;
    --transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 24px 120px;
}

/* Header */
.header {
    margin-bottom: 60px;
    opacity: 0;
    animation: fadeUp 0.6s ease forwards;
}

.header h1 {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}

.header p {
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 400;
}

/* Materials */
.materials {
    background: var(--bg-secondary);
    border: none;
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 56px;
    opacity: 0;
    animation: fadeUp 0.8s ease 0.15s forwards;
    box-shadow: 0 0 0 1px var(--border);
}

.materials h2 {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.materials ul {
    list-style: none;
}

.materials li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 14px;
}

.materials li:last-child {
    border: none;
}

.materials li strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Steps */
.step {
    background: var(--bg-secondary);
    border: none;
    border-radius: 16px;
    padding: 36px;
    margin-bottom: 32px;
    opacity: 0;
    transform: translateY(30px);
    transition: var(--transition);
    box-shadow: 0 0 0 1px var(--border);
}

.step:hover {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 20px 60px -20px rgba(0, 0, 0, 0.5);
}

.step.visible {
    opacity: 1;
    transform: translateY(0);
}

.hidden-step {
    display: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.step-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(145deg, #b8c4d4 0%, #8a9aaa 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    color: #000;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.step-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.step-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.step-content p strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Diagram */
.diagram {
    background: linear-gradient(180deg, rgba(20, 20, 25, 0.8) 0%, rgba(8, 8, 10, 0.9) 100%);
    border: none;
    border-radius: 12px;
    padding: 24px 28px;
    margin: 24px 0;
    font-family: 'SF Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: 0.02em;
    color: var(--silver-dim);
    overflow-x: auto;
    white-space: pre;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.diagram .highlight {
    color: var(--accent);
    font-weight: 500;
}

/* Boxes */
.verify-box,
.warning-box,
.tip-box {
    border-radius: 12px;
    padding: 18px 22px;
    margin: 24px 0;
    font-size: 13px;
    border: none;
}

.verify-box {
    background: var(--success-bg);
    box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.15);
}

.verify-box .label {
    color: var(--success);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.warning-box {
    background: var(--warning-bg);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.15);
}

.warning-box .label {
    color: var(--warning);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.tip-box {
    background: var(--accent-glow);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.15);
}

.tip-box .label {
    color: var(--accent);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.verify-box ul,
.warning-box ul,
.tip-box ul {
    list-style: none;
    color: var(--text-secondary);
    font-size: 13px;
}

.verify-box li,
.warning-box li,
.tip-box li {
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

.verify-box li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
}

.warning-box li::before {
    content: '!';
    position: absolute;
    left: 0;
    color: var(--warning);
    font-weight: 600;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 24px 0;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

th {
    background: linear-gradient(180deg, #151515 0%, #111 100%);
    color: var(--silver);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.01);
    transition: background 0.2s;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

tr:last-child td {
    border: none;
}

/* Code */
code,
.coord {
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-radius: 6px;
    padding: 3px 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--silver);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Lists */
.step-content ol,
.step-content ul {
    margin: 16px 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.step-content li {
    margin: 8px 0;
}

/* Section headers */
h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 28px 0 16px;
    letter-spacing: -0.01em;
}

h4 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 20px 0 12px;
}

/* Controls */
.step-controls {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.confirmation-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: var(--transition);
}

.confirmation-label:hover {
    color: var(--text-secondary);
}

.confirmation-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.next-button {
    background: linear-gradient(145deg, #c8d4e4 0%, #9aa8b8 100%);
    color: #000;
    border: none;
    padding: 12px 28px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    display: none;
    transition: var(--transition);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.next-button:hover {
    background: linear-gradient(145deg, #d8e4f4 0%, #aab8c8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.next-button:active {
    transform: translateY(0);
}

.next-button.completed {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: default;
}

/* Code block */
.code-block {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    overflow-x: auto;
    white-space: pre;
}

.code-block .comment {
    color: rgba(255, 255, 255, 0.35);
}

.code-block .keyword {
    color: #c084fc;
}

.code-block .function {
    color: #60a5fa;
}

.code-block .number {
    color: #f472b6;
}

.code-block .string {
    color: #4ade80;
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step:first-of-type {
    animation: fadeUp 0.6s ease 0.2s forwards;
}

/* Sidebar TOC */
.page-wrapper {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    align-items: flex-start;
}

.toc-sidebar {
    width: 240px;
    position: sticky;
    top: 40px;
    margin-right: 40px;
    padding-top: 60px;
    display: none;
    /* Hidden on small screens */
}

@media (min-width: 1100px) {
    .toc-sidebar {
        display: block;
    }
}

.toc-list {
    list-style: none;
    border-left: 1px solid var(--border);
}

.toc-item {
    padding-left: 20px;
    position: relative;
}

.toc-link {
    display: block;
    padding: 8px 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.toc-link:hover {
    color: var(--text-primary);
}

.toc-link.active {
    color: var(--text-primary);
    font-weight: 500;
}

.toc-link.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--text-primary);
}

/* Adjust Main Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    /* Centered relative to available space */
    padding: 60px 24px 120px;
    flex: 1;
}

/* Toggle Switch */
.toggle-container {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.toggle-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.switch-wrapper {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px;
    position: relative;
}

.switch-btn {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s;
}

.switch-btn.active {
    color: #fff;
}

.switch-bg {
    position: absolute;
    top: 4px;
    left: 4px;
    bottom: 4px;
    width: calc(50% - 4px);
    background: var(--bg-secondary);
    border-radius: 6px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}

/* View All Mode Overrides */
body.view-all-mode .step {
    opacity: 1 !important;
    transform: translateY(0) !important;
    display: block !important;
}

body.view-all-mode .next-button {
    display: none !important;
}

/* ============================================ */
/* ML GUIDE VISUAL COMPONENTS                   */
/* ============================================ */

/* Link Styling */
a {
    color: #fff;
    text-decoration: underline;
    text-decoration-color: var(--silver-dim);
    transition: all 0.2s;
}
a:hover {
    color: #fff;
    text-decoration-color: var(--accent-solid);
    text-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.toc-link {
    text-decoration: none;
    color: var(--text-muted);
}
.toc-link:hover {
    color: #fff;
}

/* Visual Blocks (General Container) */
.visual-block {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    font-family: 'Inter', sans-serif;
}

/* Chart Bars (Signal Levels) */
.chart-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
}
.chart-label {
    width: 140px;
    color: var(--text-secondary);
    font-weight: 500;
}
.chart-bar-container {
    flex: 1;
    background: rgba(255,255,255,0.05);
    height: 8px;
    border-radius: 4px;
    margin-right: 12px;
    overflow: hidden;
}
.chart-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-solid), #fff);
    border-radius: 4px;
}
.chart-value {
    width: 50px;
    text-align: right;
    font-family: 'SF Mono', monospace;
    color: var(--silver);
    font-size: 11px;
}

/* Flow Diagram (Curriculum Steps) */
.flow-step-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.flow-step {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: 50px;
    width: 100%;
    max-width: 400px;
    transition: transform 0.2s;
}
.flow-step:hover {
    border-color: rgba(255,255,255,0.2);
    transform: scale(1.02);
}
.flow-num {
    background: var(--accent-solid);
    color: #000;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-right: 16px;
}
.flow-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.flow-title {
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}
.flow-desc {
    font-size: 12px;
    color: var(--text-muted);
}
.flow-arrow {
    color: var(--silver-dim);
    font-size: 18px;
    opacity: 0.5;
}

/* MFCC Heatmap */
.mfcc-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    margin: 0 auto;
    max-width: 300px;
    aspect-ratio: 2/1;
}
.h-cell {
    background: var(--bg-tertiary);
    border-radius: 2px;
}
.c1 { background: rgba(255,255,255,0.05); }
.c2 { background: rgba(255,255,255,0.15); }
.c3 { background: rgba(255,255,255,0.3); }
.c4 { background: rgba(255,255,255,0.5); }
.c5 { background: rgba(255,255,255,0.8); box-shadow: 0 0 10px rgba(255,255,255,0.2); }

/* Neural Network Boxes */
.nn-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--silver);
    min-width: 80px;
}
.nn-box.highlight {
    border-color: var(--accent-solid);
    color: #fff;
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
}
.nn-layer {
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    font-size: 12px;
    color: var(--silver);
    border: 1px solid transparent;
}
.nn-layer.frozen {
    border: 1px dashed var(--silver-dim);
    opacity: 0.6;
}
.nn-layer.retrain {
    background: var(--accent-glow);
    border: 1px solid var(--accent-solid);
    color: #fff;
}

/* Confusion Matrix Table */
.confusion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: 'SF Mono', monospace;
}
.confusion-table td {
    text-align: center;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    color: var(--text-muted);
}
.confusion-table td.high { background: rgba(110, 231, 160, 0.2); color: #fff; font-weight: 700; }
.confusion-table td.mid { background: rgba(252, 211, 77, 0.15); color: #fff; }
.confusion-table td.err { background: rgba(255, 100, 100, 0.15); color: #ffadad; }

/* Syntax Highlighting (Code Blocks) */
.k { color: #c678dd; } /* keyword */
.f { color: #61afef; } /* function */
.s { color: #98c379; } /* string */
.c { color: #5c6370; font-style: italic; } /* comment */
.n { color: #d19a66; } /* number */
.t { color: #e5c07b; } /* type/class */