/* Hand Rules Practice: a physics bench with a magnet on it. Cool steel-grey page, a narrow engineering typeface for
   headings, copper for current, blue for field, green for force, red and blue magnet poles, and a direction pad laid out
   like the page itself (up at the top, into and out of the page beside it). Diagrams sit on white in both themes. */
:root {
  --bg: #eef1f4;
  --paper: #ffffff;
  --ink: #17202b;
  --muted: #47515d;
  --line: #cfd6de;
  --edge: #7d8792;
  --accent: #8a3f0e;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6da;
  --info: #1f5a8a;
  --ok: #17663a;
  --ok-soft: #dff1e6;
  --close: #7a5300;
  --close-soft: #f7ecd4;
  --bad: #a2261f;
  --bad-soft: #f8e1de;
  --focus: #1b5fd0;
  --fig: #ffffff;
  --cI: #a24d12;
  --cB: #2459a6;
  --cF: #157a3c;
  --cv: #3d4650;
  --pN: #c4302b;
  --pS: #2f5ea8;
  --head: Bahnschrift, "DIN Alternate", "D-DIN", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --paper: #1b2128;
    --ink: #e7ebef;
    --muted: #a9b3bd;
    --line: #313a44;
    --edge: #6d7884;
    --accent: #f0a46c;
    --accent-ink: #2a1203;
    --accent-soft: #3a2414;
    --info: #86c0f0;
    --ok: #8adca6;
    --ok-soft: #142c1e;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8ab8ff;
    --fig: #f3f5f7;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--sans); }
a { color: var(--info); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; letter-spacing: 0.01em; }
.hero { padding: 20px 0 10px; }
.hero h1 { font-size: clamp(1.6rem, 4.6vw, 2.5rem); margin: 0 0 6px; font-weight: 700; }
.lede { margin: 0; max-width: 62ch; color: var(--muted); }

/* setup bar */
.setup { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-end; padding: 12px 0 14px; border-bottom: 2px solid var(--ink); }
.setup label.inline, .setup .field { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 1rem; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: var(--r); min-height: 44px; padding: 6px 10px; }
select { padding-right: 28px; max-width: 100%; }
.setup .board { flex: 1 1 15rem; max-width: 22rem; min-width: 0; }
.setup .board select { width: 100%; }
.topics { flex: 1 1 100%; order: 3; }
.topics summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; font-size: 1rem; }
.topics fieldset { border: 0; padding: 0; margin: 0 0 4px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.tg { position: relative; }
.tg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tg span { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 12px; border: 1px solid var(--edge); border-radius: 22px; background: var(--paper); font-size: 1rem; }
.tg input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tg input:checked + span::before { content: "✓ "; white-space: pre; }
.tg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.bhint { flex: 1 1 100%; order: 2; margin: 0; color: var(--muted); font-size: 1rem; }
.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 1rem; }
.link { font: inherit; background: none; border: 0; padding: 10px 4px; color: var(--info); text-decoration: underline; cursor: pointer; min-height: 44px; }

