/*
 * The one stylesheet of the site. The look is a reference desk: paper and ink, rules
 * instead of boxes, dense where the page shows data, roomy where it explains.
 *
 * - No web font: two system stacks, a serif for reading and a sans for data and controls.
 * - Light and dark follow the visitor's setting. Each color pair below was checked
 *   for contrast (4.5:1 for text, 3:1 for borders of controls, focus rings and chart lines).
 * - No inline style anywhere: the Content-Security-Policy refuses it. A state is a class,
 *   an attribute or `hidden`.
 * - Sizes are in rem, so the page follows the reader's font size and zooms to 200%.
 */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  --paper: #fbfaf5;
  --paper-2: #f3f1ea;
  --rule: #d7d4cc;
  --rule-strong: #726e65;
  --ink: #1b1f29;
  --ink-2: #4a505b;
  --link: #14488f;
  --visited: #5d3270;
  --warn-ink: #573400;
  --warn-bg: #fbecc7;
  --warn-rule: #a67628;
  --error: #9b1f1b;
  --focus: #005ccc;
  --series-1: #14488f;
  --series-2: #a13029;
  --series-3: #13684b;
  --series-4: #7e5403;
  /* The shadow at the edge of a table that scrolls sideways: a hint beside the scrollbar, not text. */
  --edge: rgb(27 31 41 / 0.3);

  --font-read: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  --font-data: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;

  --gap-1: 0.25rem;
  --gap-2: 0.5rem;
  --gap-3: 0.75rem;
  --gap-4: 1rem;
  --gap-5: 1.5rem;
  --gap-6: 2.5rem;
  --gap-7: 4rem;

  /* A reading line of about 80 characters in the serif at its size. */
  --measure: 38rem;
  --measure-data: 50rem;
  --target: 2.75rem;
}

/* On screen only: a page printed from a dark screen is still ink on paper. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1217;
    --paper-2: #191c22;
    --rule: #2d3038;
    --rule-strong: #767a84;
    --ink: #e6e4df;
    --ink-2: #b4b1a9;
    --link: #91c3f6;
    --visited: #ceabde;
    --warn-ink: #eed59b;
    --warn-bg: #332710;
    --warn-rule: #a67f38;
    --error: #f69c90;
    --focus: #80c3ff;
    --series-1: #91c3f6;
    --series-2: #ef9687;
    --series-3: #7ecaa9;
    --series-4: #dbb970;
    --edge: rgb(255 255 255 / 0.24);
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-data);
  line-height: 1.5;
  /* A link the focus scrolls into view stops short of the edge of the window by more than its ring. */
  scroll-padding-block: var(--gap-2);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--font-read);
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-top: var(--gap-6);
  margin-bottom: var(--gap-3);
}

h3 {
  font-family: var(--font-data);
  font-size: 1rem;
  font-weight: 700;
  margin-top: var(--gap-5);
  margin-bottom: var(--gap-1);
}

p,
ul,
ol,
figure {
  margin: 0;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.18em;
}

a:visited {
  color: var(--visited);
}

a:hover {
  text-decoration-thickness: 0.125em;
}

:focus-visible {
  outline: 0.1875rem solid var(--focus);
  outline-offset: 0.125rem;
  border-radius: 0.125rem;
}

/* The target of the skip link takes focus without a ring: it is not a control. */
main:focus {
  outline: none;
}

time,
.num,
.stat-number,
.result-number {
  font-variant-numeric: lining-nums tabular-nums;
}

abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
}

var {
  font-family: var(--font-read);
}

/* ---------- Frame: skip link, header, breadcrumbs, footer ---------- */

