/* Components: the range bar, the ruler axis, chips, receipts, portraits, the
   person line, the figure, controls, tables, the tray, the sheet and search.
   Money has no hue: bands are warm gray, marks are ink. Color only for a verdict
   and for focus. Text never wears a data color. */

/* ------------------------------------------------------------ range bar */

.rb {
  --band: 8px;
  --tick: 14px;
  --h: 20px;
  --cy: calc(var(--h) / 2);
  position: relative;
  height: var(--h);
  min-width: 0;
}
.rb--s { --band: 6px; --tick: 12px; --h: 16px; }
.rb--m { --band: 8px; --tick: 14px; --h: 20px; }
.rb--l { --band: 10px; --tick: 20px; --h: 32px; }
.rb--has-pub { --cy: calc(var(--h) / 2 + 12px); height: calc(var(--h) + 12px); }
.rb--m.rb--open, .rb--m.rb--open-low, .rb--m.rb--open-both,
.rb--l.rb--open, .rb--l.rb--open-low, .rb--l.rb--open-both { padding-bottom: 16px; height: auto; min-height: calc(var(--h) + 16px); }
.rb--m.rb--has-pub.rb--open, .rb--l.rb--has-pub.rb--open { min-height: calc(var(--h) + 28px); }

/* A change row: the starting figure as a thin outline over the bar. */
.rb--has-then { --cy: calc(var(--h) / 2 + 8px); height: calc(var(--h) + 8px); }
.rb__plot { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--cy) * 2); }
.rb__plot > span { position: absolute; display: block; }

/* Zero and the household line are short ticks centered on the band, never full-height
   rules, so a long list of bars stays calm. */
.rb__zero { top: calc(var(--cy) - var(--tick) / 2); height: var(--tick); width: 1px; margin-left: -0.5px; background: var(--axis); }
.rb__ref { top: calc(var(--cy) - var(--tick) / 2 - 3px); height: calc(var(--tick) + 6px); width: 1px; margin-left: -0.5px; background: var(--ink-3); }

