/* Truss practice: a drafting sheet. Cool grey-white paper, graphite ink, trusses drawn on a faint grid like a
   statics notebook, one steel-blue accent. Tension and compression in the key are told apart by line weight and by
   the letters T and C, with colour only as a third cue. Figures in tabular numerals. */
:root {
  --bg: #f1f3f2; --paper: #fcfdfc; --ink: #1b2229; --muted: #47525c; --line: #d3d9dc; --line2: #7c8891;
  --accent: #155e86; --accent-ink: #ffffff; --accent-soft: #dcebf3;
  --grid: #e3e9ec; --load: #8a3b12; --t: #1f5d99; --c: #a12b23; --zero: #5d6770;
  --ok: #1d6a39; --ok-soft: #e1f1e6; --bad: #a3261b; --bad-soft: #fbe4e1; --warn: #6e4f00; --warn-soft: #f6ecd0;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171b; --paper: #1a2126; --ink: #e4eaee; --muted: #b0bcc5; --line: #313c44; --line2: #6e7d88;
    --accent: #7cc0e8; --accent-ink: #0a1d29; --accent-soft: #183245;
    --grid: #222b31; --load: #f0a676; --t: #8cbcf0; --c: #f19a8f; --zero: #a3afb8;
    --ok: #82d39f; --ok-soft: #173020; --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: 1060px; 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(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; font-weight: 750; letter-spacing: -0.01em; }
sub { font-size: 0.72em; }

/* hero */
.hero { padding: 22px 0 2px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); margin: 0 0 8px; }
.lede { margin: 4px 0 0; max-width: 64ch; }
.safety { margin: 10px 0 0; font-weight: 650; color: var(--warn); }
.crumbs { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.crumbs a { font-weight: 600; }

/* setup */
.setup { margin: 14px 0 10px; display: grid; gap: 10px; }
.setup fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.setup legend { font-weight: 700; margin-bottom: 4px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: flex; align-items: center; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line2); background: var(--paper); border-radius: var(--r); white-space: nowrap; }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.setgrid { display: grid; gap: 10px 28px; }
@media (min-width: 760px) { .setgrid { grid-template-columns: auto auto; justify-content: start; } }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
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%; }
.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: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 16px; margin: 10px 0 18px; }
@media (max-width: 480px) { .sheet { padding: 12px 10px 14px; } }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.lvname { font-weight: 500; color: var(--muted); font-size: 1rem; }
.score { margin: 0; color: var(--muted); }
details.rules { margin: 10px 0 4px; }
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: 74ch; }
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(--line); }
.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.15rem; display: flex; gap: 10px; align-items: baseline; }
.qn { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; border: 2px solid var(--ink); border-radius: 50%; font-size: 0.9rem; }
.see { font-weight: 600; padding: 10px 0; }
.scen { margin: 4px 0 8px; max-width: 74ch; }

