/* The chapter reader. The article markup comes from the books' pipeline (notes/pipeline/md2html.py
   via notes/tools/export_study.py): callout boxes (.box.<kind> > .bt), display maths (.dm),
   inline maths (.m, typeset by KaTeX), figures, tables, practice questions (h2.qs, ol.mcq,
   .opts > .opt, .parts > .part, .marks) and folded answers (details.ans). */

.rd-progress { position: fixed; z-index: 60; top: 0; left: 0; right: 0; height: 3px; background: transparent; pointer-events: none; }
.rd-progress span { display: block; height: 100%; width: 0; background: var(--syl-c, var(--md-primary)); }
.rd-page { --rd-scale: 1; padding-bottom: 80px; }
/* The reader owns the whole window: the site's bar is not rendered here, so
   nothing pads the top of main and the reader bar sits flush. The footer goes
   too -- the bar and the rails are the navigation. */
body.rd-mode .site-main { padding-top: 0; padding-bottom: 0; }
body.rd-mode .site-footer { display: none; }
/* The site's page-enter spring scales main from its centre; on a chapter that
   is twenty thousand pixels tall that lifts the whole page by ~160px while it
   runs, and a transformed main is a containing block, so the fixed reading
   progress bar lands mid-page. The reader paints settled instead. */
body.rd-mode .site-main { animation: none; }

/* ---------- the reader bar: back, what you are reading, three controls ---------- */
.rd-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  background: color-mix(in srgb, var(--md-surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.rd-bar-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.rd-bar-name { overflow: hidden; font-size: 15px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; color: var(--md-on-surface); }
.rd-bar-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.rd-bar-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--md-on-surface-variant); cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .12s ease; }
.rd-bar-btn:hover { background: var(--md-surface-container-high); color: var(--md-on-surface); }
.rd-bar-btn:active { transform: scale(.96); }
.rd-bar-btn:focus-visible { outline: 2px solid var(--md-primary); outline-offset: -2px; }
.rd-bar-btn .material-symbols-outlined { font-size: 22px; }
.rd-bar-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--md-outline-variant); }
.rd-bar-done[aria-pressed="true"], .rd-bar-done[aria-pressed="true"]:hover { background: var(--syl-c, var(--md-primary)); color: #fff; }
.rd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- three columns: units, the text, what is on this page ---------- */
.rd-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr) 232px; gap: 44px; max-width: 1400px; margin: 0 auto; padding: 28px 24px 0; align-items: start; }
.rd-units { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; padding-right: 4px; }
.rd-side { position: sticky; top: 84px; max-height: calc(100vh - 104px); }
.rd-page.rd-no-toc .rd-layout { grid-template-columns: 248px minmax(0, 1fr) 0; }
.rd-page.rd-no-toc .rd-side { display: none; }

.rd-unit-list { display: flex; flex-direction: column; gap: 1px; list-style: none; margin: 0; padding: 0; }
.rd-unit { display: flex; align-items: baseline; gap: 9px; padding: 7px 10px; border-radius: 10px; color: var(--md-on-surface-variant); text-decoration: none; font-size: 13.5px; line-height: 1.35; }
.rd-unit:hover { background: var(--md-surface-container-high); color: var(--md-on-surface); }
.rd-unit-no { flex: none; width: 17px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--md-on-surface-variant); }
.rd-unit-name { flex: 1; min-width: 0; }
.rd-unit-check { display: none; flex: none; font-size: 15px; color: var(--syl-c, var(--md-primary)); }
.rd-unit.is-read .rd-unit-check { display: block; }
.rd-unit.is-current { background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 12%, transparent); color: var(--md-on-surface); font-weight: 600; }
.rd-unit.is-current .rd-unit-no { color: color-mix(in srgb, var(--syl-c, var(--md-primary)) 62%, var(--md-on-surface)); }
.rd-unit.is-empty { opacity: .5; }
.rd-units-more { display: flex; flex-direction: column; margin-top: 24px; }
.rd-units-more .rd-side-head { margin-left: 10px; }
.rd-units-more a { padding: 6px 10px; border-radius: 9px; font-size: 13.5px; color: var(--md-on-surface-variant); text-decoration: none; }
.rd-units-more a:hover { background: var(--md-surface-container-high); color: var(--md-on-surface); }

.rd-side-inner { display: flex; flex-direction: column; max-height: inherit; }
.rd-side-head { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--md-on-surface-variant); }
/* One card per section: the row you are reading is filled in the subject's
   colour, the rest sit on the surface and lift on hover. */
