/* Machines practice: a workshop notebook. Steel-blue ink on grey-white paper, rope drawn in rust orange (the one
   accent, the thing students count), DIN-style condensed headings like the plates on a hoist. Mostly flat, one radius. */
:root {
  --bg: #eef0f1; --paper: #fcfcfb; --ink: #1b2a36; --muted: #45525d; --line: #cdd3d8; --line2: #7c8892;
  --accent: #1d4f6e; --accent-ink: #ffffff; --accent-soft: #dde8ef;
  --rope: #a8430f; --rope-soft: #f6e3d6; --steel: #5d6b76; --block: #e3e7ea; --wood: #d9c6a4; --woodl: #8a6d3e;
  --ok: #1c6a3a; --ok-soft: #e0f0e5; --bad: #a3261b; --bad-soft: #fbe4e1; --warn: #6b4d00; --warn-soft: #f5ebcd;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --head: "Bahnschrift", "DIN Alternate", "DIN Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171b; --paper: #192026; --ink: #e2e8ec; --muted: #b0bcc5; --line: #2f3a43; --line2: #6d7a85;
    --accent: #8cc3e4; --accent-ink: #0b1d29; --accent-soft: #1d2f3b;
    --rope: #f29a63; --rope-soft: #3a2518; --steel: #9eacb7; --block: #26313a; --wood: #5d4c33; --woodl: #c8a873;
    --ok: #84d3a0; --ok-soft: #163020; --bad: #ff9b8f; --bad-soft: #3d1f1b; --warn: #efc46a; --warn-soft: #382e15;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); font-variant-numeric: tabular-nums; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--rope); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.12; font-weight: 700; letter-spacing: 0; }

/* hero */
.hero { padding: 20px 0 2px; }
.hero h1 { font-size: clamp(1.75rem, 5.4vw, 2.6rem); margin: 0 0 6px; }
.lede { margin: 4px 0 0; max-width: 66ch; }
.safety { margin: 8px 0 0; font-weight: 650; color: var(--warn); }
.crumbs { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 0 18px; }
.crumbs a { font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }
.crumbs span { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }

/* setup */
.setup { margin: 10px 0 8px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; max-width: 100%; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); }
select { min-height: 44px; padding: 6px 10px; max-width: 100%; min-width: 0; }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 16px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.note { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: var(--r); overflow-wrap: anywhere; }
.note.info { background: var(--accent-soft); }

/* the sheet */
.sheet { background: var(--paper); border-left: 6px solid var(--accent); padding: 12px 18px 16px; margin: 8px 0 18px; }
@media (max-width: 480px) { .sheet { padding: 10px 10px 14px 12px; margin-left: -8px; margin-right: -8px; border-left-width: 4px; } }
.sheet:focus { outline: none; }
.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.3rem; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.lvname { font-family: var(--sans); font-weight: 500; color: var(--muted); font-size: 1rem; }
.score { margin: 0; color: var(--muted); }
details.rules { margin: 6px 0 2px; }
details.rules summary, details.work summary, details.recent summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
details.rules ul { margin: 4px 0 10px; padding-left: 20px; max-width: 78ch; }
details.rules li { margin: 0 0 4px; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 14px 0 16px; border-top: 1px solid var(--line2); }
.q:first-child { border-top: 0; }
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; }
.qhead h3 { margin: 0 0 4px; font-size: 1.25rem; display: flex; gap: 10px; align-items: baseline; }
.qn { font-family: var(--mono); font-size: 1rem; color: var(--rope); font-weight: 800; }
.qn::after { content: "."; }
.see { font-weight: 600; padding: 10px 0; }
@media (max-width: 600px) { .see { display: none; } }
.qtext { margin: 2px 0 10px; max-width: 76ch; }