/* layout: sheet and the rule card */
.tool { display: grid; gap: 18px; padding-top: 16px; }
@media (min-width: 980px) { .tool { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } .rules { position: sticky; top: 12px; } }
.rules { background: var(--paper); border-top: 4px solid var(--cB); padding: 12px 16px 6px; }
.rules h2 { font-size: 1.2rem; margin: 0 0 6px; }
.rules p { margin: 0 0 10px; }
.rules .keyline { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.rules .keyline span { display: inline-flex; gap: 6px; align-items: center; }
.mk { width: 1.3em; height: 1.3em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; vertical-align: -0.25em; }
.mk .mkd { fill: currentColor; stroke: none; }
.rules dl { margin: 0 0 8px; }
.rules dt { font-weight: 700; }
.rules dd { margin: 0 0 8px; }

.note { padding: 10px 12px; border-radius: var(--r); background: var(--bad-soft); margin: 0 0 12px; overflow-wrap: anywhere; }
.note.info { background: var(--accent-soft); }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.sheet-head h2 { margin: 0; font-size: 1.5rem; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.06em; }
.score { margin: 0; color: var(--muted); }
.qs { list-style: none; margin: 10px 0 0; padding: 0; }
.q { background: var(--paper); border-left: 4px solid var(--ink); padding: 12px 14px 14px; margin: 0 0 14px; }
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.q h3 { margin: 0; font-size: 1.2rem; }
.qn { color: var(--muted); margin-right: 6px; }
.see { white-space: nowrap; font-size: 1rem; min-height: 44px; display: inline-flex; align-items: center; }
.scen { margin: 4px 0 10px; }
.qbody { display: grid; gap: 12px; }
@media (min-width: 640px) { .qbody { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); align-items: start; } }
.figwrap { background: var(--fig); border: 1px solid var(--line); border-radius: var(--r); padding: 4px; max-width: 360px; }
svg.fig { display: block; width: 100%; height: auto; }
.part { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.part legend, .part .prompt { font-weight: 600; padding: 0; margin-bottom: 6px; display: block; }
.fbwrap { min-height: 0; }
.fb { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--r); }
.fb.right { background: var(--ok-soft); color: var(--ok); }
.fb.close { background: var(--close-soft); color: var(--close); }
.fb.wrong, .fb.unread { background: var(--bad-soft); color: var(--bad); }
.fb.right, .fb.close, .fb.wrong, .fb.unread { color: var(--ink); }
.fb b { font-weight: 700; }
.fb.right b { color: var(--ok); } .fb.close b { color: var(--close); } .fb.wrong b, .fb.unread b { color: var(--bad); }

