/* Layout: a household statement. Masthead strip, the lead question beside its chart,
   a pay-stub ledger of this month's figures, then chapters with a sticky left rail. */
:root {
  --paper: #f1f5f0;
  --paper-2: #e4ece5;
  --ink: #102326;
  --ink-2: #4b5e5f;
  --rule: #c3d1c7;
  --grid: #d9e3db;
  --c0: #00806a;
  --c1: #c8412b;
  --c2: #2f5da8;
  --c3: #b7791f;
  --c4: #7b4fa0;
  --good: #0a6e4f;
  --watch: #8a5e00;
  --bad: #b3261e;
  --shade: rgba(16, 35, 38, 0.075);
  --tip-bg: #ffffff;
  --tip-shadow: 0 6px 24px rgba(16, 35, 38, 0.14);
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark follows the device setting unless the reader picked light; the toggle sets data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10191b;
    --paper-2: #172427;
    --ink: #e3ece7;
    --ink-2: #9aaea8;
    --rule: #2b3d40;
    --grid: #1f2e31;
    --c0: #26a68c;
    --c1: #e2654a;
    --c2: #6f94da;
    --c3: #b5862a;
    --c4: #a57fd0;
    --good: #4cc79f;
    --watch: #e2b04a;
    --bad: #f38170;
    --shade: rgba(227, 236, 231, 0.06);
    --tip-bg: #1b2a2d;
    --tip-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10191b;
  --paper-2: #172427;
  --ink: #e3ece7;
  --ink-2: #9aaea8;
  --rule: #2b3d40;
  --grid: #1f2e31;
  --c0: #26a68c;
  --c1: #e2654a;
  --c2: #6f94da;
  --c3: #b5862a;
  --c4: #a57fd0;
  --good: #4cc79f;
  --watch: #e2b04a;
  --bad: #f38170;
  --shade: rgba(227, 236, 231, 0.06);
  --tip-bg: #1b2a2d;
  --tip-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--f-body);
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, p, figure, ul { margin: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { max-width: 80rem; margin-inline: auto; padding-inline: clamp(16px, 4vw, 48px); }

/* Masthead */
.mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  padding-block: 14px 10px;
  border-bottom: 3px solid var(--ink);
}
.brand {
  font-family: var(--f-display);
  font-stretch: 112%;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
}
.mast-meta { font-size: 0.82rem; color: var(--ink-2); }
.mast-next { white-space: nowrap; }
.live-note { font-size: 0.82rem; font-weight: 700; color: var(--good); }
.live-note[hidden] { display: none; }
.mast-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 0.78rem/1 var(--f-body);
  padding: 6px 10px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-btn svg { width: 14px; height: 14px; flex: none; }
.theme-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* Just in: the newest releases, newest first */
.justin {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 28px;
  align-items: start;
  padding-block: 14px;
  border-bottom: 1px solid var(--rule);
}
.justin[hidden] { display: none; }
.justin-h {
  font: 800 0.74rem/1.2 var(--f-display);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-top: 4px;
}
.justin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.5rem), 1fr));
  gap: 12px 28px;
}
.justin-list a { display: block; text-decoration: none; }
.justin-list a:hover .justin-label { text-decoration: underline; }
.justin-label { display: block; font-size: 0.8rem; color: var(--ink-2); }
.justin-value { display: block; font: 700 1.3rem/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.justin-sub { display: block; font-size: 0.78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.justin .stamp { margin-left: 8px; font-size: 0.64rem; padding: 1px 5px 0; vertical-align: 3px; }
@media (max-width: 640px) {
  .justin { grid-template-columns: minmax(0, 1fr); }
  .justin-list li:nth-child(n + 3) { display: none; } /* phones: the two newest only */
}

/* Lead */
.lead {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: end;
  padding-block: clamp(28px, 5vw, 64px) clamp(28px, 4vw, 44px);
}
.lead h1 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
  line-height: 1.12;
  text-wrap: balance;
  max-width: 18ch;
}
.verdict {
  font-family: var(--f-display);
  font-stretch: 125%;
  font-weight: 900;
  /* "Barely." is the widest verdict at about 4.3em, so cap it to the column width. */
  font-size: min(clamp(4.2rem, 11vw, 8.75rem), 22cqi);
  line-height: 0.92;
  letter-spacing: -0.025em;
  margin-top: 0.12em;
}
.verdict.is-good { color: var(--good); }
.verdict.is-bad { color: var(--bad); }
.lead-text { margin-top: 1rem; font-size: 1.06rem; max-width: 44ch; font-variant-numeric: tabular-nums; }
.lead-text b { font-weight: 700; }
.lead > div:first-child { container-type: inline-size; }
.lead-fig { min-width: 0; }

/* Pay-stub ledger */
.stub {
  background-color: var(--paper-2);
  background-image: repeating-linear-gradient(135deg, transparent 0 7px, var(--shade) 7px 8px);
  border-top: 2px dashed var(--ink-2);
  padding: 18px clamp(16px, 3vw, 28px) 8px;
}
.stub-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.stub-head h2 { font: inherit; color: var(--ink); font-weight: 700; }
.stub-lines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  column-gap: clamp(24px, 4vw, 48px);
}
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 10px;
  row-gap: 2px;
  padding-block: 12px 11px;
  border-bottom: 1px solid var(--rule);
}
.line-label { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 0.95rem; }
.line-label::after { content: ""; flex: 1; min-width: 12px; border-bottom: 1px dotted var(--ink-2); opacity: 0.55; }
.line-value {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.line-sub {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 12px;
  font-size: 0.8rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.is-good { color: var(--good); }
.is-bad { color: var(--bad); }

/* Range control */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: clamp(32px, 5vw, 56px) 12px;
}
.controls-label { font-size: 0.82rem; color: var(--ink-2); margin-right: 10px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); }
.seg button {
  font: 600 0.82rem/1 var(--f-body);
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.shade-key { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--ink-2); }
.shade-key i { width: 18px; height: 12px; background: var(--shade); outline: 1px solid var(--rule); }

