/* Hackory · Programación — its own interface, separate from the academy. */
:root, [data-theme="light"] {
  --bg: #f5f6f2; --bg-2: #eceee7; --surface: #ffffff; --surface-2: #f1f3ee; --ink: #121a17; --ink-2: #2b3631; --muted: #5a6661;
  --line: #dcdfd6; --line-strong: #c4c9bd; --brand: #17352e; --brand-ink: #ffffff; --accent: #3d6b12; --accent-soft: #e7f2d3;
  --accent-ink: #253f0b; --focus: #2f6fdb; --ok: #1f7a3d; --ok-soft: #e3f3e7; --bad: #b42318; --bad-soft: #fbe9e7; --warn: #8a5a00;
  --warn-soft: #fff3d6; --code-bg: #f7f8f5; --code-ink: #1c2622; --console-bg: #101815; --console-ink: #dfe8e2; --shadow: 0 1px 2px rgb(18 26 23 / 6%), 0 8px 24px rgb(18 26 23 / 6%);
  --tk-k: #8a3ffc; --tk-f: #0b6bcb; --tk-n: #a5551a;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1210; --bg-2: #0f1815; --surface: #121c19; --surface-2: #17231f; --ink: #e9efeb; --ink-2: #c9d3ce; --muted: #94a39c;
  --line: #22302b; --line-strong: #31423b; --brand: #c9ec6a; --brand-ink: #10180f; --accent: #c9ec6a; --accent-soft: #1d2a15;
  --accent-ink: #d9f39a; --focus: #7fb2ff; --ok: #6fd08c; --ok-soft: #12271a; --bad: #ff8a7a; --bad-soft: #2c1513; --warn: #f0c060;
  --warn-soft: #2a2210; --code-bg: #0e1714; --code-ink: #dbe5df; --console-bg: #070c0a; --console-ink: #d7e2dc; --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 25%);
  --tk-k: #c4a7ff; --tk-f: #7cc4ff; --tk-n: #ffb27a;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }
body.pg { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: 'Space Grotesk', 'DM Sans', system-ui, sans-serif; letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); font-weight: 650; }
h2 { font-size: 1.35rem; font-weight: 620; }
h3 { font-size: 1.05rem; font-weight: 620; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: .18em; }
[data-theme="dark"] a { color: var(--accent-ink); }
code, pre, textarea { font-family: ui-monospace, 'Cascadia Code', 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.pg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pg-text { white-space: pre-line; }
.pg-skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--surface); color: var(--ink); border-radius: 8px; box-shadow: var(--shadow); }
.pg-skip:focus { top: 12px; }
[hidden] { display: none !important; }

/* Top bar */
.pg-top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.pg-top-inner { max-width: 1320px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 20px; }
.pg-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.pg-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; overflow: hidden; background: transparent; }
/* Same mark as the academy (/hackory-mark.png): white H with the green arrow. The PNG has padding,
   so it is scaled like .brand-mark in logo.css; on the light theme it sits on the dark brand green. */
