/* web/static/css/learn.css
 *
 * Styling for the Learn exercise screen (screens/learn/exercise.js).
 * Calm and theme-driven: every colour comes from a CANONICAL CivNode theme
 * variable (--bg-primary, --text-primary, --accent, ...) so the screen follows
 * the active theme. Fallbacks are dark (midnight is the default theme); they
 * are only ever reached if a theme variable is somehow undefined.
 *
 * The hard rule honoured here is NO layout shift -- the result area reserves
 * vertical space so a PASS/FAIL never jumps the page. Pass is a quiet success
 * tone, fail a gentle diff, never an alarming red wall.
 */

.learn-exercise {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    color: var(--text-primary, #d4d0c8);
}

.learn-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 6px;
}

.learn-progress {
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
    white-space: nowrap;
}

.learn-title {
    font-size: 1.4rem;
    margin: 0;
    line-height: 1.2;
    color: var(--text-primary, #d4d0c8);
}

.learn-brief {
    color: var(--text-secondary, #8a8680);
    margin: 0 0 16px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Tiered hints (R6): optional, no-penalty disclosures under the brief. */
.learn-hints {
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.learn-hints__label {
    font-size: 0.8125rem;
    color: var(--text-muted, #5a5650);
    margin-bottom: 2px;
}

.learn-hint {
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    background: var(--bg-secondary, #0e0e12);
}

.learn-hint__summary {
    cursor: pointer;
    list-style: none;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-secondary, #8a8680);
    user-select: none;
}

.learn-hint__summary::-webkit-details-marker {
    display: none;
}

.learn-hint__summary::before {
    content: '+';
    display: inline-block;
    width: 1em;
    color: var(--accent, #c9a84c);
    font-weight: 600;
}

.learn-hint[open] > .learn-hint__summary {
    color: var(--text-primary, #d4d0c8);
    border-bottom: 1px solid var(--border-subtle, #20202a);
}

.learn-hint[open] > .learn-hint__summary::before {
    content: '\2212'; /* minus sign */
}

.learn-hint__summary:hover {
    color: var(--text-primary, #d4d0c8);
}

.learn-hint__text {
    margin: 0;
    padding: 10px 12px 12px;
    color: var(--text-primary, #d4d0c8);
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Reveal-solution fold (Task 1.5): a single collapsed disclosure carrying the
   reference answer. Mirrors the .learn-hint disclosure treatment so it reads as
   part of the same book; the code body reuses the .learn-diff <pre> look. */
.learn-solution {
    margin: 16px 0 0;
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    background: var(--bg-secondary, #0e0e12);
}

.learn-solution__summary {
    cursor: pointer;
    list-style: none;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-secondary, #8a8680);
    user-select: none;
}

.learn-solution__summary::-webkit-details-marker {
    display: none;
}

.learn-solution__summary::before {
    content: '+';
    display: inline-block;
    width: 1em;
    color: var(--accent, #c9a84c);
    font-weight: 600;
}

.learn-solution[open] > .learn-solution__summary {
    color: var(--text-primary, #d4d0c8);
    border-bottom: 1px solid var(--border-subtle, #20202a);
}

.learn-solution[open] > .learn-solution__summary::before {
    content: '\2212'; /* minus sign */
}

.learn-solution__summary:hover {
    color: var(--text-primary, #d4d0c8);
}

.learn-solution__nudge {
    margin: 0;
    padding: 10px 12px 0;
    color: var(--text-muted, #5a5650);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.learn-solution__code {
    margin: 10px 12px 12px;
    padding: 10px 12px;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-surface, #14141a);
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 4px);
    color: var(--text-primary, #d4d0c8);
}

/* Common-mistake notes (Task 1.6): surfaced in the result area after Run, on
   both pass and fail. A "note" chip is a warn (style pointer, accent hue); an
   "avoid" chip is an error (a real trap, danger hue). */
.learn-mistakes {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.learn-mistakes__label {
    font-size: 0.8125rem;
    color: var(--text-muted, #5a5650);
}

.learn-mistake {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary, #d4d0c8);
}

.learn-mistake__chip {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 7px;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: var(--radius, 4px);
    border: 1px solid transparent;
}

.learn-mistake--warn .learn-mistake__chip {
    color: var(--accent, #c9a84c);
    border-color: var(--accent, #c9a84c);
    background: var(--accent-subtle, rgba(201, 168, 76, 0.08));
}

.learn-mistake--error .learn-mistake__chip {
    color: var(--danger, #c07070);
    border-color: var(--danger, #c07070);
}

.learn-editor {
    border: 1px solid var(--border, #2a2a32);
    border-radius: var(--radius, 6px);
    overflow: hidden;
    min-height: 220px;
    background: var(--bg-surface, #14141a);
}

/* Plain-textarea fallback (no CodeMirror) still reads like an editor. */
.code-editor-fallback {
    width: 100%;
    min-height: 220px;
    border: 0;
    padding: 12px;
    font-family: var(--font-mono, monospace);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    background: var(--bg-surface, #14141a);
    color: var(--text-primary, #d4d0c8);
    box-sizing: border-box;
}

.learn-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
}

.learn-spacer {
    flex: 1 1 auto;
}

.learn-btn {
    appearance: none;
    border: 1px solid var(--border, #2a2a32);
    background: var(--bg-surface, #14141a);
    color: var(--text-primary, #d4d0c8);
    padding: 8px 18px;
    border-radius: var(--radius, 6px);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-btn:hover:not(:disabled) {
    border-color: var(--accent, #c9a84c);
}

.learn-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.learn-run {
    background: var(--accent, #c9a84c);
    border-color: var(--accent, #c9a84c);
    color: var(--bg-primary, #08080a);
    font-weight: 600;
}

.learn-run:hover:not(:disabled) {
    background: var(--accent-hover, #d8b95e);
    border-color: var(--accent-hover, #d8b95e);
}

/* Reserve space so PASS/FAIL does not shift the page. */
.learn-result {
    min-height: 96px;
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    padding: 14px 16px;
    background: var(--bg-secondary, #0e0e12);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.learn-result[data-state="pass"] {
    border-color: var(--success, #6a9a6a);
    background: var(--accent-subtle, rgba(201, 168, 76, 0.08));
}

.learn-hint-line {
    margin: 0;
    color: var(--text-muted, #5a5650);
}

.learn-pass {
    color: var(--success, #6a9a6a);
    font-size: 1.05rem;
}

/* Reset controls (exercise screen) — quiet, secondary to Run/Prev/Next. */
.learn-reset-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.learn-reset {
    background: none;
    border: none;
    padding: 4px 2px;
    font-size: 0.8125rem;
    color: var(--text-muted, #5a5650);
    cursor: pointer;
    border-bottom: 1px solid transparent;
}

.learn-reset:hover {
    color: var(--text-secondary, #8a8680);
    border-bottom-color: var(--border, #2a2a32);
}

.learn-reset--all:hover {
    color: var(--danger, #c07070);
    border-bottom-color: var(--danger, #c07070);
}

.learn-reset:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Resume banner (course index) — "where you left off". */
.learn-resume {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 12px 16px;
    border: 1px solid var(--border, #1e1e28);
    border-left: 3px solid var(--accent, #c9a84c);
    border-radius: var(--radius, 6px);
    background: var(--bg-secondary, #0e0e12);
    text-decoration: none;
    transition: border-color var(--transition, 180ms ease);
}

.learn-resume:hover {
    border-color: var(--accent, #c9a84c);
}

.learn-resume__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #5a5650);
}

.learn-resume__target {
    color: var(--text-primary, #d4d0c8);
    font-weight: 600;
}

/* Reset-all footer (course index). */
.learn-index-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle, #20202a);
    display: flex;
    justify-content: flex-end;
}

.learn-pass-mark {
    font-family: var(--font-mono, monospace);
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-right: 6px;
}

.learn-fail {
    color: var(--text-primary, #d4d0c8);
    font-size: 1.02rem;
}

.learn-fail-mark {
    font-family: var(--font-mono, monospace);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--danger, #c07070);
    margin-right: 6px;
}

.learn-diff {
    margin: 10px 0 0;
    padding: 10px 12px;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-surface, #14141a);
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 4px);
    color: var(--text-primary, #d4d0c8);
}

.learn-stderr {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
}

.learn-stderr pre {
    margin: 8px 0 0;
    font-family: var(--font-mono, monospace);
    white-space: pre-wrap;
    word-break: break-word;
}

.learn-error {
    padding: 32px 0;
    color: var(--danger, #c07070);
}

.learn-back {
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
    text-decoration: none;
    white-space: nowrap;
}

.learn-back:hover {
    color: var(--accent, #c9a84c);
}

/* ── Course index (/learn) ────────────────────────────────────────────────── */

/* ---------------------------------------------------------------------------
 * Learn course index (screens/learn/index.js) — the sandbox catalog.
 * Searchable filter grid ("A1 editorial" + A3 hover-reveal run), built only
 * from canonical CivNode theme tokens so it follows the active theme.
 * ------------------------------------------------------------------------- */
.learn-index {
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    color: var(--text-primary, #d4d0c8);
}

/* Header: title + lead on the left, a live course count on the right, with a
   short accent rule underneath to echo the platform's editorial feel. */
.learn-index-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    padding-bottom: 18px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle, #14141c);
    position: relative;
}
.learn-index-header::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 64px;
    height: 2px;
    background: var(--accent, #c9a84c);
}
.learn-index-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 6px;
    color: var(--text-primary, #d4d0c8);
}
.learn-index-lead {
    margin: 0;
    max-width: 56ch;
    color: var(--text-secondary, #8a8680);
    line-height: 1.55;
}
.learn-index-kpi {
    text-align: right;
    white-space: nowrap;
    font-family: var(--font-mono, monospace);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #5a5650);
    line-height: 1.4;
}
.learn-index-kpi b {
    display: block;
    font-weight: 500;
    font-size: 1.6rem;
    color: var(--accent, #c9a84c);
    margin-bottom: 2px;
}

/* Controls: search field + language filter chips. */
.learn-index-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}
.learn-index-searchwrap {
    flex: 1 1 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    background: var(--bg-secondary, #0f0f14);
    border: 1px solid var(--border, #1e1e28);
    border-radius: var(--radius, 6px);
    transition: border-color var(--transition, 180ms ease), box-shadow var(--transition, 180ms ease);
}
.learn-index-searchwrap svg { flex: none; opacity: 0.45; color: var(--text-secondary, #8a8680); }
.learn-index-searchwrap:focus-within {
    border-color: var(--accent, #c9a84c);
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(201, 168, 76, 0.08));
}
.learn-index-search {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary, #d4d0c8);
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.98rem;
}
.learn-index-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.learn-chip {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.85rem;
    color: var(--text-secondary, #8a8680);
    background: none;
    border: 1px solid var(--border, #1e1e28);
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    transition: var(--transition, 180ms ease);
}
.learn-chip:hover { color: var(--text-primary, #d4d0c8); border-color: var(--border-strong, #3a3733); }
.learn-chip.active {
    color: var(--text-on-accent, #1a1814);
    background: var(--accent, #c9a84c);
    border-color: var(--accent, #c9a84c);
    font-weight: 600;
}

/* The card grid. Per-language accent hue on the left stripe. */
.learn-course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}
.learn-course-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 18px 20px 17px 22px;
    border: 1px solid var(--border, #1e1e28);
    border-radius: var(--radius-lg, 12px);
    background: var(--bg-surface, #16161e);
    cursor: pointer;
    transition: border-color var(--transition, 180ms ease), transform var(--transition, 180ms ease), box-shadow var(--transition, 180ms ease);
}
.learn-course-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 3px;
    background: var(--hue, var(--accent, #c9a84c));
    opacity: 0.55;
    transition: var(--transition, 180ms ease);
}
.learn-course-card:hover {
    border-color: var(--border-strong, #3a3733);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg, 0 4px 16px rgba(0,0,0,0.35));
}
.learn-course-card:hover::before { opacity: 1; top: 0; bottom: 0; }
.learn-course-card:focus-visible { outline: 2px solid var(--accent, #c9a84c); outline-offset: 2px; }
.learn-course-card.soon { opacity: 0.45; cursor: default; }
.learn-course-card.soon:hover { transform: none; box-shadow: none; border-color: var(--border, #1e1e28); }

/* Per-language hue. Falls back to the gold accent for unknown languages. */
.learn-course-card.lang-go { --hue: #4d97b8; }
.learn-course-card.lang-python { --hue: #c9a84c; }
.learn-course-card.lang-sql { --hue: #9a7bc8; }
.learn-course-card.lang-c { --hue: #7aa86a; }
.learn-course-card.lang-cpp { --hue: #7aa86a; }
.learn-course-card.lang-rust { --hue: #d08770; }
.learn-course-card.lang-js { --hue: #d4b455; }

.learn-card-top { display: flex; align-items: center; justify-content: space-between; }
.learn-card-lang {
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hue, var(--accent, #c9a84c));
}
.learn-card-count {
    font-family: var(--font-mono, monospace);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #5a5650);
}
.learn-course-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 1.28rem;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
    color: var(--text-primary, #d4d0c8);
}
.learn-course-blurb {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-secondary, #8a8680);
    flex: 1 1 auto;
}
.learn-course-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--bg-secondary, #0f0f14);
    overflow: hidden;
}
.learn-course-bar-fill {
    height: 100%;
    background: var(--accent, #c9a84c);
    transition: width 0.3s ease;
}
.learn-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 3px;
    padding-top: 11px;
    border-top: 1px solid var(--border-subtle, #14141c);
}
.learn-card-progress { font-size: 0.78rem; color: var(--text-muted, #5a5650); }
/* A3-style run affordance: hidden until the card is hovered, then slides in. */
.learn-card-run {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent, #c9a84c);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-4px);
    transition: var(--transition, 180ms ease);
}
.learn-course-card:hover .learn-card-run { opacity: 1; transform: none; }
@media (hover: none) { .learn-card-run { opacity: 1; transform: none; } }

.learn-index-empty {
    color: var(--text-muted, #5a5650);
    padding: 32px 0;
    text-align: center;
    grid-column: 1 / -1;
}

@media (max-width: 560px) {
    .learn-index-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .learn-index-kpi { text-align: left; }
    .learn-course-grid { grid-template-columns: 1fr; }
}

/* "Also in the sandbox" — the code runner + developer library, folded in from
 * the retired /study page. Quieter than the course cards: they are adjacent
 * tools, not graded courses. */
.learn-index-extras {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle, #20202a);
}

.learn-index-extras-title {
    margin: 0 0 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #5a5650);
}

.learn-extras-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.learn-extra-card {
    display: block;
    padding: 16px 18px;
    border: 1px solid var(--border, #1e1e28);
    border-radius: var(--radius-lg, 12px);
    background: var(--bg-secondary, #0e0e12);
    text-decoration: none;
    transition: border-color var(--transition, 180ms ease), transform var(--transition, 180ms ease);
}

.learn-extra-card:hover {
    border-color: var(--accent, #c9a84c);
    transform: translateY(-2px);
}

.learn-extra-card:focus-visible {
    outline: 2px solid var(--accent, #c9a84c);
    outline-offset: 2px;
}

.learn-extra-title {
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--text-primary, #d4d0c8);
}

.learn-extra-blurb {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary, #8a8680);
}

@media (max-width: 560px) {
    .learn-extras-row { grid-template-columns: 1fr; }
}

/* ── Course Resources ──────────────────────────────────────────────────────
   The reusable cheat-sheet / reference-doc panel for any Learn course. A
   discreet link on each course card, a header link on the exercise screen, and
   the two-pane Resources screen itself. */

/* Course-card link: a quiet, underlined affordance under the footer. */
.learn-card-resources {
    display: inline-block;
    margin-top: 9px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.78rem;
    color: var(--text-secondary, #8a8680);
    text-decoration: none;
    border-bottom: 1px solid var(--border-subtle, #20202a);
    transition: color var(--transition, 180ms ease), border-color var(--transition, 180ms ease);
}
.learn-card-resources:hover {
    color: var(--accent, #c9a84c);
    border-bottom-color: var(--accent, #c9a84c);
}

/* Exercise-header link: sits beside the progress counter. */
.learn-resources-link {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.82rem;
    color: var(--text-secondary, #8a8680);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition, 180ms ease);
}
.learn-resources-link:hover { color: var(--accent, #c9a84c); }

/* Resources screen ------------------------------------------------------- */
.learn-resources { max-width: var(--container-wide, 960px); margin: 0 auto; }

.learn-resources__header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 18px;
}
.learn-resources__title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-resources__lead {
    margin: 4px 0 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-secondary, #8a8680);
}
.learn-resources__empty,
.learn-resources__loading {
    color: var(--text-muted, #5a5650);
    font-size: 0.9rem;
}

.learn-resources__layout {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 24px;
    align-items: start;
}

.learn-resources__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 16px;
}
.learn-resources__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius, 6px);
    background: transparent;
    cursor: pointer;
    transition: var(--transition, 180ms ease);
}
.learn-resources__item:hover {
    background: var(--bg-secondary, #0e0e12);
    border-color: var(--border, #1e1e28);
}
.learn-resources__item.active {
    background: var(--accent-subtle, rgba(201,168,76,0.08));
    border-color: var(--accent, #c9a84c);
}
.learn-resources__item-title {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.9rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-resources__item-kind {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted, #5a5650);
}

.learn-resources__viewer {
    min-width: 0;
    padding: 4px 0;
}
.learn-resources__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle, #20202a);
}
.learn-resources__doc { line-height: 1.6; }

@media (max-width: 768px) {
    .learn-resources__layout { grid-template-columns: 1fr; }
    .learn-resources__list { position: static; }
}

/* --- Course landing: a book's introduction + ordered exercise list ------- */

.learn-course {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    color: var(--text-primary, #d4d0c8);
}

.learn-course__header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 18px;
}
.learn-course__titlewrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.learn-course__lang {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #5a5650);
}
.learn-course__title {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.15;
    color: var(--text-primary, #d4d0c8);
}

.learn-course__begin {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0 0 22px;
}
.learn-course__count {
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
}

/* The rendered prose.md introduction. Inherits the shared `reading` styles
   used by the in-app document viewer; this only sets spacing + a rule below. */
.learn-course__intro {
    line-height: 1.65;
    margin: 0 0 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle, #20202a);
}

.learn-course__exercises-title {
    font-size: 1.05rem;
    margin: 0 0 12px;
    color: var(--text-secondary, #8a8680);
}
.learn-course__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.learn-course__item-link {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius, 6px);
    text-decoration: none;
    transition: var(--transition, 180ms ease);
}
.learn-course__item-link:hover {
    background: var(--bg-secondary, #0e0e12);
    border-color: var(--border, #1e1e28);
}
.learn-course__item-num {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--text-muted, #5a5650);
    white-space: nowrap;
}
.learn-course__item-title {
    flex: 1 1 auto;
    font-size: 0.95rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-course__item-solved {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent, #c9a84c);
    white-space: nowrap;
}
.learn-course__item.is-solved .learn-course__item-title {
    color: var(--text-secondary, #8a8680);
}
.learn-course__empty {
    color: var(--text-muted, #5a5650);
    font-size: 0.9rem;
}

/* Q&A — the no-stakes self-check below the exercise list. Reuses the same
   disclosure pattern as the kata hints so it reads as part of the same book. */
.learn-course__qa {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle, #20202a);
}
.learn-course__qa-title {
    font-size: 1.05rem;
    margin: 0 0 6px;
    color: var(--text-secondary, #8a8680);
}
.learn-course__qa-lead {
    margin: 0 0 16px;
    font-size: 0.875rem;
    color: var(--text-muted, #5a5650);
}
.learn-qa {
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    margin-bottom: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #0e0e12);
}
.learn-qa__q {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-size: 0.95rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-qa__q::-webkit-details-marker { display: none; }
.learn-qa__num {
    flex: 0 0 auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--accent, #c9a84c);
    min-width: 1.2em;
}
.learn-qa__prompt { flex: 1 1 auto; }
.learn-qa__q:hover { background: var(--bg-tertiary, #14141c); }
.learn-qa[open] > .learn-qa__q {
    border-bottom: 1px solid var(--border-subtle, #20202a);
}
.learn-qa__body {
    padding: 12px 14px 14px 38px;
}
.learn-qa__choices {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.learn-qa__choice {
    font-size: 0.9rem;
    color: var(--text-secondary, #8a8680);
    padding: 6px 10px;
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
}
.learn-qa__choice.is-correct {
    color: var(--text-primary, #d4d0c8);
    border-color: var(--accent, #c9a84c);
    background: var(--accent-subtle, rgba(201, 168, 76, 0.08));
}
.learn-qa__answer {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-qa__answer-label {
    display: inline-block;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent, #c9a84c);
    margin-right: 6px;
}

/* ── Guided build tutorial (screens/learn/build.js) ─────────────────────────
 * Mirrors the .learn-* exercise look: a centred reading column, theme-driven
 * colours only, a quiet header, and the same editor / result / solution chrome.
 * The one new element is the pros/cons panel — two labelled blocks, accent for
 * pros and a muted danger hue for cons, distinguished but never alarming. */
.learn-build {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    color: var(--text-primary, #d4d0c8);
}

.learn-build__header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.learn-build__progress {
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
    white-space: nowrap;
}

.learn-build__title {
    font-size: 1.4rem;
    margin: 0;
    line-height: 1.2;
    color: var(--text-primary, #d4d0c8);
}

.learn-build__status,
.learn-build__empty {
    color: var(--text-muted, #5a5650);
    margin: 16px 0;
    line-height: 1.6;
}

/* Intro: a collapsible above the first step. */
.learn-build__intro {
    margin: 0 0 18px;
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    background: var(--bg-secondary, #0e0e12);
}

.learn-build__intro-summary {
    cursor: pointer;
    list-style: none;
    padding: 9px 14px;
    font-size: 0.9rem;
    color: var(--text-secondary, #8a8680);
    user-select: none;
}

.learn-build__intro-summary::-webkit-details-marker { display: none; }

.learn-build__intro-summary::before {
    content: '+';
    display: inline-block;
    width: 1em;
    color: var(--accent, #c9a84c);
    font-weight: 600;
}

.learn-build__intro[open] > .learn-build__intro-summary {
    color: var(--text-primary, #d4d0c8);
    border-bottom: 1px solid var(--border-subtle, #20202a);
}

.learn-build__intro[open] > .learn-build__intro-summary::before {
    content: '\2212';
}

.learn-build__intro-body {
    padding: 12px 16px 4px;
    line-height: 1.6;
}

/* One step. */
.learn-build__step-title {
    font-size: 1.5rem;
    margin: 6px 0 4px;
    line-height: 1.25;
    color: var(--text-primary, #d4d0c8);
}

.learn-build__subject {
    margin: 0 0 14px;
    color: var(--text-secondary, #8a8680);
    font-size: 1.05rem;
    line-height: 1.5;
}

.learn-build__prose {
    margin: 0 0 18px;
    line-height: 1.6;
}

/* Pros / cons panel: two labelled columns, distinct but calm. */
.learn-build__proscons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 0 0 20px;
}

.learn-build__proscons-block {
    border: 1px solid var(--border-subtle, #20202a);
    border-radius: var(--radius, 6px);
    background: var(--bg-secondary, #0e0e12);
    padding: 12px 14px;
}

.learn-build__proscons-block--pros {
    border-top: 2px solid var(--success, #6a9a6a);
}

.learn-build__proscons-block--cons {
    border-top: 2px solid var(--danger, #c07070);
}

.learn-build__proscons-label {
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.learn-build__proscons-block--pros .learn-build__proscons-label {
    color: var(--success, #6a9a6a);
}

.learn-build__proscons-block--cons .learn-build__proscons-label {
    color: var(--danger, #c07070);
}

.learn-build__proscons-body {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-primary, #d4d0c8);
}

.learn-build__proscons-body p:first-child { margin-top: 0; }
.learn-build__proscons-body p:last-child { margin-bottom: 0; }

/* Button row — wraps gracefully when narrow; Download is a quiet secondary. */
.learn-build__controls {
    flex-wrap: wrap;
}

.learn-build__download {
    border-style: dashed;
}

.learn-build__result {
    margin-top: 4px;
}

@media (max-width: 768px) {
    .learn-build__proscons {
        grid-template-columns: 1fr;
    }
}

/* Course landing: the "Build a project" entry link. */
.learn-course__build {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin: 4px 0 18px;
}

.learn-course__build-link {
    font-family: var(--font-sans, sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent, #c9a84c);
    text-decoration: none;
    padding: 6px 0;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.learn-course__build-link:hover {
    border-bottom-color: var(--accent, #c9a84c);
}

.learn-course__build-note {
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
}

/* ── Interactive register reference (asm-registers.js) ──────────────────── */

.learn-reg__header { margin-bottom: 20px; }
.learn-reg__titlewrap { margin-top: 8px; }
.learn-reg__title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 2rem;
    color: var(--text-primary, #d4d0c8);
    margin: 0 0 6px;
}
.learn-reg__lead {
    font-size: 0.95rem;
    color: var(--text-secondary, #8a8680);
    max-width: 60ch;
    line-height: 1.6;
}
.learn-reg__empty { color: var(--text-secondary, #8a8680); }

.learn-reg__layout {
    display: grid;
    grid-template-columns: minmax(210px, 280px) 1fr;
    gap: 24px;
    align-items: start;
}

/* Left: grouped, scrollable nav of every register. */
.learn-reg__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding-right: 4px;
}
.learn-reg__group {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #5a5650);
    margin: 14px 0 4px;
    padding: 0 12px;
}
.learn-reg__group:first-child { margin-top: 0; }

/* Sticky filter box at the top of the (scrolling) nav. */
.learn-reg__filter {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-primary, #08080a);
    padding: 0 0 8px;
}
.learn-reg__filter-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.85rem;
    color: var(--text-primary, #d4d0c8);
    background: var(--bg-secondary, #0e0e12);
    border: 1px solid var(--border, #1e1e28);
    border-radius: var(--radius, 6px);
    padding: 7px 10px;
    transition: var(--transition, 180ms ease);
}
.learn-reg__filter-input::placeholder { color: var(--text-muted, #5a5650); }
.learn-reg__filter-input:focus {
    outline: none;
    border-color: var(--accent, #c9a84c);
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(201,168,76,0.08));
}
.learn-reg__nomatch {
    font-size: 0.85rem;
    color: var(--text-muted, #5a5650);
    padding: 8px 12px;
}
/* The [hidden] attribute is display:none, but .learn-reg__item sets
   display:flex, which would override it — restore hiding for filtered rows. */
.learn-reg__item[hidden],
.learn-reg__group[hidden] { display: none; }
.learn-reg__item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: left;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius, 6px);
    background: transparent;
    cursor: pointer;
    transition: var(--transition, 180ms ease);
}
.learn-reg__item:hover {
    background: var(--bg-secondary, #0e0e12);
    border-color: var(--border, #1e1e28);
}
.learn-reg__item.is-active {
    background: var(--accent-subtle, rgba(201,168,76,0.08));
    border-color: var(--accent, #c9a84c);
}
.learn-reg__item-name {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.92rem;
    color: var(--text-primary, #d4d0c8);
}
.learn-reg__item-tag {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.74rem;
    color: var(--text-muted, #5a5650);
    line-height: 1.35;
}
.learn-reg__item--os .learn-reg__item-name { color: var(--accent, #c9a84c); }

/* Right: the detail pane. */
.learn-reg__pane {
    min-width: 0;
    background: var(--bg-surface, #16161e);
    border: 1px solid var(--border, #1e1e28);
    border-radius: var(--radius-lg, 12px);
    padding: 24px 28px;
}
.learn-reg__detail-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.learn-reg__detail-name {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 1.6rem;
    color: var(--text-primary, #d4d0c8);
    margin: 0;
}
.learn-reg__badge {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm, 3px);
    border: 1px solid transparent;
}
.learn-reg__badge--callee {
    color: var(--success, #4a8a5a);
    border-color: rgba(74,138,90,0.4);
    background: rgba(74,138,90,0.08);
}
.learn-reg__badge--caller {
    color: var(--resonance, #d4a574);
    border-color: rgba(212,165,116,0.4);
    background: rgba(212,165,116,0.08);
}
.learn-reg__detail-tag {
    font-size: 0.95rem;
    color: var(--text-secondary, #8a8680);
    margin: 6px 0 16px;
}
.learn-reg__widths {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}
.learn-reg__widths-label {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #5a5650);
    margin-right: 4px;
}
.learn-reg__width {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.82rem;
    color: var(--text-primary, #d4d0c8);
    background: var(--bg-elevated, #1e1e28);
    border-radius: var(--radius-sm, 3px);
    padding: 2px 7px;
}
.learn-reg__field { margin: 0 0 16px; }
.learn-reg__field-label {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent, #c9a84c);
    margin: 0 0 4px;
}
.learn-reg__field-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary, #d4d0c8);
    margin: 0;
}
.learn-reg__field.is-footgun .learn-reg__field-label { color: var(--error, #cc4444); }
.learn-reg__pinned {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.learn-reg__pinned code {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.82rem;
    color: var(--text-secondary, #8a8680);
    background: var(--bg-secondary, #0e0e12);
    border-radius: var(--radius-sm, 3px);
    padding: 2px 7px;
}
.learn-reg__steps {
    margin: 0 0 14px;
    padding-left: 20px;
    color: var(--text-primary, #d4d0c8);
    line-height: 1.6;
    font-size: 0.95rem;
}
.learn-reg__steps li { margin-bottom: 4px; }
.learn-reg__note {
    font-size: 0.86rem;
    color: var(--text-muted, #5a5650);
    line-height: 1.55;
    margin: 0 0 18px;
}
.learn-reg__tablewrap { overflow-x: auto; margin: 0 0 14px; }
.learn-reg__tablewrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
.learn-reg__tablewrap th {
    text-align: left;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #5a5650);
    background: var(--bg-elevated, #1e1e28);
    padding: 6px 10px;
    white-space: nowrap;
}
.learn-reg__tablewrap td {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    color: var(--text-primary, #d4d0c8);
    padding: 6px 10px;
    border-top: 1px solid var(--border, #1e1e28);
    white-space: nowrap;
}
.learn-reg__tablewrap tr.is-highlight td {
    background: var(--accent-subtle, rgba(201,168,76,0.08));
    color: var(--accent-hover, #dab85c);
}
.learn-reg__code { margin: 0 0 6px; }

@media (max-width: 768px) {
    .learn-reg__layout { grid-template-columns: 1fr; }
    .learn-reg__nav {
        position: static;
        max-height: 320px;
    }
    .learn-reg__pane { padding: 18px; }
}