.rb__band {
  top: calc(var(--cy) - var(--band) / 2);
  height: var(--band);
  min-width: 2px;
  background: var(--range);
  border-radius: var(--r-band);
  /* A 1px edge in the cap color, top and bottom, so the band reaches 3:1 against
     the page (the fill alone is 1.5:1) without a heavier look. The fade on an open
     end masks it too. */
  box-shadow: inset 0 1px 0 var(--range-edge), inset 0 -1px 0 var(--range-edge);
}
/* The frayed end: an open bracket runs to the plot edge and fades over 24px. */
.rb--open .rb__band {
  border-radius: var(--r-band) 0 0 var(--r-band);
  -webkit-mask-image: linear-gradient(to left, transparent, #000 24px);
  mask-image: linear-gradient(to left, transparent, #000 24px);
}
.rb--open-low .rb__band {
  border-radius: 0 var(--r-band) var(--r-band) 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 24px);
  mask-image: linear-gradient(to right, transparent, #000 24px);
}
.rb--open-both .rb__band {
  border-radius: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

/* An end past the edge of the scale (the profile's two-bar plot): drawn open at
   that edge, never capped there, so a short bar is not read as its value. */
.rb--past-lo .rb__band {
  border-radius: 0 var(--r-band) var(--r-band) 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 70%);
  mask-image: linear-gradient(to right, transparent, #000 70%);
}
.rb--past-hi .rb__band {
  border-radius: var(--r-band) 0 0 var(--r-band);
  -webkit-mask-image: linear-gradient(to left, transparent, #000 70%);
  mask-image: linear-gradient(to left, transparent, #000 70%);
}
.rb--open.rb--past-lo .rb__band, .rb--open-low.rb--past-hi .rb__band {
  border-radius: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.rb__cap {
  top: calc(var(--cy) - var(--band) / 2 - 2px);
  height: calc(var(--band) + 4px);
  width: 1px;
  background: var(--range-edge);
}
.rb__cap--hi { margin-left: -1px; }

.rb__chev {
  top: calc(var(--cy) - 3.5px);
  width: 7px;
  height: 7px;
  border-top: 1.5px solid var(--range-edge);
  border-right: 1.5px solid var(--range-edge);
}
.rb__chev--hi { right: 2px; transform: rotate(45deg); }
.rb__chev--lo { left: 2px; transform: rotate(-135deg); }

.rb__mid {
  top: calc(var(--cy) - var(--tick) / 2);
  height: var(--tick);
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
  border-radius: 1px;
  box-shadow: 0 0 0 1.5px var(--ring);
}
.rb__mid--hollow {
  width: 6px;
  margin-left: -3px;
  background: var(--ring);
  border: 1.5px solid var(--ink);
  box-shadow: none;
}

/* Published estimate: a hollow diamond above the band, never on it. */
.rb__pub {
  top: calc(var(--cy) - var(--band) / 2 - 15px);
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border: 1.5px solid var(--ink);
  background: var(--ring);
  transform: rotate(45deg);
}
/* The label sits on the side of the diamond with more room (--room, set beside
   left or right) and never reaches past the end of the bar. A long one wraps, and
   grows up from the line just above the band. A bar with a label keeps a line of
   air above it for that. */
.rb__publabel {
  bottom: calc(100% - var(--cy) + var(--band) / 2 + 6px);
  max-width: var(--room, none);
  padding-left: 12px;
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  color: var(--ink-2);
}
.rb__publabel--left { padding: 0 12px 0 0; text-align: right; }
.rb--l.rb--has-pub { margin-top: var(--lh-micro); }

.rb__more {
  position: absolute;
  top: calc(var(--cy) + var(--band) / 2 + 2px);
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  color: var(--ink-3);
  white-space: nowrap;
}
.rb__more--hi { right: 0; }
.rb__more--lo { left: 0; }

.rb--none { display: flex; align-items: center; height: auto; min-height: var(--h); }
.rb__none { font-size: var(--t-small); line-height: var(--lh-small); font-style: italic; color: var(--ink-3); }
.rb--s .rb__none { font-size: var(--t-micro); line-height: var(--lh-micro); }

@media (forced-colors: active) {
  .rb__band { forced-color-adjust: none; background: repeating-linear-gradient(45deg, CanvasText 0 1px, Canvas 1px 4px); box-shadow: none; }
  .rb__mid { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
  .rb__mid--hollow { background: Canvas; border-color: CanvasText; }
  .rb__cap, .rb__ref, .rb__zero { forced-color-adjust: none; background: CanvasText; }
  .rb__chev { border-color: CanvasText; }
}

/* ------------------------------------------------------------ axis */

.axis {
  position: relative;
  container-type: inline-size;
  height: 24px;
  border-top: 1px solid var(--axis);
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.axis--zone { height: auto; min-height: 24px; }
.axis__zone {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: color-mix(in srgb, var(--range) 16%, transparent);
}
.axis__tick {
  position: absolute;
  top: 0;
  padding-top: 6px;
  transform: translateX(-50%);
  white-space: nowrap;
}
.axis__tick::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  width: 1px; height: 4px;
  background: var(--axis);
}
.axis__tick.is-start { transform: none; }
.axis__tick.is-start::before { left: 0; }
.axis__tick.is-end { transform: translateX(-100%); }
.axis__tick.is-end::before { left: auto; right: 0; }
/* The debt zone is narrow (8% of the plot): its short label sits centered under
   it and may run a little past its edges. */
.axis__zone-label {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 23px;
  padding: 0 0 4px;
  color: var(--ink-3);
  font-style: italic;
  white-space: nowrap;
  overflow: visible;
}
@container (min-width: 840px) {
  .axis__tick.no-full { display: none; }
}
@container (max-width: 839px) {
  .axis__tick:not(.is-mid) { display: none; }
}
@container (max-width: 399px) {
  .axis__tick:not(.is-thin) { display: none; }
}
/* A list axis in a narrow column or on a small phone has a fourth, sparser set. */
@container (max-width: 299px) {
  .axis--list .axis__tick:not(.is-tiny) { display: none; }
}
/* On a list axis a label a tier leaves out drops only its words: the tick stays
   at every stop (DESIGN 13.6). */
@container (min-width: 840px) {
  .axis--list .axis__tick.no-full { display: block; color: transparent; }
}
@container (min-width: 400px) and (max-width: 839px) {
  .axis--list .axis__tick:not(.is-mid) { display: block; color: transparent; }
}
@container (min-width: 300px) and (max-width: 399px) {
  .axis--list .axis__tick:not(.is-thin) { display: block; color: transparent; }
}
@container (max-width: 299px) {
  .axis--list .axis__tick:not(.is-tiny) { display: block; color: transparent; }
}
.axis--list .axis__tick.is-bare { color: transparent; }
/* A list's axis sits above its bars (DESIGN 10, item 2). */
.axis--list { margin-bottom: 2px; }

.ruler-grid { position: absolute; inset: 0; pointer-events: none; }
.ruler-grid > span { position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -0.5px; background: var(--hairline); }
.ruler-grid > span.is-zero { background: var(--axis); }

.caption, .note {
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  color: var(--ink-3);
}
.caption { margin-top: var(--s2); }
.figure__caption { margin-top: 0; margin-bottom: var(--s2); }
.note { max-width: 70ch; }

/* ------------------------------------------------------------ chips */

.party {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  margin-left: 8px;
  border: 1px solid var(--ink-3);
  border-radius: var(--r-chip);
  font-family: var(--sans);
  font-size: var(--t-micro);
  line-height: 1;
  font-weight: 650;
  color: var(--ink-2);
  vertical-align: 2px;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--sans);
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  font-weight: 650;
  color: var(--ink-3);
  vertical-align: 1px;
}

.verdict {
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 2px 10px 2px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-chip);
  background: var(--surface);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: 560;
  color: var(--ink);
  white-space: nowrap;
}
.verdict--plain { border: 0; background: none; padding: 0; min-height: 0; }
/* A share ("now about 40% of the starting figure") may wrap under the word. */
.verdict:has(.verdict__mult) { flex-wrap: wrap; row-gap: 0; max-width: 100%; }
.verdict__mult { white-space: normal; }
.verdict--none { color: var(--ink-3); font-weight: 450; }
.verdict__mult { font-weight: 450; color: var(--ink-2); }
/* The separator belongs to the word, so it stays at the end of the first line
   when the multiple or the share wraps under it. */
.verdict__word:has(+ .verdict__mult)::after { content: "·"; margin: 0 -1px 0 6px; font-weight: 450; color: var(--ink-3); }
.glyph { width: 12px; height: 12px; overflow: visible; }
.glyph--up { fill: var(--gain); }
.glyph--down { fill: var(--loss); }
.glyph--unclear { fill: none; stroke: var(--neutral); stroke-width: 1.6; }
.glyph--none { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.glyph--hollow.glyph--up { fill: var(--surface); stroke: var(--gain); stroke-width: 1.6; stroke-linejoin: round; }
.glyph--hollow.glyph--down { fill: var(--surface); stroke: var(--loss); stroke-width: 1.6; stroke-linejoin: round; }
@media (forced-colors: active) {
  .glyph--up, .glyph--down { fill: CanvasText; }
  .glyph--unclear, .glyph--hollow { stroke: CanvasText; }
}

.asof {
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-chip);
  font-size: var(--t-micro);
  line-height: 1;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: 1px;
}
/* --ink-3 alone is 4.4:1 on the tint; a touch of --ink takes it past 4.5:1 in both modes. */
.asof--dated { color: color-mix(in srgb, var(--ink-3) 82%, var(--ink)); border-style: solid; background: color-mix(in srgb, var(--range) 25%, transparent); }
.asof__dated { font-weight: 450; }
.asof__dated::before { content: "·"; margin-right: 5px; }

.grade {
  font-family: var(--sans);
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  font-size: var(--t-micro);
  line-height: 1;
  font-weight: 650;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.grade--none {
  border-color: var(--axis);
  background: linear-gradient(to top right, transparent calc(50% - 0.6px), var(--axis) calc(50% - 0.6px), var(--axis) calc(50% + 0.6px), transparent calc(50% + 0.6px));
}
/* A grade letter is a link to what the grades mean. It keeps the look of the chip:
   no underline, the chip's own color, and a darker rim on hover. */
a.grade { text-decoration: none; color: var(--ink-2); }
a.grade:hover { border-color: var(--ink); color: var(--ink); }

/* ------------------------------------------------------------ receipt & rules */

.receipt {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-3);
  letter-spacing: 0;
}
.receipt__link { display: inline-flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; padding-block: 4px; }
a.receipt__link:hover span { text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); }
.receipt__icon { fill: none; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; opacity: 0.9; }
.receipt__extra { margin-left: 10px; }
.receipt__part { white-space: nowrap; }
.receipt__sep { white-space: pre-wrap; }

.double-rule {
  height: 4px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

/* ------------------------------------------------------------ portraits */

.portrait {
  --pw: 32px;
  position: relative;
  display: block;
  flex: none;
  width: var(--pw);
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 2px;
  background: color-mix(in srgb, var(--range) 38%, var(--surface));
}
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 9%, transparent);
  pointer-events: none;
}
.portrait--xs { --pw: 28px; }
.portrait--s { --pw: 32px; }
.portrait--m { --pw: 48px; }
.portrait--l { --pw: 120px; }
@media (min-width: 768px) { .portrait--l { --pw: 160px; } }
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 38%;
  filter: grayscale(1) contrast(1.04);
}
.portrait--color img { filter: none; }
.portrait__initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: calc(var(--pw) * 0.36);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  padding-top: calc(var(--pw) * 0.04);
}

/* ------------------------------------------------------------ person line */

/* The rank column and the gap are tighter on a small phone, so a name keeps
   its party chip on its line. Anything aligned to the bars uses these. */
:root { --pl-rank: 34px; --pl-gap: 12px; }
@media (max-width: 479px) { :root { --pl-rank: 20px; --pl-gap: 10px; } }
.pl {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  grid-template-areas:
    "pic name value"
    "pic office asof"
    "bar bar bar";
  column-gap: var(--pl-gap);
  align-items: baseline;
  padding-block: 10px 12px;
}
.pl--ranked {
  grid-template-columns: var(--pl-rank) 32px minmax(0, 1fr) auto;
  grid-template-areas:
    "rank pic name value"
    ". pic office asof"
    ". bar bar bar";
}
.pl:not(.pl--bar) { padding-block: 8px; }
.pl__rank {
  grid-area: rank;
  align-self: start;
  padding-top: 1px;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  text-align: right;
  /* "100" is 29.4px wide at 14px, so a rank never wraps onto two lines. The column is
     wide enough for it from 480px up. On a small phone the column stays 20px, so
     names keep their room, and a three-digit rank hangs into the margin on its left
     (flex-end, so the overflow runs leftward and the numerals stay right-aligned). */
  white-space: nowrap;
  display: flex;
  justify-content: flex-end;
}
.pl > .portrait { grid-area: pic; align-self: start; margin-top: 2px; }
.pl__name {
  grid-area: name;
  min-width: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 22px;
  font-weight: 560;
  color: var(--ink);
}
.pl__name > a { text-decoration: none; }
.pl__name > a:hover { text-decoration: underline; text-decoration-color: var(--axis); }
.pl--link .pl__name > a::after { content: ""; position: absolute; inset: 0; }
.pl--link:hover { background: color-mix(in srgb, var(--ink) 2.5%, transparent); }
.pl__value {
  grid-area: value;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.value__pre { font-weight: 450; color: var(--ink-2); }
/* On a small phone a long lead ("open both ways ·") sits on its own line above
   the amount, so the name and the office line keep their width. */
@media (max-width: 479px) {
  .pl__value:has(.value__pre) { white-space: normal; max-width: 8.5em; }
}
.pl__office {
  grid-area: office;
  min-width: 0;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--ink-2);
}
.pl__asof { grid-area: asof; justify-self: end; }
.pl__note { color: var(--ink-3); }
.pl__bar { grid-area: bar; margin-top: 8px; }
/* A place never breaks across lines: a district code such as IN-6 stays whole. */
.nb { white-space: nowrap; }
/* A name with its party chip (DESIGN 13.7): the line holding the name, the chip
   and any status tag never wraps, except between the words before the last one
   (the nmw span of the name_bound macro). So the chip travels with the last word
   of the name and never sits on a line of its own. */
.xp__name, .pl__name, .home-latest__name, .ex-row__name,
.xp__name > a, .pl__name > a, .home-latest__name > a, .ex-row__name > a { white-space: nowrap; }
.nmw { white-space: normal; }
.pl + .pl, .pl-list > li + li > .pl { border-top: 1px solid var(--hairline); }
.pl-list { list-style: none; padding: 0; margin: 0; }

/* The axis above a list, lined up with the bars of its person lines. */
.list-axis { position: sticky; top: 0; z-index: 2; padding: 6px 0 0; background: var(--page); }
.list-axis--ranked { padding-left: calc(var(--pl-rank) + var(--pl-gap)); }
.card .list-axis { background: var(--surface); }

/* ------------------------------------------------------------ the figure */

.figure { --ring: var(--page); }
.figure__eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.figure__sentence {
  margin-top: 14px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 22px;
  line-height: 30px;
  font-weight: 420;
  color: var(--ink);
  max-width: 34ch;
  text-wrap: pretty;
}
.figure__sentence strong { font-weight: 620; white-space: nowrap; }
@media (min-width: 768px) { .figure__sentence { font-size: 28px; line-height: 36px; max-width: 38ch; } }
.figure__sentence--none { color: var(--ink-2); }
/* "No reliable figure." above a graded-D flag: the place of the figure sentence. */
.figure__lead {
  margin-top: 14px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 22px;
  line-height: 30px;
  font-weight: 420;
  color: var(--ink-2);
  max-width: 34ch;
}
@media (min-width: 768px) { .figure__lead { font-size: 28px; line-height: 36px; } }
/* Where the figure comes from when it is not the current office's report. */
.figure__note { margin-top: 6px; }
.figure__detail { margin-top: 8px; color: var(--ink-2); max-width: 62ch; }
.figure__plot { position: relative; margin-top: var(--s5); padding-top: 8px; }
.figure__zone { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--range) 16%, transparent); }
.figure__plot .axis__zone { display: none; }
.figure__plot .rb { margin-bottom: 4px; }
.figure__caveat { margin-top: 6px; }
/* Why a figure is not ranked or compared (a latest figure graded D): a plain
   sentence set beside the figure, with its grade mark. */
