/*
 * Design System Components
 * Reusable component styles. Requires tokens.css to be loaded first.
 *
 * Sections:
 *   1.  Layout shell
 *   2.  Navigation
 *   3.  Stat cards
 *   4.  Badges, tags, score badges
 *   5.  Buttons
 *   6.  Data tables
 *   7.  Filter bar
 *   8.  Timeline
 *   9.  Callouts
 *   10. Prose / article content
 *   11. Keyboard hints
 *   12. Score bars (in-cell)
 *   13. Reading guides
 *   14. Detail rows
 *   15. Live activity indicator
 *   16. Tooltips
 *   17. Modals / overlays
 *   18. Utility classes
 */


/* ─── 1. Layout shell ────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
}

/* Three-column variant (sidebar + main + inspector) */
.shell.shell--three-col {
  grid-template-columns: var(--sidebar-width) 1fr var(--inspector-width);
}

/* No sidebar (single-column artifact view) */
.shell.shell--single {
  grid-template-columns: 1fr;
}

.shell-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--header-height);
}

.shell-header__brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.shell-header__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Horizontal nav links within header (simple tools) */
.shell-header__nav {
  display: flex;
  align-items: center;
  height: var(--header-height);
  gap: 0;
}

.shell-header__nav-link {
  display: inline-flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.shell-header__nav-link:hover {
  color: var(--text);
}

.shell-header__nav-link.is-active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}

.shell-sidebar {
  border-right: 1px solid var(--border);
  padding: var(--space-4) 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.shell-main {
  padding: var(--space-6) var(--space-8);
  min-width: 0; /* prevent grid blowout */
}

.shell-inspector {
  border-left: 1px solid var(--border);
  padding: var(--space-4);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

/* Wrap for centered content max-width */
.content-wrap {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Responsive: stack at narrow viewports */
@media (max-width: 860px) {
  .shell,
  .shell.shell--three-col {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) auto;
  }
  .shell-sidebar  { display: none; }
  .shell-inspector { display: none; }
  .shell-main { padding: var(--space-4); }
}


/* ─── 2. Navigation ──────────────────────────────────────────────────────── */

.nav-section {
  margin-bottom: var(--space-4);
}

.nav-section__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-dim);
  padding: var(--space-1) var(--space-4);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.nav-item.is-active {
  color: var(--accent-text);
  border-left-color: var(--accent);
  background: var(--accent-surface);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-dim);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb__sep {
  color: var(--text-dim);
}

.breadcrumb__current {
  color: var(--text);
}


/* ─── 3. Stat cards ──────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
}

.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.stat-card__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: var(--leading-tight);
  margin-bottom: 3px;
}

.stat-card__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.stat-card__delta {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.stat-card__delta--up   { color: var(--success); }
.stat-card__delta--down { color: var(--error); }

/* Semantic value color variants */
.stat-card__value--success { color: var(--success); }
.stat-card__value--warning { color: var(--warning); }
.stat-card__value--error   { color: var(--error); }
.stat-card__value--accent  { color: var(--accent-text); }

/* Pipeline flow variant (horizontal with → connectors) */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.pipeline__step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
}

.pipeline__step-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pipeline__step-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pipeline__arrow {
  color: var(--border-strong);
  font-size: 18px;
  flex-shrink: 0;
}


/* ─── 4. Badges, tags, score badges ─────────────────────────────────────── */

/* Status badge — filled pill with border */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border: 1px solid;
  line-height: 1.6;
  white-space: nowrap;
}

.badge--success {
  color: var(--success);
  background: var(--success-subtle);
  border-color: var(--success-muted);
}

.badge--warning {
  color: var(--warning);
  background: var(--warning-subtle);
  border-color: var(--warning-muted);
}

.badge--error {
  color: var(--error);
  background: var(--error-subtle);
  border-color: var(--error-muted);
}

.badge--info {
  color: var(--info);
  background: var(--info-subtle);
  border-color: var(--info);
}

.badge--neutral {
  color: var(--text-muted);
  background: var(--surface-raised);
  border-color: var(--border);
}

.badge--accent {
  color: var(--accent-text);
  background: var(--accent-surface);
  border-color: var(--accent-muted);
}

