:root {
  --ink: #14181c;
  --ink-soft: #4a5560;
  --ink-faint: #6b7680;      /* darkened from #7b8791 -- P-018: secondary text must
                                 stay comfortably legible, not merely present */
  --paper: #fbfaf7;
  --paper-raised: #ffffff;
  --line: #e2e0d8;
  --line-strong: #c9c6ba;

  --accent: #1d6b64;        /* deep teal -- calm and diagnostic, not alarmist */
  --accent-soft: #e4efed;
  --accent-ink: #0f403c;

  --good: #2f7a4f;
  --good-bg: #eaf4ec;
  --low: #8a7a1f;
  --low-bg: #f7f2df;
  --medium: #a05a1f;
  --medium-bg: #faeee0;
  --high: #b23a2e;
  --high-bg: #fbe9e6;
  --critical: #8c1f22;
  --critical-bg: #f8e2e1;
  --neutral: #4f5960;        /* darkened from #5a6570 for badge-text legibility at small size */
  --neutral-bg: #eef0f1;

  --radius: 10px;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  /* ---------------------------------------------------------------------
     HUMAN-FIRST TYPE SCALE (P-018, confirmed / REF-007)
     These are a usability FLOOR, not decoration. "Could a roofer standing
     on a jobsite, one-handed, read this without zooming or squinting?"
     Mobile-first values; desktop gets more room via clamp(), never less.
     --------------------------------------------------------------------- */
  --fs-diagnosis: clamp(1.85rem, 7vw, 2.5rem);   /* ~30px -> 40px: main diagnosis headline */
  --fs-section-heading: clamp(1.5rem, 5.5vw, 1.85rem); /* ~24px -> 30px: h2 section headings */
  --fs-finding-title: 1.3rem;      /* ~21px: leak/finding titles */
  --fs-body: 1.125rem;             /* 18px: primary reading text -- findings, diagnosis support */
  --fs-supporting: 1.0625rem;      /* ~17px: supporting prose -- what's-working, evidence descriptions */
  --fs-meta: 0.9rem;               /* ~14.4px: metadata floor -- never smaller than this for anything read as a sentence */
  --fs-pill: 0.8125rem;            /* ~13px: evidence/severity pills -- floor per P-018 */
  --fs-control: 1.0625rem;         /* ~17px: buttons and interactive controls */

  --lh-body: 1.6;
  --lh-supporting: 1.55;
  --lh-tight: 1.3;

  --measure: 66ch;                 /* long-form reading measure ceiling */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece9e2; --ink-soft: #c3c8cc; --ink-faint: #999fa4;
    --paper: #14181a; --paper-raised: #1b1f21;
    --line: #2b2f31; --line-strong: #3a3f42;
    --accent: #4fb3a9; --accent-soft: #17322f; --accent-ink: #9adbd2;
    --good: #6ec98d; --good-bg: #17281c;
    --low: #d8c25a; --low-bg: #2b2717;
    --medium: #e2a15f; --medium-bg: #2e2115;
    --high: #e6786c; --high-bg: #331815;
    --critical: #f28e85; --critical-bg: #341412;
    --neutral: #a8afb5; --neutral-bg: #202426;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px 120px;
}

