/* ============================================================
   Robotics Industry & Policy Tracker — design system
   Per DESIGN.md § 15: four named themes (caves / naked-sun /
   dawn / robot-dreams), role-based CSS variables, web fonts
   justified as theme identity. WCAG 2.1 AA across all themes.
   ============================================================ */

/* --- Universal tokens (theme-independent) --- */

:root {
  /* Type stacks: each theme overrides --font-serif (display) and
     --font-sans (body). Mono stays universal. */
  --font-sans: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-serif: "Charter", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
    monospace;

  /* Layout */
  --max-w: 1280px;
  --header-h: 56px;

  /* Theme-tunable aesthetic tokens (defaults if no theme is set) */
  --radius-card: 10px;
  --radius-pill: 999px;
  --surface-backdrop: none;
  --transition-fast: 90ms;
  --transition-base: 120ms;
  --transition-slow: 200ms;

  /* Tabular numerals everywhere */
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Theme 1: Caves of Steel (Earth) ---
   Industrial, subterranean, high-density. Sharp borders. */

[data-theme="caves"] {
  --font-serif: "Barlow Condensed", "Arial Narrow", "Helvetica Condensed", "Impact", sans-serif;
  --font-sans: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --bg: #121212;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2f2f2f;
  --border-strong: #4a4a4a;
  --text: #f5f5f5;
  --text-muted: #b0b0b0;
  --text-faint: #7a7a7a;
  --accent: #ffc700;
  --accent-soft: #3a2f00;
  --accent-on: #121212;
  --link: #ffc700;

  --status-positive: #00ff66;
  --status-positive-soft: #003a18;
  --status-warning: #ffc700;
  --status-warning-soft: #3a2f00;
  --status-negative: #ff5252;
  --status-negative-soft: #3a1414;
  --status-neutral: #b0b0b0;
  --status-neutral-soft: #2a2a2a;

  --cat-funding: #c9a0ff;
  --cat-deployment: #6de2db;
  --cat-policy: #ffd66e;
  --cat-competitive: #ff8fb6;
  --cat-supplychain: #8fb6ff;
  --cat-geopolitics: #ff9d7e;
  --cat-research: #a3e1a5;

  --dir-accelerating: #00ff66;
  --dir-stable: #b0b0b0;
  --dir-slowing: #ffc700;

  --radius-card: 4px;
  --radius-pill: 4px;
  --shadow-rest: 0 0 0 1px rgba(0, 0, 0, 0.5);
  --shadow-elevated: 0 0 0 1px var(--border-strong);
}

/* --- Theme 2: The Naked Sun (Solaria) ---
   Hyper-minimalist, sterile, ultra-isolated. Whitespace + slow motion. */

[data-theme="naked-sun"] {
  --font-serif: "Didot", "Bodoni MT", "Bodoni Moda", "Big Caslon", "Palatino Linotype", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F0ECE1;
  --border: #E5E0D5;
  --border-strong: #C9C2B0;
  --text: #1A1A1A;
  --text-muted: #5a5a5a;
  --text-faint: #9a9388;
  --accent: #1C4E3A;
  --accent-soft: #d8e3dc;
  --accent-on: #FAFAFA;
  --link: #1C4E3A;

  --status-positive: #1C4E3A;
  --status-positive-soft: #d8e3dc;
  --status-warning: #8a6b1a;
  --status-warning-soft: #efe6cc;
  --status-negative: #8a2a1a;
  --status-negative-soft: #f0d8d2;
  --status-neutral: #5a5a5a;
  --status-neutral-soft: #ececec;

  --cat-funding: #4a3a7a;
  --cat-deployment: #1a5a5a;
  --cat-policy: #7a4a1a;
  --cat-competitive: #8a2a5a;
  --cat-supplychain: #2a4a7a;
  --cat-geopolitics: #5a2a2a;
  --cat-research: #2a5a2a;

  --dir-accelerating: #1C4E3A;
  --dir-stable: #5a5a5a;
  --dir-slowing: #7a4a1a;

  --radius-card: 14px;
  --shadow-rest: none;
  --shadow-elevated: 0 2px 20px rgba(0, 0, 0, 0.04);
  --transition-base: 200ms;
  --transition-slow: 320ms;
}

/* --- Theme 3: Robots of Dawn (Aurora) ---
   Utopian, premium, serene. Rounded cards, soft depth. */

[data-theme="dawn"] {
  --font-serif: "Cormorant Garamond", Georgia, "Iowan Old Style", "Apple Garamond", "Palatino", serif;
  --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --bg: #FFF9F5;
  --surface: #FFFFFF;
  --surface-2: #EFE3D8;
  --border: #E4D8C7;
  --border-strong: #C9B89F;
  --text: #2D2520;
  --text-muted: #6b5e54;
  --text-faint: #a59585;
  --accent: #8C4303;
  --accent-soft: #f5e3d1;
  --accent-on: #FFF9F5;
  --link: #8C4303;

  --status-positive: #406b3a;
  --status-positive-soft: #e0ead4;
  --status-warning: #8C4303;
  --status-warning-soft: #f5e3d1;
  --status-negative: #8a2a1a;
  --status-negative-soft: #f3d6d0;
  --status-neutral: #6b5e54;
  --status-neutral-soft: #ede5dc;

  --cat-funding: #5f4291;
  --cat-deployment: #1f6a6a;
  --cat-policy: #a05a1a;
  --cat-competitive: #b0306e;
  --cat-supplychain: #3e5e8a;
  --cat-geopolitics: #6b3838;
  --cat-research: #467044;

  --dir-accelerating: #406b3a;
  --dir-stable: #6b5e54;
  --dir-slowing: #a05a1a;

  --radius-card: 16px;
  --shadow-rest: 0 1px 3px rgba(45, 37, 32, 0.08);
  --shadow-elevated: 0 8px 24px rgba(45, 37, 32, 0.10);
}

/* --- Theme 4: Robot Dreams (Subconscious) ---
   Cosmic, ethereal dark. Glassmorphism + cyan glow. */

[data-theme="robot-dreams"] {
  --font-serif: "Orbitron", "Courier New", "SF Mono", Menlo, Consolas, monospace;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  --bg: #0A0915;
  --surface: rgba(25, 24, 48, 0.6);
  --surface-2: rgba(25, 24, 48, 0.42);
  --border: rgba(170, 200, 240, 0.18);
  --border-strong: rgba(170, 200, 240, 0.32);
  --text: #E0E6ED;
  --text-muted: #8a96a8;
  --text-faint: #5a667a;
  --accent: #00E5FF;
  --accent-soft: rgba(0, 229, 255, 0.14);
  --accent-on: #0A0915;        /* MUST be used for text inside any cyan fill */
  --link: #00E5FF;

  --status-positive: #5dffae;
  --status-positive-soft: rgba(93, 255, 174, 0.14);
  --status-warning: #ffd66e;
  --status-warning-soft: rgba(255, 214, 110, 0.14);
  --status-negative: #ff7a8a;
  --status-negative-soft: rgba(255, 122, 138, 0.14);
  --status-neutral: #8a96a8;
  --status-neutral-soft: rgba(138, 150, 168, 0.14);

  --cat-funding: #c9a0ff;
  --cat-deployment: #5dffae;
  --cat-policy: #ffd66e;
  --cat-competitive: #ff8fb6;
  --cat-supplychain: #8fb6ff;
  --cat-geopolitics: #ff9d7e;
  --cat-research: #a3e1a5;

  --dir-accelerating: #5dffae;
  --dir-stable: #8a96a8;
  --dir-slowing: #ffd66e;

  --radius-card: 12px;
  --shadow-rest: 0 0 0 1px rgba(0, 229, 255, 0.08);
  --shadow-elevated: 0 0 24px rgba(0, 229, 255, 0.18);
  --surface-backdrop: blur(12px) saturate(140%);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

/* The [hidden] trap — explicit override per DESIGN.md § 12.1 */
[hidden] { display: none !important; }

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 90ms;
}
a:hover { border-bottom-color: var(--link); }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* iOS auto-zoom suppression */
  color: var(--text);
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   Layout — header, container
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  height: var(--header-h);
}

