/* =============================================================================
   Components. Every one uses semantic tokens, supports light and dark, and has
   default, hover, focus-visible, active and disabled states.
   Rules: 05-components.md, 02-color.md, 06-motion.md, 08-accessibility.md.
   ============================================================================= */

/* ---- Icons -------------------------------------------------------------- */
.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.icon-sm { width: 1rem; height: 1rem; }

/* The brand chevron used as a link arrow. Small, optically aligned. */
.chevron { width: 0.6em; height: 0.6em; flex: none; color: currentColor; }

/* ---- Brand lockup ------------------------------------------------------- */
/* Text-only for now (DECISIONS.md 7): the product name in Semibold beside the
   brand chevron. The official wordmark drops in here as a one-step swap once
   its origin is confirmed: replace .lockup-mark with the <img> and keep
   .lockup-name. Nothing from design-system/assets/logo/ ships in this folder. */
.lockup {
  display: inline-flex; align-items: center; gap: var(--space-3);
  text-decoration: none; color: var(--color-text);
}
.lockup-mark {
  width: 1.125rem; height: 1.125rem; flex: none;
  color: var(--color-accent);           /* purple on light */
}
[data-theme="dark"] .lockup-mark { color: var(--neutral-white); }   /* white on dark */
.lockup-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  letter-spacing: -0.015em;
}
.lockup:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(10px);
  /* A hairline plus a soft shadow falling onto the page, not a grey fill: the
     bar stays the colour of the page and is separated by the shadow under it. */
  border-bottom: var(--border-width) solid var(--color-border);
  box-shadow: 0 8px 20px -14px rgba(0, 0, 0, 0.45);
}

/* The bar spans the viewport with a one-gutter inset on each side, like the
   console: the lockup sits near the left edge and the profile near the right,
   instead of both being pulled in to the 1216px content column. Three tracks,
   the outer two equal, so the navigation is centred on the bar itself. */
.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-5);
  min-height: var(--nav-h);
  padding-inline: var(--gutter);
}

.nav { justify-self: center; }
.nav-list { display: flex; gap: var(--space-7); list-style: none; }
.nav-link {
  display: inline-block; font-size: var(--text-body);
  color: var(--color-text); text-decoration: none;
  padding-block: var(--space-2); border-bottom: 2px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.nav-link:hover { border-bottom-color: var(--color-border); }
.nav-link[aria-current="page"] { font-weight: var(--weight-semibold); border-bottom-color: var(--color-text); }
.nav-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }

.topbar-actions {
  justify-self: end;
  display: flex; align-items: center; gap: var(--space-5);
}

/* Square icon control, sized to the 44px touch target. */
.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem;
  color: var(--color-text); text-decoration: none;
  background: transparent; border: var(--border-width) solid transparent;
  border-radius: var(--radius-control); cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.icon-btn:hover { border-color: var(--color-border); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* The same 2px underline the nav links use, drawn inside the box so the
   button does not change size when it becomes the current page. */
.icon-btn[aria-current="page"] { box-shadow: inset 0 -2px 0 0 var(--color-text); }

/* The count is decorative: the link's accessible name carries it as words. */
.icon-btn-count {
  position: absolute; top: 0.125rem; right: 0.125rem;
  min-width: 1.125rem; height: 1.125rem; padding-inline: 0.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: var(--weight-semibold); line-height: 1;
  color: var(--color-on-accent); background: var(--color-accent);
  border-radius: var(--radius-control);
}
/* The attribute alone would lose to display: inline-flex above. */
.icon-btn-count[hidden] { display: none; }

/* Profile. A circle, because that is what a photo will be when sign-in exists;
   until then it holds the brand chevron rather than a stand-in face. */
.avatar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  color: var(--color-accent);
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.avatar-btn:hover { border-color: var(--color-accent); }
.avatar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.avatar-mark { width: 0.875rem; height: 0.875rem; display: block; }

@media (max-width: 560px) {
  .topbar-inner { gap: var(--space-3); }
  .lockup { gap: var(--space-2); }
  .lockup-name { font-size: var(--text-small); }
}

/* Mobile navigation: a button that opens a full-width panel. The lockup, the
   menu button and the right-hand cluster stay on one row. */
.nav-toggle { display: none; }
@media (max-width: 767px) {
  .topbar-inner { display: flex; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; margin-left: auto;
    background: transparent; border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-control); color: var(--color-text); cursor: pointer;
  }
  .nav-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .nav {
    position: absolute; left: 0; right: 0; top: 100%;
    justify-self: auto; padding: var(--space-4) var(--gutter);
    background: var(--color-bg);
    border-bottom: var(--border-width) solid var(--color-border);
    display: none;
  }
  .nav.is-open { display: block; }
  .nav-list { flex-direction: column; gap: 0; }
  .nav-link { padding-block: var(--space-4); border-bottom: 0; }
  .nav-link[aria-current="page"] { border-bottom: 0; }
  .topbar-actions { justify-self: auto; }
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 3rem; padding-inline: var(--space-5);
  font: inherit; font-size: 1rem; font-weight: var(--weight-semibold);
  text-align: center; text-decoration: none; cursor: pointer;
  border: var(--border-width) solid transparent; border-radius: var(--radius-control);
  transition: background-color var(--duration-base) var(--ease-standard),
              border-color var(--duration-base) var(--ease-standard),
              color var(--duration-base) var(--ease-standard);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-pressed); }