/* ---------- Header / identity ---------- */
.masthead {
  padding: 28px 20px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.masthead-mark {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.masthead-mark .glyph {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}
.product-descriptor {
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 0.7em;
  margin-left: 0.35em;
}
.masthead-note {
  font-size: var(--fs-meta); color: var(--ink-faint);
  letter-spacing: 0.03em;
}

/* ---------- Executive diagnosis ---------- */
.diagnosis {
  padding: 48px 0 12px;
}
.diagnosis .eyebrow {
  font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-ink); font-weight: 700; margin-bottom: 14px;
}
.diagnosis h1 {
  font-family: var(--serif);
  font-size: var(--fs-diagnosis);
  line-height: 1.22;
  margin: 0 0 20px;
  font-weight: 400;
  max-width: 24ch;
}
.diagnosis .support {
  color: var(--ink-soft);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  max-width: var(--measure);
}
.diagnosis .meta-row {
  margin-top: 24px;
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  font-size: var(--fs-meta); color: var(--ink-faint);
  line-height: 1.5;
}

/* ---------- Pillar strip: NOT three identical cards -- a horizontal
   comparative strip so the three pillars read as one system, not three
   separate widgets. ---------- */
.pillar-strip {
  margin: 40px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.pillar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 22px 22px;
  border-bottom: 1px solid var(--line);
}
.pillar-row:last-child { border-bottom: none; }
.pillar-row .label-block { min-width: 0; }
.pillar-row .pillar-name {
  font-weight: 700; font-size: 1.15rem; margin-bottom: 5px; line-height: 1.3;
}
.pillar-row .pillar-sub {
  font-size: var(--fs-meta); color: var(--ink-faint); line-height: 1.5; max-width: 46ch;
}
.pillar-score {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.pillar-bar-track {
  width: 90px; height: 8px; border-radius: 4px; background: var(--line);
  overflow: hidden;
}
.pillar-bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.pillar-bar-fill.band-strong { background: var(--good); }
.pillar-bar-fill.band-mixed { background: var(--medium); }
.pillar-bar-fill.band-weak { background: var(--high); }
.pillar-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 800; font-size: 1.2rem; min-width: 3.4ch; text-align: right;
}
.pillar-pct.unscored { color: var(--ink-faint); font-weight: 600; font-size: var(--fs-meta); min-width: auto; }
.pillar-coverage {
  font-size: var(--fs-meta); color: var(--ink-faint); margin-top: 4px; line-height: 1.5;
}

/* ---------- Section shell (editorial, not a card grid) ---------- */
.section {
  margin-top: 56px;
}
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--serif); font-weight: 400;
  font-size: var(--fs-section-heading);
  line-height: 1.25;
  margin: 0;
}
.section-dek {
  color: var(--ink-faint); font-size: var(--fs-supporting); line-height: var(--lh-supporting);
  margin: 6px 0 24px;
  max-width: var(--measure);
}

/* ---------- Top leaks: numbered editorial blocks, not cards ---------- */
.leak {
  padding: 26px 0;
  border-top: 1px solid var(--line);
}
.leak:last-child { border-bottom: 1px solid var(--line); }
.leak-head {
  display: flex; align-items: flex-start; gap: 14px;
}
.leak-index {
  font-family: var(--serif); font-size: 1.7rem; color: var(--line-strong);
  line-height: 1.3; flex-shrink: 0; width: 1.4ch;
}
.leak-title-block { flex: 1; min-width: 0; }
.leak-title { font-weight: 700; font-size: var(--fs-finding-title); line-height: 1.3; margin: 0 0 8px; }
.leak-finding { color: var(--ink-soft); font-size: var(--fs-body); line-height: var(--lh-body); max-width: var(--measure); }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.badge {
  font-size: var(--fs-pill); font-weight: 700; letter-spacing: 0.02em;
  padding: 5px 12px; border-radius: 100px; white-space: nowrap;
  line-height: 1.4;
}
.badge.sev-none, .badge.sev-low { background: var(--low-bg); color: var(--low); }
.badge.sev-medium { background: var(--medium-bg); color: var(--medium); }
.badge.sev-high { background: var(--high-bg); color: var(--high); }
.badge.sev-critical { background: var(--critical-bg); color: var(--critical); }
.badge.evidence { background: var(--neutral-bg); color: var(--neutral); }
.badge.evidence.ev-observed { background: var(--accent-soft); color: var(--accent-ink); }
.badge.evidence.ev-tested { background: var(--accent-soft); color: var(--accent-ink); }
.badge.evidence.ev-owner_reported { background: var(--neutral-bg); color: var(--neutral); }
.badge.evidence.ev-benchmark { background: var(--low-bg); color: var(--low); }
.badge.evidence.ev-inferred { background: var(--neutral-bg); color: var(--ink-faint); }

.leak-detail-toggle {
  margin-top: 16px; margin-left: calc(1.4ch + 14px);
  background: none; border: none; padding: 10px 0;
  color: var(--accent-ink); font-size: var(--fs-control); font-weight: 700;
  cursor: pointer; font-family: var(--sans);
  min-height: 44px; display: inline-flex; align-items: center;
}
.leak-detail-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.leak-detail {
  margin-top: 8px; margin-left: calc(1.4ch + 14px);
  padding: 20px 20px; background: var(--paper-raised);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: var(--fs-supporting); line-height: var(--lh-supporting); color: var(--ink-soft);
  display: none;
  max-width: var(--measure);
}
.leak-detail.open { display: block; }
.leak-detail dt { font-weight: 700; color: var(--ink); margin-top: 16px; font-size: var(--fs-body); }
.leak-detail dt:first-child { margin-top: 0; }
.leak-detail dd { margin: 6px 0 0; }

