/*
 * The quizzes: /quizzes (learn/quizzes.php), a topic quiz's page (learn/quiz.php) and its player (learn-quiz.js,
 * learn-quiz-types.js). The prose and code it shares with the lessons are learn-content.css's; the buttons are
 * learn-shell.css's .btn. On learn-shell.css's tokens (the --lr-* names are aliases there).
 */

/* ========== /quizzes: every lesson's quiz, by part ========== */
.quizzes {
    max-width: 860px;
    margin: 0 auto;
    padding: 48px 24px 0;
}

.quizzes-hero h1 {
    margin: 0 0 12px;
    font-size: clamp(40px, 5vw, 54px);
}

.quizzes-lead {
    max-width: 40em;
    margin: 0 0 10px;
    color: var(--ink-2);
    font-size: 18px;
}

.quizzes-stats {
    margin: 0;
    color: var(--ink-3);
    font-size: 14px;
}

/* The Mastery Quiz (/python-quiz), first: one quiz across every topic */
.quizzes-mastery {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 28px;
    padding: 18px 20px;
    border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%);
    color: var(--ink);
    text-decoration: none;
}

.quizzes-mastery:hover {
    border-color: var(--brand);
    text-decoration: none;
}

.quizzes-mastery-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
}

.quizzes-mastery-icon .ic {
    width: 24px;
    height: 24px;
}

.quizzes-mastery-text {
    display: grid;
    flex: 1;
    gap: 2px;
}

.quizzes-mastery-text b {
    font-size: 18px;
}

.quizzes-mastery-text span {
    color: var(--ink-2);
    font-size: 15px;
}

.quizzes-mastery-go {
    flex: none;
    color: var(--brand);
}

.quiz-part {
    margin-top: 40px;
}

.quiz-part h2 {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 12px;
    font-size: 23px;
}

.quiz-part h2 span {
    color: var(--part);
    font-size: 14px;
    font-weight: 650;
}

.quiz-part .learn-row-num {
    background: color-mix(in srgb, var(--part) 12%, transparent);
    color: var(--part);
}

/* ========== A quiz's page ========== */
.quiz-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 28px 24px 0;
}

.quiz-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    color: var(--ink-3);
    font-size: 14px;
}

.quiz-crumbs a {
    color: var(--ink-2);
}

.quiz-crumbs .ic {
    width: 12px;
    height: 12px;
}

.quiz-page h1 {
    margin: 0 0 10px;
    font-size: clamp(34px, 4.6vw, 44px);
}

.quiz-page .lq-lead {
    margin: 0 0 24px;
    color: var(--ink-2);
    font-size: 17px;
}

.quiz-page .lq-lead a {
    font-weight: 600;
}

@media (max-width: 480px) {
    .quizzes,
    .quiz-page {
        padding-left: 14px;
        padding-right: 14px;
    }

}

/* ========== The player ========== */
/* The actions under a question and on the results: on the right, Skip pushed to the left */
.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-skip {
    margin-right: auto;
}

/* ========== Quiz (/learn/<slug>/quiz, learn-quiz.js) ========== */
body.learn-page {
    /* Code token colours: GitHub's, as the lessons' code (ace-theme-github.js) */
    --lq-code-text: #1f2328;
    --lq-tok-kw: #cf222e;
    --lq-tok-op: #cf222e;
    --lq-tok-num: #0550ae;
    --lq-tok-const: #0550ae;
    --lq-tok-str: #0a3069;
    --lq-tok-com: #6e7781;
    --lq-tok-fn: #8250df;
    --lq-tok-var: #953800;
    --lq-on-accent: #ffffff;
}

body.learn-page.dark {
    /* GitHub dark */
    --lq-code-text: #e6edf3;
    --lq-tok-kw: #ff7b72;
    --lq-tok-op: #ff7b72;
    --lq-tok-num: #79c0ff;
    --lq-tok-const: #79c0ff;
    --lq-tok-str: #a5d6ff;
    --lq-tok-com: #8b949e;
    --lq-tok-fn: #d2a8ff;
    --lq-tok-var: #ffa657;
    --lq-on-accent: #10161d;
}

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