/* Header status block (replaces the old brand wordmark). Wrapped in an
   <a href="index.html"> so the upper-left area still navigates home. */
.header-updated {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.15;
  color: var(--text-muted);
  border-bottom: none;
  transition: color var(--transition-base, 120ms);
}
.header-updated:hover { color: var(--text); border-bottom: none; }
.header-updated-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  font-weight: 600;
}
.header-updated-date {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--text);
}

nav.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
nav.primary-nav a,
.primary-more > summary {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  border-bottom: none;
  font-weight: 500;
  font-size: 14px;
  transition: background 120ms, color 120ms;
}
nav.primary-nav a:hover,
nav.primary-nav a[aria-current="page"],
.primary-more > summary:hover,
.primary-more[data-current="true"] > summary {
  background: var(--surface-2);
  color: var(--text);
}
.primary-more {
  position: relative;
}
.primary-more > summary {
  list-style: none;
  cursor: pointer;
}
.primary-more > summary::-webkit-details-marker {
  display: none;
}
.primary-more > summary::after {
  content: "v";
  display: inline-block;
  margin-left: 6px;
  color: var(--text-faint);
  font-size: 12px;
}
.primary-more[open] > summary::after {
  transform: rotate(180deg);
}
.primary-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
}
.primary-more-menu a {
  display: block;
  white-space: nowrap;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

h1.page-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.015em;
  margin: 4px 0 4px;
  line-height: 1.15;
}
.page-lede {
  color: var(--text-muted);
  font-size: 14.5px;
  max-width: 64ch;
  margin: 0 0 18px;
  line-height: 1.5;
}