/* Chapters */
.chapter {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: 20px clamp(24px, 4vw, 56px);
  padding-block: 40px 48px;
  border-top: 1px solid var(--ink);
}
.rail { align-self: start; }
@media (min-width: 861px) { .rail { position: sticky; top: 16px; } }
.rail h2 {
  font-family: var(--f-display);
  font-stretch: 112%;
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.1;
  text-wrap: balance;
  margin-bottom: 0.55rem;
}
.rail p { color: var(--ink-2); font-size: 0.94rem; max-width: 40ch; }
.rail p + p { margin-top: 0.6rem; }
.rail .big-figure { color: var(--ink); font-size: clamp(2.6rem, 5vw, 3.6rem); margin: 4px 0 12px; }
.rail .big-figure small { display: block; margin: 8px 0 0; font-size: 0.9rem; }
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  gap: 40px clamp(24px, 3vw, 40px);
  min-width: 0;
}
.charts.split { grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); align-items: start; }
@media (max-width: 1100px) { .charts.split { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 40px; min-width: 0; align-content: start; }
.charts.smalls { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15.5rem), 1fr)); gap: 32px clamp(20px, 3vw, 32px); }
.block { min-width: 0; display: flex; flex-direction: column; }
.block.wide { grid-column: 1 / -1; }
.block h3 { font-size: 1rem; font-weight: 700; line-height: 1.3; }
.chart-meta { font-size: 0.74rem; color: var(--ink-2); margin: -4px 0 10px; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.chart-meta[hidden] { display: none; }
.chart-note { font-size: 0.82rem; color: var(--ink-2); margin: 3px 0 10px; max-width: 64ch; }
.big-figure {
  font-family: var(--f-display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(2.3rem, 5vw, 3.3rem);
  line-height: 1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.big-figure small { font: 500 0.95rem var(--f-body); color: var(--ink-2); margin-left: 6px; letter-spacing: 0; }

.chart { position: relative; min-height: 220px; margin-top: auto; }
.chart.small { min-height: 170px; }
.chart svg { display: block; overflow: visible; }
.chart .ax { fill: var(--ink-2); font: 400 11.5px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .end-label { fill: var(--ink); font: 600 12px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .ref-label { fill: var(--ink-2); font: 500 11px var(--f-body); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .tip i { width: 10px; height: 3px; display: inline-block; flex: none; }
.chart-empty { display: flex; align-items: center; min-height: inherit; color: var(--ink-2); font-size: 0.85rem; }
.tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
  background: var(--tip-bg);
  border: 1px solid var(--rule);
  box-shadow: var(--tip-shadow);
  padding: 6px 10px;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tip[hidden] { display: none; }
.tip-date { color: var(--ink-2); }
.tip-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip-row b { margin-left: auto; padding-left: 12px; }
.tip-rec { color: var(--ink-2); font-style: italic; }

/* Grocery receipt: a till slip with a torn bottom edge */
.receipt {
  position: relative;
  background: var(--paper-2);
  padding: 18px clamp(16px, 3vw, 24px) 16px;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.receipt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 10px;
  background: linear-gradient(-45deg, transparent 7px, var(--paper-2) 0) 0 0 / 14px 10px repeat-x,
    linear-gradient(45deg, transparent 7px, var(--paper-2) 0) 0 0 / 14px 10px repeat-x;
}
.receipt-head {
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--ink-2);
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.receipt-head h3 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; font-size: 1.05rem; letter-spacing: 0.06em; color: var(--ink); }
.receipt-items { list-style: none; padding: 0; }
.receipt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 10px;
  row-gap: 3px;
  padding-block: 10px 9px;
  border-bottom: 1px solid var(--rule);
}
.r-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 0.95rem; }
.r-name::after { content: ""; flex: 1; min-width: 12px; border-bottom: 1px dotted var(--ink-2); opacity: 0.55; }
.r-now { font-family: var(--f-display); font-weight: 700; font-size: 1.25rem; line-height: 1.1; text-align: right; }
.r-sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: 0.8rem; color: var(--ink-2); }
.r-chg { margin-left: auto; font-weight: 600; }
.spark { display: block; flex: none; overflow: visible; }
.spark path { fill: none; stroke: var(--c0); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--c0); }
.receipt-total { border-top: 1px dashed var(--ink-2); border-bottom: 2px solid var(--ink); margin-top: -1px; }
.receipt-total .r-name { font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85rem; }
.receipt-foot { margin-top: 10px; text-align: center; font-size: 0.76rem; color: var(--ink-2); }

/* Bill-by-bill bars */
.bars { display: grid; font-variant-numeric: tabular-nums; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 10rem) minmax(0, 1fr) 3.6rem;
  align-items: center;
  column-gap: 12px;
  min-height: 30px;
  font-size: 0.9rem;
}
.bar-track { position: relative; align-self: stretch; }
.bar-track i { position: absolute; display: block; }
.bar { top: 50%; height: 12px; margin-top: -6px; background: var(--ink-2); opacity: 0.55; }
.bar.is-bad { background: var(--bad); opacity: 1; }
.bar.is-good { background: var(--good); opacity: 1; }
.bar-zero { top: 0; bottom: 0; border-left: 1px solid var(--ink-2); }
.bar-ref { top: 0; bottom: 0; border-left: 1.5px dashed var(--ink); }
.bar-value { text-align: right; font-weight: 600; }
.bar-row.is-ref .bar-label, .bar-row.is-ref .bar-value { font-weight: 700; }
.bar-row.is-ref .bar { background: var(--ink); opacity: 1; }

