:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #69707d;
  --card: #f5f6f8;
  --border: #e3e5e8;
  --accent: #0052ff;
  --grid: #e9ebee;
  --danger: #d0342c;
  --warn: #a16000;
  --ok: #1c7e45;
  --accent2: #d9480f;
  --band: rgba(0, 82, 255, 0.08);
  --shade: rgba(107, 114, 128, 0.14);
  --gutter: 24px;
  --nav-bg: rgba(255, 255, 255, 0.92);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --card: #1b1e22;
    --border: #2b2f35;
    --accent: #4d8cff;
    --grid: #262a30;
    --danger: #f07168;
    --warn: #f0a63a;
    --ok: #4fc47f;
    --accent2: #d97706;
    --band: rgba(77, 140, 255, 0.12);
    --shade: rgba(154, 160, 166, 0.16);
    --nav-bg: rgba(16, 18, 20, 0.92);
  }
}
@media (max-width: 700px) { :root { --gutter: 16px; } }

/* 8px spacing grid; type scale h1 1.75rem, h2 1.25rem, h3 1rem, body 15px, muted 0.875rem, hero 2.25rem. */
* { box-sizing: border-box; }
html { scroll-padding-top: 56px; }
body {
  margin: 0 auto;
  padding: 0 var(--gutter) 32px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 1040px;
}
h1 { font-size: 1.75rem; margin: 24px 0 8px; }
h2 { font-size: 1.25rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 24px 0 8px; }
p { margin: 4px 0 8px; }
p:not(.banner), dd { max-width: 72ch; }  /* a readable measure; tables and charts keep the full width */
.lede { margin: 0 0 16px; }
.muted { color: var(--muted); font-size: 0.875rem; }
.stale { color: var(--danger); }
a { color: var(--accent); text-decoration: none; }
p a, footer a { text-decoration: underline; text-underline-offset: 2px; }  /* links in running text need more than color */
a:hover { text-decoration: underline; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

details > summary { cursor: pointer; color: var(--accent); padding: 2px 0; }  /* 24px tap target (WCAG 2.5.8) */
#glossary { margin: 8px 0 16px; }
#glossary dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 0.875rem; }
#glossary dt { font-weight: 600; }
#glossary dd { margin: 0; }
@media (max-width: 700px) { #glossary dl { grid-template-columns: 1fr; } #glossary dt { margin-top: 8px; } }

nav.sections {
  position: sticky; top: 0; z-index: 2;
  background: var(--nav-bg); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
}
nav.sections ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; overflow-x: auto; white-space: nowrap; }
nav.sections a { display: inline-block; padding: 12px 0; font-weight: 600; }

section { padding: 24px 0; border-top: 1px solid var(--border); }
section:first-child { border-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.tile h3 { margin: 0 0 8px; color: var(--muted); font-weight: 500; }
.hero { font-size: 2.25rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero.red, .mark.red { color: var(--danger); }
.hero.amber, .mark.amber { color: var(--warn); }
.hero.green, .mark.green { color: var(--ok); }
.tile .cards { margin: 8px 0 0; }
.tile .card { background: var(--bg); min-width: 96px; flex: 1 1 96px; padding: 8px; }
.tile .card .value { font-size: 1rem; }
#distance-list { list-style: none; margin: 8px 0; padding: 0; }
#distance-list li { padding: 4px 0; border-top: 1px solid var(--border); }
#distance-list a { color: inherit; display: block; }
#distance-list ol { list-style: none; margin: 0; padding: 0; }
#distance-list b { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {  /* phones: a tighter header and tiles bring the three answers up the first screen */
  h1 { font-size: 1.375rem; margin: 16px 0 4px; }
  .tiles { grid-template-columns: 1fr; gap: 12px; }
  .tile { padding: 12px; }
  #now .lede { display: none; }  /* the three tiles name themselves; desktop keeps the sentence */
  .hero { font-size: 2rem; }
  nav.sections a { padding: 10px 0; }
  #glossary { margin: 4px 0 8px; }
  #now { padding-top: 16px; }
}

.cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 120px;
  flex: 1 1 120px;
}
.card .label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.card .value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 0 0 8px; }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.buttons button {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.buttons button.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.buttons details { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.buttons details[open] summary { margin-right: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 24px; }

.fig h3 { margin-top: 24px; }
.chart { width: 100%; height: 380px; }
.chart-short { height: 300px; }
.chart-tall { height: 520px; }
.chart:empty::before { content: "loading"; color: var(--muted); font-size: 0.875rem; }
.table-toggle {
  display: block; margin: 0 0 4px auto;
  background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; font: inherit; font-size: 0.8rem; cursor: pointer;
}
.table-toggle[aria-pressed="true"] { color: var(--fg); border-color: var(--fg); }
.fold > summary { font-size: 1rem; font-weight: 600; color: var(--fg); margin: 24px 0 8px; }
.banner { background: var(--danger); color: var(--bg); padding: 8px var(--gutter); margin: 0 calc(-1 * var(--gutter)); }
h2 small { font-size: 0.875rem; font-weight: 400; margin-left: 8px; }
.explain { font-size: 0.875rem; color: var(--muted); }
@media (max-width: 700px) {
  .chart, .chart-short { height: 280px; }
  .chart-tall { height: 480px; }
  #chart-curve { height: 380px; }  /* four-row legend sits inside the chart on phones */
}

.scroll-x { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
th:first-child, td:first-child { text-align: left; }
.badge {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 0.75rem;
  margin-left: 6px;
}
footer { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }

/* Check a loan */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#check-form input {
  flex: 1 1 360px; min-width: 0; max-width: 480px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875rem;
}
#check-form button {
  background: var(--accent); color: var(--bg); border: 1px solid var(--accent); border-radius: 6px;
  padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
td.wrap { white-space: normal; min-width: 240px; text-align: left; }
#check-table tr.pos td { border-bottom: 0; }
#check-table tr.sub td { padding-top: 0; font-size: 0.875rem; }
.empty { border-left: 3px solid var(--border); padding-left: 8px; }
@media (max-width: 700px) {  /* phones: market, debt, liquidation price and buffer fit the width, so the crash line under each row is readable */
  #check-table tr:not(.sub) > :nth-child(3), #check-table tr:not(.sub) > :nth-child(4) { display: none; }
  #check-table th, #check-table td { white-space: normal; }
  td.wrap { min-width: 0; }
}

/* Risk briefing: answer rows first, with the established Spine type and color roles. */
h1 .muted { display: inline-block; font-size: 0.65em; font-weight: 400; }
.investigate { gap: 8px; margin: 12px 0 4px; }
.investigate select { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; font: inherit; }
.investigate a { margin-left: auto; padding: 6px 0; }
.briefing-rows { margin: 16px 0 8px; }
.briefing-rows > div { display: grid; grid-template-columns: 1fr 1.7fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.briefing-rows dt { color: var(--muted); font-size: 0.875rem; }
.briefing-rows dd { margin: 0; }
.briefing-rows strong { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.briefing-rows a { display: block; font-size: 0.875rem; padding: 4px 0; }
.brief-exposure { display: block; font-size: 0.875rem; }
.briefing-date { margin-bottom: 12px; }
#now-evidence > summary { margin-bottom: 12px; }
#daily-changes h3 { margin-top: 24px; }
.model-note { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 16px 0; font-size: 0.875rem; }
@media (max-width: 700px) {
  .briefing-rows > div { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
  .briefing-rows strong { font-size: 1.375rem; }
  #selection-note { margin-bottom: 8px; }
}
@media (max-width: 700px) {
  #daily-changes table { table-layout: fixed; }
  #daily-changes th, #daily-changes td { white-space: normal; padding: 6px 4px; font-size: 0.8125rem; }
  #daily-changes th:first-child { width: 32%; }
}