.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-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 .ic {
    width: 18px;
    color: var(--lr-accent);
    text-align: center;
}

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

.lq-start-best .ic {
    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);
}

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

.lq-q-head {
    display: flex;
    flex-wrap: wrap; /* phones: the type chip goes under the count and level */
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--lr-muted);
}

/* Difficulty: a chip after "Question N of M" (1-3 filled bars, like a signal meter), and on the results
   a meter per level. Easy green, Medium amber, Hard red. */
.lq-card {
    --lq-l1: #1f9d55;
    --lq-l2: #c27803;
    --lq-l3: #d1453b;
}

body.learn-page.dark .lq-card {
    --lq-l1: #3fb970;
    --lq-l2: #e3a33b;
    --lq-l3: #ef6b61;
}

.lq-q-count {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.lq-level {
    --lq-level: var(--lq-l2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--lq-level) 12%, transparent);
    color: var(--lq-level);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
}

.lq-level.is-1 {
    --lq-level: var(--lq-l1);
}

.lq-level.is-3 {
    --lq-level: var(--lq-l3);
}

.lq-level-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 10px;
}

.lq-level-bars i {
    width: 3px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.25;
}

.lq-level-bars i:nth-child(1) { height: 4px; }
.lq-level-bars i:nth-child(2) { height: 7px; }
.lq-level-bars i:nth-child(3) { height: 10px; }

.lq-level.is-1 .lq-level-bars i:nth-child(-n+1),
.lq-level.is-2 .lq-level-bars i:nth-child(-n+2),
.lq-level.is-3 .lq-level-bars i {
    opacity: 1;
}

/* Results: chip | meter | right/asked, one row per level asked */
.lq-levels {
    margin: 18px 0 0;
    padding: 12px 16px 14px;
    border: 1px solid var(--lr-border);
    border-radius: 10px;
}

.lq-levels h3 {
    margin: 0 0 8px;
    color: var(--lr-heading);
    font-size: 16px;
    font-weight: 700;
}

.lq-level-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
}

.lq-level-row .lq-level {
    justify-self: start;
}

.lq-meter {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--lr-surface-2);
}

.lq-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--lq-l2);
    transform-origin: left;
    animation: lq-meter-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.lq-meter.is-1 span {
    background: var(--lq-l1);
}

.lq-meter.is-3 span {
    background: var(--lq-l3);
}

.lq-level-row:nth-child(3) .lq-meter span { animation-delay: 0.12s; }
.lq-level-row:nth-child(4) .lq-meter span { animation-delay: 0.24s; }

