/* U-value practice: a construction drawing sheet. Warm drawing paper, graphite ink, a title-block rule under the
   heading, a section drawn with the usual material hatching, and one burnt-orange accent (the set code, focus, links).
   Figures in a tabular face so R values line up. */
:root {
  --bg: #efece4; --paper: #fbfaf6; --ink: #22262a; --muted: #4b5157; --line: #cbc5b6; --line2: #8a8576;
  --accent: #9a4300; --accent-ink: #ffffff; --accent-soft: #f6e4d4;
  --ok: #1d6634; --ok-soft: #dcefe1; --bad: #a3261b; --bad-soft: #fae3df; --warn: #6f4e00; --warn-soft: #f4e8c8;
  --render: #e3ded3; --block: #d9d6cf; --board: #f3dd84; --bead: #f6e7b0; --wool: #f2cfa6; --timber: #e8c99a;
  --plaster: #f1eee7; --concrete: #cfd2d4; --membrane: #3a3d40; --screed: #dcd8cc; --sand: #eadfb8; --hardcore: #cbc3b2;
  --soil: #c9b49a; --cavity: #fbfaf6; --hatch: #3d4246;
  --head: Futura, "Century Gothic", "Avenir Next", "Avenir", "Trebuchet MS", system-ui, sans-serif;
  --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: #17191b; --paper: #1f2225; --ink: #e6e3dc; --muted: #b3b0a8; --line: #3a3e42; --line2: #7a786f;
    --accent: #f0a46a; --accent-ink: #231204; --accent-soft: #3a2615;
    --ok: #86d29e; --ok-soft: #173020; --bad: #ff9d90; --bad-soft: #3e201c; --warn: #ecc86e; --warn-soft: #372d14;
    --render: #4a4740; --block: #44464a; --board: #6b5b1c; --bead: #5c5130; --wool: #6a4e33; --timber: #634c2e;
    --plaster: #34363a; --concrete: #3f4448; --membrane: #c9ccce; --screed: #45433d; --sand: #5a5236; --hardcore: #4a463e;
    --soil: #54473a; --cavity: #1f2225; --hatch: #d7d4cc;
  }
}
* { 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); }
.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, h4 { font-family: var(--head); line-height: 1.2; font-weight: 700; letter-spacing: 0.01em; }
.nw { white-space: nowrap; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* heading: a drawing's title block */
.hero { padding: 22px 0 10px; border-bottom: 3px double var(--line2); }
.hero h1 { font-size: clamp(1.65rem, 5vw, 2.4rem); margin: 0 0 6px; }
.lede { margin: 0; max-width: 66ch; }

/* setup */
.setup { margin: 14px 0 10px; display: grid; gap: 10px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; margin-bottom: 6px; 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: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--paper); cursor: pointer; }
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
label.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 8px; max-width: 100%; }
.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 44px; padding: 6px 14px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; padding: 10px 4px; min-height: 44px; color: var(--accent); text-decoration: underline; cursor: pointer; }
.note { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--bad); background: var(--bad-soft); border-radius: var(--r); max-width: 78ch; overflow-wrap: anywhere; }
.note.info { border-color: var(--line2); background: var(--paper); }

/* the sheet */
.sheet { margin: 14px 0 18px; }
.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 { font-size: 1.3rem; margin: 0; }
.code { font-family: var(--mono); color: var(--accent); letter-spacing: 0.06em; }
.lvname { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 1rem; }
.score { margin: 0; font-weight: 600; }
.rules { margin: 10px 0; }
.rules summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.rules ul { margin: 4px 0 8px; padding-left: 1.3em; max-width: 80ch; }
.rules li { margin: 4px 0; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--ink); padding: 12px 14px 14px; margin: 16px 0; }
.qhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.qhead h3 { margin: 0; font-size: 1.2rem; }
.qn { display: inline-block; min-width: 1.6em; margin-right: 6px; color: var(--accent); }
.see { white-space: nowrap; padding: 10px 0; }
.scen { margin: 6px 0 12px; max-width: 72ch; }