.btn-secondary { background: transparent; color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-text); color: var(--color-text-inverse); }
.btn-secondary:active { background: var(--color-accent-pressed); border-color: var(--color-accent-pressed); color: var(--color-on-accent); }

.btn-sm { min-height: 2.75rem; font-size: var(--text-small); padding-inline: var(--space-4); }

/* Disabled: 3:1 dashed boundary, plus aria-disabled. Never colour alone. */
.btn[aria-disabled="true"], .btn:disabled {
  background: transparent; color: var(--neutral-gray-dark);
  border-color: var(--color-border); border-style: dashed;
  pointer-events: none;
}

/* ---- Text link with the brand chevron ----------------------------------- */
.link {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--color-link); font-weight: var(--weight-semibold); text-decoration: none;
  background: none; border: 0; padding: 0; font-size: inherit; font-family: inherit; cursor: pointer;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }

/* ---- Forms -------------------------------------------------------------- */
.field + .field { margin-top: var(--space-5); }
.field-label { display: block; font-size: var(--text-small); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }
.field-req { font-weight: var(--weight-regular); color: var(--color-text-muted); }

.field-input, .field-select, .field-textarea {
  display: block; width: 100%; min-height: 3rem;
  padding: var(--space-3) var(--space-4);
  font: inherit; font-size: var(--text-body);
  color: var(--color-text); background: var(--color-bg);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
}
.field-textarea { min-height: 0; resize: vertical; }
.field-input::placeholder, .field-textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
.field-input:focus-visible, .field-select:focus-visible, .field-textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.field-input[aria-invalid="true"], .field-textarea[aria-invalid="true"], .field-select[aria-invalid="true"] {
  border-color: var(--color-accent-pressed); border-width: 2px;
}
.field-help { font-size: var(--text-small); color: var(--color-text-muted); margin-top: var(--space-2); }

/* Error text: icon plus words, never a red border on its own. */
.field-error {
  display: flex; align-items: flex-start; gap: var(--space-2);
  font-size: var(--text-small); color: var(--color-text);
  margin-top: var(--space-2);
}
.field-error .icon { width: 1.125rem; height: 1.125rem; margin-top: 2px; }

fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
legend { padding: 0; font-size: var(--text-small); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }

.choice-grid { display: grid; gap: var(--space-2); }
@media (min-width: 640px) { .choice-grid.cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .choice-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.choice {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-height: 2.75rem; padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control); cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
              background-color var(--duration-fast) var(--ease-standard);
}
.choice:hover { border-color: var(--color-border-strong); }
.choice input { flex: none; width: 1.125rem; height: 1.125rem; margin: 3px 0 0; accent-color: var(--color-accent); }
.choice:has(input:focus-visible) { outline: none; box-shadow: var(--focus-ring); }
/* Selected: fill AND a 2px border AND the native control's own check mark, so
   selection never depends on colour alone. Padding compensates for the border. */