/* Semantic aliases for data-tool status vocabulary */
.badge--verified  { color: var(--success); background: var(--success-subtle); border-color: var(--success-muted); }
.badge--pending   { color: var(--warning); background: var(--warning-subtle); border-color: var(--warning-muted); }
.badge--dropped   { color: var(--error);   background: var(--error-subtle);   border-color: var(--error-muted);   }
.badge--active    { color: var(--accent-text); background: var(--accent-surface); border-color: var(--accent-muted); }
.badge--draft     { color: var(--text-muted); background: var(--surface-raised); border-color: var(--border); }

/* Tag — outline chip for secondary metadata */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-medium);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  white-space: nowrap;
}

.tag:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* Score badge — fixed-width, bucketed continuous range */
.score {
  display: inline-block;
  min-width: 44px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.score--hi  { background: var(--score-hi-bg);  color: var(--score-hi);  }
.score--mid { background: var(--score-mid-bg); color: var(--score-mid); }
.score--lo  { background: var(--score-lo-bg);  color: var(--score-lo);  }
.score--na  { background: var(--surface-raised); color: var(--text-muted); }

/* Convenience: auto-assign band by data-score attribute */
[data-score] .score { /* use JS to set the modifier class */ }


/* ─── 5. Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  cursor: pointer;
  border: 1px solid;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: var(--accent-muted);
  border-color: var(--accent-muted);
}

.btn--secondary {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}
.btn--secondary:hover {
  background: var(--border);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.btn--destructive {
  background: var(--error-subtle);
  border-color: var(--error-muted);
  color: var(--error);
}
.btn--destructive:hover {
  opacity: 0.8;
}

.btn--sm {
  padding: 3px 8px;
  font-size: var(--text-sm);
}

.btn--lg {
  padding: 10px var(--space-5);
  font-size: var(--text-md);
}

.btn--icon {
  padding: 6px;
  min-width: 32px;
}


/* ─── 6. Data tables ─────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th.col--num,
.data-table td.col--num {
  text-align: right;
}

.data-table th.col--center,
.data-table td.col--center {
  text-align: center;
}

.data-table td {
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table td.col--num {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.data-table td.col--mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.data-table tbody tr:hover {
  background: var(--surface-raised);
}

/* Row with two lines (title + meta) */
.table-row__title {
  font-weight: var(--weight-medium);
  color: var(--text);
}

.table-row__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* In-cell bar chart (gradient background) */
.table-bar-cell {
  position: relative;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.table-bar-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-sm);
}

.table-bar-val {
  position: relative;
}

/* Sort indicator on sortable columns */
.col--sortable {
  cursor: pointer;
  user-select: none;
}

.col--sortable:hover {
  color: var(--text);
}

.col--sort-asc::after  { content: " ▲"; font-size: 9px; }
.col--sort-desc::after { content: " ▼"; font-size: 9px; }
.col--sort-none::after { content: " ⇅"; font-size: 9px; opacity: 0.4; }

/* TanStack Table: button-based sort header (used with DataTableColumnHeader) */
.col--sortable-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.col--sortable-btn:hover { color: var(--text); }

/* TanStack Table: selected row highlight */
.data-table tbody tr[data-state="selected"] {
  background: var(--accent-surface);
}
.data-table tbody tr[data-state="selected"] td {
  color: var(--text);
}

/* Responsive: horizontally scrollable */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* ─── 7. Filter bar ──────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.filter-input,
.filter-select {
  padding: 5px var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--transition);
}

.filter-input {
  min-width: 180px;
}

.filter-input::placeholder {
  color: var(--text-dim);
}

.filter-input:focus,
.filter-select:focus {
  border-color: var(--border-focus);
}

/* Triggered filter button — shows count badge inside */
.filter-input--active {
  border-color: var(--accent-muted);
  color: var(--text);
}

/* Active filter chip (dismissible) */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent-surface);
  border: 1px solid var(--accent-muted);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--accent-text);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition);
}

.filter-chip:hover {
  opacity: 0.8;
}

.filter-chip__remove {
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

.filter-clear {
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
  font-family: var(--font-sans);
  margin-left: auto;
}

.filter-clear:hover {
  color: var(--text-muted);
}

/* Sidebar filter panel variant (vertical layout) */
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
}

.filter-panel__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-panel__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-dim);
  font-weight: var(--weight-medium);
}

.filter-panel .filter-input,
.filter-panel .filter-select {
  width: 100%;
}