/* ============================================================
   BLUF — Bottom Line Up Front. One per page, directly under the
   lede. The single most important takeaway, stated first.
   ============================================================ */
.bluf {
  display: flex;
  gap: 14px;
  align-items: baseline;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 13px 16px;
  margin: 0 0 22px;
  max-width: 74ch;
}
.bluf-tag {
  flex: none;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--accent);
  white-space: nowrap;
}
.bluf-body {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
}
.bluf-body strong { font-weight: 600; }
@media (max-width: 540px) {
  .bluf { flex-direction: column; gap: 5px; padding: 12px 14px; }
}

h2.section-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 26px 0 10px;
}

/* ============================================================
   Collapsible Sections
   ============================================================ */

details.collapsible-section {
  margin-top: 28px;
  margin-bottom: 24px;
}

details.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
}

details.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

details.collapsible-section > summary::before {
  content: "▶";
  font-size: 10px;
  color: var(--text-muted);
  position: absolute;
  left: 0;
  top: 6px;
  line-height: 1;
  transition: transform var(--transition-base, 120ms), color var(--transition-base, 120ms);
}

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

details.collapsible-section > summary > h2.section-title {
  display: inline-block;
  margin-top: 0;
  margin-bottom: 4px;
  transition: color var(--transition-base, 120ms);
}

details.collapsible-section > summary > p.muted {
  margin-top: 0;
  margin-bottom: 14px;
}

details.collapsible-section > summary:hover > h2.section-title,
details.collapsible-section > summary:hover::before {
  color: var(--accent);
}

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

footer.site-footer .footer-credit {
  margin-top: 8px;
}

