/* Centroid practice: an engineering computation pad. Pale green paper, graphite ink, cut sections hatched at 45° the
   way a drafted cross-section is, one deep green accent, the centroid marked in brick red only in the key. Tables are
   ruled like a hand calculation sheet. Figures in tabular numerals. */
:root {
  --bg: #eef2ea; --paper: #fbfcf8; --ink: #1c261e; --muted: #48544b; --line: #cfd8cc; --line2: #7b887d;
  --accent: #2c6640; --accent-ink: #ffffff; --accent-soft: #dcebdf;
  --fill: #dfe8da; --hatch: #7d9583; --hole: #fbfcf8; --dimc: #4d5a50; --cen: #a33a1f;
  --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: 3px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a16; --paper: #1c231e; --ink: #e3ebe4; --muted: #b3c0b6; --line: #334037; --line2: #6f7f73;
    --accent: #86c99a; --accent-ink: #0d2015; --accent-soft: #1e3526;
    --fill: #2a352d; --hatch: #6e8a74; --hole: #1c231e; --dimc: #b3c0b6; --cen: #f3a088;
    --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: 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(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; font-weight: 750; letter-spacing: -0.01em; }
sub { font-size: 0.72em; line-height: 0; }

/* hero */
.hero { padding: 20px 0 2px; }
.hero h1 { font-size: clamp(1.65rem, 5vw, 2.45rem); margin: 0 0 8px; }
.lede { margin: 4px 0 0; max-width: 66ch; }
.safety { margin: 10px 0 0; font-weight: 650; color: var(--warn); }
.pages { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 0 18px; }
.pages a, .crumbs a { font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }
.crumbs { margin: 0; color: var(--muted); }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.btnrow .btn { text-decoration: none; display: inline-flex; align-items: center; }

/* setup */
.setup { margin: 12px 0 10px; }
.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: a ruled calculation pad */
.sheet { background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--accent); padding: 14px 18px 16px; margin: 10px 0 18px; }
@media (max-width: 480px) { .sheet { padding: 12px 10px 14px; margin-left: -6px; margin-right: -6px; } }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; border-bottom: 1px solid var(--line2); 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: 8px 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, details.rules ol { 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: 2px solid var(--ink); }
.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 { font-family: var(--mono); font-size: 1rem; color: var(--accent); font-weight: 800; }
.qn::after { content: "."; }
.see { font-weight: 600; padding: 10px 0; }
/* on a phone the answer is reached from its own disclosure under the tables, so the drawing comes up sooner */
@media (max-width: 600px) { .see { display: none; } }
.scen { margin: 4px 0 8px; max-width: 76ch; }

/* the drawing */
.fig { margin: 4px 0 12px; padding: 0; background: var(--paper); border: 1px solid var(--line); max-width: 680px; }
.fig figcaption { margin: 0; padding: 2px 10px 8px; }
.radii { margin: 0; color: var(--muted); }
svg.shape { display: block; width: 100%; height: auto; }
svg.shape text { font-family: var(--sans); font-size: var(--fs); fill: var(--ink); }
.pc { fill: var(--fill); stroke: none; }
.ph { stroke: none; }
.hl { stroke: var(--hatch); stroke-width: 1.1; }
.hole { fill: var(--hole); stroke: none; }
.po { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; }
.cln { stroke: var(--dimc); stroke-width: 0.9; stroke-dasharray: 10 3 2 3; fill: none; }
.rad { stroke: var(--ink); stroke-width: 1.2; }
.cdot { fill: var(--ink); }
.ext { stroke: var(--dimc); stroke-width: 0.8; stroke-dasharray: 2 2; }
.dim, .tick { stroke: var(--dimc); stroke-width: 1.1; }
svg.shape .dl { fill: var(--muted); }
.axes line { stroke: var(--accent); stroke-width: 1.8; }
.axes path, .axes circle { fill: var(--accent); }
svg.shape .ol { fill: var(--accent); font-weight: 750; }
.pn circle { fill: var(--paper); stroke: var(--ink); stroke-width: 1.4; }
svg.shape .pn text { font-weight: 750; }
.lead { stroke: var(--ink); stroke-width: 1; }
.cax { stroke: var(--cen); stroke-width: 1.4; stroke-dasharray: 12 4 3 4; }
.cm { fill: var(--paper); stroke: var(--cen); stroke-width: 2.2; }
.cmd { fill: var(--cen); }
svg.shape .cl { fill: var(--cen); font-weight: 750; }