.figure__flag {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: var(--s3);
  padding: 10px 12px;
  max-width: 62ch;
  border: 1px solid var(--axis);
  border-radius: var(--r-chip);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--ink);
}
.figure__flag .grade { flex: none; }
.figure__foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: var(--s3); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: var(--s3);
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  color: var(--ink-2);
}
.legend > li { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.key { position: relative; display: inline-block; width: 14px; height: 10px; flex: none; top: 1px; }
.key--band::before { content: ""; position: absolute; left: 0; right: 0; top: 2px; height: 6px; border-radius: 2px; background: var(--range); }
.key--mid::before { content: ""; position: absolute; left: 6px; top: -1px; width: 2px; height: 12px; background: var(--ink); border-radius: 1px; }
.key--hollow::before { content: ""; position: absolute; left: 4px; top: -1px; width: 6px; height: 12px; border: 1.5px solid var(--ink); border-radius: 1px; }
.key--ref::before { content: ""; position: absolute; left: 6.5px; top: -2px; width: 1px; height: 14px; background: var(--ink-3); }
.key--pub::before { content: ""; position: absolute; left: 3px; top: 1px; width: 8px; height: 8px; border: 1.5px solid var(--ink); transform: rotate(45deg); }

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: var(--r-chip);
  background: var(--ink);
  color: var(--page);
  font-size: var(--t-small);
  line-height: 1;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--motion) var(--ease), color var(--motion) var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--ink) 86%, var(--page)); }
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--axis); }
.btn--quiet:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); border-color: var(--ink-3); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.link-quiet { color: var(--ink-2); text-decoration: none; }
.link-quiet:hover { color: var(--ink); text-decoration: underline; }

