:root {
  color-scheme: light dark;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink-2: #4a4946; --muted: #6b6a65;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.12);
  --accent: #1c5cab; --accent-ink: #ffffff; --accent-soft: #e3eefb;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --pos: #2a78d6; --neg: #e34948; --mid: #e4e3de;
  --land: #eceae3; --land-focus: #ffffff; --sea: #f9f9f7;
  --warn-bg: #fff4d6; --warn-ink: #4d3800; --warn-line: #e2bd55;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a3a29a;
    --grid: #2c2c2a; --axis: #4a4a46; --border: rgba(255, 255, 255, 0.13);
    --accent: #86b6ef; --accent-ink: #0b0b0b; --accent-soft: #14263d;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --pos: #3987e5; --neg: #e66767; --mid: #45453f;
    --land: #262624; --land-focus: #33332f; --sea: #1a1a19;
    --warn-bg: #2e2508; --warn-ink: #f4dd9a; --warn-line: #6b5517;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--page); color: var(--ink); line-height: 1.6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); margin: 0.4em 0 0.5em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 0 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
/* A page that is only text keeps a comfortable line length, centred. */
.narrow { max-width: 80ch; margin-inline: auto; }
/* Running text is justified, hyphenated so that lines do not open into wide gaps. */
main p, main li, .site-footer p, .site-footer li { text-align: justify; hyphens: auto; hyphenate-limit-chars: 6 3 3; }
main .headlines li, main .stack li, main .flow li, main .requests li, main .log li,
main .status, main .legend-line, main .role, main .hint { text-align: left; hyphens: manual; }
.proper { hyphens: manual; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  white-space: nowrap;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 14px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-block: 8px; }
.brand { font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none; margin-right: auto; padding-block: 8px; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0 4px; }
.site-header nav a { color: var(--ink-2); text-decoration: none; padding: 10px 10px; font-size: 0.94rem; border-bottom: 2px solid transparent; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
/* The section links stay on one line on a phone. */
@media (max-width: 480px) {
  .site-header nav { margin-left: -6px; }
  .site-header nav a { padding-inline: 6px; font-size: 0.84rem; }
  .site-header nav .long { display: none; }
}
.site-footer { border-top: 1px solid var(--border); margin-top: 56px; padding-block: 28px 40px; font-size: 0.86rem; color: var(--ink-2); }
.site-footer ul { padding-left: 18px; margin: 0 0 1rem; columns: 2 300px; }
.site-footer h2 { font-size: 0.95rem; }

/* Home */
.hero { padding-block: 40px 8px; }
.hero .role { font-size: 1.15rem; color: var(--accent); font-weight: 600; margin-bottom: 1.2rem; }
.hero .bio { font-size: 1.1rem; line-height: 1.7; color: var(--ink-2); }
.stack { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.stack li { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 14px; font-size: 0.9rem; }
.demo { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-top: 20px; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.demo .kind { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.preview { min-height: 148px; align-self: center; }
@media (max-width: 760px) { .demo { grid-template-columns: minmax(0, 1fr); padding: 18px; } }

/* Controls */
.button, button.chip {
  font: inherit; font-size: 0.92rem; cursor: pointer; border-radius: 999px; min-height: 40px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 6px 16px;
}
a.button { display: inline-flex; align-items: center; background: var(--accent); color: var(--accent-ink); border-color: transparent; text-decoration: none; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.chips .label { font-size: 0.85rem; color: var(--muted); margin-right: 2px; }
button.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
button.chip[aria-pressed="false"] .key { opacity: 0.3; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

/* Panels and charts */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-top: 18px; min-width: 0; }
.columns { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.columns > .panel { margin-top: 0; }
.columns { margin-top: 18px; }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.chart { width: 100%; min-width: 0; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.strong { fill: var(--ink); font-weight: 600; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .mark { cursor: pointer; }
.chart [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.chart .selected { stroke: var(--ink); stroke-width: 2.5; }
.chart .land { fill: var(--land); stroke: var(--axis); stroke-width: 0.7; }
.chart .land.focus { fill: var(--land-focus); }
.chart .brush-area { fill: var(--accent); fill-opacity: 0.14; stroke: var(--accent); cursor: grab; touch-action: none; }
.chart .brush-handle { fill: var(--accent); cursor: ew-resize; touch-action: none; }
.scroll-x { overflow-x: auto; }
/* Wide charts keep their size and scroll, instead of being clipped to the screen. */
.chart.scroll-x svg { max-width: none; }
.legend-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; color: var(--ink-2); margin: 8px 0 0; }
.legend-line svg { vertical-align: -3px; margin-right: 6px; }
.key-forest { fill: var(--series-2); }
.key-z { fill: none; stroke: var(--series-3); stroke-width: 2; }
.key-wrong { fill: none; stroke: var(--series-2); stroke-width: 2.5; }
/* Hidden until drawn, and tall enough to keep the footer off screen, so nothing jumps. */
.data-area[aria-busy] { visibility: hidden; min-height: 100vh; }
/* Same proportions as the map that is drawn into it. */
#map { aspect-ratio: 1.513; max-width: 860px; margin-inline: auto; }
.ramp { display: inline-block; width: 120px; height: 10px; border-radius: 5px; vertical-align: -1px; margin-inline: 8px; }
.ramp.sentiment { background: linear-gradient(90deg, var(--neg), var(--mid), var(--pos)); }
.ramp.rain { background: linear-gradient(90deg, var(--mid), var(--pos)); }

.tooltip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--page);
  border-radius: 8px; padding: 8px 11px; font-size: 0.82rem; line-height: 1.45; max-width: 260px;
}
.tooltip strong { display: block; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.tile .name { font-size: 0.82rem; color: var(--muted); }
.tiles + p { margin-top: 10px; }

.notice { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; font-size: 0.9rem; }

details.data { margin-top: 12px; font-size: 0.88rem; }
details.data summary { cursor: pointer; color: var(--accent); padding: 8px 0; width: fit-content; }
.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { background: var(--surface); position: sticky; top: 0; font-weight: 600; }
td.num, th.num { text-align: right; }

.headlines { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.headlines li { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--grid); font-size: 0.9rem; }
.score { font-variant-numeric: tabular-nums; font-weight: 600; border-left: 5px solid var(--mid); padding-left: 7px; height: fit-content; }
.score.up { border-left-color: var(--pos); }
.score.down { border-left-color: var(--neg); }
.headlines .source { display: block; font-size: 0.78rem; color: var(--muted); }
.headlines a { overflow-wrap: anywhere; }

/* Long lists of days scroll inside their own box. */
#flag-list { max-height: 192px; overflow-y: auto; padding: 4px; }

/* Business system: home card, feature list and interactive sample. */
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); counter-reset: step; }
.flow li { border: 1px solid var(--border); border-top: 4px solid var(--series-1); border-radius: 8px; padding: 10px 12px; counter-increment: step; }
.flow strong::before { content: counter(step) ". "; color: var(--muted); }
.flow span { display: block; font-size: 0.8rem; color: var(--muted); }
.cards { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.cards li { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.cards p { margin: 0; font-size: 0.93rem; color: var(--ink-2); }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 0.93rem; }
.split.sample { margin-top: 20px; }
.split.sample > div { min-width: 0; }
.split.sample + p { margin-top: 18px; }
#clients th, #clients td { white-space: nowrap; padding-inline: 8px; }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }
.requests { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 8px; }
.requests li { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.decide { display: inline-flex; gap: 8px; }
.bars { display: grid; gap: 4px; margin-bottom: 22px; }
.bars button { display: grid; grid-template-columns: 76px minmax(0, 1fr) 56px; gap: 10px; align-items: center; width: 100%; min-height: 40px; padding: 6px 8px; font: inherit; font-size: 0.9rem; color: var(--ink); text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.bars button:hover { border-color: var(--border); }
.bars button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.bars .track { height: 14px; }
.bars .fill { display: block; height: 100%; min-width: 2px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bars .amount { text-align: right; font-variant-numeric: tabular-nums; }
.log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 0.9rem; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--grid); }
.log .source { display: block; font-size: 0.8rem; color: var(--muted); }

.status { font-size: 0.82rem; color: var(--muted); }
.error { color: var(--ink); background: var(--warn-bg); border-radius: 8px; padding: 10px 14px; }
