/* /learn tutorial pages: layout, prose and runnable code widgets */

/* ========== Text font: Google Sans Flex (OFL), self-hosted variable font, 400-700 ========== */
@font-face {
    font-family: "Google Sans Flex";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/google-sans-flex-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Google Sans Flex";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/google-sans-flex-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Arial resized to Google Sans Flex's metrics, shown until the font arrives,
   so the swap barely moves the text (less layout shift) */
@font-face {
    font-family: "Google Sans Flex Fallback";
    src: local("Arial"), local("ArialMT");
    size-adjust: 100.8%;
    ascent-override: 95.8%;
    descent-override: 28.4%;
    line-gap-override: 0%;
}

body.learn-page {
    font-family: "Google Sans Flex", "Google Sans Flex Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* A touch of tracking makes long body text easier to read */
    letter-spacing: 0.015em;
}

/* Large headings look loose with extra tracking; keep them at the font's default */
.learn-article h1,
.learn-content h2,
.learn-content h3,
.learn-hero h1 {
    letter-spacing: 0;
}

/* Code must stay monospaced-aligned (Ace measures character widths) */
body.learn-page code,
body.learn-page pre,
body.learn-page kbd,
body.learn-page .ace_editor,
body.learn-page .lr-input {
    letter-spacing: normal;
}

body.learn-page {
    /* Light theme: one flat white page like the dark theme (no paper card);
       the sidebar sits on a soft grey panel and the code widgets carry the structure */
    --lr-bg: #ffffff;
    --lr-card: #ffffff;
    --lr-card-border: transparent;
    --lr-panel: #f8f9fa;
    --lr-surface: #ffffff;
    --lr-surface-2: #f1f3f5;
    --lr-code-bg: #ffffff;
    --lr-border: #dde2e8;
    --lr-text: #3c4043;
    --lr-heading: #2d2f31;
    --lr-muted: #5f6368;
    --lr-accent: #0678f4;
    --lr-accent-soft: #e8f1fe;
    --lr-run: #1f9d55;
    --lr-run-hover: #188a49;
    --lr-stop: #d1453b;
    --lr-err: #c62828;
    --lr-info: #6e7781;
    --lr-in: #0b6bcb;
    --lr-inline-code: #eff1f3;
    --lr-inline-code-text: #24292f;
    --lr-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    background: var(--lr-bg);
    color: var(--lr-text);
    overflow-y: auto;
}

/* Dark theme: flat charcoal page, light grey text, bright blue links */
body.learn-page.dark {
    --lr-bg: #1b1e21;
    --lr-card: #1b1e21;
    --lr-card-border: transparent;
    --lr-panel: #212529;
    --lr-surface: #212529;
    --lr-surface-2: #2b3035;
    --lr-code-bg: #181b1f;
    --lr-border: #373b3e;
    --lr-text: #cfd4da;
    --lr-heading: #eef1f4;
    --lr-muted: #adb5bd;
    --lr-accent: #6ea8fe;
    --lr-accent-soft: #2b3035;
    --lr-run: #22a35a;
    --lr-run-hover: #2bb867;
    --lr-stop: #e0574d;
    --lr-err: #ff7b72;
    --lr-info: #8a9199;
    --lr-in: #79c0ff;
    --lr-inline-code: #2b3035;
    --lr-inline-code-text: #e6c07b;
    --lr-shadow: none;
}

body.learn-page.dark .navbar-top {
    border-bottom: 1px solid var(--lr-card-border);
}

/* Flat white page: a hairline keeps the pinned navbar apart from the content */
body.learn-page:not(.dark) .navbar-top {
    border-bottom: 1px solid var(--lr-border);
}

/* ========== Layout ========== */
.learn-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 160px;
    gap: 28px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    align-items: start;
}

.learn-main {
    min-width: 0;
}

/* The lesson sits straight on the page (flat, in both themes) */
.learn-article {
    max-width: 1040px;
    margin: 0 auto;
    padding: 28px 48px 40px;
    background: var(--lr-card);
    border: 1px solid var(--lr-card-border);
    border-radius: 12px;
}

/* ========== Lesson nav (left) ========== */
.learn-nav {
    position: sticky;
    top: 16px;
}

.learn-nav-box {
    background: var(--lr-panel);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
}

.learn-nav-title {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 15px;
    color: var(--lr-text);
    cursor: pointer;
    list-style: none;
}

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

/* Long lesson lists scroll inside the sticky panel */
.learn-nav-scroll {
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding-bottom: 8px;
}

.learn-nav-group+.learn-nav-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--lr-border);
}

.learn-nav-part {
    padding: 8px 18px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lr-info);
}

.learn-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 4px;
}

.learn-nav-list a {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--lr-muted);
    font-size: 15px;
    line-height: 1.35;
    text-decoration: none;
}

.learn-nav-num {
    flex: none;
    min-width: 1.6em;
    color: var(--lr-info);
}

.learn-nav-list a.active .learn-nav-num {
    color: inherit;
}

.learn-nav-list a:hover {
    background: var(--lr-surface-2);
    color: var(--lr-text);
    text-decoration: none;
}

.learn-nav-list a.active {
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 600;
}

/* ========== Ad rail (right) ========== */
/* The rail column itself is sticky (like the lesson nav), so the ad stays
   pinned to the top of the viewport while the lesson scrolls */
.learn-rail {
    position: sticky;
    top: 16px;
}

/* Reserve ad space up front so the page does not shift when the ad loads */
.learn-rail [data-freestar-ad] {
    width: 160px;
    min-height: 600px;
}

/* ========== Article prose ========== */
.learn-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.learn-breadcrumb {
    margin: 0;
    font-size: 14px;
    color: var(--lr-muted);
}

.learn-breadcrumb a {
    color: var(--lr-accent);
}

.learn-theme-toggle {
    border: 1px solid var(--lr-border);
    background: var(--lr-surface);
    color: var(--lr-text);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
}

.learn-article h1 {
    font-size: 40px;
    font-weight: 700;
    margin: 12px 0 20px;
    color: var(--lr-heading);
}

.learn-content {
    font-size: 18px;
    line-height: 1.7;
}

.learn-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 40px 0 12px;
    padding-top: 8px;
    color: var(--lr-heading);
}

.learn-content h3 {
    font-size: 21px;
    font-weight: 600;
    margin: 28px 0 10px;
    color: var(--lr-heading);
}

.learn-content p,
.learn-content ul,
.learn-content ol {
    margin: 0 0 16px;
}

.learn-content a {
    color: var(--lr-accent);
}

.learn-content code {
    font-family: "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.learn-content pre {
    background: var(--lr-panel);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    color: var(--lr-text);
    overflow-x: auto;
}

.learn-content pre code {
    padding: 0;
    background: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Highlighted plain code blocks: Ace wraps the code in a theme div (.ace-tm, .ace-one-dark)
   with its own solid background; let the block's panel colour show through in both themes */
.learn-content pre.lr-static>div,
.learn-content pre.lr-static .ace_static_highlight {
    background: transparent;
    border: 0;
    font-family: inherit;
    /* Fira Mono, from .learn-content pre; Ace sets Menlo/Monaco */
    font-size: 14px;
}

.learn-content table {
    width: 100%;
    margin: 0 0 20px;
    border-collapse: collapse;
    font-size: 16px;
}

.learn-content th,
.learn-content td {
    padding: 8px 12px;
    border: 1px solid var(--lr-border);
    text-align: left;
}

.learn-content th {
    background: var(--lr-surface-2);
}

.learn-content blockquote {
    margin: 0 0 16px;
    padding: 10px 16px;
    border-left: 4px solid var(--lr-accent);
    background: var(--lr-accent-soft);
    border-radius: 0 6px 6px 0;
    font-size: 17px;
}

.learn-content blockquote p:last-child {
    margin-bottom: 0;
}

/* ========== Runnable widget ========== */
.lr-runner {
    margin: 20px 0 28px;
    background: var(--lr-surface);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    box-shadow: var(--lr-shadow);
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
}

.lr-panes {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.lr-editor-pane,
.lr-output-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lr-output-pane {
    position: relative;
    border-left: 1px solid var(--lr-border);
}

.lr-tabs {
    display: flex;
    align-items: stretch;
    background: var(--lr-surface-2);
    border-bottom: 1px solid var(--lr-border);
    height: 32px;
    flex: none;
}

.lr-tab,
.lr-tab-label {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-weight: 600;
    font-size: 13px;
    color: var(--lr-muted);
    background: none;
    border: 0;
    border-right: 1px solid transparent;
    border-left: 1px solid transparent;
}

.lr-tab {
    cursor: pointer;
}

/* answer.py stays hidden until "Show answer" (display:flex above would override [hidden]) */
.lr-tab[hidden] {
    display: none;
}

.lr-tab-label,
.lr-tab.active {
    color: var(--lr-text);
    background: var(--lr-code-bg);
    border-color: var(--lr-border);
    margin-bottom: -1px;
}

.lr-tab:first-child,
.lr-tab-label {
    border-left-color: transparent;
}

/* Copy sits at the right end of each tab strip; on the Output strip, Clear follows it */
.lr-copy,
.lr-clear {
    padding: 0 12px;
    border: 0;
    background: none;
    color: var(--lr-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.lr-copy {
    margin-left: auto;
}

.lr-copy + .lr-clear {
    padding-left: 4px;
}

.lr-copy:hover,
.lr-clear:hover,
.lr-copy.lr-copied {
    color: var(--lr-text);
}

/* Copied: green check */
.lr-copy.lr-copy-ok,
.lr-snippet-copy.lr-copy-ok {
    color: var(--lr-co-success, #1a7f45);
}

.lr-snippet-copy.lr-copy-ok {
    border-color: currentColor;
}

/* Plain code blocks: copy button floating top right, shown on hover/focus (always on touch) */
.lr-snippet {
    position: relative;
}

.lr-snippet-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.lr-snippet:hover .lr-snippet-copy,
.lr-snippet-copy:focus-visible,
.lr-snippet-copy.lr-copied {
    opacity: 1;
}

.lr-snippet-copy:hover,
.lr-snippet-copy.lr-copied {
    color: var(--lr-text);
}

@media (hover: none) {
    .lr-snippet-copy {
        opacity: 1;
    }
}

.learn-content .lr-code,
.learn-content .lr-output {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--lr-code-bg);
}

/* Ace sizes itself (12-30 lines); the output pane stretches to match it */
.learn-content .lr-code {
    flex: none;
    padding: 0;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
}

/* Ace must clip its own gutter; the generic ".learn-content pre" rules would otherwise override it */
.lr-editor-pane {
    overflow: hidden;
}

.learn-content .lr-code.ace_editor {
    overflow: hidden;
    padding: 0;
    border: 0;
    white-space: normal;
    word-break: normal;
}

/* Match the Ace theme background to the widget surface in both themes */
.lr-runner .ace_editor,
.lr-runner .ace_editor .ace_gutter {
    background: var(--lr-code-bg);
}

.lr-runner .ace_editor .ace_gutter {
    color: var(--lr-info);
}

/* Fixed line height: Ace measures its rows from the container's font, so pinning it
   here lets the plain <pre> below reserve exactly the editor's height (no layout shift) */
.learn-content .lr-code,
.learn-content .lr-code.ace_editor {
    font-size: 14px;
    line-height: 18px;
}

/* Before Ace takes over: same rows x line height as the editor will have.
   --lr-rows (12-30) is set per runner by Lesson_markdown.php */
.learn-content pre.lr-code:not(.ace_editor) {
    height: calc(var(--lr-rows, 12) * 18px);
    padding: 0 16px 0 48px;
    white-space: pre;
    overflow: hidden;
}

/* Output is pinned below its tab strip and never taller than the editor:
   long output scrolls instead of stretching the widget */
.learn-content .lr-output {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 14px;
    overflow: auto;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--lr-text);
}

.lr-output .lr-err {
    color: var(--lr-err);
}

.lr-output .lr-info {
    color: var(--lr-info);
    font-style: italic;
}

.lr-output .lr-in {
    color: var(--lr-in);
}

.lr-output .lr-input {
    min-width: 120px;
    width: 50%;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px solid var(--lr-accent);
    outline: none;
    background: transparent;
    color: var(--lr-in);
    font: inherit;
}

.lr-bar {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--lr-surface-2);
    border-top: 1px solid var(--lr-border);
}

.lr-btn {
    height: 28px;
    padding: 0 12px;
    border-radius: 5px;
    border: 1px solid var(--lr-border);
    background: var(--lr-code-bg);
    color: var(--lr-text);
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.lr-btn:hover {
    border-color: var(--lr-muted);
}

.lr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lr-run {
    min-width: 76px;
    background: var(--lr-run);
    border-color: var(--lr-run);
    color: #fff;
}

.lr-run:hover:not(:disabled) {
    background: var(--lr-run-hover);
    border-color: var(--lr-run-hover);
}

.lr-runner.is-running .lr-run {
    background: var(--lr-stop);
    border-color: var(--lr-stop);
}

.lr-run i {
    font-size: 10px;
    margin-right: 4px;
}

/* Exercise bar: Run, Reset, status ... then Hint and Show answer on the right */
.lr-hint-btn {
    margin-left: auto;
}

.lr-hint-btn[hidden]+.lr-show-answer {
    margin-left: auto;
}

.lr-hint-btn i {
    color: #d4a017;
    margin-right: 2px;
}

.lr-status {
    font-size: 13px;
    color: var(--lr-muted);
}

.lr-runner[data-kind="example"] .lr-status {
    margin-left: auto;
}

.lr-status.ok {
    color: var(--lr-run);
}

.lr-status.err {
    color: var(--lr-err);
}

.lr-status.warn {
    color: #c27c0e;
}

/* Spinner while Pyodide downloads and starts (first run can take a few seconds) */
@keyframes lr-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== Landing page ========== */
.learn-hero {
    padding-bottom: 28px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--lr-border);
}

.learn-hero h1 {
    margin-bottom: 12px;
}

.learn-lead {
    font-size: 19px;
    line-height: 1.6;
    color: var(--lr-muted);
    max-width: 720px;
}

.learn-lead code {
    font-family: "Fira Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.learn-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    list-style: none;
    margin: 18px 0 24px;
    padding: 0;
    font-size: 15px;
    color: var(--lr-text);
}

.learn-features i {
    color: var(--lr-run);
    margin-right: 4px;
}

.learn-hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.learn-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 22px;
    border-radius: 8px;
    background: var(--lr-run);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}

.learn-cta:hover,
.learn-cta:focus {
    background: var(--lr-run-hover);
    color: #fff;
    text-decoration: none;
}

.learn-cta-secondary {
    color: var(--lr-accent);
    font-weight: 600;
    font-size: 15px;
}

.learn-stats {
    margin: 18px 0 0;
    font-size: 14px;
    color: var(--lr-muted);
}

.learn-part {
    margin-top: 36px;
}

.learn-part-head {
    margin-bottom: 14px;
}

.learn-part-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lr-accent);
}