/* the section and the table side by side when there is room */
.fig { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 22px; align-items: start; }
.fig > * { min-width: 0; }
@media (min-width: 860px) { .fig { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); } }
.sec { margin: 0; }
.sec .end { font-weight: 700; font-size: 1rem; padding: 2px 0; }
.bands { border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.ly { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: stretch; gap: 10px; }
.ly .ln { align-self: center; padding: 3px 0; }
.ly + .ly .sw { border-top: 1px solid var(--hatch); }
.sw { display: block; width: 112px; height: 100%; min-height: 100%; border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); }
.sw .bg, .wsec .bg { fill: var(--cavity); }
.sw .hl, .wsec .hl { stroke: var(--hatch); stroke-width: 1; fill: none; }
.sw .hl.thin, .wsec .hl.thin { stroke-width: 0.6; }
.sw .hd, .wsec .hd { fill: var(--hatch); }
.sw .void, .wsec .void { fill: var(--cavity); stroke: var(--hatch); stroke-width: 0.8; }
.wsec { display: block; max-width: 100%; height: auto; overflow: visible; }
.wsec .wbox { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.wsec .wsep { stroke: var(--hatch); stroke-width: 1; }
.wsec .wnum { fill: var(--ink); font: 700 12px var(--sans); }
.wends { display: flex; justify-content: space-between; max-width: 224px; }
.wl { margin: 6px 0 0; padding: 0; list-style: none; }
.wl li { margin: 1px 0; padding-left: 1.5em; text-indent: -1.5em; }
.wl .wn { display: inline-block; width: 1.5em; text-indent: 0; font-weight: 700; }
.p-render .bg { fill: var(--render); } .p-block .bg, .p-hollow .bg { fill: var(--block); } .p-board .bg { fill: var(--board); }
.p-bead .bg { fill: var(--bead); } .p-wool .bg { fill: var(--wool); } .p-timber .bg { fill: var(--timber); }
.p-plaster .bg { fill: var(--plaster); } .p-concrete .bg { fill: var(--concrete); }
.p-screed .bg { fill: var(--screed); } .p-sand .bg { fill: var(--sand); } .p-hardcore .bg { fill: var(--hardcore); } .p-soil .bg { fill: var(--soil); }
.sw .mem, .wsec .mem { fill: var(--membrane); }
.ln { font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }

/* tables */
.twrap { max-width: 100%; }
table.ut, table.kt { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.ut th, table.ut td, table.kt th, table.kt td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.ut thead th, table.kt thead th { font-family: var(--head); font-size: 1rem; border-bottom: 1.5px solid var(--ink); }
table.ut tbody th { font-weight: 600; }
table.ut tr.sf th, table.ut tr.sf td.t { color: var(--muted); font-weight: 400; }
table.ut td.t { white-space: nowrap; }
table.ut td.d { font-family: var(--mono); font-size: 0.95rem; }
table.ut td.d .u { font-family: var(--sans); color: var(--muted); }
table.ut td.a { white-space: nowrap; }
table.ut tfoot th { text-align: right; font-family: var(--head); border-bottom: 0; }
table.ut tfoot td { border-bottom: 0; }
table.kt td { font-family: var(--mono); font-size: 0.95rem; }
table.kt td.a { font-weight: 700; }
/* tables that do not fit their box: each row becomes a block with every value labelled (fit.js) */
@media screen {
  .twrap.rows table, .twrap.rows tbody, .twrap.rows tfoot { display: block; width: 100%; }
  .twrap.rows thead { display: none; }
  .twrap.rows tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 8px 2px; border-bottom: 1px solid var(--line); align-items: center; }
  .twrap.rows th, .twrap.rows td { border: 0; padding: 0; }
  .twrap.rows tbody th { grid-column: 1 / -1; }
  .twrap.rows td.t, .twrap.rows td.d { grid-column: 1; }
  .twrap.rows td.t:empty { display: none; }
  .twrap.rows td.a { grid-column: 2; grid-row: 2 / span 2; justify-self: end; }
  .twrap.rows tfoot tr { grid-template-columns: minmax(0, 1fr) auto; }
  .twrap.rows tfoot th { text-align: left; grid-column: 1; }
  .twrap.rows tfoot td.a { grid-column: 2; grid-row: auto; }
  .twrap.rows.kt tr { grid-template-columns: minmax(0, 1fr) auto; }
  .twrap.rows.kt td { grid-column: 1; overflow-wrap: anywhere; }
  .twrap.rows.kt td.a { grid-column: 2; grid-row: 2; }
}

/* answer lines */
.aline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 8px 0; }
.alab { font-weight: 600; min-width: 9.5em; }
.abox { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.unit { color: var(--muted); }
.heat { margin-top: 16px; border-top: 1px solid var(--line2); padding-top: 4px; }
.heat h4 { margin: 8px 0; font-size: 1.05rem; }
.hd { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15em), 1fr)); gap: 4px 20px; margin: 0 0 10px; }
.hd div { display: flex; flex-wrap: wrap; gap: 0 6px; border-bottom: 1px dotted var(--line); padding: 2px 0; }
.hd dt { color: var(--muted); }
.hd dd { margin: 0; font-weight: 600; }