/* the tables */
.twrap { max-width: 100%; margin: 0 0 10px; }
/* fit.js turns a table that does not fit into rows; until it has measured (a busy phone), the table scrolls inside
   its box instead of pushing the page sideways */
@media screen { .twrap { overflow-x: auto; } .twrap:not(.rows) .dt input.cell { max-width: none; } }
table.dt { border-collapse: collapse; font-variant-numeric: tabular-nums; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.dt caption { text-align: left; font-weight: 700; font-size: 1.05rem; padding: 0 0 4px; }
.dt th, .dt td { padding: 5px 8px; text-align: left; vertical-align: middle; font-weight: 400; }
.dt thead th { font-weight: 700; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
/* a column heading ends where its boxes end, not over the marks beside them */
@media screen { .twrap:not(.rows) .dt thead th.num { padding-right: calc(2.5em + 6px); } }
.dt .num { text-align: right; white-space: nowrap; }
.hu { display: block; font-weight: 500; color: var(--muted); font-size: 1rem; }
.dt tbody th[scope="row"] { font-weight: 600; white-space: nowrap; }
.rn { font-family: var(--mono); font-weight: 800; color: var(--accent); }
.dt tbody tr + tr { border-top: 1px solid var(--line); }
.dt tr.tot { border-top: 1.5px solid var(--line2); }
.dt tr.tot th { font-size: 1.15rem; }
.dt td.in { padding: 4px 4px; }
.dt td.kc { font-weight: 700; padding: 5px 10px; }
.dt td.in .cw { display: flex; justify-content: flex-end; }
.answers { display: grid; gap: 4px 24px; margin: 0 0 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19em), 1fr)); }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; min-height: 46px; border-bottom: 1px dotted var(--line2); flex-wrap: wrap; }
.alab { font-weight: 700; }
.aval { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.un { color: var(--muted); min-width: 4.4em; }
.cw { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; }
.cw > .cell { flex: none; }
input.cell { width: calc(var(--w) * 0.62em + 1em); max-width: 100%; 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(--warn); border-style: dashed; }
.mk { display: inline-flex; align-items: baseline; justify-content: flex-start; width: 2.5em; 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; }
.kv { font-family: var(--mono); }

/* tables that do not fit (fit.js measures them; screen only): each row becomes a block, each value labelled */
@media screen {
  .twrap.rows table, .twrap.rows tbody { display: block; width: 100%; }
  .twrap.rows table.dt { border-bottom: 0; }
  .twrap.rows caption { display: block; }
  .twrap.rows thead { display: none; }
  .twrap.rows tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14em), 1fr)); gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
  .twrap.rows tbody tr + tr { border-top: 0; }
  .twrap.rows tbody th[scope="row"] { grid-column: 1 / -1; }
  .twrap.rows th, .twrap.rows td { border: 0; padding: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; white-space: normal; }
  .twrap.rows th { justify-content: flex-start; font-weight: 700; color: var(--ink); }
  .twrap.rows td::before { content: attr(data-l); font: 600 1rem var(--sans); color: var(--muted); }
  .twrap.rows td::before { flex: 1 1 3.5em; min-width: 0; overflow-wrap: anywhere; text-align: left; }
  .twrap.rows td { flex-wrap: wrap; }
  .twrap.rows td > .cw { flex: 0 0 auto; }
  .twrap.rows td.na { display: none; }
  .twrap.rows td.in .cw { margin-left: auto; }
  .twrap.rows input.cell { width: 9.5em; }
  .twrap.rows tr.tot th { display: none; }
}