.learn-part-head h2 {
    margin: 2px 0 4px;
    font-size: 26px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-part-head p {
    margin: 0;
    font-size: 16px;
    color: var(--lr-muted);
}

.learn-topics {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.learn-topics>li {
    display: flex;
}

.learn-topic {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--lr-surface);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    color: var(--lr-text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}

a.learn-topic:hover {
    border-color: var(--lr-accent);
    color: var(--lr-text);
    text-decoration: none;
    transform: translateY(-1px);
}

.learn-topic-num {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 700;
    font-size: 14px;
}

.learn-topic-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.learn-topic-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-topic-desc {
    font-size: 14px;
    line-height: 1.45;
    color: var(--lr-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.learn-topic.is-soon {
    background: transparent;
    border-style: dashed;
}

.learn-topic.is-soon .learn-topic-num {
    background: var(--lr-surface-2);
    color: var(--lr-info);
}

.learn-topic.is-soon .learn-topic-title {
    color: var(--lr-muted);
    font-weight: 600;
}

.learn-soon {
    font-size: 12px;
    font-weight: 600;
    color: var(--lr-info);
}

/* ========== Prev / Next ========== */
.learn-pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--lr-border);
}

.learn-pager-link {
    display: flex;
    flex-direction: column;
    max-width: 48%;
    padding: 12px 16px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    text-decoration: none;
}

.learn-pager-link:hover {
    border-color: var(--lr-accent);
    text-decoration: none;
}

.learn-pager-link.next {
    margin-left: auto;
    text-align: right;
}

.learn-pager-label {
    font-size: 13px;
    color: var(--lr-muted);
}

.learn-pager-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--lr-accent);
}

/* ========== Responsive ========== */
@media (max-width: 1199px) {
    .learn-layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .learn-rail {
        display: none;
    }
}

@media (max-width: 899px) {
    .learn-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 16px 16px 48px;
    }

    .learn-nav {
        position: static;
    }

    .learn-nav-scroll {
        max-height: 60vh;
    }

    .learn-nav-title::after {
        content: "\25BE";
        float: right;
        color: var(--lr-muted);
    }

    .learn-article {
        padding: 20px 16px 28px;
        border-radius: 10px;
    }

    .learn-article h1 {
        font-size: 32px;
    }
}

@media (max-width: 639px) {
    .lr-panes {
        grid-template-columns: minmax(0, 1fr);
    }

    .lr-output-pane {
        border-left: 0;
        border-top: 1px solid var(--lr-border);
    }

    /* Stacked on phones: the output gets its own fixed height */
    .learn-content .lr-output {
        position: static;
        height: 200px;
    }

    .learn-content {
        font-size: 17px;
    }

    /* Phones: the article card already pads its text, so keep the outer gutter thin */
    .learn-layout {
        padding-left: 6px;
        padding-right: 6px;
    }
}

/* Light text on dark reads heavier; give it a little more room */
body.learn-page.dark .learn-content {
    line-height: 1.75;
}

/* ========== Bottom ad ========== */
.learn-bottom-ad {
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 20px 32px;
    text-align: center;
}

/* In-content unit (336x280): reserve its height so the page does not shift */
/* Cap the width at the placement's largest size (970px). Native ads stretch to fill
   their container; at full page width they grew taller than their iframe and the
   bottom row (sponsor name, AdChoices icon) was clipped. */
.learn-bottom-ad [data-freestar-ad] {
    max-width: 970px;
    min-height: 280px;
    margin: 0 auto;
}

/* ========== Site footer ========== */
.site-footer {
    background: var(--lr-card);
    border-top: 1px solid var(--lr-border);
    color: var(--lr-muted);
    font-size: 15px;
    /* Room for Freestar's sticky footer ad so it never covers the footer */
    padding-bottom: 120px;
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 20px 20px;
}

.site-footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--lr-heading);
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}

.site-footer-logo:hover {
    color: var(--lr-heading);
    text-decoration: none;
}

.site-footer-brand p {
    margin: 6px 0 0;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.site-footer-links a {
    color: var(--lr-muted);
    text-decoration: none;
}

.site-footer-links a:hover {
    color: var(--lr-accent);
    text-decoration: none;
}

.site-footer-copy {
    max-width: 1480px;
    margin: 0 auto;
    padding: 14px 20px 22px;
    border-top: 1px solid var(--lr-border);
    font-size: 13px;
}

@media (max-width: 639px) {
    .site-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Show code characters literally: fallback fonts such as JetBrains Mono would otherwise
   draw ligatures such as == as one long bar and >= as a single symbol */
.learn-page code,
.learn-page pre,
.learn-page kbd,
.lr-runner,
.lr-runner .ace_editor,
.lr-runner .ace_editor * {
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}

/* Divider between runs in the Output pane */
.lr-output .lr-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--lr-info);
    white-space: nowrap;
    user-select: none;
}

.lr-output .lr-sep::before,
.lr-output .lr-sep::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--lr-border);
}

.lr-output .lr-sep::before {
    flex: 0 0 12px;
}

/* ide.css sets a global "pre { min-height: 95% }" for the IDE; on lesson pages it
   made the output (and editor) taller than their pane, hiding the last output line */
.learn-content .lr-code,
.learn-content .lr-output {
    min-height: 0;
}


/* ========== Exercise hints ========== */
body.learn-page {
    --lr-hint-bg: #fff8e1;
    --lr-hint-border: #f3d98b;
    --lr-ok-bg: #e9f7ef;
    --lr-ok-border: #a7dcba;
    --lr-bad-bg: #fdf0ef;
    --lr-bad-border: #f2c0bb;
}

body.learn-page.dark {
    --lr-hint-bg: #2c2a1f;
    --lr-hint-border: #5a5030;
    --lr-ok-bg: #1d2b22;
    --lr-ok-border: #2f5a3c;
    --lr-bad-bg: #2f2020;
    --lr-bad-border: #5c3431;
}

.lr-hint {
    padding: 10px 14px;
    background: var(--lr-hint-bg);
    border-top: 1px solid var(--lr-hint-border);
    font-size: 15px;
    line-height: 1.55;
}

.lr-hint p {
    margin: 4px 0 0;
}

.lr-hint p:first-of-type {
    display: inline;
}

.lr-hint-label {
    display: inline-block;
    margin-right: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #b8860b;
}

body.learn-page.dark .lr-hint-label {
    color: #e0b84a;
}

/* ========== Auto-check feedback ========== */
.lr-feedback {
    padding: 10px 14px;
    border-top: 1px solid var(--lr-border);
    font-size: 15px;
}

.lr-feedback.is-correct {
    background: var(--lr-ok-bg);
    border-top-color: var(--lr-ok-border);
    color: var(--lr-run);
    font-weight: 600;
}

.lr-feedback.is-wrong {
    background: var(--lr-bad-bg);
    border-top-color: var(--lr-bad-border);
}

.lr-feedback.is-wrong .lr-feedback-title {
    color: var(--lr-err);
    font-weight: 600;
}

