/* ================================================================
   polish.css — Refined typography, restrained color, real light
   mode. Loaded last so it can tone down anything noisy added by
   styles.css / enhancements.css.

   Goals:
   - Editorial / textbook feel, not "AI website" feel
   - Asymmetry, hand-tuned spacing, restrained color
   - Light mode that looks intentional (not a dark-mode invert)
   - Reusable .diagram component for inline SVG illustrations
   ================================================================ */

/* ============ 1. Tokens ============ */
:root {
    /* Layered surfaces — used for cards, popovers, callouts. */
    --surface-1: rgba(255, 255, 255, 0.025);
    --surface-2: rgba(255, 255, 255, 0.05);
    --surface-3: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.18), 0 1px 3px rgba(0,0,0,0.14);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.22), 0 1px 4px rgba(0,0,0,0.18);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.22);

    /* One restrained palette for phases — we'll only use this in
       small accents (the mini badge), never as full backgrounds. */
    --phase-1: #facc15;
    --phase-2: #fb923c;
    --phase-3: #e2a247;
    --phase-4: #34d399;
    --phase-5: #a78bfa;

    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.08);

    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Editorial type scale */
    --serif: "Iowan Old Style", "Source Serif Pro", "PT Serif", Georgia, serif;
}

/* =====================================================================
   2. LIGHT MODE — full overhaul
   The original light theme inherited the dark layout but on a near-white
   background. Most of the brand-tinted gradient overlays read as muddy or
   washed out. We re-tune all the surfaces, hairlines, shadow depth, and
   accent intensities here.
   ===================================================================== */
body.light-theme {
    /* Warmer paper rather than cold white. */
    --bg: #fbf8f1;
    --bg-card: #ffffff;
    --bg-card-hover: #fff8eb;
    --surface: rgba(28, 18, 4, 0.035);
    --surface-1: rgba(28, 18, 4, 0.03);
    --surface-2: rgba(28, 18, 4, 0.055);
    --surface-3: rgba(28, 18, 4, 0.08);
    --border: rgba(28, 18, 4, 0.10);
    --border-strong: rgba(28, 18, 4, 0.18);
    --text: #1a1916;
    --text-muted: #6b665c;

    /* Use a deeper, less saturated accent for light bg so it doesn't
       glow nuclear orange against the warm paper. */
    --accent: #a96a13;
    --accent-hover: #8a5610;
    --accent-glow: rgba(169, 106, 19, 0.10);
    --accent-dim: rgba(169, 106, 19, 0.07);

    --green: #2f8b3e;
    --green-bg: rgba(47, 139, 62, 0.08);
    --red: #b8423e;
    --red-bg: rgba(184, 66, 62, 0.07);
    --yellow: #b07a18;

    --shadow-sm: 0 1px 1px rgba(15, 12, 6, 0.04), 0 1px 2px rgba(15, 12, 6, 0.04);
    --shadow-md: 0 4px 14px rgba(15, 12, 6, 0.06), 0 1px 4px rgba(15, 12, 6, 0.04);
    --shadow-lg: 0 12px 28px rgba(15, 12, 6, 0.10), 0 2px 8px rgba(15, 12, 6, 0.06);

    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.08);
    --phase-1: #b07a18;
    --phase-2: #c45a18;
    --phase-3: #a96a13;
    --phase-4: #167a47;
    --phase-5: #6c52c4;
}

body.light-theme {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 40% at 50% -10%, rgba(169, 106, 19, 0.06), transparent 70%);
    background-attachment: fixed;
    color: var(--text);
}

/* The dark-mode noise texture is too noisy on paper. Quiet it. */
body.light-theme::after {
    opacity: 0.018;
    mix-blend-mode: multiply;
}

/* ============ 3. Typography rhythm ============ */
body {
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    font-feature-settings: "ss01", "cv02", "cv11", "kern";
    font-synthesis: none;
}

.content-section h2 {
    position: relative;
    padding-bottom: 10px;
    margin-bottom: 18px;
    font-size: clamp(1.35rem, 2.2vw, 1.55rem);
    letter-spacing: -0.018em;
    font-weight: 700;
}

.content-section h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 32px;
    height: 2px;
    background: var(--accent);
    border-radius: 100px;
    opacity: 0.7;
}

.content-section h3 {
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text);
}

.content-section h4 {
    font-size: 1rem;
    margin-top: 24px;
    margin-bottom: 10px;
    color: var(--text);
}

.content-section p {
    text-wrap: pretty;
    max-width: 68ch;
}

.content-section p strong { color: var(--text); font-weight: 700; }

/* ============ 4. HERO — quiet, editorial ============ */
#hero {
    min-height: auto;
    padding: 140px clamp(24px, 4vw, 64px) 80px;
    align-items: center;
    gap: clamp(40px, 8vw, 80px);
    isolation: isolate;
}

#hero::before {
    content: '';
    position: absolute;
    inset: -40px -20% auto -20%;
    height: 80vh;
    z-index: -2;
    background: radial-gradient(ellipse 60% 50% at 30% 30%, rgba(226, 162, 71, 0.05), transparent 60%);
    pointer-events: none;
}

body.light-theme #hero::before {
    background: radial-gradient(ellipse 60% 50% at 30% 30%, rgba(169, 106, 19, 0.05), transparent 60%);
}

/* Quiet eyebrow — no pill, no gradient, just type. */
.hero-content .eyebrow {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 22px;
    padding-left: 14px;
    border-left: 2px solid var(--accent);
}

.hero-content h1 {
    font-size: clamp(2.5rem, 4.6vw, 3.6rem);
    font-weight: 800;
    line-height: 1.06;
    letter-spacing: -0.035em;
    margin-bottom: 22px;
    color: var(--text);
    /* No gradient text — single-color heading reads as a real publication. */
    -webkit-text-fill-color: currentColor;
    background: none;
}

.hero-subtitle {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-muted);
    max-width: 540px;
    margin-bottom: 28px;
}

.hero-buttons {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 13px 16px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.btn-ghost:hover {
    color: var(--text);
    background: transparent;
}

.btn-ghost::after {
    content: " \2192";
    transition: transform 0.2s;
    display: inline-block;
}

.btn-ghost:hover::after { transform: translateX(3px); }

.hero-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
    letter-spacing: 0.01em;
}

/* The 3D model viewport gets a soft frame on hover */
.hero-visual model-viewer {
    border-radius: 18px;
    transition: transform 0.6s var(--ease-out-expo);
}

/* The decorative aura behind the model — keep but soften so it doesn't
   look like a stock-template "glow". */
.hero-visual::before {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
    filter: blur(50px);
    animation: none;
    opacity: 0.7;
}

body.light-theme .hero-visual::before {
    opacity: 0.5;
}

