/* Graph and Uncertainty Practice: a physics lab notebook. Squared-paper cream page, blue-black ink, a red margin rule
   down the left of each experiment (as in a school exercise book), condensed technical headings, and graphs on
   white graph paper with pale blue squares in both themes, as on paper. Error bars and the worst lines are red; the
   best-fit line is ink blue. On paper everything prints black and grey on white. */
:root {
  --bg: #f3f2ec;
  --paper: #fffefa;
  --ink: #17202c;
  --muted: #4a5563;
  --line: #d8d9d0;
  --edge: #737a82;
  --accent: #124f86;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecf5;
  --margin: #c9302c;
  --sq: #e4e3d8;
  --info: #124f86;
  --ok: #17663a;
  --ok-soft: #dcefe0;
  --close: #7a5300;
  --close-soft: #f6ecd2;
  --bad: #a3241d;
  --bad-soft: #f8e0dd;
  --focus: #c9302c;
  --head: "Bahnschrift", "DIN Alternate", "DIN Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, 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: 3px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --paper: #182029;
    --ink: #e6ebf1;
    --muted: #a9b4c1;
    --line: #2e3945;
    --edge: #7d8a98;
    --accent: #8cc4f0;
    --accent-ink: #0b1a28;
    --accent-soft: #1c2c3c;
    --margin: #ff8a7e;
    --sq: #19212b;
    --info: #9ccdf5;
    --ok: #8adca6;
    --ok-soft: #14301f;
    --close: #f0c56b;
    --close-soft: #352a12;
    --bad: #ff9c8f;
    --bad-soft: #3a1c18;
    --focus: #ffb3a8;
  }
}
* { 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); }
/* the exercise-book squared page behind everything (5 mm squares), so the site reads as a lab notebook at a glance */
body { background-image: linear-gradient(var(--sq) 1px, transparent 1px), linear-gradient(90deg, var(--sq) 1px, transparent 1px); background-size: 19px 19px; background-position: -1px -1px; }
.wrap { max-width: 1080px; 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; letter-spacing: 0.005em; }

/* ---------- title ---------- */
.crumbs { margin: 12px 0 0; font-size: 15px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 18px 0 12px; }
.hero h1 { font-size: clamp(27px, 4.3vw, 40px); margin: 0 0 6px; max-width: 24ch; }
.lede { margin: 0; max-width: 64ch; }
.levels { margin: 8px 0 0; font-size: 15.5px; color: var(--muted); }
.levels b { color: var(--ink); font-weight: 600; }
.mark { flex: none; width: 150px; height: 84px; }
.mark .mg { stroke: var(--line); stroke-width: 1; }
.mark .mb { stroke: var(--margin); stroke-width: 2; }
.mark .mp { stroke: var(--ink); stroke-width: 2; }
.mark .ml { stroke: var(--accent); stroke-width: 2.5; }
.mark .mw { stroke: var(--margin); stroke-width: 2; stroke-dasharray: 5 3; }