.rd-toc { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; padding: 0; overflow-y: auto; scrollbar-width: thin; }
.rd-toc a { display: block; padding: 8px 11px; border: 1px solid transparent; border-radius: 10px; font-size: 13.5px; line-height: 1.4; color: var(--md-on-surface-variant); text-decoration: none; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.rd-toc a:hover { background: var(--md-surface-container-high); color: var(--md-on-surface); }
.rd-toc a.is-current { background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 10%, transparent); border-color: color-mix(in srgb, var(--syl-c, var(--md-primary)) 24%, transparent); color: color-mix(in srgb, var(--syl-c, var(--md-primary)) 68%, var(--md-on-surface)); font-weight: 600; }
.rd-toc a.rd-toc-qs::before { content: "quiz"; font-family: 'Material Symbols Outlined'; font-size: 15px; vertical-align: -3px; margin-right: 6px; }
.rd-article { width: 100%; max-width: 760px; min-width: 0; justify-self: center; }
.rd-head { margin-bottom: 22px; }
.rd-eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-title { margin: 0; font-size: clamp(26px, 3.4vw, 36px); line-height: 1.18; font-weight: 700; letter-spacing: -.015em; color: var(--md-on-surface); }
.rd-syllabus { margin-top: 16px; border: 1px solid var(--md-outline-variant); border-radius: 14px; background: var(--md-surface-container-low); }
.rd-syllabus summary { cursor: pointer; padding: 11px 14px; font-size: 14px; font-weight: 600; color: var(--md-on-surface); list-style: none; display: flex; align-items: center; gap: 8px; }
.rd-syllabus summary::-webkit-details-marker { display: none; }
.rd-syllabus summary::after { content: "expand_more"; font-family: 'Material Symbols Outlined'; font-weight: 400; font-size: 20px; margin-left: auto; color: var(--md-on-surface-variant); transition: transform .2s; }
.rd-syllabus[open] summary::after { transform: rotate(180deg); }
.rd-syllabus ul { margin: 0; padding: 0 16px 14px 34px; font-size: 14px; line-height: 1.6; color: var(--md-on-surface-variant); }
.rd-count { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }
.rd-head-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rd-chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 11px; border: 1px solid var(--md-outline-variant); border-radius: 999px; background: var(--md-surface); color: var(--md-on-surface); font: 600 13.5px var(--md-font); cursor: pointer; }
.rd-chip:hover { border-color: var(--md-outline); }
.rd-chip .material-symbols-outlined { font-size: 18px; color: var(--md-on-surface-variant); }
.rd-chip[aria-pressed="true"] { background: var(--md-on-surface); border-color: var(--md-on-surface); color: var(--md-surface); }
.rd-chip[aria-pressed="true"] .material-symbols-outlined { color: var(--md-surface); }
.rd-chip[hidden] { display: none; }
.rd-resume { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 9px 16px; border: 0; border-radius: 999px; background: var(--md-on-surface); color: var(--md-surface); font: 600 14px var(--md-font); cursor: pointer; transition: opacity .3s; }
.rd-resume .material-symbols-outlined { font-size: 18px; }
.rd-resume.is-quiet { opacity: .7; }

/* ---------- the text ---------- */
.rd-body { --rd-fs: calc(16.5px * var(--rd-scale)); font-size: var(--rd-fs); line-height: 1.75; color: var(--md-on-surface); overflow-wrap: break-word; }
.rd-body:lang(ne), .rd-article:lang(ne) .rd-body { line-height: 1.9; }
.rd-body p { margin: 0 0 1em; }
.rd-body h2 { margin: 2.2em 0 .7em; padding-top: .2em; font-size: 1.36em; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; scroll-margin-top: 90px; }
.rd-body h3 { margin: 1.7em 0 .5em; font-size: 1.12em; line-height: 1.35; font-weight: 600; }
.rd-body h4 { margin: 1.4em 0 .4em; font-size: 1em; font-weight: 600; }
.rd-body ul, .rd-body ol { margin: 0 0 1em; padding-left: 1.5em; }
.rd-body li { margin: .3em 0; }
.rd-body li.num { list-style: none; }
.rd-body a { color: var(--md-primary); }
.rd-body strong { font-weight: 600; }
.rd-body blockquote { margin: 1.2em 0; padding: .2em 0 .2em 1.1em; border-left: 3px solid var(--md-outline-variant); color: var(--md-on-surface-variant); }
.rd-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; padding: .1em .35em; border-radius: 6px; background: var(--md-surface-container-high); }
.rd-body pre { margin: 1.2em 0; padding: 14px 16px; border-radius: 12px; background: var(--md-surface-container-high); overflow-x: auto; font-size: .86em; line-height: 1.55; }
.rd-body pre code { padding: 0; background: none; }
.rd-body hr { border: 0; border-top: 1px solid var(--md-outline-variant); margin: 2em 0; }

/* tables: a shell with a header band, not a stack of loose rules. display:block
   is what lets a wide table scroll inside itself on a phone instead of pushing
   the page sideways. Zebra and hover mix --md-on-surface into transparency, so
   one value reads correctly on both themes without a dark override. */
.rd-body table { display: block; max-width: 100%; overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--md-outline-variant); border-radius: 14px; border-collapse: separate; border-spacing: 0; background: var(--md-surface-container-low); font-size: .9em; line-height: 1.5; font-variant-numeric: tabular-nums; }
.rd-body th, .rd-body td { padding: .6em .85em; text-align: left; vertical-align: top; border-bottom: 1px solid var(--md-outline-variant); }
.rd-body th { color: var(--md-on-surface); font-size: .82em; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 7%, var(--md-surface-container-low)); border-bottom-color: color-mix(in srgb, var(--syl-c, var(--md-primary)) 34%, var(--md-outline-variant)); }
.rd-body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); }
.rd-body tbody td:first-child { font-weight: 600; }
.rd-body tbody tr:last-child > th, .rd-body tbody tr:last-child > td { border-bottom: 0; }
@media (hover: hover) {
  .rd-body tbody tr:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
}