/* the drawing, on a faint grid */
.fig { margin: 4px 0 10px; padding: 6px 0; background-color: var(--paper); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; border: 1px solid var(--line); border-radius: var(--r); }
svg.truss { display: block; width: 100%; height: auto; overflow: visible; }
svg.truss text { font-family: var(--sans); font-size: var(--fs); fill: var(--ink); }
svg.truss .jl { font-weight: 750; }
svg.truss .ll { fill: var(--load); font-weight: 650; }
svg.truss .dl { fill: var(--muted); }
svg.truss .cutl { fill: var(--accent); font-weight: 650; }
.mem { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.mem.mt { stroke: var(--t); stroke-width: 2.6; }
.mem.mc { stroke: var(--c); stroke-width: 6; }
.mem.m0 { stroke: var(--zero); stroke-width: 2; stroke-dasharray: 7 5; }
.jt { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.sup { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.gnd { stroke: var(--ink); stroke-width: 2; }
.hatch { stroke: var(--ink); stroke-width: 1.2; }
.ld { stroke: var(--load); stroke-width: 2.4; fill: none; }
.ldh { fill: var(--load); }
.dim { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.cut { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 9 6; fill: none; }
.legend { margin: 6px 10px 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 1rem; }
.lg { display: inline-block; width: 30px; height: 0; border-top: 3px solid var(--t); margin-left: 8px; vertical-align: middle; }
.lg:first-child { margin-left: 0; }
.lg.lc { border-top: 6px solid var(--c); }
.lg.l0 { border-top: 2px dashed var(--zero); }

/* answers */
.answers { display: grid; gap: 10px; }
.agh { margin: 0 0 4px; font-weight: 700; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.2em), 1fr)); gap: 2px 18px; }
.agrid.r { grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.4em), 1fr)); }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 46px; border-bottom: 1px dotted var(--line); }
.alab { font-weight: 700; }
@media (min-width: 560px) {
  .alab { white-space: nowrap; }
  .agrid.r { grid-template-columns: repeat(auto-fill, minmax(15.5em, 1fr)); }
}
.pos { font-weight: 400; color: var(--muted); }
.aval { display: inline-flex; align-items: center; gap: 4px; }
.un { color: var(--muted); min-width: 1.4em; }
.cw { display: inline-flex; align-items: center; gap: 2px; }
input.cell { width: calc(var(--w) * 0.6em + 1em); min-height: 44px; padding: 6px 6px; text-align: right; font-family: var(--mono); font-size: 16px; }
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(--line2); border-style: dashed; }
.mk { display: inline-flex; align-items: baseline; justify-content: flex-start; width: 1.8em; font-weight: 800; padding-left: 3px; }
.mk-right { color: var(--ok); } .mk-close { color: var(--warn); } .mk-wrong, .mk-unread { color: var(--bad); } .mk-own { color: var(--muted); }
.mn { font-size: 0.75em; font-weight: 700; margin-left: 1px; }
.arow.azf { display: block; border: 0; }
.cwz { display: flex; align-items: flex-start; }
.zf { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.zchip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 10px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--paper); cursor: pointer; font-family: var(--mono); font-weight: 700; }
.zchip input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.zchip.is-right { border-color: var(--ok); background: var(--ok-soft); }
.zchip.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.zm { font-family: var(--sans); }
.zchip.is-right .zm { color: var(--ok); } .zchip.is-wrong .zm { color: var(--bad); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* feedback */
.fbwrap { margin: 8px 0 0; }
.fbl { margin: 0; padding-left: 1.6em; }
.fb { margin: 4px 0; max-width: 78ch; }
.fb.wrong, .fb.unread { color: var(--bad); }
.fb.close { color: var(--warn); }
.fb.own, .fb.empty { color: var(--muted); }
.fb.right { color: var(--ok); }
.fb b { color: var(--ink); }
.qfoot { margin-top: 8px; }
details.work { margin-top: 6px; }
.keyfig { padding: 4px 0 6px; }
.kh { font-weight: 700; margin: 10px 0 4px; }
.kq { display: none; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: 0 0 6px; max-width: 80ch; overflow-wrap: anywhere; }
.kv { font-family: var(--mono); margin-right: 1.2em; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--ink); }
.confirm { margin: 0; flex-basis: 100%; }
.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; }
.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.45rem; 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); }
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: 50%; bottom: 16px; transform: translateX(-50%); max-width: min(92vw, 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: 12mm; }
@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: 9.5pt; 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: 15pt; margin: 0; }
  .pmeta { margin: 0; display: flex; gap: 12pt; flex-wrap: wrap; }
  .prules { margin: 0 0 4pt; padding-left: 14pt; font-size: 9.5pt; }
  .prules li { margin: 0 0 1pt; break-inside: avoid; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { margin: 0 0 8pt; padding-top: 4pt; border-top: 1.2pt solid #000; break-inside: avoid; }
  .pk > li { margin: 0 0 8pt; padding-top: 4pt; border-top: 1pt solid #000; }
  /* the key drawing stays with the start of its working; the working breaks between steps, never inside one */
  .kpart:first-child, .kpart:last-child { break-inside: avoid; }
  .kpart:first-child { break-after: avoid; }
  .kh { break-after: avoid; }
  .steps li { break-inside: avoid; }
  /* the answers stay on the page with the end of their working */
  .kpart:last-child { break-before: avoid; }
  .steps li:last-child { break-after: avoid; }
  .alab, .kv, .pos, .un { white-space: nowrap; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 0 0 3pt; break-after: avoid; }
  .scen { margin: 0 0 4pt; max-width: none; }
  .fig { background: none; border: 0.5pt solid #999; margin: 0 0 5pt; padding: 2pt 0; break-inside: avoid; }
  .fig svg.truss { width: 70%; max-height: 60mm; margin: 0 auto; }
  svg.truss text { fill: #000; }
  svg.truss .ll { fill: #000; }
  .mem { stroke: #000; }
  .mem.mt { stroke: #000; stroke-width: 2.2; }
  .mem.mc { stroke: #000; stroke-width: 6; }
  .mem.m0 { stroke: #000; stroke-width: 1.6; }
  .ld { stroke: #000; } .ldh { fill: #000; }
  .lg { border-top: 2px solid #000; } .lg.lc { border-top: 6px solid #000; } .lg.l0 { border-top: 1.6px dashed #000; }
  .legend { font-size: 10pt; margin: 2pt 6pt; }
  .agh { font-size: 10.5pt; margin: 0 0 2pt; }
  .agrid { grid-template-columns: repeat(4, 1fr); gap: 2pt 12pt; }
  .agrid.r { grid-template-columns: repeat(3, 1fr); }
  .arow { min-height: 0; padding: 1.5pt 0; border-bottom: 0; }
  .pblank { display: inline-block; border: 0.75pt solid #000; height: 18pt; vertical-align: middle; }
  .pos, .un { color: #222; }
  .pzf { display: flex; flex-wrap: wrap; gap: 4pt 10pt; margin-top: 3pt; font-family: var(--mono); font-weight: 700; }
  .pzf span { padding: 1pt 4pt; }
  .kq { display: inline; }
  .kh { margin: 3pt 0 1pt; font-size: 10.5pt; }
  .steps { font-size: 10pt; }
  .steps li { margin: 0.5pt 0; max-width: none; }
  .kpart .answers .agrid { grid-template-columns: repeat(4, 1fr); }
  .kpart .arow { padding: 1pt 0; }
  .answers { gap: 4pt; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