.pg-mark img { display: block; width: 100%; height: 100%; object-fit: contain; transform: scale(1.42); }
[data-theme="light"] .pg-mark { background: #172f2d; }
.pg-word { font: 650 1.05rem/1 'Space Grotesk', sans-serif; letter-spacing: .01em; }
.pg-product { font: 500 .95rem/1 'Space Grotesk', sans-serif; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-strong); }
/* Brand with the academy tagline (I15), the same in every header of Hackory. */
.pg-brand-text { display: grid; gap: 3px; min-width: 0; }
.pg-tagline { font: 600 .56rem/1 ui-monospace, 'Cascadia Code', Consolas, monospace; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
.pg-nav { display: flex; gap: 4px; margin-left: 8px; }
.pg-nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: .94rem; }
.pg-nav a:hover, .pg-nav a[aria-current] { background: var(--surface-2); color: var(--ink); }
.pg-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pg-language { position: relative; }
.pg-language summary { list-style: none; cursor: pointer; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.pg-language summary::-webkit-details-marker { display: none; }
.pg-language ul { position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 150px; }
.pg-language a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.pg-language a:hover, .pg-language a[aria-current] { background: var(--surface-2); }
.pg-icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; }
.pg-theme-icon { width: 16px; height: 16px; border-radius: 50%; background: currentColor; box-shadow: inset -5px -3px 0 0 var(--bg); }
[data-theme="light"] .pg-theme-icon { box-shadow: none; background: transparent; border: 2px solid currentColor; }
.pg-account { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; background: var(--brand); color: var(--brand-ink) !important; text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.pg-account-xp { font-size: .78rem; opacity: .8; font-weight: 500; }

.pg-main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 32px 24px 56px; }
.pg-main:focus { outline: none; }
.pg-eyebrow { font: 600 .78rem/1.3 'DM Sans', sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.pg-lead { font-size: 1.12rem; color: var(--ink-2); max-width: 62ch; }
.pg-content-note { display: inline-block; font-size: .85rem; color: var(--warn); background: var(--warn-soft); padding: 4px 10px; border-radius: 6px; }
.pg-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 18px; border-radius: 9px; font: 600 .95rem/1.2 'DM Sans', sans-serif; text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.pg-button:disabled { opacity: .55; cursor: progress; }
.pg-button-primary { background: var(--brand); color: var(--brand-ink) !important; }
.pg-button-primary:hover:not(:disabled) { filter: brightness(1.1); }
.pg-button-ghost { background: var(--surface); color: var(--ink) !important; border-color: var(--line-strong); }
.pg-button-ghost:hover:not(:disabled) { background: var(--surface-2); }
.pg-button-small { min-height: 36px; padding: 7px 13px; font-size: .88rem; }
.pg-link-button { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; text-underline-offset: .2em; padding: 4px; }
.pg-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 18px; }
.pg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); }
.pg-badge { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; font: 700 .95rem/1 'Space Grotesk', sans-serif; flex: none; }
.pg-badge-python { background: #1f4b7a; color: #ffd866; }
.pg-badge-javascript { background: #2b2b1f; color: #f2dd4c; }
.pg-meter { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.pg-meter span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.pg-honesty { font-size: .88rem; color: var(--muted); border-left: 3px solid var(--line-strong); padding-left: 12px; max-width: 75ch; }
.pg-honesty-small { font-size: .8rem; margin-top: 14px; }
.pg-section { margin-top: 64px; }

/* Home */
.pg-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 48px; align-items: center; padding: 24px 0 8px; }
.pg-window { margin: 0; border-radius: 14px; overflow: hidden; background: var(--console-bg); border: 1px solid var(--line); box-shadow: var(--shadow); }
.pg-window-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid rgb(255 255 255 / 8%); color: #9fb0a8; font-size: .8rem; }
.pg-window-bar i { width: 10px; height: 10px; border-radius: 50%; background: #33433d; }
.pg-window-bar span { margin-left: 8px; font-family: ui-monospace, Consolas, monospace; }
.pg-window-code { margin: 0; padding: 18px 20px; color: #dbe5df; font-size: .9rem; line-height: 1.65; overflow-x: auto; }
.pg-window-out { padding: 12px 20px; border-top: 1px solid rgb(255 255 255 / 8%); color: #c9ec6a; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.pg-window-out span { color: #6e8279; margin-right: 6px; }
.tk-k { color: #c4a7ff; } .tk-f { color: #7cc4ff; } .tk-n { color: #ffb27a; }
.pg-course-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.pg-course-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.pg-course-card:hover:not(.is-soon) { border-color: var(--line-strong); }
.pg-course-card h3 { font-size: 1.35rem; margin: 6px 0 0; }
.pg-course-card p { color: var(--ink-2); margin: 0; }
.pg-card-link { color: var(--ink) !important; text-decoration: none; }
.pg-card-link::after { content: ''; position: absolute; inset: 0; border-radius: 14px; }
.pg-course-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pg-course-card .pg-meter { margin-top: 8px; }
.pg-course-progress { font-size: .85rem; color: var(--muted) !important; }
.pg-course-card.is-soon { opacity: .75; box-shadow: none; border-style: dashed; }
.pg-how { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.pg-how li { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.pg-how p { color: var(--ink-2); margin: 0; }
.pg-how-index { display: inline-block; font: 600 .8rem/1 'Space Grotesk', sans-serif; color: var(--accent); margin-bottom: 12px; }
[data-theme="dark"] .pg-how-index { color: var(--accent-ink); }

/* Course map */
.pg-crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 20px; }
.pg-crumbs a { color: var(--muted); }
.pg-map-head { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(260px, 340px); gap: 24px; align-items: start; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.pg-map-head .pg-badge { width: 56px; height: 56px; font-size: 1.1rem; }
.pg-map-copy p { color: var(--ink-2); }
.pg-map-stats { font-size: .9rem; color: var(--muted) !important; }
.pg-map-progress { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface-2); border-radius: 12px; }
.pg-map-summary { font-weight: 600; margin: 0; }
.pg-map-xp { margin: 0; color: var(--muted); font-size: .9rem; }
.pg-map-xp:empty { display: none; }
.pg-account-note { margin: 0; font-size: .84rem; color: var(--muted); }
.pg-units { display: flex; flex-direction: column; gap: 40px; margin: 40px 0; }
.pg-unit { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 28px; }
.pg-unit-head p { color: var(--ink-2); font-size: .95rem; }
.pg-unit-head .pg-eyebrow { color: var(--accent); }
[data-theme="dark"] .pg-unit-head .pg-eyebrow { color: var(--accent-ink); }
.pg-unit-count { font-size: .85rem !important; color: var(--muted) !important; }
.pg-lesson-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pg-lesson-card { height: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 4px 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink) !important; text-decoration: none; transition: border-color .15s, transform .15s; }
.pg-lesson-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.pg-lesson-number { grid-row: span 2; font: 600 .85rem/1 'Space Grotesk', sans-serif; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--ink-2); }
.pg-lesson-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pg-lesson-title { font-weight: 620; line-height: 1.35; }
.pg-lesson-subtitle { font-size: .86rem; color: var(--muted); line-height: 1.45; }
.pg-lesson-meta { grid-column: 2; display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pg-xp { font-size: .78rem; font-weight: 600; color: var(--muted); }
.pg-status { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pg-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.pg-status[data-status="progress"] { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pg-status[data-status="done"], .pg-status[data-status="assisted"] { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pg-lesson-card[data-state="done"] .pg-lesson-number, .pg-lesson-card[data-state="assisted"] .pg-lesson-number { background: var(--ok-soft); color: var(--ok); }

/* Lesson */
.pg-lesson-hero { margin-bottom: 28px; }
.pg-lesson-hero h1 { margin-bottom: 10px; }
.pg-lesson-chips { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pg-steps { list-style: none; margin: 18px 0 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.pg-steps a { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink) !important; text-decoration: none; font-weight: 600; font-size: .9rem; }
.pg-steps span { font: 600 .75rem/1 'Space Grotesk', sans-serif; padding: 6px 7px; border-radius: 7px; background: var(--brand); color: var(--brand-ink); }
.pg-lesson-grid-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: start; }
.pg-read { display: flex; flex-direction: column; gap: 40px; min-width: 0; }
.pg-stage { display: flex; flex-direction: column; gap: 18px; scroll-margin-top: 90px; }
.pg-stage > h2 { margin: 6px 0 0; }
.pg-intro { font-size: 1.04rem; color: var(--ink-2); }
.pg-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.pg-pieces { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pg-pieces li { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 14px; align-items: baseline; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.pg-pieces p { margin: 0; color: var(--ink-2); white-space: pre-line; }
.pg-term { font-size: .9rem; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; justify-self: start; overflow-wrap: anywhere; }
.pg-code { margin: 0 0 14px; padding: 14px 16px; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; line-height: 1.6; overflow-x: auto; tab-size: 4; }
.pg-console { margin: 12px 0; padding: 14px 16px; min-height: 64px; max-height: 340px; overflow: auto; background: var(--console-bg); color: var(--console-ink); border-radius: 10px; font-size: .88rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.pg-console-err { color: #ffb4a8; }
.pg-console-error { color: #ffcf8a; font-family: 'DM Sans', sans-serif; }
.pg-console-muted { color: #8fa39a; font-family: 'DM Sans', sans-serif; }
.pg-predict fieldset { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.pg-predict legend { font-weight: 600; margin-bottom: 12px; padding: 0; }
.pg-options { display: grid; gap: 8px; }
.pg-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface-2); }
.pg-option input { margin-top: 4px; accent-color: var(--brand); }
.pg-option span { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; overflow-wrap: anywhere; }
.pg-option.is-right { border-color: var(--ok); background: var(--ok-soft); }
.pg-option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.pg-feedback { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--line-strong); }
.pg-feedback[data-state="right"] { border-left-color: var(--ok); }
.pg-feedback[data-state="wrong"] { border-left-color: var(--bad); }
.pg-feedback p { margin: 0 0 6px; }
.pg-feedback-head { font-weight: 700; }
.pg-mission { border-left: 4px solid var(--brand); }
[data-theme="dark"] .pg-mission { border-left-color: var(--accent); }
.pg-mission-steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.pg-hint-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.pg-hint-list li { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); }
.pg-hint-list p { margin: 0; }
.pg-hint-index { font: 700 .8rem/1.6 'Space Grotesk', sans-serif; color: var(--warn); }
.pg-hints > p { color: var(--muted); font-size: .92rem; }
.pg-key { background: var(--brand); border-color: transparent; color: var(--brand-ink); }
.pg-key h2 { color: inherit; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; font-family: 'DM Sans', sans-serif; font-weight: 700; opacity: .85; }
.pg-key p { margin: 0; font: 600 1.15rem/1.45 'Space Grotesk', sans-serif; }
.pg-debrief { border: 2px solid var(--ok); background: var(--ok-soft); }
.pg-debrief:focus { outline: none; }
.pg-debrief h2 { color: var(--ok); }
.pg-debrief ul { padding-left: 20px; display: grid; gap: 6px; }
.pg-award { font-weight: 600; }
.pg-award:empty { display: none; }
.pg-help > p { color: var(--ink-2); font-size: .94rem; }
.pg-help-status { margin: 10px 0 0; font-size: .9rem; }
.pg-help-status:empty { display: none; }
.pg-solution { margin-top: 14px; }
.pg-solution-title { font-weight: 700; margin-bottom: 8px; }

/* Workspace */
.pg-work { position: sticky; top: 84px; min-width: 0; }
.pg-work-inner { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.pg-work-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pg-work-head h2 { margin: 0; font-size: 1.05rem; }
.pg-file { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }
.pg-work-head .pg-link-button { margin-left: auto; }
.pg-editor { display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line-strong); border-radius: 10px; background: var(--code-bg); overflow: hidden; height: clamp(260px, 42vh, 460px); }
.pg-editor:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.pg-gutter { padding: 14px 10px 14px 14px; text-align: right; color: var(--muted); font: .9rem/1.6 ui-monospace, 'Cascadia Code', Consolas, monospace; white-space: pre; overflow: hidden; user-select: none; background: var(--surface-2); border-right: 1px solid var(--line); min-width: 44px; }
.pg-textarea { width: 100%; height: 100%; resize: none; border: 0; margin: 0; padding: 14px 16px; background: transparent; color: var(--code-ink); font-size: .9rem; line-height: 1.6; tab-size: 4; white-space: pre; overflow: auto; outline: none; }
.pg-editor-help { font-size: .8rem; color: var(--muted); margin: 8px 0 12px; }
.pg-run-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pg-runtime { font-size: .84rem; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.pg-runtime:empty { display: none; }
.pg-runtime[data-state="loading"]::before, .pg-runtime[data-state="restarting"]::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: pg-spin .8s linear infinite; }
.pg-runtime[data-state="ready"] { color: var(--ok); }
.pg-runtime[data-state="failed"] { color: var(--bad); }
@keyframes pg-spin { to { transform: rotate(360deg); } }
.pg-run-hint { font-size: .8rem; color: var(--muted); margin: 8px 0 0; }
.pg-output { margin-top: 16px; }
.pg-output h3, .pg-results h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0; font-family: 'DM Sans', sans-serif; }
.pg-output .pg-console { margin-top: 8px; }
.pg-results { margin-top: 16px; }
.pg-results h3:focus { outline: none; }
.pg-results > p { font-weight: 600; margin: 6px 0 10px; }
.pg-results[data-state="pass"] > p { color: var(--ok); }
.pg-case-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pg-case-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.pg-case-list li.is-pass { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pg-case-list li.is-fail { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
.pg-case-head { margin: 0; font-weight: 600; }
.pg-case-badge { font-size: .74rem; padding: 2px 8px; border-radius: 99px; margin-right: 4px; }
.is-pass .pg-case-badge { background: var(--ok-soft); color: var(--ok); }
.is-fail .pg-case-badge { background: var(--bad-soft); color: var(--bad); }
.pg-case-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.pg-case-compare span { font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pg-case-compare pre { margin: 4px 0 0; padding: 8px 10px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; font-size: .84rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.pg-case-error { font-size: .84rem; color: var(--bad); margin: 6px 0 0; }
.pg-case-hint { margin: 10px 0 0; font-size: .9rem; color: var(--ink-2); }
.pg-pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.pg-pager-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--ink) !important; }
.pg-pager-link span { font-size: .8rem; color: var(--muted); }
.pg-pager-next { text-align: right; }
.pg-pager-map { font-size: .9rem; }
.pg-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; margin: 0; padding: 12px 18px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.pg-empty { max-width: 560px; margin: 80px auto; text-align: center; }

.pg-footer { border-top: 1px solid var(--line); background: var(--bg-2); }
.pg-footer-inner { max-width: 1320px; margin: 0 auto; padding: 22px 24px; display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; font-size: .86rem; color: var(--muted); }
.pg-footer-inner span { font-weight: 600; color: var(--ink-2); }
.pg-footer-inner p { margin: 0; flex: 1; min-width: 240px; }
.pg-footer a { color: var(--ink-2); }

@media (max-width: 1100px) {
  .pg-lesson-grid-layout { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  /* One column: the editor follows the mission, before the key idea and the wrap-up. */
  .pg-read { display: contents; }
  #pg-understand { order: 1; } #pg-try { order: 2; } .pg-work { position: static; order: 3; } #pg-explain { order: 4; }
  .pg-map-head { grid-template-columns: auto minmax(0, 1fr); }
  .pg-map-progress { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .pg-hero { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .pg-course-grid, .pg-how { grid-template-columns: minmax(0, 1fr); }
  .pg-unit { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .pg-nav a:first-child { display: none; }
}
@media (max-width: 640px) {
  .pg-top-inner { padding: 10px 14px; gap: 10px; }
  .pg-product, .pg-nav { display: none; }
  /* The tagline wraps under the name instead of running under the tools. */
  .pg-tagline { white-space: normal; line-height: 1.25; }
  .pg-main { padding: 22px 14px 40px; }
  .pg-map-head { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .pg-map-head .pg-badge { display: none; }
  .pg-pieces li { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .pg-case-compare { grid-template-columns: minmax(0, 1fr); }
  .pg-pager { grid-template-columns: minmax(0, 1fr); }
  .pg-pager-next { text-align: left; }
  .pg-account { padding: 8px 10px; }
  .pg-account-xp { display: none; }
  .pg-work-inner, .pg-card { padding: 16px; }
  .pg-editor { height: 300px; }
  .pg-button { width: auto; }
}
/* I4. Python download notice and real progress, in the lesson header. */
.pg-python { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); max-width: 760px; }
.pg-python-text { margin: 0 0 8px; font-size: .92rem; color: var(--ink-2); }
.pg-python-cached { display: none; }
[data-python-cached] .pg-python-first { display: none; }
[data-python-cached] .pg-python-cached { display: block; }
.pg-python-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 44px; }
.pg-python-bar { flex: 1 1 160px; max-width: 320px; height: 10px; accent-color: var(--accent); }
.pg-python-status { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pg-python[data-state="ready"] .pg-python-status { color: var(--ok); }
.pg-python[data-state="failed"] .pg-python-status { color: var(--bad); }
.pg-python[data-state="idle"] .pg-python-bar, .pg-python[data-state="failed"] .pg-python-bar { display: none; }
.pg-python .pg-button-small { min-height: 44px; }
.pg-runtime-detail { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pg-runtime-detail:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Code inside titles keeps a monospace face so () and operators read as code. */
.pg-title-code { font-family: var(--pg-mono, ui-monospace, "Cascadia Code", Consolas, monospace); font-size: .86em; font-weight: 600; letter-spacing: 0; padding: 0 .12em; border-radius: .2em; background: color-mix(in srgb, currentColor 8%, transparent); }