/* 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; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.kpart { min-width: 0; }
.kh { font-weight: 700; margin: 10px 0 4px; }
.kq { display: none; }
.kplain { margin: 0 0 6px; max-width: 80ch; }
.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: 2px solid var(--ink); }
.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.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); 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: 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: 14pt; margin: 0; }
  .pmeta { margin: 0; display: flex; gap: 10pt; flex-wrap: wrap; font-size: 10pt; }
  .prules { margin: 0 0 3pt; padding-left: 14pt; font-size: 9pt; line-height: 1.22; column-count: 2; column-gap: 18pt; }
  .prules li { margin: 0 0 1pt; break-inside: avoid; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { margin: 0 0 5pt; padding-top: 3pt; border-top: 1.2pt solid #000; }
  .ptop, .answers, .tblock { break-inside: avoid; }
  /* a problem that fits on a page is kept whole (the first one may share its page with the rules, so it only keeps
     its drawing with its first table, as does one too tall for a page) */
  .pq > li:not(:first-child) { break-inside: avoid; }
  .ptop { break-after: avoid; }
  .tshort { break-before: avoid; }
  .pk > li { margin: 0 0 8pt; padding-top: 4pt; border-top: 1pt solid #000; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 0 0 3pt; break-after: avoid; }
  .scen { margin: 0 0 4pt; max-width: none; }
  .fig { border: 0.5pt solid #999; margin: 0 0 5pt; break-inside: avoid; max-width: none; text-align: center; }
  .fig svg.shape { width: 56%; max-height: 2in; margin: 0 auto; }
  /* on the worksheet the problem's words sit beside its drawing */
  .pq .ptop { display: grid; grid-template-columns: minmax(0, 1fr) 58%; column-gap: 10pt; align-items: start; }
  .pq .ptop > h3 { grid-column: 1 / -1; }
  .pq .ptop > .scen { grid-column: 1; margin: 0; }
  .pq .ptop > .fig { grid-column: 2; }
  .pq .ptop .fig svg.shape { width: 100%; }
  .fig figcaption { text-align: left; padding: 0 6pt 3pt; }
  .radii { color: #222; }
  svg.shape text, svg.shape .dl, svg.shape .ol, svg.shape .cl { fill: #000; }
  .pc { fill: #fff; } .hl { stroke: #777; stroke-width: 0.9; } .hole { fill: #fff; }
  .po, .rad, .lead { stroke: #000; } .cdot { fill: #000; }
  .ext, .dim, .tick, .cln { stroke: #444; }
  .axes line { stroke: #000; } .axes path, .axes circle { fill: #000; }
  .pn circle { fill: #fff; stroke: #000; }
  .cax { stroke: #000; } .cm { fill: #fff; stroke: #000; } .cmd { fill: #000; }
  .twrap { break-inside: avoid; margin: 0 0 2pt; }
  table.dt { font-size: 10pt; width: 100%; border-top: 1.2pt solid #000; border-bottom: 1.2pt solid #000; }
  .dt caption { font-size: 10pt; padding-bottom: 2pt; }
  .dt th, .dt td { padding: 1.5pt 5pt; }
  .dt thead th { border-bottom: 0.75pt solid #000; }
  .dt tbody tr + tr { border-top: 0.5pt solid #999; }
  .dt tr.tot { border-top: 0.9pt solid #000; }
  .hu { font-size: 8.5pt; color: #222; }
  .rn { color: #000; }
  .dt td.in { height: 14pt; padding: 1.5pt 4px; }
  .pblank { display: inline-block; border-bottom: 0.75pt solid #000; height: 12pt; vertical-align: bottom; }
  .answers { grid-template-columns: repeat(2, 1fr); gap: 2pt 14pt; margin: 0 0 3pt; }
  .arow { min-height: 0; padding: 2pt 0; border-bottom: 0; }
  .un { color: #222; min-width: 0; }
  .kq { display: inline; }
  .kh { margin: 3pt 0 1pt; font-size: 10.5pt; break-after: avoid; }
  .kplain { font-size: 10pt; margin: 0 0 2pt; max-width: none; }
  .steps { font-size: 10pt; }
  .steps li { margin: 0.5pt 0; max-width: none; break-inside: avoid; }
  .kpart:not(.kmain) { break-inside: avoid; }
  .pq > li:last-child, .pk > li:last-child, .kpart:last-child, .steps li:last-child, .kpart:last-child .kplain { margin-bottom: 0; padding-bottom: 0; } /* a page filled to the last line does not spill an empty one */ /* a few lines of working never spill onto a page of their own */
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