/* ============================================================
   KPI / stats strip
   ============================================================ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
@media (min-width: 640px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}
@media (min-width: 1024px) {
  .kpi-strip { grid-template-columns: repeat(5, 1fr); }
}
/* If a page has only 4 KPIs (e.g. policies page), use 4-up on desktop */
.kpi-strip.cols-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1024px) {
  .kpi-strip.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

.kpi-card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 10px 12px;
  box-shadow: var(--shadow-rest);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ============================================================
   Pills
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--status-neutral-soft);
  color: var(--status-neutral);
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill.outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.pill.positive { background: var(--status-positive-soft); color: var(--status-positive); }
.pill.warning  { background: var(--status-warning-soft);  color: var(--status-warning); }
.pill.negative { background: var(--status-negative-soft); color: var(--status-negative); }
.pill.mixed    { background: var(--status-warning-soft);  color: var(--status-warning); }

/* Category pills — semantic to data type */
.pill.cat-funding     { background: color-mix(in srgb, var(--cat-funding) 14%, transparent); color: var(--cat-funding); }
.pill.cat-deployment  { background: color-mix(in srgb, var(--cat-deployment) 14%, transparent); color: var(--cat-deployment); }
.pill.cat-policy      { background: color-mix(in srgb, var(--cat-policy) 14%, transparent); color: var(--cat-policy); }
.pill.cat-competitive { background: color-mix(in srgb, var(--cat-competitive) 14%, transparent); color: var(--cat-competitive); }
.pill.cat-supplychain { background: color-mix(in srgb, var(--cat-supplychain) 14%, transparent); color: var(--cat-supplychain); }
.pill.cat-geopolitics { background: color-mix(in srgb, var(--cat-geopolitics) 14%, transparent); color: var(--cat-geopolitics); }
.pill.cat-research    { background: color-mix(in srgb, var(--cat-research) 14%, transparent); color: var(--cat-research); }

.pill.dir-accelerating { background: color-mix(in srgb, var(--dir-accelerating) 14%, transparent); color: var(--dir-accelerating); }
.pill.dir-stable       { background: color-mix(in srgb, var(--dir-stable) 14%, transparent); color: var(--dir-stable); }
.pill.dir-slowing      { background: color-mix(in srgb, var(--dir-slowing) 14%, transparent); color: var(--dir-slowing); }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-rest);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-hoverable {
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
  cursor: pointer;
}
.card-hoverable:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-strong);
}

