/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #1e1e1e;
    --bg-card: #252526;
    --bg-card-hover: #2d2d2d;
    --surface: #333333;
    --border: #404040;
    --text: #cccccc;
    --text-muted: #858585;
    --accent: #0696D7;
    --accent-hover: #0078D7;
    --accent-glow: rgba(6, 150, 215, 0.2);
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --radius: 4px;
    --radius-sm: 2px;
    --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

body.light-theme {
    --bg: #f3f3f3;
    --bg-card: #ffffff;
    --bg-card-hover: #f9f9f9;
    --surface: #e5e5e5;
    --border: #cccccc;
    --text: #333333;
    --text-muted: #666666;
    --accent: #0696D7;
    --accent-hover: #0078D7;
    --accent-glow: rgba(6, 150, 215, 0.1);
}

.theme-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
}
.theme-toggle-btn:hover {
    transform: scale(1.1);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

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

/* ===== Navigation ===== */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-logo:hover {
    color: var(--accent);
}

.logo-icon {
    font-size: 1.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 32px;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--text);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ===== Hero ===== */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 100px 24px 60px;
    max-width: 1200px;
    margin: 0 auto;
    gap: 60px;
}

.hero-content {
    flex: 1;
}

.hero-content h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 520px;
    margin-bottom: 36px;
    line-height: 1.8;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    margin-bottom: 36px;
}

.hero-stats {
    display: flex;
    gap: 32px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-visual {
    flex: 0 0 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    font-family: var(--font);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px var(--accent-glow);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}

.btn-outline:hover {
    background: rgba(59, 130, 246, 0.1);
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9rem;
}

.btn-outline.btn-small {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}

.btn-outline.btn-small:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* ===== Progress Bar ===== */
#progress-bar {
    padding: 32px 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

#progress-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 100px;
    overflow: hidden;
}

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

/* ===== Section Titles ===== */
.section-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
    text-align: center;
}

.section-subtitle {
    color: var(--text-muted);
    text-align: center;
    max-width: 600px;
    margin: 0 auto 48px;
}

/* ===== Modules ===== */
#modules {
    padding: 80px 0;
}

.modules-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    transition: all var(--transition);
}

.module-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--accent-glow);
}

.module-card.completed {
    border-color: var(--green);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

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

.module-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    opacity: 0.4;
}

.module-tag {
    background: var(--border);
    color: var(--text);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.module-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.module-desc {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Card entrance stagger — driven by scroll-reveal (.reveal / .active) in shared.js.
   We only set the transition-delay here; opacity & transform live on .reveal / .reveal.active. */
.module-card-link:nth-child(1) .module-card { transition-delay: 0.05s; }
.module-card-link:nth-child(2) .module-card { transition-delay: 0.10s; }
.module-card-link:nth-child(3) .module-card { transition-delay: 0.12s; }
.module-card-link:nth-child(4) .module-card { transition-delay: 0.14s; }
.module-card-link:nth-child(5) .module-card { transition-delay: 0.16s; }
.module-card-link:nth-child(6) .module-card { transition-delay: 0.18s; }
.module-card-link:nth-child(7) .module-card { transition-delay: 0.20s; }
.module-card-link:nth-child(8) .module-card { transition-delay: 0.22s; }
.module-card-link:nth-child(9) .module-card { transition-delay: 0.24s; }
.module-card-link:nth-child(10) .module-card { transition-delay: 0.26s; }
.module-card-link:nth-child(11) .module-card { transition-delay: 0.28s; }
.module-card-link:nth-child(12) .module-card { transition-delay: 0.30s; }
.module-card-link:nth-child(13) .module-card { transition-delay: 0.32s; }
.module-card-link:nth-child(14) .module-card { transition-delay: 0.34s; }
.module-card-link:nth-child(15) .module-card { transition-delay: 0.36s; }

/* Concept Blocks */
.concept-block {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin: 24px 0;
}

.concept-block h5 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
}

/* Comparison Grid */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.compare-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 20px;
    border: 1px solid var(--border);
}

.compare-item h6 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.compare-item ul {
    list-style: none;
    padding: 0;
}

.compare-item ul li {
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.compare-item ul li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: bold;
}

.compare-item p {
    font-size: 0.9rem;
}

