@layer components {
  /* Reports view, filters, filter sheet body, dates list and notice lines (WP2).
     Tokens only (SPEC §17); WP1 owns the primitives (.btn, .chip, .empty-state, .band, .status) and the shell grid. */

  /* ---- #feed-stats: S1 + S2 (§6.1) ---------------------------------------------------------------- */
  .feed-stats { display: grid; gap: 4px; }
  .feed-stat { margin: 0; }
  .feed-stat--assembled, .feed-stat--loading { font-size: var(--fs-sm); line-height: 1.4; color: var(--text-muted); }
  .feed-stat-time, .feed-stat time { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .feed-stat--assembled .feed-stat-time { color: var(--text-2); }
  /* Phones: S1 repeats the chip stamp (and, once stale, the age the notice already states), so only S2 shows, at
     14 px. The dates sheet and the footer keep "Snapshot assembled". */
  .feed-stat--assembled { display: none; }
  .feed-stat--scope { font: 600 var(--fs-sm)/1.4 var(--font-sans); color: var(--text); text-wrap: pretty; }
  @media (min-width: 600px) {
    .feed-stat--assembled { display: block; }
    .feed-stat--scope { font-size: var(--fs-md); line-height: 1.32; letter-spacing: -.01em; }   /* S2 on one line in the 720 column (§5) */
  }
  .feed-stat--scope strong { font-weight: 750; }
  .feed-stat--example { font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }

  /* ---- #filter-bar: search, Filters (n), quick chips (§6.2) ------------------------------------------ */
  /* Below 600 the search takes the full width, so its placeholder is never cut, and "Filters (n)" leads the
     quick-chip row. From 600 the Filters button sits beside the search and the chips wrap underneath. */
  .filter-bar {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 4px; align-items: center;
    margin-top: 10px;
  }
  .filter-search { position: relative; min-width: 0; grid-column: 1 / -1; }
  .filter-search input {
    width: 100%; min-height: 48px; padding: 0 44px 0 42px;
    border: 1px solid var(--border-input); border-radius: var(--r-2);
    background: var(--bg-raised); color: var(--text); font: 400 var(--fs-md)/1.2 var(--font-sans);
    appearance: none;
  }
  .filter-search input::placeholder { color: var(--text-muted); opacity: 1; }
  .filter-search input::-webkit-search-cancel-button { appearance: none; display: none; }
  .filter-search-icon {
    position: absolute; left: 13px; top: 50%; width: 20px; height: 20px; translate: 0 -50%;
    color: var(--text-muted); pointer-events: none;
  }
  .filter-clear { position: absolute; right: 2px; top: 50%; translate: 0 -50%; color: var(--text-2); }
  .filter-clear[hidden] { display: none; }
  .filter-open { min-height: var(--tap); padding-inline: 12px 14px; border-radius: var(--r-pill); gap: 6px; }
  .filter-count { font-variant-numeric: tabular-nums; }

  /* The chips scroll inside their own box, bleeding to the right edge; an 8 px fade at each end. */
  .quick-chips {
    min-width: 0;
    margin-inline-end: calc(-1 * var(--gutter)); padding: 3px var(--gutter) 3px 8px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    scroll-padding-inline: 8px var(--gutter);
    mask-image: linear-gradient(to right, transparent 0, var(--text) 8px, var(--text) calc(100% - var(--gutter)), transparent 100%);
  }
  .quick-chips::-webkit-scrollbar { display: none; }
  .quick-chips-track { display: flex; gap: 8px; width: max-content; padding-block: 2px; }
  .quick-chip .icon:not(.chip-check) { width: 18px; height: 18px; margin-inline-end: -4px; }
  @media (min-width: 600px) {
    .filter-bar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
    .filter-search { grid-column: auto; }
    .filter-open { min-height: 48px; padding-inline: 14px 16px; border-radius: var(--r-2); gap: 8px; }
    /* Wider screens: the chips wrap instead of scrolling, so none is hidden under a fade. */
    .quick-chips { grid-column: 1 / -1; margin-inline: 0; padding: 0; overflow: visible; mask-image: none; }
    .quick-chips-track { flex-wrap: wrap; width: auto; padding: 0; gap: 8px 6px; }
    .quick-chip { padding-inline: 10px; }
  }

  /* ---- #active-filters (§6.2) -------------------------------------------------------------------------- */
  .active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
  .active-filters[hidden] { display: none; }
  .active-chip { background: var(--bg-sunken); border-color: var(--border-strong); max-width: 100%; white-space: normal; text-align: start; }
  .active-chip-x { font-size: var(--fs-lg); line-height: 1; color: var(--text-2); }
  .active-clear { min-height: var(--tap); }

  /* ---- .feed-head (§6.3) ----------------------------------------------------------------------------- */
  /* Phones: 4 px above and below the rule (and 6 px notice-line padding), so the first card title clears the tab bar
     at 360 × 780 on the stale and archive clocks (smoke 17). */
  .feed-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px;
    margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border-strong);
  }
  .feed-head h1 { margin: 0; font: 700 var(--fs-xl)/1.2 var(--font-sans); letter-spacing: -.01em; }
  .feed-head > :not(h1, .feed-density) { grid-column: 1 / -1; }

  /* Segmented Cards | List toggle: two real 44 px buttons sharing a border. */
  /* Equal columns, so the pressed button's check (static .feed-density-check in index.html) never shifts the pair. */
  .feed-density { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-self: end; }
  .feed-density button {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    min-height: var(--tap); min-width: 64px; padding: 0 14px;
    border: 1px solid var(--border-input); background: var(--bg-raised); color: var(--text-2);
    font: 600 var(--fs-sm)/1 var(--font-sans); cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
  }
  .feed-density button:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
  .feed-density button:last-child { margin-inline-start: -1px; border-radius: 0 var(--r-pill) var(--r-pill) 0; }
  .feed-density button[aria-pressed="true"] { position: relative; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
  .feed-density button:focus-visible { position: relative; z-index: 1; }
  .feed-density-check { flex: none; width: 16px; height: 16px; margin-inline-start: -4px; }
  .feed-density button:not([aria-pressed="true"]) .feed-density-check { display: none; }
  .feed-head h1 { align-self: center; }

  .result-summary { margin: 0; min-height: 1.45em; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }

  /* Share and CSV: an enabled button has a solid resting outline, a refused one the dashed box (C-43), so the two
     never read the other way round. Phones show the row under the list, so the first record reaches the first
     viewport in every snapshot state (MAJOR 5); from 600 px it shares the summary row in the head. */
  .feed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
  .feed-actions .btn { padding-inline: 12px; font-size: var(--fs-sm); gap: 6px; }
  .feed-actions .btn:not([aria-disabled="true"]) { border-color: var(--border-input); background: var(--bg-raised); }
  .feed-actions .btn .icon { width: 18px; height: 18px; }
  .feed-actions--foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
  .feed-head > .feed-actions { display: none; }
  @media (min-width: 600px) {
    .feed-head { margin-top: 8px; padding-top: 6px; }
    .feed-actions--foot { display: none; }
    .feed-head > .feed-actions { display: flex; }
    /* The summary and the actions share a row (§5: the first card and the next one start higher). */
    .feed-head > .result-summary { grid-column: 1; }
    .feed-head > .feed-actions { grid-column: 2; justify-self: end; margin: 4px 0; }
  }

  .feed-explainer { margin-bottom: -6px; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }
  .feed-explainer[open] { margin-bottom: 4px; }
  .feed-explainer > summary { width: fit-content; color: var(--text-2); font-weight: 600; cursor: pointer; }
  .feed-explainer > p { margin: 0 0 8px; max-width: 62ch; }

  /* ---- #event-list (§6.4) ------------------------------------------------------------------------------ */
  .feed { margin-top: 0; }
  .feed-gap {
    display: grid; gap: 6px; margin: 8px 0 4px; padding: 12px 14px;
    border-inline-start: 3px solid var(--border-strong); border-radius: 0 var(--r-1) var(--r-1) 0;
    background: var(--bg-sunken); color: var(--text-2);
    font-size: var(--fs-sm); line-height: 1.45;
  }
  .feed-gap-line { margin: 0; }
  .feed-gap-line:first-child { color: var(--text); font-weight: 600; }

  .feed-group { margin-top: 20px; }
  .feed-group:first-child { margin-top: 0; }
  /* The explainer above already separates the first group, so it carries no extra rule. */
  .feed-group:first-child > .feed-group-title, .feed-gap + .feed-group > .feed-group-title { padding-top: 6px; border-top: 0; }
  .feed-group-title {
    margin: 0; padding-top: 7px; border-top: 1px solid var(--border);
    font: 700 var(--fs-md)/1.3 var(--font-sans); color: var(--text);
  }
  .feed-group-count { font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .feed-group-note { margin: 1px 0 0; max-width: 80ch; text-wrap: pretty; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }
  .feed-group-note--end { margin-top: 12px; padding-inline-start: 12px; border-inline-start: 2px solid var(--border); }

  .feed-list { display: grid; gap: 12px; margin: 6px 0 0; padding: 0; list-style: none; }
  .feed-list[data-density="row"] { gap: 0; border-top: 1px solid var(--border); }
  .feed-item { min-width: 0; }

  .feed-loading { margin: 12px 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-muted); }
  .feed-skeleton { display: grid; gap: 12px; }
  .feed-empty { margin-top: 16px; }
  .feed-empty-title { text-wrap: balance; }

  /* An Ahead teaser placed by list.js (WP5 styles .ahead-teaser itself). */
  .feed > .ahead-teaser { margin-top: 24px; }

  /* ---- #list-more ------------------------------------------------------------------------------------------ */
  .list-more { margin-top: 20px; }
  .list-more:empty { display: none; }
  .list-more-btn { width: 100%; font-variant-numeric: tabular-nums; }
  @media (min-width: 600px) { .list-more-btn { width: auto; } }

  /* ---- #filters-body (§9) -------------------------------------------------------------------------------- */
  .filter-form { display: grid; gap: 24px; }
  .filter-group { min-width: 0; margin: 0; padding: 0; border: 0; }
  .filter-group > legend, .filter-field > label {
    padding: 0; margin-bottom: 8px; font: 700 var(--fs-md)/1.3 var(--font-sans); color: var(--text);
  }
  .filter-group > legend { float: left; width: 100%; }
  .filter-group > legend + * { clear: left; }
  .filter-group > .filter-field + .filter-field { margin-top: 16px; }
  .filter-field > label { display: block; font-weight: 600; }
  /* A group of fields (History) is a ruled section; its field labels sit one step below the legend. */
  .filter-group:has(> .filter-field) { padding-top: 16px; border-top: 1px solid var(--border); }
  .filter-group > .filter-field > label { font-size: var(--fs-md); color: var(--text-2); }
  .filter-field select { width: 100%; min-height: 48px; font-size: var(--fs-md); }
  .filter-field select:disabled { color: var(--text-muted); border-style: dashed; cursor: not-allowed; }
  .filter-help { margin: 8px 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-muted); max-width: 60ch; }
  .filter-note {
    display: grid; gap: 8px; justify-items: start;
    margin: 16px 0 0; padding: 8px 12px; border-radius: var(--r-1);
    background: var(--warn-weak); color: var(--warn); font: 600 var(--fs-sm)/1.45 var(--font-sans);
  }
  .filter-note > p { margin: 0; }

  /* Segmented window control: three 48 px segments; the radio is visually hidden, the label is the target. */
  .filter-segment-track {
    container: filter-segment / inline-size;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px;
    border: 1px solid var(--border-input); border-radius: var(--r-2); background: var(--bg);
  }
  .filter-segment label {
    position: relative; display: flex; align-items: center; justify-content: center; gap: 4px;
    min-height: 48px; padding: 0 6px; border-radius: calc(var(--r-2) - 3px);
    color: var(--text); font: 600 var(--fs-md)/1.2 var(--font-sans); text-align: center; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-out);
  }
  .filter-segment label:has(input:checked) {
    background: var(--accent); color: var(--accent-ink);
    box-shadow: inset 0 0 0 2px var(--border-strong);
  }
  .filter-segment label:has(input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
  .filter-check { width: 18px; height: 18px; flex: none; }
  .filter-segment label:not(:has(input:checked)) .filter-check { display: none; }
  /* Phone widths: the check becomes a corner tick so "Last 30 days" stays on one line. */
  @container filter-segment (max-width: 420px) {
    .filter-segment label { font-size: var(--fs-sm); white-space: nowrap; padding-inline: 4px; }
    .filter-segment label .filter-check { position: absolute; top: 4px; left: 4px; width: 14px; height: 14px; }
  }
  @media (hover: hover) and (pointer: fine) {
    .filter-segment label:not(:has(input:checked)):hover { background: var(--accent-weak); }
    .filter-row:hover { background: var(--accent-weak); }
  }

  /* Status radio rows, 48 px; zero-count rows are hidden by filters.js (C-07). */
  .filter-rows { display: grid; }
  .filter-row {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 8px; margin-inline: -8px;
    border-bottom: 1px solid var(--border); cursor: pointer;
    font-size: var(--fs-md); line-height: 1.3;
  }
  .filter-row[hidden] { display: none; }
  .filter-row input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
  .filter-row-label { flex: 1 1 auto; min-width: 0; }
  .filter-n { flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .filter-row:has(input:checked) { font-weight: 700; }
  .filter-rows > .filter-help { margin-top: 10px; }

  .filter-roadmap { margin: 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2); }
  .filter-roadmap a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--text); font-weight: 600; }
  .filter-error, .filter-loading { display: grid; gap: 12px; justify-items: start; margin: 0; font-size: var(--fs-md); line-height: 1.5; color: var(--text-2); }
  .filter-error > p { margin: 0; }
  .filter-foot-clear[hidden] { display: none; }

  /* ---- Dates list: #stamps-body and #about-stamps (§10) ---------------------------------------------- */
  .stamp-list-intro { margin: 0 0 12px; font-size: var(--fs-md); line-height: 1.5; color: var(--text-2); max-width: 62ch; }
  .stamp-list { margin: 0; border-top: 1px solid var(--border); }
  .stamp-list-row { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .stamp-list-label { font: 700 var(--fs-md)/1.3 var(--font-sans); color: var(--text); }
  .stamp-list-value { margin: 0; font-size: var(--fs-md); line-height: 1.4; font-variant-numeric: tabular-nums; color: var(--text); }
  .stamp-list-note { margin: 2px 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-muted); max-width: 62ch; }
  .stamp-list-commit { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95em; }
  .stamp-list-sweep {
    margin: 16px 0 0; padding: 10px 12px; border-inline-start: 3px solid var(--border-strong);
    background: var(--bg-sunken); font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2);
  }
  .stamp-list-closing { margin: 16px 0 0; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-muted); max-width: 62ch; }
  @media (min-width: 600px) {
    .stamp-list-row { grid-template-columns: minmax(0, 13em) minmax(0, 1fr); column-gap: 16px; }
    .stamp-list-label { grid-row: span 2; padding-top: 1px; }
    .stamp-list-value, .stamp-list-note { grid-column: 2; }
  }

  /* ---- #data-notice lines and "What this means" (§4.2; WP1 styles the container) --------------------- */
  /* The 44 px summary overlaps the notice's bottom padding, so the strip stays compact. */
  .notice-more { margin: -2px 0 -12px; }
  .notice-more[open] { margin-bottom: 0; }
  .notice-more > summary { width: fit-content; min-height: var(--tap); padding-block: 10px; font-weight: 600; cursor: pointer; }
  .notice-more > p { margin: 0 0 4px; max-width: 75ch; color: var(--text-2); }
  .notice-line {
    display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; padding: 6px 12px;
    border-radius: var(--r-1); background: var(--warn-weak); color: var(--warn);
    font-weight: 600;
  }
  .notice-line .icon { width: 18px; height: 18px; margin-top: 1px; }
  .notice-line[data-kind="error"], .notice-line[data-kind="countries-error"], .notice-line[data-kind="contexts-error"] { background: var(--danger-weak); color: var(--danger); }
  .notice-line-body { flex: 1 1 auto; min-width: 0; }
  .notice-line-text { text-wrap: pretty; }
  .notice-date { white-space: nowrap; }
  /* "Why?" ends the warn line: a 44 px target whose negative block margin keeps the line box one text line tall. */
  .notice-why-btn {
    display: inline-flex; align-items: center; gap: 2px; min-width: var(--tap); min-height: var(--tap);
    margin: -12px 0 -12px 2px; padding: 0 6px; border: 0; border-radius: var(--r-1); background: none;
    color: inherit; font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: .2em;
    vertical-align: baseline; cursor: pointer;
  }
  .notice-why-btn::after {
    content: ""; width: .5em; height: .5em; margin-inline-start: 4px; border: solid currentColor; border-width: 0 2px 2px 0;
    transform: translateY(-2px) rotate(45deg); transition: transform var(--dur-1) var(--ease-out);
  }
  .notice-why-btn[aria-expanded="true"]::after { transform: translateY(2px) rotate(-135deg); }
  .notice-why { margin-top: 6px; font-weight: 500; }
  .notice-why[hidden] { display: none; }
  .notice-why-line { margin: 0; max-width: 75ch; }
  .notice-why-line + .notice-why-line { margin-top: 6px; }
  @media (min-width: 600px) { .notice-line { padding-block: 8px; } }
  @media (min-width: 1200px) {
    .notice-inner { display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; }
    .notice-pilot { flex: 0 1 auto; }
    .notice-more { margin-block: -12px; }
    .notice-more[open] { flex-basis: 100%; }
    .notice-line { flex-basis: 100%; }
  }

  @media (forced-colors: active) {
    .filter-segment label:has(input:checked) { border: 2px solid CanvasText; }
    .feed-density button[aria-pressed="true"] { border: 2px solid CanvasText; }
    .notice-line, .feed-gap { border: 1px solid CanvasText; }
  }
}