/* ---------- No-leak state ---------- */
.no-leak-banner {
  margin-top: 26px;
  padding: 26px 24px;
  border: 1px solid var(--good);
  background: var(--good-bg);
  border-radius: var(--radius);
  color: var(--ink);
}
.no-leak-banner strong {
  color: var(--good); font-size: 1.2rem; display: block; margin-bottom: 10px;
  line-height: 1.35;
}
.no-leak-banner p { font-size: var(--fs-body); line-height: var(--lh-body); max-width: var(--measure); margin: 10px 0 0; }
.help-offer p { max-width: var(--measure); font-size: var(--fs-supporting); line-height: var(--lh-supporting); }

/* ---------- What's working ---------- */
.working-list { list-style: none; margin: 0; padding: 0; }
.working-item {
  display: flex; gap: 14px; padding: 18px 0;
  border-top: 1px solid var(--line);
  align-items: flex-start;
}
.working-item:last-child { border-bottom: 1px solid var(--line); }
.working-check {
  width: 26px; height: 26px; border-radius: 50%; background: var(--good-bg);
  color: var(--good); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; margin-top: 2px;
}
.working-text strong { font-weight: 700; }
.working-text { font-size: var(--fs-supporting); line-height: var(--lh-supporting); color: var(--ink-soft); max-width: var(--measure); }
.working-text .finding-title { color: var(--ink); font-weight: 700; }

/* ---------- Evidence explorer ---------- */
.evidence-filter {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px;
}
.filter-chip {
  font-size: var(--fs-meta); font-weight: 600; padding: 9px 16px; border-radius: 100px;
  border: 1px solid var(--line-strong); background: var(--paper-raised);
  color: var(--ink-soft); cursor: pointer; font-family: var(--sans);
  min-height: 40px;
}
.filter-chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.evidence-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
  padding: 16px 0; border-top: 1px solid var(--line);
  font-size: var(--fs-supporting); align-items: center;
}
.evidence-row .ev-title { color: var(--ink); font-weight: 600; line-height: 1.4; }
.evidence-row .ev-sub { color: var(--ink-faint); font-size: var(--fs-meta); line-height: var(--lh-supporting); margin-top: 4px; max-width: 54ch; }
.evidence-row[data-hidden="true"] { display: none; }

/* ---------- Opportunity scenarios ---------- */
.scenario-panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-raised); overflow: hidden;
}
.scenario {
  padding: 26px 24px; border-top: 1px solid var(--line);
}
.scenario:first-child { border-top: none; }
.scenario-label { font-weight: 700; font-size: 1.1rem; margin-bottom: 10px; line-height: 1.35; }
.scenario-value {
  font-family: var(--serif); font-size: 2.1rem; color: var(--accent-ink);
  margin: 8px 0; line-height: 1.2;
}
.scenario-desc { font-size: var(--fs-supporting); line-height: var(--lh-supporting); color: var(--ink-soft); max-width: var(--measure); }
.scenario-disclaimer {
  margin-top: 28px; padding: 18px 20px; background: var(--neutral-bg);
  border-radius: 10px; font-size: var(--fs-meta); line-height: var(--lh-supporting); color: var(--ink-soft);
  max-width: var(--measure);
}
.assumption-row { font-size: var(--fs-body) !important; }
.assumption-row label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.assumption-row input {
  font-size: var(--fs-body) !important; padding: 8px 10px !important; min-height: 44px;
}

/* ---------- Priority action plan ---------- */
.plan-tier { margin-bottom: 36px; }
.plan-tier-label {
  font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 800; color: var(--accent-ink); margin-bottom: 16px;
}
.plan-item {
  padding: 16px 0; border-top: 1px solid var(--line);
  font-size: var(--fs-body); line-height: var(--lh-body);
}
.plan-item:last-child { padding-bottom: 0; }
.plan-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.plan-effort {
  font-size: var(--fs-pill); font-weight: 700; letter-spacing: 0.02em;
  padding: 4px 10px; border-radius: 100px; background: var(--neutral-bg);
  color: var(--neutral); flex-shrink: 0; white-space: nowrap;
}
.plan-action-text { color: var(--ink); max-width: var(--measure); }

