/* Lab notebook (lab/notebook.js): toolbar, Python cells, outputs, plots, dialogs; also the staff page (admin.html).
   Colours are tokens derived from the book's (--ink, --paper, --line, --blue, --purple, --positive). The plot reads
   the --lab-* tokens from its figure, one colour per quantity: I, Q, magnitude, complex (I/Q plane), reference.
   A dark theme only has to redefine the book tokens, or set data-theme="dark" on <html>. */
.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin {
  --lab-bg: var(--paper, #fff); --lab-ink: var(--ink, #25343c); --lab-muted: var(--muted, #617079); --lab-line: var(--line, #e1e5ec);
  --lab-grid: var(--line, #e1e5ec); --lab-axis: var(--line-2, #c8cfda); --lab-surface: var(--wash, #f3f5f8); --lab-code: var(--wash, #f3f5f8); --lab-accent: var(--go, #1f4fd8);
  --lab-i: var(--go, #1f4fd8); --lab-q: #c05f14; --lab-mag: var(--ink, #25343c); --lab-complex: var(--purple, #845cb2);
  --lab-ref: var(--positive, #16816f); --lab-phase: var(--purple, #845cb2); --lab-select: rgb(31 79 216 / .12);
  --lab-ok: #16816f; --lab-busy: #c7901c; --lab-bad: #b3261e; --lab-warn-bg: #fff4d6; --lab-mono: "JetBrains Mono", var(--remi-font);
}
:root[data-theme="dark"] :is(.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin) {
  --lab-bg: #141b1f; --lab-ink: #e8eef7; --lab-muted: #a9b6c9; --lab-line: #26354f; --lab-grid: #17243f; --lab-axis: #566b8e;
  --lab-surface: #0f1a30; --lab-code: #0f1a30; --lab-accent: #a8bfff; --lab-i: #a8bfff; --lab-q: #f0a050; --lab-mag: #e8eef7;
  --lab-complex: #b99ae6; --lab-ref: #5fd0b0; --lab-phase: #b99ae6; --lab-select: rgba(168, 191, 255, .18); --lab-warn-bg: #3a3218;
}

.lab-toolbar button, .lab-cell button, .lab-dialog button, .lab-admin button {
  font-size: 15px; line-height: 1.2; min-height: 30px; padding: 5px 10px; border: 1px solid var(--line-2, #c8cfda); border-radius: 12px;
  background: var(--lab-bg); color: var(--lab-accent); white-space: nowrap;
}
:is(.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin) button:hover:not(:disabled) { background: var(--lab-surface); }
:is(.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin) button:disabled { background: var(--wash, #f3f5f8); color: var(--ink-2, #4a5466); border-color: var(--line, #e1e5ec); opacity: 1; }
:is(.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin) .lab-primary:not(:disabled) { background: var(--lab-accent); border-color: var(--lab-accent); color: var(--lab-bg); }
:is(.lab-toolbar, .lab-cell, .lab-dialog, .lab-admin) .lab-primary:hover:not(:disabled) { background: var(--go-2, #1638a8); }
.lab-toolbar .lab-danger { border-color: var(--lab-bad); color: var(--lab-bad); font-weight: 650; }
.lab-toolbar .lab-warn { background: var(--lab-warn-bg); border-color: var(--lab-busy); color: var(--lab-ink); }

/* Toolbar: sticky at the top of the reading column; wraps into rows on a phone. */
.lab-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  margin: 0 0 22px; padding: 8px 0 9px; background: var(--lab-bg); border-bottom: 1px solid var(--lab-line); font-size: 15px; color: var(--lab-ink);
}
/* A page of a course by kinds (shared/course-kinds.css, the wireless course) has the course bar as its sticky first row,
   --course-bar-h high at every width: the toolbar sticks right under it, so neither covers the other, and a heading or
   a 실습 row reached by a link (the toolbar's index, the stage pills) lands below both. */
html[data-course-layout="kinds"] .lab-toolbar { top: var(--course-bar-h, 0px); }
html[data-course-layout="kinds"] .lab-toolbar ~ article h2 { scroll-margin-top: calc(var(--course-bar-h, 0px) + var(--lab-index-offset, 96px)); }
html[data-course-layout="kinds"].rows-page .rows-row { scroll-margin-top: calc(var(--course-bar-h, 0px) + var(--rows-bar-h, 110px) + 8px); }
.lab-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.lab-actions { margin-left: auto; }
.lab-label { font-weight: 650; }
.lab-state { color: var(--lab-muted); font-variant-numeric: tabular-nums; }
.lab-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2, #c8cfda); flex: none; }
[data-state="loading"] > .lab-dot, [data-state="connecting"] > .lab-dot { background: var(--lab-busy); }
[data-state="ready"] > .lab-dot, [data-state="connected"] > .lab-dot { background: var(--lab-ok); }
[data-state="error"] > .lab-dot { background: var(--lab-bad); }
[data-state="tx"] > .lab-dot { background: var(--lab-bad); box-shadow: 0 0 0 3px rgba(179, 38, 30, .25); }
[data-state="tx"] .lab-state { color: var(--lab-bad); font-weight: 650; }
.lab-bar { width: 70px; height: 5px; background: var(--lab-line); border-radius: 12px; overflow: hidden; }
.lab-bar > span { display: block; height: 100%; width: 0; background: var(--lab-busy); transition: width .2s; }
.lab-signal-label { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; color: var(--lab-muted); }
.lab-signal-label[hidden] { display: none; }
.lab-signal { font: inherit; min-width: 0; max-width: 15em; min-height: 30px; padding: 3px 4px; border: 1px solid var(--lab-line); border-radius: 12px; background: var(--lab-bg); color: var(--lab-ink); }
.lab-notice { flex-basis: 100%; margin: 0; font-size: 15px; color: var(--lab-muted); line-height: 1.5; }
.lab-notice[hidden] { display: none; }

/* A cell: bar, editor (line numbers + textarea), output. */
.lab-cell { margin: 22px 0 26px; }
.lab-cell-live { border: 1px solid var(--lab-line); border-left: 3px solid var(--lab-line); background: var(--lab-bg); }
.lab-cell-live[data-state="running"], .lab-cell-live[data-state="queued"] { border-left-color: var(--lab-busy); }
.lab-cell-live[data-state="done"] { border-left-color: var(--lab-ok); }
.lab-cell-live[data-state="error"] { border-left-color: var(--lab-bad); }
.lab-cell-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 5px 8px; background: var(--lab-surface); border-bottom: 1px solid var(--lab-line); font-size: 15px; color: var(--lab-muted); }
.lab-count { font-family: var(--lab-mono); min-width: 3.2em; }
.lab-cell-name { font-family: var(--lab-mono); color: var(--lab-ink); }
.lab-flag { color: var(--lab-busy); }
.lab-cell-status { color: var(--lab-muted); }
[data-state="error"] .lab-cell-status { color: var(--lab-bad); font-weight: 650; }
.lab-spacer { flex: 1; }
.lab-editor { display: grid; grid-template-columns: auto minmax(0, 1fr); background: var(--lab-code); }
.lab-editor .lab-lines, .lab-editor textarea { font: 15px/1.6 var(--lab-mono); padding: 10px 10px 12px; margin: 0; tab-size: 4; }
.lab-editor .lab-lines { background: transparent; color: var(--ink-2, #4a5466); text-align: right; user-select: none; border-right: 1px solid var(--lab-line); overflow: hidden; min-width: 2.6em; padding-right: 8px; }
.lab-editor textarea { display: block; width: 100%; min-height: 3.5em; border: 0; resize: none; overflow-x: auto; overflow-y: hidden; white-space: pre; background: transparent; color: var(--lab-ink); }
.lab-editor textarea:focus { outline: 2px solid #e3a541; outline-offset: -2px; }
.lab-editor textarea[readonly] { color: var(--lab-muted); }
.lab-output { padding: 4px 10px 8px; border-top: 1px solid var(--lab-line); font-size: 15px; line-height: 1.5; }
.lab-output:empty { display: none; }
.lab-output pre { margin: 6px 0; padding: 6px 8px; font: 15px/1.5 var(--lab-mono); background: transparent; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.lab-output .lab-stderr { color: #8a5a00; background: var(--lab-warn-bg); }
.lab-output .lab-error { color: var(--lab-bad); background: rgba(179, 38, 30, .06); border-left: 3px solid var(--lab-bad); }
.lab-output .lab-value { color: var(--lab-ink); }
.lab-note { margin: 6px 0; font-size: 15px; color: var(--lab-muted); }
.lab-note-record::before { content: "● "; color: var(--lab-ok); }
.lab-note-warn { color: var(--lab-ink); background: var(--lab-warn-bg); padding: 4px 8px; }
.lab-note-todo { color: var(--lab-ink); background: var(--lab-warn-bg); border-left: 3px solid #d4a017; padding: 6px 10px; font-size: 15px; }
.lab-cell-live[data-state="todo"] { border-left-color: #d4a017; }
[data-state="todo"] .lab-cell-status { color: #8a6500; font-weight: 650; }
.lab-prompt { margin: 8px 0; padding: 10px 12px; background: var(--lab-warn-bg); border-left: 3px solid var(--lab-busy); }
.lab-prompt p { margin: 0 0 8px; }
.lab-prompt-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Plots */
.lab-plot { margin: 10px 0 14px; padding: 0; border: 0; min-width: 0; }
.lab-plot canvas { display: block; width: 100%; cursor: crosshair; }
.lab-plot-tools { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.lab-plot-readout { flex: 1; margin: 0; min-height: 1.5em; font-size: 15px; color: var(--lab-muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.lab-plot-tools button { min-height: 26px; padding: 3px 8px; font-size: 15px; }
.lab-plot-note { margin: 2px 0 0; font-size: 15px; color: var(--lab-muted); line-height: 1.5; }

/* Tables (show.table, record lists) */
.lab-table { overflow-x: auto; margin: 8px 0; }
.lab-grade { margin: 16px 0 24px; }
.lab-grade-total { font-size: 1.15em; font-weight: 650; }
.lab-table table { border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.lab-table caption { text-align: left; font-weight: 650; padding: 0 0 4px; }
.lab-table th, .lab-table td { padding: 4px 10px 4px 0; border-bottom: 1px solid var(--lab-line); text-align: left; vertical-align: top; }
.lab-table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--lab-mono); }
.lab-row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Dialogs */
.lab-dialog { width: min(720px, calc(100vw - 20px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--lab-line); border-radius: 20px; background: var(--lab-bg); color: var(--lab-ink); font-size: 15px; line-height: 1.6; }
.lab-dialog::backdrop { background: rgba(20, 30, 35, .45); }
.lab-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--lab-line); position: sticky; top: 0; background: var(--lab-bg); }
.lab-dialog-head h2 { margin: 0; font-size: 16px; letter-spacing: 0; }
.lab-dialog > :not(.lab-dialog-head) { margin: 12px 16px 16px; }
.lab-form { display: grid; gap: 10px; }
.lab-form label { display: grid; gap: 4px; font-size: 15px; font-weight: 650; }
.lab-form input { box-sizing: border-box; font-family: inherit; font-size: 15px; line-height: 1.4; padding: 7px 9px; border: 1px solid var(--line-2, #c8cfda); border-radius: 12px; background: var(--lab-bg); color: var(--lab-ink); width: 100%; }
.lab-form p, .lab-records p { margin: 0; }
.lab-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-form-error { color: var(--lab-bad); font-size: 15px; min-height: 1.2em; }
.lab-quiet { color: var(--lab-muted); font-size: 15px; }
.lab-records { display: grid; gap: 10px; }
.lab-records h3 { margin: 4px 0 0; font-size: 16px; }
.lab-records ul { margin: 0; padding-left: 18px; }
.lab-waiting { padding: 8px 10px; background: var(--lab-warn-bg); display: grid; gap: 6px; justify-items: start; }
.lab-snippet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lab-snippet code { font-family: var(--lab-mono); background: var(--lab-surface); padding: 4px 8px; overflow-wrap: anywhere; }
.lab-saved-code { max-height: 300px; overflow: auto; font-size: 15px; }
.lab-answers dt { font-weight: 650; }
.lab-answers dd { margin: 0 0 6px; }
.lab-dialog .lab-link { border: 0; padding: 0; min-height: 0; text-decoration: underline; background: none; }

/* Staff page (admin.html), which loads no book stylesheet. */
.lab-admin-page { margin: 0; background: var(--paper, #fff); color: var(--ink, #25343c); --remi-font: Remi, KaTeX_Main, KaTeX_AMS, sans-serif; font-family: var(--remi-font); }
.lab-admin { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; font-size: 15px; line-height: 1.6; background: var(--lab-bg); color: var(--lab-ink); }
.lab-admin h1 { font-size: 26px; margin: 0 0 18px; }
.lab-admin h2 { font-size: 17px; margin: 18px 0 8px; }
.lab-admin select { font: inherit; padding: 4px 6px; }
.lab-admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-bottom: 1px solid var(--lab-line); }
.lab-admin-login { max-width: 360px; }

@media (max-width: 540px) {
  .lab-toolbar { gap: 5px 10px; font-size: 15px; }
  .lab-actions { margin-left: 0; }
  .lab-editor .lab-lines, .lab-editor textarea { font-size: 15px; padding-left: 6px; }
  .lab-output { padding: 2px 6px 6px; }
}
@media print {
  .lab-toolbar, .lab-cell-bar button, .lab-plot-tools, .lab-prompt { display: none !important; }
  .lab-output pre { max-height: none; }
}

.lab-answer { margin: 1.5rem 0; }
.lab-answer textarea { display: block; box-sizing: border-box; width: 100%; min-height: 7em; padding: .7rem; font: inherit; color: inherit; background: var(--lab-bg, transparent); border: 1px solid #888; border-radius: 12px; }
.lab-controls { display: flex; flex-wrap: wrap; gap: .6rem 1rem; padding: .6rem 0; }
.lab-controls label { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-width: 0; max-width: 100%; }
.lab-controls input { min-width: 0; max-width: 100%; }
.lab-controls select { max-width: 100%; }
.lab-controls output { font-variant-numeric: tabular-nums; }

.lab-output, .lab-control-output { container: lab-output / inline-size; }
.lab-control-output { display: flow-root; overflow-anchor: none; }
.lab-redraw-stage { position: fixed; left: 0; top: 0; visibility: hidden; pointer-events: none; }
.lab-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
.lab-columns > * { min-width: 0; }
@container lab-output (min-width: 640px) {
  .lab-columns { grid-template-columns: repeat(var(--lab-column-count), minmax(0, 1fr)); }
}

/* Student result page, round 3 (Opus design, mockup). In the implementation these rules replace the
   "Student feedback" block of lab/notebook.css (7c395af lines 166-231); the .inquiry-card / .inquiry-exams rules of the
   PI list page stay. Colours are the lab tokens (--lab-*, derived from shared/book.css) plus the --fb-* tokens below,
   each taken from a literal book.css already uses, except the loss pair and the band track (named here). */
.lab-feedback {
  --fb-band: #f8faf9;            /* book.css .book-sidebar background */
  --fb-track: var(--line, #e1e5ec);           /* = --lab-grid */
  --fb-gain-bg: var(--go-t, #e5ecfd);         /* book.css current-chapter background */
  --fb-gain-line: var(--line-2, #c8cfda);
  --fb-gain-ink: var(--go-2, #1638a8);
  --fb-gain-mark: var(--go, #1f4fd8);
  --fb-loss-bg: #f8ebe7;         /* tint of book --negative #ba6552 */
  --fb-loss-line: #e6c0b5;
  --fb-loss-ink: #8f3a29;        /* 6.43:1 on --fb-loss-bg */
  --fb-loss-mark: #a4513f;       /* 4.71:1 on --fb-loss-bg; white on it 5.49:1 */
  --fb-wait-bg: #fff4d6;         /* = --lab-warn-bg */
  --fb-wait-ink: #6b4e00;        /* 7.06:1 on --fb-wait-bg */
  --fb-detail: #4f5e66;          /* detail text on tinted rows */
  --fb-focus: #e3a541;           /* book.css focus outline */
  --fb-radius: 6px;
  max-width: 1200px; padding: 28px 32px 72px; font-size: 15px; line-height: 1.65;
  word-break: keep-all; overflow-wrap: break-word;
}
.lab-feedback .katex { font-size: 1.05em; word-break: normal; }
.lab-feedback .katex-display { margin: 10px 0; padding: 4px 0; overflow-x: auto; overflow-y: hidden; }
.feedback-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.lab-feedback :is(a, button, summary, textarea):focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 2px; }
.lab-feedback button { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 12px; }

/* Header: course line and exam title come from the shell; the bar (back link, account) comes from the script. */
.lab-feedback > .lab-quiet { margin: 0 0 2px; font-size: 13px; }
.lab-feedback h1 { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.35; margin: 0 0 10px; }
.lab-feedback .lab-admin-bar { padding: 6px 0 12px; margin: 0 0 24px; font-size: 14px; }
.feedback-back { color: var(--lab-accent); text-decoration: none; }
.feedback-back:hover { text-decoration: underline; }
.feedback-preview { margin: 0 0 20px; padding: 10px 14px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-band); font-size: 14px; }

/* 1. Score summary */
.feedback-total { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px 48px; padding: 24px 28px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-card); }
.feedback-total h2 { margin: 0 0 2px; font-size: 14px; font-weight: 650; color: var(--lab-muted); }
.feedback-total-number { margin: 0; font-size: 44px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.feedback-total-number > span { margin-left: 6px; font-size: 18px; font-weight: 500; letter-spacing: 0; color: var(--lab-muted); }
.feedback-meter { display: block; height: 8px; margin: 14px 0 0; border-radius: 12px; background: var(--fb-track); overflow: hidden; }
.feedback-meter > span { display: block; height: 100%; border-radius: 12px; background: var(--lab-accent); }
.feedback-absent { margin: 10px 0 0; font-weight: 650; }
.feedback-deduction { margin: 10px 0 0; font-size: 14px; color: var(--lab-muted); overflow-wrap: anywhere; }
.feedback-total-side h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; color: var(--lab-muted); }
.feedback-comment { margin: 0; white-space: pre-line; font-size: 16px; line-height: 1.7; }
.feedback-total-side > .feedback-inquiry { margin-top: 12px; }
.feedback-inquiry-window-inline { margin: 0; font-size: 14px; }
.feedback-inquiry-window { grid-column: 1 / -1; margin: 0; padding-top: 14px; border-top: 1px solid var(--lab-line); font-size: 14px; }

/* 2. Unit overview */
.feedback-scores { margin: 40px 0 0; }
.feedback-scores > h2, .feedback-stats > h2, .feedback-previous > h2 { margin: 0 0 12px; font-size: 19px; font-weight: 650; }
.feedback-score-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.feedback-score-list a { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 6px 8px; height: 100%; box-sizing: border-box; padding: 10px 12px 12px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-card); color: inherit; text-decoration: none; }
.feedback-score-list a:hover { border-color: var(--line-2, #c8cfda); background: var(--fb-band); }
.feedback-tile-id { font-weight: 650; }
.feedback-tile-score { justify-self: end; font-variant-numeric: tabular-nums; font-weight: 650; }
.feedback-tile-score > span { font-weight: 400; color: var(--lab-muted); }
.feedback-tile-meter { grid-column: 1 / -1; display: block; height: 4px; border-radius: 2px; background: var(--fb-track); overflow: hidden; }
.feedback-tile-meter > span { display: block; height: 100%; background: var(--lab-accent); }
.feedback-score-list .feedback-chip { grid-column: 1 / -1; justify-self: start; }
.feedback-chip { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap; }
.feedback-chip[data-state="open"] { background: var(--fb-wait-bg); color: var(--fb-wait-ink); }
.feedback-chip[data-state="answered"] { background: var(--fb-gain-bg); color: var(--fb-gain-ink); }
.feedback-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 14px 0 0; font-size: 13px; color: var(--lab-muted); }
.feedback-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* 3. Unit cards */
.feedback-units { margin-top: 32px; }
.feedback-unit { margin: 0 0 24px; padding: 18px 24px 0; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-card); scroll-margin-top: 16px; }
.feedback-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 20px; padding: 0 0 14px; border-bottom: 1px solid var(--lab-line); }
.lab-feedback .feedback-score { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.feedback-card-score { margin: 0 0 0 auto; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.feedback-card-score > span { font-size: 15px; font-weight: 500; color: var(--lab-muted); }
.feedback-grade-link { color: var(--lab-muted); font-size: 13px; line-height: 1.5; text-underline-offset: 3px; }
.feedback-grade-link:hover, .feedback-grade-link:focus-visible { color: var(--lab-accent); }
.feedback-unit h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 650; }
.feedback-unit-body > * + * { margin-top: 24px; }

/* 내 답안: scan crops, each opens full size */
.feedback-image { position: relative; margin: 0 0 10px; border: 1px solid var(--lab-line); border-radius: 20px; background: #fff; overflow: hidden; }
.feedback-image a { display: block; color: inherit; }
.feedback-image a:focus-visible { outline-offset: -3px; }
.feedback-image img { display: block; width: 100%; height: auto; }
.feedback-zoom { position: absolute; top: 8px; right: 8px; padding: 1px 8px; border: 1px solid var(--lab-line); border-radius: 999px; background: rgba(255, 255, 255, .94); font-size: 12px; color: var(--lab-accent); }
.feedback-answers > :last-child { margin-bottom: 0; }
.feedback-answers > p { margin: 0; color: var(--lab-muted); }

/* 모범답안 */
.feedback-model summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; margin: 0 0 10px; }
.feedback-model summary::-webkit-details-marker { display: none; }
.feedback-model summary::before { content: ""; flex: none; width: 7px; height: 7px; margin: 0 2px 2px 2px; border-right: 1.5px solid var(--lab-muted); border-bottom: 1.5px solid var(--lab-muted); transform: rotate(-45deg); transition: transform .15s; }
.feedback-model[open] summary::before { transform: rotate(45deg); margin-bottom: 4px; }
.feedback-model summary h3 { margin: 0; }
.feedback-key-body { line-height: 1.75; }
.feedback-key-body > :first-child { margin-top: 0; }
.feedback-key-body > :last-child { margin-bottom: 0; }
.feedback-key-body p { margin: 8px 0; }
.feedback-key-body :is(ul, ol) { margin: 8px 0; padding-left: 22px; }
.feedback-key-body li.depth-1 { margin-left: 18px; }
.feedback-key-body li.depth-2 { margin-left: 36px; }
.feedback-key-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 10px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.feedback-key-body :is(th, td) { padding: 4px 16px 4px 0; border-bottom: 1px solid var(--lab-line); text-align: left; }
.feedback-key-body th { font-weight: 650; color: var(--lab-muted); }
.feedback-key-body pre { overflow-x: auto; padding: 10px 12px; background: var(--lab-code); font: 13px/1.55 var(--lab-mono); }
.feedback-key-body blockquote { margin: 10px 0; padding: 4px 14px; background: var(--fb-band); }
.feedback-key-body img { display: block; max-width: 100%; height: auto; margin-top: 10px; }
.feedback-model-hidden p { margin: 0; padding: 12px 14px; border: 1px dashed var(--line-2, #c8cfda); border-radius: 20px; background: var(--fb-band); color: var(--lab-muted); }

/* 채점: rubric (left) and inquiry (right) on a band across the card foot */
.feedback-grading { margin: 24px -24px 0; padding: 20px 24px 24px; border-top: 1px solid var(--lab-line); border-radius: 0 0 5px 5px; background: var(--fb-band); }
.feedback-side > * + * { margin-top: 20px; }
.feedback-rubric-empty { margin: 0 0 8px; font-size: 13.5px; color: var(--fb-detail); }
.feedback-rubric { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.feedback-rubric-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 10px; align-items: start; padding: 7px 10px; border: 1px solid transparent; border-radius: 20px; font-size: 14.5px; line-height: 1.55; color: var(--lab-muted); }
.feedback-rubric-row[data-state="gain"] { background: var(--fb-gain-bg); border-color: var(--fb-gain-line); color: var(--lab-ink); font-weight: 600; }
.feedback-rubric-row[data-state="loss"] { background: var(--fb-loss-bg); border-color: var(--fb-loss-line); color: var(--lab-ink); font-weight: 600; }
.feedback-mark { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; margin-top: 2px; box-sizing: border-box; border: 1.5px solid var(--lab-muted); border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; line-height: 1; }
.feedback-mark[data-state="gain"] { background: var(--fb-gain-mark); border-color: var(--fb-gain-mark); }
.feedback-mark[data-state="loss"] { background: var(--fb-loss-mark); border-color: var(--fb-loss-mark); font-size: 15px; }
.feedback-legend .feedback-mark { margin-top: 0; }
.feedback-points { min-width: 2.6em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feedback-rubric-row[data-state="gain"] .feedback-points { color: var(--fb-gain-ink); font-weight: 700; }
.feedback-rubric-row[data-state="loss"] .feedback-points { color: var(--fb-loss-ink); font-weight: 700; }
.feedback-adjust { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-2, #c8cfda); }
.feedback-reason { grid-column: 2 / -1; margin: 2px 0 0; font-size: 13.5px; font-weight: 400; color: var(--fb-detail); white-space: pre-line; }
.feedback-unit-total { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 0; padding: 10px 10px 0; border-top: 1px solid var(--lab-line); font-weight: 650; font-variant-numeric: tabular-nums; }
.feedback-unit-total > :last-child > span { font-weight: 500; color: var(--lab-muted); }
.feedback-range { margin: 4px 10px 0; text-align: right; font-size: 13px; color: var(--lab-muted); }
.feedback-comment-text { margin: 0; padding: 12px 14px; border: 1px solid var(--lab-line); border-radius: 20px; background: var(--fb-card); white-space: pre-line; }

/* 채점 문의 */
.feedback-inquiry h3 { display: flex; align-items: center; gap: 8px; }
.feedback-inquiry > :last-child { margin-bottom: 0; }
.feedback-preview-note { margin: 0 0 10px; padding: 6px 10px; border-radius: 20px; background: var(--fb-wait-bg); color: var(--fb-wait-ink); font-size: 13px; }
.feedback-inquiry-entry { margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--lab-line); border-radius: 20px; background: var(--fb-card); }
.feedback-inquiry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 6px; font-size: 12.5px; color: var(--lab-muted); }
.feedback-inquiry-text { margin: 0; white-space: pre-line; }
.feedback-inquiry-reply { margin: 10px 0 0; padding: 10px 12px; border-radius: 20px; background: var(--fb-gain-bg); }
.feedback-inquiry-reply strong { display: block; font-size: 13px; color: var(--fb-gain-ink); }
.feedback-inquiry-reply p { margin: 2px 0 0; white-space: pre-line; }
.feedback-inquiry-reply .feedback-inquiry-meta { margin: 6px 0 0; }
.feedback-inquiry-entry .lab-form-actions { margin-top: 10px; }
.feedback-inquiry-form { display: grid; gap: 8px; margin: 0; }
.feedback-inquiry-form label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 650; }
.feedback-inquiry-form textarea { display: block; box-sizing: border-box; width: 100%; min-height: 7.5em; padding: 10px 12px; border: 1px solid var(--line-2, #c8cfda); border-radius: 12px; background: var(--fb-card); color: var(--lab-ink); font: inherit; font-weight: 400; resize: vertical; }
.feedback-inquiry-form textarea:disabled { background: var(--lab-surface); }
.feedback-inquiry-form p { margin: 0; }
.feedback-inquiry .lab-form-error:empty { display: none; }

/* 4. Class statistics (last) */
.feedback-stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 48px; margin: 40px 0 0; padding: 24px 28px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-card); }
.feedback-stats > h2, .feedback-stats-summary { grid-column: 1 / -1; }
.feedback-stats-summary { margin: 0 0 8px; }
.feedback-histogram { display: grid; gap: 8px; align-content: start; }
.feedback-bin { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) 3em; gap: 10px; align-items: center; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.feedback-bin > :last-child { text-align: right; }
.feedback-bin-track { display: block; height: 10px; border-radius: 5px; background: var(--fb-track); overflow: hidden; }
.feedback-bar { display: block; height: 100%; border-radius: 5px; background: var(--lab-accent); }
.feedback-stats .lab-table { margin: 0; }
.feedback-unit-means { width: 100%; }
.feedback-unit-means.feedback-unit-means { font-size: 14px; }
.feedback-unit-means caption { padding: 0 0 6px; font-size: 14px; }
.feedback-unit-means th { color: var(--lab-muted); font-weight: 600; }
.feedback-unit-means tbody th { color: var(--lab-ink); }
.feedback-unit-means .num { font-family: inherit; text-align: right; font-variant-numeric: tabular-nums; }

/* Wide: inside a card, answers side by side, then the grading band in two columns. */
@media (min-width: 1000px) {
  .feedback-unit-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; align-items: start; }
  .feedback-unit-body > * + * { margin-top: 0; }
  .feedback-unit-body > .feedback-grading { grid-column: 1 / -1; margin-top: 24px; }
  .feedback-grading { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; align-items: start; }
  /* Model answer not released: the answer spans both rows, the right column stacks notice and grading. */
  .feedback-key-unreleased { padding-bottom: 24px; }
  .feedback-key-unreleased .feedback-unit-body > .feedback-answers { grid-row: 1 / span 2; }
  .feedback-right > .feedback-grading { display: block; margin: 16px 0 0; padding: 18px 20px 20px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); }
  .feedback-right > .feedback-grading .feedback-side { margin-top: 20px; }
}
@media (max-width: 999px) {
  .feedback-right { display: contents; }
  .feedback-unit-body > .feedback-right > * + * { margin-top: 24px; }
  .feedback-side { margin-top: 24px; }
  .feedback-stats { grid-template-columns: minmax(0, 1fr); }
  .feedback-stats .lab-table { margin-top: 16px; }
}
@media (max-width: 640px) {
  .lab-feedback { padding: 20px 16px 56px; }
  .lab-feedback h1 { font-size: 24px; }
  .feedback-total { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 18px 16px; }
  .feedback-total-number { font-size: 38px; }
  .feedback-score-list { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .feedback-unit { padding: 14px 16px 0; }
  .feedback-card-head { margin-bottom: 16px; padding-bottom: 12px; }
  .lab-feedback .feedback-score { font-size: 18px; }
  .feedback-card-score { font-size: 20px; }
  .feedback-grading { margin: 20px -16px 0; padding: 16px 16px 20px; }
  .feedback-rubric-row { padding: 7px 8px; column-gap: 8px; font-size: 14px; }
  .feedback-stats { padding: 18px 16px; }
}
@media print {
  .lab-feedback .lab-admin-bar, .feedback-inquiry-form, .feedback-inquiry button, .feedback-zoom, .feedback-preview-note { display: none !important; }
  .feedback-grading { background: none; }
  .feedback-rubric-row, .feedback-inquiry-entry, .feedback-image { break-inside: avoid; }
  .feedback-rubric-row[data-state="gain"], .feedback-rubric-row[data-state="loss"], .feedback-mark { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* Keep PI list styles independent of the feedback shell. */
.inquiry-card { border-top: 1px solid var(--lab-line); margin-top: 24px; padding-top: 8px; }
.inquiry-exams { table-layout: fixed; width: 100%; }
.inquiry-card .lab-form-error:empty { display: none; }
.inquiry-card a, .lab-admin-bar a, .inquiry-exams a { color: var(--lab-accent); text-decoration: none; }
.inquiry-card a:hover, .lab-admin-bar a:hover, .inquiry-exams a:hover { text-decoration: underline; }
.feedback-unit-body > *, .feedback-grading > *, .feedback-rubric-text { min-width: 0; }
.feedback-math-display { display: block; max-width: 100%; overflow-x: auto; }
.feedback-common { margin-top: 24px; }
.feedback-rubric-notice { font-size: 13px; color: var(--lab-muted); }
.feedback-common :is(pre, table) { display: block; max-width: 100%; overflow-x: auto; }
.inquiry-card .feedback-inquiry-reply { border-left: 3px solid var(--lab-accent); padding-left: 12px; }
.inquiry-card .feedback-inquiry-reply strong { color: var(--lab-ink); }

/* Round 5 model answers: step rail, equations, figures and callouts. */
/* ---------- tokens ---------- */
.lab-feedback {
  --fb-card: #fff;                      /* new name for the round-3 literal #fff of cards */
  --fb-surface: var(--lab-surface);
  --fb-math-bg: var(--lab-code);
  --fb-math-line: var(--lab-grid);
  --fb-rail: var(--lab-line);           /* step connector */
  --fb-badge-line: var(--fb-gain-line);
  --fb-badge-ink: var(--fb-gain-ink);
  --fb-chg-bg: var(--lab-select);
  --fb-chg-line: var(--lab-accent);
  --fb-chg-ink: var(--fb-gain-ink);
  --fb-callout-bg: var(--fb-wait-bg);   /* #fff4d6 (= --lab-warn-bg) */
  --fb-callout-line: #f0dca0;           /* new: border of the callout, tint of --lab-busy */
  --fb-callout-rail: var(--lab-busy);   /* #c7901c */
  --fb-callout-ink: var(--fb-wait-ink); /* #6b4e00, 7.1:1 on --fb-callout-bg */
  --fb-mat: #fff;                       /* figure mat: white in both themes (figures are white PNGs) */
  --fb-mat-line: var(--lab-line);
  --fb-scroll-shade: rgba(37, 52, 60, .22); /* new: edge shade of an equation that scrolls */
  --fb-mark-ink: #fff;
  --fb-measure: 46em;                   /* prose line length in the box */
}
:root[data-theme="dark"] body.lab-admin-page { background: #141b1f; color: #e8eef7; }
:root[data-theme="dark"] .lab-feedback {
  --fb-card: #0f1a30;
  --fb-band: #0f1a30;
  --fb-surface: #17243f;
  --fb-math-bg: #070e1c;
  --fb-math-line: #17243f;
  --fb-track: #17243f;
  --fb-gain-bg: #0f1a30; --fb-gain-line: #26354f; --fb-gain-ink: #a8bfff; --fb-gain-mark: #a8bfff;
  --fb-loss-bg: #3a2420; --fb-loss-line: #63392f; --fb-loss-ink: #f2b4a4; --fb-loss-mark: #e0907a;
  --fb-wait-bg: #3a3218; --fb-wait-ink: #f0d58a;
  --fb-detail: #a9b6c9;
  --fb-badge-line: #26354f;
  --fb-chg-bg: rgba(168, 191, 255, .2);
  --fb-chg-line: #a8bfff;
  --fb-chg-ink: #a8bfff;
  --fb-callout-bg: #332c17; --fb-callout-line: #5a4a1f; --fb-callout-rail: #d9a53a; --fb-callout-ink: #f0d58a;
  --fb-mat-line: #26354f;
  --fb-scroll-shade: rgba(0, 0, 0, .6);
  --fb-mark-ink: #070e1c;
}
:root[data-theme="dark"] .lab-feedback .feedback-mark { color: var(--fb-mark-ink); }
:root[data-theme="dark"] .lab-feedback .feedback-image { background: #fff; border-color: var(--fb-mat-line); }
:root[data-theme="dark"] .lab-feedback .feedback-zoom { background: rgba(23, 36, 63, .92); border-color: #26354f; color: #a8bfff; }
:root[data-theme="dark"] .lab-feedback button { border-color: #26354f; }

/* ---------- card layout when the key has steps or figures ---------- */
/* The answer box takes the full card width under 내 답안 (side by side stays for short keys). */
@media (min-width: 1000px) {
  .feedback-unit-rich .feedback-unit-body { display: block; }
  .feedback-unit-rich .feedback-unit-body > * + * { margin-top: 32px; }
  .feedback-unit-rich .feedback-answers { max-width: 640px; }
  .feedback-unit-rich .feedback-unit-body > .feedback-grading { margin-top: 32px; }
}
.feedback-unit-rich .feedback-model > summary { padding-top: 20px; border-top: 1px solid var(--lab-line); margin-bottom: 16px; }
.feedback-unit-rich .feedback-model:not([open]) > summary { margin-bottom: 0; }

/* ---------- the box ---------- */
.fb-rich { line-height: 1.75; }
.fb-rich p { margin: 8px 0; }
.fb-rich :is(ul, ol):not(.fb-steps) { margin: 8px 0; padding-left: 22px; }
.fb-rich li + li { margin-top: 4px; }
.fb-prose { max-width: var(--fb-measure); }

/* 1. Final answer: a quiet panel with the accent rail, read first */
.fb-answer { max-width: calc(var(--fb-measure) + 40px); margin: 0 0 32px; padding: 14px 20px 14px 18px; border-left: 4px solid var(--lab-accent);
  border-radius: 0 var(--fb-radius) var(--fb-radius) 0; background: var(--fb-surface); font-size: 15.5px; }
.fb-answer > :first-child { margin-top: 0; }
.fb-answer > :last-child { margin-bottom: 0; }
.fb-answer > h4 { margin: 0 0 6px; font-size: 13px; font-weight: 650; color: var(--fb-badge-ink); }

/* Part label (source bold-only line or ### heading) */
.fb-part { margin: 0 0 8px; }
.fb-part + .fb-part, .fb-answer + .fb-part { margin-top: 0; }
.fb-part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 18px; padding: 0 0 10px; border-bottom: 1px solid var(--lab-line); }
.fb-part-head h4 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.fb-part-count { font-size: 13px; color: var(--lab-muted); font-variant-numeric: tabular-nums; }
.fb-part-head .fb-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 0 auto; font-size: 12.5px; line-height: 1.5; color: var(--lab-muted); }
.fb-legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fb-legend .katex { font-size: 1.1em; }

/* 2. Steps: numbered badges on a rail; the equation stack sits in an inset panel under the reason */
.fb-rich .fb-steps { container: fb-steps / inline-size; margin: 0; padding: 0; list-style: none; } /* beats .feedback-key-body :is(ul, ol) */
.fb-step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 16px; padding: 0 0 24px; }
.fb-step::before { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1px; background: var(--fb-rail); }
.fb-step:last-child { padding-bottom: 8px; }
.fb-step:last-child::before { display: none; }
.fb-badge { grid-column: 1; grid-row: 1; align-self: start; display: grid; place-items: center; width: 28px; height: 28px; box-sizing: border-box;
  border: 1.5px solid var(--fb-badge-line); border-radius: 50%; background: var(--fb-card); color: var(--fb-badge-ink);
  font-size: 13.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.fb-step-main { grid-column: 2; min-width: 0; }
.fb-step-text { margin: 1px 0 0; max-width: var(--fb-measure); }
.fb-step-main > p:not(.fb-step-text) { max-width: var(--fb-measure); }
.fb-step-side { grid-column: 2; min-width: 0; }

/* The equation stack: one row per source line; rows that start with a relation line up under the first row's. */
.fb-eqs { width: fit-content; min-width: min(100%, 360px); max-width: 100%; box-sizing: border-box; margin: 12px 0 0; padding: 6px 20px;
  border: 1px solid var(--fb-math-line); border-radius: var(--fb-radius); background: var(--fb-math-bg); }
.fb-eq { min-width: 0; }
.lab-feedback .fb-eq .feedback-math-display { overflow: visible; }
.lab-feedback .fb-eq .katex-display { margin: 0; padding: 8px 0; text-align: left;
  background:
    linear-gradient(to right, var(--fb-math-bg) 40%, transparent) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--fb-math-bg) 40%, transparent) right / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--fb-scroll-shade), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--fb-scroll-shade), transparent) right / 10px 100% no-repeat scroll; }
.lab-feedback .fb-eq .katex-display > .katex { text-align: left; font-size: 1.12em; }
.fb-eq + .fb-eq .katex-display { padding-top: 2px; }
.fb-eq[data-cont] .katex-display > .katex { padding-left: var(--fb-eq-indent, 1.5em); }

/* \changed{…}: tint box + 2 px rule under it + accent ink (three cues; the box and the rule stay in grey) */
.lab-feedback .fb-chg { background-color: var(--fb-chg-bg); box-shadow: inset 0 -2px 0 var(--fb-chg-line); border-radius: 12px 12px 0 0; }
.lab-feedback .fb-chg-ink { color: var(--fb-chg-ink); }

/* 3. Figures: white mat, caption under it; side figures sit beside the equations on wide boxes */
.fb-fig { margin: 14px 0 0; }
.fb-fig[data-shape="wide"] { max-width: 720px; }
.fb-fig[data-shape="side"] { max-width: 360px; }
.fb-fig-frame { position: relative; display: block; box-sizing: border-box; padding: 8px; border: 1px solid var(--fb-mat-line); border-radius: var(--fb-radius);
  padding-bottom: 32px; background: var(--fb-mat); color: inherit; }
.feedback-key-body .fb-fig-frame > img { display: block; width: 100%; height: auto; margin: 0; }
.fb-fig-frame > .fb-fig-wait { width: 100%; }
.feedback-key-body .fb-fig-wait { display: grid; place-items: center; margin: 0; color: #617079; font-size: 13px; }
/* The zoom tag sits in a strip of the white mat under the PNG, so it never covers a label; light style in both themes. */
:root .lab-feedback .fb-fig .feedback-zoom { top: auto; bottom: 5px; right: 8px; padding: 0 8px; border-color: var(--line, #e1e5ec); background: #fff; color: var(--go, #1f4fd8); font-size: 11.5px; line-height: 1.7; }
.fb-fig figcaption { margin: 8px 2px 0; font-size: 13.5px; line-height: 1.6; color: var(--fb-detail); }
.fb-fig figcaption > b { margin-right: 6px; font-weight: 650; color: var(--lab-ink); }
.fb-fig figcaption .katex { font-size: 1.02em; }
.fb-fig-frame:hover { border-color: var(--lab-accent); }
.lab-feedback .fb-fig-frame:focus-visible { outline-offset: 2px; }

/* 4. Callout '자주 틀린 곳' */
.fb-callout { max-width: calc(var(--fb-measure) + 40px); margin: 32px 0 0; padding: 14px 20px 16px 16px; border: 1px solid var(--fb-callout-line);
  border-left: 4px solid var(--fb-callout-rail); border-radius: 0 var(--fb-radius) var(--fb-radius) 0; background: var(--fb-callout-bg); }
.fb-callout > h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--fb-callout-ink); }
.fb-callout-icon { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--fb-callout-ink);
  color: var(--fb-callout-bg); font-size: 13px; font-weight: 800; line-height: 1; }
.fb-callout > :last-child { margin-bottom: 0; }
.fb-callout ul { padding-left: 20px; }

/* Blocks after the steps (e.g. the source's '확인:' line) line up with the step text. */
.fb-rich .fb-after { margin-left: 44px; max-width: var(--fb-measure); }

/* Wide box: a side figure gets its own column beside the reason and the equations. */
@container fb-steps (min-width: 720px) {
  .fb-step.fb-has-side { grid-template-columns: 28px minmax(0, 1fr) minmax(240px, 320px); }
  .fb-step.fb-has-side .fb-step-side { grid-column: 3; grid-row: 1 / span 2; }
  .fb-step.fb-has-side .fb-fig[data-shape="side"]:first-child { margin-top: 2px; }
}
/* Narrow box (phones): badge beside the reason only; equations and figures take the full width under it. */
@container fb-steps (max-width: 519px) {
  .fb-step { grid-template-columns: 26px minmax(0, 1fr); column-gap: 10px; padding-bottom: 20px; }
  .fb-step::before { display: none; }
  .fb-badge { width: 26px; height: 26px; font-size: 13px; }
  .fb-step-main { display: contents; }
  .fb-step-text { grid-column: 2; }
  .fb-step-main > :not(.fb-step-text), .fb-step-side { grid-column: 1 / -1; }
  .fb-eqs { min-width: 100%; padding: 4px 12px; }
  .lab-feedback .fb-eq .katex-display > .katex { font-size: 1.05em; }
  .fb-fig[data-shape="side"] { max-width: 100%; }
}
@media (max-width: 640px) {
  .fb-answer { padding: 12px 14px 12px 12px; font-size: 15px; }
  .fb-callout { padding: 12px 14px 14px 12px; }
  .fb-rich .fb-after { margin-left: 0; }
  .fb-part-head .fb-legend { margin-left: 0; flex-basis: 100%; }
  .feedback-unit-rich .feedback-model > summary { padding-top: 16px; }
}
@media print {
  .lab-feedback .fb-chg, .fb-answer, .fb-callout, .fb-eqs { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .fb-step, .fb-fig, .fb-callout { break-inside: avoid; }
  .fb-fig .feedback-zoom { display: none; }
}

/* Round 6: one page per problem (paging-opus design). The summary and each problem are pages of one document;
   wide screens get an index rail (the book sidebar's look), narrow screens a bottom bar and an index sheet. */
/* ---------- tokens ---------- */
.lab-feedback {
  --fb-rail-w: 216px;                       /* index rail, wide screens */
  --fb-bar-h: 60px;                         /* phone bar without the safe area */
  --fb-control-line: var(--line-2, #c8cfda);               /* = the lab button border literal */
  --fb-bar-shadow: 0 -6px 18px rgba(37, 52, 60, .10); /* new: ink #25343c at 10 %, lifts the bar off the page */
  --fb-backdrop: rgba(20, 30, 35, .45);     /* = .lab-dialog::backdrop */
}
:root[data-theme="dark"] .lab-feedback {
  --fb-control-line: #26354f;               /* = the dark button border above */
  --fb-bar-shadow: 0 -6px 18px rgba(0, 0, 0, .55);
  --fb-backdrop: rgba(0, 0, 0, .6);
}

/* ---------- pages ---------- */
.fb-main, .fb-page { min-width: 0; }
.fb-page > .feedback-unit { margin-bottom: 0; }
.fb-page.fb-enter { animation: fb-page-in .14s ease-out; }
@keyframes fb-page-in { from { opacity: 0; } }
/* The heading takes focus after a turn; the ring shows only for keyboard turns. */
.lab-feedback [tabindex="-1"]:focus { outline: none; }
.lab-feedback [tabindex="-1"]:focus-visible { outline: 3px solid var(--fb-focus); outline-offset: 4px; border-radius: 2px; }
/* The rubric legend now sits under each 채점 기준 heading. */
.feedback-detail > .feedback-legend { margin: -4px 0 10px; gap: 4px 14px; font-size: 12.5px; }

/* ---------- index list (rail rows; sheet tiles below) ---------- */
.fb-index { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; }
.fb-index-link { display: grid; grid-template-columns: 2.8em minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 3px;
  padding: 7px 8px 7px 9px; border-left: 3px solid transparent; border-radius: 0 12px 12px 0; color: var(--lab-ink); text-decoration: none; }
.fb-index-link:hover { background: var(--fb-card); }
.fb-index-link[aria-current="page"] { border-left-color: var(--lab-accent); background: var(--fb-gain-bg); color: var(--fb-gain-ink); }
.fb-index-id { font-weight: 650; white-space: nowrap; }
.fb-index-meter { display: block; height: 4px; border-radius: 2px; background: var(--fb-track); overflow: hidden; }
.fb-index-meter > span { display: block; height: 100%; background: var(--lab-accent); }
.fb-index-score { grid-column: 3; justify-self: end; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-index-score > span { font-weight: 400; color: var(--lab-muted); }
.fb-index-link[aria-current="page"] .fb-index-score > span { color: inherit; }
.fb-index .feedback-chip { grid-column: 2 / -1; justify-self: start; font-size: 11.5px; }
.fb-index-top { margin: 0 0 6px; padding: 0 0 6px; border-bottom: 1px solid var(--lab-line); }

/* ---------- rail (wide) ---------- */
.fb-rail { display: none; }
.fb-rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 6px 10px; }
.fb-rail-title { font-size: 13px; font-weight: 650; color: var(--lab-muted); }
.fb-rail .fb-count { font-size: 13px; color: var(--lab-muted); font-variant-numeric: tabular-nums; }
.fb-rail-turn { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 8px; padding: 0 2px 12px; border-bottom: 1px solid var(--lab-line); }
.fb-turn { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 36px; white-space: nowrap; box-sizing: border-box; border: 1px solid var(--fb-control-line); border-radius: 12px;
  background: var(--fb-card); color: var(--lab-accent); font-size: 14px; font-weight: 600; text-decoration: none; }
.fb-turn[href]:hover { background: var(--lab-surface); }
.fb-turn:not([href]), .fb-bar-turn:not([href]) { border-color: var(--lab-line); color: var(--lab-muted); opacity: .55; cursor: default; }
.fb-rail-foot { margin: 10px 0 0; padding: 12px 4px 0; border-top: 1px solid var(--lab-line); }
.lab-feedback .fb-print { width: 100%; }
.fb-print-status { margin: 6px 0 0; font-size: 12.5px; color: var(--lab-muted); }
.fb-print-status:empty { display: none; }
.fb-keys { margin: 10px 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--lab-muted); }

/* ---------- pager under a page (wide): the book's page-nav as two cards ---------- */
.fb-pager { display: none; }
.fb-pager a { display: block; min-width: 200px; box-sizing: border-box; padding: 10px 14px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius);
  background: var(--fb-card); color: var(--fb-gain-ink); font-size: 15px; font-weight: 650; text-decoration: none; }
.fb-pager a[href]:hover { border-color: var(--fb-control-line); background: var(--fb-band); }
.fb-pager a:not([href]) { visibility: hidden; }
.fb-pager small { display: block; margin: 0 0 2px; font-size: 12.5px; font-weight: 400; color: var(--lab-muted); }
.fb-pager-prev { justify-self: start; }
.fb-pager-next { justify-self: end; text-align: right; }
.fb-pager-count { margin: 0; font-size: 13px; color: var(--lab-muted); font-variant-numeric: tabular-nums; }

/* ---------- bar (narrow): fixed at the bottom, within thumb reach ---------- */
.fb-bar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
  box-sizing: border-box; min-height: calc(var(--fb-bar-h) + env(safe-area-inset-bottom));
  padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--lab-line); background: var(--fb-card); box-shadow: var(--fb-bar-shadow); }
.fb-bar-turn { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 76px; min-height: 44px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--fb-control-line);
  border-radius: 6px; background: var(--fb-card); color: var(--lab-accent); font-size: 15px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.lab-feedback .fb-bar-index { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--lab-line); border-radius: 6px; background: var(--fb-band); color: var(--lab-ink); font-size: 15px; }
.fb-bar-index b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.fb-bar-index .fb-count { font-size: 13.5px; color: var(--lab-muted); font-variant-numeric: tabular-nums; }
.fb-bar-icon { flex: none; width: 16px; height: 12px; color: var(--lab-muted);
  background: linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat, linear-gradient(currentColor, currentColor) 0 5px / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 10px / 100% 2px no-repeat; }
/* While the reader types an inquiry the phone keyboard is up: the bar steps aside. */
.lab-feedback:has(.feedback-inquiry textarea:focus) .fb-bar { display: none; }

/* ---------- sheet (narrow): the index as a bottom sheet ---------- */
.fb-sheet { box-sizing: border-box; width: 100%; max-width: 640px; max-height: min(85vh, 720px); margin: auto auto 0; padding: 0; border: 0;
  border-radius: 14px 14px 0 0; background: var(--fb-card); color: var(--lab-ink); overflow-y: auto; overscroll-behavior: contain; }
.fb-sheet::backdrop { background: var(--fb-backdrop); }
.fb-sheet[open] { animation: fb-sheet-in .18s ease-out; }
@keyframes fb-sheet-in { from { transform: translateY(32px); opacity: 0; } }
.fb-sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--lab-line); background: var(--fb-card); }
.lab-feedback .fb-sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.fb-sheet .fb-index { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 14px 16px 16px; }
.fb-sheet .fb-index-top { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.fb-sheet .fb-index-link { grid-template-columns: auto minmax(0, 1fr); align-content: start; align-items: baseline; row-gap: 6px; height: 100%; box-sizing: border-box;
  padding: 10px 12px 12px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-card); }
.fb-sheet .fb-index-id { grid-column: 1; grid-row: 1; }
.fb-sheet .fb-index-score { grid-column: 2; grid-row: 1; }
.fb-sheet .fb-index-meter { grid-column: 1 / -1; grid-row: 2; }
.fb-sheet .fb-index .feedback-chip { grid-column: 1 / -1; }
.fb-sheet .fb-index-link[aria-current="page"] { border-color: var(--lab-accent); box-shadow: inset 0 0 0 1px var(--lab-accent); background: var(--fb-gain-bg); }
.fb-sheet-foot { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

/* ---------- widths ---------- */
@media (min-width: 1100px) {
  .lab-feedback.fb-paging { max-width: 1400px; }
  .fb-paged { display: grid; grid-template-columns: var(--fb-rail-w) minmax(0, 1fr); column-gap: 32px; align-items: start; }
  .fb-rail { display: block; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; box-sizing: border-box;
    padding: 12px 8px 14px; border: 1px solid var(--lab-line); border-radius: var(--fb-radius); background: var(--fb-band); font-size: 13.5px; line-height: 1.4; }
  .fb-pager { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; margin: 32px 0 0; padding: 20px 0 0;
    border-top: 1px solid var(--lab-line); }
  .fb-bar { display: none; }
}
@media (max-width: 1099px) {
  .lab-feedback.fb-paging { padding-bottom: calc(var(--fb-bar-h) + 48px + env(safe-area-inset-bottom)); }
  /* Focus moves and find-in-page matches stop above the bar (60 px bar + 16 px). */
  html:has(.lab-feedback.fb-paging) { scroll-padding-bottom: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-page.fb-enter, .fb-sheet[open] { animation: none; }
}

/* ---------- print: every page, each problem on a new sheet ---------- */
@media print {
  .fb-rail, .fb-bar, .fb-pager, .fb-sheet { display: none !important; }
  .fb-paged { display: block !important; }
  .lab-feedback.fb-paging { max-width: none; padding-bottom: 0; }
  .fb-page[hidden] { display: block !important; content-visibility: visible !important; }
  .fb-page + .fb-page { break-before: page; }
  .fb-page.fb-enter { animation: none; }
}

/* D1: the unit comment spans the card, immediately below its score heading. */
.feedback-unit > .feedback-unit-comment { margin-bottom: 24px; }

/* ---------- Lab page reading aids: overview, step rail, callout, no-device detail, explanation, step index ----------
   Appended to lab/notebook.css. Same tokens as the model-answer steps (.fb-step, .fb-badge, .fb-callout): badge ring
   = --fb-gain-line, badge ink = --fb-gain-ink, rail = --lab-line, callout = --fb-callout-*. The book (shared/book.css)
   has no dark theme yet; these blocks turn dark only with :root[data-theme="dark"], like the rest of notebook.css, so a
   light book never shows half-dark blocks. */
.lab-overview, .lab-steps, .lab-why, .lab-callout, .lab-nodevice, .lab-index {
  --lp-ink: var(--ink, #25343c); --lp-muted: var(--muted, #617079); --lp-line: var(--line, #e1e5ec);
  --lp-band: #f8faf9;            /* book.css sidebar band */
  --lp-card: #fff;
  --lp-accent: var(--go, #1f4fd8);          /* site link colour */
  --lp-badge-line: var(--line-2, #c8cfda);      /* = --fb-gain-line */
  --lp-badge-ink: var(--go-2, #1638a8);
  --lp-current-bg: var(--go-t, #e5ecfd);      /* book.css current-chapter background */
  --lp-callout-bg: #fff4d6; --lp-callout-line: #f0dca0; --lp-callout-rail: #c7901c; --lp-callout-ink: #6b4e00;
  --lp-why-ink: var(--ink-2, #4a5466);         /* = .lead colour */
  --lp-page: var(--paper, #fff); /* badge and full-width blocks cover the rail with the page colour */
}
:root[data-theme="dark"] :is(.lab-overview, .lab-steps, .lab-why, .lab-callout, .lab-nodevice, .lab-index) {
  --lp-ink: #e8eef7; --lp-muted: #a9b6c9; --lp-line: #26354f; --lp-band: #0f1a30; --lp-card: #0f1a30; --lp-accent: #a8bfff;
  --lp-badge-line: #26354f; --lp-badge-ink: #a8bfff; --lp-current-bg: #0f1a30;
  --lp-callout-bg: #332c17; --lp-callout-line: #5a4a1f; --lp-callout-rail: #d9a53a; --lp-callout-ink: #f0d58a;
  --lp-why-ink: #a9b6c9; --lp-page: #141b1f;
}

/* 1. 오늘 할 일: one box under the lead. Facts first (장치, 연결 방식, 기록), then the numbered activities as cards. */
.lab-overview { container: lab-overview / inline-size; margin: 8px 0 36px; padding: 18px 20px 20px; border: 1px solid var(--lp-line);
  border-radius: 6px; background: var(--lp-band); color: var(--lp-ink); font-size: 15.5px; line-height: 1.7; }
.lab-overview > .lab-overview-title { margin: 0 0 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.lab-overview > p { position: relative; margin: 0 0 6px; padding-left: 6.2em; }
.lab-overview > p > strong:first-child { position: absolute; left: 0; color: var(--lp-badge-ink); font-weight: 650; }
.lab-overview > p.lab-overview-title { padding-left: 0; }
.lab-overview > ol { counter-reset: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.lab-overview > ol > li { position: relative; margin: 0; padding: 12px 14px 12px 50px; border: 1px solid var(--lp-line); border-radius: 6px; background: var(--lp-card); min-width: 0; }
.lab-overview > ol > li::before { content: counter(list-item); position: absolute; left: 12px; top: 12px; display: grid; place-items: center;
  width: 26px; height: 26px; box-sizing: border-box; border: 1.5px solid var(--lp-badge-line); border-radius: 50%; color: var(--lp-badge-ink);
  font-size: 15px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.lab-overview > ol > li > a { display: inline-block; margin: 0 0 4px; font-weight: 650; font-size: 16px; line-height: 1.55; }
.lab-overview > ol > li > ul { margin: 0; padding: 0; list-style: none; font-size: 15px; line-height: 1.6; }
.lab-overview > ol > li > ul > li { margin: 2px 0 0; color: var(--lp-ink); }
.lab-overview > ol > li > ul > li > strong:first-child { margin-right: .35em; color: var(--lp-muted); font-weight: 650; }
.lab-overview code { font-size: max(15px, .92em); }
@container lab-overview (min-width: 680px) {
  .lab-overview > ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .lab-overview { margin: 4px 0 28px; padding: 14px 14px 16px; font-size: 15px; }
  .lab-overview > p { padding-left: 0; }
  .lab-overview > p > strong:first-child { position: static; margin-right: .4em; }
  .lab-overview > ol > li { padding: 10px 12px 10px 44px; }
  .lab-overview > ol > li::before { left: 10px; top: 11px; width: 24px; height: 24px; font-size: 15px; }
}

/* 2. Step rail: a Markdown ordered list inside <div class="lab-steps">. Each list item is a step with a number badge;
   a cell, an answer box, a table or a callout between items hangs on the same rail, indented to the step text.
   The badge number is the list-item counter, so "3." after a cell continues as 3 (Markdown writes <ol start="3">). */
.lab-steps { position: relative; margin: 18px 0 28px; }
.lab-steps::before { content: ""; position: absolute; left: 13.5px; top: 14px; bottom: 14px; width: 1px; background: var(--lp-line); }
.lab-steps > ol { margin: 0; padding: 0; list-style: none; }
.lab-steps > ol > li { position: relative; margin: 0; padding: 1px 0 14px 44px; min-width: 0; }
.lab-steps > ol > li::before { content: counter(list-item); position: absolute; left: 0; top: 0; display: grid; place-items: center;
  width: 28px; height: 28px; box-sizing: border-box; border: 1.5px solid var(--lp-badge-line); border-radius: 50%; background: var(--lp-page);
  color: var(--lp-badge-ink); font-size: 15px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.lab-steps > :not(ol) { position: relative; margin-left: 44px; }      /* cell, answer, table, callout on the rail */
.lab-steps > .lab-cell { margin-top: 2px; margin-bottom: 18px; }
.lab-steps > .lab-answer { margin: 0 0 8px 44px; }
.lab-steps > .lab-answer > div > p:first-child { margin-top: 0; }
.lab-steps > .table-scroll { margin-top: 0; margin-bottom: 16px; font-size: 15px; }
.lab-steps > :last-child, .lab-steps > ol:last-child > li:last-child { padding-bottom: 0; margin-bottom: 0; }
@media (max-width: 540px) {
  .lab-steps::before { left: 11.5px; top: 12px; }
  .lab-steps > ol > li { padding-left: 36px; }
  .lab-steps > ol > li::before { width: 24px; height: 24px; font-size: 15px; }
  .lab-steps > :not(ol) { margin-left: 0; background: var(--lp-page); }  /* cells and tables take the full width */
  .lab-steps > .lab-answer { margin-left: 0; }
}

/* 3. The one caution that can damage the device: a quiet callout in the model-answer callout colours. */
.lab-callout { margin: 0 0 16px; padding: 10px 14px 10px 14px; border: 1px solid var(--lp-callout-line); border-left: 4px solid var(--lp-callout-rail);
  border-radius: 0 6px 6px 0; background: var(--lp-callout-bg); color: var(--lp-ink); font-size: 15.5px; line-height: 1.7; }
.lab-callout > p { margin: 0; }
.lab-callout strong { color: var(--lp-callout-ink); }

/* 3b. 장치 없이 할 때: closed by default, one line high. */
.lab-nodevice { margin: 0 0 24px; border: 1px solid var(--lp-line); border-radius: 6px; background: var(--lp-band); font-size: 15px; line-height: 1.75; }
.lab-nodevice > summary { cursor: pointer; padding: 8px 14px; font-weight: 650; color: var(--lp-ink); }
.lab-nodevice[open] > summary { border-bottom: 1px solid var(--lp-line); }
.lab-nodevice > :not(summary) { margin: 10px 14px 12px; }
.lab-nodevice code { overflow-wrap: anywhere; }

/* 4. Explanation after the steps: kept in full, smaller and quieter than the procedure. */
.lab-why { margin: 0 0 32px; padding: 2px 0 2px 16px; border-left: 2px solid var(--lp-line); color: var(--lp-why-ink); font-size: 15.5px; line-height: 1.85; }
.lab-why > p { margin: 0 0 10px; }
.lab-why > :last-child { margin-bottom: 0; }

/* 5. Step index: the last row of the sticky lab toolbar (built by notebook.js from the page's ## headings). */
.lab-index { min-width: 0; max-width: 100%; flex-basis: 100%; display: flex; gap: 4px; margin: 2px 0 0; padding: 0; overflow-x: auto; scrollbar-width: none; list-style: none; }
.lab-index::-webkit-scrollbar { display: none; }
.lab-index a { flex: none; padding: 3px 10px; border: 1px solid var(--lp-line); border-radius: 999px; color: var(--lp-muted); font-size: 15px;
  line-height: 1.6; text-decoration: none; white-space: nowrap; }
.lab-index a:hover { color: var(--lp-accent); border-color: var(--lp-badge-line); }
.lab-index a[aria-current="step"] { background: var(--lp-current-bg); border-color: var(--lp-badge-line); color: var(--lp-badge-ink); font-weight: 650; }
.lab-toolbar ~ article h2 { scroll-margin-top: var(--lab-index-offset, 96px); }   /* the sticky toolbar does not cover a heading reached from the overview or index */
@media print { .lab-index { display: none; } .lab-nodevice { display: block; } }

/* Lab page layout modes. See layoutControl() in notebook.js.
   <html data-lab-layout="book|wide|split"> is set by notebook.js from the 화면 control; phones (<= 900 px) ignore it.
   book  = today's page (table of contents left, one 840 px reading column).
   wide  = table of contents folded, one reading column up to 1080 px.
   split = table of contents folded, the article in the left column (text, code), each cell's output in the right
           column beside its own cell, sticky until the next cell or the next section heading.
   Outputs never leave their cell: .lab-pane is a wrapper inside the cell (display: contents outside split). */

/* The 화면 control in the toolbar. */
.lab-layout { gap: 0; border: 1px solid var(--lab-line); border-radius: 12px; overflow: hidden; }
.lab-toolbar .lab-layout button { border: 0; border-radius: 0; min-height: 28px; padding: 3px 10px; background: var(--lab-bg); color: var(--lab-muted); }
.lab-toolbar .lab-layout button + button { border-left: 1px solid var(--lab-line); }
.lab-toolbar .lab-layout button[aria-pressed="true"] { background: var(--lab-surface); color: var(--lab-ink); font-weight: 650; box-shadow: inset 0 -2px 0 var(--lab-accent); }
.lab-toolbar .lab-layout button:disabled { background: var(--wash); color: var(--ink-2); border: 1px solid var(--line); cursor: default; }
.lab-pane { display: contents; }
@media (max-width: 900px) { .lab-toolbar .lab-layout { display: none; } }

@media screen and (min-width: 901px) {
  /* Fold: the shared sidebar column goes; the page navigation (이전/다음) and the 목차 보기 button remain. */
  html:is([data-lab-layout="wide"], [data-lab-layout="split"]) .book-layout { grid-template-columns: minmax(0, 1fr); }
  html:is([data-lab-layout="wide"], [data-lab-layout="split"]) .book-sidebar { display: none; }
  html[data-lab-layout="wide"] main .reading-width { max-width: 1080px; }
}

@media screen and (min-width: 1200px) {
  html[data-lab-layout="split"] .book-layout { max-width: none; }
  /* No side padding of its own: the textbook shell (t2, whole draft) sets the gutter, and 32 px here added to it
     (web-design D:9e7b67: the text started at x 64 at 1440 instead of the column line). */
  html[data-lab-layout="split"] main .reading-width { max-width: none; }
  /* Left column = 50 % of the article (text, code); the right 50 % holds the outputs. */
  html[data-lab-layout="split"] main article { --lab-gap: 28px; padding-right: 50%; padding-bottom: var(--lab-tail, 0px); position: relative; }
  html[data-lab-layout="split"] main article .lab-cell-live { position: relative; margin-top: calc(22px + var(--lab-push, 0px)); }
  html[data-lab-layout="split"] main article h2 { margin-top: calc(40px + var(--lab-push, 0px)); }
  html[data-lab-layout="split"] main article > h2:first-child { margin-top: var(--lab-push, 0px); }
  /* Pane width = from the cell's right edge + gap to the article's right edge; height = the cell's span (both set by notebook.js). */
  html[data-lab-layout="split"] main article .lab-pane {
    display: block; position: absolute; top: -1px; left: calc(100% + var(--lab-gap));
    width: var(--lab-pane-w, 100%); height: var(--lab-span, 100%);
  }
  html[data-lab-layout="split"] main article .lab-pane > .lab-output {
    position: sticky; top: min(var(--lab-index-offset, 120px), calc(100vh - var(--lab-out-h, 0px) - 12px));
    border: 1px solid var(--lab-line); border-left: 3px solid var(--lab-state, var(--lab-line)); background: var(--lab-bg);
    padding-top: 0;
  }
  /* Under the course bar of a course by kinds (the toolbar sticks under it, above). */
  html[data-course-layout="kinds"][data-lab-layout="split"] main article .lab-pane > .lab-output {
    top: min(calc(var(--course-bar-h, 0px) + var(--lab-index-offset, 120px)), calc(100vh - var(--lab-out-h, 0px) - 12px));
  }
  html[data-lab-layout="split"] main article .lab-pane > .lab-output::before {
    content: "결과 · " var(--lab-for, ""); display: block; margin: 0 -10px 4px; padding: 4px 10px;
    background: var(--lab-surface); border-bottom: 1px solid var(--lab-line); font: 15px/1.5 var(--lab-mono); color: var(--lab-muted);
  }
  html[data-lab-layout="split"] .lab-cell-live { --lab-state: var(--lab-line); }
  html[data-lab-layout="split"] .lab-cell-live:is([data-state="running"], [data-state="queued"]) { --lab-state: var(--lab-busy); }
  html[data-lab-layout="split"] .lab-cell-live[data-state="done"] { --lab-state: var(--lab-ok); }
  html[data-lab-layout="split"] .lab-cell-live[data-state="error"] { --lab-state: var(--lab-bad); }
  html[data-lab-layout="split"] .lab-cell-live[data-state="todo"] { --lab-state: #d4a017; }
  /* The cell whose output is pinned at the top of the right column. */
  html[data-lab-layout="split"] .lab-cell-live[data-shown] > .lab-cell-bar { box-shadow: inset 0 -2px 0 var(--lab-accent); }
  /* Plot columns open later in the narrower right column. */
  html[data-lab-layout="split"] .lab-columns { grid-template-columns: minmax(0, 1fr); }
  @container lab-output (min-width: 900px) {
    html[data-lab-layout="split"] .lab-columns { grid-template-columns: repeat(var(--lab-column-count), minmax(0, 1fr)); }
  }
}

@media print {
  html[data-lab-layout] .book-sidebar { display: revert; }
  html[data-lab-layout="split"] main article { padding-right: 0; }
  html[data-lab-layout="split"] main article .lab-pane { display: contents; }
}

.lab-admin-page :is(button, input, select, textarea) { font: inherit; }

.lab-grades a:not(.lab-primary) { color: var(--go); }
.lab-grades a.lab-primary { display: inline-block; padding: 5px 10px; border-radius: 12px; text-decoration: none; }
.lab-admin.lab-grades { box-sizing: content-box; max-width: var(--column); padding-inline: 32px; font-size: 18px; }
@media (max-width: 760px) {
  .lab-admin.lab-grades { padding-inline: 16px; }
}
