/* Loupe — light, Apple-style visual system. Always light; no dark mode. */
:root {
  color-scheme: light;
  --bg: #ffffff; --bg-alt: #f5f5f7; --fg: #1d1d1f; --muted: #6e6e73; --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff; --accent: #0071e3; --accent-hover: #0077ed; --on-accent: #ffffff;
  --warn-bg: #fff8e6; --warn-fg: #7a5a00;
  --c1: #3478f6; --c2: #ff8d3a; --c3: #34c759; --c4: #e8b400; --c5: #ff5c8a; --c6: #00897b; --c7: #6e63e8; --c8: #ff453a; --c9: #5ac8fa; --c10: #a2845e;
  --seq-1: #d6e9ff; --seq-2: #9cc8ff; --seq-3: #4ea2ff; --seq-4: #0071e3; --seq-5: #004a99;
  --radius: 18px; --radius-sm: 12px; --gap: 20px; --maxw: 1100px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Inter, system-ui, Segoe UI, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 17px/1.47 var(--font); letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: 22px; }

/* Top bar: thin, translucent, blurred like apple.com */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.72); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; gap: 14px; align-items: center; min-height: 48px; }
.brand { font-weight: 600; font-size: 19px; letter-spacing: -0.02em; color: var(--fg); }
.brand:hover { text-decoration: none; }
.tag { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) { .tag { display: none; } .wrap { padding-inline: 18px; } .card { padding: 20px 18px 16px; } .hero { padding-top: 40px; } }
.docs-link { margin-left: auto; font-size: 14px; font-weight: 500; }

/* Hero */
.hero { padding: 56px 0 8px; text-align: center; }
.hero h1 { font-size: clamp(36px, 6vw, 56px); line-height: 1.07; letter-spacing: -0.028em; font-weight: 600; margin: 0 0 12px; }
.hero p { font-size: clamp(18px, 2.4vw, 23px); line-height: 1.33; letter-spacing: -0.015em; color: var(--muted); margin: 0 auto; max-width: 680px; }

/* Segmented control */
.tabs-wrap { display: flex; justify-content: center; padding: 30px 22px 10px; }
.tabs { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 2px; background: #e8e8ed; border-radius: 999px; padding: 3px; }
.tabs button {
  background: transparent; color: var(--fg); border: 0; border-radius: 999px; padding: 8px 18px;
  font: 500 14px/1.2 var(--font); letter-spacing: -0.01em; cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.tabs button:hover { color: #000; }
.tabs button.active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06); }

main { padding-bottom: 24px; }
.status { color: var(--muted); text-align: center; font-size: 15px; padding: 24px 0; }
.banner { background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius-sm); padding: 12px 16px; margin-block: 12px; font-size: 15px; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 24px 0 8px; }
@media (min-width: 900px) { .tiles:has(> :nth-child(4)):not(:has(> :nth-child(5))) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--bg-alt); border-radius: var(--radius); padding: 22px 20px 18px; min-height: 112px; display: flex; flex-direction: column; justify-content: flex-end; container-type: inline-size; }
.tile b { display: block; font-size: clamp(20px, 15cqi, 34px); white-space: nowrap; line-height: 1.05; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tile span { display: block; color: var(--muted); font-size: 13px; letter-spacing: -0.005em; margin-top: 8px; }

@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .tile { padding: 18px 16px 14px; min-height: 96px; } .tile span { font-size: 12px; } }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 26px 20px; margin-block: var(--gap); }
.card h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.2; letter-spacing: -0.022em; font-weight: 600; }
.card p.note { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.card p.note b { color: var(--fg); font-weight: 600; }
.card figure { margin: 0; overflow-x: auto; }
.card svg { max-width: 100%; height: auto; }
/* Observable Plot output: match type and soften grid */
.card figure, .card figure svg, .card figure [class$="-swatches"] { font-family: var(--font) !important; font-size: 12px !important; color: var(--muted); }
.card figure [class$="-swatches"] { margin-bottom: 10px; gap: 4px 14px; }
.card figure svg [aria-label="y-grid"] line, .card figure svg [aria-label="x-grid"] line { stroke: #000; stroke-opacity: 0.06; }
.card figure svg [aria-label$="-axis tick"] line { stroke-opacity: 0; }
.card figure svg [aria-label$="-axis tick label"] text { fill: var(--muted); }
.card figure svg [aria-label$="-axis label"] text { fill: var(--muted); font-weight: 500; }

/* Controls */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-block: 12px; }
.controls select, .controls input, textarea {
  background: var(--bg-alt); color: var(--fg); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 12px; font: 15px/1.4 var(--font);
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.controls select:focus, .controls input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.18); background: #fff; }
textarea { width: 100%; min-height: 128px; font-family: var(--mono); font-size: 13px; resize: vertical; }
button.run {
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 999px; padding: 9px 20px;
  font: 500 15px/1.2 var(--font); cursor: pointer; transition: background 0.15s ease;
}
button.run:hover { background: var(--accent-hover); }

/* Tables */
.tablewrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--bg-alt); }