/* ─── 8. Timeline ────────────────────────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.timeline-year {
  border-left: 2px solid var(--accent);
  padding-left: var(--space-4);
}

.timeline-year__label {
  font-size: 22px;
  font-weight: var(--weight-normal);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  line-height: 1;
}

.timeline-items {
  margin: 0;
  padding: 0 0 0 var(--space-2);
  list-style: none;
}

.timeline-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
  color: var(--text);
  line-height: var(--leading-normal);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-item__source {
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-left: var(--space-2);
}


/* ─── 9. Callouts ────────────────────────────────────────────────────────── */

.callout {
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-3);
}

.callout--info {
  background: var(--info-subtle);
  border-color: var(--info);
  color: var(--text);
}

.callout--warning {
  background: var(--warning-subtle);
  border-color: var(--warning);
  color: var(--text);
}

.callout--success {
  background: var(--success-subtle);
  border-color: var(--success);
  color: var(--text);
}

.callout--error {
  background: var(--error-subtle);
  border-color: var(--error);
  color: var(--text);
}


/* ─── 10. Prose / Article layouts ───────────────────────────────────────── */
/*
 * Two layout systems:
 *   .article          — narrative-first, named CSS grid with breakout zones
 *   .article--split   — prose + data panel side by side
 *
 * Typography registers:
 *   --font-prose (Newsreader) — body, narrative headings (h1, h3, lede, pullquote)
 *   --font-sans  (Geist)      — structural h2 dividers, kickers, bylines, captions
 *   --font-mono  (Geist Mono) — inline code, numeric data cells
 */

/* ── Article grid ─────────────────────────────────────────────────────────
 *
 *  7 tracks, 4 named zones:
 *
 *  [full-start]
 *    1fr                         ← outer-left (page margin)
 *  [breakout-start]
 *    0–130px                     ← left breakout gutter
 *  [prose-start]
 *    0–680px                     ← PROSE (default for all children)
 *  [prose-end]
 *    --article-margin-gap (32px) ← gutter between prose and margin column
 *  [margin-start]
 *    0–200px                     ← MARGIN (definitions, notes, small charts)
 *  [margin-end]
 *    minmax(20px, 1fr)           ← outer-right (minimum keeps margin from clipping)
 *  [full-end]
 *
 *  Zone shortcuts:
 *    grid-column: prose     → center column only (default)
 *    grid-column: breakout  → prose + left gutter (940px max)
 *    grid-column: full      → full container edge-to-edge
 *    grid-column: margin    → right margin column (200px)
 *
 *  Margin notes flow in document order alongside prose — no JS needed.
 *  They stack vertically adjacent to their reference points.
 *  Below --prose-wide (940px) the margin column collapses to 0 and notes
 *  pull back into the prose column via a class swap or media query.
 */

.article {
  --article-margin-gap:   var(--space-8);
  --article-margin-width: 200px;

  display: grid;
  grid-template-columns:
    [full-start]
    minmax(var(--space-5), 1fr)
    [breakout-start]
    minmax(0, calc((var(--prose-wide) - var(--prose-max)) / 2))
    [prose-start]
    minmax(0, var(--prose-max))
    [prose-end]
    var(--article-margin-gap)
    [margin-start]
    minmax(0, var(--article-margin-width))
    [margin-end]
    minmax(var(--space-5), 1fr)
    [full-end];
  row-gap: 0;
  width: 100%;
}

.article > * {
  grid-column: prose;
}

.article-breakout {
  grid-column: breakout;
}

.article-full {
  grid-column: full;
}

/* Margin items sit in the right-gutter column, flowing alongside prose */
.article-marginnote {
  grid-column: margin;
}

/*
 * Paired prose + margin row — subgrid wrapper that lets a paragraph and its
 * margin note share a single grid row and align at the top.
 * Usage: <div class="article-mrow"><p>…</p><aside class="article-marginnote …">…</aside></div>
 */
.article-mrow {
  grid-column: prose-start / margin-end;
  display: grid;
  grid-template-columns: subgrid;
  align-items: start;
}
.article-mrow > * {
  grid-column: prose;
}
.article-mrow > .article-marginnote {
  grid-column: margin;
}

/*
 * Prose block — groups a float figure with the paragraphs that wrap around it.
 * Direct children of .article can't participate in float layout since grid items
 * are isolated formatting contexts. Wrap float + wrapping text in this container.
 */
.article-prose-block {
  grid-column: prose;
  display: flow-root; /* contains internal floats without a clearfix */
}


/* ── Article header ────────────────────────────────────────────────────── */