.lr-feedback-title i {
    margin-right: 4px;
}

.lr-compare {
    margin-top: 6px;
}

.lr-compare summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--lr-muted);
    list-style: none;
    user-select: none;
}

.lr-compare summary::-webkit-details-marker {
    display: none;
}

.lr-compare summary:hover {
    color: var(--lr-heading);
}

/* Chevron: points right when collapsed, down when open */
.lr-compare summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.lr-compare[open] summary::before {
    transform: rotate(45deg) translate(-2px, -2px);
}

/* The input() form only wraps the input for mobile keyboards; keep the layout inline */
.lr-input-form {
    display: contents;
}

.lr-compare-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.lr-compare-label {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--lr-muted);
}

.learn-content .lr-compare pre {
    min-height: 0;
    max-height: 220px;
    margin: 0;
    padding: 8px 10px;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    background: var(--lr-code-bg);
}

@media (max-width: 639px) {
    .lr-compare-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ========== "Going deeper" boxes (optional extras) ========== */
.learn-deeper {
    margin: 20px 0 24px;
    border: 1px dashed var(--lr-border);
    border-radius: 8px;
    background: var(--lr-panel);
}

.learn-deeper>summary {
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--lr-heading);
    cursor: pointer;
}

.learn-deeper>summary i {
    margin-right: 6px;
    color: var(--lr-accent);
}

.learn-deeper-tag {
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font-size: 12px;
    font-weight: 600;
    vertical-align: 2px;
}

.learn-deeper-body {
    padding: 0 16px 6px;
    font-size: 17px;
}

.learn-deeper[open]>summary {
    border-bottom: 1px dashed var(--lr-border);
    margin-bottom: 12px;
}

/* ========== Fixed top navbar on lesson pages ========== */
body.learn-page {
    --learn-nav-h: 40px;
}

body.learn-page .navbar-top {
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Side columns stick just below the navbar instead of sliding under it */
body.learn-page .learn-nav,
body.learn-page .learn-rail {
    top: calc(var(--learn-nav-h) + 16px);
}

body.learn-page .learn-nav-scroll {
    max-height: calc(100vh - var(--learn-nav-h) - 90px);
}

@media (max-width: 899px) {
    body.learn-page .learn-nav-scroll {
        max-height: 60vh;
    }
}

/* Wide reference tables (methods at a glance) scroll sideways on phones
   instead of squeezing their code into unreadable columns */
@media (max-width: 639px) {
    .learn-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .learn-content td code {
        white-space: nowrap;
    }
}

/* In-page links (#section) land below the pinned navbar, not under it */
.learn-content h2[id],
.learn-content h3[id] {
    scroll-margin-top: calc(var(--learn-nav-h) + 16px);
}

/* ========== Community tutorials ========== */
.learn-community-note {
    margin: -6px 0 24px;
    color: var(--lr-muted);
    font-size: 14px;
    line-height: 1.5;
}

.learn-community-note i {
    margin-right: 4px;
}

/* ========== Tutorial editor (/learn/create) ========== */
.lc-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100vh - var(--learn-nav-h));
    height: calc(100dvh - var(--learn-nav-h));
    min-height: 480px;
    padding: 12px 16px 16px;
    color: var(--lr-text);
}

.lc-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
}

.lc-meta {
    flex: 1 1 420px;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.lc-meta input {
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-heading);
    font-family: inherit;
}

.lc-meta input:focus {
    outline: none;
    border-color: var(--lr-accent);
    box-shadow: 0 0 0 3px var(--lr-accent-soft);
}

.lc-meta input.lc-title {
    flex: 2 1 0;
    font-weight: 700;
    font-size: 17px;
}

.lc-meta input.lc-description {
    flex: 3 1 0;
    font-size: 15px;
}

.lc-meta input.invalid {
    border-color: var(--lr-err);
}

.lc-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.lc-size {
    font-size: 13px;
    color: var(--lr-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.lc-size.warn {
    color: #b7791f;
    font-weight: 600;
}

.lc-size.over {
    color: var(--lr-err);
    font-weight: 700;
}

.lc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}

.lc-btn:hover,
.lc-btn:focus {
    color: var(--lr-heading);
    background: var(--lr-surface-2);
    text-decoration: none;
}

.lc-btn-primary,
.lc-btn-primary:focus {
    border-color: transparent;
    background: var(--lr-run);
    color: #fff;
}

.lc-btn-primary:hover {
    background: var(--lr-run-hover);
    color: #fff;
}

.lc-btn[disabled] {
    opacity: 0.6;
    cursor: default;
}

/* Publishing: the paper plane becomes a spinner */
.lc-btn.is-busy i {
    animation: lr-spin 0.8s linear infinite;
}

.lc-btn.is-busy i::before {
    content: "\f110";
}

.lc-tabs {
    display: none;
}

.lc-panes {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.lc-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--lr-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--lr-surface);
}

.lc-toolbar,
.lc-preview-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--lr-border);
    background: var(--lr-panel);
    font-size: 13px;
}

.lc-toolbar-label {
    margin-right: 4px;
    color: var(--lr-muted);
    font-weight: 600;
}

.lc-toolbar button,
.lc-toolbar select {
    height: 28px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--lr-text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.lc-toolbar button:hover {
    border-color: var(--lr-border);
    background: var(--lr-surface);
}

.lc-toolbar select {
    max-width: 150px;
    border-color: var(--lr-border);
    background: var(--lr-surface);
}

.lc-toolbar i {
    margin-right: 2px;
    color: var(--lr-muted);
}

.lc-editor-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
}

.lc-ace,
.lc-source {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.lc-ace.ace_editor {
    font-size: 14px;
    line-height: 20px;
    letter-spacing: normal;
}

/* Hidden until learn-create.js swaps in Ace, so the raw textarea never flashes first;
   shown again if Ace fails to load, or via <noscript> */
.lc-source {
    visibility: hidden;
    padding: 12px;
    border: 0;
    resize: none;
    background: var(--lr-surface);
    color: var(--lr-text);
    font: 14px/20px "Fira Mono", Consolas, Menlo, monospace;
}

.lc-source[hidden] {
    display: none;
}

.lc-preview-head {
    justify-content: space-between;
    padding: 4px 14px;
    font-weight: 600;
    color: var(--lr-muted);
}

.lc-preview-status {
    font-weight: 400;
}

.lc-preview-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--lr-card);
}

.lc-preview-article {
    padding: 24px 28px 40px;
    border: 0;
}

.learn-article h1.lc-preview-title {
    font-size: 32px;
}

.lc-preview-description {
    margin: -6px 0 18px;
    color: var(--lr-muted);
    font-size: 16px;
}

/* Guide drawer */
.lc-guide {
    position: fixed;
    top: var(--learn-nav-h);
    right: 0;
    bottom: 0;
    z-index: 1001;
    width: 620px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--lr-card);
    border-left: 1px solid var(--lr-border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
}

.lc-guide[hidden] {
    display: none;
}

.lc-guide-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--lr-border);
    background: var(--lr-panel);
    color: var(--lr-heading);
}

.lc-guide-head a {
    margin-left: auto;
    font-size: 14px;
    color: var(--lr-accent);
}

.lc-guide-close {
    border: 0;
    background: transparent;
    color: var(--lr-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.lc-guide-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 4px 24px 32px;
}

.lc-guide-scroll .learn-content {
    font-size: 16px;
}

/* Published dialog */
.lc-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
}

.lc-modal[hidden] {
    display: none;
}

.lc-modal-box {
    width: 560px;
    max-width: 100%;
    padding: 22px 24px;
    border-radius: 12px;
    border: 1px solid var(--lr-border);
    background: var(--lr-card);
    color: var(--lr-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.lc-modal-box h2 {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lc-modal-box h2 i {
    color: var(--lr-run);
}

.lc-modal-label {
    display: block;
    margin: 12px 0 6px;
    font-size: 14px;
    font-weight: 600;
}

.lc-copy-row {
    display: flex;
    gap: 6px;
}

.lc-copy-row input {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-panel);
    color: var(--lr-text);
    font-size: 13px;
}

.lc-modal-warn {
    margin: 16px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--lr-hint-border);
    background: var(--lr-hint-bg);
    font-size: 14px;
    line-height: 1.5;
}

.lc-modal-warn i {
    color: #b7791f;
}

.lc-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

/* Phones and small tablets: Write / Preview tabs instead of side by side */
@media (max-width: 899px) {
    .lc-page {
        padding: 8px 6px 10px;
        gap: 8px;
    }

    .lc-meta {
        flex-direction: column;
        flex-basis: 100%;
        gap: 6px;
    }

    .lc-meta input.lc-title,
    .lc-meta input.lc-description {
        flex: none;
    }

    .lc-actions {
        width: 100%;
        margin-left: 0;
    }

    .lc-actions .lc-size {
        margin-right: auto;
    }
}

/* Phones: Guide / View become icon buttons and Save gets its own full-width row */
@media (max-width: 599px) {
    .lc-actions {
        flex-wrap: wrap;
    }

    .lc-actions #lc-publish {
        flex: 1 0 100%;
        justify-content: center;
        height: 40px;
    }

    .lc-tabs {
        display: flex;
        gap: 4px;
    }

    .lc-tab {
        flex: 1;
        height: 34px;
        border: 1px solid var(--lr-border);
        border-radius: 8px;
        background: var(--lr-surface);
        color: var(--lr-muted);
        font-family: inherit;
        font-weight: 600;
    }

    .lc-tab.active {
        border-color: var(--lr-accent);
        background: var(--lr-accent-soft);
        color: var(--lr-accent);
    }

    .lc-panes {
        grid-template-columns: minmax(0, 1fr);
    }

    .lc-panes[data-show="write"] .lc-preview,
    .lc-panes[data-show="preview"] .lc-write {
        display: none;
    }

    .lc-preview-article {
        padding: 16px 12px 28px;
    }

    .lc-guide-scroll {
        padding: 4px 14px 24px;
    }
}

/* Community tutorial pages: no lesson sidebar, just the article and the ad rail */
.learn-layout.no-nav {
    grid-template-columns: minmax(0, 1fr) 160px;
}