/* Footer */
.foot { border-top: 1px solid var(--line); margin-top: 48px; padding-block: 28px 48px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.foot p { margin: 0 0 8px; max-width: 820px; }

/* Docs */
.docnav { max-width: 760px; margin: 0 auto; padding: 22px 22px 0; display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; }
.docnav a { color: var(--muted); padding: 4px 0; }
.docnav a:hover { color: var(--fg); text-decoration: none; }
.docnav a.current { color: var(--fg); font-weight: 600; }
.doc { max-width: 760px; margin: 0 auto; padding: 24px 22px 96px; font-size: 17px; line-height: 1.6; }
.doc h1 { font-size: clamp(34px, 5vw, 46px); line-height: 1.08; letter-spacing: -0.028em; font-weight: 600; margin: 12px 0 18px; }
.doc h2 { margin: 48px 0 12px; font-size: 27px; line-height: 1.15; letter-spacing: -0.022em; font-weight: 600; }
.doc h3 { margin: 32px 0 8px; font-size: 20px; letter-spacing: -0.015em; font-weight: 600; }
.doc p { margin: 0 0 16px; }
.doc > p:first-of-type { color: var(--muted); font-size: 15px; }
.doc > p:first-of-type strong { color: var(--fg); font-weight: 500; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; display: block; overflow-x: auto; margin: 16px 0 24px; }
.doc th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.doc th, .doc td { border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.doc pre { background: var(--bg-alt); border: 0; padding: 16px 18px; overflow-x: auto; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; }
.doc code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-alt); padding: 2px 6px; border-radius: 6px; }
.doc pre code { background: none; padding: 0; font-size: inherit; }
.doc blockquote { border-left: 3px solid var(--accent); margin: 20px 0; padding: 2px 0 2px 18px; color: var(--muted); }
.doc blockquote p { margin: 0 0 8px; }
.doc ul, .doc ol { padding-left: 24px; margin: 0 0 16px; }
.doc li { margin-bottom: 6px; }
.doc img { max-width: 100%; border-radius: var(--radius-sm); }

/* Tiles: date or context line under the label */
.tile small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; opacity: 0.85; }

/* Insight card: the question a product owner asks, answered from the data */
.card.insight { background: var(--fg); color: #fff; box-shadow: none; padding: 28px 30px 26px; }
.card.insight .eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.55); }
.card.insight h2 { color: #fff; font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.025em; margin-bottom: 16px; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.facts li { position: relative; padding-left: 22px; font-size: 16px; line-height: 1.5; color: rgba(255, 255, 255, 0.82); }
.facts li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 10px; height: 10px; border-radius: 50%; background: var(--c1); }
.facts li:nth-child(2)::before { background: var(--c2); }
.facts li:nth-child(3)::before { background: var(--c3); }
.facts li b { color: #fff; font-weight: 600; }
.card.insight .more { display: inline-block; margin-top: 18px; color: #6cb4ff; font-size: 15px; font-weight: 500; }
@media (max-width: 640px) { .card.insight { padding: 22px 20px 20px; } .facts li { font-size: 15px; } }

/* Chart cards */
.card.chart .card-head { margin-bottom: 12px; }
.card .so { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: var(--fg); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--bg-alt); color: var(--fg); border: 0; border-radius: 999px; padding: 5px 11px 5px 8px; font: 500 13px/1.2 var(--font); letter-spacing: -0.005em; cursor: pointer; transition: background 0.15s ease, opacity 0.15s ease, color 0.15s ease; }
.chip i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.chip:hover { background: #e8e8ed; }
.chip.off { opacity: 0.38; }
.chip.off i { filter: grayscale(1); }
.chip[aria-pressed="true"] { background: var(--fg); color: #fff; }
.chip[hidden] { display: none; }
.chip.chip-all { background: transparent; color: var(--accent); padding-left: 10px; }
.chip.chip-all:hover { text-decoration: underline; }
.legend .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .legend .hint { display: none; } }
.panels { display: grid; gap: 0; }
details.def { margin-top: 10px; }
details.def summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.def summary::-webkit-details-marker { display: none; }
details.def summary::before { content: "i"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid currentColor; font: 600 10px/1 var(--font); font-style: italic; }
details.def[open] summary { color: var(--fg); }
details.def p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 820px; }
.card figure [class$="-ramp"] { font-family: var(--font) !important; font-size: 11px !important; margin-bottom: 8px; }

/* Collapsible reliability card on the Intent view */
details.reliability summary { cursor: pointer; list-style: none; }
details.reliability summary::-webkit-details-marker { display: none; }
details.reliability summary h2 { display: inline; margin-right: 10px; }
details.reliability summary .so { display: block; margin-top: 6px; color: var(--muted); }
details.reliability[open] summary .so { display: none; }
details.reliability .note { margin-top: 12px; }

/* Cross-view model filter */
.picker-wrap { padding-top: 6px; }
.model-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.model-picker button { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font: 500 13px/1.2 var(--font); cursor: pointer; transition: all 0.15s ease; }
.model-picker button:hover { color: var(--fg); border-color: rgba(0, 0, 0, 0.2); }
.model-picker button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.scope-banner { margin: 12px auto 0; text-align: center; font-size: 14px; color: var(--muted); }
.scope-banner b { color: var(--fg); font-weight: 600; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.scope { display: inline-block; vertical-align: middle; margin-left: 10px; padding: 2px 8px; border-radius: 999px; background: var(--bg-alt); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }

/* Chart keys and residual rows */
.card .keys { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