/* The segmented control: Most · Least · Grew most · Fell most. Buttons with
   aria-pressed, or radio inputs inside labels. */
.seg {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: color-mix(in srgb, var(--range) 18%, var(--surface));
  overflow-x: auto;
  scrollbar-width: none;
}
.seg__opt { position: relative; flex: none; }
.seg__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg__btn, .seg__opt > span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-chip);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-small);
  line-height: 1;
  font-weight: 560;
  white-space: nowrap;
  transition: background var(--motion) var(--ease), color var(--motion) var(--ease);
}
.seg__btn:hover, .seg__opt:hover > span { color: var(--ink); }
.seg__btn[aria-pressed="true"], .seg__opt input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--hairline), 0 1px 0 var(--hairline);
}
.seg__opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.field { display: grid; gap: 6px; }
.field__label { font-size: var(--t-micro); line-height: var(--lh-micro); letter-spacing: var(--track-micro); text-transform: uppercase; font-weight: 650; color: var(--ink-3); }
.input, .select {
  min-height: var(--touch);
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--axis);
  border-radius: var(--r-chip);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-body);
}
.input::placeholder { color: var(--ink-3); }
.select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input:hover, .select:hover { border-color: var(--ink-3); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--touch); font-size: var(--t-small); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }

/* ------------------------------------------------------------ cards & tables */