.wrap {
  width: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

body > .wrap {
  flex: 1 0 auto;
}

.skip-link {
  position: absolute;
  left: var(--gap-2);
  top: var(--gap-2);
  z-index: 1;
  padding: var(--gap-2) var(--gap-4);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:visited {
  color: var(--paper);
}

.skip-link:focus {
  transform: none;
}

/* The double rule of a ledger closes the header; the same rule marks a result. */
.site-header {
  border-bottom: 0.1875rem double var(--ink);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--gap-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  font-family: var(--font-read);
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  text-decoration: none;
}

.brand,
.brand:visited {
  color: var(--ink);
}

.brand:hover {
  text-decoration: underline;
}

.topic-nav ul,
.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--gap-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-nav a,
.footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  font-size: 0.9375rem;
  text-decoration: none;
}

.topic-nav a,
.topic-nav a:visited {
  color: var(--ink);
}

.topic-nav a:hover,
.footer-nav a:hover {
  text-decoration: underline;
}

/* The topic the page belongs to: heavier and underlined, not only another color. */
.topic-nav a[aria-current] {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 0.125em;
  text-underline-offset: 0.35em;
}

/*
 * A phone: the name on one line and the topics on the next, spread across the width, so
 * the header takes two lines and not three. On a screen too narrow for that the topics
 * wrap as before.
 */
@media (max-width: 40rem) {
  .topic-nav {
    flex: 1 0 100%;
  }

  .topic-nav ul {
    justify-content: space-between;
    column-gap: var(--gap-2);
  }

  .topic-nav a {
    font-size: 0.875rem;
  }

  /* The page a reader is on is the heading right below: the trail ends at its parent. */
  .breadcrumbs li[aria-current] {
    display: none;
  }
}

/* The narrowest phones: the five topics still stand on one line, a little smaller and closer. */
@media (max-width: 22rem) {
  .topic-nav ul {
    column-gap: var(--gap-1);
  }

  .topic-nav a {
    font-size: 0.8125rem;
  }
}

.breadcrumbs {
  margin-top: var(--gap-3);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
}

.breadcrumbs li + li::before {
  content: "/";
  margin-inline: var(--gap-2);
  color: var(--ink-2);
}

.site-footer {
  flex: none;
  margin-top: var(--gap-7);
  padding-block: var(--gap-4) var(--gap-5);
  border-top: 0.0625rem solid var(--rule);
  background: var(--paper-2);
  font-size: 0.875rem;
}

.site-footer .notice {
  margin-top: var(--gap-2);
  padding-top: var(--gap-3);
}

.footer-brand {
  margin-top: var(--gap-2);
  color: var(--ink-2);
}

/* ---------- Page ---------- */

.page {
  padding-top: var(--gap-5);
}

.page > h1 {
  max-width: var(--measure);
  margin-bottom: var(--gap-5);
}

.breadcrumbs + .page {
  padding-top: var(--gap-3);
}

/*
 * Below the opening of a page: what is read, in one column, and the rail (the outline of
 * the page, the related pages). A narrow screen reads the column and then the related
 * pages; it has no outline. A wide screen sets the rail beside the column, where a
 * reading line leaves the page empty, and keeps it in view while the column scrolls.
 * Wide is 68rem, the width at which the page stops growing: the column beside the rail
 * is then 47.5rem at every width, which the widest table of the site needs. Set beside
 * a narrower column, the rail would make that table scroll sideways.
 */
.toc {
  display: none;
}

@media (min-width: 68rem) {
  .page-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 14rem;
    column-gap: var(--gap-6);
    align-items: start;
  }

  .page-rail {
    position: sticky;
    top: var(--gap-4);
    max-height: calc(100vh - 2 * var(--gap-4));
    overflow-y: auto;
    margin-top: var(--gap-6);
    /*
     * A box that scrolls clips what reaches its edge: the right and the bottom leave room for
     * the focus ring of a link, and a link the focus scrolls into view stops short of the top
     * or the bottom by more than its ring.
     */
    padding: 0 0.375rem 0.375rem var(--gap-5);
    scroll-padding-block: var(--gap-2);
    border-left: 0.0625rem solid var(--rule);
    font-size: 0.875rem;
  }

  .toc {
    display: block;
  }

  .page-rail h2 {
    margin: 0;
    padding-bottom: var(--gap-1);
    border-bottom: 0.0625rem solid var(--ink);
    font-family: var(--font-data);
    font-size: 0.875rem;
  }

  .toc ul {
    margin: var(--gap-2) 0 0;
    padding: 0;
    list-style: none;
  }

  .toc a,
  .page-rail .layer-group a,
  .page-rail .layers-hub a {
    display: block;
    padding-block: var(--gap-1);
    font-weight: 400;
    text-decoration: none;
  }

  .toc a,
  .toc a:visited {
    color: var(--ink);
  }

  .toc a:hover,
  .page-rail .layer-group a:hover,
  .page-rail .layers-hub a:hover {
    text-decoration: underline;
  }

  /* In the rail the related pages are a list of names: what each page holds is said where the reader arrives. */
  .page-rail .layers {
    margin-top: var(--gap-5);
  }

  .page-rail .layer-groups {
    display: block;
    margin-top: var(--gap-2);
  }

  .page-rail .layer-group + .layer-group {
    margin-top: var(--gap-3);
  }

  .page-rail .layer-group h3 {
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink-2);
  }

  .page-rail .layer-group li {
    padding-block: 0;
  }

  .page-rail .link-note {
    display: none;
  }

  .page-rail .layers-hub {
    margin-top: var(--gap-3);
    font-size: inherit;
  }
}