/* the direction pad: laid out like the page, with into and out of the page beside it */
.pad { display: grid; grid-template-columns: repeat(3, minmax(54px, 66px)) 10px minmax(74px, 92px); grid-template-rows: repeat(3, 52px); gap: 4px; }
.pad .o-up { grid-area: 1 / 2; } .pad .o-left { grid-area: 2 / 1; } .pad .o-right { grid-area: 2 / 3; } .pad .o-down { grid-area: 3 / 2; }
.pad .o-in { grid-area: 1 / 5; } .pad .o-out { grid-area: 2 / 5; } .pad .o-none { grid-area: 3 / 5; }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt .ot { display: flex; align-items: center; justify-content: center; gap: 4px; height: 100%; min-height: 44px; padding: 4px 10px; border: 1px solid var(--edge); border-radius: var(--r); background: var(--paper); text-align: center; line-height: 1.15; font-size: 1rem; }
.pad .ot { padding: 2px 4px; flex-direction: column; gap: 0; font-size: 1rem; }
.pad .ot .ar { font-size: 1.25rem; }
.opt input:checked + .ot { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.opt input:focus-visible + .ot { outline: 3px solid var(--focus); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.row .opt .ot { min-width: 120px; }
.is-right .opt input:checked + .ot { background: var(--ok); border-color: var(--ok); color: var(--paper); }
.is-wrong .opt input:checked + .ot { background: var(--bad); border-color: var(--bad); color: var(--paper); }
.ain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ain input { width: 9.5rem; }
.unit { font-weight: 600; }
.mk { font-weight: 700; font-size: 1.2rem; }
.is-right .mk { color: var(--ok); } .is-close .mk { color: var(--close); } .is-wrong .mk { color: var(--bad); }
.is-wrong input:not([type=radio]) { border-color: var(--bad); }
.is-right input:not([type=radio]) { border-color: var(--ok); }
.qfoot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.work { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.work summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--info); }
.work .ans { margin: 6px 0 2px; font-weight: 600; }
.work .steps { margin: 0 0 6px; padding-left: 1.3em; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 18px; }
.ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
[hidden] { display: none !important; }
.share { padding: 14px 0; border-top: 1px solid var(--line); }
.print-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.print-row label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 1rem; }
.share-out label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.share-out input { width: 100%; }
.hint { color: var(--muted); }
.recent { margin-top: 12px; }
.recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.recent small { display: block; color: var(--muted); font-size: 1rem; }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); max-width: calc(100% - 32px); opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 20; }
.toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* SVG drawing */
svg.fig { color: #17202b; }
.fig line, .fig polyline, .fig path, .fig circle, .fig rect, .fig polygon { vector-effect: non-scaling-stroke; }
.fig .lb { font: 700 13px var(--sans); fill: #17202b; }
.fig .sm { font: 11px var(--sans); fill: #2c3540; }
.fig .qm { font: 700 13px var(--sans); fill: #17202b; }
.fig .pl { font: 700 18px var(--head); fill: #fff; }
.fig .pl.ends, .fig .pl.big, .fig .pl.compassN { fill: #17202b; }
.fig .pl.big { font-size: 30px; }
.fig .kI { fill: var(--cI); } .fig .kB { fill: var(--cB); } .fig .kF { fill: var(--cF); } .fig .kv { fill: var(--cv); }
.fig .arr { stroke-width: 2.4; }
.fig .arr.k-I, .fig .arc.k-I { stroke: var(--cI); } .fig .ah.k-I { fill: var(--cI); }
.fig .arr.k-B, .fig .arc.k-B { stroke: var(--cB); } .fig .ah.k-B { fill: var(--cB); }
.fig .arr.k-F { stroke: var(--cF); } .fig .ah.k-F { fill: var(--cF); }
.fig .arr.k-v { stroke: var(--cv); } .fig .ah.k-v { fill: var(--cv); }
.fig .arc { fill: none; stroke-width: 2; }
.fig .xo .xr { fill: #fff; stroke-width: 1.6; }
.fig .xo line { stroke-width: 1.6; }
.fig .xo.k-I .xr, .fig .xo.k-I line { stroke: var(--cI); } .fig .xo.k-I .dot { fill: var(--cI); }
.fig .xo.k-B .xr, .fig .xo.k-B line { stroke: var(--cB); } .fig .xo.k-B .dot { fill: var(--cB); }
.fig .xo.k-F .xr, .fig .xo.k-F line { stroke: var(--cF); } .fig .xo.k-F .dot { fill: var(--cF); }
.fig .pole rect { stroke: #17202b; stroke-width: 1; }
.fig .pole.pN rect { fill: var(--pN); } .fig .pole.pS rect { fill: var(--pS); } .fig .pole.hidden rect { fill: #6b7580; }
.fig .wire { stroke: var(--cI); stroke-width: 4; stroke-linecap: round; }
.fig .wire.under { stroke-dasharray: 7 5; }
.fig .beam { stroke: var(--cv); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.fig .fl { fill: none; stroke: var(--cB); stroke-width: 1.4; stroke-dasharray: 3 4; }
.fig .pt { fill: #17202b; }
.fig .hide { fill: none; stroke: #6b7580; stroke-dasharray: 6 4; }
.fig .compass circle { fill: #fff; stroke: #17202b; stroke-width: 1.6; }
.fig .compass .pivot { fill: #17202b; }
.fig .needleN { fill: var(--pN); stroke: #17202b; stroke-width: 0.8; } .fig .needleS { fill: #fff; stroke: #17202b; stroke-width: 0.8; }
.fig .core { fill: #e3e7ec; stroke: none; }
.fig .turn { stroke: var(--cI); stroke-width: 3; stroke-linecap: round; }
.fig .turn.back { stroke-width: 1.6; stroke-dasharray: 4 3; opacity: 0.85; }
.fig .lead, .fig .coil, .fig .rail { fill: none; stroke: #17202b; stroke-width: 2; }
.fig .coil { stroke: var(--cI); stroke-width: 3.2; }
.fig .rod { stroke: var(--cI); stroke-width: 6; stroke-linecap: round; }
.fig .plate { stroke: #17202b; stroke-width: 2.6; }
.fig .loopw { fill: none; stroke: var(--cI); stroke-width: 3; }
.fig .axle { stroke: #6b7580; stroke-width: 2; stroke-dasharray: 8 3 2 3; }
.fig .comm { fill: none; stroke: #8a5a14; stroke-width: 3.2; }
.fig .brush { fill: #4b5560; }
.fig .plane { stroke: #6b7580; stroke-dasharray: 5 4; stroke-width: 1.6; }
.fig .pivot { fill: #17202b; }
.fig .meter { fill: #fff; stroke: #17202b; stroke-width: 1.6; }
.fig .dim, .fig .angle { fill: none; stroke: #2c3540; stroke-width: 1; }
.fig .ref { stroke: #2c3540; stroke-width: 1; stroke-dasharray: 4 3; }

/* explainer */
.content { max-width: 74ch; padding: 24px 0 8px; }
.content h2 { font-size: 1.45rem; margin: 28px 0 8px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; padding: 6px 0; }
.faq details p { margin: 0 0 12px; }
.sources { color: var(--muted); }
footer { border-top: 2px solid var(--ink); margin-top: 24px; padding: 14px 0 28px; color: var(--muted); }
footer .indep { margin: 0 0 10px; }
.sb-footer p { margin: 0 0 8px; }
.sb-more { font-size: 1rem; }
.print-root { display: none; }

@media (max-width: 420px) {
  .q { padding: 10px 10px 12px; }
}

/* ---------- print ---------- */
@page { margin: 13mm 12mm; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #999; --paper: #fff; --fig: #fff; }
  body { background: #fff; color: #000; font: 10.5pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  svg { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  table.pt { width: 100%; border-collapse: collapse; }
  table.pt > tbody > tr > td, table.pt > thead > tr > td { padding: 0; }
  .prun { padding-bottom: 5pt !important; }
  .prun .psym { font-family: "Segoe UI Symbol", "Cambria Math", "DejaVu Sans", "Noto Sans Math", sans-serif; }
  .prun p { margin: 0; font-size: 8.5pt; line-height: 1.3; border-bottom: 0.75pt solid #000; padding-bottom: 3pt; display: flex; gap: 6pt; align-items: center; flex-wrap: wrap; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2pt solid #000; margin-bottom: 5pt; }
  .ph h2 { font: 700 15pt var(--head); margin: 0; }
  .ph p { margin: 0; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 4pt 0 6pt; }
  .pq { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 8mm; }
  .pq > li { padding: 5pt 0 6pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pq h3 { font: 700 11pt var(--head); margin: 0 0 2pt; }
  .pq .pscen { margin: 0 0 3pt; font-size: 10pt; }
  .pq svg.fig { display: block; width: 60mm; height: 45mm; margin: 2pt 0 3pt; }
  .pparts { font-size: 10pt; }
  .pparts .pp { margin: 0 0 3pt; }
  .pparts .pp p { margin: 0; }
  .popts { margin: 1pt 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 0 9pt; }
  .popts li::before { content: "○ "; }
  .pline { margin: 4pt 0 1pt !important; }
  .pkey { break-before: page; page-break-before: always; }
  .pk { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 8mm; }
  .pk > li { padding: 3pt 0 4pt; border-bottom: 0.75pt solid #bbb; break-inside: avoid; page-break-inside: avoid; }
  .pk h3 { font: 700 10.5pt var(--head); margin: 0 0 1pt; }
  .pkp { font-size: 10pt; }
  .pkp p { margin: 0; font-weight: 700; }
  .pkp ul { margin: 0 0 2pt; padding-left: 11pt; }
  .fig .lb, .fig .qm { font-size: 13px; }
}
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