.choice:has(input:checked) {
  background: var(--color-accent-soft); border-color: var(--color-accent); border-width: 2px;
  padding: calc(var(--space-3) - 1px) calc(var(--space-4) - 1px);
}
.choice-text { font-size: var(--text-small); }
.choice-sub { display: block; color: var(--color-text-muted); font-size: var(--text-caption); margin-top: 2px; }
[data-theme="dark"] .choice:has(input:checked) .choice-sub { color: var(--neutral-gray-medium); }

/* ---- Stepper ------------------------------------------------------------ */
.stepper { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-5); margin-bottom: var(--space-4); }
.stepper li {
  font-size: var(--text-small); color: var(--color-text-muted);
  padding-bottom: var(--space-2); border-bottom: 2px solid transparent;
}
.stepper li.is-done { color: var(--color-text); }
.stepper li[aria-current="step"] { color: var(--color-text); font-weight: var(--weight-semibold); border-bottom-color: var(--color-accent); }
.step-count { font-size: var(--text-small); color: var(--color-text-muted); margin-bottom: var(--space-6); }

/* ---- Messages ----------------------------------------------------------- */
.msg {
  display: flex; gap: var(--space-3); padding: var(--space-5);
  background: var(--color-bg-subtle); border-radius: var(--radius-panel);
}
[data-theme="dark"] .msg { background: transparent; border: var(--border-width) solid var(--color-border); }
.msg-success { border-left: 4px solid var(--color-border-strong); }
.msg-error { border-left: 4px solid var(--color-accent-pressed); }
[data-theme="dark"] .msg-error { border-left-color: var(--secondary-pink); }
.msg .icon { width: 1.375rem; height: 1.375rem; margin-top: 2px; }
.msg-title { font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.msg:empty, .msg[hidden] { display: none; }

/* ---- Hairline list (the innovation feed) -------------------------------- */
.hair-list { border-top: var(--border-width) solid var(--color-border); }
.hair-row {
  display: grid; gap: var(--space-2) var(--space-6); align-items: start;
  padding-block: var(--space-5);
  border-bottom: var(--border-width) solid var(--color-border);
  text-decoration: none; color: inherit;
}
@media (min-width: 768px) { .hair-row { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
a.hair-row:hover .hair-title { text-decoration: underline; text-underline-offset: 3px; }
a.hair-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.hair-title { font-size: var(--text-h4); font-weight: var(--weight-semibold); }
.hair-desc {
  color: var(--color-text-muted); font-size: var(--text-small);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hair-facts { font-size: var(--text-caption); color: var(--color-text-muted); margin-top: var(--space-2); }

/* Row plus its bookmark. The button is a sibling of the link, laid over the
   row's right-hand padding, so neither control is nested in the other. */
.hair-item { position: relative; }
.hair-item .hair-row { padding-right: 3.25rem; }

.bookmark-btn {
  position: absolute; top: var(--space-4); right: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem;
  color: var(--color-text-muted); background: transparent;
  border: var(--border-width) solid transparent; border-radius: var(--radius-control);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.bookmark-btn:hover { color: var(--color-text); border-color: var(--color-border); }
.bookmark-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.bookmark-btn[aria-pressed="true"] { color: var(--color-accent); }

/* Maturity: words plus a three-step indicator, never a coloured pill. */
.maturity { display: inline-flex; align-items: center; gap: var(--space-2); }
.maturity-steps { width: 1.625em; height: 0.5em; fill: none; stroke: currentColor; stroke-width: 1.5; }
.maturity-steps .on { fill: currentColor; }

/* ---- Table -------------------------------------------------------------- */
.table-wrap { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
caption { text-align: left; color: var(--color-text-muted); font-size: var(--text-small); padding-bottom: var(--space-4); }
th, td { text-align: left; padding: var(--space-4) var(--space-3); border-bottom: var(--border-width) solid var(--color-border); }
th { font-weight: var(--weight-semibold); font-size: var(--text-caption); color: var(--color-text-muted); }
thead th { border-bottom-color: var(--color-border-strong); }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Narrow: stacked blocks, label above value. The table stays semantic and the
   header row is kept for assistive technology. 04-layout-and-spacing.md. */
@media (max-width: 767px) {
  table, tbody, tbody tr, tbody td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  tbody tr { padding-block: var(--space-4); border-bottom: var(--border-width) solid var(--color-border); }
  tbody td { border-bottom: 0; padding: var(--space-1) 0; text-align: left; }
  tbody td::before {
    content: attr(data-label); display: block;
    font-size: var(--text-caption); font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
  }
  tbody td.num { text-align: left; }
}

/* ---- Bars --------------------------------------------------------------- */
/* display:block matters: these are spans, and an inline box ignores height,
   so the fill would collapse and only the track border would show. */
.bar-row {
  display: grid; grid-template-columns: minmax(5rem, 1fr) minmax(0, 3fr) auto;
  gap: var(--space-4); align-items: center; padding-block: var(--space-3);
}
.bar-track {
  display: block; height: 0.625rem;
  background: var(--color-bg-subtle);
  border: var(--border-width) solid var(--color-border);
}
[data-theme="dark"] .bar-track { background: transparent; }
.bar-fill { display: block; height: 100%; background: var(--color-text); }
.bar-row.is-lead .bar-fill { background: var(--color-accent); }
.bar-value { font-variant-numeric: tabular-nums; font-size: var(--text-small); }

/* ---- Loading skeleton --------------------------------------------------- */
.skeleton-row { padding-block: var(--space-5); border-bottom: var(--border-width) solid var(--color-border); }
.skeleton-bar {
  height: 0.75rem; background: var(--color-bg-subtle);
  border: var(--border-width) solid var(--color-border);
}
[data-theme="dark"] .skeleton-bar { background: transparent; }
.skeleton-bar + .skeleton-bar { margin-top: var(--space-3); }

/* ---- Definition list (facts) -------------------------------------------- */
.facts { border-top: var(--border-width) solid var(--color-border); margin: 0; }
.facts > div {
  display: grid; gap: var(--space-1);
  padding-block: var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
}
@media (min-width: 640px) { .facts > div { grid-template-columns: 1fr 2fr; gap: var(--space-5); } }
.facts dt { font-size: var(--text-caption); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.facts dd { margin: 0; font-size: var(--text-small); }

/* ---- Sample-content note (one component, easy to remove) ---------------- */
.sample-note {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-caption); color: var(--color-text-muted);
  border: var(--border-width) dashed var(--color-border);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
}

/* ---- Footer and the Appearance toggle ----------------------------------- */
/* Same treatment as the top bar: the colour of the page at the same
   translucency, a hairline, and a soft shadow rising off the page. Not a grey
   band -- a filled footer reads as a seam. */
.site-footer {
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: var(--border-width) solid var(--color-border);
  box-shadow: 0 -8px 20px -14px rgba(0, 0, 0, 0.45);
  padding-block: var(--space-5);
  margin-top: var(--space-7);
}

/* Spread across the viewport with the same one-gutter inset as the bar, so the
   footer lockup sits under the top-bar lockup and the right-hand column ends
   where the profile does. */
.footer-grid {
  display: grid;
  gap: var(--space-5);
  padding-inline: var(--gutter);
}
@media (min-width: 768px) {
  .footer-grid {
    /* The first column is widest so the legal links and the Appearance control
       stay on one row; wrapping them adds 40px to the whole footer. */
    grid-template-columns: 2.5fr 1fr 1.2fr;
    gap: var(--space-7);
    align-items: start;
  }
}

.footer-brand > * + * { margin-top: var(--space-2); }

/* The legal links and the Appearance control share one row. */
.footer-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}
.footer-lockup { display: flex; align-items: center; gap: var(--space-3); }

.footer-legal { display: flex; flex-wrap: wrap; gap: var(--space-4); list-style: none; }

/* Vertical in the footer's own column, as a list of destinations rather than a
   row of inline links. */
.footer-nav .footer-links { flex-direction: column; gap: var(--space-1); }

/* The last column ends at the right gutter, mirroring the top bar, so the two
   bars are inset by the same amount on both sides. */
@media (min-width: 768px) {
  .footer-aside { justify-self: end; text-align: right; }
}
.footer-aside > * + * { margin-top: var(--space-2); }

.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-4); list-style: none; }
.footer-links a { font-size: var(--text-small); color: var(--color-link); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.footer-links a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }

/* A button that reads as a link, for the two dialogs. It is a button because it
   opens something on this page instead of going anywhere. */
.link-button {
  font: inherit; font-size: var(--text-small);
  color: var(--color-link); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: none;
}
.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control); }

/* A segmented slider: one track, two options, and a thumb that slides between
   them. Native radios underneath, hidden visually but still focusable, so the
   radiogroup semantics and theme.js are untouched. Corners stay at
   --radius-control: a pill would be the only rounded thing on the page
   (DECISIONS.md 2). */
.appearance { display: flex; align-items: center; gap: var(--space-2); }
.appearance-label { font-size: var(--text-caption); font-weight: var(--weight-semibold); }

.switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-bg);
}
.switch:has(input:focus-visible) { outline: none; box-shadow: var(--focus-ring); }