/* Explanations are set for reading: a serif, a short line, room between paragraphs. */
.prose {
  max-width: var(--measure);
  font-family: var(--font-read);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.prose > * + * {
  margin-top: var(--gap-4);
}

.prose > h2 {
  margin-top: var(--gap-6);
}

.prose > h3 {
  margin-top: var(--gap-5);
}

.prose > :first-child {
  margin-top: 0;
}

/* Running text avoids a last line of one word. Set where text is read, not on everything: it costs layout time. */
.prose p,
.prose li,
.faq-item p {
  text-wrap: pretty;
}

section.prose,
.figures,
.validation,
.sources,
.faq,
.layers,
.headlines,
.topics,
.tool-index,
.front-body {
  margin-top: var(--gap-6);
}

/* Today's numbers where they follow a calculator: the heading, then the first group right under it. */
.figures > h2 {
  margin-top: 0;
}

.figures > h2 + .stale-scope {
  margin-top: 0;
}

/* A part of today's numbers with a name of its own: a heading one level below "Latest figures". */
.figures h3 {
  margin-top: var(--gap-5);
  margin-bottom: var(--gap-3);
  font-family: var(--font-read);
  font-size: 1.125rem;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: var(--gap-2);
}

.prose math {
  font-size: 1.0625em;
}

.prose .table-wrap {
  font-family: var(--font-data);
}

.validation > p,
.faq-item,
.sources > p {
  max-width: var(--measure);
}

.validation > p,
.faq-item p {
  font-family: var(--font-read);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.validation .table-block {
  margin-top: var(--gap-4);
}

/*
 * The two figures of a check are long with their unit ("99.843952 dollars per 100 par"): kept
 * on one line each they took two thirds of the table and left the description of the check a
 * column of two words, and with wider type the table outgrew its column. So a long unit wraps
 * under its number, at any width, and the description takes the room. The lines of a figure
 * are of like length where the browser can balance them, so no unit ends in a word alone.
 */
.validation table .num {
  white-space: normal;
  text-wrap: balance;
}

/*
 * On a narrow page the validation table is wider than the page and scrolls sideways, so every
 * column would be as narrow as its longest word. The description of the check keeps two fifths
 * of the scroll region, which leaves the two numbers in view beside it.
 */
@media (max-width: 30rem) {
  .validation tbody th {
    min-width: 40cqi;
  }
}

/* ---------- The answer: numbers of the day ---------- */

.stat-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--gap-5) var(--gap-6);
}

.stat-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.stat-value {
  margin-top: var(--gap-1);
  line-height: 1.05;
}