/* ============ 5. SECTION TITLES — tighter ============ */
.section-title {
    font-size: clamp(1.6rem, 2.4vw, 1.95rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    /* No gradient — let the heading be a heading. */
    -webkit-text-fill-color: currentColor;
    background: none;
    color: var(--text);
}

.section-subtitle {
    font-size: 0.98rem;
    line-height: 1.6;
}

/* ============ 6. PHASE HEADERS — restrained ============ */
.phase-group[data-phase="1"] { --phase: var(--phase-1); }
.phase-group[data-phase="2"] { --phase: var(--phase-2); }
.phase-group[data-phase="3"] { --phase: var(--phase-3); }
.phase-group[data-phase="4"] { --phase: var(--phase-4); }
.phase-group[data-phase="5"] { --phase: var(--phase-5); }

/* Refined: subtle baseline rule + small numbered chip. No background fill,
   no gradient — just type with a quiet color accent on the badge. */
.phase-header {
    position: relative;
    padding: 14px 0 14px 56px;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: none;
    overflow: visible;
}

.phase-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--phase, var(--accent)) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--phase, var(--accent)) 28%, transparent);
}

.phase-header::after {
    content: attr(data-glyph);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--phase, var(--accent));
    font-weight: 700;
    font-size: 1.05rem;
    pointer-events: none;
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
}

.phase-header .phase-number {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.phase-header .phase-title {
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.018em;
}

.phase-header .phase-desc {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.88rem;
}

/* ============ 7. MODULE CARDS — subdued accent ============ */
.modules-grid > .module-card-link .module-card {
    position: relative;
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
}

/* Drop the radial corner glow — too generic. Keep just an elevation. */
.module-card::after {
    content: none;
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.module-card .module-number {
    opacity: 0.5;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

/* Phase-tinted top accent + tag chip — kept, but very low saturation. */
.phase-group[data-phase="1"] .module-tag,
.phase-group[data-phase="2"] .module-tag,
.phase-group[data-phase="3"] .module-tag,
.phase-group[data-phase="4"] .module-tag,
.phase-group[data-phase="5"] .module-tag {
    color: var(--phase);
    border-color: color-mix(in srgb, var(--phase) 25%, transparent);
    background: color-mix(in srgb, var(--phase) 8%, transparent);
}

.phase-group[data-phase="1"] .module-card::before { background: var(--phase-1); }
.phase-group[data-phase="2"] .module-card::before { background: var(--phase-2); }
.phase-group[data-phase="3"] .module-card::before { background: var(--phase-3); }
.phase-group[data-phase="4"] .module-card::before { background: var(--phase-4); }
.phase-group[data-phase="5"] .module-card::before { background: var(--phase-5); }

/* ============ 8. STATS TRACKER — quieter ============ */
.stat-card-icon {
    transition: transform 0.4s var(--ease-back), background 0.3s ease;
}

.stat-card:hover .stat-card-icon {
    transform: scale(1.06);
}

/* No gradient text on stats — readability over flair. */
.stat-card-value {
    color: var(--text);
    background: none;
    -webkit-text-fill-color: currentColor;
    font-variant-numeric: tabular-nums;
}

/* ============ 9. BUTTONS — flatter, less branded ============ */
.btn-primary {
    background: var(--accent);
    color: #fff8eb;
    box-shadow: 0 1px 0 rgba(0,0,0,0.10);
    border: 1px solid color-mix(in srgb, var(--accent) 75%, #000);
    font-weight: 700;
    letter-spacing: 0.005em;
}

body.light-theme .btn-primary {
    color: #fff8eb;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 0 rgba(0,0,0,0.10);
    transform: translateY(-1px);
    color: #fff8eb;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(0,0,0,0.10);
}

.btn-outline {
    background: var(--surface-1);
    border-color: var(--border-strong);
}

/* ============ 10. PROGRESS BAR — refined ============ */
#progress-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.progress-fill {
    background: var(--accent);
}

/* ============ 11. DIAGRAM COMPONENT ============ */
.diagram {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px 22px 14px;
    margin: 28px 0;
    box-shadow: var(--shadow-sm);
}

.diagram svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 460px;
    color: var(--text);
}

.diagram .diagram-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.diagram .diagram-title::before {
    content: 'FIG.';
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.diagram .diagram-caption {
    font-size: 0.86rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
    line-height: 1.55;
    font-family: var(--serif);
    font-style: italic;
}

.diagram .diagram-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.diagram .diagram-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.diagram .diagram-legend i {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
}

/* SVG class palette — works for both themes via CSS vars */
.svg-stroke { stroke: var(--text); fill: none; stroke-width: 1.5; }
.svg-stroke-strong { stroke: var(--text); fill: none; stroke-width: 2; }
.svg-stroke-dim { stroke: var(--text-muted); fill: none; stroke-width: 1; }
.svg-stroke-dashed { stroke: var(--text-muted); fill: none; stroke-width: 1; stroke-dasharray: 4 4; }
.svg-fill-surface { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1; }
.svg-fill-accent { fill: var(--accent); }
.svg-fill-accent-dim { fill: var(--accent-dim); stroke: var(--accent); stroke-width: 1.5; }
.svg-fill-green { fill: rgba(92, 184, 92, 0.18); stroke: var(--green); stroke-width: 1.5; }
.svg-fill-red { fill: rgba(217, 83, 79, 0.18); stroke: var(--red); stroke-width: 1.5; }
.svg-fill-info { fill: rgba(96, 165, 250, 0.18); stroke: var(--info); stroke-width: 1.5; }
.svg-text { fill: var(--text); font-family: var(--font); font-size: 12px; }
.svg-text-muted { fill: var(--text-muted); font-family: var(--font); font-size: 11px; }
.svg-text-accent { fill: var(--accent); font-family: var(--font); font-weight: 700; font-size: 12px; }
.svg-mono { fill: var(--text); font-family: var(--font-mono); font-size: 11px; }
.svg-hatch { stroke: var(--text-muted); stroke-width: 0.7; opacity: 0.6; fill: none; }

/* On light, increase fills slightly so they don't read as ghost */
body.light-theme .svg-fill-accent-dim { fill: rgba(169, 106, 19, 0.12); }
body.light-theme .svg-fill-green { fill: rgba(47, 139, 62, 0.13); }
body.light-theme .svg-fill-red { fill: rgba(184, 66, 62, 0.13); }
body.light-theme .svg-fill-info { fill: rgba(37, 99, 235, 0.12); }

/* Faint paper-grid on diagrams — it reads "engineering blueprint"
   without screaming "AI". */
.diagram.has-grid {
    background-image:
        linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px),
        var(--bg-card);
    background-size: 20px 20px, 20px 20px, auto;
    background-position: -1px -1px;
}

body.light-theme .diagram.has-grid {
    background-image:
        linear-gradient(rgba(15, 12, 6, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 12, 6, 0.05) 1px, transparent 1px),
        var(--bg-card);
}

/* ============ 12. CALLOUTS ============ */
.callout {
    --c: var(--accent);
    --cb: var(--accent-dim);
    background: var(--cb);
    border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
    border-left: 3px solid var(--c);
    border-radius: 6px;
    padding: 14px 18px 14px 52px;
    margin: 18px 0;
    position: relative;
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.6;
}

.callout::before {
    position: absolute;
    left: 14px;
    top: 14px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--c) 18%, transparent);
    color: var(--c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    line-height: 1;
}

.callout strong { color: var(--c); display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }

.callout.tip     { --c: var(--accent); --cb: var(--accent-dim); }
.callout.tip::before     { content: '!'; }
.callout.info    { --c: var(--info);   --cb: var(--info-bg); }
.callout.info::before    { content: 'i'; font-style: italic; }
.callout.warning { --c: #facc15;       --cb: rgba(250, 204, 21, 0.10); }
.callout.warning::before { content: '!'; }
.callout.success { --c: var(--green);  --cb: var(--green-bg); }
.callout.success::before { content: '\2713'; }
.callout.danger  { --c: var(--red);    --cb: var(--red-bg); }
.callout.danger::before  { content: '\2715'; }

.callout p:last-child { margin-bottom: 0; }

/* ============ 13. COMPARE TABLE ============ */
.compare-table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 0;
    background: var(--bg-card);
}

.compare-table .col {
    padding: 18px 20px;
    border-right: 1px solid var(--border);
    background: var(--surface-1);
}

.compare-table .col:last-child { border-right: none; }

.compare-table .col h6 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--accent);
}

