/* Torque Wrench Practice: a tool drawer. Brushed-steel grey ground, graphite ink, one safety-yellow accent for the
   main action and the question tags, and a handle scale (a long line every fifth tick) under the title. Drawings stay
   light like a real chrome handle in both themes. On paper everything is black on white. */
:root {
  --bg: #e9ecee;
  --paper: #ffffff;
  --ink: #15181b;
  --muted: #4a5258;
  --line: #cbd1d6;
  --edge: #6f787f;
  --yellow: #f2c200;
  --yellow-ink: #15181b;
  --graphite: #24292e;
  --graphite-ink: #f1f3f4;
  --graphite-muted: #b8c0c6;
  --info: #1c5a8c;
  --ok: #17663a;
  --ok-soft: #dcefe2;
  --close: #7a5300;
  --close-soft: #f6ecd2;
  --bad: #a3241d;
  --bad-soft: #f8e0dd;
  --keyred: #c0261b;
  --focus: #0b6bcb;
  --head: "Arial Narrow", "Roboto Condensed", "Helvetica Neue Condensed", "Liberation Sans Narrow", "Nimbus Sans Narrow", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --r: 4px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --paper: #1b1e21;
    --ink: #e8ebed;
    --muted: #a8b0b6;
    --line: #33393f;
    --edge: #6c757c;
    --graphite: #2a3036;
    --info: #8fc1ef;
    --ok: #8adca6;
    --ok-soft: #14301f;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #8fc1ef;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
a { color: var(--info); text-underline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.12; font-weight: 700; font-stretch: condensed; }

/* ---------- title with a handle scale under it ---------- */
.hero { padding: 20px 0 22px; position: relative; }
.hero h1 { font-size: clamp(30px, 5.4vw, 48px); margin: 0 0 6px; letter-spacing: -0.01em; max-width: 22ch; }
.hero::after { content: ""; display: block; height: 14px; margin-top: 14px; max-width: 560px; border-top: 2px solid var(--ink);
  background: repeating-linear-gradient(to right, var(--ink) 0 2px, transparent 2px 50px) top left / 100% 14px no-repeat,
    repeating-linear-gradient(to right, var(--ink) 0 1.5px, transparent 1.5px 10px) top left / 100% 7px no-repeat; }
.lede { margin: 0; max-width: 66ch; }
.safety { margin: 6px 0 0; max-width: 66ch; color: var(--muted); }
.tip { margin: 10px 0 0; max-width: 66ch; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); }

/* ---------- layout: controls beside the sheet on wide screens ---------- */
.tool { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 980px) { .tool { grid-template-columns: 270px minmax(0, 1fr); } .setup { position: sticky; top: 12px; } }
.setup { background: var(--graphite); color: var(--graphite-ink); padding: 12px 12px 4px; border-radius: var(--r); }
.ctl { display: grid; gap: 8px 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "preset preset" "level level" "count new"; align-items: end; }
@media (min-width: 640px) and (max-width: 979px) { .ctl { grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) auto; grid-template-areas: "preset level count new"; } }
.f-preset { grid-area: preset; } .f-level { grid-area: level; } .f-count { grid-area: count; } .f-new { grid-area: new; }
.fld { display: grid; gap: 2px; min-width: 0; }
.fld span { font: 600 14px var(--sans); color: var(--graphite-muted); }
.fld select { width: 100%; }
.more { display: flex; flex-wrap: wrap; gap: 0 22px; }
.more details[open] { flex-basis: 100%; }
.setup summary { color: var(--graphite-ink); }
.setup .tsum { color: var(--graphite-muted); }
.more details > fieldset, .more details > div { background: var(--paper); color: var(--ink); padding: 8px 10px; margin: 0 0 10px; border-radius: var(--r); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font: 600 15px var(--sans); color: var(--muted); padding: 0; margin-bottom: 4px; }
.tdet summary, .rules summary { cursor: pointer; font-weight: 600; min-height: 44px; padding: 10px 0; display: list-item; }
.tsum { font-weight: 400; font-size: 15px; }
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; padding-top: 4px; }
.tg { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; min-height: 44px; background: var(--paper); }
.tg input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--graphite); flex: none; }
.tg b { display: block; font-weight: 600; font-size: 15.5px; }
.tg small { display: block; color: var(--muted); font-size: 14px; line-height: 1.3; }
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; max-width: 100%; }
.btn { font: 600 16px var(--sans); min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.btn.primary:hover { border-color: #fff; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.link { font: inherit; background: none; border: 0; color: var(--info); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 44px; padding: 0 4px; }
.rl { margin: 4px 0 0; padding-left: 20px; font-size: 15px; line-height: 1.45; }
.rl li { margin: 0 0 4px; }

/* ---------- the sheet ---------- */
.note { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--bad); background: var(--bad-soft); font-size: 16px; border-radius: var(--r); }
#store-note { overflow-wrap: anywhere; }
.note.info { border-color: var(--info); background: var(--paper); }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; }
.sheet-head h2 { font-size: 30px; margin: 0; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.score { margin: 0; color: var(--muted); font-size: 15px; }
.sline { margin: 2px 0 10px; color: var(--muted); font-size: 15px; }
.qs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.q { background: var(--paper); border-top: 4px solid var(--graphite); min-width: 0; }
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 0; }
.q h3 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.qn { font: 700 16px var(--mono); background: var(--yellow); color: var(--yellow-ink); min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 2px; }
.scen { margin: 6px 14px 8px; max-width: 75ch; }
.figview { padding: 0 14px; min-width: 0; }
.qparts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 10px 14px 14px; }

