/* 平均是谁的 — one stylesheet, read once at start-up and served from memory.

   A roll book on a grey morning: cool slate ground, rectangles in a single
   muted blue because they are all the same kind of thing, and the two averages
   in the only two accent colours on the page — moss for the one counted per
   group, brass for the one counted per person.

   Neither accent is a warning colour, on purpose. Neither average is wrong.

   The tones are `same`, `apart`, `far` — how far the two figures are from each
   other, and nothing about whether that is good. */

:root {
  --bg: #0f1114;
  --panel: #171a1f;
  --panel2: #1d2127;
  --line: #2c323a;
  --ink: #e8eaee;
  --dim: #9aa3ad;
  --faint: #6b747e;

  --bar: #5d8fb8;
  --plain: #8fb87a;
  --weighted: #d9a05b;

  --c0: #5d8fb8;
  --c1: #6fa8a0;
  --c2: #8c8fc4;
  --c3: #b58aa8;
  --c4: #7f9ec4;
  --c5: #96a7b8;

  --same: #8fb87a;
  --apart: #d9a05b;
  --far: #cf7f6d;
  --radius: 11px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 14px calc(30px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.62 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", "Noto Sans SC", "PingFang SC", sans-serif;
  overflow-wrap: anywhere;
}
main { max-width: 800px; margin: 0 auto; }

.topbar {
  max-width: 800px; margin: 0 auto; padding: 22px 0 14px;
  display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 13px; align-items: start;
}
.brand {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(160deg, var(--bar) 0%, #33587a 100%);
  color: #0a1219; font-size: 21px; font-weight: 700; line-height: 1;
}
.titles h1 { margin: 0; font-size: 21px; letter-spacing: -0.01em; line-height: 1.25; }
.titles p { margin: 4px 0 0; color: var(--dim); font-size: 14px; }

.panel, .block, .findings {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 14px 0;
}
.panel h2 { margin: 0 0 9px; font-size: 15px; }
h3 { margin: 0 0 8px; font-size: 14.5px; }
.sub { margin: 0 0 10px; color: var(--dim); font-size: 14px; }
.sub:last-child { margin-bottom: 0; }
.tiny { margin: 10px 0 0; color: var(--faint); font-size: 12.5px; line-height: 1.55; }
.cap { margin: 10px 0 0; color: var(--faint); font-size: 12.5px; line-height: 1.55; }
.quiet { background: transparent; }
code {
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}

/* The identity the page is built on, given room to be looked at. */
.formula {
  margin: 12px 0; padding: 14px; text-align: center;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); font-size: 13.5px; line-height: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
}
.formula .second { color: var(--weighted); font-size: 12.5px; }

/* ------------------------------------------------------------------ form */

.egs { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 14px; }
.eg {
  cursor: pointer; font: inherit; font-size: 12.5px;
  background: var(--panel2); color: var(--dim);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px;
}
.eg:hover { color: var(--ink); border-color: var(--faint); }
.eg:focus-visible, input:focus-visible, textarea:focus-visible, .go:focus-visible {
  outline: 2px solid var(--bar); outline-offset: 2px;
}
.go {
  display: block; width: 100%; margin-top: 14px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 650;
  background: var(--bar); color: #0a1219;
  border: 0; border-radius: 9px; padding: 11px;
}

.fields {
  display: grid; gap: 9px; margin-bottom: 4px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.fl { display: grid; gap: 4px; min-width: 0; }
.fl span { color: var(--dim); font-size: 12.5px; }
.fl input, textarea {
  width: 100%; min-width: 0;
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px;
  font: 13.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
textarea { resize: vertical; line-height: 1.7; font-size: 12.5px; padding: 10px; }
.lbl { display: block; margin: 4px 0 7px; color: var(--dim); font-size: 13.5px; line-height: 1.55; }

/* --------------------------------------------------------------- verdict */

.verdict {
  border: 1px solid var(--line); border-left: 4px solid var(--bar);
  border-radius: var(--radius); background: var(--panel2); padding: 15px 16px; margin: 14px 0;
}
.verdict > b { display: block; font-size: 20px; line-height: 1.3; }
.verdict .say { margin: 8px 0 0; color: var(--dim); font-size: 13.5px; }
.verdict.same { border-left-color: var(--same); }
.verdict.apart { border-left-color: var(--apart); }
.verdict.far { border-left-color: var(--far); }

.findings { padding: 4px 16px; }
.finding { border-top: 1px solid var(--line); padding: 13px 0; }
.finding:first-child { border-top: 0; }
.finding > b { display: block; font-size: 14.5px; }
.finding > p { margin: 5px 0 0; color: var(--dim); font-size: 13.5px; }
.finding.same > b { color: var(--same); }
.finding.apart > b { color: var(--apart); }
.finding.far > b { color: var(--far); }

/* -------------------------------------------------------------- the chart */

svg.mek { display: block; width: 100%; max-width: 580px; height: auto; margin: 8px auto 2px; }
.grid { stroke: var(--line); stroke-width: 1; }
.ax { fill: var(--faint); font-size: 10px; font-family: inherit; }

/* One colour family for the rectangles: they are all the same kind of thing,
   and giving each its own hue would suggest a difference that is not there. */
.mk { fill-opacity: 0.6; stroke: var(--panel); stroke-width: 0.8; }
.mk.c0 { fill: var(--c0); }
.mk.c1 { fill: var(--c1); }
.mk.c2 { fill: var(--c2); }
.mk.c3 { fill: var(--c3); }
.mk.c4 { fill: var(--c4); }
.mk.c5 { fill: var(--c5); }

.avg { stroke-width: 2; }
.avg.plain { stroke: var(--plain); }
.avg.weighted { stroke: var(--weighted); stroke-dasharray: 5 3; }
.alab {
  font-size: 10px; font-family: inherit; font-weight: 650;
  paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round;
}
.alab.plain { fill: var(--plain); }
.alab.weighted { fill: var(--weighted); }

.legend { display: flex; flex-wrap: wrap; gap: 5px 13px; margin-top: 10px; }
.legend .li { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; }
i.k { width: 14px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
i.k.plain { background: var(--plain); }
i.k.weighted { background: var(--weighted); }

i.sw {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
  display: inline-block; margin-right: 6px; vertical-align: -1px; opacity: 0.6;
}
i.sw.c0 { background: var(--c0); }
i.sw.c1 { background: var(--c1); }
i.sw.c2 { background: var(--c2); }
i.sw.c3 { background: var(--c3); }
i.sw.c4 { background: var(--c4); }
i.sw.c5 { background: var(--c5); }

/* ------------------------------------------------------------- the tables */

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
table.t th, table.t td {
  padding: 8px 9px; border-bottom: 1px solid var(--line); text-align: right;
}
table.t thead th { color: var(--faint); font-weight: 600; font-size: 11.5px; }
/* A floor on this column: `white-space: normal` without one lets a narrow
   scroll container squeeze it to one character per line — taller, not wider,
   so no overflow check ever sees it. */
table.t th.ln { text-align: left; font-weight: 600; white-space: normal; min-width: 128px; }
table.t td { font-variant-numeric: tabular-nums; color: var(--dim); }
table.t td.amt { color: var(--ink); font-weight: 600; }
table.t tr.base { background: rgba(93, 143, 184, 0.10); }
table.t tr.foot th.ln, table.t tr.foot td { color: var(--weighted); border-bottom: 0; }
table.t tr.foot td.amt { color: var(--weighted); }

/* ------------------------------------------------------------------ lists */

.panel.bad { border-color: var(--far); }
.badlist { margin: 0; padding-left: 18px; color: var(--dim); font-size: 13px; }
.badlist li { margin: 6px 0; }
.badlist b { color: var(--ink); }

.foot {
  max-width: 800px; margin: 22px auto 0; padding-top: 14px;
  border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px;
}