.compare-table .col.col-good h6 { color: var(--green); }
.compare-table .col.col-bad h6 { color: var(--red); }

.compare-table .col p,
.compare-table .col li {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.compare-table .col ul {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
}

.compare-table .col ul li {
    padding: 3px 0 3px 18px;
    position: relative;
}

.compare-table .col.col-good ul li::before { content: '\2713'; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.compare-table .col.col-bad  ul li::before { content: '\2715'; position: absolute; left: 0; color: var(--red); font-weight: 700; }

@media (max-width: 600px) {
    .compare-table { grid-template-columns: 1fr; }
    .compare-table .col { border-right: none; border-bottom: 1px solid var(--border); }
    .compare-table .col:last-child { border-bottom: none; }
}

/* ============ 14. CONCEPT BLOCK ============ */
/* Drop the gradient and the gold border-left from styles.css —
   replace with a calmer card.  We also lose the diamond glyph in front
   of the heading. */
.concept-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    box-shadow: var(--shadow-sm);
}

body.light-theme .concept-block {
    background: var(--bg-card);
}

.concept-block:hover {
    box-shadow: var(--shadow-md);
}

.concept-block h5 {
    padding-left: 0;
    color: var(--text);
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.concept-block h5::before {
    content: none;
}

/* ============ 15. MODULE PAGE HEADER — calmer ============ */
.module-page-header {
    padding: 28px 0 24px;
    margin-top: 8px;
    margin-bottom: 28px;
    background: none;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    position: relative;
    overflow: visible;
}

.module-page-header::before {
    content: none;
}

.module-page-header h1 {
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 8px;
}

.module-page-header .module-desc {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 64ch;
}

.module-page-header .back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.module-page-header .module-number {
    color: var(--text-muted);
    opacity: 0.7;
    font-size: 1rem;
    font-weight: 700;
}

/* ============ 16. LEARNING OBJECTIVES & TAKEAWAYS — flatter ============ */
.learning-objectives,
.key-takeaways {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 22px 26px;
    margin: 24px 0 28px;
    overflow: visible;
    box-shadow: var(--shadow-sm);
}

.learning-objectives::before,
.key-takeaways::before { content: none; }

.learning-objectives h3,
.key-takeaways h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 14px;
    color: var(--accent);
    font-weight: 700;
}

.key-takeaways {
    border-left-color: var(--green);
    background: var(--green-bg);
}

.key-takeaways h3 {
    color: var(--green);
}

.learning-objectives li {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.55;
}

.key-takeaways li {
    color: var(--text);
    font-size: 0.94rem;
    line-height: 1.6;
}

.key-takeaways li::before {
    content: '\2192';
    color: var(--green);
    font-weight: 700;
}

.learning-objectives li::before {
    content: '\2022';
    color: var(--accent);
    font-size: 1.1rem;
    line-height: 1;
}

/* ============ 17. GLOSSARY ============ */
.glossary-category-heading {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    margin: 32px 0 14px;
    padding-left: 0;
    position: relative;
    letter-spacing: -0.015em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.glossary-category-heading::before,
.glossary-category-heading::after { content: none; }

.glossary-category-heading::after {
    content: attr(data-icon);
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-60%);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.12em;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface-1);
}

.glossary-category-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}

.glossary-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease;
}

.glossary-item:hover {
    border-color: var(--accent);
    transform: none;
    box-shadow: var(--shadow-sm);
}

.glossary-item dt {
    color: var(--text);
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.glossary-item dt::after {
    content: '';
    display: block;
    width: 18px;
    height: 2px;
    background: var(--accent);
    margin-top: 6px;
    margin-bottom: 8px;
    opacity: 0.7;
}

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

/* ============ 18. RESOURCES CARDS ============ */
.resource-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

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

.resource-card h4 {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.resource-card h4::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 100px;
    background: var(--accent);
    transform: translateY(-2px);
    flex-shrink: 0;
}

/* ============ 19. NAVBAR ============ */
body.light-theme #navbar {
    background: rgba(251, 248, 241, 0.85);
    border-bottom: 1px solid var(--border);
}

#navbar.scrolled {
    box-shadow: var(--shadow-sm);
}

/* ============ 20. KOLB CYCLE — quieter ============ */
.kolb-cycle {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

/* ============ 21. STEP RAIL ============ */
.step-rail {
    position: relative;
    padding-left: 36px;
    margin: 24px 0;
    counter-reset: steps;
}

.step-rail::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--accent);
    border-radius: 100px;
    opacity: 0.4;
}

.step-rail .step {
    position: relative;
    padding-bottom: 22px;
}