.card {
  --ring: var(--surface);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: var(--s4);
}
@media (min-width: 768px) { .card { padding: var(--s5); } }
/* On a phone a card runs edge to edge, so charts and lists get the full width. */
@media (max-width: 767px) {
  .card { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; padding-inline: var(--gutter); }
  .card .card { margin-inline: 0; border-radius: var(--r-card); border-inline: 1px solid var(--hairline); }
}

.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; font-size: var(--t-small); line-height: var(--lh-small); }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--hairline); }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table thead th {
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  font-weight: 650;
  color: var(--ink-3);
  border-bottom-color: var(--axis);
  white-space: nowrap;
}
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .col-bar { width: 38%; min-width: 180px; }
.sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.sort::after {
  content: "";
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--axis);
  opacity: 0.9;
}
th[aria-sort="descending"] .sort, th[aria-sort="ascending"] .sort { color: var(--ink); }
th[aria-sort="descending"] .sort::after { border-top-color: var(--ink); }
th[aria-sort="ascending"] .sort::after { border-top: 0; border-bottom: 5px solid var(--ink); }
.table tr.is-median td { border-bottom: 1px solid var(--ink-3); }
.table .del { text-decoration: line-through; color: var(--ink-3); }

/* ------------------------------------------------------------ tray */

.tray { border-top: 1px solid var(--hairline); font-size: var(--t-small); line-height: var(--lh-small); }
.tray__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch);
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 560;
  list-style: none;
}
.tray__summary::-webkit-details-marker { display: none; }
.tray__summary::after {
  content: "";
  width: 6px; height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--motion) var(--ease);
}
.tray[open] > .tray__summary::after { transform: rotate(-135deg) translateY(-1px); }
.tray__glyph {
  width: 10px; height: 10px;
  border: 1px solid var(--ink-3);
  background: linear-gradient(to top right, transparent calc(50% - 0.5px), var(--ink-3) calc(50% - 0.5px), var(--ink-3) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}
.tray__list { padding: 0 0 var(--s3) 20px; display: grid; gap: 6px; }
.tray__list li { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.tray__reason { color: var(--ink-3); }

/* ------------------------------------------------------------ sheet */

.sheet {
  --ring: var(--surface);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  color: var(--ink);
}
.sheet::backdrop { background: color-mix(in srgb, #000 38%, transparent); }
.sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 82vh;
  overflow: auto;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  border-radius: 12px 12px 0 0;
  padding: 0 var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  animation: sheet-up var(--motion) var(--ease);
}
.sheet__handle { width: 100%; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet__handle::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--axis); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--hairline); }
.sheet__title { font-size: 18px; line-height: 24px; font-weight: 560; }
.sheet__close, .search__close {
  min-height: var(--touch);
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 560;
  text-decoration: underline;
  text-decoration-color: var(--axis);
  text-underline-offset: 0.2em;
}
.sheet__close:hover, .search__close:hover { color: var(--ink); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 768px) {
  .sheet__panel {
    left: auto; top: 0; bottom: 0;
    width: 420px;
    max-height: none;
    border-top: 0;
    border-left: 1px solid var(--hairline);
    border-radius: 0;
    padding-top: var(--s4);
    animation-name: sheet-in;
  }
  .sheet__handle { display: none; }
  @keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ------------------------------------------------------------ search */

.search {
  --ring: var(--surface);
  margin: 0 auto;
  padding: 0;
  border: 0;
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
}
.search::backdrop { background: color-mix(in srgb, #000 38%, transparent); }
.search__panel { display: flex; flex-direction: column; height: 100%; padding: var(--s3) var(--s4) var(--s4); }
.search__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search__label { font-size: var(--t-micro); line-height: var(--lh-micro); letter-spacing: var(--track-micro); text-transform: uppercase; font-weight: 650; color: var(--ink-3); }
.search__field { position: relative; margin-top: 4px; }
.search__icon { position: absolute; left: 0; top: 50%; transform: translateY(-50%); fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-linecap: round; }
.search__input {
  width: 100%;
  min-height: 52px;
  padding: 0 0 0 30px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 24px;
  line-height: 32px;
  border-radius: 0;
}
.search__input:focus { outline: none; border-bottom-width: 2px; padding-bottom: 0; }
.search__input:focus-visible { outline: none; box-shadow: 0 2px 0 0 var(--focus); }
.search__input::placeholder { color: var(--ink-3); }
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search__status { min-height: 20px; margin-top: 10px; font-size: var(--t-small); line-height: var(--lh-small); color: var(--ink-3); }
.search__results { position: relative; flex: 1; overflow: auto; margin: 8px calc(-1 * var(--s4)) 0; padding: 0 var(--s4); }
.search__group + .search__group { margin-top: var(--s4); }
.search__group-title { padding: 8px 0 4px; }
.search__item + .search__item { border-top: 1px solid var(--hairline); }
.search__hit {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--touch);
  padding: 4px 8px;
  margin-inline: -8px;
  border-radius: var(--r-chip);
  color: inherit;
  text-decoration: none;
}
.search__hit > .pl { flex: 1; min-width: 0; padding-block: 6px 8px; }
a.search__hit:hover, a.search__hit:focus-visible { background: color-mix(in srgb, var(--ink) 4%, transparent); }
a.search__hit:focus-visible { outline-offset: 0; }
.search__label-main { font-family: var(--serif); font-size: 17px; line-height: 22px; font-weight: 560; padding-block: 11px; }
.search__meta { font-size: var(--t-small); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.search__legend { display: flex; align-items: baseline; gap: 8px; padding: 8px 0 2px; font-size: var(--t-micro); line-height: var(--lh-micro); color: var(--ink-2); }
.search__hint { margin-top: var(--s3); display: none; gap: 6px; align-items: center; font-size: var(--t-micro); color: var(--ink-3); }
.search__hint kbd { margin-right: 2px; }
.search__hint kbd + kbd { margin-left: 0; }
@media (min-width: 768px) {
  .search { height: fit-content; max-height: min(78vh, 760px); margin-top: 8vh; border: 1px solid var(--hairline); border-radius: var(--r-card); }
  .search__panel { height: auto; max-height: min(78vh, 760px); padding: var(--s4) var(--s5) var(--s4); }
  .search__hint { display: flex; }
}

/* ------------------------------------------------------------ touch targets */

/* On a phone or any touch screen a link in a list, a line of notes or a breadcrumb
   is at least 24px tall (WCAG 2.2, 2.5.8). Inline links get vertical padding, which
   changes no line height. A link that is a block or a flex item gets the same
   padding and an equal negative margin, so the rows keep their spacing. */
@media (pointer: coarse), (max-width: 767px) {
  :where(.pl__name, .xp__name, .ex-row__name, .home-latest__name, .grp-nofig__name, .grp-nofig__link,
         .grp-crumb, .prof-id__eyebrow, .prof-id__credit, .prof-leave__more, .prof-bio__sources,
         .grp-bg__nofig, .grp-links li, .cp-defs dd) > a { padding-block: 5px; }
  .tray__list li > a, .xsrc { padding-block: 2px; margin-block: -2px; }
}