.article-header {
  padding-bottom: var(--space-8);
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--border);
}

/* Small label above the headline: "GOVERNANCE · APR 2026" */
.article-kicker {
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--accent-text);
  margin-bottom: var(--space-3);
}

.article-h1 {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 var(--space-4);
}

/* Subtitle / standfirst — one or two sentences below h1 */
.article-dek {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 19px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}

.article-byline {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.article-byline__sep {
  color: var(--border-strong);
}


/* ── Article body typography ───────────────────────────────────────────── */

/* Base prose: all body text within .article uses --font-prose */
.article p,
.article li,
.article dt,
.article dd {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: var(--leading-relaxed);
  color: var(--text);
}

/* First paragraph of article — slightly larger */
.article-lede {
  font-size: 19px !important;
  color: var(--text) !important;
}

/* Structural section break — Geist Sans, acts as a visual chapter marker */
.article h2,
.article-section {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  margin: var(--space-12) 0 var(--space-6);
}

/* Narrative section heading — Newsreader, within a prose section */
.article h3,
.article-h3 {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 22px;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--text);
  margin: var(--space-8) 0 var(--space-3);
}

.article h4,
.article-h4 {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin: var(--space-6) 0 var(--space-2);
}

.article p {
  margin: 0 0 var(--space-5);
}

.article a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent);
  text-underline-offset: 2px;
}

.article a:hover {
  text-decoration-color: var(--accent-text);
}

.article strong {
  font-weight: var(--weight-semibold);
}

.article em {
  font-style: italic;
}

.article ul,
.article ol {
  margin: 0 0 var(--space-5);
  padding-left: var(--space-6);
}

.article li {
  margin-bottom: var(--space-2);
}

.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-10) 0;
  grid-column: prose;
}

.article code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-raised);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.article pre {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin: 0 0 var(--space-5);
}

.article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}


/* ── Blockquote ────────────────────────────────────────────────────────── */

.article blockquote {
  border-left: 2px solid var(--accent);
  padding-left: var(--space-5);
  margin: var(--space-6) 0;
  color: var(--text-muted);
  font-style: italic;
}

.article blockquote p {
  font-size: 17px;
  color: inherit;
}

.article blockquote cite {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-style: normal;
  color: var(--text-dim);
  margin-top: var(--space-2);
}


/* ── Pull quote ────────────────────────────────────────────────────────── */

.article-pullquote {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: clamp(20px, 2.5vw, 26px);
  font-weight: 400;
  font-style: italic;
  line-height: 1.45;
  color: var(--text);
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
  padding: var(--space-6) 0 var(--space-5);
  margin: var(--space-8) 0;
}

.article-pullquote cite {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-style: normal;
  color: var(--text-dim);
  margin-top: var(--space-3);
}


/* ── Figure / caption ──────────────────────────────────────────────────── */

.article-figure {
  margin: var(--space-8) 0;
}

.article-figure > :first-child {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-inset);
}

.article-figcaption {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: var(--space-2);
}

.article-figcaption strong {
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}


/* ── Text-flow figures ───────────────────────────────────────────────────
 *
 * Figures that let prose wrap around them rather than breaking the column.
 * Use for images, small charts, pull-out boxes up to ~half the column width.
 *
 * .article-figure--left   float left, prose wraps right
 * .article-figure--right  float right, prose wraps left
 *
 * Rules:
 * - Max 45% of prose width so wrapped text stays readable (≥3 words/line)
 * - h2/h3 always clear floats — a new section starts fresh
 * - Add .article-figure--clear after a floated figure to cancel the float
 *   before the next section if you don't want wrapping to continue
 * - On narrow screens (< 640px) float collapses to full-width block
 */

.article-figure--left,
.article-figure--right {
  max-width: 45%;
  margin-bottom: var(--space-4);
}

.article-figure--left {
  float: left;
  margin-right: var(--space-6);
  margin-top: var(--space-1);
  clear: left;
}

.article-figure--right {
  float: right;
  margin-left: var(--space-6);
  margin-top: var(--space-1);
  clear: right;
}

/* Section headings always start below any active float */
.article h2,
.article h3,
.article-section,
.article-h3 {
  clear: both;
}

/* Explicit clear — use as an empty div after a floated figure */
.article-figure--clear {
  clear: both;
  display: block;
  height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
}