/* boxes and marks */
input.cell { min-height: 44px; padding: 6px 8px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; max-width: 100%; width: calc(var(--w, 8) * 1ch + 22px); }
.cell.is-right { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.cell.is-wrong, .cell.is-unread { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.cell.is-close { border-color: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn); }
.cell.is-own { border-color: var(--warn); border-style: dashed; box-shadow: inset 0 0 0 1px var(--warn); }
.cw { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; min-width: 0; }
.cw > .cell { flex: 0 1 auto; min-width: 5ch; }
.mk { flex: none; min-width: 1.6em; font-weight: 700; font-size: 1.1rem; line-height: 1; white-space: nowrap; }
.mn { font-size: 0.8rem; vertical-align: super; margin-left: 1px; }
.mk-right { color: var(--ok); }
.mk-close, .mk-own { color: var(--warn); }
.mk-wrong, .mk-unread { color: var(--bad); }
.fbwrap { margin: 8px 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: 8px 0 4px; }
.work { margin-top: 8px; border-top: 1px solid var(--line); }
.work summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.keyfig { padding: 4px 0 6px; }
.kl { margin: 10px 0 0; padding-left: 1.4em; }
.kl li { margin: 4px 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; }
.confirm { flex-basis: 100%; margin: 0; padding: 8px 10px; background: var(--warn-soft); border-radius: var(--r); }
.save-hint { margin: 0; color: var(--muted); }

/* print and share */
.share { margin: 8px 0 24px; padding-top: 12px; border-top: 1px solid var(--line2); }
.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 { margin: 10px 0; }
.share-out label { display: grid; gap: 4px; font-weight: 600; }
.share-out input { width: 100%; min-height: 44px; padding: 6px 8px; font-family: var(--mono); }
.recent { margin-top: 14px; }
.recent summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.recent .when { display: block; color: var(--muted); }
.hint { color: var(--muted); }

/* text below the tool */
.content { max-width: 75ch; padding-bottom: 24px; }
.content h2 { font-size: 1.35rem; margin: 28px 0 8px; }
.content table.dt { border-collapse: collapse; margin: 8px 0; }
.content table.dt th, .content table.dt td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.content table.dt thead th { border-bottom: 1.5px solid var(--ink); font-family: var(--head); }
.content table.dt td { font-family: var(--mono); font-size: 0.95rem; }
@media screen { .content .twrap.rows tr { display: block; } .content .twrap.rows td { display: block; } }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); }
.sources a { overflow-wrap: anywhere; }