.step-rail .step::before {
    content: counter(steps);
    counter-increment: steps;
    position: absolute;
    left: -36px;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.step-rail .step h4 {
    font-size: 1rem;
    margin: 0 0 6px;
    color: var(--text);
}

.step-rail .step p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============ 22. INLINE GLOSSARY DEFS ============ */
.def {
    border-bottom: 1px dotted var(--accent);
    color: var(--text);
    cursor: help;
    padding: 0 1px;
}

/* ============ 23. INTERACTIVE DEMOS — light-mode tweaks ============ */
body.light-theme .interactive-container canvas {
    background: rgba(255, 250, 240, 0.65);
    border-color: var(--border);
}

body.light-theme .extrude-demo,
body.light-theme .gear-demo,
body.light-theme .linkage-demo,
body.light-theme .dof-demo,
body.light-theme .print-demo,
body.light-theme .cam-demo,
body.light-theme .parametric-demo,
body.light-theme .tolerance-demo,
body.light-theme .sweep-loft-demo,
body.light-theme .section-demo {
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

body.light-theme .demo-btn {
    background: var(--surface-1);
    border-color: var(--border-strong);
    color: var(--text);
}

body.light-theme .demo-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

body.light-theme .demo-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff8eb;
    box-shadow: var(--shadow-sm);
}

/* ============ 24. KNOWLEDGE CHECK & EXPERIMENT BLOCKS — quieter ============ */
.knowledge-check,
.experiment-block,
.reflection-block,
.real-world-card,
.weight-challenge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.knowledge-check::before,
.experiment-block::before,
.reflection-block::before,
.real-world-card::before,
.weight-challenge::before {
    /* Trim down the rainbow bar at the top of every card */
    background: var(--accent);
    opacity: 0.55;
    height: 2px;
}

body.light-theme .reflection-block {
    background: linear-gradient(180deg, #fff 0%, #faf8f3 100%);
    border-color: var(--border);
}

body.light-theme .reflection-prompt textarea {
    background: var(--surface-1);
    border-color: var(--border-strong);
    color: var(--text);
}

body.light-theme .reflection-prompt textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

body.light-theme .reflection-header {
    color: #6c52c4;
}

body.light-theme .experiment-tasks li {
    background: var(--surface-1);
    border-color: var(--border);
    color: var(--text);
}

/* ============ 25. CHALLENGE BANNER & PREDICTION PROMPT ============ */
body.light-theme .challenge-banner {
    background: rgba(176, 122, 24, 0.06);
    border-color: rgba(176, 122, 24, 0.18);
}

body.light-theme .challenge-banner .challenge-body h4,
body.light-theme .challenge-banner .challenge-body .challenge-target {
    color: var(--yellow);
}

body.light-theme .prediction-prompt {
    background: rgba(196, 90, 24, 0.05);
    border-color: rgba(196, 90, 24, 0.18);
}

body.light-theme .prediction-prompt .pred-header {
    color: #c45a18;
}

body.light-theme .prediction-options button {
    background: rgba(196, 90, 24, 0.04);
    border-color: rgba(196, 90, 24, 0.20);
    color: var(--text);
}

body.light-theme .prediction-options button:hover {
    border-color: #c45a18;
    background: rgba(196, 90, 24, 0.10);
}

body.light-theme .prediction-options button.selected {
    background: rgba(196, 90, 24, 0.14);
    color: #c45a18;
    border-color: #c45a18;
}

/* ============ 26. INFO TABLES — light bg adjustments ============ */
body.light-theme .info-table {
    background: var(--bg-card);
}

body.light-theme .info-table thead th {
    background: var(--surface-1);
    color: var(--accent);
}

body.light-theme .info-table tbody tr:nth-child(even) {
    background: rgba(28, 18, 4, 0.025);
}

body.light-theme .info-table tbody tr:hover {
    background: var(--accent-dim);
}

/* ============ 27. CODE BLOCKS — light bg ============ */
body.light-theme code {
    background: rgba(169, 106, 19, 0.08);
    color: var(--accent);
    border-color: rgba(169, 106, 19, 0.15);
}

body.light-theme pre {
    background: #faf6ec;
    border-color: var(--border);
}

body.light-theme pre code {
    color: var(--text);
}

/* ============ 28. TOC — quieter ============ */
.module-toc {
    box-shadow: var(--shadow-sm);
    border-radius: 10px;
    background: var(--bg-card);
}

body.light-theme .module-toc {
    background: var(--bg-card);
}

.module-toc h4::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 100px;
    background: var(--accent);
    margin-right: 8px;
    vertical-align: middle;
}

/* ============ 29. FOOTER ============ */
footer {
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, transparent, var(--surface-1));
}

/* ============ 30. REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
    .stat-card:hover .stat-card-icon { transform: none; }
}

/* ============ 31. PRINT ============ */
@media print {
    .diagram { break-inside: avoid; box-shadow: none; }
    .phase-header { background: #f8f8f8 !important; border-color: #ccc !important; }
    .module-page-header { background: #fff !important; }
}

/* ============ 32. ACCESSIBLE FOCUS RING ============ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ============ 33. HIDE the ::before number watermark on phase headers
   on light theme paper if it crowds the title */
@media (max-width: 600px) {
    .phase-header { padding-left: 48px; }
    .phase-header::before, .phase-header::after { width: 32px; height: 32px; }
}

/* ============ 34. Module-card numbers + tags use tabular nums ============ */
.module-meta { font-variant-numeric: tabular-nums; }

/* ============ 35. Author note — small editorial card we can drop in ============ */
.author-note {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    margin: 24px 0;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    background: var(--surface-1);
    border-radius: 4px;
    font-family: var(--serif);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
    font-style: italic;
}

.author-note::before {
    content: '\201C';
    font-family: var(--serif);
    font-size: 2.2rem;
    color: var(--accent);
    line-height: 0.4;
    margin-top: 14px;
    font-style: normal;
}

.author-note .by {
    display: block;
    margin-top: 6px;
    font-style: normal;
    font-family: var(--font);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

/* ============ 36. MODULE PROGRESS RAIL ============ */
.module-rail {
    margin: 0 0 14px;
    padding: 14px 0 16px;
    border-bottom: 1px solid var(--border);
}

.module-rail[data-phase="1"] { --phase: var(--phase-1); }
.module-rail[data-phase="2"] { --phase: var(--phase-2); }
.module-rail[data-phase="3"] { --phase: var(--phase-3); }
.module-rail[data-phase="4"] { --phase: var(--phase-4); }
.module-rail[data-phase="5"] { --phase: var(--phase-5); }

.module-rail-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.module-rail-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.module-rail-phase {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--phase, var(--accent));
    letter-spacing: 0.02em;
}

.module-rail-dots {
    display: grid;
    grid-template-columns: repeat(21, 1fr);
    gap: 4px;
    width: 100%;
}

.module-rail-dot {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-2);
    border: none;
    transition: background 0.2s ease, transform 0.2s ease;
    position: relative;
}

.module-rail-dot:hover {
    background: var(--text-muted);
    transform: translateY(-1px);
}

.module-rail-dot.done {
    background: var(--green);
    opacity: 0.65;
}

.module-rail-dot.current {
    background: var(--phase, var(--accent));
    height: 8px;
    margin-top: -1px;
    border-radius: 4px;
    box-shadow: 0 1px 4px color-mix(in srgb, var(--phase, var(--accent)) 40%, transparent);
}

.module-rail-dot[data-phase="1"]::after,
.module-rail-dot[data-phase="2"]::after,
.module-rail-dot[data-phase="3"]::after,
.module-rail-dot[data-phase="4"]::after,
.module-rail-dot[data-phase="5"]::after {
    /* invisible phase boundary marker — added via :nth-of-type below */
    content: none;
}

@media (max-width: 600px) {
    .module-rail-dots { gap: 3px; }
}

/* ============ 37. MINI TABLE OF CONTENTS — inline ============ */
.mini-toc {
    margin: 18px 0 28px;
    padding: 12px 0 14px;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}

.mini-toc-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.mini-toc ol {
    list-style: none;
    counter-reset: tocnum;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 18px;
}

.mini-toc li {
    counter-increment: tocnum;
    padding-left: 22px;
    position: relative;
}

.mini-toc li::before {
    content: counter(tocnum, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.mini-toc a {
    display: block;
    padding: 4px 0;
    font-size: 0.86rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
    line-height: 1.45;
}

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

/* ============ 38. NAVBAR REFINE ============ */
#navbar {
    border-bottom: 1px solid var(--border);
}

.nav-logo {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.nav-logo .logo-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--bg);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1;
}

body.light-theme .nav-logo .logo-icon {
    color: #fff8eb;
}

.nav-links a {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Subtle progress hairline at the bottom of the navbar — driven by CSS var */
#navbar::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent) var(--nav-progress, 0%), transparent var(--nav-progress, 0%));
    pointer-events: none;
    transition: --nav-progress 0.4s var(--ease);
}

/* ============ 39. FOOTER ============ */
footer {
    padding: 60px 24px 48px;
    margin-top: 60px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--border-strong);
}

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