@media (max-width: 640px) {
  .article-figure--left,
  .article-figure--right {
    float: none;
    max-width: 100%;
    margin: var(--space-5) 0;
  }
}


/* ── Inline graphics ─────────────────────────────────────────────────────
 *
 * Small visual elements that sit within the text flow, not as block figures.
 *
 * .inline-chart    sparkline-sized SVG or canvas element (~80×24px)
 * .inline-swatch   small color square (for legend refs in prose)
 * .inline-badge    status indicator sized for inline text
 */

/* Sparkline: tiny inline chart flush with text baseline */
.inline-chart {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
  line-height: 0;
  border-radius: 2px;
  overflow: hidden;
}

.inline-chart svg,
.inline-chart canvas {
  display: block;
}

/* Default sparkline size — override width/height as needed */
.inline-chart--sm  { width: 60px;  height: 20px; }
.inline-chart--md  { width: 100px; height: 24px; }
.inline-chart--lg  { width: 160px; height: 32px; }

/* Color swatch — for inline legend references */
.inline-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  flex-shrink: 0;
}

/* Thumbnail image in text flow — small, right- or left-aligned */
.inline-thumb {
  display: inline-block;
  vertical-align: top;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 0 var(--space-2);
}


/* ── Inline note / aside ───────────────────────────────────────────────── */
/* A callout block within the prose flow — not a sidebar */

.article-note {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.55;
}

.article-note p {
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  color: var(--text-muted);
  margin: 0;
}


/* ── Split layout ──────────────────────────────────────────────────────── */
/*
 * Side-by-side prose + data panel.
 * Use when the article is interpretation alongside structured data output.
 * Responsive: stacks to single column below 860px.
 */

.article--split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-10);
  align-items: start;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.article-split-prose {
  min-width: 0;
}

.article-split-data {
  min-width: 0;
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  /* Override grid column defaults that article sets */
  grid-column: unset;
}

/* Inside the split prose column, override article grid to be single-column */
.article-split-prose .article {
  display: block;
}

.article-split-prose .article > * {
  grid-column: unset;
  max-width: var(--prose-max);
}

@media (max-width: 860px) {
  .article--split {
    grid-template-columns: 1fr;
  }
  .article-split-data {
    position: static;
  }
}


/* ── Dateline ──────────────────────────────────────────────────────────── */
/* AP-style location + date before first body paragraph */

.article-dateline {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--text-dim);
  margin-bottom: var(--space-4);
}

.article-dateline__location {
  font-style: normal;
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}


/* ── Summary / key-findings box ────────────────────────────────────────── */
/* Short bulleted overview at article top — always visible or collapsible */

.article-summary {
  background: var(--accent-surface);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-8);
}

.article-summary__label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--accent-text);
  margin-bottom: var(--space-3);
  display: block;
}

.article-summary ul {
  margin: 0;
  padding-left: var(--space-5);
}

.article-summary li {
  font-family: var(--font-prose) !important;
  font-optical-sizing: auto;
  font-size: 16px !important;
  color: var(--text);
  margin-bottom: var(--space-2);
  line-height: 1.55;
}

.article-summary li:last-child {
  margin-bottom: 0;
}

/* Collapsible variant via <details> */
.article-summary details summary {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--accent-text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0;
}

.article-summary details[open] summary {
  margin-bottom: var(--space-3);
}

.article-summary details summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.article-summary details[open] summary::before {
  transform: rotate(90deg);
}


/* ── Editor notices ────────────────────────────────────────────────────── */
/* Correction and update banners — typically placed at article top or inline */