/* Recession watch */
.tally { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 18px; }
.stamp {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--f-display);
  font-stretch: 87.5%;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-2deg);
  white-space: nowrap;
}
.stamp b { font-size: 1.05rem; letter-spacing: 0; }
.stamp.calm { color: var(--good); }
.stamp.watch { color: var(--watch); }
.stamp.warning { color: var(--bad); }
.score-wrap { overflow-x: auto; }
.score { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.score th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 8px 10px;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.score td { padding: 12px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.score td:first-child, .score th:first-child { padding-left: 0; }
.score .num { text-align: right; white-space: nowrap; font-weight: 700; }
.score .what { display: block; font-size: 0.8rem; color: var(--ink-2); max-width: 36ch; }
.score .level { color: var(--ink-2); min-width: 11rem; }
.score .asof { color: var(--ink-2); white-space: nowrap; }
.score a { text-decoration: none; }
.score a:hover { text-decoration: underline; }

/* Footer */
.foot {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: 20px clamp(24px, 4vw, 56px);
  padding-block: 32px 56px;
  border-top: 3px solid var(--ink);
}
.foot h2 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; font-size: 1.1rem; margin-bottom: 0.5rem; }
.foot p { color: var(--ink-2); font-size: 0.86rem; max-width: 42ch; }
.foot p + p { margin-top: 0.75rem; }
.foot .fred-notice { color: var(--ink); border-left: 3px solid var(--ink); padding-left: 10px; }
.sources { list-style: none; padding: 0; columns: 2 20rem; column-gap: 40px; font-size: 0.82rem; }
.sources li { break-inside: avoid; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.sources span { display: block; color: var(--ink-2); font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .lead, .chapter, .foot { grid-template-columns: minmax(0, 1fr); }
  .verdict { margin-top: 0.08em; }
}