.card-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.005em;
  margin: 0;
  line-height: 1.25;
}
.card-sub {
  color: var(--text-muted);
  font-size: 13px;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.card-meta .sep::before { content: "·"; padding: 0 4px; color: var(--text-faint); }

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

/* ============================================================
   Filters
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 18px;
}
.filter-bar fieldset { border: 0; margin: 0; padding: 0; display: contents; }
.filter-bar legend { display: none; }

.filter-input,
.filter-select {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  min-height: 38px;
  outline: none;
  transition: border-color 90ms, background 90ms;
}
.filter-input:hover, .filter-select:hover { border-color: var(--border-strong); }
.filter-input:focus-visible, .filter-select:focus-visible {
  border-color: var(--accent);
  background: var(--surface);
}
.filter-search {
  flex: 1 1 220px;
  min-width: 140px;
}
.filter-result-count {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  min-height: 38px;
  transition: background 120ms, border-color 120ms;
}
.btn:hover { background: var(--surface); border-color: var(--border-strong); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover { background: var(--surface-2); }

/* ============================================================
   Tables (data-dense — companies, policies)
   ============================================================ */

.table-wrap {
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: break-word;
  min-width: 0;
  line-height: 1.4;
}
/* Dates and numbers should never wrap mid-value (e.g. "May 17, / 2026"). */
.data-table .tnum,
.data-table td.num { white-space: nowrap; }
/* Numeric/date columns hug their content so the text columns absorb the slack
   instead of every column stretching across the full width. */
.data-table th.num,
.data-table td.num,
.data-table th.col-tight,
.data-table td.col-tight { width: 1%; white-space: nowrap; }
.data-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}
.data-table thead th button.sortable {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}
.data-table thead th button.sortable:hover { color: var(--text); }
.data-table thead th .sort-indicator {
  font-size: 10px;
  opacity: 0.6;
}
.data-table tbody tr {
  transition: background 90ms;
}
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table td .secondary-line {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.muted-cell { color: var(--text-faint); font-style: italic; }

/* Company name + derived deployment-stage pill (companies table) */
.company-name-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-pill { font-size: 9.5px; padding: 1px 6px; letter-spacing: 0.06em; }

/* show-mobile: only visible when hide-mobile columns are hidden (≤760px).
   Must match .secondary-line specificity (0,3,0) to win. */
.data-table td .show-mobile { display: none; }

@media (max-width: 760px) {
  .data-table th.hide-mobile,
  .data-table td.hide-mobile { display: none; }
  .data-table td .show-mobile { display: block; }
}

/* ============================================================
   Detail panel — bottom sheet on mobile, side panel on desktop
   ============================================================ */

.detail-panel {
  position: fixed;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-elevated);
  overflow-y: auto;
  transition: transform 200ms ease;
}
@media (max-width: 1023px) {
  .detail-panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    padding: 14px 16px max(20px, env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .detail-panel.open { transform: translateY(0); }
}
@media (min-width: 1024px) {
  .detail-panel {
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: min(520px, 40vw);
    border-radius: 0;
    border-top: 1px solid var(--border);
    padding: 22px 24px 40px;
    transform: translateX(100%);
  }
  .detail-panel.open { transform: translateX(0); }
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.detail-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.detail-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 24px;
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.detail-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.detail-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.detail-close:hover { background: var(--surface-2); color: var(--text); }

/* (Reduced-motion is consolidated at the bottom of the file.) */

/* Key-value grids */
.kv {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 6px 14px;
  margin: 12px 0 16px;
  font-size: 13.5px;
}
@media (min-width: 1024px) {
  .kv { grid-template-columns: 160px 1fr; }
}
/* Phones: stack label above value. A fixed label column forces multi-word
   labels ("Defense contracts", "Latest valuation") into ugly 2-line wraps
   while their values sit on one line — uneven rhythm. Stacking fixes both. */
@media (max-width: 560px) {
  .kv {
    grid-template-columns: 1fr;
    gap: 0;
    margin: 10px 0 14px;
  }
  .kv dt { padding-top: 11px; }
  .kv dt:first-of-type { padding-top: 0; }
  .kv dd { padding-top: 1px; }
}
.kv dt {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding-top: 1px;
}
.kv dd { margin: 0; }
.dd-note {
  color: var(--text-faint);
  font-size: 11.5px;
  display: block;
  margin-top: 1px;
}

/* Inline link list — sources etc. */
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.link-list li {
  font-size: 12.5px;
  word-break: break-all;
}

/* Sub-section heads inside detail panel */
.detail-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.detail-section h3 {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
}
/* Tables nested inside a detail panel are in a narrower column than the main
   page table — compact the cells so columns don't crush on tablet/desktop. */
.detail-panel .data-table { font-size: 13px; }
.detail-panel .data-table th,
.detail-panel .data-table td { padding: 7px 10px; }
/* Phones: tighten the divider rhythm between detail sections. */
@media (max-width: 560px) {
  .detail-section { margin-top: 14px; padding-top: 12px; }
}

/* ============================================================
   Charts (SVG)
   ============================================================ */

.chart {
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 16px 14px;
  box-shadow: var(--shadow-rest);
}
.chart h2,
.chart h3 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.chart-head h3 { margin-bottom: 0; }
.chart-toggle {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
.chart-toggle .btn.ghost {
  padding: 3px 10px;
  font-size: 11.5px;
  min-height: 0;
}
.chart .chart-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-label { fill: var(--text-muted); font-size: 10px; }
.chart-source {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.4;
}
.chart-source a { color: var(--text-muted); border-bottom: 1px dotted var(--border-strong); }
.chart-source a:hover { color: var(--text); border-bottom-color: var(--text); }

/* Wayback / archive links — small, secondary, never compete with the primary source link. */
.archive-link {
  font-size: 11px;
  margin-left: 6px;
  color: var(--text-faint);
  border-bottom: 1px dotted var(--border-strong);
  white-space: nowrap;
}
.archive-link:hover {
  color: var(--text-muted);
  border-bottom-color: var(--text-muted);
}
.chart .grid-line { stroke: var(--border); }
.chart .series-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .series-dot { fill: var(--accent); }
.chart .bar { fill: var(--accent); }
.chart .bar.alt { fill: var(--cat-supplychain); }

.chart-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .chart-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   News + Theme feed
   ============================================================ */

.feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.feed-card {
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-rest);
  transition: border-color var(--transition-base, 120ms), box-shadow var(--transition-base, 120ms);
}
.feed-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-elevated); }