/* footer */
footer { border-top: 3px double var(--line2); padding: 18px 0 28px; background: var(--bg); }
.indep { margin: 0 0 10px; color: var(--muted); max-width: 80ch; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-privacy, .sb-credit { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); max-width: min(92vw, 560px); z-index: 20; pointer-events: none; transition: transform 0.2s; }
.toast.on { transform: translate(-50%, 0); }
.toast.top { top: 16px; bottom: auto; transform: translate(-50%, -140%); }
.toast.top.on { transform: translate(-50%, 0); }
@media (max-width: 520px) {
  .toast { left: 8px; right: 8px; bottom: 8px; max-width: none; text-align: center; transform: translateY(140%); }
  .toast.top { top: 8px; bottom: auto; transform: translateY(-140%); }
  .toast.on, .toast.top.on { transform: none; }
  .q { padding: 10px 10px 12px; margin: 12px -6px; }
  .alab { min-width: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.print-root { display: none; }

/* ---------- print ---------- */
@page { margin: 12mm; }
@media print {
  :root { --paper: #fff; --ink: #000; --muted: #333; --line: #999; --line2: #555; --hatch: #222; --cavity: #fff;
    --render: #e8e4dc; --block: #dedbd5; --board: #f5e39c; --bead: #f7ecc2; --wool: #f4d8b8; --timber: #ecd4ae;
    --plaster: #f4f2ee; --concrete: #d8dadc; --membrane: #222; --screed: #e2dfd6; --sand: #efe7c9; --hardcore: #d4cdbf; --soil: #d3c2ad; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--sans); }
  main, footer, .skip, .toast { 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: #333; padding-bottom: 4pt; border-bottom: 0.5pt solid #888; text-align: left; font-weight: 400; }
  .pt > tbody > tr > td { padding: 0; }
  .ph { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4pt 16pt; border-bottom: 1.5pt solid #000; margin: 6pt 0; }
  .ph h2 { font-size: 15pt; margin: 0 0 3pt; }
  .pmeta { display: flex; gap: 16pt; margin: 0; }
  .prules { margin: 4pt 0 6pt; padding-left: 14pt; font-size: 10pt; }
  .prules li { margin: 1pt 0; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li, .pk > li { break-inside: avoid; border-top: 1pt solid #000; padding: 3pt 0 4pt; margin-top: 3pt; }
  .pq h3, .pk h3 { font-size: 11.5pt; margin: 0 0 2pt; }
  .psheet .scen { display: none; } /* the title names the build-up and the rules say what to fill in */
  .fig { display: grid; grid-template-columns: 56mm minmax(0, 1fr); gap: 8pt; }
  /* on paper a band is as tall as its label: the drawing fills the band instead of setting its height */
  .ly { grid-template-columns: 18mm minmax(0, 1fr); gap: 4pt; min-height: 17pt !important; position: relative; }
  .ly .ln { grid-column: 2; padding: 1pt 0; }
  .sw { position: absolute; left: 0; top: 0; width: 18mm; height: 100%; }
  .wsec { width: 52mm; }
  .wsec .wnum { font-size: 15.5px; } /* 10pt once the drawing is scaled to 52mm */
  .wends { max-width: 52mm; }
  .wl { margin-top: 3pt; font-size: 10pt; }
  .wl li { margin: 0; }
  .ln { font-size: 10pt; }
  .sec .end { font-size: 10pt; }
  table.ut th, table.ut td, table.kt th, table.kt td { line-height: 1.2; padding: 1.5pt 4pt; border-bottom: 0.5pt solid #999; font-size: 10pt; }
  table.ut thead th, table.kt thead th { font-size: 10pt; border-bottom: 1pt solid #000; }
  table.ut, table.kt { width: calc(100% - 1pt); margin-left: 0.5pt; }
  table.ut td.d, table.ut td.t { font-size: 10pt; white-space: nowrap; }
  .pblank { display: inline-block; border-bottom: 0.75pt solid #000; height: 14pt; vertical-align: bottom; }
  .aline { margin: 1.5pt 0; gap: 2pt 8pt; }
  .alab { min-width: 34mm; }
  .heat { margin-top: 3pt; padding-top: 1pt; border-top: 0.5pt solid #999; }
  .heat h4 { margin: 1pt 0; font-size: 10pt; }
  .hd { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12pt; margin: 0 0 3pt; font-size: 10pt; }
  .hd div { border-bottom: 0; padding: 0; }
  .psheet .heat .aline { display: inline-flex; width: 49%; flex-wrap: nowrap; vertical-align: top; }
  .psheet .heat .alab { min-width: 29mm; flex: none; }
  .psheet .heat .abox { flex-wrap: nowrap; }
  .unit { font-size: 10pt; white-space: nowrap; }
  .keyfig { padding: 0; }
  .kl { margin: 4pt 0 0; font-size: 10pt; }
  .kl li { margin: 1pt 0; }
}