@media (max-width: 1199px) {
    .learn-layout.no-nav {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Quiz pages: an ad rail on each side instead of the lesson sidebar (rails hide below 1200px) */
.learn-layout.is-quiz {
    grid-template-columns: 160px minmax(0, 1fr) 160px;
}

@media (max-width: 1199px) {
    .learn-layout.is-quiz {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* The tutorial editor fills the window exactly: no footer, no page scroll.
   The editor, preview and guide scroll inside their own panes. */
/* Pinned below the 40px navbar rather than laid out in the body's flow: ad and anti-adblock
   scripts briefly append elements to <body> while the page loads, and as body flex items
   they squeezed the editor and preview (a flash each time). Fixed, the editor ignores them. */
body.learn-page.learn-create {
    overflow: hidden;
}

body.learn-create .lc-page {
    position: fixed;
    top: var(--learn-nav-h);
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    min-height: 0;
}

/* "Write your own tutorial" banner under the navbar on /learn pages */
.learn-promo {
    border-bottom: 1px solid var(--lr-border);
    background: var(--lr-accent-soft);
    color: var(--lr-text);
}

.learn-promo[hidden] {
    display: none;
}

.learn-promo-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 8px 20px;
    font-size: 14px;
    line-height: 1.4;
}

.learn-promo-icon {
    color: var(--lr-accent);
    font-size: 16px;
}

.learn-promo p {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.learn-promo strong {
    color: var(--lr-heading);
}

.learn-promo-short {
    display: none;
}

.learn-promo-cta {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 14px;
    border-radius: 15px;
    background: var(--lr-accent);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.learn-promo-cta:hover,
.learn-promo-cta:focus {
    color: #fff;
    text-decoration: none;
    filter: brightness(1.08);
}

body.learn-page.dark .learn-promo-cta {
    color: #10161d;
}

.learn-promo-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--lr-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.learn-promo-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--lr-heading);
}

body.learn-page.dark .learn-promo-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 899px) {
    .learn-promo-inner {
        gap: 8px;
        padding: 6px 6px 6px 12px;
        font-size: 13px;
    }

    .learn-promo-icon,
    .learn-promo-long {
        display: none;
    }

    .learn-promo-short {
        display: inline;
    }

    .learn-promo-cta {
        height: 28px;
        padding: 0 12px;
    }
}

/* ========== Editor toasts and bot check (learn-editor-ui.js) ========== */
.le-toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
    max-width: calc(100% - 40px);
}

.le-toasts:empty {
    display: none;
}

.le-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 380px;
    max-width: 100%;
    padding: 12px 10px 12px 14px;
    border: 1px solid var(--lr-border);
    border-left: 4px solid var(--lr-err);
    border-radius: 10px;
    background: var(--lr-card);
    color: var(--lr-text);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    font-size: 14.5px;
    line-height: 1.45;
    animation: le-toast-in 0.18s ease-out;
}

.le-toast p {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.le-toast > i {
    margin-top: 2px;
    font-size: 16px;
    color: var(--lr-err);
}

.le-toast.is-ok {
    border-left-color: var(--lr-run);
}

.le-toast.is-ok > i {
    color: var(--lr-run);
}

.le-toast.is-info {
    border-left-color: var(--lr-border);
}

.le-toast.is-info > i {
    color: var(--lr-muted);
}

.le-toast-close {
    flex: none;
    width: 26px;
    height: 26px;
    margin: -3px 0 -3px 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--lr-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.le-toast-close:hover,
.le-toast-close:focus-visible {
    background: var(--lr-panel);
    color: var(--lr-text);
}

@keyframes le-toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .le-toast {
        animation: none;
    }
}

@media (max-width: 600px) {
    .le-toasts {
        right: 12px;
        bottom: 12px;
        left: 12px;
        max-width: none;
    }

    .le-toast {
        width: auto;
    }
}

/* The dark page and card share a colour: lift floating boxes off it */
body.learn-page.dark .le-toast,
body.learn-page.dark .le-bot-box {
    background: var(--lr-panel);
}

/* The bot check sits off-screen (so Cloudflare can run it unseen) until it needs a click */
.le-bot {
    position: fixed;
    top: 0;
    left: -10000px;
    width: 360px;
}

.le-bot.is-open {
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1150;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
}

.le-bot-box {
    width: 360px;
    max-width: 100%;
    padding: 20px 22px;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-card);
    color: var(--lr-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.le-bot-box h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--lr-heading);
}

.le-bot-box h2 i {
    color: var(--lr-run);
}

.le-bot-box p {
    margin: 0 0 14px;
    color: var(--lr-muted);
    font-size: 14.5px;
}

.le-bot-widget {
    display: flex;
    justify-content: center;
    min-height: 65px;
}

.le-bot-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

/* ========== Callouts: > [!info|success|warning|danger] Title ========== */
body.learn-page {
    --lr-co-info: #0b6bcb;
    --lr-co-info-bg: #e8f1fe;
    --lr-co-success: #1a7f45;
    --lr-co-success-bg: #e9f7ef;
    --lr-co-warning: #a8650a;
    --lr-co-warning-bg: #fff6e0;
    --lr-co-danger: #c62828;
    --lr-co-danger-bg: #fdeeed;
}

body.learn-page.dark {
    --lr-co-info: #79b8ff;
    --lr-co-info-bg: #1b2735;
    --lr-co-success: #56d68b;
    --lr-co-success-bg: #1a2a21;
    --lr-co-warning: #f0b955;
    --lr-co-warning-bg: #2c2717;
    --lr-co-danger: #ff8a80;
    --lr-co-danger-bg: #331f1f;
}

.learn-content .learn-callout {
    --co: var(--lr-co-info);
    --co-bg: var(--lr-co-info-bg);
    margin: 0 0 18px;
    padding: 12px 16px;
    border-left: 4px solid var(--co);
    border-radius: 0 8px 8px 0;
    background: var(--co-bg);
    font-size: 17px;
}

.learn-content .learn-callout-success {
    --co: var(--lr-co-success);
    --co-bg: var(--lr-co-success-bg);
}

.learn-content .learn-callout-warning {
    --co: var(--lr-co-warning);
    --co-bg: var(--lr-co-warning-bg);
}

.learn-content .learn-callout-danger {
    --co: var(--lr-co-danger);
    --co-bg: var(--lr-co-danger-bg);
}

.learn-content .learn-callout-title {
    margin: 0 0 4px;
    color: var(--co);
    font-weight: 700;
}

.learn-content .learn-callout-title::before {
    display: inline-block;
    width: 1.3em;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    content: "\f05a";
    /* info-circle */
}

.learn-content .learn-callout-success .learn-callout-title::before {
    content: "\f058";
    /* check-circle */
}

.learn-content .learn-callout-warning .learn-callout-title::before {
    content: "\f071";
    /* exclamation-triangle */
}

.learn-content .learn-callout-danger .learn-callout-title::before {
    content: "\f06a";
    /* exclamation-circle */
}

.learn-content .learn-callout-body> :last-child {
    margin-bottom: 0;
}

.learn-content .learn-callout-body:empty {
    display: none;
}

.learn-content .learn-callout:has(.learn-callout-body:empty) .learn-callout-title {
    margin-bottom: 0;
}

/* ========== Editor: Insert dropdown menus ========== */
.lc-menu-wrap {
    position: relative;
    display: inline-block;
}

.lc-toolbar .lc-menu-btn .lc-caret {
    margin: 0 0 0 4px;
    font-size: 10px;
}

.lc-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 20;
    min-width: 240px;
    max-height: 60vh;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.lc-menu[hidden] {
    display: none;
}

.lc-toolbar .lc-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 34px;
    padding: 0 10px;
    text-align: left;
    font-size: 14px;
}

.lc-toolbar .lc-menu button:hover,
.lc-toolbar .lc-menu button:focus {
    outline: none;
    border-color: transparent;
    background: var(--lr-surface-2);
}

.lc-toolbar .lc-menu i {
    width: 18px;
    margin: 0;
    text-align: center;
}

.lc-menu-label {
    flex: 1;
}

.lc-menu-syntax {
    color: var(--lr-muted);
    font-family: "Fira Mono", Consolas, Menlo, monospace;
    font-size: 12px;
    white-space: nowrap;
}

.lc-menu-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--lr-border);
}

.lc-toolbar .lc-menu .co-info i {
    color: var(--lr-co-info);
}

.lc-toolbar .lc-menu .co-success i {
    color: var(--lr-co-success);
}

.lc-toolbar .lc-menu .co-warning i {
    color: var(--lr-co-warning);
}

.lc-toolbar .lc-menu .co-danger i {
    color: var(--lr-co-danger);
}

/* ========== Share buttons (end of a lesson / community tutorial) ========== */
.learn-share {
    margin-top: 48px;
    text-align: center;
}

.learn-share+.learn-pager {
    margin-top: 32px;
}

.learn-share-title {
    margin: 0 0 12px;
    color: var(--lr-muted);
    font-size: 17px;
    font-weight: 600;
}

.learn-share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.learn-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.learn-share-btn:hover,
.learn-share-btn:focus-visible {
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
    filter: brightness(1.08);
}

.learn-share-btn.is-linkedin {
    background: #0a66c2;
}

.learn-share-btn.is-x {
    background: #1d9bf0;
}

.learn-share-btn.is-facebook {
    background: #1877f2;
}

.learn-share-btn.is-whatsapp {
    background: #25d366;
}

.learn-share-btn.is-copy,
.learn-share-btn.is-copy:hover,
.learn-share-btn.is-copy:focus-visible {
    background: var(--lr-surface-2);
    color: var(--lr-heading);
}

.learn-share-btn.is-copy.copied {
    background: var(--lr-run);
    color: #fff;
}

.learn-share-copied {
    display: block;
    min-height: 20px;
    margin-top: 8px;
    color: var(--lr-run);
    font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .learn-share-btn {
        transition: none;
    }

    .learn-share-btn:hover,
    .learn-share-btn:focus-visible {
        transform: none;
    }
}

/* Python is loading: a centred spinner over the output area (below the 32px tab bar) */
.lr-loading {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: var(--lr-code-bg);
    color: var(--lr-text);
    text-align: center;
}

.lr-loading[hidden] {
    display: none;
}

.lr-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--lr-border);
    border-top-color: var(--lr-accent);
    border-radius: 50%;
    animation: lr-spin 0.8s linear infinite;
}

.lr-loading-text {
    font-size: 15px;
    font-weight: 600;
}

.lr-loading-note {
    color: var(--lr-muted);
    font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
    .lr-loading-spinner {
        animation-duration: 2s;
    }
}

/* ========== Visualize (runner button + dialog; panel styles come from ide.css) ========== */
.lr-viz i {
    color: var(--lr-accent);
}

.lr-btn[hidden] {
    display: none;
}

body.lv-open {
    overflow: hidden;
}

.lv-dialog {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1200;
    display: flex;
    padding: 24px;
    background: rgba(0, 0, 0, 0.5);
}

.lv-dialog[hidden] {
    display: none;
}

.lv-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-card);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    letter-spacing: normal;
}

.lv-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px 10px 18px;
    border-bottom: 1px solid var(--lr-border);
    background: var(--lr-panel);
    color: var(--lr-heading);
}

.lv-head strong i {
    margin-right: 4px;
    color: var(--lr-accent);
}

.lv-hint {
    flex: 1;
    min-width: 0;
    color: var(--lr-muted);
    font-size: 14px;
}

.lv-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--lr-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.lv-close:hover,
.lv-close:focus-visible {
    background: var(--lr-surface-2);
    color: var(--lr-heading);
}

.lv-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 38fr) minmax(0, 62fr);
}

.lv-code {
    position: relative;
    min-height: 0;
    border-right: 1px solid var(--lr-border);
    background: var(--lr-code-bg);
}

#lv-editor {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: normal;
}