.stat-number {
  font-size: clamp(2.5rem, 1.9rem + 2.6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-unit {
  font-size: 1.25rem;
  font-weight: 600;
  margin-left: 0.125em;
}

/* One line under the number, for example the range a rate belongs to. */
.stat-note {
  margin-top: var(--gap-2);
  font-size: 0.9375rem;
}

.stat-meta {
  margin-top: var(--gap-2);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.stale-flag {
  margin-top: var(--gap-2);
  padding: var(--gap-2) var(--gap-3);
  max-width: var(--measure);
  border: 0.0625rem solid var(--warn-rule);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.875rem;
}

.stale-scope {
  margin-top: var(--gap-5);
}

/* The as-of line that ends a scope made of a table and no stat: a sentence, so it wraps at the width of one. */
.stale-scope > .stat-meta {
  max-width: var(--measure);
}

/* A sentence that opens a further group of numbers in the answer block, and the group under it. */
.stale-scope + .note {
  margin-top: var(--gap-5);
}

.note + .stat-group {
  margin-top: var(--gap-3);
}

.headlines .stat-group {
  padding-block: var(--gap-4);
  border-block: 0.0625rem solid var(--rule);
}

/*
 * Numbers of one publication: the date, the source and the stale flag are said once, under
 * all of them, across the width of the group.
 */
.stat-group-shared {
  row-gap: var(--gap-2);
}

.stat-group-shared > .stat-meta,
.stat-group-shared > .stale-flag {
  grid-column: 1 / -1;
  margin-top: 0;
}

.headline-terms {
  margin-top: var(--gap-3);
}

/* ---------- Home and hubs: the lede, today's numbers, the tools, the copy ---------- */

/*
 * A phone reads the page in the order it is written: the lede, the numbers, the tools, the
 * copy. A wide screen sets the numbers in a column of their own beside the other three, so
 * the first screen holds both what the site says today and every page a reader can go to
 * (decision 58).
 */

/* The numbers answer to the width of their own column, not to the width of the screen. */
.front > .headlines,
.answer-lead {
  container: numbers / inline-size;
}

/* A container does not let the margin of its heading out, so the heading has none. */
.front > .headlines > h2 {
  margin-top: 0;
}

/* In a narrow column the numbers are a board: one row each, the name on the left, the value on the right. */
@container numbers (max-width: 30rem) {
  .stat-group {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-block: 0;
  }

  .stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--gap-4);
    align-items: baseline;
    padding-block: var(--gap-3);
  }

  .stat + .stat {
    border-top: 0.0625rem solid var(--rule);
  }

  .stat-value {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    text-align: right;
    white-space: nowrap;
  }

  .stat-number {
    font-size: 2rem;
  }

  .stat-unit {
    font-size: 1rem;
  }

  .stat-note,
  .stat-meta,
  .stat > .stale-flag {
    grid-column: 1 / -1;
    margin-top: var(--gap-1);
  }

  /* The rows of a shared group stand closer: none of them holds a date line. */
  .stat-group-shared > .stat {
    padding-block: var(--gap-2);
  }

  .stat-group-shared > .stat-meta {
    margin-top: 0;
  }

  .stat-group-shared > .stale-flag {
    margin-top: var(--gap-2);
  }
}

/* The numbers of a phone start close under the lede: they are what the page opens with. */
.front > .front-lede + .headlines {
  margin-top: var(--gap-5);
}

@media (min-width: 64rem) {
  .page-home > h1,
  .page-hub > h1 {
    max-width: none;
  }

  /* A tool's name stands over the inputs and the result together, so it takes their width. */
  .page-tool > h1 {
    max-width: none;
  }

  /* The last row takes what the numbers need beyond the lede and the index, so those two stay close. */
  .front:has(> .headlines) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 21rem);
    grid-template-rows: auto auto 1fr;
    column-gap: var(--gap-6);
    align-items: start;
  }

  .front:has(> .headlines) > * {
    grid-column: 1;
  }

  .front:has(> .headlines) > .front-lede + .headlines {
    grid-column: 2;
    grid-row: 1 / -1;
    margin-top: 0;
  }

  .front:has(> .headlines) > .tool-index {
    margin-top: var(--gap-5);
  }
}

/*
 * The index of tools: every page a reader can go to. Rules and no boxes, as in the index
 * of a reference book: a heavy rule opens it, a light one closes each entry or each topic.
 * A hub says what each of its few pages holds. The home page names every page of the site
 * under its topic, the kind of page in a column before the name, so that all of them are
 * on the first screen.
 */
.tool-index > h2 {
  margin: 0;
  padding-bottom: var(--gap-2);
  border-bottom: 0.125rem solid var(--ink);
}

.index-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  column-gap: var(--gap-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.index-list > li {
  padding-block: var(--gap-3);
  border-bottom: 0.0625rem solid var(--rule);
}

.index-layer {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
}

.index-link {
  font-family: var(--font-read);
  font-size: 1.0625rem;
  font-weight: 700;
}

.index-children {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--gap-3);
  align-items: center;
  margin-top: var(--gap-1);
  font-size: 0.875rem;
}

.index-children a {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  font-weight: 600;
}

.index-topic {
  padding-block: var(--gap-3);
  border-bottom: 0.0625rem solid var(--rule);
}

.index-topic > h3 {
  margin: 0;
  padding-block: var(--gap-1);
  font-family: var(--font-read);
  font-size: 1.0625rem;
}

.tool-index-compact .index-list {
  display: block;
}

/* One line per page: the kind of page, then its name. The line is tall enough to be tapped. */
.tool-index-compact .index-list > li {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  column-gap: var(--gap-3);
  align-items: baseline;
  padding-block: 0;
  border-bottom: 0;
}

.tool-index-compact .index-layer {
  grid-column: 1;
  font-weight: 400;
}

