/*
 * Tokens. White by default; night mode when the page carries data-theme="dark" (a switch in the header, kept in a cookie).
 * Two brand colours: green #00D6A3 and pink #FF3797. On white the data marks use a darker step of each so they keep
 * 3:1 against the surface and stay apart for colour-blind readers; on the dark surface the brand colours are used as they are.
 * Green is the action colour and the positive pole, pink the highlight and the negative pole. Red is kept for errors only.
 */
:root {
  --brand-green: #00D6A3; --brand-pink: #FF3797;
  --bg: #ffffff; --panel: #ffffff; --soft: #f5f6f8; --fg: #14161a; --muted: #5b6370; --line: #e4e7ec;
  --accent: #00D6A3; --accent-fg: #062a21; --link: #00795c;
  --ok: #00A37C; --bad: #C2185B; --ok-text: #00795c; --bad-text: #C2185B; --danger: #B42318; --warn: #8f5a00;
  --series-1: #14161a; --series-2: #00A37C; --series-3: #8a919e;
  --grid: #eef0f3; --axis: #c3c8d0; --muted-fill: #c3c8d0; --shadow: 0 6px 24px rgb(20 22 26 / 0.10);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --small: 0.8125rem; --body: 0.9375rem; --head: 1.125rem; --title: 1.75rem;
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111315; --panel: #181b1f; --soft: #1f2328; --fg: #eef0f2; --muted: #9ba3af; --line: #2a2f36;
  --accent: #00D6A3; --accent-fg: #062a21; --link: #00D6A3;
  --ok: #00D6A3; --bad: #FF3797; --ok-text: #00D6A3; --bad-text: #FF5FAB; --danger: #ff7a70; --warn: #e0a84a;
  --series-1: #eef0f2; --series-2: #00D6A3; --series-3: #7d8590;
  --grid: #23272d; --axis: #4a515b; --muted-fill: #4a515b; --shadow: 0 6px 24px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: var(--body); line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--link); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-block: 10px; }
.brand { font-size: var(--head); font-weight: 700; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; }
/* the mark: a green and a pink disc meeting, after the brand swatch */
.brand::before { content: ""; width: 26px; height: 16px; flex: none; background: radial-gradient(circle at 8px 8px, var(--brand-green) 7.5px, transparent 8px), radial-gradient(circle at 18px 8px, var(--brand-pink) 7.5px, transparent 8px); }
.brand small { font-size: var(--small); font-weight: 400; letter-spacing: 0; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 0; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand-pink); border-radius: 6px 6px 0 0; }
.who { display: flex; align-items: center; gap: 10px; font-size: var(--small); color: var(--muted); }
.who form { margin: 0; }
.theme { font: inherit; font-size: var(--small); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; cursor: pointer; white-space: nowrap; }
.theme:hover { color: var(--fg); }
@media (max-width: 760px) {
  .top-in { justify-content: space-between; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; margin-inline: -10px; }
  .nav a { white-space: nowrap; }
  .who span:not(:last-of-type) { display: none; }
}
main.wrap { padding-block: 28px 64px; display: flex; flex-direction: column; gap: 28px; }
.foot { color: var(--muted); font-size: var(--small); padding-block: 0 32px; }