#lv-editor.ace_editor,
#lv-editor .ace_gutter {
    background: var(--lr-code-bg);
}

.lv-viz {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* input() values, asked before recording */
.lv-stdin {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 5;
    padding: 16px 18px;
    border-bottom: 1px solid var(--lr-border);
    background: var(--lr-card);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    color: var(--lr-text);
    font-size: 15px;
}

.lv-stdin[hidden] {
    display: none;
}

.lv-stdin p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.lv-stdin textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-code-bg);
    color: var(--lr-text);
    font: 14px/20px "Fira Mono", Consolas, Menlo, monospace;
    resize: vertical;
}

.lv-stdin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* Phones and small tablets: the code on top, the visualizer below */
@media (max-width: 899px) {
    .lv-dialog {
        padding: 0;
    }

    .lv-box {
        border: 0;
        border-radius: 0;
    }

    .lv-hint {
        display: none;
    }

    .lv-head strong {
        flex: 1;
    }

    .lv-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(120px, 32%) minmax(0, 1fr);
    }

    .lv-code {
        border-right: 0;
        border-bottom: 1px solid var(--lr-border);
    }
}

/* ========== "Write a tutorial" entry points (quiet by design) ========== */
.learn-nav-write {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    border: 1px dashed var(--lr-border);
    border-radius: 8px;
    color: var(--lr-muted);
    font-size: 14px;
    line-height: 1.3;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.learn-nav-write i {
    font-size: 15px;
}

.learn-nav-write strong {
    display: block;
    color: var(--lr-text);
    font-weight: 600;
}

.learn-nav-write small {
    display: block;
    font-size: 12.5px;
}

.learn-nav-write:hover,
.learn-nav-write:focus-visible {
    border-color: var(--lr-accent);
    color: var(--lr-muted);
    text-decoration: none;
}

.learn-nav-write:hover i,
.learn-nav-write:hover strong,
.learn-nav-write:focus-visible i,
.learn-nav-write:focus-visible strong {
    color: var(--lr-accent);
}

/* The lesson list leaves room for the card in the sticky sidebar */
body.learn-page .learn-nav-scroll {
    max-height: calc(100vh - var(--learn-nav-h) - 160px);
}

/* Phones: the sidebar is a collapsed list at the top, so the end-of-lesson line does this job */
@media (max-width: 899px) {
    .learn-nav-write {
        display: none;
    }

    body.learn-page .learn-nav-scroll {
        max-height: 60vh;
    }
}

.learn-write-own {
    margin: 18px 0 0;
    color: var(--lr-muted);
    font-size: 14px;
}

.learn-write-own a {
    color: var(--lr-accent);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .learn-nav-write {
        transition: none;
    }
}

/* Divider (---): Bootstrap draws it #eee, nearly white on the dark theme; use the theme border colour */
body.learn-page.dark .learn-content hr {
    border-top-color: var(--lr-border);
}

/* ========== Quiz (/learn/<slug>/quiz, learn-quiz.js) ========== */
body.learn-page {
    /* Code token colours, as Ace's textmate theme */
    --lq-code-text: #24292f;
    --lq-tok-kw: #0000ff;
    --lq-tok-op: #687687;
    --lq-tok-num: #0000cd;
    --lq-tok-const: #585cf6;
    --lq-tok-str: #036a07;
    --lq-tok-com: #4c886b;
    --lq-tok-fn: #3c4c72;
    --lq-tok-var: #318495;
    --lq-on-accent: #ffffff;
}

body.learn-page.dark {
    /* As Ace's one_dark theme */
    --lq-code-text: #abb2bf;
    --lq-tok-kw: #c678dd;
    --lq-tok-op: #56b6c2;
    --lq-tok-num: #d19a66;
    --lq-tok-const: #d19a66;
    --lq-tok-str: #98c379;
    --lq-tok-com: #7f848e;
    --lq-tok-fn: #61afef;
    --lq-tok-var: #e06c75;
    --lq-on-accent: #10161d;
}

.lq [hidden] {
    display: none !important;
}

/* Bootstrap makes labels bold with a bottom margin */
.lq label {
    font-weight: inherit;
    margin-bottom: 0;
}

.lq code,
.lq-cta code {
    font-family: "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 0.88em;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.lq-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.lq-lead {
    margin: -4px 0 20px;
    font-size: 16px;
    color: var(--lr-muted);
}

.lq-lead a {
    color: var(--lr-accent);
    font-weight: 600;
}

.lq-card {
    background: var(--lr-surface);
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    box-shadow: var(--lr-shadow);
    padding: 20px 22px;
    scroll-margin-top: 80px;
}

/* ----- Start card ----- */
.lq-facts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 15px;
    color: var(--lr-text);
}

.lq-facts i {
    width: 18px;
    color: var(--lr-accent);
    text-align: center;
}

.lq-start-best {
    margin: 14px 0 0;
    color: var(--lr-muted);
}

.lq-start-best i {
    color: #d4a017;
}

.lq-preview-note {
    margin: 0 0 14px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--lr-hint-bg);
    border: 1px solid var(--lr-hint-border);
    font-size: 14px;
}

.lq-noscript {
    margin: 12px 0 0;
    color: var(--lr-err);
}

/* ----- Buttons ----- */
.lq-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.lq-start .lq-actions {
    justify-content: flex-start;
}

.lq-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.lq-btn:hover,
.lq-btn:focus {
    border-color: var(--lr-accent);
    color: var(--lr-text);
    text-decoration: none;
}

.lq-btn-primary,
.lq-btn-primary:hover,
.lq-btn-primary:focus {
    background: var(--lr-accent);
    border-color: var(--lr-accent);
    color: var(--lq-on-accent);
}

.lq-btn-primary:hover {
    filter: brightness(1.08);
}

.lq-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: none;
}

.lq-btn-ghost {
    background: transparent;
}

.lq-skip {
    margin-right: auto;
    border-color: transparent;
    color: var(--lr-muted);
}

/* ----- Question card ----- */
.lq-q {
    min-height: 280px;
}

.lq-q-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--lr-muted);
}

.lq-q-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 600;
}

.lq-progress {
    height: 6px;
    margin: 10px 0 0;
    border-radius: 3px;
    background: var(--lr-surface-2);
    overflow: hidden;
}

.lq-progress>span {
    display: block;
    height: 100%;
    background: var(--lr-accent);
    transition: width 0.3s;
}

.lq-prompt {
    margin: 18px 0 4px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--lr-heading);
    outline: none;
}

.lq-prompt p {
    margin: 0 0 8px;
}

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

.lq-hint {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--lr-muted);
}

/* ----- Code ----- */
.lq pre,
.lq-cta pre {
    word-break: normal;
    word-wrap: normal;
}

.lq-code {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: var(--lr-code-bg);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
    color: var(--lq-code-text);
    white-space: pre;
    overflow-x: auto;
}

.lq-ln {
    display: block;
    min-height: 1.6em;
}

.lq-code .ace_keyword,
.lq-line-code .ace_keyword {
    color: var(--lq-tok-kw);
}

.lq-code .ace_keyword.ace_operator,
.lq-line-code .ace_keyword.ace_operator {
    color: var(--lq-tok-op);
}

.lq-code .ace_constant.ace_numeric,
.lq-line-code .ace_constant.ace_numeric {
    color: var(--lq-tok-num);
}

.lq-code .ace_constant.ace_language,
.lq-line-code .ace_constant.ace_language {
    color: var(--lq-tok-const);
}

.lq-code .ace_string,
.lq-line-code .ace_string {
    color: var(--lq-tok-str);
}

.lq-code .ace_comment,
.lq-line-code .ace_comment {
    color: var(--lq-tok-com);
    font-style: italic;
}

.lq-code .ace_support.ace_function,
.lq-line-code .ace_support.ace_function {
    color: var(--lq-tok-fn);
}

.lq-code .ace_variable.ace_language,
.lq-line-code .ace_variable.ace_language {
    color: var(--lq-tok-var);
}

/* Click the line */
.lq-code.has-lines {
    padding: 6px 0;
}

.lq-code button.lq-ln {
    display: flex;
    width: 100%;
    padding: 1px 14px 1px 0;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    white-space: pre;
    cursor: pointer;
}

.lq-ln-text {
    flex: 1;
    min-width: 0;
    white-space: pre;
}

.lq-lnum {
    flex: none;
    width: 2.6em;
    padding-right: 12px;
    text-align: right;
    color: var(--lr-info);
    user-select: none;
}

.lq-code button.lq-ln:hover {
    background: var(--lr-accent-soft);
}

.lq-code button.lq-ln[aria-pressed="true"] {
    background: var(--lr-accent-soft);
    border-left-color: var(--lr-accent);
}

.lq-code.is-locked button.lq-ln {
    cursor: default;
}

.lq-code button.lq-ln.is-correct {
    background: var(--lr-ok-bg);
    border-left-color: var(--lr-run);
}

.lq-code button.lq-ln.is-wrong {
    background: var(--lr-bad-bg);
    border-left-color: var(--lr-err);
}

.lq-code button.lq-ln.is-missed {
    border-left-color: var(--lr-run);
    /* the right line, not picked: solid like a correct pick */
    background: var(--lr-ok-bg);
}

/* ----- Choices (true/false, single, multi) ----- */
.lq-choices {
    display: grid;
    gap: 8px;
}

.lq-choices.is-tf {
    grid-template-columns: 1fr 1fr;
}

.lq-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 15.5px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.lq-choice:hover {
    border-color: var(--lr-accent);
}

.lq-choice[aria-pressed="true"] {
    border-color: var(--lr-accent);
    background: var(--lr-accent-soft);
    box-shadow: inset 0 0 0 1px var(--lr-accent);
}

.lq-key {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--lr-muted);
}

.lq-choices.is-multi .lq-key {
    border-radius: 4px;
}

.lq-choice[aria-pressed="true"] .lq-key {
    background: var(--lr-accent);
    border-color: var(--lr-accent);
    color: var(--lq-on-accent);
}

.lq-choice-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.lq-choices.is-locked .lq-choice {
    cursor: default;
}

.lq-choice.is-correct {
    border-color: var(--lr-ok-border);
    background: var(--lr-ok-bg);
    box-shadow: inset 0 0 0 1px var(--lr-run);
}

.lq-choice.is-wrong {
    border-color: var(--lr-bad-border);
    background: var(--lr-bad-bg);
    box-shadow: inset 0 0 0 1px var(--lr-err);
}

.lq-choice.is-missed {
    border: 1px dashed var(--lr-run);
    background: var(--lr-ok-bg);
}

.lq-choice.is-correct .lq-key,
.lq-choice.is-missed .lq-key {
    background: var(--lr-run);
    border-color: var(--lr-run);
    color: #fff;
}

.lq-choice.is-wrong .lq-key {
    background: var(--lr-err);
    border-color: var(--lr-err);
    color: #fff;
}

.lq-literal {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    color: inherit;
    white-space: pre-wrap;
}

