/* Food safety plan builder (13 Oct 2026). All styles live here (no inline styles) so the page can run under a strict
   Content-Security-Policy (see /_headers). Screen layout first, then the print stylesheet that makes the PDF. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #2b2f36;
  --muted: #5b6270;
  --border: #e4e6eb;
  --soft: #f7f8fa;
  --brand: #B71C1C;
  --brand-soft: #fdecea;
  --green: #2E7D32;
  --green-soft: #e8f5e9;
  --amber: #8a5a00;
  --amber-soft: #fff4e5;
  --amber-border: #ffc98a;
  --blue: #1565C0;
  --blue-soft: #e8f0fb;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  font-size: 16px;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 32px 16px 120px; }
.wrap > header { margin-bottom: 22px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.02em; }
.lede { color: #3a3f48; font-size: 1.05rem; margin: 0 0 6px; }
.updated { color: var(--muted); font-size: 0.9rem; margin: 0; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 34px 0 12px 2px; letter-spacing: -0.01em; }
h3 { font-size: 1.08rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
section { margin-bottom: 22px; }
a { color: var(--brand); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px;
  margin-bottom: 14px;
}
.card > :last-child { margin-bottom: 0; }
.card ul, .card ol { margin: 4px 0 12px; padding-left: 20px; }
.card li { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px;
  font: inherit; font-weight: 600; font-size: 0.98rem; cursor: pointer;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:focus-visible, .seg input:focus-visible + span, .tick input:focus-visible + span,
input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #1565C0; outline-offset: 2px;
}
.btn.secondary { background: #fff; color: var(--brand); }
.btn.quiet { background: #fff; color: var(--ink); border-color: #c9ccd3; }
.btn.small-btn { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* ---------- privacy / notes ---------- */
.private { border-left: 4px solid var(--green); }
.private strong { color: var(--green); }
.note {
  background: var(--amber-soft); border: 1px solid var(--amber-border); border-radius: 10px;
  padding: 12px 14px; margin: 12px 0; font-size: 0.94rem;
}
.note > :last-child { margin-bottom: 0; }
.stop { border-left: 4px solid var(--brand); }
.stop h3 { color: var(--brand); }
.error { color: var(--brand); font-weight: 600; }

/* ---------- gates ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; padding: 0; }
.choice-list { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer;
}
.choice input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.step-num { display: inline-block; min-width: 26px; height: 26px; border-radius: 13px; background: var(--brand);
  color: #fff; font-size: 0.85rem; font-weight: 700; text-align: center; line-height: 26px; margin-right: 8px; }

/* ---------- builder layout ---------- */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.toc a { font-size: 0.9rem; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border);
  color: var(--ink); text-decoration: none; font-weight: 600; }
.toc a:hover { border-color: var(--brand); }
.section-intro { color: #3a3f48; margin: -4px 0 14px 2px; }

details.method { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
details.method > summary {
  list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
  justify-content: space-between; font-weight: 700; font-size: 1.05rem;
}
details.method > summary::-webkit-details-marker { display: none; }
details.method > summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted); transform: rotate(45deg); flex: none; margin-left: 4px; }
details.method[open] > summary::after { transform: rotate(-135deg); }
details.method[open] > summary { border-bottom: 1px solid var(--border); }
.method-title { flex: 1; }
.badge { font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: #eef0f3; color: var(--muted); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.part { background: var(--amber-soft); color: var(--amber); }
.badge.na { background: var(--blue-soft); color: var(--blue); }
.method-body { padding: 16px 18px 18px; }
.method-intro { color: #3a3f48; }

.na-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px;
  background: var(--soft); border: 1px dashed #c9ccd3; margin: 0 0 16px; cursor: pointer; font-size: 0.95rem; }
.na-box input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--blue); }

.fsa { background: var(--soft); border-radius: 10px; padding: 12px 14px; margin: 14px 0 10px; font-size: 0.94rem; color: #3a3f48; }
.fsa .lbl { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 2px; }
.fsa p { margin: 0 0 8px; }
.fsa p:last-child { margin-bottom: 0; }
.fsa ul { margin: 0; padding-left: 18px; }
.sub-head { font-weight: 700; margin: 18px 0 6px; }
.say { margin: 10px 0; color: #3a3f48; font-size: 0.95rem; }
.say ul { padding-left: 20px; margin: 6px 0; }
.think { border-left: 4px solid var(--amber-border); background: var(--amber-soft); border-radius: 8px; padding: 10px 12px;
  margin: 12px 0; font-size: 0.93rem; }
.think .lbl, .tag-law .lbl, .tag-guide .lbl { font-weight: 700; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; display: block; }
.tag-law { border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 0.94rem; }
.tag-law cite { display: block; font-style: normal; font-size: 0.84rem; color: var(--muted); margin-top: 4px; }
.tag-guide { border-left: 4px solid var(--blue); background: var(--blue-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 0.94rem; }

/* ---------- questions ---------- */
.q { margin: 10px 0 16px; }
.q-label { display: block; font-weight: 600; margin-bottom: 6px; }
.q-label .cr { font-weight: 500; font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
textarea, input[type="text"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
  border: 1px solid #c9ccd3; border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
input[type="date"] { max-width: 240px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.seg label { cursor: pointer; }
.seg input, .tick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: inline-block; min-width: 72px; text-align: center; padding: 9px 16px; border-radius: 999px;
  border: 1px solid #c9ccd3; background: #fff; font-weight: 600; font-size: 0.95rem;
}
.seg input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.seg .clear { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline;
  cursor: pointer; padding: 9px 4px; }
.alt { margin-top: 10px; }
.alt .q-label { font-weight: 500; }
.ticks { display: grid; gap: 8px; }
.tick { display: block; cursor: pointer; }
.tick span {
  display: block; position: relative; padding: 10px 12px 10px 42px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; font-size: 0.95rem;
}
.tick span::before {
  content: ""; position: absolute; left: 12px; top: 11px; width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid #9aa0aa; background: #fff;
}
.tick input:checked + span { border-color: var(--green); background: var(--green-soft); }
.tick input:checked + span::before { background: var(--green); border-color: var(--green); }
.tick input:checked + span::after {
  content: ""; position: absolute; left: 19px; top: 14px; width: 6px; height: 11px;
  border-right: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(45deg);
}

/* ---------- row tables ---------- */
.rows-wrap { margin: 10px 0 16px; }
.row-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--soft); }
.row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-grid .long { grid-column: 1 / -1; }
.row-grid label { font-size: 0.85rem; font-weight: 600; display: block; margin-bottom: 4px; }
.row-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 560px) { .row-grid { grid-template-columns: 1fr; } }

.wrongs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.wrongs > div { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: 0.92rem; }
.wrongs h4 { margin: 0 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.wrongs ul { margin: 0; padding-left: 18px; }
.wrongs .diary { margin: 8px 0 0; font-weight: 600; }
@media (max-width: 640px) { .wrongs { grid-template-columns: 1fr; } }

/* ---------- sticky action bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(0,0,0,0.06);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.bar .in { max-width: 820px; margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.bar .progress { font-size: 0.9rem; color: var(--muted); }
.bar .progress strong { color: var(--ink); }
.bar .btn-row { margin: 0; }
.unsaved { color: var(--amber); font-weight: 600; }

.next { border-left: 4px solid var(--brand); }
.src-list { font-size: 0.88rem; }
.src-list a { overflow-wrap: anywhere; }
footer.site { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 40px; line-height: 1.7; }

/* The print copy is built by plan.js into #print-root; it is hidden on screen. */
#print-root { display: none; }

/* =====================================================================
   PRINT: only #print-root is printed. Plain black on white, A4.
   ===================================================================== */
@media print {
  @page { size: A4; margin: 14mm 14mm 12mm; }
  html, body { background: #fff !important; }
  body { font-size: 10.5pt; line-height: 1.4; color: #000; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  a { color: #000; text-decoration: none; }

  .pf { width: 100%; border-collapse: collapse; }
  .pf > thead > tr > td, .pf > tfoot > tr > td { padding: 0; }
  .pf > tfoot .stamp { border-top: 0.5pt solid #777; padding-top: 3pt; margin-top: 6pt; font-size: 7.5pt; color: #333; }
  .pf > thead .head-space { height: 2mm; }

  .p-cover h1 { font-size: 24pt; margin: 18mm 0 4mm; }
  .p-cover .p-biz { font-size: 15pt; font-weight: 700; margin: 0 0 6mm; }
  .p-kv { width: 100%; border-collapse: collapse; margin: 0 0 6mm; }
  .p-kv th { text-align: left; width: 38%; font-weight: 600; vertical-align: top; padding: 4pt 6pt 4pt 0; border-bottom: 0.5pt solid #bbb; }
  .p-kv td { vertical-align: top; padding: 4pt 0; border-bottom: 0.5pt solid #bbb; white-space: pre-wrap; }
  .p-box { border: 0.75pt solid #000; padding: 6pt 8pt; margin: 0 0 4mm; font-size: 9pt; }
  .p-box p { margin: 0 0 4pt; }
  .p-break { break-before: page; page-break-before: always; }
  .p-section-title { font-size: 17pt; margin: 0 0 2mm; border-bottom: 1.5pt solid #000; padding-bottom: 2pt; }
  .p-section-intro { font-size: 9.5pt; margin: 0 0 4mm; }
  .p-method { margin: 0 0 6mm; }
  .p-method h3 { font-size: 13pt; margin: 4mm 0 1mm; break-after: avoid; page-break-after: avoid; }
  .p-method .p-intro { font-size: 9pt; font-style: italic; margin: 0 0 2mm; }
  .p-na { border: 0.75pt solid #000; padding: 4pt 6pt; font-weight: 600; }
  .p-point { font-size: 8.5pt; color: #222; margin: 2mm 0 1mm; padding-left: 5pt; border-left: 1pt solid #999; break-inside: avoid; }
  .p-point b { font-weight: 700; }
  .p-q { margin: 1.5mm 0 2mm; break-inside: avoid; page-break-inside: avoid; }
  .p-q .p-qq { font-weight: 700; font-size: 9.5pt; }
  .p-q .p-qa { white-space: pre-wrap; padding: 1pt 0 0 8pt; }
  .p-missing { font-weight: 700; text-decoration: underline; }
  .p-label { font-weight: 700; font-size: 7.5pt; letter-spacing: 0.05em; text-transform: uppercase; }
  .p-law, .p-guide, .p-think { font-size: 8.5pt; border: 0.5pt solid #555; padding: 3pt 6pt; margin: 2mm 0; break-inside: avoid; }
  .p-law { border-left: 3pt solid #000; }
  .p-list { font-size: 8.5pt; margin: 1mm 0 2mm; padding-left: 14pt; }
  .p-wrong { font-size: 8.5pt; margin: 2mm 0 0; break-inside: avoid; }
  .p-wrong h4 { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.05em; margin: 1mm 0 0.5mm; }
  .p-wrong ul { margin: 0; padding-left: 14pt; }
  .p-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; margin: 1mm 0 3mm; }
  .p-table th, .p-table td { border: 0.5pt solid #555; padding: 3pt 4pt; text-align: left; vertical-align: top; white-space: pre-wrap; }
  .p-table th { background: #eee; }
  .p-table td.blank { height: 9mm; }
  .p-table tr { break-inside: avoid; }
  .p-short .p-point, .p-short .p-think, .p-short .p-list:not(.p-ans), .p-short .p-wrong, .p-short .p-intro, .p-short .p-say { display: none; }
  .p-say { font-size: 8.5pt; margin: 1mm 0; }
  .p-head { margin-top: 2.5mm; break-after: avoid; page-break-after: avoid; }
  .p-completion { table-layout: fixed; }
  .p-completion th:nth-child(1) { width: 17%; }
  .p-completion th:nth-child(2) { width: 33%; }
  .p-completion th:nth-child(3) { width: 20%; }
  .p-completion th:nth-child(4) { width: 12%; }
  .p-completion th:nth-child(5) { width: 18%; }
}