/* maths */
.rd-body .m { white-space: normal; }
.rd-body .m-raw { font-family: ui-monospace, monospace; font-size: .9em; white-space: normal; }
.rd-body .dm { margin: 1em 0; overflow-x: auto; overflow-y: hidden; text-align: center; padding: .2em 0; }
.rd-body .dm .m { display: block; }
.rd-body .katex { font-size: 1.07em; }
.rd-body .katex-display { margin: 0; }
.rd-body .eqx .fr { display: inline-block; vertical-align: -.62em; text-align: center; }
.rd-body .eqx .fr .fn { display: block; padding: 0 .34em 1px; border-bottom: 1px solid currentColor; }
.rd-body .eqx .fr .fd { display: block; padding: 1px .34em 0; }

/* figures and photographs: the figures are drawn for paper, so they sit on a paper card in
   dark mode too */
.rd-body figure { margin: 1.6em 0; text-align: center; }
.rd-body figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 12px; background: #fff; padding: 10px; box-sizing: border-box; }
.rd-body figure.photo img { padding: 0; }
.rd-zf { position: relative; display: inline-block; max-width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 12px; }
.rd-zf:focus-visible { outline: 2px solid var(--md-on-surface); outline-offset: 3px; }
.rd-zb { position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px; border-radius: 15px; background: rgba(20, 20, 20, .62); color: #fff; font-size: 17px; line-height: 30px; text-align: center; pointer-events: none; opacity: .85; transition: opacity .2s; }
.rd-zf:hover .rd-zb { opacity: 1; }
.rd-zoom { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: #0b0b0b; user-select: none; }
.rd-zoom-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: grab; }
.rd-zoom-stage img { max-width: min(100%, 1400px); max-height: 100%; background: #fff; border-radius: 6px; transform-origin: 50% 50%; }
.rd-zoom-x { position: absolute; z-index: 2; top: 12px; right: 12px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 22px; background: rgba(28, 28, 28, .82); box-shadow: 0 0 0 1px rgba(255, 255, 255, .2); color: #fff; cursor: pointer; }
.rd-zoom-x:hover { background: rgba(48, 48, 48, .9); }
.rd-zoom-cap { margin: 0 auto; padding: 10px 20px 18px; max-width: 900px; max-height: 26vh; overflow: auto; color: #d6d6d6; font-size: 14px; line-height: 1.55; }
.rd-zoom-hint { position: absolute; z-index: 2; left: 50%; bottom: calc(26vh + 10px); transform: translateX(-50%); padding: 6px 14px; border-radius: 99px; background: rgba(255, 255, 255, .12); color: #eee; font-size: 12.5px; transition: opacity .4s; white-space: nowrap; }
.rd-zoom-hint.is-gone { opacity: 0; }
.rd-body figcaption { margin-top: .7em; font-size: .86em; line-height: 1.55; color: var(--md-on-surface-variant); text-align: left; }
.rd-body figcaption .src { display: block; margin-top: .3em; font-size: .85em; opacity: .8; }
/* figure keys — the number is a marker, not the first word of the sentence. A
   grid gives it its own column, so a label that wraps hangs under its own text
   instead of doubling back under the number. */
.rd-body .photokey { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55em 1.6em; margin: .7em auto 0; max-width: 96%; text-align: left; font-size: .86em; }
.rd-body .photokey .pk { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .55em; align-items: start; padding: .45em .7em .5em; border: 1px solid color-mix(in srgb, var(--syl-c, var(--md-primary)) 26%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 10%, var(--md-surface-container-low)); }
.rd-body .photokey .pk:only-child { grid-column: 1 / -1; }
/* the accent hues are dark in both themes, so the digit on top of them is a
   fixed light -- no dark override needed */
.rd-body .photokey .pk i { display: grid; place-items: center; margin-top: .14em; min-width: calc(1.3 * var(--rd-fs)); height: calc(1.3 * var(--rd-fs)); padding-inline: .12em; border-radius: 999px; background: var(--syl-c, var(--md-primary)); color: #fff; font: 700 calc(.78 * var(--rd-fs))/1 var(--md-font); font-variant-numeric: tabular-nums; font-style: normal; }

/* callouts — a titled panel. --box-c is the kind: it colours the label and the
   rule under it, and nothing else. --box-pad-x is in --rd-fs terms, not em, so
   the header's negative margin matches the panel padding even though the label
   shrinks its own font-size. */
.rd-body .box { --box-c: var(--md-on-surface-variant); --box-pad-x: calc(1.15 * var(--rd-fs)); margin: 1.4em 0; padding: 1em var(--box-pad-x) 1.05em; border-radius: 14px; background: var(--md-surface-container-low); border: 1px solid var(--md-outline-variant); }
.rd-body .box > :last-child { margin-bottom: 0; }
.rd-body .box .bt, .rd-body details.ans > summary { font-size: .78em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; margin-bottom: .45em; color: var(--md-on-surface-variant); }
.rd-body .box .bt { color: var(--box-c); margin: 0 calc(var(--box-pad-x) * -1) .6em; padding: 0 var(--box-pad-x) .55em; border-bottom: 1px solid color-mix(in srgb, var(--box-c) 26%, var(--md-outline-variant)); }
.rd-body .box.key { --box-c: var(--syl-c, var(--md-primary)); background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 6%, var(--md-surface)); }
.rd-body .box.definition { --box-c: var(--md-on-surface); }
.rd-body .box.example { --box-c: #64748b; }
.rd-body .box.derivation { --box-c: #6d5bd0; }
.rd-body .box.caution { --box-c: #a8650a; }
.rd-body .box.tip { --box-c: #0b7a70; }
.rd-body .box.memory { --box-c: #a3437f; }
.rd-body .box.note { --box-c: var(--md-on-surface-variant); }
[data-theme="dark"] .rd-body .box.caution { --box-c: #f0b35e; }
[data-theme="dark"] .rd-body .box.tip { --box-c: #5ed3c6; }
[data-theme="dark"] .rd-body .box.derivation { --box-c: #b2a7ff; }
[data-theme="dark"] .rd-body .box.memory { --box-c: #f29ad1; }

/* chapter summary */
.rd-body .chsum { margin: 2.2em 0 1.4em; padding: 1.1em 1.3em .4em; border-radius: 16px; background: var(--md-surface-container-low); border: 1px solid var(--md-outline-variant); }
.rd-body .chsum h2 { margin-top: 0; font-size: 1.15em; }
.rd-body .chsum h2::before { content: "checklist"; font-family: 'Material Symbols Outlined'; font-weight: 400; font-size: 1.2em; vertical-align: -.2em; margin-right: .35em; color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-body .chsum ul.cols2 { columns: 2; column-gap: 2em; }
.rd-body .chsum ul.cols2 li { break-inside: avoid; }

/* practice questions */
.rd-body h2.qs { padding-top: 1.2em; border-top: 1px solid var(--md-outline-variant); }
.rd-body h2.qs::before { content: "quiz"; font-family: 'Material Symbols Outlined'; font-weight: 400; font-size: 1.05em; vertical-align: -.15em; margin-right: .35em; color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-body .marks { margin-left: .35em; padding: .05em .5em; border-radius: 99px; font-size: .74em; font-weight: 600; color: var(--md-on-surface-variant); background: var(--md-surface-container-high); white-space: nowrap; vertical-align: .08em; }
.rd-body .opts { display: grid; gap: .45em; margin: .6em 0 .2em; }
.rd-body .opts.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rd-body .opts.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rd-body .opts.c1 { grid-template-columns: 1fr; }
.rd-body .opt { display: flex; align-items: baseline; gap: .55em; padding: .45em .7em; border-radius: 10px; border: 1px solid var(--md-outline-variant); background: var(--md-surface); line-height: 1.45; }
.rd-body .opt > i { flex: none; font-style: normal; font-weight: 700; font-size: .85em; color: var(--md-on-surface-variant); }
.rd-body .opt > i::after { content: "."; }
.rd-body .mcq-p { margin: 0 0 1.2em; }
.rd-body .mcq-p > p { margin-bottom: .2em; }
.rd-body [data-key] .opt { cursor: pointer; transition: border-color .15s, background .15s; }
.rd-body [data-key]:not(.is-answered) .opt:hover { border-color: var(--md-outline); background: var(--md-surface-container-low); }
.rd-body [data-key] .opt:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 1px; }
.rd-body [data-key] .opt.is-right { border-color: #1f8a4c; background: color-mix(in srgb, #1f8a4c 12%, var(--md-surface)); }
.rd-body [data-key] .opt.is-right > i { color: #1f8a4c; }
.rd-body [data-key] .opt.is-wrong { border-color: #c2412d; background: color-mix(in srgb, #c2412d 10%, var(--md-surface)); }
.rd-body [data-key] .opt.is-wrong > i { color: #c2412d; }
.rd-body [data-key].is-answered .opt { cursor: default; }
.rd-body ol.mcq > li { margin-bottom: 1em; }
.rd-body .parts { display: block; margin: .4em 0 0; }
.rd-body .part { display: block; margin: .35em 0; padding-left: 1.9em; text-indent: -1.9em; }
.rd-body .part > i { display: inline-block; width: 1.9em; text-indent: 0; font-style: normal; font-weight: 600; color: var(--md-on-surface-variant); }
.rd-tip { margin: .2em 0 .8em; font-size: .86em; color: var(--md-on-surface-variant); }

/* answers: closed until asked for */
.rd-body details.ans { margin: 1em 0 1.6em; border-radius: 14px; border: 1px dashed var(--md-outline); background: transparent; padding: 0; }
.rd-body details.ans > summary { display: flex; align-items: center; gap: .5em; margin: 0; padding: .8em 1.1em; cursor: pointer; list-style: none; color: var(--md-on-surface); }
.rd-body details.ans > summary::-webkit-details-marker { display: none; }
.rd-body details.ans > summary::before { content: "visibility"; font-family: 'Material Symbols Outlined'; font-weight: 400; font-size: 1.4em; letter-spacing: 0; text-transform: none; color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-body details.ans > summary::after { content: "Show"; margin-left: auto; font-size: .95em; letter-spacing: .02em; text-transform: none; font-weight: 600; color: var(--md-on-surface-variant); }
.rd-body details.ans[open] { border-style: solid; background: var(--md-surface-container-low); }
.rd-body details.ans[open] > summary::before { content: "visibility_off"; }
.rd-body details.ans[open] > summary::after { content: "Hide"; }
.rd-body .ans-body { padding: 0 1.15em 1em; }
.rd-body .ans-body > :last-child { margin-bottom: 0; }
.rd-body .ansline { margin: 0 0 .5em; }

/* ---------- the end of the chapter ---------- */
.rd-end { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--md-outline-variant); }
.rd-score { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 14px; border-radius: 14px; background: var(--md-surface-container-low); border: 1px solid var(--md-outline-variant); font-size: 14.5px; color: var(--md-on-surface); }
.rd-score[hidden] { display: none; }
.rd-score > .material-symbols-outlined { color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-score small { color: var(--md-on-surface-variant); font-size: 13.5px; }
.rd-link { margin-left: auto; border: 0; background: none; padding: 4px 0; font: 600 13.5px var(--md-font); color: var(--md-primary); cursor: pointer; }
.rd-more { margin: 18px 0 0; font-size: 14px; color: var(--md-on-surface-variant); }
.rd-more a { color: var(--md-primary); font-weight: 600; }

/* Narrower rails rather than folding: down to 1024 the three columns still
   hold, with the text column around 600. Below that the contents fold into the
   sheet the bar's contents button opens. */
.rd-page.rd-no-units .rd-layout { grid-template-columns: minmax(0, 1fr) 232px; }
.rd-page.rd-no-toc .rd-layout { grid-template-columns: 248px minmax(0, 1fr); }
.rd-page.rd-no-units.rd-no-toc .rd-layout { grid-template-columns: minmax(0, 1fr); }
.rd-page.rd-no-units .rd-units { display: none; }
.rd-page.rd-no-toc .rd-side { display: none; }

/* A chapter list can be longer than the window, so the rail scrolls. The bar
   is invisible until you are in the rail: the gutter is always reserved, so
   showing it never moves a single row. */
.rd-units { scrollbar-width: thin; scrollbar-color: transparent transparent; scrollbar-gutter: stable; }
.rd-units:hover { scrollbar-color: var(--md-outline-variant) transparent; }
.rd-units::-webkit-scrollbar-thumb { background: transparent; }
.rd-units:hover::-webkit-scrollbar-thumb { background: var(--md-outline-variant); }

/* Class and subject, editable from the bar. Same disclosure as the syllabus
   breadcrumb, sized to the bar's eyebrow line. */
/* baseline, not centre: the label at the end is not a trigger box, and centring
   boxes of different construction left it two pixels above the other two. */
.rd-picks { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.rd-picks .st-pick { flex: none; }
/* the breadcrumb caps its trigger at the container width, and a percentage
   contributes nothing to max-content -- which is what squeezed "Class 12" into
   "CLASS...". In the bar the triggers keep their own width; only the title
   gives way. */
.rd-picks .st-pick-b { max-width: none; gap: 3px; padding: 1px 3px; margin: -1px -3px; border-radius: 6px; }
.rd-picks .st-pick-b:hover { background: var(--md-surface-container-high); }
.rd-picks .st-pick-b:hover .st-pick-t { text-decoration: none; color: var(--md-on-surface); }
.rd-picks .st-pick-t { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--md-on-surface-variant); }
.rd-picks .st-pick-i { width: 13px; height: 13px; font-size: 13px; }
/* the trigger sits on the bar's first line, so the menu clears the 60px bar
   instead of opening over it */
.rd-picks .st-pick-menu { top: calc(100% + 36px); }
/* one gap either side of each dot, so the row reads evenly */
.rd-pick-dot { flex: none; margin: 0 1px; font-size: 11px; color: var(--md-on-surface-variant); }
/* The label is not a link, but it rides in the same .st-pick-t box the triggers
   use -- that box carries a 1px transparent border for the focus ring, and a
   bare span without it sat two pixels high against them. */
.rd-pick-doc { flex: none; padding: 0 4px; }
.rd-i-shut { display: none; }
.rd-page.rd-no-units .rd-i-open { display: none; }
.rd-page.rd-no-units .rd-i-shut { display: inline-block; }

@media (max-width: 1240px) {
  .rd-layout { grid-template-columns: 232px minmax(0, 1fr) 208px; gap: 30px; padding: 24px 20px 0; }
  .rd-page.rd-no-units .rd-layout { grid-template-columns: minmax(0, 1fr) 208px; }
  .rd-page.rd-no-toc .rd-layout { grid-template-columns: 232px minmax(0, 1fr); }
  .rd-page.rd-no-units.rd-no-toc .rd-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .rd-layout { grid-template-columns: 226px minmax(0, 1fr); gap: 34px; }
  .rd-page.rd-no-toc .rd-layout { grid-template-columns: 226px minmax(0, 1fr); }
  .rd-page.rd-no-units .rd-layout,
  .rd-page.rd-no-units.rd-no-toc .rd-layout { grid-template-columns: minmax(0, 1fr); }
  /* the contents are a sheet again here, whatever the wide-window state was */
  .rd-page.rd-no-toc .rd-side { display: block; }
  .rd-side { position: fixed; z-index: 70; inset: 0; top: 0; max-height: none; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .rd-side.is-open { opacity: 1; pointer-events: auto; }
  .rd-side-inner { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72vh; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: var(--md-surface-container); transform: translateY(24px); transition: transform .25s cubic-bezier(.2, 0, 0, 1); }
  .rd-side.is-open .rd-side-inner { transform: none; }
}
@media (max-width: 900px) {
  .rd-layout,
  .rd-page.rd-no-units .rd-layout,
  .rd-page.rd-no-toc .rd-layout,
  .rd-page.rd-no-units.rd-no-toc .rd-layout { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 0; }
  .rd-units { display: none; }
  [data-rd-units-toggle] { display: none; }
  .rd-picks .st-pick-t { font-size: 10.5px; }
  .rd-picks .rd-pick-doc, .rd-picks .rd-pick-dot[data-rd-doc-dot] { display: none; }
}
@media (max-width: 560px) {
  .rd-picks { display: none; }
  .rd-bar { padding: 0 10px; }
  .rd-bar-name { font-size: 14px; }
  .rd-bar-btn { width: 38px; height: 38px; }
  .rd-bar-sep { margin: 0 2px; }
}
@media (max-width: 600px) {
  .rd-body { --rd-fs: calc(16px * var(--rd-scale)); font-size: var(--rd-fs); }
  .rd-body .opts.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rd-body .opts.c2 { grid-template-columns: 1fr; }
  .rd-body .chsum ul.cols2 { columns: 1; }
  .rd-body .box { --box-pad-x: var(--rd-fs); padding: .85em var(--box-pad-x) .95em; }
  .rd-body .photokey { grid-template-columns: 1fr; }
}
@media print {
  .rd-progress, .rd-bar, .rd-units, .rd-side, .rd-end, .rd-resume, .rd-head-tools, .rd-zb { display: none !important; }
  .rd-layout { display: block; }
  .rd-body details.ans { border-style: solid; }
}

/* ---------- a model paper taken as a timed test (js/study-exam.js) ---------- */
.rd-chip.rd-chip-exam { background: var(--md-on-surface); border-color: var(--md-on-surface); color: var(--md-surface); }
.rd-chip.rd-chip-exam .material-symbols-outlined { color: var(--md-surface); }
.rd-chip.rd-chip-exam:hover { border-color: var(--md-on-surface); opacity: .92; }
.rd-exam-on .rd-body details.ans, .rd-exam-on .rd-x-key,
.rd-exam-on .rd-tip, .rd-exam-review .rd-tip,
.rd-exam-on [data-rd-score], .rd-exam-review [data-rd-score],
.rd-exam-on [data-rd-answers], .rd-exam-review [data-rd-answers] { display: none !important; }
.rd-page.rd-exam-on, .rd-page.rd-exam-review { padding-bottom: 120px; }

.rd-body [data-key] { scroll-margin: 96px 0; }
.rd-exam-on .rd-body [data-key] .opt.is-picked { border-color: var(--syl-c, var(--md-primary)); background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 11%, var(--md-surface)); box-shadow: inset 0 0 0 1px var(--syl-c, var(--md-primary)); }
.rd-exam-on .rd-body [data-key] .opt.is-picked > i { color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-exam-review .rd-body [data-key].is-blank .opt.is-right { border-style: dashed; }
.rd-body [data-key].is-flash, .rd-body .ansline.is-flash { border-radius: 10px; animation: rd-x-flash 1.7s ease-out; }
@keyframes rd-x-flash {
  0%, 35% { background: color-mix(in srgb, var(--syl-c, var(--md-primary)) 14%, transparent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--syl-c, var(--md-primary)) 14%, transparent); }
  100% { background: transparent; box-shadow: 0 0 0 6px transparent; }
}
.rd-x-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: .45em; font-size: .84em; line-height: 1.4; }
.rd-x-tools:empty { display: none; }
.rd-x-clear { display: none; align-items: center; gap: 4px; min-height: 30px; padding: 3px 11px 3px 7px; border: 1px solid var(--md-outline-variant); border-radius: 999px; background: none; color: var(--md-on-surface-variant); font: 600 12.5px var(--md-font); cursor: pointer; }
.rd-x-clear .material-symbols-outlined { font-size: 16px; }
.rd-x-clear:hover { color: var(--md-on-surface); border-color: var(--md-outline); }
.rd-exam-on [data-key].has-pick .rd-x-clear { display: inline-flex; }
.rd-x-verdict { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.rd-x-verdict .material-symbols-outlined { font-size: 17px; }
.rd-x-verdict.is-right { color: #1f8a4c; }
.rd-x-verdict.is-wrong { color: #c2412d; }
.rd-x-verdict.is-blank { color: var(--md-on-surface-variant); }
[data-theme="dark"] .rd-x-verdict.is-right { color: #5fd391; }
[data-theme="dark"] .rd-x-verdict.is-wrong { color: #ff8a73; }
.rd-x-why { border: 0; background: none; padding: 2px 0; font: 600 12.5px var(--md-font); color: var(--md-primary); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.rd-x-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* the bar: clock, answered, the palette and Submit; the score after */
.rd-xbar { position: fixed; z-index: 66; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: min(720px, calc(100% - 24px)); min-height: 60px; padding: 8px 8px 8px 16px; border-radius: 22px; border: 1px solid var(--md-outline-variant); background: var(--md-surface-container-lowest); box-shadow: 0 10px 28px rgba(0, 0, 0, .14); color: var(--md-on-surface); font-family: var(--md-font); }
[data-theme="dark"] .rd-xbar { background: var(--md-surface-container-high); box-shadow: 0 10px 28px rgba(0, 0, 0, .36); }
.rd-xbar-clock { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-xbar-clock .material-symbols-outlined { font-size: 20px; color: var(--md-on-surface-variant); }
.rd-xbar-clock b { font-size: 19px; font-weight: 700; }
.rd-xbar.is-low .rd-xbar-clock, .rd-xbar.is-low .rd-xbar-clock .material-symbols-outlined { color: #c2412d; }
[data-theme="dark"] .rd-xbar.is-low .rd-xbar-clock, [data-theme="dark"] .rd-xbar.is-low .rd-xbar-clock .material-symbols-outlined { color: #ff8a73; }
.rd-xbar-count { display: flex; flex-direction: column; min-width: 0; margin-right: auto; padding-left: 12px; border-left: 1px solid var(--md-outline-variant); font-size: 14px; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-xbar-count b { font-weight: 700; }
.rd-xbar-count small { font-size: 12px; color: var(--md-on-surface-variant); }
.rd-xbar-m { display: none; }
.rd-xbar-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; height: 44px; padding: 0 16px; border: 1px solid var(--md-outline-variant); border-radius: 999px; background: var(--md-surface); color: var(--md-on-surface); font: 600 14px var(--md-font); white-space: nowrap; cursor: pointer; }
.rd-xbar-btn:hover { border-color: var(--md-outline); }
.rd-xbar-btn .material-symbols-outlined { font-size: 19px; }
.rd-xbar-btn.is-primary { background: var(--md-on-surface); border-color: var(--md-on-surface); color: var(--md-surface); }
.rd-xbar-score { display: inline-flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; padding: 6px 10px 6px 2px; border: 0; border-radius: 14px; background: none; color: var(--md-on-surface); font: 600 14px var(--md-font); font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; }
.rd-xbar-score b { font-size: 19px; }
.rd-xbar-score small { font-size: 13px; color: var(--md-on-surface-variant); }
.rd-xbar-score .material-symbols-outlined { color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-xbar button:focus-visible, .rd-xdlg button:focus-visible, .rd-xres button:focus-visible, .rd-x-tools button:focus-visible { outline: 2px solid var(--md-on-surface); outline-offset: 2px; }

/* dialogs: the intro, the confirmation, the palette */
.rd-xdlg { box-sizing: border-box; width: min(480px, calc(100% - 32px)); max-width: none; max-height: calc(100% - 32px); margin: auto; padding: 0; border: 0; border-radius: 26px; background: var(--md-surface-container-lowest); color: var(--md-on-surface); box-shadow: 0 24px 64px rgba(0, 0, 0, .28); font-family: var(--md-font); overflow: hidden; }
.rd-xdlg[open] { display: flex; flex-direction: column; }
.rd-xdlg::backdrop { background: rgba(0, 0, 0, .45); }
.rd-xdlg.is-fallback { position: fixed; z-index: 210; inset: 0; }
[data-theme="dark"] .rd-xdlg { background: var(--md-surface-container-high); }
.rd-xdlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 0; }
.rd-xdlg-t { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 700; color: var(--md-on-surface); }
.rd-xdlg-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.rd-xdlg-x { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; margin: -6px -8px 0 auto; padding: 0; border: 0; border-radius: 20px; background: var(--md-surface-container-high); color: var(--md-on-surface); cursor: pointer; }
.rd-xdlg-body { min-height: 0; padding: 14px 22px 4px; overflow-y: auto; font-size: 14.5px; line-height: 1.55; color: var(--md-on-surface-variant); }
.rd-xdlg-body p { margin: 0 0 .8em; }
.rd-xdlg-body b { color: var(--md-on-surface); }
.rd-xdlg-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rd-xdlg-facts li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start; }
.rd-xdlg-facts .material-symbols-outlined { font-size: 21px; color: var(--md-on-surface); }
.rd-xdlg-act { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }
.rd-xbtn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 18px; border: 1px solid var(--md-outline-variant); border-radius: 999px; background: var(--md-surface); color: var(--md-on-surface); font: 600 14.5px var(--md-font); cursor: pointer; }
.rd-xbtn:hover { border-color: var(--md-outline); }
.rd-xbtn .material-symbols-outlined { font-size: 19px; }
.rd-xbtn.is-primary { background: var(--md-on-surface); border-color: var(--md-on-surface); color: var(--md-surface); }
.rd-xpal { width: min(620px, calc(100% - 32px)); max-height: min(78vh, 680px); }
.rd-xpal .rd-xdlg-body { padding-top: 4px; padding-bottom: 16px; }
.rd-xpal .rd-xdlg-act { justify-content: flex-start; padding-top: 12px; border-top: 1px solid var(--md-outline-variant); }
.rd-xpal .rd-xpal-sec { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 8px; font-size: 13.5px; font-weight: 700; color: var(--md-on-surface); }
.rd-xpal .rd-xpal-sec small { font-weight: 500; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.rd-xpal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.rd-xq { height: 42px; padding: 0; border: 1px solid var(--md-outline-variant); border-radius: 12px; background: var(--md-surface); color: var(--md-on-surface); font: 600 13.5px var(--md-font); font-variant-numeric: tabular-nums; cursor: pointer; }
.rd-xq:hover { border-color: var(--md-outline); }
.rd-xq:focus-visible { outline: 2px solid var(--md-on-surface); outline-offset: 2px; }
.rd-xq.is-done { background: var(--md-on-surface); border-color: var(--md-on-surface); color: var(--md-surface); }
.rd-xq.is-right { background: #1f8a4c; border-color: #1f8a4c; color: #fff; }
.rd-xq.is-wrong { background: #c2412d; border-color: #c2412d; color: #fff; }
.rd-xq.is-blank { border-style: dashed; color: var(--md-on-surface-variant); }

/* the result, above the paper */
.rd-xres { margin: 0 0 28px; padding: 20px 20px 18px; border-radius: 20px; border: 1px solid var(--md-outline-variant); background: var(--md-surface-container-low); color: var(--md-on-surface); outline: none; scroll-margin-top: 90px; }
.rd-xres-kick { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--md-on-surface-variant); }
.rd-xres-kick .material-symbols-outlined { font-size: 19px; color: color-mix(in srgb, var(--syl-c, var(--md-primary)) var(--ink-mix, 58%), var(--md-on-surface)); }
.rd-xres-score { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rd-xres-score span { font-size: 17px; font-weight: 600; letter-spacing: 0; color: var(--md-on-surface-variant); }
.rd-xres-sum { margin: 6px 0 0; font-size: 14px; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.rd-xres-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 16px 0 0; }
.rd-xres-stats div { min-width: 0; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--md-outline-variant); background: var(--md-surface); }
.rd-xres-stats dt { font-size: 12px; font-weight: 600; color: var(--md-on-surface-variant); }
.rd-xres-stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-xres-stats dd small { display: block; font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); }
.rd-xres-scroll { margin-top: 16px; overflow-x: auto; }
.rd-xres-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.rd-xres-table th, .rd-xres-table td { padding: 8px 10px; border-bottom: 1px solid var(--md-outline-variant); text-align: right; white-space: nowrap; }
.rd-xres-table th:first-child { text-align: left; white-space: normal; }
.rd-xres-table thead th { font-size: 12px; font-weight: 600; color: var(--md-on-surface-variant); }
.rd-xres-table abbr { text-decoration: none; }
.rd-xres-table tbody th, .rd-xres-table tfoot th { font-weight: 600; }
.rd-xres-table tfoot th, .rd-xres-table tfoot td { border-bottom: 0; border-top: 1px solid var(--md-outline); }
.rd-xres-note { margin: 14px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--md-on-surface-variant); }
.rd-xres-act { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

@media (max-width: 600px) {
  .rd-xbar { width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); gap: 8px; padding: 6px 6px 6px 12px; border-radius: 20px; }
  .rd-xbar-w, .rd-xbar-l { display: none; }
  .rd-xbar-m { display: inline; }
  .rd-xbar-clock b { font-size: 17px; }
  .rd-xbar-count { padding-left: 9px; }
  .rd-xbar-btn { padding: 0 14px; }
  .rd-xbar-pal { width: 44px; padding: 0; }
  .rd-xdlg, .rd-xpal { width: 100%; max-height: 88vh; margin: auto 0 0; border-radius: 26px 26px 0 0; }
  .rd-xdlg-act { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .rd-xdlg-act .rd-xbtn { flex: 1 1 0; }
  .rd-xpal-grid { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
  .rd-xres { padding: 16px 14px; }
  .rd-xres-score { font-size: 34px; }
  .rd-xres-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rd-xres-stats div:last-child { grid-column: span 2; }
  .rd-xres-stats dd small { display: inline; }
  .rd-xres-table { font-size: 13px; }
  .rd-xres-table th, .rd-xres-table td { padding: 8px 5px; }
  .rd-xres-act .rd-xbtn { flex: 1 1 auto; }
}
@media print {
  .rd-xbar, .rd-x-clear, .rd-x-why, .rd-xres-act { display: none !important; }
}