.feed-card .top-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.feed-card h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  margin: 4px 0 6px;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.feed-card h3 a {
  color: var(--text);
  border-bottom: none;
}
.feed-card h3 a:hover { color: var(--accent); }
.feed-card .summary {
  font-size: 14px;
  color: var(--text);
  margin: 0 0 8px;
}
.feed-card .footer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Compact density mode */
.feed[data-density="compact"] .feed-card {
  padding: 6px 12px;
}
.feed[data-density="compact"] .feed-card h3 {
  font-size: 14px;
  margin: 2px 0 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.feed[data-density="compact"] .feed-card .summary,
.feed[data-density="compact"] .feed-card .footer-row {
  display: none;
}
/* In compact: only show category pill + date — hide sentiment/confidence pills and source */
.feed[data-density="compact"] .feed-card .top-row > .pill:not(:first-child) {
  display: none;
}
.feed[data-density="compact"] .feed-card .top-row .row-end > span:not(.tnum):not(.faint) {
  display: none;
}

/* Pagination bar */
.feed-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 4px;
}
.pag-info {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 90px;
  text-align: center;
}
.pag-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Density toggle active state */
.btn.ghost[aria-pressed="true"] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Theme — AI/curator narrative gets accent border per DESIGN.md § 11 */
.curator-narrative {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 14px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text);
  line-height: 1.55;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 36px 18px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Loading state */