/* a problem: the drawing, then the answer rows (beside a tall pulley drawing on wider screens) */
.qbody { display: grid; gap: 8px 22px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 640px) { .qbody.tall { grid-template-columns: auto minmax(0, 1fr); } }
.fig { margin: 0; padding: 0; min-width: 0; }
.fig figcaption { color: var(--muted); padding: 2px 0 0; }
svg.mach { display: block; max-width: 100%; height: auto; }
svg.mach text { font-family: var(--sans); font-size: var(--fs); fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.bar { fill: var(--wood); stroke: var(--woodl); stroke-width: 1.2; }
.rule { fill: #f4e7b8; stroke: var(--woodl); stroke-width: 1.2; }
@media (prefers-color-scheme: dark) { .rule { fill: #4f4528; } }
.rtick { stroke: var(--woodl); stroke-width: 1; }
.ful { fill: var(--steel); }
.pv { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.ext { stroke: var(--line2); stroke-width: 0.8; stroke-dasharray: 2 3; }
.axis { stroke: var(--muted); stroke-width: 1.1; }
svg.mach .pos { fill: var(--muted); }
svg.mach .endl, svg.mach .pvl { font-weight: 700; }
.fl { stroke: var(--ink); stroke-width: 2.2; fill: none; }
.ah { fill: var(--ink); }
.fl.r-effort, .ah.r-effort { stroke: var(--accent); fill: var(--accent); }
.fl.r-effort { fill: none; }
svg.mach .fla { font-weight: 700; }
svg.mach .fla.r-effort { fill: var(--accent); }
.str { stroke: var(--ink); stroke-width: 1.2; }
.wt { fill: var(--steel); }
.ceil { fill: var(--block); }
.ceill { stroke: var(--ink); stroke-width: 2; }
.rod { stroke: var(--ink); stroke-width: 2.4; }
.blk { fill: var(--block); stroke: var(--steel); stroke-width: 1.4; }
.pul { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.axle { fill: var(--ink); }
.rope { fill: none; stroke: var(--rope); stroke-width: 2.6; stroke-linecap: round; }
.knot { fill: var(--rope); }
.load { fill: var(--paper); stroke: var(--ink); stroke-width: 1.8; }
svg.mach .loadl { font-weight: 700; }
.keyc { stroke: var(--rope); }
.ah.keyc { fill: var(--rope); stroke: none; }
.ful.keyc { fill: var(--rope); }
.dim { stroke-width: 1.4; }
svg.mach .arml { fill: var(--rope); font-weight: 700; }
.ah.r-key, .fl.r-key { fill: var(--rope); stroke: var(--rope); }
svg.mach .fla.r-key { fill: var(--rope); }
.rope.hold { stroke-width: 5; }
.num { fill: var(--rope); }
svg.mach .numl { fill: var(--paper); stroke: none; font-weight: 800; font-size: calc(var(--fs) * 0.85); }

/* answer rows */
.answers { display: grid; gap: 0 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24em), 1fr)); align-content: start; }
.qbody.tall .answers { grid-template-columns: minmax(0, 1fr); max-width: 36em; }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; min-height: 50px; border-bottom: 1px dotted var(--line2); flex-wrap: wrap; }
.alab { font-weight: 600; flex: 1 1 8em; }
.aval { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.un { color: var(--muted); min-width: 3.4em; padding-left: 6px; }
.un.typed { visibility: hidden; }
.cw { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; }
input.cell { width: 10.5em; max-width: 100%; min-height: 44px; padding: 6px 8px; text-align: right; font-family: var(--mono); font-size: 16px; }
input.cell.wide { text-align: left; }
input.cell.is-right { border-color: var(--ok); background: var(--ok-soft); }
input.cell.is-close { border-color: var(--warn); background: var(--warn-soft); }
input.cell.is-wrong, input.cell.is-unread { border-color: var(--bad); background: var(--bad-soft); }
input.cell.is-own { border-color: var(--warn); border-style: dashed; }
.mk { display: inline-flex; align-items: baseline; width: 2.3em; flex: none; font-weight: 800; padding-left: 3px; white-space: nowrap; }
.mk-right { color: var(--ok); } .mk-close, .mk-own { color: var(--warn); } .mk-wrong, .mk-unread { color: var(--bad); }
.mn { font-size: 0.8em; font-weight: 700; margin-left: 1px; }

/* feedback */
.fbwrap { margin: 6px 0; }
.fbl { margin: 4px 0; padding: 0 0 0 2.2em; max-width: 80ch; }
.fb { margin: 4px 0; padding: 6px 10px; border-radius: var(--r); background: var(--bad-soft); max-width: 80ch; }
.fbl .fb::marker { font-weight: 700; }
.fb.right { background: var(--ok-soft); }
.fb.close { background: var(--warn-soft); }
.fb.own { background: var(--paper); border: 1px dashed var(--warn); }
.fb.empty { background: var(--paper); border: 1px solid var(--line); }
.qfoot { margin-top: 6px; }
details.work { margin-top: 6px; }
.keyfig { padding: 4px 0 6px; }
.keyfig .fig { margin: 0 0 8px; }
.kans { margin: 0 0 6px; padding-left: 0; list-style: none; }
.kans li { margin: 0 0 2px; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: 0 0 6px; max-width: 86ch; overflow-wrap: anywhere; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line2); }
.confirm { margin: 0; flex-basis: 100%; padding: 10px; background: var(--warn-soft); border-radius: var(--r); }
.save-hint { margin: 0; color: var(--muted); flex-basis: 100%; }

/* print and share */
.share { margin: 0 0 22px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.print-row label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; flex-wrap: wrap; max-width: 100%; }
.share-out label { display: grid; gap: 4px; font-weight: 600; }
.share-out input { min-height: 44px; padding: 6px 10px; width: 100%; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.when { display: block; color: var(--muted); }
.hint { color: var(--muted); margin: 6px 0; }

/* the text below */
.content { max-width: 74ch; padding-bottom: 24px; }
.content h2 { font-size: 1.55rem; margin: 28px 0 8px; }
.content li { margin-bottom: 4px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; padding: 6px 0; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }
footer { border-top: 1px solid var(--line); padding: 16px 0 28px; color: var(--muted); }
footer p { margin: 6px 0; }
.sb-more a { white-space: nowrap; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; margin: 0 auto; width: fit-content; max-width: 560px; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; }
.toast.on { opacity: 1; }
.toast.top { bottom: auto; top: 16px; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.print-root { display: none; }

/* ---------- print ---------- */
@page { margin: 13mm; }
@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child, .psheet:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { font-size: 10pt; color: #222; padding-bottom: 4pt; border-bottom: 0.5pt solid #888; }
  .psafe { display: block; font-weight: 700; color: #000; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 6pt 12pt; flex-wrap: wrap; margin: 4pt 0; }
  .ph h2 { font-size: 14pt; margin: 0; }
  .pmeta { margin: 0; display: flex; gap: 10pt; flex-wrap: wrap; font-size: 10pt; }
  .prules { margin: 0 0 4pt; padding-left: 14pt; font-size: 10pt; line-height: 1.22; }
  .prules li { margin: 0 0 1pt; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li, .pk > li { margin: 0 0 6pt; padding-top: 4pt; border-top: 1pt solid #000; break-inside: avoid; }
  .pq > li:last-child, .pk > li:last-child { margin-bottom: 0; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 0 0 2pt; break-after: avoid; }
  .qtext { margin: 0 0 4pt; max-width: none; }
  .pbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4pt 12pt; align-items: start; }
  .pbody.tall { grid-template-columns: 2.6in minmax(0, 1fr); }
  .pfig svg.mach { width: 100%; max-height: 2.5in; }
  .pbody.tall .pfig svg.mach { max-height: 3.1in; width: auto; max-width: 100%; }
  .pfig figcaption { font-size: 10pt; color: #222; }
  .plines { list-style: none; margin: 0; padding: 0; }
  .plines li { display: flex; align-items: flex-end; gap: 6pt; padding: 7pt 0 1pt; }
  .plines .pl { flex: 1 1 auto; border-bottom: 0.75pt solid #000; min-width: 1in; height: 11pt; }
  .kans { font-size: 10pt; columns: 2; column-gap: 18pt; }
  .kans li { break-inside: avoid; }
  .pbody.tall .kans { columns: 1; }
  .steps { font-size: 10pt; }
  .steps li { margin: 0.5pt 0; max-width: none; break-inside: avoid; }
  svg.mach text { fill: #000; stroke: #fff; }
  svg.mach .pos { fill: #222; }
  .bar { fill: #fff; stroke: #000; } .rule { fill: #fff; stroke: #000; } .rtick { stroke: #000; }
  .ful { fill: #444; } .pv { fill: #fff; stroke: #000; }
  .ext { stroke: #777; } .axis { stroke: #333; }
  .fl, .str, .rod, .ceill { stroke: #000; } .ah, .axle, .wt { fill: #000; }
  .fl.r-effort, .ah.r-effort { stroke: #000; fill: #000; } .fl.r-effort { fill: none; }
  svg.mach .fla.r-effort { fill: #000; }
  .ceil { fill: #fff; } .blk { fill: #fff; stroke: #000; } .pul, .load { fill: #fff; stroke: #000; }
  .rope { stroke: #000; } .knot { fill: #000; }
  .keyc, .rope.hold { stroke: #000; } .ah.keyc, .ful.keyc, .num { fill: #000; }
  svg.mach .arml, svg.mach .fla.key { fill: #000; }
  .ah.r-key, .fl.r-key { fill: #000; stroke: #000; }
  svg.mach .numl { fill: #fff; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