.tool-index-compact .index-link {
  grid-column: 2;
  padding-block: 0.4375rem;
  font-family: var(--font-data);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.tool-index-compact .index-children {
  grid-column: 2;
  margin-top: 0;
  margin-bottom: var(--gap-1);
}

/* From the width of a large phone held sideways the name of the topic stands in a column of its own. */
@media (min-width: 36rem) {
  .index-topic {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    column-gap: var(--gap-4);
    align-items: baseline;
  }
}

/* ---------- Tool: inputs and result ---------- */

/*
 * The inputs and the result are what a reader came for, so they open the page (decision
 * 58): right under the heading, or under the lead numbers of a page that has them. The
 * double rule of the header closes the block; what explains the result starts below it.
 */
.page-tool > .answer:has(.tool) {
  padding-bottom: var(--gap-6);
  border-bottom: 0.1875rem double var(--ink);
}

/*
 * A phone reads the tool in the order it is written: the answer to the inputs as they
 * stand, the inputs, then the tables behind the answer. So the answer is on the first
 * screen, and the inputs right under it say what it is an answer to.
 */
.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--gap-4);
}

/* Under lead numbers: a rule between the numbers and the inputs. */
.answer-lead + .tool {
  margin-top: var(--gap-5);
  padding-top: var(--gap-5);
  border-top: 0.0625rem solid var(--rule);
}

/*
 * A wide screen sets the inputs in a column on the left and, beside them, the answer and
 * the tables. A note about the inputs (no script, or the tool did not load) stands above
 * the answer. The last row takes the height the inputs need beyond the answer, so the
 * tables start right under the answer however long the inputs are.
 */
@media (min-width: 52rem) {
  .tool {
    grid-template-columns: minmax(16rem, 21rem) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: var(--gap-6);
    row-gap: 0;
    align-items: start;
  }

  .tool > * {
    grid-column: 2;
    grid-row: 1;
  }

  .tool > .tool-form {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  .tool > .tool-result {
    grid-row: 2;
  }

  .tool > .tool-tables {
    grid-row: 3;
  }

  /* Beside the inputs the tables stand right under the result, and the flag of the result speaks for the column. */
  .tool-tables > .stale-flag {
    display: none;
  }

  .tool > noscript > .note,
  .tool > .note {
    margin-bottom: var(--gap-3);
  }
}

.tool-fields {
  min-width: 0;
  margin: 0;
  padding: var(--gap-4);
  border: 0.0625rem solid var(--rule);
  background: var(--paper-2);
}

/*
 * The legend is the first line inside the box. A legend left where a browser puts it sits
 * on the border of the box, and one of two lines then straddles it, half outside. Floated,
 * it is laid out as a block of the box's content.
 */
.tool-fields legend {
  float: left;
  width: 100%;
  margin-bottom: var(--gap-3);
  padding: 0;
  font-weight: 700;
  line-height: 1.3;
}

.tool-fields legend + * {
  clear: both;
}

/*
 * In the box of inputs every field takes the box's width, so the fields line up at both
 * edges and a list shows as much of its choice as the box allows. On a tablet, where the
 * box spans the page, they stop at a width a value needs.
 */
.tool-fields .field input:not([type="checkbox"]),
.tool-fields .field select {
  max-width: 24rem;
}

@media (min-width: 52rem) {
  .tool-fields .field input:not([type="checkbox"]),
  .tool-fields .field select {
    max-width: none;
  }
}

.field + .field {
  margin-top: var(--gap-4);
}

.field label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
}

.field-unit {
  font-weight: 400;
  color: var(--ink-2);
}

.field input,
.field select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 0.0625rem solid var(--rule-strong);
  border-radius: 0.125rem;
}

.field input:not([type="checkbox"]),
.field select {
  display: block;
  width: 100%;
  max-width: 16rem;
  min-height: var(--target);
  margin-top: var(--gap-1);
  padding: var(--gap-2) var(--gap-3);
  font-variant-numeric: lining-nums tabular-nums;
}

.field [aria-invalid="true"] {
  border: 0.125rem solid var(--error);
}

.check-row {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: var(--target);
}

.check-row input {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--link);
}

.check-row label {
  font-weight: 400;
}

.field-hint {
  margin-top: var(--gap-1);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.field-error {
  margin-top: var(--gap-1);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--error);
}

.field-error:empty {
  display: none;
}

/* Reset, copy the link, and what the copying reports: in a row, wrapping where the box is narrow. */
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  margin-top: var(--gap-4);
}

.tool-actions > .copy-status {
  flex-basis: 100%;
  font-size: 0.875rem;
}