/* Workflow Steps */
.workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.workflow-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.step-num {
    flex: 0 0 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.workflow-step p {
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.feature-card strong {
    display: block;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.85rem;
}

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 8px 0 8px 20px;
    position: relative;
    color: var(--text-muted);
}

.feature-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Tip Box */
.tip-box {
    background: rgba(59, 130, 246, 0.08);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 20px 24px;
    margin: 24px 0;
    color: var(--text-muted);
}

.tip-box strong {
    color: var(--accent);
}

/* Table */
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.info-table th,
.info-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.info-table th {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-table td {
    color: var(--text-muted);
}

/* Tolerance Visuals */
.tolerance-visual {
    height: 40px;
    margin-top: 12px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.tolerance-visual.clearance {
    background: repeating-linear-gradient(
        90deg,
        var(--accent) 0px, var(--accent) 40px,
        transparent 40px, transparent 50px,
        var(--green) 50px, var(--green) 90px,
        transparent 90px, transparent 100px
    );
    opacity: 0.3;
}

.tolerance-visual.transition {
    background: repeating-linear-gradient(
        90deg,
        var(--accent) 0px, var(--accent) 45px,
        transparent 45px, transparent 47px,
        var(--green) 47px, var(--green) 92px,
        transparent 92px, transparent 94px
    );
    opacity: 0.3;
}

.tolerance-visual.interference {
    background: repeating-linear-gradient(
        90deg,
        var(--accent) 0px, var(--accent) 48px,
        var(--yellow) 48px, var(--yellow) 52px,
        var(--green) 52px, var(--green) 100px
    );
    opacity: 0.3;
}

/* DOF Visual */
.dof-visual {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.dof-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.dof-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 4px;
}

.dof-icon.translate { color: var(--accent); }
.dof-icon.rotate { color: var(--green); }

.dof-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Joint List */
.joint-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.joint-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.joint-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.joint-icon.revolute {
    background: conic-gradient(var(--accent), transparent 270deg, var(--accent));
    border: 3px solid var(--accent);
}

.joint-icon.prismatic {
    background: linear-gradient(180deg, var(--accent) 30%, transparent 30%, transparent 70%, var(--accent) 70%);
    border: 3px solid var(--accent);
    border-radius: 8px;
}

.joint-icon.cylindrical {
    background: conic-gradient(var(--green), transparent 180deg, var(--green));
    border: 3px solid var(--green);
}

.joint-icon.rigid {
    background: var(--surface);
    border: 3px solid var(--text-muted);
}

.joint-item strong {
    color: var(--text);
}

.joint-item p {
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Mechanism List */
.mechanism-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mechanism-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.mechanism-item h6 {
    color: var(--accent);
    margin-bottom: 6px;
}

.mechanism-item p {
    font-size: 0.9rem;
}

/* Formula Box */
.formula-box {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin: 16px 0;
    text-align: center;
}

.formula-box p {
    margin-bottom: 6px;
}

.formula-example {
    font-size: 1.1rem;
    color: var(--text);
}

.formula-note {
    color: var(--green);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Code Example */
.code-example {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-top: 12px;
}

.code-example code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--green);
    line-height: 1.8;
}

/* Folder Tree */
.folder-tree {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 2;
}

.folder { padding-left: 20px; color: var(--accent); }
.file { padding-left: 20px; color: var(--text-muted); }
.folder-tree > .folder { padding-left: 0; }

/* Checklist */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
}

.check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--green);
    cursor: pointer;
}

/* Mistakes Grid */
.mistakes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mistake-card {
    padding: 16px;
    border-radius: var(--radius-sm);
}