.article-correction,
.article-update {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.article-correction {
  background: var(--error-subtle);
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  border-left: 3px solid var(--error);
  color: var(--text);
}

.article-update {
  background: var(--warning-subtle);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-left: 3px solid var(--warning);
  color: var(--text);
}

.article-correction__label,
.article-update__label {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.article-correction__label { color: var(--error); }
.article-update__label     { color: var(--warning); }

.article-correction p,
.article-update p {
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  margin: 0;
}

.article-correction p + p,
.article-update p + p {
  margin-top: var(--space-1);
}


/* ── Marginalia ──────────────────────────────────────────────────────────
 *
 * .article-marginnote is a direct child of .article placed in the grid's
 * `margin` zone (right gutter column, 200px). It flows in document order
 * alongside its prose sibling — no JS, no absolute positioning.
 *
 * Placement rule: put the marginnote element BEFORE the prose element it
 * annotates. Because both are grid children in the same row-gap:0 grid,
 * the note will be aligned to the top of the adjacent prose block.
 *
 * Variants:
 *   .article-marginnote--def     definition / glossary term
 *   .article-marginnote--source  source / citation
 *   .article-marginnote--figure  thumbnail chart or image
 *   .article-marginnote--callout highlighted aside
 *
 * Below --prose-wide (940px) the margin column collapses and notes
 * automatically pull into the prose column via a media query.
 */

.article-marginnote {
  grid-column: margin;
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  padding-top: 2px; /* optical alignment with first line of adjacent prose */
  align-self: start;
}

/* Definition variant — term + explanation */
.article-marginnote--def {
  border-left: 2px solid var(--border);
  padding-left: var(--space-3);
}

.article-marginnote--def .mn-term {
  display: block;
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  margin-bottom: 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-marginnote--def .mn-body {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}

/* Source / citation variant */
.article-marginnote--source {
  border-left: 2px solid var(--border-subtle);
  padding-left: var(--space-3);
  font-style: italic;
}

.article-marginnote--source .mn-source-num {
  font-style: normal;
  font-weight: var(--weight-semibold);
  color: var(--accent-text);
  margin-right: 4px;
}

/* Callout variant — highlighted aside */
.article-marginnote--callout {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  font-size: 12px;
}

/* Thumbnail figure variant — small chart or image in margin */
.article-marginnote--figure {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.article-marginnote--figure .mn-fig {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-disabled);
  font-size: 10px;
}

.article-marginnote--figure .mn-caption {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Collapse: at narrow widths, notes flow back into prose column */
@media (max-width: 940px) {
  .article-marginnote {
    grid-column: prose;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
    /* reset variant borders that would double up */
    border-left-width: 3px;
  }

  .article-marginnote--def,
  .article-marginnote--source {
    border-left: 3px solid var(--border-strong);
    padding-left: var(--space-3);
  }

  .article-marginnote--callout {
    border-left-width: 3px;
  }
}

/* Inline sidenote ref marker (used for footnote-style calls into marginalia) */
.sidenote-ref {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: var(--accent-text);
  vertical-align: super;
  line-height: 0;
  cursor: default;
  user-select: none;
}


/* ── Footnote references (inline) ──────────────────────────────────────── */

.article a.fn-ref,
.prose a.fn-ref {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: var(--accent-text);
  text-decoration: none;
  vertical-align: super;
  line-height: 0;
  padding: 0 1px;
}

.article a.fn-ref:hover,
.prose a.fn-ref:hover {
  text-decoration: underline;
}


/* ── Endnotes / footnote section ───────────────────────────────────────── */

.article-footnotes {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  grid-column: prose;
}

.article-footnotes__label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-dim);
  margin-bottom: var(--space-4);
  display: block;
}

.article-footnotes ol {
  margin: 0;
  padding-left: var(--space-5);
  counter-reset: none;
}

.article-footnotes li {
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-2);
  position: relative;
}

.article-footnotes li:target {
  background: var(--accent-surface);
  border-radius: var(--radius-sm);
  outline: 1px solid var(--accent-muted);
  outline-offset: 3px;
}

/* Back-link arrow */
.article-footnotes .fn-back {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  margin-left: var(--space-1);
}

.article-footnotes .fn-back:hover {
  color: var(--accent-text);
}


/* ── References / bibliography ─────────────────────────────────────────── */

.article-references {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.article-references__label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-dim);
  margin-bottom: var(--space-5);
  display: block;
}

.article-references ol,
.article-references ul {
  margin: 0;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.article-references li {
  font-family: var(--font-sans) !important;
  font-size: var(--text-sm) !important;
  color: var(--text-muted);
  line-height: 1.6;
}

.article-references li:target {
  background: var(--accent-surface);
  border-radius: var(--radius-sm);
  outline: 1px solid var(--accent-muted);
  outline-offset: 3px;
}

.article-references .ref-authors {
  color: var(--text);
}

.article-references .ref-title {
  font-style: italic;
}

.article-references .ref-source {
  color: var(--text-dim);
}


/* ── Table of contents ─────────────────────────────────────────────────── */

.article-toc {
  grid-column: prose;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-8);
  overflow: hidden;
}

.article-toc details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.article-toc details > summary::-webkit-details-marker { display: none; }