/* ----- Typed answers ----- */
.lq-input {
    display: block;
    width: 100%;
    max-width: 560px;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-code-bg);
    color: var(--lr-text);
    font-size: 16px;
    /* 16px keeps iOS from zooming in */
    line-height: 1.5;
    resize: vertical;
}

.lq-input:focus,
.lq-blank-input:focus {
    outline: 2px solid var(--lr-accent-soft);
    border-color: var(--lr-accent);
}

.lq-mono {
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 15px;
}

.lq-input.is-correct,
.lq-blank-input.is-correct {
    border-color: var(--lr-run);
    background: var(--lr-ok-bg);
}

.lq-input.is-wrong,
.lq-blank-input.is-wrong {
    border-color: var(--lr-err);
    background: var(--lr-bad-bg);
}

.lq-output-answer {
    max-width: 560px;
}

.lq-output-label {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lr-muted);
}

/* ----- Fill in the blanks ----- */
.lq-blanks.is-code .lq-code {
    line-height: 2.3;
}

.lq-blanks-text {
    font-size: 16px;
    line-height: 2.4;
}

.lq-slot {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    min-height: 32px;
    margin: 0 2px;
    border-radius: 6px;
    line-height: 1.4;
}

.lq-slot-drop {
    flex: 1;
    min-height: 30px;
    padding: 0 8px;
    border: 1.5px dashed var(--lr-muted);
    border-radius: 6px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font: inherit;
    /* the gap's width is set in ch of the surrounding text */
    cursor: pointer;
}

.is-armed .lq-slot-drop,
.is-armed .lq-group-name {
    border-color: var(--lr-accent);
    background: var(--lr-accent-soft);
}

.lq-slot.is-over,
.lq-bank.is-over,
.lq-group.is-over,
.lq-order-list.is-over {
    outline: 2px solid var(--lr-accent);
    outline-offset: 2px;
}

/* Right or wrong shows on the chip or text box in the gap */
.lq-slot.is-correct .lq-chip,
.lq-slot.is-correct .lq-blank-input {
    border-color: var(--lr-run);
    background: var(--lr-ok-bg);
    box-shadow: none;
}

.lq-slot.is-wrong .lq-chip,
.lq-slot.is-wrong .lq-blank-input {
    border-color: var(--lr-err);
    background: var(--lr-bad-bg);
    box-shadow: none;
}

/* One even 2px border (border + shadow ring rendered unevenly); padding trimmed 1px so the chip keeps its size */
.lq-slot.is-correct .lq-chip,
.lq-slot.is-wrong .lq-chip {
    border-width: 2px;
    padding: 2px 11px;
}

.lq-slot.is-correct .lq-blank-input,
.lq-slot.is-wrong .lq-blank-input {
    border-width: 2px;
}

.lq-blank-input {
    min-height: 30px;
    padding: 2px 6px;
    border: 1px solid var(--lr-border);
    border-bottom: 2px solid var(--lr-muted);
    border-radius: 4px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 15px;
    line-height: 1.4;
}

.lq-drop-hint {
    font-size: 12px;
}

/* ----- Chips (blanks, match, groups) ----- */
.lq-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin: 0;
    padding: 3px 12px;
    border: 1px solid var(--lr-border);
    border-radius: 999px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 14.5px;
    line-height: 1.3;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.lq-chip.is-code,
.lq-blanks.is-code .lq-chip {
    border-radius: 6px;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
}

.lq-chip:hover {
    border-color: var(--lr-accent);
}

.lq-chip[aria-pressed="true"] {
    border-color: var(--lr-accent);
    background: var(--lr-accent-soft);
    box-shadow: 0 0 0 2px var(--lr-accent);
}

.lq-chip.is-dragging {
    opacity: 0.35;
}

.lq-chip.is-static {
    cursor: default;
    box-shadow: none;
    touch-action: auto;
}

.is-locked .lq-chip {
    cursor: default;
}

.lq-chip.is-correct {
    border-color: var(--lr-run);
    background: var(--lr-ok-bg);
}

.lq-chip.is-wrong {
    border-color: var(--lr-err);
    background: var(--lr-bad-bg);
}

.lq-bank {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    min-height: 54px;
    margin-top: 16px;
    padding: 10px;
    border: 1px dashed var(--lr-border);
    border-radius: 10px;
    background: var(--lr-panel);
}

.lq-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2000;
    margin: 0;
    list-style: none;
    pointer-events: none;
    opacity: 0.92;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* ----- Match ----- */
.lq-match-rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.lq-match-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
}

.lq-match .lq-slot {
    display: flex;
    min-height: 36px;
    margin: 0;
}

.lq-match .lq-slot-drop {
    min-height: 34px;
}

/* ----- Groups ----- */
.lq-groups {
    display: grid;
    grid-template-columns: repeat(var(--lq-cols, 2), minmax(0, 1fr));
    gap: 10px;
}

.lq-group {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    min-height: 130px;
    padding: 6px 8px 10px;
    border: 1.5px dashed var(--lr-border);
    border-radius: 10px;
    background: var(--lr-panel);
}

.lq-group-name {
    flex-basis: 100%;
    padding: 4px 6px 6px;
    border: 0;
    border-bottom: 1px solid var(--lr-border);
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--lr-heading);
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

/* ----- Arrange the code ----- */
.lq-order-label {
    margin: 4px 0 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lr-muted);
}

.lq-order-label+.lq-order-list+.lq-order-label {
    margin-top: 14px;
}

.lq-order-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 56px;
    margin: 0;
    padding: 6px;
    border: 1.5px dashed var(--lr-border);
    border-radius: 10px;
    background: var(--lr-panel);
}

.lq-order-empty {
    padding: 10px;
    text-align: center;
    font-size: 13px;
    color: var(--lr-muted);
}

.lq-line {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-code-bg);
    overflow: hidden;
}

.lq-grip {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    border-right: 1px solid var(--lr-border);
    color: var(--lr-info);
    cursor: grab;
    touch-action: none;
}

.lq-line-code {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    border: 0;
    background: transparent;
    color: var(--lq-code-text);
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    white-space: pre;
    overflow-x: auto;
    cursor: pointer;
}

.lq-line-ctl {
    flex: none;
    display: flex;
}

.lq-line-btn {
    width: 38px;
    border: 0;
    border-left: 1px solid var(--lr-border);
    background: transparent;
    color: var(--lr-muted);
    cursor: pointer;
}

.lq-line-btn:hover:not(:disabled) {
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
}

.lq-line-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.lq-line.is-dragging {
    opacity: 0.35;
}

.lq-order.is-locked .lq-grip,
.lq-order.is-locked .lq-line-code {
    cursor: default;
}

.lq-line.is-correct {
    border-color: var(--lr-run);
    box-shadow: inset 3px 0 0 var(--lr-run);
}

.lq-line.is-wrong {
    border-color: var(--lr-err);
    box-shadow: inset 3px 0 0 var(--lr-err);
}

/* ----- Code challenge ----- */
.lq-runner .lr-runner {
    margin: 4px 0 0;
}

.lq-runner.is-locked .lr-reset {
    display: none;
}

/* ----- Feedback ----- */
.lq-feedback {
    margin-top: 16px;
    padding: 12px 16px;
    border: 1px solid var(--lr-border);
    border-radius: 10px;
    font-size: 15px;
}

/* Kept in the accessibility tree while empty, so its result is announced when it fills */
.lq-feedback:empty {
    margin: 0;
    padding: 0;
    border: 0;
}

.lq-feedback.is-correct {
    background: var(--lr-ok-bg);
    border-color: var(--lr-ok-border);
}

.lq-feedback.is-wrong {
    background: var(--lr-bad-bg);
    border-color: var(--lr-bad-border);
}

.lq-feedback.is-skipped {
    background: var(--lr-surface-2);
}

.lq-feedback.is-near {
    background: var(--lr-hint-bg);
    border-color: var(--lr-hint-border);
}

.lq-feedback.is-near .lq-fb-title {
    color: #9a6700;
}

body.learn-page.dark .lq-feedback.is-near .lq-fb-title {
    color: #e3b341;
}

/* Right apart from spacing or quote marks */
.lq-near-note {
    margin: 4px 0 8px;
    font-size: 14.5px;
    color: var(--lr-muted);
}

.lq-near-note p {
    margin: 0 0 6px;
}

.lq-near-note i {
    color: var(--lr-info);
}

.lq-input.is-near-correct {
    border-color: var(--lr-run);
    background: var(--lr-ok-bg);
}

.lq-input.is-near {
    border-color: var(--lr-hint-border);
    background: var(--lr-hint-bg);
}

.lq-fb-title {
    margin: 0 0 6px;
    font-weight: 700;
    font-size: 16px;
}

.lq-feedback.is-correct .lq-fb-title {
    color: var(--lr-run);
}

.lq-feedback.is-wrong .lq-fb-title {
    color: var(--lr-err);
}

.lq-fb-explain p {
    margin: 6px 0;
}

.lq-fb-review {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-weight: 600;
    color: var(--lr-accent);
}

.lq-fb-review .fa-external-link-alt {
    font-size: 11px;
}

.lq-note {
    margin: 8px 0 0;
    font-size: 14px;
    color: var(--lr-err);
}

.lq-answer-block {
    margin: 8px 0;
}

.lq-answer-label {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--lr-muted);
}

.lq-answer-block .lq-code {
    margin: 0;
}

.lq-pre {
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-code-bg);
    color: var(--lq-code-text);
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    white-space: pre-wrap;
}

.lq-inline-pre {
    display: inline-block;
}

.lq-answer-text {
    margin: 0;
}

.lq-answer-pairs {
    margin: 0;
    padding-left: 18px;
}

.lq-answer-pairs li,
.lq-answer-group {
    margin: 4px 0;
}

.lq-answer-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* ----- Results ----- */
.lq-score {
    display: flex;
    align-items: center;
    gap: 20px;
}

.lq-ring {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: conic-gradient(var(--lr-accent) calc(var(--p, 0) * 1%), var(--lr-surface-2) 0);
}

.lq-ring.is-pass {
    background: conic-gradient(var(--lr-run) calc(var(--p, 0) * 1%), var(--lr-surface-2) 0);
}

.lq-ring::before {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--lr-surface);
}

.lq-ring span {
    position: relative;
    font-size: 22px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lq-score-line {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--lr-heading);
    outline: none;
}

.lq-score-msg,
.lq-score-best {
    margin: 0;
    color: var(--lr-muted);
}

.lq-newbest {
    margin: 6px 0 0;
    font-weight: 700;
    color: #b7791f;
}

body.learn-page.dark .lq-newbest {
    color: #e3b341;
}

.lq-review-sections {
    --lq-review-ink: #7a6322;
    margin: 18px 0 0;
    padding: 12px 16px;
    border: 1px solid var(--lr-hint-border);
    border-radius: 10px;
    background: var(--lr-hint-bg);
}

body.learn-page.dark .lq-review-sections {
    --lq-review-ink: #d8c38a;
}

.lq-review-sections h3,
.lq-review h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--lr-heading);
}

