:root {
  --bg: #f5f0ea;
  --paper: #fffdfa;
  --ink: #26181d;
  --muted: #66545a;
  --line: #e2d5cf;
  --accent: #a12d4b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3e7;
  --focus: #1f5fd1;
  --good: #1d6b3c;
  --good-soft: #e3f2e7;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --chart-paper: #ffffff;
  --grid: #a9c2bd;
  --grid-strong: #44716b;
  --chart-ink: #20262b;
  --pen: #1f47b8;
  --radius: 6px;
  --head: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171013;
    --paper: #21181c;
    --ink: #f1e8ea;
    --muted: #c3b0b6;
    --line: #3b2d33;
    --accent: #e0778f;
    --accent-ink: #1d0f14;
    --accent-soft: #3a2029;
    --focus: #8fb4ff;
    --good: #7fd3a0;
    --good-soft: #17301f;
    --bad: #ff9a8f;
    --bad-soft: #3b1a18;
    --chart-paper: #f7f3ef;
  }
}
:root[data-theme="dark"] {
  --bg: #171013; --paper: #21181c; --ink: #f1e8ea; --muted: #c3b0b6; --line: #3b2d33; --accent: #e0778f; --accent-ink: #1d0f14;
  --accent-soft: #3a2029; --focus: #8fb4ff; --good: #7fd3a0; --good-soft: #17301f; --bad: #ff9a8f; --bad-soft: #3b1a18; --chart-paper: #f7f3ef;
}
* { 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(--body); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-family: var(--head); font-stretch: condensed; line-height: 1.15; letter-spacing: 0.005em; }
h1 { font-size: clamp(1.9rem, 4.6vw, 2.75rem); margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 1.5rem; margin: 1.6em 0 0.4em; }
h3 { font-size: 1.15rem; margin: 1.2em 0 0.3em; }

/* hero: a strip like the top of a ward chart */
.hero { padding: 22px 0 14px; border-bottom: 2px solid var(--ink); margin-bottom: 14px; }
.hero .lede { margin: 0; max-width: 62ch; color: var(--ink); }
.hero .safety { margin: 8px 0 0; font-size: 0.93rem; color: var(--muted); max-width: 70ch; }
.fmt-switch { margin: 0 0 6px; font-size: 0.95rem; }
.fmt-switch a, .fmt-switch b { margin-right: 14px; }
.fmt-switch b { color: var(--ink); border-bottom: 3px solid var(--accent); }

/* setup row */
.setup { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0 0 10px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; font-size: 0.95rem; border: 0; background: var(--paper); color: var(--ink); padding: 9px 13px; min-height: 44px; cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.btn { font: inherit; font-size: 0.97rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 16px; border-radius: var(--radius); border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { min-height: 36px; padding: 5px 11px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link { font: inherit; background: none; border: 0; padding: 8px 2px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 44px; }
.qdrop { position: relative; }
.qdrop summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 0.3em; padding: 0 4px; list-style: none; text-decoration: underline; text-underline-offset: 2px; color: var(--accent); }
.qdrop summary::-webkit-details-marker { display: none; }
.qdrop fieldset { border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); margin: 4px 0 0; padding: 8px 12px; display: grid; gap: 2px; min-width: 260px; }
.qc { display: flex; gap: 8px; align-items: center; min-height: 36px; }
.qc input { width: 20px; height: 20px; }
.setcode { font-family: var(--head); font-stretch: condensed; font-size: 1.05rem; margin-left: auto; }
.setcode b { letter-spacing: 0.08em; }

.note { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 8px 12px; margin: 8px 0; border-radius: 0 var(--radius) var(--radius) 0; }
.note.info { background: var(--paper); border-left-color: var(--muted); }

/* the work: notes beside the chart on wide screens */
.work { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) {
  .work.has-notes { grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); align-items: start; }
}
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; }
.panel-h h2 { margin: 0; font-size: 1.3rem; }
.notes-box details > summary { cursor: pointer; font-family: var(--head); font-stretch: condensed; font-size: 1.3rem; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.notes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.notes li { display: grid; grid-template-columns: 3.4em 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; line-height: 1.45; }
.notes li p { margin: 0; }
.notes time { font-variant-numeric: tabular-nums; font-weight: 700; }
.notes li.day { display: block; padding: 10px 0 4px; border-bottom: 0; }
.notes li.day span { font-family: var(--head); font-stretch: condensed; font-weight: 700; font-size: 1.02rem; }

/* chart */
.chartbox { background: var(--chart-paper); color: #20262b; border: 1px solid var(--line); border-radius: var(--radius); }
.chartview { overflow-x: auto; overscroll-behavior-x: contain; }
.chartview svg { display: block; width: 100%; height: auto; min-width: 640px; }
.chartview.zoom svg { min-width: 1150px; }
.chartview .lcgchart { min-width: 860px; }
.chartview.zoom .lcgchart { min-width: 1500px; }
@media (max-width: 760px) {
  .chartview svg { min-width: 820px; }
  .chartview .lcgchart { min-width: 1100px; }
}
/* one note at a time beside the chart, for phones and tablets where the notes are not beside it */
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; align-items: start; padding: 8px; border-bottom: 1px solid #e6dedb; background: #fff8e6; color: #26181d; border-radius: var(--radius) var(--radius) 0 0; }
.stepper p { margin: 0; font-size: 0.93rem; line-height: 1.4; min-height: 2.8em; }
.stepper time { font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }
.stepper .day { display: block; font-weight: 700; font-size: 0.85rem; }
.stepper button { font: inherit; font-size: 1.2rem; min-height: 44px; border: 1.5px solid #8b7d82; background: #fff; color: #26181d; border-radius: var(--radius); cursor: pointer; }
.stepper button:disabled { opacity: 0.4; cursor: default; }
.stepper small { display: block; color: #66545a; font-size: 0.8rem; }
@media (min-width: 1000px) { .stepper { display: none; } }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid #e6dedb; background: #faf7f4; border-radius: var(--radius) var(--radius) 0 0; color: #26181d; }
.tools .tool { font: inherit; font-size: 0.9rem; min-height: 40px; padding: 4px 10px; border: 1.5px solid #8b7d82; background: #fff; color: #26181d; border-radius: var(--radius); cursor: pointer; }
.tools .tool[aria-pressed="true"] { border-color: #1f47b8; background: #1f47b8; color: #fff; }
.tools .shade { display: inline-flex; gap: 4px; align-items: center; font-size: 0.85rem; }
.tools .sep { width: 1px; height: 28px; background: #d9cfcb; margin: 0 2px; }
.tools .btn { border-color: #8b7d82; background: #fff; color: #26181d; }
.plotmsg { min-height: 1.4em; margin: 0; padding: 6px 10px; font-size: 0.92rem; color: #26181d; }
.plotres { padding: 0 10px 10px; color: #26181d; font-size: 0.93rem; }
.plotres ul { margin: 4px 0; padding-left: 18px; }
.chartfoot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-top: 1px solid #e6dedb; }
.chartfoot .btn { border-color: #8b7d82; background: #fff; color: #26181d; }
.birthline { margin: 0; padding: 4px 10px 8px; font-size: 0.92rem; color: #26181d; }

/* svg chart styling */
.chart text { font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif; fill: #20262b; }
.chart .lab { font-size: 2.45px; }
.chart .lab.small { font-size: 2.05px; }
.chart .lab.b { font-weight: 700; }
.chart .lab.sec { font-size: 2.2px; font-weight: 700; letter-spacing: 0.05px; }
.chart .ttl { font-size: 3.3px; font-weight: 700; }
.chart .ax { font-size: 2.2px; fill: #3d4a50; }
.chart .gl { stroke: #a9c2bd; stroke-width: 0.18; }
.chart .gl.faint { stroke: #cfdedb; stroke-width: 0.14; }
.chart .gl.dot { stroke: #c4d6d2; stroke-width: 0.14; stroke-dasharray: 0.5 0.5; }
.chart .gl.strong { stroke: #2f5f59; stroke-width: 0.45; }
.chart .cell { fill: none; stroke: #7da39c; stroke-width: 0.25; }
.chart .alertcol { fill: #f4f1ee; }
.chart .shade { fill: #d6d2cf; stroke: #7da39c; stroke-width: 0.25; }
.chart .fld { stroke: #7a8a8f; stroke-width: 0.2; }
.chart .brk { stroke: #3d4a50; stroke-width: 0.3; }
.chart .alert-line, .chart .action-line { stroke: #20262b; stroke-width: 0.6; }
.chart .line-lab { font-size: 2.6px; font-weight: 700; font-style: italic; }
.chart .pat-ink { fill: #1f47b8; }
.chart .pat-line { stroke: #1f47b8; stroke-width: 0.35; }
.chart .pat-solid { fill: #1f47b8; }
.chart .ink, .chart .hv { fill: #1f47b8; font-size: 2.6px; font-weight: 700; }
.chart .ink.tsmall { font-size: 2.15px; }
.chart .lcg-v.tsmall { font-size: 2.15px; }
.chart .ink-line { fill: none; stroke: #1f47b8; stroke-width: 0.35; }
.chart .ink-line.thin { stroke-width: 0.25; }
.chart .ink-dot { fill: #1f47b8; }
.chart .ink-x { stroke: #1f47b8; stroke-width: 0.5; stroke-linecap: round; }
.chart .ink-o { fill: #fff; stroke: #1f47b8; stroke-width: 0.45; }
.chart .ink-bp { fill: none; stroke: #1f47b8; stroke-width: 0.35; stroke-linejoin: round; }
.chart .circle-alert { fill: none; stroke: #d0271d; stroke-width: 0.4; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .stu-x { stroke: #1f47b8; stroke-width: 0.55; stroke-linecap: round; }
.chart .stu-o { fill: #fff; stroke: #1f47b8; stroke-width: 0.5; }
.chart .stu-dot { fill: #1f47b8; }
.chart .stu-line { fill: none; stroke: #1f47b8; stroke-width: 0.3; opacity: 0.75; }
.chart .stu-t { fill: #1f47b8; font-size: 2.7px; font-weight: 700; }
.chart .stu.bad .stu-x, .chart .stu-o.bad { stroke: #d0271d; }
.chart .stu-dot.bad, .chart .stu-t.bad { fill: #d0271d; }
.chart rect.stu.bad { stroke: #d0271d; stroke-width: 0.4; }
.chart .stu.good .stu-x, .chart .stu-o.good { stroke: #15803d; }
.chart .stu-dot.good, .chart .stu-t.good { fill: #15803d; }
.chart .miss { fill: none; stroke: #d0271d; stroke-width: 0.3; stroke-dasharray: 0.8 0.6; }

/* questions */
.qs { margin-top: 22px; }
.qs-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.qs-head h2 { margin: 0; }
.score { margin: 0; color: var(--muted); }
.qlist { list-style: none; margin: 0; padding: 0; }
.q { border-bottom: 1px solid var(--line); padding: 14px 0; }
.qt { display: flex; gap: 10px; margin: 0 0 8px; font-weight: 600; }
.qt .num { flex: none; width: 1.9em; height: 1.9em; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.qbody { padding-left: calc(1.9em + 10px); }
.q.is-right .num { background: var(--good); border-color: var(--good); color: var(--paper); }
.q.is-wrong .num, .q.is-unread .num { background: var(--bad); border-color: var(--bad); color: var(--paper); }
.q.is-close .num { border-color: var(--good); }
.arow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.arow input, .arow select { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 10px; border: 1.5px solid #8b7d82; border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.arow input { width: 8.5em; }
.arow .unit { color: var(--muted); }
.radios { display: grid; gap: 4px; }
.radios label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; min-height: 44px; }
.radios input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid #8b7d82; border-radius: 999px; background: var(--paper); cursor: pointer; min-height: 40px; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.chips label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chips input { width: 18px; height: 18px; margin: 0; }
.chips.list { display: grid; gap: 4px; }
.chips.list label { border-radius: var(--radius); }
.fb { margin: 8px 0 0; padding: 6px 10px; border-radius: var(--radius); }
.fb.right { background: var(--good-soft); color: var(--good); }
.fb.close { background: var(--good-soft); color: var(--ink); }
.fb.wrong, .fb.unread { background: var(--bad-soft); color: var(--bad); }
details.workd { margin-top: 8px; }
details.workd > summary { cursor: pointer; color: var(--accent); min-height: 40px; display: inline-flex; align-items: center; }
.ans { margin: 4px 0; }
.steps { margin: 4px 0 0; padding-left: 20px; }
.steps li { margin: 3px 0; }
.qs-foot { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 12px 0; }
.ask { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--bad-soft); padding: 6px 10px; border-radius: var(--radius); }

/* print and share */
.share { margin: 26px 0 8px; padding: 14px 0; border-top: 2px solid var(--ink); }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.print-row label { display: grid; gap: 2px; font-size: 0.92rem; color: var(--muted); }
.print-row select { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 8px; border-radius: var(--radius); border: 1.5px solid #8b7d82; background: var(--paper); color: var(--ink); }
.hint { color: var(--muted); font-size: 0.93rem; margin: 6px 0; }
.share-out label { display: grid; gap: 4px; font-size: 0.92rem; }
.share-out input { font: inherit; font-size: 16px; padding: 8px; border: 1.5px solid #8b7d82; border-radius: var(--radius); width: 100%; background: var(--paper); color: var(--ink); }
.recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 4px 0; }
.recent small { display: block; color: var(--muted); }
.code { font-family: var(--head); font-stretch: condensed; letter-spacing: 0.06em; }

/* content */
.content { max-width: 74ch; margin: 30px 0 10px; }
.content p, .content li { margin: 0.5em 0; }
.content table { border-collapse: collapse; margin: 8px 0; font-size: 0.95rem; }
.content th, .content td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0 0 12px; }
.sources { font-size: 0.92rem; color: var(--muted); }

footer { margin-top: 30px; border-top: 1px solid var(--line); padding: 14px 0 30px; font-size: 0.92rem; color: var(--muted); }
.indep { margin: 0 0 8px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-more a, .sb-credit a { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(150%); max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); transition: transform 0.2s; z-index: 30; font-size: 0.95rem; }
.toast.on { transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

.print-root { display: none; }
@media (max-width: 520px) {
  .qbody { padding-left: 0; }
  .setcode { margin-left: 0; width: 100%; }
  .seg button { padding: 9px 10px; }
}

/* ---------- print ---------- */
@page { margin: 10mm; }
@page lcg { size: landscape; margin: 8mm; }
@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
  .print-root * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .psheet { break-after: page; }
  .psheet:last-child { break-after: auto; }
  .pchart.lcg { page: lcg; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5pt solid #000; margin: 0 0 3mm; padding-bottom: 1mm; }
  .ph h2 { margin: 0; font-size: 14pt; font-family: Arial, sans-serif; }
  .ph p { margin: 0; font-size: 9.5pt; }
  .pmeta { display: flex; gap: 8mm; margin: 0 0 3mm; font-size: 10pt; }
  .blank { display: inline-block; border-bottom: 0.8pt solid #000; height: 1em; vertical-align: bottom; }
  .w-name { width: 55mm; } .w-date { width: 30mm; } .w-score { width: 12mm; } .w-ans { width: 40mm; } .w-fill { width: 100%; }
  .pnotes { list-style: none; margin: 0; padding: 0; columns: 1; }
  .pnotes li { display: grid; grid-template-columns: 12mm 1fr; gap: 2mm; padding: 1.2mm 0; border-bottom: 0.4pt solid #bbb; font-size: 9.6pt; line-height: 1.32; break-inside: avoid; }
  .pnotes li.day { display: block; border: 0; font-weight: 700; padding-top: 2mm; break-after: avoid; }
  .pnotes time { font-weight: 700; }
  .pnotes p { margin: 0; }
  .psheet h3 { break-after: avoid; page-break-after: avoid; } /* never a lone Questions heading */
  .pq { margin: 3mm 0 0; padding-left: 6mm; }
  .pq > li { margin: 0 0 3mm; break-inside: avoid; }
  .pq p { margin: 0 0 1mm; }
  .popts { margin: 0; padding-left: 5mm; list-style: lower-alpha; }
  .popts li { margin: 0.4mm 0; }
  .ptimes { columns: 6; margin: 1mm 0 0; padding: 0; list-style: none; font-size: 9pt; }
  .ptimes li::before { content: "☐ "; }
  .pans { margin: 1.5mm 0 0; }
  .pchart { break-before: page; break-inside: avoid; }
  .pchart .chart { display: block; width: 100%; height: auto; }
  .pchart.pg .chart { max-height: 236mm; }
  .pchart.lcg .chart { max-height: 182mm; }
  .pchart .chart text { fill: #000; }
  .pchart .chart .gl { stroke: #8fa9a4; }
  .pchart .chart .gl.strong { stroke: #1d3d39; stroke-width: 0.5; } /* the 100 and 180 lines stay dark on paper */
  .pchart .ph { margin-bottom: 1.5mm; break-after: avoid; }
  .pkey .pk { padding-left: 6mm; margin: 0; }
  .pkey .pk > li { margin: 0 0 2mm; break-inside: avoid; }
  .pkey .pka { font-weight: 700; margin: 0.5mm 0; }
  .pkey .pks { margin: 0.5mm 0 0; padding-left: 5mm; font-size: 9.4pt; line-height: 1.3; }
  .pkey .pkq { margin: 0; }
  .pbirth { font-size: 9.5pt; margin: 1mm 0 0; }
  .psafe { font-size: 8.5pt; color: #333; margin: 0 0 2.5mm; } /* under the header, so it is never alone on a page */
}
.notes-box summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--accent); }
.notes-box details[open] > summary::before { content: "▾"; }
/* the Labour Care Guide is wide: give it the full width, with the notes above and one note at a time over it */
@media (min-width: 1000px) {
  body[data-fmt="lcg"] .work.has-notes { grid-template-columns: minmax(0, 1fr); }
  body[data-fmt="lcg"] .stepper { display: grid; }
  body[data-fmt="lcg"] .notes-box .notes { columns: 2; column-gap: 28px; }
  body[data-fmt="lcg"] .notes-box .notes li { break-inside: avoid; }
}