/* ============ 40. TEXTBOOK LEAD PARAGRAPH ============ */
.module-page-header .module-desc {
    font-family: var(--serif);
    font-size: 1.08rem;
    line-height: 1.6;
    color: var(--text);
    font-weight: 400;
}

body.light-theme .module-page-header .module-desc {
    color: #2b2723;
}

/* The drop-cap is too cute for technical material — keep prose plain */
.content-section > p:first-of-type::first-letter {
    initial-letter: 1;
}

/* ============ 41. MODULE CARD POLISH ============ */
.module-card {
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s ease;
}

.module-card h3 {
    font-size: 1.18rem;
    letter-spacing: -0.018em;
    color: var(--text);
}

.module-card .module-desc {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* ============ 42. KICKER on phase headers — the original .phase-number
   pill clashed with the new badge. Hide it (the badge already shows
   "Phase 1" semantically via the data-glyph + the phase title). */
.phase-header .phase-number {
    display: none;
}

/* ============ 43. PROPORTIONS PASS — based on visual review ============ */

/* Hero typography: tighten down so headline doesn't dominate at 1440. */
.hero-content h1 {
    font-size: clamp(2.2rem, 3.6vw, 3rem);
    line-height: 1.08;
    margin-bottom: 18px;
}

.hero-content .eyebrow {
    margin-bottom: 18px;
}

.hero-subtitle {
    font-size: 1.02rem;
    margin-bottom: 24px;
    max-width: 480px;
}

#hero {
    padding-top: 110px;
    padding-bottom: 60px;
    min-height: auto;
}

/* Bigger 3D model on desktop so it balances the text column */
@media (min-width: 1024px) {
    .hero-visual { flex: 0 0 480px; }
    .hero-visual model-viewer {
        width: 480px !important;
        height: 480px !important;
    }
}

/* ============ 44. NAVBAR DEDUPLICATION ============ */
/* Make Sign In + Review + Theme toggle visually consistent */

.signin-btn,
.theme-toggle-btn,
.review-toggle-btn {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 6px 12px;
    min-height: 28px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.signin-btn:hover,
.theme-toggle-btn:hover,
.review-toggle-btn:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--surface-2);
    transform: none;
}

/* Review toggle: dim by default unless ON */
.review-toggle-btn {
    color: var(--text-muted);
    background: var(--surface-1);
    border-color: var(--border);
}

.review-toggle-btn[aria-pressed="true"] {
    background: var(--accent);
    color: #fff8eb;
    border-color: var(--accent);
}

/* Sign In: subtle by default — primary CTA lives in the hero */
.signin-btn,
.signin-btn:link,
.signin-btn:visited {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

body.light-theme .signin-btn,
body.light-theme .signin-btn:link {
    color: var(--text);
    background: rgba(28, 18, 4, 0.04);
}

/* Hide the review toggle entirely unless we're explicitly in review mode
   (the script that injects it can override this by adding
   .review-mode-active to <body> when review=1). */
body:not(.review-mode):not(.review-mode-active) .review-toggle-btn {
    display: none;
}

/* ============ 45. MODULE PAGE: REMOVE REDUNDANT CHROME ============ */
/* The new module-rail at top already shows "Module N of 21" and the
   phase color. Drop the duplicate watermark "01" + tag chip in the
   page header — the H1 alone communicates the topic. */

.module-page-header > .module-header {
    display: none;
}

.module-page-header .back-link {
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.85;
}

.module-page-header h1 {
    margin-top: 4px;
    font-size: clamp(1.65rem, 2.6vw, 2.05rem);
    line-height: 1.15;
}

.module-page-header .module-page-meta {
    /* Pushed lower: small, restrained meta below the lead paragraph. */
    margin-top: 14px;
    font-size: 0.75rem;
    opacity: 0.85;
}

/* ============ 46. AUTHOR NOTE — slightly smaller, less heavy ============ */
.author-note {
    font-size: 0.92rem;
    padding: 12px 16px;
    margin: 18px 0 32px;
}

.author-note::before {
    font-size: 1.6rem;
    margin-top: 10px;
}

/* ============ 47. SECTION TITLES on the homepage ============ */
.section-title {
    text-align: left;
}

.section-subtitle {
    text-align: left;
    margin: 0 0 30px;
}

#modules .container > .section-title {
    margin-bottom: 4px;
    font-size: 1.6rem;
    letter-spacing: -0.02em;
}

/* ============ 48. PROGRESS BAR — quieter ============ */
#progress-bar {
    padding: 22px 0 24px;
}

.progress-header h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
}

#progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ============ 49. STATS TRACKER — quieter ============ */
#stats-tracker {
    padding: 28px 0 32px;
}

.stat-card-value {
    font-size: 1.05rem;
    font-weight: 800;
}

.stat-card-label {
    font-size: 0.62rem;
    letter-spacing: 0.10em;
}

/* ============ 50. NAVBAR — actually override the nav buttons ============ */
/* The Sign In button (auth.css .nav-auth-btn) was a solid orange block
   that competed with the hero CTA. Make it a quiet pill matching the
   theme/review toggles. */
.nav-links a.nav-auth-btn,
.nav-auth-btn {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 100px;
}

.nav-links a.nav-auth-btn:hover,
.nav-auth-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--accent);
    transform: none;
}