.switch-thumb {
  position: absolute; inset-block: 0; left: 0; width: 50%;
  background: var(--color-accent);
  transition: transform var(--duration-base) var(--ease-standard);
}
.switch:has(input[value="dark"]:checked) .switch-thumb { transform: translateX(100%); }

.switch-option {
  position: relative;              /* paints above the thumb */
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 1.75rem; padding-inline: var(--space-4);
  font-size: var(--text-caption); cursor: pointer;
  transition: color var(--duration-base) var(--ease-standard);
}
.switch-option:has(input:checked) { color: var(--color-on-accent); font-weight: var(--weight-semibold); }

/* Full-size but invisible: the whole half of the track is the hit area. */
.switch-option input {
  position: absolute; inset: 0;
  margin: 0; opacity: 0; cursor: pointer;
}

/* ---- Sticky action bar --------------------------------------------------
   The wizard's Back / Continue pair pinned to the bottom of the viewport, so
   the next action is reachable without scrolling on a short laptop screen.
   Opaque background: it sits over content, and the page grid must not read
   through it. */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-nav);
  background: var(--color-bg);
  border-top: var(--border-width) solid var(--color-border);
  padding-block: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  margin-top: var(--task-space);
}
.action-bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
}
.action-bar .btn { min-width: 7.5rem; }