/* ---------- Could not verify ---------- */
.unverified-list { list-style: none; margin: 0; padding: 0; }
.unverified-item {
  padding: 18px 0; border-top: 1px solid var(--line);
  font-size: var(--fs-supporting); line-height: var(--lh-supporting); color: var(--ink-soft);
  max-width: var(--measure);
}
.unverified-item strong { color: var(--ink); font-weight: 700; }

/* ---------- Share bar ---------- */
.share-bar {
  margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 12px;
}
.share-btn {
  font-family: var(--sans); font-size: var(--fs-control); font-weight: 700;
  padding: 13px 20px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--paper-raised); color: var(--ink);
  min-height: 48px;
}
.share-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Optional help (deliberately last, deliberately quiet) ---------- */
.help-offer {
  margin-top: 48px; padding: 24px 24px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); font-size: var(--fs-supporting); line-height: var(--lh-supporting); color: var(--ink-soft);
}
.help-offer .help-title { font-weight: 700; color: var(--ink); font-size: 1.15rem; margin-bottom: 10px; line-height: 1.35; }
.help-options { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.help-options button {
  font-family: var(--sans); font-size: var(--fs-meta); font-weight: 600;
  padding: 11px 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--paper-raised); color: var(--ink-soft); cursor: pointer;
  min-height: 44px;
}

/* ---------- Footer ---------- */
.report-footer {
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
  font-size: var(--fs-meta); color: var(--ink-faint); line-height: 1.65;
}
.report-footer p { max-width: var(--measure); margin: 0 0 12px; }
.report-footer p:last-child { margin-bottom: 0; }

/* ---------- Reduced motion / accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.leak-detail, .working-check { transition: none; }

/* ---------- Mobile tuning (~390px baseline; also checked at ~360px and ~430px) ---------- */
@media (max-width: 480px) {
  .wrap { padding: 0 18px 96px; }
  .masthead { padding: 22px 18px 18px; }
  .diagnosis { padding-top: 36px; }
  .diagnosis h1 { max-width: none; }
  .pillar-row { grid-template-columns: 1fr; row-gap: 12px; padding: 20px 18px; }
  .pillar-score { justify-content: space-between; width: 100%; }
  .evidence-row { grid-template-columns: 1fr; row-gap: 6px; }
  .leak-index { display: none; }
  .leak-head { gap: 0; }
  .leak-detail-toggle, .leak-detail { margin-left: 0; }
}

/* Focus visibility everywhere, no reliance on hover */
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Feedback block ---------- */
.feedback-block {
  margin-top: 40px; padding: 24px 24px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper-raised);
}
.feedback-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 14px; }
.feedback-options { display: flex; gap: 10px; flex-wrap: wrap; }
.feedback-btn {
  font-family: var(--sans); font-size: var(--fs-control); font-weight: 600;
  padding: 11px 20px; border-radius: 100px; border: 1px solid var(--line-strong);
  background: var(--paper-raised); color: var(--ink-soft); cursor: pointer;
  min-height: 44px;
}
.feedback-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.feedback-followup { margin-top: 18px; }
.feedback-label { display: block; font-size: var(--fs-meta); color: var(--ink-faint); margin-bottom: 8px; }
.feedback-textarea {
  width: 100%; font-family: var(--sans); font-size: var(--fs-body);
  padding: 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  resize: vertical; box-sizing: border-box;
}
.feedback-submit {
  margin-top: 12px; font-family: var(--sans); font-size: var(--fs-control); font-weight: 700;
  padding: 12px 20px; border-radius: 8px; border: none; background: var(--accent);
  color: #fff; cursor: pointer; min-height: 44px;
}
.feedback-thanks { font-size: var(--fs-body); color: var(--good); font-weight: 600; margin-top: 12px; }

/* ---------- Print styles ---------- */
@media print {
  .masthead, .share-bar, .feedback-block, .help-offer, .evidence-filter { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; }
  .section { break-inside: avoid; margin-top: 28px; }
  .leak, .working-item, .evidence-row, .plan-item { break-inside: avoid; }
  a[href]::after { content: ""; }
}