body.light-theme .nav-links a.nav-auth-btn,
body.light-theme .nav-auth-btn {
    background: rgba(28, 18, 4, 0.04);
    color: var(--text);
}

/* Theme + review toggle buttons: same shape, slightly different intent */
.theme-toggle-btn,
.review-toggle-btn {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 6px 12px !important;
    min-height: 28px !important;
    border-radius: 100px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface-1) !important;
    color: var(--text-muted) !important;
    transition: all 0.2s ease !important;
}

.theme-toggle-btn:hover,
.review-toggle-btn:hover {
    color: var(--text) !important;
    border-color: var(--text-muted) !important;
    background: var(--surface-2) !important;
    transform: none !important;
}

.review-toggle-btn[aria-pressed="true"] {
    background: var(--accent) !important;
    color: #fff8eb !important;
    border-color: var(--accent) !important;
}

body.light-theme .theme-toggle-btn,
body.light-theme .review-toggle-btn {
    background: rgba(28, 18, 4, 0.04) !important;
    color: var(--text) !important;
}

/* Hide review toggle entirely unless review mode is active */
body:not(.review-mode) .review-toggle-btn {
    display: none !important;
}

/* ============ 51. NAV LINKS — slightly more refined gap ============ */
.nav-links {
    gap: 24px;
    align-items: center;
}

.nav-links li {
    display: flex;
    align-items: center;
}

/* On scroll, the underline indicator looks heavy — soften */
.nav-links a.active::after {
    height: 1.5px;
    bottom: -6px;
    opacity: 0.7;
}

/* ============ 52. HIDE the legacy floating TOC ============ */
/* The inline .mini-toc (under learning objectives) replaces it. */
.module-toc { display: none !important; }

/* And undo the wide-screen container offset that left room for it */
@media (min-width: 1200px) {
    body[data-module] .module-page .container {
        max-width: 1100px;
        margin-right: auto;
    }
}

/* ============ 53. SITE FOOTER ============ */
footer {
    margin-top: 80px;
    padding: 56px 0 28px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, transparent, var(--surface-1));
}

.site-footer {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.site-footer-col {
    min-width: 0;
}

.site-footer-brand {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.018em;
}

.site-footer-tag {
    font-family: var(--serif);
    font-size: 0.92rem;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 32ch;
}

.site-footer-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 10px;
}

.site-footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.site-footer-col ul li {
    padding: 4px 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.site-footer-col ul li a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s, color 0.15s;
}

.site-footer-col ul li a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.site-footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 18px;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 12px;
}

.site-footer-keys kbd {
    display: inline-block;
    padding: 1px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 2px;
}

@media (max-width: 720px) {
    .site-footer { grid-template-columns: 1fr; gap: 24px; }
}

/* ============ 54. MODULE BOTTOM NAV — unified ============ */
/* Hide the static .module-nav-bottom prev/next pair — the up-next-card
   already handles forward nav with module title. We add a thin previous
   pill via CSS for symmetry. */

.module-nav-bottom {
    margin-top: 40px;
    padding-top: 0;
    border-top: none;
    align-items: stretch;
    gap: 14px;
}

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

.module-nav-bottom .btn {
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 12px 18px;
    font-weight: 600;
    border-radius: 10px;
    width: auto;
}

.module-nav-bottom .btn:hover {
    color: var(--text);
    border-color: var(--accent);
    background: var(--surface-2);
}

/* Up-Next card — make it the headline forward action */
.up-next-card {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px !important;
    padding: 18px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
    box-shadow: var(--shadow-sm);
}

.up-next-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.up-next-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 700;
}

.up-next-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
    letter-spacing: -0.01em;
}

.up-next-arrow {
    font-size: 1.4rem;
    color: var(--accent);
    transition: transform 0.2s var(--ease);
}

.up-next-card:hover .up-next-arrow {
    transform: translateX(4px);
}

/* ============ 55. KNOWLEDGE CHECK heading ============ */
.kc-header {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 18px;
}

/* ============ 56. SECTION COLLAPSE TOGGLE ============ */
/* The little ▼ that some content-section h2s sport is ugly — hide */
.content-section h2 .section-collapse-toggle,
.content-section h2 > span:last-child:where([style*="cursor"], [class*="toggle"]) {
    display: none;
}

/* If the toggle is added by some script as a sibling triangle */
.section-collapse-toggle { display: none !important; }

/* ============ 57. RIPPLES + MICRO-MOTION ============ */
.ripple {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple-grow 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 0;
}

body.light-theme .ripple {
    background: rgba(255, 255, 255, 0.55);
}

.btn-primary > * { position: relative; z-index: 1; }
.up-next-card > * { position: relative; z-index: 1; }

@keyframes ripple-grow {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

/* ============ 58. SECTION SCROLL-REVEAL ============ */
.diagram {
    /* Card-level reveal handled at the section/scroll level via CSS animations
       in section #64. SVG paths draw themselves (motion.js initSvgDraw) so
       we don't fade the wrapper. */
}

/* ============ 59. UP-NEXT CARD breathing ============ */
.up-next-card .up-next-arrow {
    animation: nudge 2.6s ease-in-out infinite;
}

@keyframes nudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(4px); }
}

.up-next-card:hover .up-next-arrow { animation: none; }

/* ============ 60. MODULE CARD HOVER LIFT ============ */
.modules-grid > .module-card-link .module-card {
    transition: transform 0.32s var(--ease-out-expo), box-shadow 0.32s var(--ease-out-expo), border-color 0.2s ease;
}

.modules-grid > .module-card-link:hover .module-card {
    transform: translateY(-4px);
}

/* Subtle accent line drawn from left on hover */
.module-card::before {
    width: 0;
    transition: width 0.4s var(--ease-out-expo), opacity 0.2s ease;
    height: 2px;
    border-radius: 2px;
    opacity: 0;
}

.module-card:hover::before { width: 100%; opacity: 1; }

/* ============ 61. NAV LINK underline draw ============ */
.nav-links a {
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0; right: auto;
    bottom: -6px;
    height: 1.5px;
    width: 0;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s var(--ease-out-expo);
    opacity: 0.85;
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* ============ 62. PHASE HEADER badge entrance ============ */
.phase-header::before {
    transition: transform 0.4s var(--ease-out-expo), background 0.3s ease;
}

.phase-header:hover::before {
    transform: translateY(-50%) scale(1.06) rotate(-3deg);
}

/* ============ 63. EYEBROW shimmer (subtle) ============ */
.hero-content .eyebrow {
    background-image: linear-gradient(90deg,
        var(--accent) 0%, var(--accent) 50%,
        color-mix(in srgb, var(--accent) 60%, var(--text)) 75%,
        var(--accent) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: eyebrow-shimmer 8s ease-in-out infinite;
}

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

/* ============ 64. STAGGER for content sections ============ */
.content-section {
    animation: section-in 0.55s var(--ease-out-expo) both;
}

@keyframes section-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.content-section:nth-of-type(1) { animation-delay: 0.05s; }
.content-section:nth-of-type(2) { animation-delay: 0.12s; }
.content-section:nth-of-type(3) { animation-delay: 0.18s; }
.content-section:nth-of-type(4) { animation-delay: 0.24s; }

/* ============ 65. KEY TAKEAWAYS arrow march ============ */
.key-takeaways li {
    transition: transform 0.2s ease;
}

.key-takeaways li:hover {
    transform: translateX(3px);
}

.key-takeaways li:hover::before {
    color: var(--green);
}

/* ============ 66. KNOWLEDGE-CHECK option fade ============ */
.kc-option {
    transition: transform 0.2s var(--ease), background 0.2s ease, border-color 0.2s ease;
}

.kc-option:hover:not(:disabled) {
    transform: translateX(2px);
}

/* ============ 67. SETTINGS / STATS card animation ============ */
.settings-stat {
    transition: transform 0.25s var(--ease-out-expo), background 0.25s ease;
}

.settings-stat:hover {
    transform: translateY(-2px);
    background: var(--surface-2);
}

/* ============ 68. REDUCED MOTION GUARD ============ */
@media (prefers-reduced-motion: reduce) {
    .ripple { animation: none; opacity: 0; }
    .up-next-card .up-next-arrow { animation: none; }
    .hero-content .eyebrow { animation: none; }
    .diagram { opacity: 1; transform: none; }
    .content-section { animation: none; }
}

/* ============ 69. KILL section collapse ============ */
/* The collapsible section feature was creating a triangle ▼ next to
   every h2 that competed with our typographic heading style. Mini-toc
   + rail already provide navigation, so we keep all sections expanded
   and hide the chevron entirely. */
.content-section .section-chevron { display: none !important; }
.content-section h2 { cursor: default !important; }
.section-body { max-height: none !important; opacity: 1 !important; overflow: visible !important; }
.section-collapsed .section-body { max-height: none !important; opacity: 1 !important; }

/* ============ 70. PHASE PROGRESS STRIP ============ */
.phase-progress {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    flex-shrink: 0;
}

.phase-progress-count b {
    color: var(--phase, var(--accent));
    font-weight: 700;
}

.phase-progress-count .sep {
    margin: 0 2px;
    opacity: 0.5;
}

.phase-progress-dots {
    display: inline-flex;
    gap: 3px;
}

.phase-progress-dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: background 0.25s ease;
}

.phase-progress-dots i.done {
    background: var(--phase, var(--accent));
    border-color: var(--phase, var(--accent));
}

@media (max-width: 600px) {
    .phase-progress {
        margin-left: 0;
        margin-top: 6px;
        align-self: flex-start;
    }
}

/* ============ 71. STATS TRACKER on homepage — better label hierarchy ============ */
#stats-tracker .stat-card {
    padding: 8px 4px;
}

#stats-tracker .stat-card-value {
    color: var(--text);
    font-size: 1.3rem;
}

#stats-tracker .stat-card-total,
#stats-tracker .stat-card-unit {
    font-size: 0.7rem;
    margin-left: 2px;
    color: var(--text-muted);
}

/* ============ 72. STUDY-TIME chip ============ */
/* The little floating "0:02" that appears top-right needs styling
   that fits the brand pill system. */
.study-time-chip,
.session-timer,
.module-study-time,
[class*="-timer"][class*="floating"] {
    background: var(--surface-1) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    border-radius: 100px !important;
    padding: 4px 10px !important;
    font-size: 0.7rem !important;
    font-variant-numeric: tabular-nums !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ============ 73. The little floating "Continue where you left off?"
   that some scripts inject — give it a real card style. */
.spaced-return,
.session-restore-banner {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-md) !important;
}

/* ============ 74. MOBILE RESPONSIVE — proper stacking ============ */
@media (max-width: 880px) {
    #hero {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
        gap: 32px;
        padding: 100px 20px 40px;
    }
    .hero-content { max-width: 100%; }
    .hero-content h1 { font-size: clamp(1.9rem, 8vw, 2.6rem); }
    .hero-subtitle { font-size: 0.96rem; max-width: 100%; }
    .hero-visual {
        order: -1;        /* show 3D first on mobile */
        align-self: center;
        flex: none !important;
    }
    .hero-visual model-viewer {
        width: 280px !important;
        height: 280px !important;
    }
}

@media (max-width: 720px) {
    /* Phase header layout: badge | title | desc — stack the desc line */
    .phase-header {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 14px 0 14px 50px;
        gap: 4px 12px;
    }
    .phase-header::before, .phase-header::after { width: 36px; height: 36px; }
    .phase-header .phase-title {
        font-size: 1.1rem;
        flex: 1 1 auto;
        min-width: 0;
        line-height: 1.25;
    }
    .phase-header .phase-desc {
        flex-basis: 100%;
        margin-left: 0;
        font-size: 0.85rem;
        margin-top: 4px;
    }
    .phase-progress {
        flex-basis: 100%;
        margin-top: 6px;
        margin-left: 0;
        align-self: flex-start;
    }
}

@media (max-width: 720px) {
    /* Module rail at the top of module pages — give it a hair more room */
    .module-rail-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .module-rail-dots {
        gap: 3px;
    }
    .module-rail-dot {
        height: 5px;
        border-radius: 2.5px;
    }
    .module-rail-dot.current {
        height: 7px;
        border-radius: 3.5px;
    }

    .mini-toc ol {
        grid-template-columns: 1fr;
    }

    .module-page-header h1 {
        font-size: 1.45rem;
    }
    .module-page-header .module-desc {
        font-size: 0.98rem;
    }

    /* Stats cards on homepage stack 2x2 */
    .stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
    .stat-card { justify-content: flex-start; }

    /* Diagrams + interactive demos: cap width and pad less */
    .diagram { padding: 16px 12px 12px; }
    .interactive-container .gear-demo,
    .interactive-container .extrude-demo,
    .interactive-container .linkage-demo,
    .interactive-container .dof-demo,
    .interactive-container .print-demo,
    .interactive-container .cam-demo,
    .interactive-container .parametric-demo,
    .interactive-container .tolerance-demo,
    .interactive-container .sweep-loft-demo,
    .interactive-container .section-demo {
        padding: 16px;
    }

    /* Up-Next + module-nav-bottom on mobile */
    .module-nav-bottom { flex-direction: column; gap: 10px; }
    .module-nav-bottom > div { width: 100%; }
    .module-nav-bottom .btn { width: 100%; text-align: center; }
}