.article-toc details > summary::after {
  content: "▸";
  font-size: 10px;
  color: var(--text-dim);
  transition: transform var(--duration-fast) var(--ease-out);
}

.article-toc details[open] > summary::after {
  transform: rotate(90deg);
}

.article-toc details > summary:hover {
  color: var(--text);
}

.article-toc nav {
  padding: var(--space-2) var(--space-5) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.article-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-toc li {
  margin: 0;
}

.article-toc a {
  display: block;
  padding: var(--space-1) 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}

.article-toc a:hover {
  color: var(--accent-text);
}

/* H3 entries indented under their parent h2 */
.article-toc li[data-level="3"] {
  padding-left: var(--space-5);
}

.article-toc li[data-level="3"] a {
  font-size: var(--text-xs);
  color: var(--text-dim);
}

.article-toc li[data-level="3"] a:hover {
  color: var(--accent-text);
}


/* ── Footnote hover tooltips ───────────────────────────────────────────── */

.article a.fn-ref,
.prose a.fn-ref {
  position: relative;
}

.fn-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--text-muted);
  text-align: left;
  vertical-align: baseline;
  white-space: normal;
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
  pointer-events: none;
}

/* Keep tooltip in viewport when near left/right edges */
.fn-tooltip::before {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--surface-raised);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  rotate: 45deg;
}

@media (hover: hover) {
  .article a.fn-ref:hover .fn-tooltip,
  .prose a.fn-ref:hover .fn-tooltip {
    display: block;
  }
}

/* Touch: toggled via JS adding .fn-tooltip--visible */
.fn-tooltip--visible {
  display: block !important;
}


/* ── Series navigation ─────────────────────────────────────────────────── */

.article-series {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-8);
}

.article-series__label {
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

.article-series__nav {
  display: flex;
  gap: var(--space-3);
  margin-left: auto;
}

.article-series__nav a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: var(--weight-medium);
}

.article-series__nav a:hover {
  text-decoration: underline;
}

.article-series__nav a[aria-disabled="true"] {
  color: var(--text-disabled);
  pointer-events: none;
}


/* ── Inline elements ────────────────────────────────────────────────────── */

/* Term being defined */
.article dfn,
.prose dfn {
  font-style: normal;
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
  cursor: help;
}

/* Abbreviation with title */
.article abbr,
.prose abbr {
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
  cursor: help;
  font-variant: none;
}

/* Deleted / inserted text (corrections inline) */
.article del {
  color: var(--error);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--error) 70%, transparent);
}

.article ins {
  color: var(--success);
  text-decoration: none;
  background: var(--success-subtle);
  border-radius: 2px;
  padding: 0 2px;
}

/* Inline stat callout — large metric within prose */
.article .stat-inline {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 1.2em;
  font-weight: var(--weight-semibold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.article .stat-inline--accent { color: var(--accent-text); }
.article .stat-inline--success { color: var(--success); }
.article .stat-inline--warning { color: var(--warning); }
.article .stat-inline--error   { color: var(--error); }


/* ── Figure panel labels (A, B, C) ─────────────────────────────────────── */

.article-figure--panels > :first-child {
  display: grid;
  gap: var(--space-3);
}

.article-figure--panels-2 > :first-child { grid-template-columns: 1fr 1fr; }
.article-figure--panels-3 > :first-child { grid-template-columns: 1fr 1fr 1fr; }

.article-panel {
  position: relative;
  background: var(--surface-inset);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.article-panel__label {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  line-height: 1.4;
}


/* ── Legacy .prose class ───────────────────────────────────────────────── */
/* Kept for backward compatibility — use .article for new work */

.prose {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: var(--leading-relaxed);
  color: var(--text);
  max-width: var(--prose-max);
}

.prose h2 {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  margin: var(--space-10) 0 var(--space-5);
}

.prose h3 {
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 20px;
  font-weight: var(--weight-semibold);
  margin: var(--space-6) 0 var(--space-2);
  color: var(--text);
}

.prose p { margin: 0 0 var(--space-4); }
.prose a { color: var(--accent-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent); text-underline-offset: 2px; }
.prose a:hover { text-decoration-color: var(--accent-text); }
.prose strong { font-weight: var(--weight-semibold); }
.prose em { font-style: italic; }

.prose code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-raised);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.prose pre {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin: 0 0 var(--space-4);
}

.prose pre code { background: none; border: none; padding: 0; font-size: 13px; }

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: var(--space-4);
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-style: italic;
}

.prose ul,
.prose ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}