/* Softer than the page headings: a warm tone that sits on the yellow box */
.lq-review-sections h3 {
    font-weight: 600;
    color: var(--lq-review-ink);
}

.lq-review-sections ul {
    margin: 0;
    padding-left: 20px;
    color: var(--lq-review-ink);
}

.lq-review-sections a {
    color: var(--lr-accent);
    font-weight: 600;
}

.lq-results-actions {
    justify-content: flex-start;
}

.lq-review {
    margin-top: 24px;
}

.lq-review h3 {
    font-size: 17px;
}

.lq-review-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--lr-border);
    font-size: 16px;
}

.lq-review-list>li {
    border-bottom: 1px solid var(--lr-border);
}

.lq-review-list summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 4px;
    list-style: none;
    cursor: pointer;
}

.lq-review-list summary::-webkit-details-marker {
    display: none;
}

.lq-review-list .is-correct summary>i {
    color: var(--lr-run);
}

.lq-review-list .is-wrong summary>i {
    color: var(--lr-err);
}

.lq-review-list .is-skipped summary>i {
    color: var(--lr-info);
}

.lq-review-num {
    color: var(--lr-muted);
}

.lq-review-prompt {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lq-review-type {
    flex: none;
    font-size: 13px;
    color: var(--lr-muted);
}

.lq-review-body {
    padding: 4px 4px 16px;
}

/* A copy to read: nothing in it reacts */
.lq-review-body button,
.lq-review-body input,
.lq-review-body textarea {
    pointer-events: none;
}

/* ----- What this quiz covers ----- */
.lq-covers {
    margin-top: 32px;
}

.lq-covers h2 {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lq-covers ul {
    margin: 0;
    padding-left: 20px;
    columns: 2;
    column-gap: 32px;
}

.lq-covers li {
    margin: 0 0 6px;
    break-inside: avoid;
}

.lq-covers a {
    color: var(--lr-accent);
}

.lq-covers .fa-external-link-alt {
    font-size: 10px;
    opacity: 0.7;
}

/* "Leave the quiz?" dialog (learn-quiz.js confirmLeave) */
.lq-leave {
    width: calc(100% - 32px);
    max-width: 440px;
    padding: 0;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-surface);
    color: var(--lr-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.lq-leave::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.lq-leave-body {
    padding: 20px 22px;
}

.lq-leave-title {
    margin: 0 0 8px;
    font-size: 19px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lq-leave-text {
    margin: 0 0 16px;
    font-size: 15px;
    color: var(--lr-muted);
}

.lq-leave-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lq-leave-actions .lq-btn {
    width: 100%;
}

/* ----- "Test yourself" card at the end of a lesson ----- */
.lq-cta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 40px 0 8px;
    padding: 18px 20px;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--lr-accent-soft), var(--lr-surface) 70%);
}

.lq-cta-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--lr-accent);
    color: var(--lq-on-accent);
    font-size: 20px;
}

.lq-cta-body {
    min-width: 0;
}

.lq-cta-label {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lr-accent);
}

.lq-cta-title {
    margin: 2px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lq-cta-meta {
    margin: 0;
    font-size: 14px;
    color: var(--lr-muted);
}

.lq-cta-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    min-height: 44px;
    padding: 0 20px;
    border-radius: 8px;
    background: var(--lr-run);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.lq-cta-btn:hover,
.lq-cta-btn:focus {
    background: var(--lr-run-hover);
    color: #fff;
    text-decoration: none;
}

.lq-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font-size: 12px;
    font-weight: 700;
    vertical-align: 1px;
}

/* Shown only once there is a best score (the inline-block above would override [hidden]) */
.lq-badge[hidden] {
    display: none;
}

.lq-badge.is-pass {
    background: var(--lr-ok-bg);
    color: var(--lr-run);
}

/* Quiz link on the curriculum cards: a sibling of the card link, pinned to its corner */
.learn-topics>li.has-quiz {
    position: relative;
}

.learn-topics>li.has-quiz .learn-topic {
    padding-bottom: 36px;
}

.learn-topic-quiz {
    position: absolute;
    right: 10px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--lr-accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.learn-topic-quiz:hover,
.learn-topic-quiz:focus {
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    text-decoration: none;
}

@media (max-width: 639px) {
    .lq-card {
        padding: 16px 14px;
    }

    .lq-prompt {
        font-size: 17px;
    }

    .lq-actions .lq-check,
    .lq-actions .lq-next {
        flex: 1;
    }

    .lq-match-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .lq-groups {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .lq-score {
        gap: 14px;
    }

    .lq-ring {
        width: 80px;
        height: 80px;
    }

    .lq-covers ul {
        columns: 1;
    }

    .lq-cta {
        flex-wrap: wrap;
    }

    .lq-cta-btn {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }

    .lq-results-actions .lq-btn {
        flex: 1 1 100%;
    }
}

@media (prefers-reduced-motion: reduce) {

    .lq-progress>span,
    .lq-choice {
        transition: none;
    }
}

/* ========== Quiz builder (/learn/quiz/create, learn-quiz-builder.js) ========== */
.lqb {
    max-width: 1480px;
    margin: 0 auto;
    padding: 20px 20px 48px;
    color: var(--lr-text);
}

.lqb-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.lqb-head h1 {
    margin: 2px 0 4px;
    font-size: 30px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lqb-sub {
    margin: 0;
    max-width: 720px;
    color: var(--lr-muted);
}

/* margin-left: auto keeps the buttons on the right when they wrap below the title */
.lqb-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}

/* Phones: a row of icon buttons, then Publish / Save across the full width */
@media (max-width: 639px) {
    .lqb-head-actions {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }

    .lqb-head-actions .learn-theme-toggle {
        width: 42px;
        height: 42px;
    }

    .lqb-head-actions #lqb-publish {
        flex: 1 0 100%;
    }
}

/* Editor toolbars on phones: the less-used buttons keep only their icon (the label is in aria-label) */
@media (max-width: 639px) {
    .lc-btn-compact .lc-btn-text {
        display: none;
    }

    .lc-btn-compact.lc-btn {
        width: 34px;
        padding: 0;
        justify-content: center;
    }

    .lc-btn-compact.lq-btn {
        width: 42px;
        padding: 0;
    }
}

.lqb-meta {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 170px;
    gap: 12px;
    margin-bottom: 14px;
}

.lqb-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0 0 14px;
    font-weight: normal;
}

.lqb-meta .lqb-field {
    margin: 0;
}

.lqb-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lqb-label em {
    font-weight: normal;
    color: var(--lr-muted);
}

.lqb-hint {
    font-size: 12.5px;
    color: var(--lr-muted);
}

.lqb .lq-input {
    max-width: none;
    min-height: 38px;
    padding: 7px 10px;
    font-size: 15px;
}

.lqb textarea.lq-input {
    resize: vertical;
}

.lqb .lq-input.lq-mono {
    font-size: 14px;
    line-height: 1.5;
}

.lqb-alert {
    margin: 0 0 14px;
    color: var(--lr-text);
    padding: 10px 14px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    font-size: 14.5px;
}

.lqb-alert p {
    margin: 0;
    font-weight: 600;
}

.lqb-alert ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.lqb-alert.is-err {
    background: var(--lr-bad-bg);
    border-color: var(--lr-bad-border);
}

.lqb-alert[hidden] {
    display: none;
}

.lqb-main {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.lqb-list-pane,
.lqb-editor-pane,
.lqb-preview-pane {
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-surface);
}

.lqb-list-pane,
.lqb-preview-pane {
    position: sticky;
    top: calc(var(--learn-nav-h, 40px) + 12px);
}

.lqb-preview-pane {
    padding: 0 14px 14px;
    max-height: calc(100vh - var(--learn-nav-h, 40px) - 24px);
    overflow-y: auto;
}

.lqb-pane-head {
    padding: 10px 14px;
    border-bottom: 1px solid var(--lr-border);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--lr-muted);
}

.lqb-preview-pane .lqb-pane-head {
    margin: 0 -14px 14px;
}

.lqb-count {
    display: inline-block;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    text-align: center;
}

.lqb-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.lqb-item {
    border-radius: 8px;
}

.lqb-item.is-selected {
    background: var(--lr-accent-soft);
}

.lqb-item.has-error .lqb-item-num {
    background: var(--lr-err);
    color: #fff;
}

.lqb-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    border: 0;
    background: transparent;
    color: var(--lr-text);
    text-align: left;
    font-size: 14px;
}

.lqb-item-main i {
    width: 16px;
    color: var(--lr-accent);
    text-align: center;
}

.lqb-item-num {
    flex: none;
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--lr-surface-2);
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

.lqb-item-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lqb-item-tools {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    padding: 0 6px 6px;
}

.lqb-tool {
    width: 30px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--lr-muted);
}

.lqb-tool:hover:not(:disabled) {
    border-color: var(--lr-border);
    background: var(--lr-surface);
    color: var(--lr-accent);
}

.lqb-tool.is-danger:hover:not(:disabled) {
    color: var(--lr-err);
}

.lqb-tool:disabled {
    opacity: 0.3;
}

.lqb-empty {
    padding: 14px 8px;
    font-size: 14px;
    color: var(--lr-muted);
}

.lqb-add {
    padding: 10px;
    border-top: 1px solid var(--lr-border);
}

.lqb-add-btn {
    width: 100%;
}

.lqb-types {
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.lqb [hidden],
.lqb-types[hidden] {
    display: none !important;
}

.lqb-type {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-text);
    text-align: left;
}

.lqb-type:hover {
    border-color: var(--lr-accent);
}

.lqb-type i {
    width: 18px;
    color: var(--lr-accent);
    text-align: center;
}

.lqb-type strong {
    display: block;
    font-size: 13.5px;
}

.lqb-type em {
    display: block;
    font-size: 12px;
    font-style: normal;
    color: var(--lr-muted);
}

.lqb-editor {
    padding: 14px 16px 4px;
}

.lqb-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--lr-muted);
}

.lqb-placeholder {
    padding: 48px 16px;
    text-align: center;
    color: var(--lr-muted);
}

.lqb-placeholder i {
    font-size: 32px;
    color: var(--lr-accent);
}

.lqb-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 14px;
}

.lqb-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lqb-row .lq-input {
    flex: 1;
    min-width: 0;
}

.lqb-row input[type="radio"],
.lqb-row input[type="checkbox"] {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
}

.lqb-arrow {
    color: var(--lr-muted);
}

.lqb-gap-num {
    flex: none;
    width: 52px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lr-muted);
}

.lqb-small {
    align-self: flex-start;
    min-height: 32px;
    padding: 0 12px;
    font-size: 13.5px;
}

.lqb-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px dashed var(--lr-border);
    border-radius: 8px;
}

.lqb-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: normal;
}

.lqb-select {
    max-width: 320px;
}

.lqb-line-picker {
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-code-bg);
    padding: 4px 0;
}

.lqb-line-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 2px 10px;
    font-weight: normal;
    cursor: pointer;
}