/* Empty, the line stays in the page, so that what it says later is announced; it gives back the gap of its row. */
.tool-actions > .copy-status:empty {
  margin-top: calc(-1 * var(--gap-2));
}

.button-quiet {
  min-height: var(--target);
  padding: var(--gap-2) var(--gap-4);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 0.0625rem solid var(--rule-strong);
  border-radius: 0.125rem;
  cursor: pointer;
}

.button-quiet:hover {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 0.0625rem var(--ink);
}

/* Until the inputs are switched on they read as off: dashed, and no pointer. */
.tool-fields:disabled input,
.tool-fields:disabled select,
.tool-fields:disabled .button-quiet {
  border-style: dashed;
  cursor: not-allowed;
}

.tool-fields:disabled .button-quiet:hover {
  border-color: var(--rule-strong);
  box-shadow: none;
}

.note {
  max-width: var(--measure);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.tool-result,
.tool-tables,
.tool-detail {
  min-width: 0;
}

/*
 * On a narrow screen the inputs stand between the result and the tables behind it, so the
 * tables say themselves that they may rest on a late number, before their first line.
 * With no table there is nothing to flag.
 */
.tool-tables > .stale-flag {
  margin-top: 0;
}

.tool-tables:has(> .tool-detail:empty) > .stale-flag {
  display: none;
}

/* What the result rests on, right under it: the date of the data and its source. */
.tool-result > .result-basis {
  margin-top: var(--gap-2);
  max-width: var(--measure);
}

/* Beside the inputs the result has a column of its own: the sentence, the notes and the tables all end at its edge. */
@media (min-width: 52rem) {
  .tool-result .result-line,
  .tool-result .result-basis,
  .tool-result .note,
  .tool-result .stale-flag,
  .tool-detail .note,
  .tool-detail .table-block,
  .tool-detail .chart {
    max-width: none;
  }
}

/* The result no longer matches the inputs: said in words, set as a caution. */
.tool-result > .note {
  margin-bottom: var(--gap-3);
  padding: var(--gap-2) var(--gap-3);
  border: 0.0625rem solid var(--warn-rule);
  background: var(--warn-bg);
  color: var(--warn-ink);
}

/* The result rests on a number that may be late: said right under the result. */
.tool-result > .stale-flag {
  margin-top: var(--gap-3);
}

.result-line {
  max-width: var(--measure);
  font-size: 1.0625rem;
}

/* A result is ruled twice, like the total of a column of figures. */
.result-number {
  display: inline-block;
  margin-right: var(--gap-2);
  padding-bottom: 0.0625rem;
  border-bottom: 0.1875rem double currentColor;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

/* A punctuation mark right after the figure sits against it; only a word keeps the space. */
.result-number-before-punctuation {
  margin-right: 0;
}

/* The figure and the mark after it stay on one line: a comma never starts a line. */
.result-number-with-mark {
  white-space: nowrap;
}

.tool-detail:not(:empty) {
  margin-top: var(--gap-5);
}

/* Older data is on its way: the table and chart of the last answer keep their
   place, so the page does not jump, and are not shown beside a sentence that
   says another answer is coming. */
.tool-detail[aria-busy="true"] {
  visibility: hidden;
}

/* ---------- Tables ---------- */

/*
 * A table or a chart is as wide as the reading line, so it ends where the text above and
 * the note below end. A table of five columns or more needs the room and takes up to the
 * data width (`table-wide`, set in site/shared/data-table.ts).
 */
.table-block,
.chart {
  max-width: var(--measure);
}

.table-block.table-wide {
  max-width: var(--measure-data);
}

/* A table after another table, after a chart, or after a note in a result begins a new group: its caption stands clear of what is above. */
.table-block + .table-block,
.chart + .table-block,
.tool-detail > .note + .table-block {
  margin-top: var(--gap-5);
}

/* A sentence that leads into a table: the caption stands clear of it. */
.stale-scope > p + .table-block {
  margin-top: var(--gap-4);
}

/* The same in the block that says how a fund's model was measured: its sentence leads into its table. */
#model-measurement > p + .table-block {
  margin-top: var(--gap-4);
}

/* Notes that follow one another under a result are paragraphs: a gap in proportion to their smaller type. */
.tool-detail > .note + .note {
  margin-top: var(--gap-3);
}

/* The same under an answer: its second note is a paragraph of its own. The first note stays close under the result line. */
.tool-answer > .note + .note {
  margin-top: var(--gap-3);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  /* The caption measures itself against the scroll region (see below), and a narrow region restyles its table. */
  container-type: inline-size;
  /*
   * A table wider than its region: a shadow at each edge that has more table beyond it. The
   * shadows stay at the edges of the region; a cover in the color of the paper scrolls with
   * the table and hides each shadow at its own end. No script, and nothing when the table fits.
   */
  background:
    linear-gradient(to right, var(--paper) 40%, transparent) left / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--paper) 40%, transparent) right / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--edge), transparent) left / 0.875rem 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, var(--edge), transparent) right / 0.875rem 100% no-repeat;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  border-block: 0.125rem solid var(--ink);
  font-size: 0.9375rem;
}