.prose li { margin-bottom: var(--space-1); }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-4);
  font-size: 14px;
}

.prose th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.prose td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0;
}


/* ─── 11. Keyboard hints ─────────────────────────────────────────────────── */

kbd,
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  gap: 2px;
  white-space: nowrap;
}


/* ─── 12. Score bars (in-cell or standalone) ─────────────────────────────── */

.score-bar {
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  height: 6px;
  overflow: hidden;
}

.score-bar__fill {
  height: 100%;
  border-radius: var(--radius-sm);
  background: var(--accent);
  transition: width var(--duration-slow) var(--ease-out);
}

.score-bar__fill--hi  { background: var(--score-hi); }
.score-bar__fill--mid { background: var(--score-mid); }
.score-bar__fill--lo  { background: var(--score-lo); }

/* Labeled bar (label + bar + value) */
.score-bar-labeled {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-bar-labeled__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.score-bar-labeled__val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}


/* ─── 13. Reading guides ─────────────────────────────────────────────────── */

.reading-guide {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.reading-guide__label {
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  flex-shrink: 0;
}

.reading-guide__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 3px;
}


/* ─── 14. Detail rows ────────────────────────────────────────────────────── */

/* Two/three column layout for entity property display */
.detail-row {
  display: grid;
  grid-template-columns: 1fr 120px 52px;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row__name {
  font-weight: var(--weight-medium);
  color: var(--text);
}

.detail-row__desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 1px;
}

.detail-row__count {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Two-column variant */
.detail-row--two-col {
  grid-template-columns: 1fr 80px;
}


/* ─── 15. Live activity indicator ───────────────────────────────────────── */

@keyframes ds-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.pulse-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--success);
  animation: ds-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

.pulse-dot--warning { background: var(--warning); }
.pulse-dot--error   { background: var(--error); }

/* Animated "live" label with dot */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-dim);
}

/* Value flash (live update) */
@keyframes ds-live-flash {
  0%   { color: var(--accent-text); }
  100% { color: inherit; }
}

.is-live-updated {
  animation: ds-live-flash var(--duration-live) var(--ease-out);
}


/* ─── 16. Tooltips ───────────────────────────────────────────────────────── */

.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  max-width: 380px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.tooltip.is-visible {
  opacity: 1;
}

.tooltip__title {
  font-weight: var(--weight-semibold);
  margin-bottom: 3px;
}

.tooltip__meta {
  color: var(--text-muted);
  font-size: var(--text-xs);
}


/* ─── 17. Modals / overlays ──────────────────────────────────────────────── */

.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.modal {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition);
}

.modal__close:hover { color: var(--text); }

.modal__body {
  padding: var(--space-5);
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

/* Command palette variant (full-bleed input) */
.command-palette {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
}

.command-palette__input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.command-palette__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
}

.command-palette__input::placeholder { color: var(--text-dim); }

.command-palette__list {
  padding: var(--space-2) 0;
  max-height: 320px;
  overflow-y: auto;
}

.command-palette__group-label {
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-dim);
  margin-top: 4px;
}

.command-palette__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--space-4);
  font-size: var(--text-base);
  color: var(--text-muted);
  cursor: pointer;
}

.command-palette__item:hover,
.command-palette__item.is-selected {
  background: var(--accent-surface);
  color: var(--text);
}

.command-palette__item-hint {
  display: flex;
  gap: 3px;
}


/* ─── 18. Utility classes ────────────────────────────────────────────────── */

/* Typography helpers */
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-md      { font-size: var(--text-md); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }

.text-muted   { color: var(--text-muted); }
.text-dim     { color: var(--text-dim); }
.text-accent  { color: var(--accent-text); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error   { color: var(--error); }

.font-mono    { font-family: var(--font-mono); }
.font-serif   { font-family: var(--font-serif); }
.tabular-nums { font-variant-numeric: tabular-nums; }

.uppercase    { text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout helpers */
.row          { display: flex; align-items: center; }
.row--gap-1   { gap: var(--space-1); }
.row--gap-2   { gap: var(--space-2); }
.row--gap-3   { gap: var(--space-3); }
.row--gap-4   { gap: var(--space-4); }
.row--wrap    { flex-wrap: wrap; }
.row--between { justify-content: space-between; }

.spacer       { flex: 1; }

/* Visibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