/* ---- Independent scroll panel -------------------------------------------
   Desktop only. The list gets its own scroll region so the page height stays
   constant however many items the feed returns. The panel header, the filter
   bar and the table head stay put; only the rows move.
   Below 1024px this is inert and the page scrolls normally. */
.scroll-panel { border: 0; }
.scroll-panel-head { }
.scroll-panel-body { }

@media (min-width: 1024px) {
  .scroll-panel {
    display: flex;
    flex-direction: column;
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-panel);
    overflow: hidden;                 /* keeps the rounded corner honest */
    /* 100vh first as the fallback, then dvh where it is supported, so mobile
       browser chrome does not clip the panel. */
    max-height: min(45rem, calc(100vh - var(--nav-h) - 3rem));
    max-height: min(45rem, calc(100dvh - var(--nav-h) - 3rem));
    min-height: 20rem;
  }

  /* Header and filter bar: fixed inside the panel. */
  .scroll-panel-head {
    flex: none;
    background: var(--color-bg);
    border-bottom: var(--border-width) solid var(--color-border);
    padding: var(--space-5);
  }

  .scroll-panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;     /* the wheel never escapes to the page */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
    padding-inline: var(--space-5);
  }
  .scroll-panel-body:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--color-focus); }

  .scroll-panel-body::-webkit-scrollbar { width: 10px; }
  .scroll-panel-body::-webkit-scrollbar-track { background: transparent; }
  .scroll-panel-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 999px;
  }

  /* A table inside a panel keeps its head visible while rows scroll. */
  .scroll-panel-body thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-bg);      /* opaque, or rows show through */
  }

  /* The first row should not collide with the sticky head. */
  .scroll-panel-body .hair-list { border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-panel-body { scroll-behavior: auto; }
}