.table-wrap caption {
  padding-bottom: var(--gap-2);
  text-align: left;
  font-weight: 700;
  /* A table wider than its scroll region: the caption wraps at the width of the region and stays in view while the table scrolls. */
  max-inline-size: 100cqi;
  position: sticky;
  inset-inline-start: 0;
}

.table-wrap th,
.table-wrap td {
  padding: var(--gap-2) var(--gap-4) var(--gap-2) 0;
  text-align: left;
  vertical-align: baseline;
  border-bottom: 0.0625rem solid var(--rule);
}

.table-wrap th:last-child,
.table-wrap td:last-child {
  padding-right: 0;
}

.table-wrap thead th {
  border-bottom: 0.0625rem solid var(--ink);
  font-weight: 700;
  vertical-align: bottom;
}

.table-wrap tbody th {
  font-weight: 600;
}

.table-wrap tbody:last-child tr:last-child > * {
  border-bottom: 0;
}

/* A long table: the rows after the first ones show once the "Show all rows" checkbox is ticked. */
.rows-more {
  display: none;
}

.table-block:has(.rows-toggle:checked) .rows-more {
  display: table-row-group;
}

/* A browser that cannot tell whether the checkbox is ticked shows every row and no checkbox. */
@supports not selector(:has(*)) {
  .rows-more {
    display: table-row-group;
  }

  .table-actions .check-row {
    display: none;
  }
}

.table-wrap .num {
  text-align: right;
  white-space: nowrap;
}

/* The heading of a column of figures wraps before the table grows wider than its region; the figures never do. */
.table-wrap thead th.num {
  white-space: normal;
}

/*
 * A table of two columns, a name and its value: the value keeps room for a date or a short
 * phrase on one line, and the name, which is the longer text, wraps instead.
 */
.table-wrap tbody tr > :first-child:nth-last-child(2) + td:not(.num) {
  min-width: min(10.5rem, 45cqi);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-2) var(--gap-4);
  min-height: var(--target);
  margin-top: var(--gap-2);
  font-size: 0.875rem;
}

.copy-status {
  color: var(--ink-2);
}

/*
 * A narrow region: a phone, or the result column beside a calculator's inputs. The table answers
 * to the width of its own scroll region, not to the width of the screen. It keeps its columns
 * where it can: smaller type, narrower gaps, and headings that wrap (hyphenated where a word is
 * long), so most tables fit the width without scrolling. A table too wide for that is stacked
 * (`stack` in site/shared/data-table.ts): each row is a block, its header first, then every
 * other cell after the name of its column, which the markup carries.
 */
@container (max-width: 37rem) {
  .table-wrap table {
    font-size: 0.8125rem;
  }

  .table-wrap th,
  .table-wrap td {
    padding-right: var(--gap-2);
  }

  .table-wrap thead th {
    hyphens: auto;
  }

  .table-stack thead {
    display: none;
  }

  .table-stack table,
  .table-stack caption,
  .table-stack tbody,
  .table-stack tr,
  .table-stack th,
  .table-stack td {
    display: block;
  }

  /* The heavy rule that tops a table sits under its caption, as it does where the table keeps its columns. */
  .table-stack table {
    border-top: 0;
  }

  .table-stack caption {
    border-bottom: 0.125rem solid var(--ink);
  }

  .table-stack tbody tr {
    padding-block: var(--gap-3);
    border-bottom: 0.0625rem solid var(--rule);
  }

  .table-stack tbody:last-child tr:last-child {
    border-bottom: 0;
  }

  .table-stack th,
  .table-stack td {
    padding: 0;
    border-bottom: 0;
  }

  .table-stack td {
    margin-top: var(--gap-1);
  }

  .table-stack .num {
    text-align: left;
    white-space: normal;
  }

  .table-stack td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
  }

  .table-stack .rows-more {
    display: none;
  }

  .table-stack:has(.rows-toggle:checked) .rows-more {
    display: block;
  }

  @supports not selector(:has(*)) {
    .table-stack .rows-more {
      display: block;
    }
  }
}