.title { font-weight: 700; letter-spacing: -0.02em; font-size: var(--title); line-height: 1.2; margin-bottom: 8px; }
.take { font-size: var(--head); line-height: 1.45; max-width: 62ch; margin-bottom: 8px; }
.sub, .note, .label { font-size: var(--small); color: var(--muted); }
.h2 { font-size: var(--head); font-weight: 600; }
.lede { color: var(--muted); margin-top: 4px; max-width: 72ch; }
.section { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.big { font-weight: 700; letter-spacing: -0.03em; font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.line, .note { font-variant-numeric: tabular-nums; }
.up { color: var(--ok-text); }
.down { color: var(--bad-text); }

.gauge { max-width: 300px; width: 100%; margin: 0 auto; min-height: 150px; }
.gauge .gauge-num { font-weight: 700; letter-spacing: -0.03em; font-size: 44px; fill: var(--fg); }
.gauge .gauge-band { font-size: var(--body); fill: var(--fg); }
.bar { position: relative; min-height: 44px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--small); color: var(--muted); margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.legend b { color: var(--fg); font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sw-line { height: 3px; width: 14px; vertical-align: middle; }
.sw-s0 { background: var(--series-1); } .sw-s1 { background: var(--series-2); } .sw-s2 { background: var(--series-3); }
.chart { position: relative; min-height: 230px; min-width: 0; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.charttitle { font-size: var(--body); font-weight: 600; margin-bottom: 4px; }
.chart text, .gauge text, .bar text { font-size: 12px; fill: var(--muted); font-family: var(--sans); font-variant-numeric: tabular-nums; }
.tip { position: absolute; pointer-events: none; z-index: 2; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); padding: 8px 10px; font-size: var(--small); line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tip-head { color: var(--muted); }

.scroll { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: var(--small); font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.heat td { text-align: right; white-space: nowrap; }
.heat th:first-child, .heat td:first-child { text-align: left; }
.heat .child { padding-left: 24px; }
.heat .total td, .heat .group td { font-weight: 600; }
.vp { background: color-mix(in srgb, var(--ok) 36%, transparent); }
.p { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.n { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.vn { background: color-mix(in srgb, var(--bad) 36%, transparent); }
.empty { color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: var(--small); white-space: nowrap; border: 1px solid var(--line); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.posts td:first-child { min-width: 220px; }
.posts td:nth-child(2) { white-space: nowrap; }
.posts .why { min-width: 240px; max-width: 420px; color: var(--muted); font-size: var(--small); }
.posttitle { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; overflow-wrap: anywhere; }
.postmeta { display: block; font-size: var(--small); color: var(--muted); }
.more { font: inherit; font-size: var(--small); color: var(--muted); background: none; border: 0; padding: 0; margin-top: 2px; cursor: pointer; text-decoration: underline; }
.detail td { background: var(--soft); max-width: 0; white-space: normal; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.details { color: var(--muted); max-width: 78ch; }
.details summary { cursor: pointer; color: var(--fg); }
.details p { margin-top: 8px; }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: var(--small); color: var(--muted); min-width: 0; }
input, select, textarea, button { font: inherit; color: var(--fg); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0; width: 100%;
}
textarea { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--small); }
textarea.short { min-height: 96px; }
select { width: auto; }
.btn { background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.quiet { background: transparent; color: var(--fg); border-color: var(--line); font-weight: 400; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); font-weight: 400; }
.btn.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-weight: 400; font-size: var(--small); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form .wide { grid-column: 1 / -1; }
.inline { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0; }
.fold { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.fold > summary { cursor: pointer; font-weight: 600; }
.fold[open] > summary { margin-bottom: 12px; }
.flash { border: 1px solid var(--line); border-left: 4px solid var(--brand-green); background: var(--soft); border-radius: 6px; padding: 10px 14px; }
.flash.error { border-left-color: var(--danger); }
.flash ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: var(--small); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--small); background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.chip { font-size: var(--small); border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; white-space: nowrap; color: var(--fg); text-decoration: none; }
.chip.off { color: var(--muted); border-style: dashed; }
.chip.bad { color: var(--danger); border-color: var(--danger); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: var(--small); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.stack { grid-template-columns: 1fr; gap: 2px; }
.kv.stack dt { color: var(--fg); overflow-wrap: anywhere; }
.kv.stack dd { margin-bottom: 10px; }

/* signed-out pages */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.gate-card .gate-foot { align-items: flex-start; }

/* help: the knowledge base, written in Markdown and rendered on the server */
.how { font-size: var(--small); white-space: nowrap; }
.help { display: grid; grid-template-columns: minmax(0, 74ch) minmax(0, 220px); gap: 48px; align-items: start; }
.prose { max-width: 74ch; min-width: 0; display: flex; flex-direction: column; gap: 14px; overflow-wrap: break-word; }
.prose h2 { font-size: var(--head); font-weight: 600; line-height: 1.3; margin-top: 14px; padding-top: 22px; border-top: 1px solid var(--line); scroll-margin-top: 12px; }
.prose h3, .prose h4 { font-size: var(--body); font-weight: 600; margin-top: 6px; scroll-margin-top: 12px; }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875em; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }
.prose pre { margin: 0; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; line-height: 1.6; }
.prose pre code { background: none; border: 0; padding: 0; white-space: pre; overflow-wrap: normal; }
.prose blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 6px 0; }
.prose .table th { white-space: normal; vertical-align: bottom; }
.prose .table th:first-child, .prose .table td:first-child { padding-left: 0; }
.prose .table td { min-width: 5.5em; }
.toc { position: sticky; top: 16px; font-size: var(--small); }
.toc ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--line); padding-left: 12px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--fg); text-decoration: underline; }
.pager { display: flex; justify-content: space-between; gap: 16px; max-width: 74ch; border-top: 1px solid var(--line); padding-top: 16px; }
.pager a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; min-width: 0; }
.pager .next { text-align: right; }
@media (max-width: 900px) {
  .help { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