/* ---- Empty and error states --------------------------------------------
   Centred in whatever region holds them, horizontally and vertically, rather
   than hugging the top-left corner of a tall panel. One component for the feed,
   the leaderboard and the filter no-match case. */
.state {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 16rem;
  padding: var(--space-7) var(--space-5);
  height: 100%;
}
.state-inner { max-width: 38ch; }
.state-title { font-size: var(--text-h4); font-weight: var(--weight-semibold); }
.state-body { margin-top: var(--space-3); font-size: var(--text-small); color: var(--color-text-muted); }
.state-action { margin-top: var(--space-5); }
.state-retry { margin-top: var(--space-4); font-size: var(--text-small); }

/* Inside a scroll panel the body is a flex child, so let the state fill it and
   centre within the available height instead of the content height. */
@media (min-width: 1024px) {
  .scroll-panel-body > .state { min-height: 100%; }
}

/* ---- Quick-link tiles ---------------------------------------------------- */
/* Three equal tiles, flat, with a very light wash of the accent. The tint is
   built from --color-accent-soft so one rule covers both themes: on white it is
   a pale lavender, on black a faint purple glow over the page, never a lighter
   grey surface (02-color.md). */
.tiles {
  list-style: none;
  display: grid;
  gap: var(--space-5);
}
@media (min-width: 768px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 5rem; padding-inline: var(--space-5);
  text-decoration: none; color: var(--color-text);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background-image: linear-gradient(135deg,
    color-mix(in srgb, var(--color-accent-soft) 55%, transparent) 0%,
    transparent 100%);
  transition: border-color var(--duration-base) var(--ease-standard);
}
.tile:hover { border-color: var(--color-border-strong); }
.tile:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* One tile carries more of the tint, as the middle tile does on the console. */
.tile-accent {
  background-image: linear-gradient(135deg, var(--color-accent-soft) 0%,
    color-mix(in srgb, var(--color-accent-soft) 30%, transparent) 100%);
}

.tile-icon { width: 1.25rem; height: 1.25rem; flex: none; color: var(--color-accent); }
.tile-label { font-size: var(--text-body); font-weight: var(--weight-medium); }

/* ---- Dialogs ------------------------------------------------------------ */
/* Native <dialog>: Escape, the backdrop and focus containment come from the
   platform rather than from script. app.js only opens them and returns focus.
   Narrower than the console's, because a 1500px line of legal text is hard to
   read; wide enough that it still reads as a page-level panel. */
/* overflow: hidden matters. The UA stylesheet gives dialog its own overflow,
   so with a scrolling panel inside you get two scrollbars side by side. The
   dialog clips; .modal-inner is the one scroller. */
.modal {
  width: min(56rem, calc(100vw - 2 * var(--gutter)));
  max-height: min(85vh, 60rem);
  overflow: hidden;
  padding: 0;
  color: var(--color-text);
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.45); }

.modal-inner {
  padding: var(--space-7) var(--space-7) var(--space-8);
  overflow-y: auto;
  max-height: inherit;
  overscroll-behavior: contain;
}
.modal-inner > * + * { margin-top: var(--space-4); }
.modal-inner > h3 { margin-top: var(--space-6); }
.modal-inner > h2 { margin-top: 0; padding-right: var(--space-7); }

.modal-close {
  position: absolute; top: var(--space-5); right: var(--space-5);
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem;
  color: var(--color-text); /* Opaque: the text scrolls underneath it. */
  background: var(--color-bg);
  border: var(--border-width) solid transparent; border-radius: var(--radius-control);
  cursor: pointer;
}
.modal-close:hover { border-color: var(--color-border); }
.modal-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }
