/* PythonDesdeCero — one shared design system, 2026-10-01. */
:root {
  color-scheme: dark;
  --bg: #0b1220;
  --bg2: #101a2b;
  --surface: #152238;
  --surface2: #1c2e49;
  --text: #f3f7fc;
  --muted: #b2bfd1;
  --border: #304966;
  --border-strong: #6683a8;
  --blue: #76b8ff;
  --blue2: #a4d1ff;
  --action: #3b82f6;
  --blue-soft: #122b50;
  --yellow: #f9c74f;
  --green: #63d6a0;
  --red: #ff8793;
  --code: #07101c;
  --code2: #0d192a;
  --focus: #f9c74f;
  --shadow: 0 20px 64px rgb(0 0 0 / 24%);
  --radius: 18px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --container: 1160px;
  --reading: 70ch;
  --gutter: clamp(1.25rem, 3vw, 2rem);
  --header-height: 76px;
  --section-space: clamp(3.5rem, 6vw, 5.5rem);
  --card-space: clamp(1.25rem, 2.4vw, 1.75rem);
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem; --space-8: 4rem;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Foundations: readable text, visible focus, predictable layout. */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 24px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.7; overflow-wrap: break-word; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
::selection { background: var(--blue); color: var(--code); }
a { color: var(--blue); text-underline-offset: .22em; text-decoration-thickness: .08em; }
a:hover { color: var(--blue2); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
img, svg { max-width: 100%; }
img { height: auto; }
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
:where(h1, h2, h3, h4) { margin: 0 0 1rem; line-height: 1.22; text-wrap: balance; overflow-wrap: anywhere; }
h1, h2 { letter-spacing: -.03em; }
h1 { font-size: clamp(2.1rem, 4.2vw, 3.4rem); line-height: 1.13; max-width: 26ch; }
h2 { font-size: clamp(1.6rem, 2.8vw, 2.15rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
p, ul, ol, dl { margin: 0 0 1.25rem; }
ul, ol { padding-left: 1.5rem; }
li + li { margin-top: .5rem; }
strong, b { font-weight: 750; }
pre { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; tab-size: 4; }
code { font-family: var(--mono); }
:where(.prose, .lesson-content, .term-card, .card, .challenge) code:not(pre code) { font-size: .9em; overflow-wrap: anywhere; }
.lesson-content code:not(pre code), .prose code:not(pre code) { background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; padding: .08em .3em; }
.container, .narrow { width: min(calc(100% - var(--gutter) * 2), var(--container)); margin-inline: auto; }
.narrow { max-width: var(--reading); }
.section { padding-block: var(--section-space); }
.section-soft { background: var(--bg2); border-block: 1px solid var(--border); }
.muted { color: var(--muted); }
.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; transform: translateY(-180%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-weight: 700; }
.skip-link:focus { transform: none; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Identity and global navigation. */
.site-header { position: sticky; top: 0; z-index: 50; background: rgb(11 18 32 / 96%); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
html:not(.js) .site-header { position: static; }
.nav { position: relative; min-height: var(--header-height); display: flex; align-items: center; gap: 1.25rem; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; text-decoration: none; letter-spacing: -.025em; white-space: nowrap; }
.brand-mark { display: block; width: 40px; height: 40px; aspect-ratio: 1; flex: 0 0 auto; object-fit: contain; }
.brand-wordmark { display: inline-flex; align-items: baseline; line-height: 1.2; }
.site-header .brand { min-width: 0; }
.site-header .brand-wordmark { flex-wrap: wrap; white-space: normal; }
.brand-soft { color: var(--blue); font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.nav-links a { display: flex; align-items: center; min-height: 44px; padding: 9px 11px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 650; }
.nav-links a:hover { background: var(--surface); color: var(--text); }
.nav-links a[aria-current] { background: var(--blue-soft); color: var(--blue2); box-shadow: inset 0 -2px var(--blue); }
.nav-actions { display: none; }
.icon-btn, .menu-btn { min-height: 44px; min-width: 44px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 700; }
.menu-btn { display: inline-flex; align-items: center; gap: 8px; }
.menu-btn::before { content: ""; width: 14px; height: 10px; border-block: 2px solid currentColor; }
.menu-btn[aria-expanded="true"] { background: var(--blue-soft); border-color: var(--blue); }
.menu-btn[aria-expanded="true"]::before { height: 2px; border-bottom: 0; }

/* Page hierarchy and shared spacing. */
.eyebrow, .mini-label { display: block; color: var(--blue); font-size: .8rem; line-height: 1.55; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .75rem; }
.mini-label { font-size: .77rem; margin-bottom: .5rem; }
.lead { color: var(--muted); font-size: clamp(1.1rem, 1.6vw, 1.25rem); line-height: 1.7; max-width: 62ch; }
.page-hero { padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(2rem, 4vw, 3rem); background: linear-gradient(180deg, var(--bg2), var(--bg)); border-bottom: 1px solid var(--border); }
.page-hero .lead { margin-bottom: 0; }
.page-hero .actions, .page-hero .lesson-meta { margin-top: 1.5rem; }
.breadcrumbs { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; overflow-wrap: anywhere; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--blue); }
.section-head { display: grid; grid-template-columns: 1.1fr 1fr; align-items: end; gap: 3rem; margin-bottom: 2.25rem; }
.section-head h2 { margin-bottom: 0; max-width: 26ch; }
.section-head p { max-width: 50ch; margin: 0; color: var(--muted); }
.grid-2, .grid-3, .grid-4, .split { display: grid; gap: 1.5rem; }
.grid-2, .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { gap: clamp(2rem, 5vw, 4rem); align-items: start; }
:where(.hero-grid, .split, .section-head, .course-shell, .grid-2, .grid-3, .grid-4, .practice-intro) > * { min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.75rem; }
.btn, .run-btn, .complete-btn, .practice-reset { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; padding: 11px 18px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; line-height: 1.45; text-decoration: none; transition: background .16s, border-color .16s, box-shadow .16s; }
.btn { min-width: 0; max-width: 100%; text-align: center; white-space: normal; }
.btn-primary, .run-btn, .input-lab button { background: var(--action); color: var(--code); box-shadow: 0 6px 20px rgb(59 130 246 / 15%); }
.btn-primary:hover, .run-btn:hover, .input-lab button:hover { background: var(--blue); color: var(--code); }
.btn-secondary, .complete-btn, .practice-reset { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover, .complete-btn:hover, .practice-reset:hover { background: var(--surface2); color: var(--text); border-color: var(--blue); }
.card, .route-card, .lesson-card, .tool-card, .error-card, .term-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--card-space); box-shadow: 0 1px 0 rgb(255 255 255 / 2%); }
:where(.card, .route-card, .tool-card, .error-card, .challenge) h2 { font-size: 1.4rem; }
:where(.card, .route-card, .tool-card) h3 { font-size: 1.15rem; }
:where(.card, .route-card, .lesson-card, .tool-card, .error-card) p { color: var(--muted); }
:where(.card, .route-card, .tool-card, .error-card, .lesson-note, .prediction, .mistake, .callout, .recall-box, .activity-card) > :last-child { margin-bottom: 0; }
.card-icon, .module-num { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-weight: 800; margin-bottom: 1.25rem; }
.route-card, .error-card { display: flex; flex-direction: column; align-items: flex-start; color: var(--text); text-decoration: none; transition: border-color .16s, background .16s; }
.route-card:hover, .lesson-card:hover, .error-card:hover { border-color: var(--blue); background: var(--surface2); color: var(--text); }
.route-card-primary { border-color: #44628b; background: linear-gradient(140deg, var(--blue-soft), var(--surface)); }
.route-card .route-action { margin-top: auto; padding-top: .5rem; color: var(--blue); font-weight: 750; }
.error-card { gap: .75rem; }
.error-card strong { color: var(--blue); font-size: 1.06rem; overflow-wrap: anywhere; }
.error-card span { color: var(--muted); }
.error-card::after { content: "Ver guía →"; color: var(--blue); font-size: .9rem; font-weight: 700; margin-top: auto; padding-top: .5rem; }
.check-list { list-style: none; padding: 0; }
.check-list li { position: relative; padding-left: 28px; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 800; }
.feature { padding: 1.75rem 0 .5rem; border-top: 1px solid var(--border); }
.feature-number { display: block; color: var(--blue); font-weight: 800; margin-bottom: .75rem; }
.feature p { color: var(--muted); }

/* Homepage: a clear starting point and a quiet, recognisable terminal. */
.hero { padding: clamp(3rem, 6vw, 5.5rem) 0 clamp(3rem, 5vw, 4.5rem); background: radial-gradient(ellipse at 90% 35%, rgb(59 130 246 / 8%), transparent 55%); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(2rem, 5vw, 4rem); }
.hero h1 { font-size: clamp(2.65rem, 4.8vw, 4.3rem); line-height: 1.1; max-width: 14ch; margin-bottom: 1.5rem; }
.hero h1 em { color: var(--blue); font-style: normal; }
.hero-reassurance { color: var(--muted); font-size: .9rem; margin: 1rem 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 2rem; }
.stat { border-top: 1px solid var(--border-strong); padding: 1rem 0 0; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.3; margin-bottom: .25rem; }
.stat span { color: var(--muted); font-size: .9rem; }
.python-window { min-width: 0; background: var(--code); border: 1px solid #35547b; border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.window-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 20px; background: var(--code2); color: var(--muted); font-size: .85rem; }
.dots { display: flex; gap: 7px; flex: 0 0 auto; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.dots i:nth-child(2) { background: var(--yellow); }
.dots i:nth-child(3) { background: var(--green); }
.code { margin: 0; padding: 28px 24px; color: var(--text); font: 15px/1.85 var(--mono); }
.code .kw { color: var(--yellow); }
.code .str { color: #86e0ac; }
.code .fn { color: var(--blue); }
.result { border-top: 1px solid var(--border); padding: 18px 24px; color: #9ee5bb; font: 14px/1.7 var(--mono); }

/* Reading and learning navigation. */
.prose, .lesson-content { font-size: 1.0625rem; line-height: 1.75; overflow-wrap: break-word; }
.prose { max-width: var(--reading); }
.prose > h2:not(:first-child) { margin-top: 3.25rem; }
.prose > h3:not(:first-child) { margin-top: 2rem; }
.prose > :where(.grid-2, .grid-3, .callout, .table-scroll) { margin-block: 1.75rem; }
.prose > p + p, .lesson-note > p + p { margin-top: 1rem; }
.lesson-meta, .exercise-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0 0; }
.pill, .badge { display: inline-flex; align-items: center; border: 1px solid var(--border); background: var(--surface2); border-radius: 999px; padding: 5px 11px; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.course-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(2rem, 4vw, 3.5rem); padding-block: 3rem var(--section-space); }
.course-sidebar { position: sticky; top: calc(var(--header-height) + 24px); align-self: start; max-height: calc(100dvh - var(--header-height) - 48px); overflow-y: auto; scrollbar-gutter: stable; scrollbar-width: thin; padding: 0 12px 12px 0; }
.course-sidebar h2 { font-size: 1.05rem; margin-bottom: 1rem; }
.course-sidebar a, .course-index-panel a { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: .9rem; line-height: 1.5; }
.course-sidebar a:hover, .course-index-panel a:hover { color: var(--text); background: var(--surface); }
.course-sidebar a.current, .course-index-panel a.current { color: var(--blue2); background: var(--blue-soft); box-shadow: inset 3px 0 var(--blue); font-weight: 700; }
.course-sidebar a.is-done::after, .course-index-panel a.is-done::after { content: "✓"; margin-left: auto; flex-shrink: 0; color: var(--green); font-size: 1rem; font-weight: 800; }
.course-index-mobile { display: none; }
.lesson-content { max-width: 72ch; min-width: 0; }
.lesson-content > section { padding-block: 2.75rem; border-bottom: 1px solid var(--border); }
.lesson-content > .lesson-start { padding-top: 0; }
.lesson-content > section > h2 { font-size: clamp(1.5rem, 2.2vw, 1.9rem); margin-bottom: 1.25rem; }
.lesson-content > section > h3 { margin-top: 2rem; }
.lesson-content .complete-btn { width: 100%; margin-top: 2rem; }
.complete-btn.done { background: var(--green); border-color: var(--green); color: var(--code); }
.complete-btn.done:hover { background: #9be6bc; }
.lesson-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 2rem; }
.lesson-nav a { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 90px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none; }
.lesson-nav a:last-child { text-align: right; }
.lesson-nav a:hover { border-color: var(--blue); background: var(--surface); }
.lesson-nav-kicker { color: var(--muted); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.lesson-nav-title { font-weight: 650; line-height: 1.5; }
.module { margin-top: 3.5rem; }
.module-head { display: flex; align-items: center; gap: 16px; margin-bottom: 1.5rem; }
.module-num { margin-bottom: 0; }
.module-head h2 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); margin: 0; }
.module-head .eyebrow { margin-bottom: .3rem; }
.lesson-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lesson-card { display: flex; align-items: flex-start; gap: 16px; padding: 20px; color: var(--text); text-decoration: none; }
.lesson-card h3 { font-size: 1.1rem; line-height: 1.4; margin-bottom: .4rem; }
.lesson-card small { display: block; color: var(--muted); margin-top: .5rem; font-size: .9rem; }
.lesson-index { min-width: 28px; color: var(--blue); font-weight: 800; }
.lesson-card.is-done { border-color: #467963; }
.lesson-card.is-done .lesson-index { color: var(--green); }
.lesson-card.is-done .lesson-index::after { content: " ✓"; }
.progress-wrap { height: 10px; border-radius: 999px; overflow: hidden; background: var(--code2); border: 1px solid var(--border-strong); }
.progress-bar { height: 100%; width: 0; background: var(--blue); border-radius: inherit; }
.progress-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .95rem; margin-top: 1rem; }
.course-progress-card { padding: var(--card-space); }
.course-progress-card h2 { margin-bottom: 1.5rem; }
.course-progress-card .progress-row { margin-top: 1.5rem; }
.course-facts .card { height: 100%; }
.jump-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.5rem 0 0; }
.jump-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 650; }
.jump-links a:hover { border-color: var(--blue); color: var(--text); }
.page-course #modulos { margin: 0 0 2rem; }
.related-links { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.related-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 650; max-width: 100%; }
.related-links a:hover { border-color: var(--blue); }
.related-links-label { flex-basis: 100%; color: var(--muted); font-size: .9rem; font-weight: 700; padding-top: .5rem; }
.seo-related { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* Educational notes, diagrams and disclosure controls. */
.lesson-note, .prediction, .mistake, .callout, .legal-checklist, .recall-box { border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; background: var(--surface); }
.lesson-note, .prediction { background: var(--surface2); }
.mistake { border-left: 3px solid var(--yellow); }
.callout { margin-block: 1.75rem; background: var(--blue-soft); }
.callout strong:first-child { display: block; margin-bottom: .5rem; }
.callout-warning { background: #302a1c; border-color: #79663b; }
.callout-success { background: #152c2b; border-color: #406d5c; }
.legal-note { margin-bottom: 2rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--yellow); border-radius: 14px; }
.learning-evidence { margin-top: 1.25rem; padding: 1.25rem; border-left: 3px solid var(--green); background: #142e2e; border-radius: 0 10px 10px 0; }
.learning-evidence p { margin: 0; }
.step-list { counter-reset: steps; list-style: none; padding: 0; margin-block: 1.5rem; }
.step-list > li { counter-increment: steps; position: relative; min-height: 44px; padding: 0 0 1.25rem 56px; }
.step-list > li::before { content: counter(steps); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.step-list > li + li { padding-top: 1.25rem; border-top: 1px solid var(--border); }
.step-list > li + li::before { top: 1.25rem; }
.compare-grid, .activity-grid, .error-anatomy, .relation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-block: 1.5rem; }
.activity-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.activity-card, .transfer-box, .interpretation-box, .project-done, .type-diagnostic, .trace-box, .decision-box { border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; background: var(--surface); margin-block: 1.5rem; min-width: 0; }
.activity-card { margin: 0; }
.activity-card h3 { font-size: 1.1rem; }
.recall-section { background: #20273a; padding-inline: 1.5rem; border-radius: 16px; }
.recall-box { border-color: #79663b; }
.project-done { border-color: #406d5c; }
.concept-flow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-block: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; }
.concept-flow span { background: var(--blue-soft); border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; font-weight: 700; }
.concept-flow b { color: var(--blue); }
.trace-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-block: 1.5rem; }
.trace-strip span { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); text-align: center; }
.scope-frames, .file-pair, .path-map, .regex-build, .choice-briefs, .contract-card, .mode-cards, .progression, .resource-cycle, .generator-timeline, .api-layers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-block: 1.5rem; }
.contract-card, .mode-cards, .progression { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.resource-cycle, .generator-timeline, .api-layers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
:where(.scope-frames, .file-pair, .path-map, .regex-build, .choice-briefs, .contract-card, .mode-cards, .progression, .resource-cycle, .generator-timeline, .api-layers) > div { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 18px; background: var(--surface); }
:where(.contract-card, .mode-cards, .progression, .resource-cycle, .generator-timeline, .api-layers, .regex-build) span { display: block; color: var(--muted); margin-top: .5rem; }
.scope-frames code { display: block; margin-block: .5rem; }
.path-map ul { margin: 0; }
.regex-build code, .mode-cards code { font-size: 1.15rem; font-weight: 700; }
.regex-build mark { background: var(--yellow); color: var(--code); padding: 2px 4px; border-radius: 3px; }
.decision-tree, .diagnostic-tree { display: grid; gap: 12px; justify-items: center; text-align: center; margin-block: 1.5rem; }
.decision-tree > div, .diagnostic-tree > div { width: 100%; max-width: 420px; background: var(--surface2); border: 1px solid var(--border); padding: 16px; border-radius: 12px; }
.slice-visual { display: grid; grid-template-columns: repeat(13, auto); align-items: end; justify-content: start; gap: 0; overflow: auto; margin-block: 1.5rem; padding-bottom: 10px; }
.slice-visual span { font-size: .8rem; color: var(--blue); text-align: center; min-width: 18px; padding-top: 5px; border-left: 2px solid var(--blue); }
.slice-visual b { font: 700 1.15rem var(--mono); background: var(--surface2); padding: 8px 12px; border-block: 1px solid var(--border); }
.slice-visual .slice-selected { color: var(--blue2); background: var(--blue-soft); border-color: var(--blue); box-shadow: inset 0 -3px var(--blue); }
.slice-caption { color: var(--muted); font-size: .95rem; }
.parsons { display: grid; gap: 12px; margin-block: 1.5rem; }
.parsons > div { display: flex; justify-content: space-between; gap: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); padding: 14px; }
.parsons span { color: var(--muted); font-size: .95rem; }
.debug-steps { counter-reset: debug; list-style: none; padding: 0; }
.debug-steps li { counter-increment: debug; border-left: 3px solid var(--blue); padding: 12px 0 12px 18px; margin-block: 12px; }
.debug-steps li::before { content: counter(debug) ". "; color: var(--blue); font-weight: 800; }
.check-question { font-weight: 750; margin-bottom: .5rem; }
.diagnostic-list li { margin-bottom: .75rem; }
details { min-width: 0; }
summary { position: relative; display: block; min-height: 44px; padding: .5rem 2rem .5rem 0; cursor: pointer; font-weight: 700; line-height: 1.55; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; top: .5rem; right: var(--summary-marker-inset, 0); display: grid; place-items: center; width: 18px; height: 28px; font-size: 1.4rem; line-height: 1; font-weight: 500; text-align: center; color: var(--blue); }
details[open] > summary::after { content: "−"; }
details.answer, details.hints { margin-block: 1.25rem; padding: .25rem 0 .25rem 1rem; border-left: 2px solid var(--blue); }
details.answer summary, details.hints summary { color: var(--blue); }
details.answer p, details.hints ul { margin-block: 1rem .5rem; }
details.hint, details.faq-item, .optional-note { border: 1px solid var(--border); border-radius: 14px; padding: 12px 18px; margin-block: 1rem; background: var(--surface); }
details[open] > summary { margin-bottom: 1rem; }
:where(details.hint, details.faq-item, .optional-note) > :last-child { margin-bottom: 0; }
.optional-note { border-style: dashed; background: var(--surface2); }
.optional-note summary { color: var(--blue); }
.related-error-note { margin-block: 1.5rem 0; padding: 1.25rem; border-left: 3px solid var(--blue); background: var(--surface); border-radius: 0 12px 12px 0; color: var(--muted); }
.related-error-note strong { color: var(--text); }

/* Code, forms and dynamic feedback. */
.code-block { overflow: hidden; margin-block: 1.5rem; border: 1px solid var(--border); border-radius: 14px; background: var(--code); }
.code-block .bar, .code-block .code-head { padding: 11px 18px; background: var(--code2); color: var(--muted); font-size: .85rem; line-height: 1.6; }
.code-block pre { margin: 0; padding: 22px; color: var(--text); font: 15px/1.75 var(--mono); }
.mini-code, .terminal-block, .type-diagnostic pre, .trace-box pre { margin-block: 1rem; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--code); color: var(--text); font: 14px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal-block { white-space: pre; }
.trace-box pre { margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.practice-box { padding: var(--card-space); border: 1px solid #44628b; border-radius: 18px; background: var(--blue-soft); margin-block: 2rem; }
.practice-box + .practice-box { margin-top: 2rem; }
.route-label { display: block; margin-top: .35rem; color: var(--muted); font-size: .85rem; }
.editor-actions, .reflection-controls, .order-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.editor-reset, .order-controls button { min-height: 44px; min-width: 44px; padding: .65rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.editor-reset:hover, .order-controls button:hover { background: var(--surface2); }
.editor-toolbar { gap: .75rem; flex-wrap: wrap; }
.progressive-hints { margin-block: 1.5rem; }
.activity-checks { margin-block: 1.25rem; }
.test-results { margin: 0; padding: 0; list-style: none; font-size: .9rem; line-height: 1.6; }
.test-results:not(:empty) { padding: 1.25rem; border-top: 1px solid var(--border); }
.test-results li + li { margin-top: .75rem; }
.reflection { margin-block: 1.5rem; }
.reflection label { display: block; margin-bottom: .75rem; font-weight: 600; }
.reflection input { min-height: 48px; min-width: 0; width: 100%; flex: 1 1 180px; border: 1px solid var(--border); border-radius: 8px; padding: .75rem; color: var(--text); background: var(--surface); font: inherit; }
.order-activity ol { padding-left: 1.75rem; }
.order-activity li { padding-block: 1rem; }
.order-controls { margin-top: .75rem; }
.order-controls button:disabled { opacity: .6; cursor: default; }
.order-activity [data-order-status]:not(:empty) { margin: 1.25rem 0 0; }
.route-next { margin-top: 2rem; }
.route-next .btn { white-space: normal; }
.js .order-activity { display: block; }
html:not(.js) .order-activity, html:not(.js) .reflection { display: none; }
@media (max-width: 480px) { .reflection-controls .btn { width: 100%; } .editor-actions { width: 100%; } .editor-actions button { flex: 1 1 100px; } }
.practice-goal { border: 1px dashed var(--border-strong); background: var(--surface); border-radius: 12px; margin-block: 1.25rem; padding: 16px; }
.practice-goal pre { margin: 0; white-space: pre-wrap; font: 14px/1.7 var(--mono); }
.editor { min-width: 0; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--code); overflow: hidden; }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 16px; background: var(--surface2); border-bottom: 1px solid var(--border); }
.editor-toolbar > span { color: var(--muted); font-size: .9rem; font-family: var(--mono); overflow-wrap: anywhere; }
.editor-toolbar > div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.editor-toolbar :where(.btn, .run-btn) { min-height: 44px; padding: 9px 14px; border-radius: 9px; font-size: .95rem; }
.run-btn { white-space: nowrap; }
.editor textarea { display: block; width: 100%; min-height: 200px; margin: 0; border: 0; resize: vertical; background: var(--code); color: var(--text); padding: 20px; font: 16px/1.75 var(--mono); tab-size: 4; }
.editor textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: -4px; }
.editor-help { margin: 0; padding: 12px 18px; background: var(--code2); color: var(--muted); font-size: .85rem; line-height: 1.6; border-top: 1px solid var(--border); }
.output-label { display: block; padding: 10px 18px 0; background: var(--code2); color: var(--muted); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; font-weight: 700; border-top: 1px solid var(--border); }
.output { min-height: 88px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 12px 18px 18px; background: var(--code2); color: #9ee5bb; font: 14px/1.75 var(--mono); }
.run-btn.is-running { background: var(--red); color: var(--code); }
.engine-status { display: none; gap: 10px; align-items: flex-start; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--code2); color: var(--muted); font-size: .9rem; }
.engine-status:not(:empty) { display: flex; }
.engine-status.is-loading::before { content: ""; flex: 0 0 14px; width: 14px; height: 14px; margin-top: 5px; border: 2px solid var(--border-strong); border-top-color: var(--blue); border-radius: 50%; animation: pdc-spin .75s linear infinite; }
.engine-status.is-ready { color: var(--green); }
.engine-status.is-error { color: var(--red); }
@keyframes pdc-spin { to { transform: rotate(360deg); } }
.status { margin: 1rem 0 0; padding: 14px 16px; border-radius: 12px; font-weight: 650; line-height: 1.6; }
.status:empty { display: none; }
.status.ok { color: var(--green); background: #142e2e; }
.status.bad { color: var(--red); background: #302331; }
.progress-save-note { margin: .75rem 0 0; color: var(--muted); font-size: .95rem; }
.progress-save-note:empty { display: none; }
.progress-save-note.is-error { color: var(--red); }
.search, .input-lab input, select { width: 100%; min-height: 48px; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 1rem; }
.search::placeholder, .input-lab input::placeholder { color: var(--muted); opacity: 1; }
.input-lab { padding: 1.5rem; margin-block: 1.5rem; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); }
.input-row { display: flex; gap: 12px; margin-block: 1rem; }
.input-row input { flex: 1; min-width: 0; }
.input-lab button { min-height: 48px; padding: 10px 16px; border: 0; border-radius: 10px; font-weight: 750; }
.input-lab pre { margin: 1rem 0 0; padding: 18px; border-radius: 12px; background: var(--code); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.75 var(--mono); }
.expected { font: .9em var(--mono); background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 5px; }
.table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; margin-block: 1.75rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); scrollbar-width: thin; }
:where(.table-scroll table, .data-table, .trace-table, .rubric-table) { width: 100%; border-collapse: collapse; margin: 0; }
.table-scroll table { min-width: 480px; }
.table-scroll .rubric-table { min-width: 640px; }
:where(.table-scroll table, .data-table, .trace-table, .rubric-table) caption { padding: 18px; border-bottom: 1px solid var(--border); background: var(--code2); color: var(--text); text-align: left; font-size: 1rem; font-weight: 700; line-height: 1.55; }
:where(.table-scroll table, .data-table, .trace-table, .rubric-table) :where(th, td) { padding: 15px 18px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
:where(.table-scroll table, .data-table, .trace-table, .rubric-table) th { background: var(--surface2); font-size: .95rem; }
:where(.table-scroll table, .data-table, .trace-table, .rubric-table) tr:last-child td { border-bottom: 0; }

/* Lesson rhythm applies to nested content as well as top-level sections.
 * Margins collapse in the reading flow; grid gaps and editor panels keep
 * their own spacing so connected controls remain one coherent component.
 */
.lesson-content :where(.lesson-note, .prediction, .mistake, .learning-evidence, .recall-box) { margin-block: 1.5rem; }
.lesson-content .lesson-start > .lesson-note:first-child { margin-top: 0; }
.lesson-content section > :where(details, .card) { margin-block: 1.5rem; }
.lesson-content section > section { margin-block: 2rem; }
.lesson-content section > h2:not(:first-child) { margin-top: 2.5rem; }
.lesson-content .scope-frames code { margin-block: 1rem; }
.lesson-content :where(.choice-briefs, .activity-grid) > div > strong:first-child { display: block; margin-bottom: .75rem; }
.lesson-content :where(.lesson-note, .prediction, .mistake, .learning-evidence, .practice-box, .transfer-box, .interpretation-box, .project-done, .type-diagnostic, .decision-box, .recall-box, .activity-card) > :last-child { margin-bottom: 0; }
.lesson-content > section > :last-child { margin-bottom: 0; }
.lesson-content > .lesson-end { margin-top: 1.5rem; }
.lesson-content .lesson-end .complete-btn { margin-top: 0; }
.lesson-content .essential-next { margin-top: 1.5rem; }
.lesson-content details[open] > :last-child:not(summary) { margin-bottom: 0; }
.reflection > [data-reflection-status]:empty, .order-activity [data-order-status]:empty { display: none; }
.reflection > [data-reflection-status]:not(:empty) { margin: 1rem 0 0; }

/* Practice and reference pages. */
.practice-intro { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
.practice-progress-card { margin-top: 2rem; padding: var(--card-space); border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); }
.practice-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 1.5rem; }
.practice-progress-head strong { display: block; font-size: 1.15rem; margin-bottom: .3rem; }
.practice-progress-card p { margin: 1rem 0 0; color: var(--muted); font-size: .95rem; }
.practice-jump-shell { border-bottom: 1px solid var(--border); background: var(--bg2); }
.practice-jump-shell .jump-links { margin: 0; padding-block: 16px; }
.page-practice .challenge { margin: 0 0 2.75rem; padding: var(--card-space); }
.exercise-heading-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: .5rem; }
.exercise-heading-row .eyebrow { margin: 0; }
.exercise-solved-badge { color: var(--green); background: #142e2e; border: 1px solid #406d5c; border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-weight: 750; }
.challenge.is-solved { border-color: #467963; }
.exercise-meta { margin-block: 1rem 1.5rem; }
.prereq-link { display: inline-flex; align-items: center; min-height: 44px; }
.page-practice details.hint { background: var(--surface2); }
.page-practice details.hint summary { color: var(--blue); }
.hint-level-2 { border-style: dashed !important; }
.solution-nudge { color: var(--muted); border-left: 3px solid var(--yellow); padding: 1rem; background: var(--code2); border-radius: 0 10px 10px 0; margin-block: 1rem; }
.exercise-solution { margin-top: 1.25rem; border: 1px solid #79663b; border-radius: 14px; background: #262a31; overflow: hidden; }
.exercise-solution > summary { --summary-marker-inset: 18px; padding: 14px 50px 14px 18px; color: var(--yellow); }
.exercise-solution > summary::after { top: 14px; }
.exercise-solution[open] > summary { margin: 0; border-bottom: 1px solid var(--border); }
.solution-content { padding: 1.5rem; }
.solution-content pre { margin-block: 1rem 1.5rem; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--code); color: var(--text); font: 15px/1.75 var(--mono); }
.solution-content h3 { margin: 1.5rem 0 .75rem; font-size: 1.1rem; }
.solution-content > :last-child { margin-bottom: 0; }
.practice-group-next { display: flex; justify-content: flex-end; margin: -.75rem 0 2.75rem; }
.practice-group-next a { display: inline-flex; align-items: center; min-height: 48px; padding: 10px 16px; border: 1px solid var(--border-strong); border-radius: 10px; color: var(--blue); text-decoration: none; }
.practice-editorial-guide { margin-top: 4rem; padding-top: 3rem; border-top: 1px solid var(--border); }
.page-editor .editor { max-width: 960px; margin-inline: auto; }
.page-editor .editor textarea { min-height: 340px; }
.page-editor .output { min-height: 104px; }
.page-editor .jump-links { justify-content: center; }
.search-label { display: block; font-weight: 750; margin-bottom: .75rem; }
.search-results { margin: .75rem 0 0; color: var(--muted); font-size: .95rem; }
.search-empty { padding: 2rem; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--surface); margin-top: 1.5rem; }
.search-empty p:last-child { margin-bottom: 0; }
.glossary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 2rem; }
.term-card { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.term-card dt { font-size: 1.15rem; font-weight: 750; line-height: 1.4; margin-bottom: .75rem; }
.term-card dd { margin: 0; color: var(--muted); }
.term-card dd small { display: block; margin-top: .75rem; }
.term-related { display: block; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.term-related a { display: inline-flex; align-items: center; min-height: 44px; font-size: .9rem; font-weight: 650; }
.term-card:target { outline: 3px solid var(--focus); outline-offset: 4px; }
.page-glossary .callout { margin-top: 2.5rem; }
.page-faq details { margin-block: 1rem; }
.page-errors-hub .section > .container { max-width: 1100px; }
.concept-pair { border-top: 1px solid var(--border); padding-block: 1.5rem; }
.privacy-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 20px; border: 1px solid var(--border); border-radius: 14px; margin-block: 1rem; }
.toggle { position: relative; display: inline-block; width: 48px; height: 44px; }
.toggle input { opacity: 0; width: 48px; height: 44px; margin: 0; }
.toggle span { position: absolute; inset: 8px 0; border-radius: 99px; background: var(--border-strong); pointer-events: none; }
.toggle span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: var(--text); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::before { transform: translateX(20px); background: var(--code); }
.toggle input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 4px; }

/* Footer: generous targets without expanding into an endless mobile list. */
.footer { border-top: 1px solid var(--border); background: var(--bg2); padding: 4rem 0 1.75rem; }
.footer-grid { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr)); gap: 2rem; }
.footer h3 { font-size: 1rem; margin-bottom: 1rem; }
.footer p { color: var(--muted); margin-top: 1rem; overflow-wrap: anywhere; }
.footer a { display: flex; align-items: center; width: fit-content; max-width: 100%; min-height: 44px; padding-block: 8px; color: var(--muted); text-decoration: none; font-size: .95rem; line-height: 1.5; }
.footer a:hover { color: var(--blue); text-decoration: underline; }
.footer .brand { display: inline-flex; color: var(--text); font-size: 1rem; }
.footer .brand-wordmark { flex-wrap: wrap; white-space: normal; }
.footer-bottom { display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--border); margin-top: 2.5rem; padding-top: 1.5rem; color: var(--muted); font-size: .9rem; }
.mt-5 { margin-top: 20px !important; } .mt-7 { margin-top: 28px !important; } .mt-8 { margin-top: 32px !important; } .mt-9 { margin-top: 36px !important; } .mt-10 { margin-top: 40px !important; }

/* Tablet, mobile and zoom: breakpoints follow available reading space. */
@media (max-width: 1024px) {
  :root { --header-height: 68px; }
  .nav { flex-wrap: wrap; padding-block: 12px; }
  .nav-links { width: 100%; margin: 0; flex-wrap: wrap; order: 3; }
  .js .nav { flex-wrap: nowrap; padding-block: 0; justify-content: space-between; }
  .js .nav-actions { display: flex; flex: 0 0 auto; }
  .js .nav-links { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; flex-direction: column; align-items: stretch; flex-wrap: nowrap; padding: 12px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); max-height: calc(100dvh - var(--header-height) - 24px); overflow-y: auto; }
  .js .nav-links.open { display: flex; }
  .nav-links a { font-size: 1rem; padding: 12px 16px; }
  .hero-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .hero h1 { font-size: clamp(2.4rem, 4.8vw, 3.5rem); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-shell { display: block; }
  .course-sidebar { display: none; }
  .course-index-mobile { display: block; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; margin-bottom: 2rem; padding: 12px 16px; }
  .course-index-mobile > summary { color: var(--text); }
  .course-index-panel { max-height: 55dvh; overflow: auto; padding: 4px; scrollbar-width: thin; }
  .course-index-panel nav { display: grid; gap: 4px; }
  .lesson-content { max-width: 72ch; margin-inline: auto; }
  .footer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; }
  .footer-grid > div:first-child { grid-column: 1 / -1; max-width: 55ch; }
  .resource-cycle, .generator-timeline, .api-layers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .hero-grid, .split, .practice-intro, .section-head { grid-template-columns: 1fr; }
  .hero-grid { gap: 2.5rem; }
  .hero h1 { max-width: 19ch; font-size: clamp(2.5rem, 6.2vw, 3.7rem); }
  .hero .python-window { max-width: 600px; width: 100%; }
  .hero .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .section-head { gap: 1rem; margin-bottom: 2rem; }
  .section-head h2 { max-width: 30ch; }
  .grid-3, .glossary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .activity-grid, .compare-grid, .error-anatomy, .relation-grid, .trace-strip, .scope-frames, .file-pair, .path-map, .regex-build, .choice-briefs, .contract-card, .mode-cards, .progression, .resource-cycle, .generator-timeline, .api-layers { grid-template-columns: 1fr; }
  .practice-progress-head { flex-direction: column; align-items: stretch; }
  .practice-reset { width: 100%; }
  .input-row { flex-direction: column; }
  .course-progress-card .progress-row { flex-direction: column; align-items: stretch; }
  .editor-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
  .editor-toolbar > div { width: 100%; }
  .editor-toolbar :where(.btn, .run-btn) { flex: 1; }
  .editor-toolbar > .run-btn { align-self: flex-start; }
  .parsons > div { flex-direction: column; gap: 8px; }
  .footer-bottom { flex-direction: column; gap: 8px; }
  .practice-jump-shell .jump-links { gap: 8px; }
  .page-practice :where(.challenge, .practice-editorial-guide)[id] { scroll-margin-top: 1rem; }
}
@media (max-width: 600px) {
  :root { --gutter: 1.25rem; --section-space: 3.5rem; }
  .nav { gap: 12px; }
  .brand { font-size: .96rem; gap: 8px; }
  .brand-mark { width: 34px; height: 34px; }
  h1 { font-size: clamp(2rem, 7.6vw, 2.7rem); }
  .hero h1 { font-size: clamp(2.25rem, 8.9vw, 3.1rem); max-width: 16ch; }
  .hero .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
  .hero .actions { flex-direction: column; }
  .hero .actions .btn { width: 100%; }
  .hero-reassurance { text-align: center; }
  .grid-3, .grid-4, .glossary-grid, .lesson-list { grid-template-columns: 1fr; }
  .course-shell { padding-top: 2rem; }
  .lesson-content > section { padding-block: 2rem; }
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav a:last-child { text-align: left; }
  .recall-section { padding-inline: 1rem; }
  .code { padding: 20px 16px; font-size: 14px; }
  .window-top, .result { padding-inline: 16px; }
  .code-block pre { padding: 18px 16px; font-size: 14px; }
  .editor textarea { padding: 18px 16px; }
  .editor-toolbar > .run-btn { align-self: stretch; }
  .editor-toolbar > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-toolbar > div > .run-btn { grid-column: 1 / -1; }
  .editor-help { padding-inline: 16px; }
  .page-editor .editor textarea { min-height: 280px; }
  .solution-content { padding: 18px; }
  .solution-content pre { font-size: 14px; }
  .page-editor .jump-links .btn { flex: 1 1 45%; padding-inline: 10px; }
  .page-error-detail .related-links { align-items: stretch; flex-direction: column; }
  .page-error-detail .related-links a { width: 100%; }
  .page-faq .jump-links a { flex: 1 1 40%; }
  .footer { padding-top: 3rem; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.25rem; }
  .footer-grid > div:last-child { grid-column: 1 / -1; }
  .footer-grid > div:last-child a { width: 100%; }
}
@media (max-width: 360px) {
  :root { --gutter: 1rem; }
  .brand { font-size: .9rem; gap: 6px; }
  .brand-mark { width: 30px; height: 30px; }
  .menu-btn { padding-inline: 10px; gap: 6px; }
  .footer .brand { font-size: .95rem; }
  .hero h1 { font-size: 2.15rem; }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .progress-bar { background: Highlight; }
  :where(.btn, .run-btn, .menu-btn, .complete-btn) { border: 1px solid ButtonText; }
  .current { outline: 1px solid Highlight; }
}

/* Standalone guides: shared reading layout, native disclosures and code tools. */
.guide-hero { padding-block: clamp(2rem, 5vw, 4.5rem); border-bottom: 1px solid var(--border); background: radial-gradient(ellipse at 90% 0, #142e47, transparent 60%), var(--bg2); }
.guide-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(2rem, 5vw, 5rem); align-items: center; }
.guide-hero h1 { max-width: 23ch; }
.guide-hero .lead { margin-bottom: 1.5rem; }
.guide-facts { display: flex; flex-wrap: wrap; gap: .6rem 1.1rem; color: var(--muted); font-size: .88rem; }
.guide-facts span { display: inline-flex; align-items: center; gap: .5rem; }
.guide-facts span::before { content: ""; width: 5px; height: 5px; background: var(--green); border-radius: 50%; flex-shrink: 0; }
.guide-brief { border: 1px solid var(--border); border-top: 3px solid var(--green); border-radius: 16px; padding: 1.75rem; background: var(--surface); }
.guide-brief h2 { font-size: 1.35rem; }
.guide-brief p { color: var(--muted); margin-bottom: 1.5rem; }
.guide-brief-footer { border-top: 1px solid var(--border); padding-top: 1rem; font-size: .82rem; color: var(--green); }
.guide-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); padding-block: 3.5rem 4.5rem; align-items: start; }
.guide-sidebar { position: sticky; top: calc(var(--header-height) + 24px); min-width: 0; max-height: calc(100dvh - var(--header-height) - 48px); overflow-y: auto; padding: 4px; }
.guide-index { border: 1px solid var(--border); border-radius: 14px; background: var(--bg2); padding: .75rem 1rem; }
.guide-index > summary { color: var(--text); min-height: 48px; padding-top: .75rem; }
.guide-index nav { display: grid; gap: .25rem; margin-bottom: .5rem; }
.guide-index nav a { display: flex; align-items: center; min-height: 44px; padding: .5rem .75rem; text-decoration: none; border-radius: 8px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.guide-index nav a:hover, .guide-index nav a[aria-current="location"] { background: var(--blue-soft); color: var(--blue2); }
.guide-review { font-size: .8rem; color: var(--muted); line-height: 1.8; padding: 1rem .75rem 0; }
.guide-content { width: 100%; min-width: 0; max-width: 72ch; }
.guide-content > section { padding-block: 0 2.75rem; margin-bottom: 2.75rem; border-bottom: 1px solid var(--border); }
.guide-content > section:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.guide-content h2 { font-size: clamp(1.55rem, 2.4vw, 2rem); max-width: 33ch; }
.guide-content h3 { margin-top: 2rem; font-size: 1.2rem; }
.guide-content :where(h2, h3, section, details)[id] { scroll-margin-top: calc(var(--header-height) + 24px); }
.guide-content p { color: var(--muted); }
.guide-content p strong { color: var(--text); }
.guide-note { margin-block: 1.75rem; padding: 1.25rem 1.5rem; background: #122b2d; border-left: 3px solid var(--green); border-radius: 0 12px 12px 0; }
.guide-note > strong { color: var(--green); }
.guide-note p { margin: .5rem 0 0; }
.guide-code { background: var(--code); border: 1px solid var(--border); border-radius: 12px; margin-block: 1.5rem; overflow: hidden; min-width: 0; }
.guide-code-label { padding: .75rem 1.25rem; background: var(--code2); border-bottom: 1px solid var(--border); color: var(--muted); font-size: .82rem; line-height: 1.6; }
.guide-code pre, .guide-code .terminal-block { margin: 0; padding: 1.25rem; border: 0; border-radius: 0; color: var(--text); font: 14px/1.85 var(--mono); white-space: pre; overflow-wrap: normal; scrollbar-width: thin; }
.guide-code .code-comment { color: var(--muted); }
.guide-code .code-number { color: var(--blue2); }
.guide-code .kw { color: var(--yellow); }
.guide-code .str { color: #86e0ac; }
.guide-code-tools { display: flex; flex-wrap: wrap; gap: .5rem; padding: .65rem .9rem; background: var(--code2); border-top: 1px solid var(--border); }
.guide-code-tools button { min-height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .5rem .8rem; border-radius: 8px; font-size: .8rem; font-weight: 650; }
.guide-code-tools button:hover { border-color: var(--blue); }
.guide-copy-feedback { margin: 0; padding: .5rem 1rem; color: var(--green); font-size: .85rem; }
.guide-result { margin-block: 1.5rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 10px; background: var(--bg2); }
.guide-result > span { color: var(--green); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; font-weight: 750; }
.guide-result pre { margin: .6rem 0 0; color: var(--text); font: 14px/1.8 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.guide-platforms, .guide-choice-grid { display: grid; gap: 1rem; margin-block: 1.75rem; }
.guide-platforms details, .guide-faq > details { border: 1px solid var(--border); border-radius: 12px; background: var(--bg2); padding: .5rem 1.25rem; }
.guide-platforms summary, .guide-faq > details > summary { padding-block: 1rem; min-height: 56px; }
.guide-platforms summary::after, .guide-faq > details > summary::after { top: 1rem; }
.guide-detail-body { padding-block: .25rem .75rem; }
.guide-detail-body > :last-child { margin-bottom: 0; }
.guide-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide-choice-grid a { padding: 1.15rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; }
.guide-choice-grid a:hover { border-color: var(--blue); }
.guide-choice-grid a strong { display: block; margin-bottom: .6rem; font-size: .95rem; }
.guide-choice-grid a span { color: var(--blue); font-size: .88rem; }
.guide-prerequisite { font-size: .9rem; margin-top: 1.5rem; }
.guide-troubleshooting dt { font-weight: 750; color: var(--text); margin-top: 1.5rem; }
.guide-troubleshooting dd { color: var(--muted); margin: .5rem 0 0; }
.guide-exercise { padding: 1.5rem; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; margin-top: 1.5rem; }
.guide-exercise h3 { margin-top: 0; }
.guide-exercise .guide-code-label { font-size: .78rem; }
.guide-hint, .guide-solution { border-top: 1px solid var(--border); padding-top: .5rem; margin-top: 1rem; }
.guide-hint summary, .guide-solution summary { font-size: .95rem; color: var(--blue2); padding-block: .75rem; }
.guide-hint > p { margin-top: 1rem; }
.guide-next { display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; padding: 1.5rem; margin-top: 2rem; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(140deg, var(--blue-soft), var(--surface)); }
.guide-next h3 { margin: 0; }
.guide-next p { margin: 0; }
.guide-hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.guide-related .guide-hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide-hub-grid .route-card { min-width: 0; }
.guide-sources { font-size: .9rem; }
.guide-sources h2 { font-size: 1.35rem; }
.guide-file-tree { border: 1px solid var(--border); border-radius: 12px; background: var(--code); padding: 1.25rem; margin-block: 1.5rem; }
.guide-file-tree pre { font: 13px/1.8 var(--mono); margin: 0; }
.guide-search { border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; background: var(--surface); margin-bottom: 2.5rem; }
.guide-search label { display: block; color: var(--text); font-weight: 750; margin-bottom: .75rem; }
.guide-search-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.guide-search input { flex: 1 1 200px; min-width: 0; min-height: 48px; width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--code); color: var(--text); padding: .65rem .9rem; }
.guide-search input::placeholder { color: var(--muted); opacity: 1; }
.guide-search-row .btn { min-width: 100px; font-size: .88rem; padding-inline: .9rem; }
.guide-search #busqueda-ayuda, .guide-search-count { font-size: .85rem; margin: .75rem 0 0; }
.guide-no-results { border-left: 3px solid var(--yellow); padding: 1.25rem; background: var(--bg2); }
@media (max-width: 1000px) {
  .guide-hero-grid { grid-template-columns: minmax(0, 1fr) 260px; gap: 2rem; }
  .guide-layout { grid-template-columns: 1fr; gap: 2rem; padding-top: 2rem; }
  .guide-sidebar { position: static; max-height: none; overflow: visible; padding: 0; }
  .guide-index nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-review { padding: .75rem 0 0; margin: 0; }
  .guide-content { max-width: 76ch; margin-inline: auto; }
  .guide-hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .guide-hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .guide-hero h1 { max-width: 24ch; }
  .guide-brief { display: none; }
  .guide-brief p { margin-bottom: 1rem; }
  .guide-content { font-size: 1rem; }
  .guide-exercise { padding: 1.1rem; }
  .guide-platforms details, .guide-faq > details { padding-inline: 1rem; }
  .guide-code pre, .guide-code .terminal-block { padding: 1rem; font-size: 13px; }
  .guide-code-label { padding-inline: 1rem; }
  .guide-code-tools { padding-inline: .75rem; }
  .guide-code-tools button { flex: 1 1 auto; }
  .guide-hub-grid, .guide-related .guide-hub-grid, .guide-choice-grid { grid-template-columns: 1fr; }
  .guide-hero .actions .btn { width: 100%; }
  .guide-search-row .btn { flex: 1; }
  .guide-search input { flex-basis: 100%; }
}
@media (max-width: 400px) {
  .guide-index nav { grid-template-columns: 1fr; }
  .guide-file-tree { padding: .85rem; }
  .guide-file-tree pre { font-size: 11px; }
}
@media print {
  .page-guide { color-scheme: light; background: white; color: #111; font-size: 10pt; }
  .page-guide :where(.site-header, .skip-link, .guide-sidebar, .guide-related, .footer, .guide-code-tools, .guide-search, .guide-next, .guide-brief, .guide-hero .actions, .breadcrumbs, .guide-copy-feedback) { display: none !important; }
  .page-guide :where(.container, .guide-content) { width: 100%; max-width: none; }
  .page-guide .guide-hero { background: none; padding: 0 0 1rem; }
  .page-guide .guide-hero-grid, .page-guide .guide-layout { display: block; padding: 0; }
  .page-guide h1 { font-size: 26pt; max-width: none; }
  .page-guide h2 { font-size: 16pt; }
  .page-guide :where(p, li, a, .eyebrow, .guide-facts, .guide-code-label, .code-comment) { color: #222 !important; }
  .page-guide a { text-decoration: underline; }
  .page-guide :where(.guide-code, .guide-result, .guide-file-tree, .guide-note, .guide-exercise, details, code:not(pre code)) { background: white; border-color: #bbb; }
  .page-guide .guide-code :where(pre, code, span) { color: #111 !important; background: white; }
  .page-guide .guide-code pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 9pt; }
  .page-guide .guide-code { break-inside: avoid; }
  .page-guide :where(h2, h3) { break-after: avoid; }
  .page-guide .guide-content > section { margin-bottom: 1.5rem; padding-bottom: 1.5rem; }
  .page-guide .guide-reference[hidden] { display: block !important; }
}

/* Pulido de interfaz tras la revisión visual: tamaños mínimos, aire y jerarquía. */
.eyebrow, .mini-label, .lesson-nav-kicker, .output-label, .guide-code-label, .guide-exercise .guide-code-label, .guide-result > span, .guide-brief-footer, .guide-review, .guide-code-tools button { font-size: max(.85rem, 13.6px); }
.term-card dd small, .lesson-card small { font-size: .9rem; }
.course-facts h2 { font-size: 1.2rem; line-height: 1.3; margin-bottom: .75rem; }
.page-guide p code:not(pre code), .page-guide li code:not(pre code) { font-size: .9em; background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; padding: .08em .3em; overflow-wrap: anywhere; }
.progressive-hints { margin-block: 1.25rem; }
.progressive-hints details.hints, .practice-box details.answer { margin-block: .5rem; }
.editor-reset { font-size: .95rem; }
.output { min-height: 72px; }
.lesson-nav a:last-child { border-color: var(--border-strong); background: var(--blue-soft); }
.lesson-nav a:last-child:hover { border-color: var(--blue); background: var(--surface2); }
.lesson-end .complete-btn { width: 100%; }
.editor textarea { max-height: 72dvh; overflow-y: auto; }
@media (max-width: 600px) {
  .page-hero { padding: 1.75rem 0 1.5rem; }
  .page-hero .lesson-meta, .page-hero .actions { margin-top: 1rem; }
  .course-index-mobile { margin-bottom: 1.25rem; }
  .practice-box { padding: 16px 14px; border-radius: 16px; }
  .editor-toolbar > div > .run-btn { grid-column: auto; }
  .editor textarea { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
  .editor-help { font-size: .85rem; line-height: 1.55; padding-block: 10px; }
  .guide-code pre, .guide-code .terminal-block { font-size: 14px; }
  .guide-file-tree pre { font-size: 12px; }
}
.brand { min-height: 44px; }
.guide-next a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; }