.lqb-line-row:hover {
    background: var(--lr-accent-soft);
}

.lqb-line-num {
    width: 22px;
    font-size: 12px;
    color: var(--lr-info);
    text-align: right;
}

.lqb-line-row code {
    padding: 0;
    background: none;
    color: var(--lq-code-text);
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 13.5px;
    white-space: pre;
}

.lqb-preview-card {
    min-height: 0;
    box-shadow: none;
}

.lqb-preview-note {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed var(--lr-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--lr-muted);
}

.lqb-dialog {
    width: calc(100% - 32px);
    max-width: 640px;
    padding: 0;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-surface);
    color: var(--lr-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.lqb-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.lqb-dialog-body {
    padding: 20px 22px;
}

.lqb-dialog h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--lr-heading);
}

.lqb-dialog h2 .fa-check-circle {
    color: var(--lr-run);
}

.lqb-dialog p {
    color: var(--lr-muted);
}

.lqb-dialog textarea {
    width: 100%;
    max-width: none;
}

.lqb-dialog-error {
    margin: 8px 0 0;
    color: var(--lr-err) !important;
}

.lqb-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.lqb-link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.lqb-link-row input {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-code-bg);
    color: var(--lr-text);
    font-size: 14px;
}

.lqb-warn {
    padding: 8px 12px;
    border: 1px solid var(--lr-hint-border);
    border-radius: 8px;
    background: var(--lr-hint-bg);
    color: var(--lr-text) !important;
    font-size: 14px;
}

@media (max-width: 1199px) {
    .lqb-main {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .lqb-preview-pane {
        grid-column: 2;
        position: static;
        max-height: none;
    }
}

@media (max-width: 899px) {

    .lqb-main,
    .lqb-meta {
        grid-template-columns: minmax(0, 1fr);
    }

    .lqb-list-pane,
    .lqb-preview-pane {
        position: static;
        grid-column: auto;
    }

    .lqb-list {
        max-height: 260px;
    }
}

/* Community quiz page */
.lq-community-tag {
    margin: 0 0 -6px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lr-accent);
}

.lq-make-own {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 28px 0 0;
    padding: 14px 18px;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    background: var(--lr-panel);
}

.lq-make-own p {
    margin: 0;
    max-width: 560px;
}

/* Quiz builder: per-question Validate and the guide drawer */
.lqb-editor-head {
    flex-wrap: wrap;
    gap: 8px;
}

.lqb-editor-tools {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.lqb-editor-num {
    margin-left: 8px;
}

.lqb-validate {
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    font-size: 14px;
}

.lqb-validate.is-ok {
    background: var(--lr-ok-bg);
    border-color: var(--lr-ok-border);
}

.lqb-validate.is-err {
    background: var(--lr-bad-bg);
    border-color: var(--lr-bad-border);
}

.lqb-validate-title {
    margin: 0;
    font-weight: 700;
}

.lqb-validate.is-ok .lqb-validate-title {
    color: var(--lr-run);
}

.lqb-validate.is-err .lqb-validate-title {
    color: var(--lr-err);
}

.lqb-validate ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.lqb-validate ul.lqb-tips {
    list-style: none;
    padding-left: 0;
    color: var(--lr-muted);
}

.lqb-tips i {
    color: #d4a017;
}

.lqb-guide {
    z-index: 1500;
}

.lqb-guide-all {
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 13px;
    padding: 2px 10px;
}

.lqb-guide .lc-guide-head a {
    margin-left: auto;
}

.lqb-guide-all+a {
    margin-left: 0;
}

/* Quiz pages: Freestar's sticky footer ad sometimes renders without a background and overlaps
   the quiz buttons; give its container one, and leave room below the quiz to scroll past it */
body.learn-quiz .background-inscreen-display {
    background-color: rgba(247, 247, 247, 0.9);
}

/* ========== Lesson search (learn/_search.php + learn-search.js) ========== */
.ls {
    position: relative;
    margin: 0 0 12px;
}

.ls-field {
    position: relative;
    display: flex;
    align-items: center;
}

.ls-icon {
    position: absolute;
    left: 12px;
    color: var(--lr-muted);
    font-size: 13px;
    pointer-events: none;
}

.ls-input {
    width: 100%;
    height: 38px;
    padding: 0 34px 0 34px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    color: var(--lr-text);
    font-size: 14px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.ls-input::placeholder {
    color: var(--lr-muted);
    opacity: 1;
}

.ls-input:focus {
    border-color: var(--lr-accent);
    box-shadow: 0 0 0 3px var(--lr-accent-soft);
}

.ls-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.ls-key {
    position: absolute;
    right: 10px;
    min-width: 18px;
    padding: 0 5px;
    border: 1px solid var(--lr-border);
    border-radius: 4px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font-size: 11px;
    line-height: 16px;
    text-align: center;
    box-shadow: none;
    pointer-events: none;
}

.ls-input:focus ~ .ls-key {
    display: none;
}

.ls-hero {
    max-width: 620px;
    margin: 20px 0 4px;
}

.ls-hero .ls-input {
    height: 50px;
    padding-left: 44px;
    font-size: 17px;
    border-radius: 10px;
    box-shadow: var(--lr-shadow);
}

.ls-hero .ls-icon {
    left: 16px;
    font-size: 16px;
}

.ls-hero .ls-key {
    right: 14px;
}

/* The results dropdown */
.ls-pop {
    position: absolute;
    z-index: 1100;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 280px;
    max-height: min(440px, 70vh);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--lr-border);
    border-radius: 10px;
    background: var(--lr-surface);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

.ls-pop[hidden],
.ls-empty[hidden] {
    display: none;
}

/* The sidebar is narrow: let its dropdown grow over the page */
.learn-nav .ls-pop {
    right: auto;
    width: min(420px, calc(100vw - 32px));
}

.ls-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ls-row {
    position: relative;
    border-radius: 7px;
}

.ls-row + .ls-row:not(.is-section) {
    margin-top: 4px;
    border-top: 1px solid var(--lr-border);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.ls-go {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--lr-text);
    text-decoration: none;
}

.ls-go:hover,
.ls-go:focus {
    color: var(--lr-text);
    text-decoration: none;
}

.ls-row.is-active > .ls-go,
.ls-go:hover {
    background: var(--lr-accent-soft);
}

.ls-row:not(.is-section) > .ls-go {
    padding-right: 72px;
}

.ls-title {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: var(--lr-heading);
}

.ls-num {
    margin-right: 6px;
    color: var(--lr-muted);
    font-weight: 500;
}

.ls-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--lr-muted);
}

.ls-row.is-section > .ls-go {
    padding: 6px 10px 6px 30px;
    font-size: 14px;
}

.ls-hash {
    margin-right: 6px;
    color: var(--lr-accent);
    font-weight: 700;
}

.ls-row.is-active .ls-head {
    color: var(--lr-accent);
}

.ls-go mark {
    padding: 0;
    background: transparent;
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--lr-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.ls-quiz {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border: 1px solid var(--lr-border);
    border-radius: 999px;
    color: var(--lr-muted);
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.ls-quiz:hover,
.ls-quiz:focus {
    border-color: var(--lr-accent);
    color: var(--lr-accent);
    text-decoration: none;
}

.ls-empty {
    margin: 0;
    padding: 10px;
    font-size: 14px;
    color: var(--lr-muted);
}

/* No-JS results on /learn?q= */
.ls-results {
    margin-bottom: 8px;
}

/* Where a search landed: the heading glows for a moment */
.learn-content .ls-target {
    animation: ls-flash 2s ease-out;
    border-radius: 6px;
}

@keyframes ls-flash {
    0%, 30% {
        background: var(--lr-accent-soft);
        box-shadow: 0 0 0 8px var(--lr-accent-soft);
    }
    100% {
        background: transparent;
        box-shadow: 0 0 0 8px transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .learn-content .ls-target {
        animation: none;
        outline: 2px solid var(--lr-accent);
        outline-offset: 4px;
    }
}

/* The sidebar's lesson list is shorter by the height of the search box */
body.learn-page .learn-nav .ls ~ .learn-nav-box .learn-nav-scroll {
    max-height: calc(100vh - var(--learn-nav-h) - 140px);
}

@media (max-width: 899px) {
    body.learn-page .learn-nav .ls ~ .learn-nav-box .learn-nav-scroll {
        max-height: 60vh;
    }

    .learn-nav .ls-pop {
        right: 0;
        width: auto;
    }

    .ls-key {
        display: none;
    }
}

@media (max-width: 639px) {
    .ls-hero .ls-input {
        height: 46px;
        font-size: 16px;
    }

    .ls-input {
        font-size: 16px; /* stops iOS zooming in on focus */
    }

    .ls-go {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .ls-row.is-section > .ls-go {
        padding-top: 11px;
        padding-bottom: 11px;
    }
}

body.learn-page.dark .ls-pop {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Quiz page: a compact box above the title */
.learn-article > .ls {
    max-width: 420px;
    margin-bottom: 16px;
}

/* Keep the search results above the page's code runners (Ace layers and Run buttons are
   positioned, and come later in the page than the sticky sidebar) */
.ls {
    z-index: 30;
}

.learn-nav {
    z-index: 30;
}

@media (max-width: 899px) {
    /* Not sticky here: relative only so the z-index applies (and no sticky offset) */
    body.learn-page .learn-nav {
        position: relative;
        top: auto;
    }
}

/* ========== /learn: about the course + FAQ (below the curriculum) ========== */
.learn-about,
.learn-faq {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--lr-border);
    font-size: 16px;
    line-height: 1.7;
    color: var(--lr-text);
}

.learn-about h2,
.learn-faq h2 {
    margin: 32px 0 10px;
    font-size: 26px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-about > h2:first-child,
.learn-faq > h2:first-child {
    margin-top: 0;
}

.learn-about p {
    max-width: 760px;
}

.learn-about code {
    font-size: 0.88em;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.learn-about-grid {
    list-style: none;
    margin: 18px 0 8px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.learn-about-grid li {
    /* Icon and title on one line, the text below both */
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    align-content: start;
    padding: 16px 18px;
    border: 1px solid var(--lr-border);
    border-radius: 10px;
    background: var(--lr-panel);
}

.learn-about-grid i {
    width: 20px;
    text-align: center;
    font-size: 18px;
    color: var(--lr-accent);
}

.learn-about-grid h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-about-grid p {
    grid-column: 1 / -1;
    margin: 6px 0 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--lr-muted);
}

.learn-about-list {
    margin: 0;
    padding-left: 22px;
    max-width: 760px;
}

.learn-about-list li + li {
    margin-top: 4px;
}

.learn-faq-item {
    max-width: 760px;
    padding: 14px 0;
    border-bottom: 1px solid var(--lr-border);
}

.learn-faq-item:last-child {
    border-bottom: 0;
}

.learn-faq-item h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-faq-item p {
    margin: 0;
    color: var(--lr-text);
}

@media (max-width: 639px) {
    .learn-about h2,
    .learn-faq h2 {
        font-size: 22px;
    }
}