/* ---------- Charts ---------- */

/* The last label of the axis is centered on its tick and reaches past the plot: room for it. */
.chart {
  padding-right: var(--gap-3);
}

.chart-title {
  font-weight: 700;
  font-size: 0.9375rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-1) var(--gap-5);
  margin: var(--gap-2) 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
}

.chart-key {
  flex: none;
  overflow: visible;
}

.chart-svg {
  display: block;
  max-width: 100%;
  margin-top: var(--gap-2);
  overflow: visible;
  color: var(--ink-2);
  font-family: var(--font-data);
  font-variant-numeric: lining-nums tabular-nums;
}

.chart-s1 {
  color: var(--series-1);
}

.chart-s2 {
  color: var(--series-2);
}

.chart-s3 {
  color: var(--series-3);
}

.chart-s4 {
  color: var(--series-4);
}

/* A band behind the lines: a faint fill between two thin edges, in the color of the axis. */
.chart-band,
.chart-band-edge {
  color: var(--ink-2);
}

/*
 * A narrow chart keeps the first and last label of its axis and drops the ones
 * between; its labels are set a size smaller so that they clear the plot.
 */
@media (max-width: 30rem) {
  .chart-x-minor {
    display: none;
  }

  .chart-x-label,
  .chart-y-label {
    font-size: 0.6875rem;
  }
}

/* ---------- Sources, related pages, lists of pages ---------- */

.source-list,
.page-list,
.layer-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-list,
.page-list {
  max-width: var(--measure);
  border-top: 0.0625rem solid var(--rule);
}

/* The related pages, where they close a page on a narrow screen: read at the width of the text. */
.page-rail .layer-groups {
  max-width: var(--measure-data);
}

.source,
.page-list li {
  padding-block: var(--gap-3);
  border-bottom: 0.0625rem solid var(--rule);
}

.source-name,
.source > a,
.page-list a,
.layer-group a {
  font-weight: 600;
}

.source-meta,
.link-note {
  display: block;
  margin-top: var(--gap-1);
  font-size: 0.875rem;
  color: var(--ink-2);
}

/* Notices a publisher's terms require next to its data. */
.source-notices {
  max-width: var(--measure);
  margin-top: var(--gap-4);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.source-notices p + p {
  margin-top: var(--gap-2);
}

.layer-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--gap-4) var(--gap-6);
}

.layer-group h3 {
  margin-top: 0;
  padding-bottom: var(--gap-1);
  border-bottom: 0.0625rem solid var(--ink);
}

.layer-group li {
  padding-block: var(--gap-2);
}

.layers-hub {
  margin-top: var(--gap-4);
  font-size: 0.9375rem;
}

/* ---------- Reserved ad slot, notice ---------- */

/*
 * The space is reserved at a fixed size, so that an ad arriving later cannot move
 * the page. There is no ad code; the box is empty and hidden from assistive technology.
 * The template renders the box only when ads are on (decision 36): with ads off no page has one.
 */
.ad-slot {
  width: 100%;
  max-width: 45.5rem;
  height: 6.25rem;
  margin-top: var(--gap-6);
}

@media (min-width: 48rem) {
  .ad-slot {
    height: 5.625rem;
  }
}

.notice {
  max-width: var(--measure);
  margin-top: var(--gap-6);
  padding-top: var(--gap-4);
  border-top: 0.0625rem solid var(--rule);
  font-size: 0.875rem;
  color: var(--ink-2);
}

/* ---------- Motion, forced colors, print ---------- */

@media (prefers-reduced-motion: no-preference) {
  .skip-link {
    transition: transform 120ms ease-out;
  }
}

@media (forced-colors: active) {
  .stale-flag,
  .tool-result > .note {
    border-width: 0.125rem;
  }

  /* The covers are drawn in the paper color, which is not the color of a forced page. */
  .table-wrap {
    background: none;
  }
}

@media print {
  .skip-link,
  .topic-nav,
  .footer-nav,
  .ad-slot,
  .table-actions,
  .tool-actions {
    display: none;
  }

  .table-wrap {
    overflow: visible;
    background: none;
  }

  a {
    color: inherit;
  }
}