.mistake-card h6 {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.mistake-card.bad {
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.mistake-card.bad h6 {
    color: var(--red);
}

.mistake-card.good {
    background: var(--green-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.mistake-card.good h6 {
    color: var(--green);
}

.mistake-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== Interactive Demos ===== */
.interactive-container {
    margin: 28px 0;
}

.interactive-header {
    margin-bottom: 16px;
}

.interactive-header h5 {
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.interactive-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.interactive-container canvas {
    width: 100%;
    max-width: 500px;
    display: block;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
}

.extrude-demo,
.gear-demo,
.linkage-demo,
.dof-demo,
.print-demo,
.cam-demo,
.parametric-demo,
.tolerance-demo {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.extrude-controls,
.gear-controls,
.linkage-controls,
.dof-controls,
.print-controls,
.cam-controls,
.parametric-controls,
.tolerance-controls {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.demo-btn {
    padding: 8px 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.demo-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.demo-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.extrude-slider-wrap,
.linkage-controls label,
.print-controls label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    justify-content: center;
    margin-top: 12px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--surface);
    border-radius: 100px;
    outline: none;
    cursor: pointer;
    flex: 0 0 200px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 6px var(--accent-glow);
}

.demo-description {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 12px;
    font-style: italic;
}

/* Gear readout */
.gear-readout {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.readout-item {
    text-align: center;
}

.readout-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.readout-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
}

.gear-control {
    flex: 1;
    min-width: 200px;
}

.gear-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.gear-control input[type="range"] {
    width: 100%;
    flex: 1;
}

/* DOF controls */
.dof-controls {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px !important;
    margin-top: 16px;
}

.dof-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all var(--transition);
}

.dof-toggle:has(input:checked) {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent);
    color: var(--text);
}

.dof-toggle input {
    accent-color: var(--accent);
}

.toggle-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: auto;
}

.tx-color { background: #ef4444; }
.ty-color { background: #22c55e; }
.tz-color { background: #3b82f6; }
.rx-color { background: #f97316; }
.ry-color { background: #a855f7; }
.rz-color { background: #eab308; }

.dof-readout {
    text-align: center;
    margin-top: 16px;
}

.dof-count {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.dof-count span {
    color: var(--accent);
    font-size: 2rem;
}

.dof-status {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Linkage info */
.linkage-info {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.linkage-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--surface);
    border-radius: 4px;
}

/* Print orientation meters */
.print-meters {
    width: 100%;
    max-width: 400px;
    margin: 12px auto 0;
}

.meter {
    margin-bottom: 8px;
}

.meter-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.meter-bar {
    height: 10px;
    background: var(--surface);
    border-radius: 100px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 100%;
}

.strength-fill {
    background: #22c55e;
}

.meter-value {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
    display: block;
}

/* ===== 3D Model Viewers ===== */
.model-viewer-wrap {
    margin-bottom: 28px;
}

model-viewer {
    --poster-color: transparent;
}

model-viewer::part(default-progress-bar) {
    background: var(--accent);
    height: 3px;
}

.model-caption {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
    font-style: italic;
}

.model-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.model-single {
    min-width: 0;
}

/* ===== Quiz ===== */
#quiz-section {
    padding: 80px 0;
    background: var(--bg-card);
}

.quiz-container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
}

.quiz-progress {
    margin-bottom: 28px;
}

#quiz-progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.quiz-progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 100px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    width: 10%;
    background: var(--accent);
    border-radius: 100px;
    transition: width 0.3s ease;
}

.quiz-question {
    margin-bottom: 24px;
}

.quiz-question h4 {
    font-size: 1.15rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    display: block;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: left;
}

.quiz-option:hover {
    border-color: var(--border);
    border-left-color: var(--accent);
    background: var(--surface);
    color: var(--text);
}

.quiz-option.selected {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text);
}

.quiz-option.correct {
    border-color: var(--green);
    background: var(--green-bg);
    color: var(--green);
}

.quiz-option.incorrect {
    border-color: var(--red);
    background: var(--red-bg);
    color: var(--red);
}

.quiz-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
}

.quiz-results {
    text-align: center;
    padding: 24px 0;
}

.score-display {
    margin: 24px 0;
}

.score-number {
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent);
}

.score-label {
    font-size: 1.2rem;
    color: var(--text-muted);
}

#quiz-message {
    margin-bottom: 24px;
    font-size: 1.1rem;
}

.quiz-option:disabled {
    cursor: default;
    opacity: 0.9;
}

.quiz-option:disabled:hover {
    border-color: var(--border);
    background: var(--bg-card);
}

.quiz-option.correct:disabled:hover {
    border-color: var(--green);
    background: var(--green-bg);
}

.quiz-option.incorrect:disabled:hover {
    border-color: var(--red);
    background: var(--red-bg);
}

.quiz-module-tag {
    display: inline-block;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.quiz-explanation {
    margin-top: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
    animation: fadeSlideIn 0.3s ease;
}

.quiz-explanation.correct {
    background: var(--green-bg);
    border-left: 3px solid var(--green);
    color: var(--text-muted);
}

.quiz-explanation.correct strong {
    color: var(--green);
}

.quiz-explanation.incorrect {
    background: var(--red-bg);
    border-left: 3px solid var(--red);
    color: var(--text-muted);
}

.quiz-explanation.incorrect strong {
    color: var(--red);
}

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

/* Quiz Review */
.quiz-review {
    margin-top: 32px;
    text-align: left;
}

.quiz-review h4 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text);
}

.review-item {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border-left: 3px solid;
}

.review-item.review-correct {
    background: rgba(34, 197, 94, 0.05);
    border-left-color: var(--green);
}

.review-item.review-incorrect {
    background: rgba(239, 68, 68, 0.05);
    border-left-color: var(--red);
}

.review-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.review-icon {
    font-weight: 800;
    font-size: 1.1rem;
}

.review-correct .review-icon { color: var(--green); }
.review-incorrect .review-icon { color: var(--red); }

.review-q-num {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.review-module {
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 100px;
}

.review-question {
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 6px;
    font-weight: 500;
}

.review-answer {
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.correct-text {
    color: var(--green);
    display: block;
}

.incorrect-text {
    color: var(--red);
    display: block;
    text-decoration: line-through;
    opacity: 0.7;
}

.review-explanation {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Quiz Dynamic Elements (generated by quiz.js) */
.quiz-question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.quiz-question-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 20px;
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.quiz-submit {
    display: inline-block;
    padding: 10px 24px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.quiz-submit:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.quiz-retry {
    display: inline-block;
    padding: 10px 24px;
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.quiz-retry:hover {
    background: rgba(59, 130, 246, 0.1);
}

.quiz-score {
    text-align: center;
    padding: 32px 0;
}

.quiz-score-number {
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent);
    display: block;
    line-height: 1;
}

.quiz-score-label {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 8px;
    display: block;
}

.quiz-review-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 12px;
    border-left: 3px solid var(--border);
}

.quiz-review-item.correct {
    border-left-color: var(--green);
}

.quiz-review-item.incorrect {
    border-left-color: var(--red);
}

.quiz-review-question {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.quiz-review-answer {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.quiz-review-explanation {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ===== Glossary ===== */
#glossary {
    padding: 80px 0;
}

.glossary-search {
    max-width: 400px;
    margin: 0 auto 36px;
}

.glossary-search input {
    width: 100%;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
}

.glossary-search input::placeholder {
    color: var(--text-muted);
}

.glossary-search input:focus {
    border-color: var(--accent);
}

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

.glossary-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.glossary-item dt {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
}

.glossary-item dd {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ===== Resources ===== */
#resources {
    padding: 80px 0;
    background: var(--bg-card);
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.resource-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.resource-card h4 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
}

.resource-card ul {
    list-style: none;
    padding: 0;
}

.resource-card li {
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-left: 16px;
    position: relative;
}

.resource-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ===== Multi-Page: Module Page Layout ===== */
.module-page {
    padding: 100px 0 60px;
    min-height: 100vh;
}

.module-page-header {
    margin-bottom: 36px;
}

.module-page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.module-page-header .module-desc {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 0;
}

.module-page-header .module-header {
    margin-bottom: 12px;
}

.back-link {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

/* Prev / Next navigation at bottom of module pages */
.module-nav-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    gap: 16px;
}

.module-nav-bottom > div {
    flex: 1;
}

.module-nav-bottom > div:last-child {
    text-align: right;
}

/* Module card links on index page */
.module-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.module-card-link:hover {
    color: inherit;
}

.module-card-link .module-card {
    cursor: pointer;
}

.module-card-btn {
    display: inline-block;
    margin-top: 4px;
}

/* Completed badge */
.completed-badge {
    margin-left: auto;
    background: var(--green);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.module-card.completed .completed-badge {
    display: flex !important;
}

.module-card:not(.completed) .completed-badge {
    display: none !important;
}

.module-card.completed .module-card-btn {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--green);
    color: var(--green);
}

/* Active nav link */
.nav-links a.active {
    color: var(--text);
    position: relative;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 100px;
}

/* ===== Content Sections (module pages) ===== */
.content-section {
    margin-top: 32px;
}

.content-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.content-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    margin-top: 32px;
}

.content-section p {
    margin-bottom: 16px;
    color: var(--text-muted);
}

/* ===== Feature Cards Grid ===== */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

/* ===== Model Card ===== */
.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow: hidden;
}

/* ===== Footer ===== */
footer {
    padding: 40px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #hero {
        flex-direction: column;
        text-align: center;
        padding-top: 120px;
        gap: 40px;
    }

    .hero-subtitle {
        margin: 0 auto 36px;
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
        gap: 20px;
    }

    .hero-visual {
        flex: none;
    }

    .hero-visual model-viewer {
        width: 280px !important;
        height: 280px !important;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        backdrop-filter: blur(12px);
        padding: 16px 24px;
        gap: 16px;
        border-bottom: 1px solid var(--border);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .dof-visual {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

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

    .dof-controls {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .gear-readout {
        gap: 16px;
    }

    .interactive-container canvas {
        max-width: 100%;
    }

    .model-pair {
        grid-template-columns: 1fr;
    }

    .module-nav-bottom {
        flex-direction: column;
        gap: 20px;
    }

    .module-nav-bottom > div,
    .module-nav-bottom > div:last-child {
        text-align: center;
    }

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

@media (max-width: 480px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .module-card {
        padding: 24px 20px;
    }

    .quiz-container {
        padding: 24px 20px;
    }
}

/* ===== Scroll Reveal Animations ===== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Focus Styles (Accessibility) ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.quiz-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== Skip-to-content (Accessibility) ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 9999;
    font-weight: 600;
    font-size: 0.9rem;
}
.skip-link:focus {
    top: 8px;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .reveal { opacity: 1; transform: none; }
}