@keyframes lq-meter-in {
    from { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .lq-meter span {
        animation: none;
    }
}

.lq-level-score {
    color: var(--lr-heading);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.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: 13px;
    font-weight: 700;
    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;
}

/* A hidden case that failed (learn-quiz-types.js caseFeedback): its values, then its error, as the outputs show */
.lq-runner .lr-case {
    max-height: 220px;
    margin: 8px 0 0;
    padding: 8px 10px;
    overflow: auto;
    border-radius: 6px;
    background: var(--lr-code-bg);
    font-family: "Fira Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
}

.lq-runner .lr-case.is-error {
    color: var(--lr-err);
}

/* ----- 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 .ic {
    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 .ic {
    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: 13px;
    font-weight: 700;
    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;
}

/* A Mastery Quiz's Topics to review: each topic, how many it missed, and its quiz */
.lq-review-topics li + li {
    margin-top: 4px;
}

.lq-topic-missed {
    margin: 0 8px;
    font-size: 14px;
}

.lq-review-sections .lq-topic-quiz {
    font-size: 14px;
    font-weight: 500;
}

/* ========== The Mastery Quiz's setup (learn/mastery.php, learn-mastery.js) ========== */
.mq-setup {
    display: grid;
    gap: 22px;
    padding: 22px;
}

.mq-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.mq-field legend {
    margin-bottom: 10px;
    padding: 0;
    color: var(--lr-heading);
    font-size: 16px;
    font-weight: 700;
}

.mq-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mq-lengths {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mq-option {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--lr-border);
    border-radius: 12px;
    cursor: pointer;
}

.mq-option:hover {
    border-color: color-mix(in srgb, var(--lr-accent) 45%, var(--lr-border));
}

.mq-option:has(input:checked) {
    border-color: var(--lr-accent);
    background: var(--lr-accent-soft);
    box-shadow: inset 0 0 0 1px var(--lr-accent);
}

.mq-option input {
    margin: 3px 0 0;
    accent-color: var(--lr-accent);
}

.mq-option-text {
    display: grid;
    gap: 2px;
}

.mq-option-text b {
    color: var(--lr-heading);
    font-size: 15px;
}

.mq-option-text small {
    color: var(--lr-muted);
    font-size: 13px;
    line-height: 1.35;
}

.mq-option-text .mq-xp {
    color: var(--lr-accent);
    font-weight: 600;
}

.mq-parts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mq-part {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid var(--lr-border);
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
}

.mq-part:has(input:checked) {
    border-color: var(--lr-accent);
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 600;
}

.mq-part input,
.mq-switch input {
    margin: 0;
    accent-color: var(--lr-accent);
}

.mq-switch {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    font-size: 14px;
    cursor: pointer;
}

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

.mq-note:empty {
    display: none;
}

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

/* A question's topic, beside its type (a Mastery Quiz's mixed set) */
.lq-q-topic {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--lr-muted);
    font-weight: 600;
}

@media (max-width: 640px) {
    .mq-options,
    .mq-lengths {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mq-options:not(.mq-lengths) {
        grid-template-columns: minmax(0, 1fr);
    }
}

.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: center;
    gap: 10px;
    padding: 10px 4px;
    list-style: none;
    cursor: pointer;
}

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

/* Each answer's result as a filled badge, to see at a glance: a tick on green, a cross on red, a skip on grey */
.lq-review-list summary>.ic {
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    padding: 4px;
    border-radius: 50%;
    background: var(--lr-info);
    color: var(--surface);
    stroke-width: 2.8;
}

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

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

.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;
}

/* While the questions are on screen (learn-quiz.js's is-quizzing), nothing under them draws the eye away: what the
   quiz covers, How it works and sharing show on the start or setup and on the results */
.quiz-page.is-quizzing .lq-covers,
.quiz-page.is-quizzing .learn-share {
    display: none;
}

/* ...and the page is at least a screen tall, so the footer starts below the fold however short the question */
.quiz-page.is-quizzing {
    min-height: 100vh;
}

/* The Mastery Quiz's How it works: sentences, not section names, so one column */
.mq-how ul {
    max-width: 44em;
    columns: 1;
}

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

.lq-covers .ic {
    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 .btn {
    width: 100%;
}

/* ========== Was this question clear? (learn-quiz.js): thumbs under the explanation, the reasons inline on a down ========== */
.lq-vote {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}

.lq-vote-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
    font-size: 14px;
}

.lq-vote-row > span {
    margin-right: 4px;
}

.lq-vote-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    font-size: 17px;
    cursor: pointer;
}

.lq-vote-btn:hover {
    border-color: var(--ink-3);
}

.lq-vote-btn[aria-pressed="true"] {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.lq-why {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.lq-why[hidden] {
    display: none;
}

.lq-why-ask {
    margin: 0;
    color: var(--ink);
    font-weight: 650;
}

.lq-why textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    resize: vertical;
}

.lq-why textarea:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.lq-why-actions {
    display: flex;
    gap: 8px;
}

.lq-vote-thanks {
    margin: 10px 0 0;
    color: var(--done);
    font-size: 14px;
    font-weight: 620;
}