.loading {
  opacity: 0;
  pointer-events: none;
}
.skeleton {
  display: block;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* (Skeleton reduced-motion handled at the bottom of the file.) */

/* Touch / interaction */
button, [role="button"], a.btn {
  touch-action: manipulation;
}

/* Mobile nav adjustment */
@media (max-width: 540px) {
  .site-header-inner { gap: 8px; padding: 8px 12px; }
  .header-updated-label { display: none; }
  .header-updated-date { font-size: 13px; }
  /* The header-updated block already links home — drop the "Dashboard" link to save ~80px */
  nav.primary-nav a[href="index.html"] { display: none; }
  /* Let the nav scroll horizontally as a chip strip when the remaining
     links still don't fit. Page-level h-scroll stays at 0. */
  nav.primary-nav {
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    min-width: 0;
  }
  nav.primary-nav::-webkit-scrollbar { display: none; }
  nav.primary-nav a,
  .primary-more > summary { padding: 8px 7px; font-size: 13px; white-space: nowrap; }
  .primary-more { position: static; }
  .primary-more-menu {
    top: calc(100% - 6px);
    right: 48px;
  }
  /* Drop the picker's text label below 540px; the chevron is enough */
  .theme-picker > summary { padding: 0 8px; gap: 4px; }
  .theme-picker-current { display: none; }
  h1.page-title { font-size: 24px; }
  main { padding: 16px 12px 60px; }
}

/* ============================================================
   Theme picker (DESIGN.md § 15.4)
   Native <details> for disclosure, radios for selection.
   ============================================================ */

.theme-picker {
  position: relative;
  font-family: var(--font-sans);
}
.theme-picker > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-base, 120ms), color var(--transition-base, 120ms), border-color var(--transition-base, 120ms);
}
.theme-picker > summary::-webkit-details-marker { display: none; }
.theme-picker > summary::marker { content: ""; }
.theme-picker > summary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-picker > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-picker-current {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.theme-picker-chevron {
  width: 10px;
  height: 10px;
  display: inline-block;
  flex: 0 0 10px;
  transition: transform var(--transition-base, 120ms);
}
.theme-picker[open] .theme-picker-chevron { transform: rotate(180deg); }

.theme-picker-menu {
  /* Hidden by default. position:absolute alone doesn't hide the menu —
     the native <details> rendering only suppresses non-absolute children
     of a closed <details>. So we must explicitly display:none here and
     re-enable display:flex on [open]. */
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  background: var(--surface);
  -webkit-backdrop-filter: var(--surface-backdrop, none);
  backdrop-filter: var(--surface-backdrop, none);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-elevated);
  margin: 0;
  padding: 6px;
  min-width: 240px;
  flex-direction: column;
  gap: 2px;
}
.theme-picker[open] > .theme-picker-menu {
  display: flex;
}
.theme-option {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  min-height: 36px;
  transition: background var(--transition-fast, 90ms);
}
.theme-option:hover { background: var(--surface-2); }
.theme-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  margin: 0;
  cursor: pointer;
  transition: border-color var(--transition-fast, 90ms);
  display: inline-grid;
  place-items: center;
}
.theme-option input[type="radio"]:checked {
  border-color: var(--accent);
}
.theme-option input[type="radio"]:checked::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.theme-option input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-option-name { font-weight: 500; }
.theme-option-tag {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Override: cyan accent in Robot Dreams needs explicit on-text */
[data-theme="robot-dreams"] .btn.primary,
[data-theme="robot-dreams"] .pill.cat-accent {
  color: var(--accent-on);
}

/* Reduced-motion: kill transitions across themes + picker.
   This is the single source of truth for motion gating. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  .skeleton { animation: none; background: var(--surface-2); }
  .detail-panel,
  .detail-backdrop,
  .theme-picker-chevron { transition: none !important; }
}

/* Utility */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.serif { font-family: var(--font-serif); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.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;
}

/* Mobile (<=640px) Responsive Layout Refinements */
@media (max-width: 640px) {
  /* Hide verbose hero copy to save screen space */
  .page-lede,
  .eyebrow {
    display: none;
  }
  
  /* Slightly tighter layout spacing */
  .page-title {
    margin-top: 8px;
    margin-bottom: 12px;
  }

  /* Horizontal swipeable scroll-snap carousel for KPIs */
  .kpi-strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding: 4px;
    margin-bottom: 16px;
    scrollbar-width: none; /* Firefox */
  }
  .kpi-strip::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
  }
  .kpi-card {
    flex: 0 0 160px;
    scroll-snap-align: start;
    box-sizing: border-box;
  }

  /* Clean responsive 2-column grid for filters */
  .filter-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
  }
  .filter-search {
    grid-column: span 2;
    width: 100%;
  }
  .filter-input,
  .filter-select {
    width: 100%;
    box-sizing: border-box;
  }
  .filter-bar button {
    grid-column: span 1;
    width: 100%;
  }
  .filter-result-count {
    grid-column: span 2;
    text-align: right;
    margin: 4px 0 0 0;
  }

  /* Tables: tighten padding, allow num cells to wrap */
  .data-table {
    font-size: 13px;
  }
  .data-table th,
  .data-table td {
    padding: 9px 10px;
  }
  .data-table td.num {
    white-space: normal;
  }
}