/* ---------- controls ---------- */
.tool { display: grid; gap: 12px; grid-template-columns: 1fr; align-items: start; }
.setup { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); padding: 8px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: end; }
.boards { grid-column: 1; }
.boards legend, .fld span { font: 600 14px var(--sans); color: var(--muted); margin-bottom: 3px; }
.seg { display: flex; flex-wrap: wrap; gap: 0; }
.seg label { position: relative; flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 14px; border: 1px solid var(--edge); margin-left: -1px; font: 600 16px var(--head); color: var(--ink); white-space: nowrap; background: var(--paper); }
.seg label:first-child span { margin-left: 0; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; position: relative; z-index: 1; }
.ctl { grid-column: 2; display: flex; gap: 10px; align-items: end; }
.fld { display: grid; gap: 2px; min-width: 0; }
.more { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 22px; }
.more details[open] { flex-basis: 100%; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.tdet summary, .rules summary { cursor: pointer; font-weight: 600; min-height: 44px; padding: 10px 0; display: list-item; }
.tsum { font-weight: 400; color: var(--muted); font-size: 15px; }
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px; padding: 0 0 10px; }
.tg { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); cursor: pointer; min-height: 44px; background: var(--paper); font-size: 15.5px; line-height: 1.3; }
.tg input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; min-height: 0; }
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(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.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: 0 0 10px; padding-left: 20px; font-size: 15.5px; line-height: 1.45; max-width: 80ch; }
.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: 27px; margin: 4px 0 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: 20px; }
/* an exercise-book page: red margin rule on the left */
.q { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.qhead { padding: 12px 14px 0; }
.q h3 { margin: 0; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.qn { font: 700 22px var(--head); color: var(--margin); }
.scen { margin: 6px 14px 10px; max-width: 78ch; }
.q > .tw { margin: 0 14px; }
.gtools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 6px; }
.figview { padding: 0 14px; min-width: 0; }
.qparts { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 12px 14px 14px; }
.zoom { display: none; }

/* ---------- graph paper and tables: white like paper in both themes ---------- */
svg.graph { display: block; width: 100%; max-width: 640px; height: auto; background: #fff; }
.gmin { stroke: #cfe1ec; stroke-width: 0.18; }
.gmaj { stroke: #8eb5cc; stroke-width: 0.32; }
.ax { stroke: #17202c; stroke-width: 0.45; }
.tk { fill: #17202c; font: 5px "Helvetica Neue", Arial, sans-serif; }
.al { fill: #17202c; font: 600 5.2px "Helvetica Neue", Arial, sans-serif; }
.pt { stroke: #17202c; stroke-width: 0.5; fill: none; }
.eb line { stroke: #c9302c; stroke-width: 0.4; }
.lb { stroke: #124f86; stroke-width: 0.55; }
.ls { stroke: #c9302c; stroke-width: 0.45; stroke-dasharray: 2.2 1.2; }
.lh { stroke: #1d6b45; stroke-width: 0.5; stroke-dasharray: 0.6 0.9; stroke-linecap: round; }
.tri { fill: none; stroke: #124f86; stroke-width: 0.35; stroke-dasharray: 1 1; }
.anom { fill: none; stroke: #c9302c; stroke-width: 0.45; }
.legend { list-style: none; margin: 6px 0 0; padding: 6px 10px; background: #fff; color: #17202c; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; max-width: 640px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 34px; height: 9px; flex: none; }
.legend .lb { stroke-width: 1.2; } .legend .ls { stroke-width: 1.1; stroke-dasharray: 3 2; } .legend .lh { stroke-width: 1.3; stroke-dasharray: 0.4 1.6; }
.legend .tri { stroke-width: 0.9; stroke-dasharray: 2 1.5; } .legend .anom { stroke-width: 0.9; }
.tw { max-width: 100%; overflow-x: auto; }
table.data { border-collapse: collapse; background: #fff; color: #17202c; font-size: 15.5px; font-variant-numeric: tabular-nums; border: 1.5px solid #17202c; }
table.data th, table.data td { border: 1px solid #b8c1c9; padding: 5px 10px; text-align: center; white-space: nowrap; }
table.data thead th { background: #eef3f7; font-size: 14.5px; font-weight: 600; white-space: normal; min-width: 3.5em; }
table.data tbody th { font-weight: 600; }
td.gap span { display: inline-block; color: #124f86; font-weight: 700; }
td.gap { background: #eef5fb; }
td.blank { background: #fbfbf6; min-width: 5em; }
td.fill { color: #a3241d; font-weight: 700; background: #fcf0ee; }

/* 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; flex-wrap: wrap; }
.ain input { width: 9.5em; max-width: 100%; font-variant-numeric: tabular-nums; }
.ain .unit { color: var(--muted); }
.opts { display: grid; gap: 4px; }
.opt { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); cursor: pointer; }
.opt input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; min-height: 0; }
.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); }
.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 { border-top: 1px solid var(--line); padding-top: 4px; }
details.work summary { cursor: pointer; color: var(--info); min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.keyfig { display: grid; gap: 8px; margin: 4px 0 8px; }
details.work .figview { padding: 0; }
.ans { margin: 10px 0 2px; }
ul.steps { margin: 0 0 4px; padding-left: 20px; color: var(--muted); font-size: 15.5px; overflow-wrap: anywhere; }
.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(--accent-soft); 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(160%); 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; pointer-events: none; }
.toast.on { transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- content ---------- */
.content { max-width: 72ch; padding: 26px 0 20px; }
.content h2 { font-size: 27px; margin: 26px 0 6px; }
table.conv { border-collapse: collapse; font-size: 15.5px; background: var(--paper); width: 100%; }
table.conv th, table.conv td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; text-align: left; vertical-align: top; }
table.conv thead th { font-size: 14.5px; color: var(--muted); }
.small { font-size: 15.5px; color: var(--muted); }
.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: 1fr 1fr; gap: 12px 22px; }
  .qparts .qfoot, .qparts details.work, .qparts .part.wide { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .setup { grid-template-columns: minmax(0, 1fr); }
  .ctl { grid-column: 1; }
  .ctl .fld { flex: 1; }
  .mark { display: none; }
}
@media (max-width: 640px) {
  .zoom { display: inline-block; }
  .zoomed .figview { overflow-x: auto; }
  .zoomed svg.graph { width: 640px; max-width: none; }
}
@media (max-width: 480px) {
  .hero { padding: 10px 0 8px; }
  .hero h1 { font-size: 26px; }
  .lede { font-size: 15.5px; line-height: 1.45; }
  .seg span { padding: 6px 9px; font-size: 15px; }
  .q h3 { font-size: 20px; }
  .qhead { padding: 10px 10px 0; }
  .scen { margin: 6px 10px 8px; font-size: 16px; }
  .q > .tw { margin: 0 10px; }
  .gtools { padding: 10px 10px 6px; }
  .figview { padding: 0 10px; }
  .qparts { padding: 10px 10px 12px; }
  table.data { font-size: 14px; }
  table.data th, table.data td { padding: 4px 6px; }
  table.data thead th { font-size: 13px; }
  .legend { font-size: 14px; }
}
@media (max-width: 360px) {
  table.data th, table.data td { padding: 3px 4px; }
  table.data { font-size: 13px; }
  .seg span { padding: 6px 7px; font-size: 14.5px; }
}

/* ---------- print ---------- */
@media print {
  :root { --ink: #000; --muted: #333; --line: #999; --paper: #fff; --edge: #555; }
  @page { margin: 11mm 12mm; }
  body { background: #fff; background-image: none; color: #000; font: 10.5pt/1.36 var(--sans); }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  svg, table.data, td.gap, td.fill, thead th, .legend { 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: 4pt !important; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 10pt; border-bottom: 2pt solid #000; margin-bottom: 4pt; }
  .ph h2 { font: 700 17pt 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: 8pt 0 0; font-size: 8.4pt; line-height: 1.3; border: 0.8pt solid #000; padding: 3pt 6pt; break-inside: avoid; }
  .pround ul { margin: 0; padding-left: 11pt; font-size: 8.6pt; line-height: 1.3; max-width: none; }
  .pround li { margin: 0 0 1pt; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li + li, .pk > li + li { break-before: page; page-break-before: always; }
  .pq h3, .pk h3 { font: 700 12.5pt var(--head); margin: 4pt 0 2pt; }
  .pblock, .pkhead { break-inside: avoid; }
  .pscen { margin: 0 0 4pt; font-size: 10pt; }
  .tw { overflow: visible; }
  table.data { font-size: 9.4pt; border-width: 1pt; }
  table.data th, table.data td { padding: 1.5pt 6pt; border-color: #777; }
  table.data thead th { font-size: 8.8pt; background: #eee; }
  td.gap { background: #fff; } td.gap span { color: #000; }
  td.blank { background: #fff; min-width: 18mm; }
  td.fill { color: #000; background: #e4e4e4; }
  /* the graph prints true size: 14 cm by 12 cm of 2 mm squares with bold 1 cm lines */
  .pfig, .pkfig { break-inside: avoid; margin: 4pt 0 2pt; }
  .pfig svg.graph { width: 174mm; max-width: none; }
  .pkfig svg.graph { width: 112mm; max-width: none; } /* the key graph need not be true size; 112 mm keeps most keys on one page */
  .tk { font-size: 3.3px; }
  .al { font-size: 3.9px; }
  .gmin { stroke: #9fb8c6; stroke-width: 0.12; }
  .gmaj { stroke: #4f6f82; stroke-width: 0.28; }
  .g-blank .gmin { stroke: #a9bfcc; }
  .eb line, .anom { stroke: #000; }
  .lb, .tri { stroke: #000; }
  .ls { stroke: #333; }
  .lh { stroke: #333; }
  .legend { font-size: 8.6pt; padding: 0; gap: 2pt 10pt; max-width: none; }
  /* the answers start their own page, named, so page 1 is the table and the true-size grid and page 2 never
     starts with an anonymous half-list (lessons §6: continuation pages carry the subject's name) */
  .pans { break-before: page; page-break-before: always; }
  /* page 1 of each experiment: text, table, grid, and a ruled working box that takes whatever room is left on the
     shorter Letter page (A4 just has a little more below it) */
  .ppage1 { display: flex; flex-direction: column; height: 244mm; }
  .ppage1.first { height: 226mm; }
  .pbox { flex: 1 1 auto; min-height: 0; overflow: hidden; margin: 3pt 0 0; border: 0.8pt solid #000; padding: 2pt 5pt 0; font-size: 9pt; }
  .pbox .rule { height: 8mm; border-bottom: 0.6pt solid #888; }
  .pans .pcont { margin-top: 0; }
  .pwork { margin: 0 0 6pt; font-size: 9pt; color: #333; }
  .pparts { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8mm; row-gap: 2pt; font-size: 9.6pt; }
  .pparts .pp { break-inside: avoid; }
  .pparts .pp p { margin: 0; }
  .pparts .pp.wide { grid-column: 1 / -1; }
  .pline { margin: 30pt 0 6pt !important; white-space: nowrap; } /* room for working above each answer line */
  .uline { display: inline-block; width: 30mm; border-bottom: 0.8pt solid #000; }
  .popts { display: grid; gap: 1pt; margin: 2pt 0 0 !important; }
  .pkey { break-before: page; page-break-before: always; }
  .psheet + .psheet, .pkey + .pkey { break-before: page; page-break-before: always; }
  table.pkt { width: 100%; border-collapse: collapse; font-size: 8.4pt; table-layout: fixed; margin-top: 3pt; }
  table.pkt tr { break-inside: avoid; }
  table.pkt td { border-top: 0.5pt solid #bbb; padding: 1pt 4pt; vertical-align: top; line-height: 1.25; }
  table.pkt td.pkq { width: 27%; }
  table.pkt td.pka { width: 27%; font-weight: 700; }
}