/* ---------- drawings: light, like the tool, in both themes ---------- */
.figs { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.tf { margin: 0; width: 330px; max-width: 100%; }
.figs.k-ext .tf { width: 340px; }
.figs.k-bolts .tf, .k-seq .tf, .k-stage .tf { width: 220px; }
.k-dial .tf { width: 230px; }
.k-beam .tf { width: 340px; }
.k-pick .tf { width: 300px; }
.tf figcaption { font: 600 14.5px var(--sans); color: var(--muted); margin-top: 3px; line-height: 1.35; }
.tf .kv { color: var(--keyred); font-family: var(--mono); margin-left: 4px; }
.tf .tag { display: inline-block; background: var(--graphite); color: var(--graphite-ink); padding: 0 7px; font-family: var(--mono); }
@media (prefers-color-scheme: dark) { .tf .kv { color: #ff8f84; } }
svg.tw { display: block; width: 100%; height: auto; background: #f7f8f9; border: 1px solid #c5ccd2; border-radius: 3px; font-family: "Helvetica Neue", Arial, sans-serif; }
.tube { fill: #dfe4e8; stroke: #8b949b; stroke-width: 1; }
.datum { stroke: #15181b; stroke-width: 1.4; }
.mt { stroke: #15181b; stroke-width: 1.6; }
.ml { fill: #15181b; font-size: 13px; font-weight: 700; text-anchor: middle; }
.uname { fill: #4a5258; font-size: 11px; font-weight: 700; }
.grip { fill: #2b3035; }
.bevel { fill: #cfd5da; stroke: #8b949b; stroke-width: 1; }
.knurl { stroke: #4b5258; stroke-width: 1.4; }
.edge { stroke: #15181b; stroke-width: 2.2; }
.ct { stroke: #15181b; stroke-width: 1.5; }
.cl { fill: #15181b; font-weight: 700; }
.cm { fill: #6b4300; font-weight: 600; }
.kline { stroke: #c0261b !important; stroke-width: 3 !important; }
.ktext { fill: #c0261b !important; }
.plate { fill: #e7ebee; stroke: #8b949b; }
.base { stroke: #15181b; stroke-width: 1.4; }
.bt, .bt2 { stroke: #15181b; stroke-width: 1.3; }
.bl, .bl2 { fill: #15181b; font-size: 11.5px; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: #e7ebee; stroke-width: 3px; stroke-linejoin: round; }
.bl2 { fill: #6b4300; font-weight: 600; }
.bu, .bu2 { fill: #4a5258; font-size: 10.5px; font-weight: 700; }
.bu2 { fill: #6b4300; }
.ptr { stroke: #c0261b; stroke-width: 2; }
.ptip { fill: #c0261b; }
.face { fill: #fbfbfa; stroke: #2b3035; stroke-width: 5; }
.handle { fill: #2b3035; }
.dt { stroke: #15181b; stroke-width: 1.5; }
.dl { fill: #15181b; font-size: 14px; font-weight: 700; text-anchor: middle; }
.du { fill: #4a5258; font-size: 13px; font-weight: 700; text-anchor: middle; }
.needle { stroke: #15181b; stroke-width: 3; stroke-linecap: round; }
.memo { stroke: #e06a00; stroke-width: 2.5; stroke-linecap: round; }
.ddir { fill: #4a5258; font-size: 11px; font-weight: 700; text-anchor: middle; }
.bdir { fill: #4a5258; font-size: 10px; font-weight: 600; text-anchor: middle; }
.hubc { fill: #2b3035; }
.hbar { fill: #8f989f; }
.adapter { stroke: #4b5258; stroke-width: 10; stroke-linecap: round; }
.drv { fill: #2b3035; }
.fas { fill: #f7f8f9; stroke: #15181b; stroke-width: 3; }
.gripm { fill: #f2c200; stroke: #15181b; stroke-width: 1.5; }
.dim { stroke: #15181b; stroke-width: 1.2; }
.dimL, .dimE { fill: #15181b; font-size: 14px; font-weight: 700; text-anchor: middle; }
.ext .dimE { paint-order: stroke; stroke: #f7f8f9; stroke-width: 4px; }
.dimE.start { text-anchor: start; }
.pull { stroke: #1c5a8c; stroke-width: 2.5; }
.pullhead { fill: #1c5a8c; }
.lab { fill: #4a5258; font-size: 12px; font-weight: 600; }
.lab.small { text-anchor: middle; }
.hub { fill: #e3e7ea; stroke: #8b949b; stroke-width: 1.5; }
.hubin { fill: #cfd5da; stroke: #8b949b; }
.bolt { fill: #ffffff; stroke: #15181b; stroke-width: 2; }
.bolt.mk { fill: #f2c200; }
.bk { fill: #15181b; font-size: 13px; font-weight: 700; text-anchor: middle; }
.kn { fill: #c0261b; font-size: 13px; font-weight: 700; text-anchor: middle; }

/* ---------- answer boxes ---------- */
.part { border: 0; margin: 0; padding: 0; min-width: 0; }
.part .prompt, .part legend { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; margin-bottom: 4px; color: var(--ink); }
.ain { display: flex; align-items: center; gap: 8px; }
.ain input { width: 8.5em; max-width: 100%; font-variant-numeric: tabular-nums; }
.ain .unit { color: var(--muted); }
.opts { display: grid; gap: 4px; }
.opts.row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.opt input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--graphite); flex: none; }
.part.is-right input[inputmode] { border-color: var(--ok); background: var(--ok-soft); }
.part.is-wrong input[inputmode] { border-color: var(--bad); background: var(--bad-soft); }
.part.is-close input[inputmode], .part.is-unread input[inputmode] { border-color: var(--close); background: var(--close-soft); }
.part.is-right .opts { outline: 2px solid var(--ok); outline-offset: 2px; }
.part.is-wrong .opts { outline: 2px solid var(--bad); outline-offset: 2px; }
.fb { margin: 4px 0 0; font-size: 15px; line-height: 1.4; padding: 4px 8px; }
.fb.right { color: var(--ok); background: var(--ok-soft); }
.fb.wrong { color: var(--bad); background: var(--bad-soft); }
.fb.close, .fb.unread { color: var(--close); background: var(--close-soft); }
.qfoot { display: flex; gap: 10px; align-items: center; }
details.work { margin-top: 2px; border-top: 1px dashed var(--line); padding-top: 4px; }
details.work summary { cursor: pointer; color: var(--info); min-height: 44px; display: flex; align-items: center; font-weight: 600; }
details.work .figview { padding: 0; margin: 6px 0 8px; }
.ans { margin: 8px 0 2px; }
.steps { margin: 0 0 4px; padding-left: 20px; color: var(--muted); font-size: 15.5px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 14px 0 6px; }
.ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: var(--paper); border: 1px solid var(--yellow); border-radius: var(--r); padding: 6px 10px; }
.share { margin: 16px 0 6px; }
.print-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.print-row label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; max-width: 100%; }
.print-row select { max-width: 100%; min-width: 0; }
.share-out label { display: grid; gap: 4px; font-weight: 600; margin-top: 8px; }
.share-out input { width: 100%; }
.recent { margin-top: 12px; background: var(--paper); border: 1px solid var(--line); padding: 4px 12px; }
.recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.recent small { display: block; color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 15px; margin: 0; }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--paper); padding: 10px 16px; max-width: min(92vw, 520px); font-size: 15.5px; transition: transform 0.2s; z-index: 20; }
.toast.on { transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- content ---------- */
.content { max-width: 72ch; padding: 30px 0 20px; }
.content h2 { font-size: 30px; margin: 28px 0 6px; }
.content .eg { font-family: var(--mono); font-size: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; text-wrap: balance; }
.faq details { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { font-size: 15px; color: var(--muted); }
footer { border-top: 1px solid var(--line); padding: 16px 0 28px; font-size: 15px; color: var(--muted); }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.print-root { display: none; }

@media (min-width: 900px) {
  .qparts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 22px; }
  .qparts .qfoot, .qparts details.work, .qparts .part.wide { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  /* one drawing to a row on phones, as wide as the screen allows */
  .figs .tf, .k-pick .tf, .k-ext .tf, .k-beam .tf { width: 100%; }
  .k-dial .tf, .k-seq .tf, .k-stage .tf { width: min(100%, 260px); }
  .opts.row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .hero { padding: 10px 0 14px; }
  .hero h1 { font-size: 30px; }
  .lede, .tip { font-size: 16px; line-height: 1.45; }
  .hero::after { margin-top: 10px; }
  .q h3 { font-size: 21px; }
  .qhead { padding: 10px 10px 0; }
  .scen { margin: 6px 10px; }
  .figview { padding: 0 10px; }
  .qparts { padding: 8px 10px 12px; }
  .tdet summary, .rules summary { min-height: 40px; padding: 8px 0; }
}

/* ---------- print: black on white ---------- */
@media print {
  @page { margin: 12mm 12mm; }
  body { background: #fff; color: #000; font: 10.5pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  svg, .bolt.mk { 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 { font: 8.5pt var(--sans); color: #444; padding-bottom: 5pt !important; }
  .psafe { display: block; font-weight: 700; color: #000; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 10pt; border-bottom: 2pt solid #000; margin-bottom: 4pt; }
  .ph h2 { font: 700 18pt var(--head); margin: 0; white-space: nowrap; }
  .ph p { margin: 0; font-size: 9pt; text-align: right; }
  .pmeta { display: flex; justify-content: space-between; gap: 12pt; margin: 4pt 0; }
  .pround { margin: 0 0 4pt; font-size: 7.8pt; line-height: 1.25; border: 0.8pt solid #000; padding: 3pt 6pt; }
  .pround ul { margin: 0; padding-left: 11pt; columns: 2; column-gap: 8mm; }
  .pround li { break-inside: avoid; margin: 0 0 1pt; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li, .pk > li { padding: 5pt 0 6pt; border-bottom: 0.75pt solid #999; break-inside: avoid; page-break-inside: avoid; }
  .pq > li.half { display: inline-block; vertical-align: top; width: calc(50% - 3mm); margin-right: 5mm; }
  .pq > li.half + li.half { margin-right: 0; }
  .pq > li.half .pbody.stack .pparts { grid-template-columns: 1fr; }
  .pq > li.half .pparts .pp { display: inline-block; width: 48%; vertical-align: top; }
  .pq h3, .pk h3 { font: 700 12.5pt var(--head); margin: 0 0 2pt; }
  .pscen { margin: 0 0 4pt; font-size: 10.2pt; }
  .pbody { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 7mm; align-items: start; }
  .pbody.stack { grid-template-columns: minmax(0, 1fr); }
  .figs { gap: 3mm 5mm; flex-wrap: wrap; }
  .tf { width: 72mm; }
  .k-bolts .tf, .k-seq .tf, .k-stage .tf { width: 36mm; }
  .k-dial .tf { width: 46mm; }
  .k-ext .tf { width: 74mm; }
  .k-beam .tf { width: 112mm; }
  /* the three pick drawings stack beside the choices, wide enough for 7 pt collar numbers */
  .figs.k-pick { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 1.5mm; }
  .k-pick .tf { width: 76mm; }
  .tf figcaption { font-size: 8.4pt; color: #000; font-weight: 600; }
  .tf .kv { color: #000; }
  .tf .tag { background: #fff; color: #000; border: 0.8pt solid #000; }
  svg.tw { border-color: #888; background: #fff; }
  .pparts { display: grid; grid-template-columns: 1fr; gap: 3pt; font-size: 9.8pt; }
  .pparts .pp { break-inside: avoid; }
  .pparts .pp p { margin: 0; }
  .pparts .pp.wide { grid-column: 1 / -1; }
  .pbody.stack .pparts { grid-template-columns: 1fr 1fr; column-gap: 8mm; }
  .pline { margin: 7pt 0 2pt !important; }
  .uline { display: inline-block; width: 30mm; border-bottom: 0.8pt solid #000; }
  .popts { display: grid; gap: 1pt; margin: 2pt 0 0 !important; }
  .popts { grid-template-columns: repeat(auto-fill, minmax(56mm, 1fr)); column-gap: 4mm; }
  .popts.row { grid-template-columns: repeat(3, auto); justify-content: start; column-gap: 10mm; }
  .popts span { white-space: nowrap; }
  .pkey { break-before: page; page-break-before: always; }
  .psheet + .psheet, .pkey + .pkey { break-before: page; page-break-before: always; }
  .pkbody { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 6mm; align-items: start; }
  .pkbody.stack { grid-template-columns: minmax(0, 1fr); }
  .pkfig .figs .tf { width: 58mm; }
  .pkfig .figs.k-ext .tf { width: 58mm; }
  .pkfig .figs.k-seq .tf, .pkfig .figs.k-stage .tf { width: 32mm; }
  .pkfig .figs.k-dial .tf { width: 40mm; }
  .pkfig .figs.k-beam .tf { width: 84mm; }
  .pkfig .figs.k-pick .tf { width: 60mm; }
  table.pkt { width: 100%; border-collapse: collapse; font-size: 9pt; table-layout: fixed; }
  table.pkt td { border-top: 0.5pt solid #bbb; padding: 2pt 4pt; vertical-align: top; }
  table.pkt td.pkq { width: 30%; }
  table.pkt td.pka { width: 20%; font-weight: 700; }
}