/* ============ 75. NAVBAR: hamburger at narrow widths ============ */
@media (max-width: 720px) {
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
        padding: 8px 0;
        gap: 8px;
    }

    /* Toggle button is shown by styles.css — make sure it's a quiet pill */
    .nav-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: var(--surface-1);
        border: 1px solid var(--border);
        color: var(--text-muted);
        border-radius: 100px;
        padding: 6px 14px;
        font-size: 0.78rem;
        font-weight: 600;
        font-family: var(--font);
        cursor: pointer;
        order: 3;
        margin-left: auto;
    }

    .nav-toggle:hover {
        color: var(--text);
        border-color: var(--text-muted);
    }

    /* Hide nav-links by default on mobile, show when .open */
    .nav-links {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 8px 0 12px;
        order: 4;
    }

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

    .nav-links li { width: 100%; }

    .nav-links a {
        display: block;
        width: 100%;
        padding: 8px 4px;
    }

    .theme-toggle-btn,
    .review-toggle-btn,
    .nav-auth-btn,
    .nav-links a.nav-auth-btn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* ============ 76. SITE FOOTER mobile ============ */
@media (max-width: 720px) {
    footer { padding: 36px 0 24px; margin-top: 48px; }
    .site-footer { gap: 24px; padding-bottom: 24px; }
    .site-footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ============ 77. TINY VIEWPORTS (≤380px) ============ */
@media (max-width: 380px) {
    .container { padding: 0 16px; }
    .module-page-header { padding: 20px 0; }
    .hero-content h1 { font-size: 1.7rem; }
    .author-note { font-size: 0.88rem; padding: 10px 12px; }
    .author-note::before { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ============ 78. RESUME PROMPT — refined ============ */
.resume-prompt {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 900;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px 14px 18px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    max-width: 380px;
    animation: resume-in 0.4s var(--ease-out-expo) both;
}

.resume-prompt-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.resume-prompt-eyebrow {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 700;
}

.resume-prompt-text {
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.005em;
}

.resume-prompt-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.resume-prompt-actions .btn {
    font-size: 0.78rem;
    padding: 8px 14px;
}

@keyframes resume-in {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 600px) {
    .resume-prompt {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: none;
        grid-template-columns: 1fr;
        text-align: left;
    }
    .resume-prompt-actions { justify-content: flex-end; }
}

/* ============ 79. READING PROGRESS BAR ============ */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 1100;
    pointer-events: none;
    background: transparent;
}

.reading-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 0 2px 2px 0;
    transition: width 0.12s linear;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Hide while in focus mode + on print */
body.focus-mode .reading-progress { display: none; }
@media print { .reading-progress { display: none; } }

/* ============ 80. MINI-TOC scroll-spy ============ */
.mini-toc a {
    transition: color 0.15s ease, padding-left 0.2s var(--ease-out-expo);
    border-left: 2px solid transparent;
    padding-left: 22px;
    margin-left: -22px;
}

.mini-toc a.is-current {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
}

.mini-toc li.is-current::before,
.mini-toc a.is-current ~ ::before {
    color: var(--accent);
}

/* The number-prefix on the active item glows */
.mini-toc li:has(a.is-current)::before {
    color: var(--accent);
    font-weight: 700;
}

/* ============ 81. CMD+K PALETTE ============ */
.cmdk {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
    pointer-events: none;
}

.cmdk.is-open {
    display: flex;
    pointer-events: auto;
    animation: cmdk-overlay-in 0.18s ease both;
}

.cmdk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 23, 0.55);
    backdrop-filter: blur(6px) saturate(140%);
    -webkit-backdrop-filter: blur(6px) saturate(140%);
}

body.light-theme .cmdk-backdrop {
    background: rgba(40, 30, 12, 0.30);
}

.cmdk-panel {
    position: relative;
    width: min(580px, 92vw);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: cmdk-panel-in 0.2s var(--ease-out-expo) both;
}

.cmdk-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.cmdk-icon {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    width: 18px;
    text-align: center;
}

.cmdk-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    letter-spacing: -0.005em;
    padding: 4px 0;
}

.cmdk-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.cmdk-shortcut {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.cmdk-shortcut kbd,
.cmdk-foot kbd {
    display: inline-block;
    padding: 1px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.cmdk-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 50vh;
    overflow-y: auto;
}

.cmdk-item {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.1s ease;
}

.cmdk-item.is-active {
    background: var(--surface-2);
}

.cmdk-kind {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
    background: var(--surface-1);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 100px;
    text-align: center;
}

.cmdk-item.is-active .cmdk-kind {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    background: var(--accent-dim);
}

.cmdk-label {
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmdk-sub {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmdk-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--serif);
}

.cmdk-foot {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.cmdk-foot-right {
    margin-left: auto;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

@keyframes cmdk-overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmdk-panel-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 520px) {
    .cmdk { padding-top: 6vh; }
    .cmdk-item { grid-template-columns: 56px 1fr; }
    .cmdk-sub { display: none; }
}

/* ============ 82. NAV CMD+K hint pill ============ */
.nav-cmdk {
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 100px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: var(--font);
    margin-left: 16px;
}

.nav-cmdk:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--text-muted);
}

.nav-cmdk-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.nav-cmdk-keys {
    display: inline-flex;
    gap: 2px;
}

.nav-cmdk-keys kbd {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 4px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

@media (max-width: 720px) {
    .nav-cmdk { display: none; }
}

/* The trigger button needs to be clickable */
.nav-cmdk { pointer-events: auto; }

/* ============ 83. GLOSSARY: cross-reference chips ============ */
.glossary-refs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.glossary-refs-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
    margin-right: 4px;
}

.glossary-refs a {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 100px;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.glossary-refs a:hover {
    background: var(--accent);
    color: var(--bg-card);
    transform: translateY(-1px);
}

/* ============ 84. KNOWLEDGE CHECK SUMMARY + CELEBRATION ============ */
.kc-score {
    text-align: center;
    padding: 28px 24px 24px;
    margin-top: 18px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.kc-score.is-perfect {
    background: linear-gradient(180deg, var(--green-bg), transparent);
    border-color: color-mix(in srgb, var(--green) 35%, transparent);
}

.kc-score-number {
    display: block;
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.kc-score.is-perfect .kc-score-number { color: var(--green); }

.kc-score-text {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.kc-score-text strong {
    color: var(--green);
    margin-right: 4px;
}

.kc-retry {
    margin-top: 16px;
    padding: 10px 22px;
    background: var(--accent);
    color: #fff8eb;
    border: 1px solid color-mix(in srgb, var(--accent) 75%, #000);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.2s ease;
}

.kc-retry:hover { background: var(--accent-hover); }

/* The confetti burst */
.kc-celebrate {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.kc-celebrate span {
    position: absolute;
    left: 50%;
    top: 30%;
    width: 8px;
    height: 12px;
    background: var(--c);
    border-radius: 2px;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: confetti 1.6s var(--ease-out-expo) var(--d) forwards;
}

@keyframes confetti {
    0%   { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)); }
}

@media (prefers-reduced-motion: reduce) {
    .kc-celebrate { display: none; }
}
