/* ==========================================================================
   MetaRoles — shared stylesheet (CLAUDE.md §7)
   "Role Badge" by day (default), "Readiness Ladder" by night, in the
   "Steel Dusk × Violet" palette. Dark theme: <html data-theme="dark">, set by
   the inline head snippet before first paint and by the toggle in main.js.
   Components use ONLY the tokens in §1, so both themes follow automatically.
   The class structure follows DabPop's (simplecodeworker/dbpp).
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;
  /* Steel Dusk × Violet, day */
  --paper: #EDEDF2;        /* page ground */
  --surface: #FFFFFF;      /* cards, top bar, tables, inputs */
  --surface-2: #F4F4F8;    /* hovers, table heads */
  --ink: #12131C;          /* headings, figures, active chip fill */
  --body: #2B2D3A;         /* long-form copy */
  --muted: #5A5D6E;        /* labels, captions, "as of" lines */
  --rule: #D6D7E0;         /* borders, dividers */
  --accent: #0B6E69;       /* links, kickers, lit grade bars */
  --soc: #5B3FA8;          /* SOC codes and other identifiers */
  --on-accent: #FFFFFF;    /* text on --grad-fill and --accent */
  --hl: #E6F3F2;           /* the #1 row of a ranking table */
  --cat-bg: #12131C;       /* category badge on images */
  --cat-fg: #FFFFFF;
  --badge-bg: #FFFFFF;     /* count badge on images */
  --badge-fg: #12131C;
  --img: #DDDCE6;          /* placeholder block behind a missing image */
  --img-ink: #12131C;      /* icon on --img */
  --band-text: #FFFFFF;    /* text on --grad-band */
  --band-muted: #B3B0CC;
  --band-accent: #8FE3DA;
  --band-rule: rgba(255, 255, 255, .18);
  --grade-off: #C9CAD6;    /* unlit grade bars (always labelled) */
  --data-1: #0B6E69;
  --data-2: #6A4CC2;
  --focus: #0B6E69;
  --grad-fill: linear-gradient(135deg, #0B6E69, #5B3FA8);
  --grad-band: linear-gradient(135deg, #12131C, #2A1D4A);
  --grad-stripe: linear-gradient(90deg, #0B6E69, #2BB3C0, #7B5CD6);
  --grad-bar: linear-gradient(90deg, #0E6E7A, #6A4CC2);
  --grad-text: linear-gradient(90deg, #0B6E69, #5B3FA8);

  /* Shape: rounded "Role Badge" by day */
  --r: 14px;               /* cards, panels, tables */
  --r-sm: 10px;            /* inputs, buttons, media */
  --r-pill: 999px;         /* chips, grade badges */

  --f-body: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --h1: 52px;
  --h2: 32px;
  --ct: 21px;
  --bar-h: 64px;           /* sticky top bar height, for scroll-padding */
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Steel Dusk × Violet, night */
  --paper: #0D0F16;
  --surface: #151823;
  --surface-2: #1B1F2C;
  --ink: #E9E8F2;
  --body: #C8C7D6;
  --muted: #8E8CA3;
  --rule: #282B3A;
  --accent: #5CC8D7;
  --soc: #B49CFF;
  --on-accent: #0D0F16;    /* never white on the light gradient */
  --hl: #14262B;
  --cat-bg: #5CC8D7;
  --cat-fg: #0D0F16;
  --badge-bg: #E9E8F2;
  --badge-fg: #0D0F16;
  --img: #1D2030;
  --img-ink: #E9E8F2;
  --band-text: #E9E8F2;
  --band-muted: #A19EB8;
  --band-accent: #C6B5FF;
  --band-rule: rgba(233, 232, 242, .16);
  --grade-off: #353849;
  --data-1: #5CC8D7;
  --data-2: #B49CFF;
  --focus: #5CC8D7;
  --grad-fill: linear-gradient(135deg, #5CC8D7, #B49CFF);
  --grad-band: linear-gradient(135deg, #171A26, #2A1F45);
  --grad-stripe: linear-gradient(90deg, #5CC8D7, #B49CFF);
  --grad-bar: linear-gradient(90deg, #4FB4C4, #A98CFF);
  --grad-text: linear-gradient(90deg, #5CC8D7, #B49CFF);

  /* Shape: square "Readiness Ladder" by night */
  --r: 0px;
  --r-sm: 0px;
  --r-pill: 0px;
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 16px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.6;
}
/* width: 100% stops a narrow page (About, Terms) from shrinking to its text and floating off-centre */
body > main { flex: 1 0 auto; width: 100%; }
img, svg, iframe { max-width: 100%; }
img { height: auto; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.02em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100; padding: 10px 16px;
  font-weight: 700; color: var(--on-accent); background: var(--accent); border-radius: var(--r-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums lining-nums; }
.soc { font-family: var(--f-mono); font-size: .9em; color: var(--soc); white-space: nowrap; }
.kicker, .label {
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; line-height: 1.4;
}
.kicker { color: var(--accent); }
.label { color: var(--muted); }

/* 3. Layout ---------------------------------------------------------------- */
.wrap { max-width: 1248px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 820px; margin: 0 auto; padding: 0 24px; }
main { display: block; }

/* 4. Top bar (sticky) + wordmark ------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--grad-stripe); }
.topbar-in { display: flex; align-items: center; gap: 12px 24px; min-height: var(--bar-h); }
.mini-logo { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; }
.logo-tile { width: 32px; height: 32px; flex: none; }
/* W1 wordmark: "Meta" in ink, "Roles" in the gradient (CLAUDE.md §7) */
.wordmark { font-weight: 900; font-size: 24px; line-height: 1; letter-spacing: -.03em; color: var(--ink); white-space: nowrap; }
.wordmark span {
  color: var(--accent);
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar-tag { font-size: 13px; color: var(--muted); white-space: nowrap; padding-left: 14px; border-left: 1px solid var(--rule); }
.mast-panel { display: flex; flex: 1; align-items: center; gap: 8px 20px; order: 2; }
.topbar-in > .theme-toggle { order: 3; }
.topbar-in > .nav-toggle { order: 4; }
.util-nav { display: flex; flex-wrap: nowrap; margin-left: auto; white-space: nowrap; }
.util-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px;
  font-size: 14px; font-weight: 600; text-decoration: none; color: var(--body);
}
.util-nav a:hover, .util-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.mast-tools { display: flex; align-items: center; gap: 10px; }
.mast-tools form { display: flex; margin: 0; }

.search {
  display: flex; align-items: center; gap: 8px; height: 44px; min-width: 220px; padding: 0 12px;
  color: var(--muted); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-sm);
}
.search .ico { width: 16px; height: 16px; }
.search input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }

.theme-toggle, .nav-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer;
}
.theme-toggle:hover, .nav-toggle:hover { border-color: var(--ink); }
.theme-toggle .ico { width: 16px; height: 16px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
html:not(.js) .theme-toggle { display: none; }
.nav-toggle { display: none; padding: 0; }

/* 5. Masthead + category strip (index + category pages) -------------------- */
.masthead { padding: 28px 0 0; }
.masthead h1, .masthead .mast-title { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; }
.mast-tag { margin-top: 8px; font-size: 16px; color: var(--muted); }
.cat-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 0 4px; }
.cat-strip .chip { background: var(--surface); }
.cat-strip .chip.is-active, .cat-strip .chip[aria-current="page"] { color: var(--surface); background: var(--ink); border-color: var(--ink); }

/* Chips (category strip, post tags, tag cloud) */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--body); background: transparent; border: 1px solid var(--rule); border-radius: var(--r-pill);
}
.chip:hover { color: var(--ink); border-color: var(--ink); }
.chip.is-active, .chip[aria-current="page"] { color: var(--surface); background: var(--ink); border-color: var(--ink); }
.chip-n { font-family: var(--f-mono); font-size: 12px; opacity: .75; }

/* 6. Homepage hero (latest post) ------------------------------------------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; gap: 24px;
  padding: 24px 0 8px;
}
.hero-media { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hero-media .media { flex: 1; min-height: 320px; border-radius: var(--r); }
.hero-copy {
  display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 36px;
  color: var(--band-text); background: var(--grad-band); border-radius: var(--r);
}
.hero-eyebrow, .hero-cat { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--band-accent); }
.hero-cat { align-self: flex-start; text-decoration: none; }
.hero-cat:hover { text-decoration: underline; text-underline-offset: 4px; }
.hero-t { font-weight: 900; font-size: clamp(32px, 3.8vw, var(--h1)); line-height: 1.04; letter-spacing: -.025em; }
.hero-t a { text-decoration: none; }
.hero-blurb { font-size: 18px; line-height: 1.6; color: var(--band-muted); }
.stat-list {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 0; padding: 0; list-style: none;
}
.stat-list li {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px 14px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--band-rule); border-radius: var(--r-sm);
}
.stat-list li > span:first-child { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--band-muted); }
.stat-list .val { font-family: var(--f-mono); font-size: 22px; font-weight: 500; line-height: 1.2; color: var(--band-text); overflow-wrap: anywhere; }
.hero-cta { align-self: flex-start; margin-top: auto; }

/* 7. Media boxes (hero, cards, post lead) ---------------------------------- */
.media, .card-img, .post-lead {
  position: relative; display: grid; place-items: center; overflow: hidden;
  color: var(--img-ink); background: var(--img);
}
.media { aspect-ratio: 4 / 3; }
/* A drawn diagram (e.g. the evidence ladder) sizes to its content instead of being cropped to 4:3 */
.media.is-diagram { aspect-ratio: auto; padding: 24px; }
a.media { text-decoration: none; }
.media img, .card-img img, .post-lead img, .media svg.chart-svg { width: 100%; height: 100%; object-fit: cover; }
/* YouTube's hqdefault thumbnails are 4:3 with the 16:9 picture letterboxed: zoom past the bars */
.media img[src*="img.youtube.com/"], .card-img img[src*="img.youtube.com/"] { transform: scale(1.34); }
.media .ico { width: 120px; height: 120px; stroke-width: 1; }
.badge {
  position: absolute; top: 10px; z-index: 1; padding: 5px 11px; line-height: 1.2;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-radius: var(--r-pill);
}
.badge-cat { left: 10px; max-width: calc(100% - 110px); color: var(--cat-fg); background: var(--cat-bg); overflow-wrap: anywhere; }
.badge-n { right: 10px; color: var(--badge-fg); background: var(--badge-bg); font-size: 12px; letter-spacing: .02em; text-transform: none; }
.caption, .post-lead-caption { font-size: 14px; text-align: center; color: var(--muted); }

/* 8. Buttons + links ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 24px;
  font-family: var(--f-body); font-size: 15px; font-weight: 700;
  color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
/* Primary: the brand gradient. Light: white text (6.1 / 7.7:1); dark: --on-accent near-black (9.8 / 8.3:1) */
.btn-primary { color: var(--on-accent); background: var(--grad-fill); border: 0; }
.btn-primary:hover { filter: brightness(1.08); }
.hero .btn-primary { box-shadow: 0 0 0 1px var(--band-rule); }
.link, .cta-link {
  font-weight: 700; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
}
.link:hover, .cta-link:hover { color: var(--ink); }
.cta-link { font-size: 15px; }

/* 9. Section heads + card grid --------------------------------------------- */
.section { padding-top: 40px; padding-bottom: 8px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.sec-head h2 { font-size: var(--h2); line-height: 1.1; }
.sec-head a { font-size: 14px; font-weight: 700; color: var(--accent); text-decoration: none; }
.sec-head a:hover { text-decoration: underline; text-underline-offset: 4px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
}
.card:hover { border-color: var(--ink); }
.card-img { aspect-ratio: 4 / 3; }
.card-img .ico { width: 84px; height: 84px; stroke-width: 1.1; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.card-t { font-size: var(--ct); line-height: 1.2; }
.card-blurb { font-size: 15px; line-height: 1.55; color: var(--body); }
.card-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-top: auto; padding-top: 6px;
  font-size: 13px; color: var(--muted);
}
.card-meta time { font-family: var(--f-mono); font-size: 12px; }
.card-cta { font-weight: 700; color: var(--accent); }
.card:hover .card-t { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.more { display: flex; justify-content: center; padding: 40px 0 24px; }
.empty-note { grid-column: 1 / -1; padding: 28px; font-size: 17px; color: var(--muted); background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--r); }

/* 10. Gradient band: sections list + footer -------------------------------- */
.band { margin-top: 64px; color: var(--band-text); background: var(--grad-band); }
.band-in { padding-top: 44px; padding-bottom: 48px; }
.band h2 { margin-bottom: 22px; font-size: 28px; }
.band-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 24px; margin: 0; padding: 0; list-style: none; }
.band-list a {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-height: 44px; padding: 14px 0;
  color: var(--band-text); text-decoration: none; border-top: 1px solid var(--band-rule);
}
.band-list .n { font-family: var(--f-mono); font-size: 13px; color: var(--band-muted); }
.band-list .t { font-size: 18px; font-weight: 700; }
.band-list a:hover .t { text-decoration: underline; text-underline-offset: 4px; }

.foot { margin-top: 64px; color: var(--band-text); background: var(--grad-band); }
.band + .foot { margin-top: 0; border-top: 1px solid var(--band-rule); }
.foot-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; padding-top: 28px; padding-bottom: 28px; }
.foot-logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.foot .wordmark { color: var(--band-text); }
.foot .wordmark span { color: var(--band-accent); background: linear-gradient(90deg, #5CC8D7, #B49CFF); -webkit-background-clip: text; background-clip: text; }
.foot-tag { font-size: 14px; color: var(--band-muted); }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 22px; margin: 0; padding: 0; list-style: none; }
.foot-links a, .foot .link-btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--band-text); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.foot-links a:hover, .foot .link-btn:hover { text-decoration: underline; text-underline-offset: 4px; }
.foot-fine { padding-bottom: 28px; font-size: 13px; color: var(--band-muted); }

/* 11. Page heads (category, tags, search, about, hubs…) -------------------- */
.page-head { padding: 36px 0 8px; }
.page-head h1 { max-width: 24ch; font-size: calc(var(--h1) * .85); line-height: 1.06; }
.page-head p.lede { max-width: 62ch; margin-top: 12px; font-size: 18px; color: var(--body); }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* 12. Post page ------------------------------------------------------------ */
.post { padding-top: 32px; padding-bottom: 24px; }
.post-head { max-width: 900px; }
.post-h1 { max-width: 22ch; margin: 10px 0 12px; font-weight: 900; font-size: clamp(32px, 4.4vw, var(--h1)); line-height: 1.05; letter-spacing: -.025em; }
.post-blurb { max-width: 62ch; font-size: 19px; line-height: 1.6; color: var(--body); }
.post-checked { margin-top: 10px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.post-lead-fig { margin: 28px 0 36px; }
.post-lead { aspect-ratio: 21 / 9; border-radius: var(--r); }
.post-lead .ico { width: 150px; height: 150px; stroke-width: .9; }
.post-lead-caption { margin-top: 10px; }

/* "As of" line: directly above or below every table (CLAUDE.md §1, §7) */
.asof { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.asof .ico { width: 15px; height: 15px; margin-top: 2px; }
.asof strong { color: var(--ink); font-weight: 700; }
.asof .num { font-size: 12px; }

/* Data table (table.js). The plain data table is the default; .dt-ranking adds
   the Rank column, the #1 tint and in-row bars, and is ONLY for ranked-data
   posts (CLAUDE.md §7 "Tables are the product"). */
.dt { margin: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.dt::before { content: ""; display: block; height: 4px; background: var(--grad-stripe); }
.dt > .asof { padding: 10px 16px; border-bottom: 1px solid var(--rule); }
.dt-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 16px; border-bottom: 1px solid var(--rule); }
.dt-tools .search { flex: 0 1 320px; min-width: 240px; }
.dt-filter-toggle { display: none; }
.dt-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.dt-field { display: flex; flex-direction: column; gap: 4px; }
.dt-field .label { font-size: 11px; }
.dt-field select {
  height: 44px; min-width: 170px; padding: 0 36px 0 12px; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--rule); border-radius: var(--r-sm); appearance: none; -webkit-appearance: none; cursor: pointer;
}
.dt-field select:focus-visible { border-color: var(--focus); }
.dt-clear { min-height: 44px; padding: 0 18px; }
.dt-count { margin-left: auto; align-self: center; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
/* Long tables scroll inside their box on desktop so the header stays pinned; phones use the 5-row peek instead */
.dt-scroll { overflow-x: auto; }
@media (min-width: 721px) { .dt-scroll { max-height: 80vh; overflow-y: auto; } }
.dt-table { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums lining-nums; }
.dt-table caption { text-align: left; }
.dt-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 11px 16px; text-align: left; white-space: nowrap; vertical-align: bottom;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--ink);
}
.dt-table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--rule); color: var(--body); }
.dt-table tbody tr:last-child td { border-bottom: 0; }
.dt-table tbody tr:hover td { background: var(--surface-2); }
.dt-table .r, .dt-table th.r { text-align: right; }
.dt-table td.num { font-size: 14px; white-space: nowrap; color: var(--ink); }
.dt-table td.unit { font-size: 13px; color: var(--muted); white-space: nowrap; }
.dt-table td.name { min-width: 180px; font-weight: 600; color: var(--ink); }
.dt-table td.name a { text-decoration: none; }
.dt-table td.name a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.dt-table td.name .sub { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
/* Ranking table only */
.dt-ranking td.rank { width: 64px; font-family: var(--f-mono); font-size: 15px; font-weight: 600; color: var(--muted); }
.dt-ranking tr.is-top td { background: var(--hl); }
.dt-ranking tr.is-top td.rank { color: var(--accent); }
.dt-ranking td.dt-bar { width: 22%; min-width: 120px; }
.dt-bar .bar { display: block; height: 8px; width: var(--w, 0%); background: var(--grad-bar); border-radius: calc(var(--r-sm) / 3); }
.dt-sort {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0; margin: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  background: transparent; border: 0; cursor: pointer;
}
.dt-sort:hover { color: var(--ink); }
.dt-sort .arr { font-size: 12px; opacity: .6; }
th[aria-sort="ascending"] .dt-sort, th[aria-sort="descending"] .dt-sort { color: var(--accent); }
th[aria-sort="ascending"] .dt-sort .arr, th[aria-sort="descending"] .dt-sort .arr { opacity: 1; }
.dt-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.dt-table tbody tr.dt-clip { display: none; }
.dt-more { display: flex; justify-content: center; padding: 14px 16px; border-top: 1px solid var(--rule); }
.dt-more-btn { width: 100%; max-width: 420px; min-height: 46px; color: var(--on-accent); background: var(--grad-fill); border: 0; }
.table-note { max-width: 80ch; margin-top: 12px; font-size: 14px; color: var(--muted); }

/* Evidence-grade badge (CLAUDE.md §1): signal bars + label, readable in greyscale.
   <span class="grade grade-pilot"><span class="grade-glyph" aria-hidden="true"><i></i><i></i><i></i></span>Pilot</span> */
.grade {
  display: inline-flex; align-items: flex-end; gap: 7px; padding: 4px 10px;
  font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-pill);
}
.grade-glyph { display: inline-flex; align-items: flex-end; gap: 2px; padding-bottom: 3px; }
.grade-glyph i { display: block; width: 5px; border-radius: 1px; background: var(--accent); }
.grade-glyph i:nth-child(1) { height: 5px; }
.grade-glyph i:nth-child(2) { height: 9px; }
.grade-glyph i:nth-child(3) { height: 13px; }
.grade-pilot .grade-glyph i:nth-child(3),
.grade-prototype .grade-glyph i:nth-child(n+2) { background: var(--grade-off); }
.grade-claim { border-style: dashed; border-color: var(--muted); }
.grade-claim .grade-glyph i { background: transparent; border: 1px dashed var(--muted); }

/* Role card (role hubs, homepage, cross-links) */
.role-card { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.role-card::before { content: ""; display: block; height: 6px; background: var(--grad-stripe); }
.role-body { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.role-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.role-name { font-size: 26px; line-height: 1.12; }
.role-icon { display: grid; place-items: center; width: 60px; height: 60px; flex: none; border-radius: var(--r-sm); background: var(--paper); }
.role-icon .ico { width: 30px; height: 30px; }
.role-grades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--body); }
.role-grades li { display: flex; align-items: flex-end; gap: 8px; }
.role-grades .grade { padding: 0; border: 0; background: none; font-weight: 500; color: var(--body); }
.role-grades .n { margin-left: auto; font-family: var(--f-mono); color: var(--ink); }
.role-foot { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--muted); }
a.role-card:hover { border-color: var(--ink); }

/* Chart (lead image drawn from the post's own data) and ladder diagram */
.chart { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; height: 100%; width: 100%; padding: 24px; background: var(--surface); color: var(--ink); text-align: left; }
.chart-title { font-size: 17px; font-weight: 800; }
.chart-rows { display: flex; flex-direction: column; gap: 12px; }
.chart-row { display: grid; grid-template-columns: minmax(48px, auto) minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.chart-label, .chart-val { font-family: var(--f-mono); font-size: 13px; color: var(--body); }
.chart-val { color: var(--ink); text-align: right; }
.chart-bar { height: 20px; width: var(--w, 0%); background: var(--grad-bar); border-radius: calc(var(--r-sm) / 2.5); }
.chart-note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 8px; }
.ladder { display: flex; flex-direction: column; gap: 10px; padding: 24px; color: var(--band-text); background: var(--grad-band); border-radius: var(--r); }
.ladder-step { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r-sm); }
.ladder-step.is-claim { border-style: dashed; border-color: var(--muted); }
.ladder-step b { font-weight: 800; }
.ladder-step span { font-size: 13px; color: var(--muted); }

/* Narrative */
.narrative { margin-top: 56px; }
.narrative > h2, .sources h2, .appears h2, .facts h2, .cases h2 { margin-bottom: 20px; font-size: var(--h2); }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 40px; padding: 28px 0; border-top: 1px solid var(--rule); }
.entry-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.entry-rank { font-family: var(--f-mono); font-size: 26px; font-weight: 600; line-height: 1; color: var(--accent); }
.entry h3 { font-size: calc(var(--h2) * .82); line-height: 1.12; }
.entry-val { margin-left: auto; font-family: var(--f-mono); font-size: 18px; font-weight: 500; }
.entry-body { max-width: 62ch; color: var(--body); }
.entry-body p + p { margin-top: 12px; }
.entry-body:last-child { grid-column: 1 / -1; max-width: 72ch; }
.prose-sec { padding: 28px 0; border-top: 1px solid var(--rule); }
.prose-sec h3 { margin-bottom: 12px; font-size: 24px; }
.prose-sec p + p, .prose-sec .entry-body + .entry-body { margin-top: 12px; }
.prose-sec .embed { max-width: 860px; margin-top: 20px; }
/* Footnote markers: <sup class="fn"><a href="#s1" id="r1-1">1</a></sup> */
.fn a { padding: 0 2px; font-size: .78em; font-weight: 700; color: var(--accent); text-decoration: none; vertical-align: super; line-height: 0; }
.fn a:hover { text-decoration: underline; }
.embed { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--img); border-radius: var(--r-sm); }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-facade { position: absolute; inset: 0; display: block; width: 100%; padding: 0; border: 0; background: var(--img); cursor: pointer; }
.embed-facade img { width: 100%; height: 100%; object-fit: cover; }
.play-btn {
  position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(18, 19, 28, .6); border: 1.5px solid #FFFFFF; transition: background-color .2s;
}
.play-btn svg { width: 28px; height: 28px; margin-left: 4px; fill: #FFFFFF; }
.embed-facade:hover .play-btn, .embed-facade:focus-visible .play-btn { background: #0B6E69; border-color: #0B6E69; }
.entry-img { overflow: hidden; border-radius: var(--r-sm); }
.entry-img img { width: 100%; }

/* "Latest" headlines (data/news.json via sync-cards.py; main.js hides expired items) */
.latest { padding-top: 28px; }
.latest .sec-head { margin-bottom: 10px; }
.latest-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 0; padding: 4px 20px; list-style: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.latest-item { display: grid; grid-template-columns: 5.4em minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--rule); }
.latest-list > .latest-item:nth-child(-n+2) { border-top: 0; }
.latest-date { padding-top: 2px; font-family: var(--f-mono); font-size: 12px; white-space: nowrap; color: var(--accent); }
.latest-text { margin: 0; color: var(--body); }
.latest-src { font-size: 13px; color: var(--muted); }
.latest-links { margin: 6px 0 0; font-size: 14px; }
.latest-links .link { display: inline; }
.latest-links .link + .link { margin-left: 14px; }
.latest-box { max-width: 72ch; margin: 22px 0 0; }
.latest-box .latest-list { grid-template-columns: minmax(0, 1fr); }
.latest-box .latest-list > .latest-item:nth-child(2) { border-top: 1px solid var(--rule); }
.latest-box .label { display: block; margin-bottom: 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0; }
.sources { padding-top: 28px; border-top: 1px solid var(--rule); }
.sources ol { display: grid; gap: 8px; margin: 0; padding-left: 22px; font-size: 14px; color: var(--muted); }
.sources a { color: var(--accent); overflow-wrap: anywhere; }
.sources .fn-back { margin-left: 6px; text-decoration: none; }
.sources li:target { color: var(--ink); background: var(--hl); border-radius: 4px; }

/* 13. Profile hubs --------------------------------------------------------- */
.profile-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 32px 44px; align-items: start; padding: 36px 0 12px; }
.profile-type { color: var(--accent); }
.profile-name { margin-top: 10px; font-weight: 900; font-size: clamp(38px, 5.4vw, 68px); line-height: 1.02; letter-spacing: -.03em; }
.profile-name .soc { display: block; margin-top: 10px; font-size: 18px; font-weight: 500; letter-spacing: 0; }
.profile-intro { max-width: 66ch; margin-top: 22px; font-size: 18px; line-height: 1.7; color: var(--body); }
.profile-intro p + p { margin-top: 14px; }
.facts, .cases { margin-top: 48px; }
.facts-table { width: 100%; max-width: 760px; border-collapse: separate; border-spacing: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.facts-table th, .facts-table td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.facts-table tr:last-child th, .facts-table tr:last-child td { border-bottom: 0; }
.facts-table th { width: 34%; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.facts-table td { font-weight: 500; }
.appears { margin-top: 56px; }
.appears-list { margin: 0; padding: 0 20px; list-style: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.appears-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.appears-list li:last-child { border-bottom: 0; }
.appears-list .pos { min-width: 3.2em; font-family: var(--f-mono); font-size: 16px; font-weight: 600; color: var(--accent); }
.appears-list a { flex: 1 1 320px; font-size: 18px; font-weight: 700; text-decoration: none; }
.appears-list a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.appears-list .meta { font-size: 13px; color: var(--muted); }
.related { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 40px; }
.type-filter { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 0 8px; }
.type-filter button.chip { cursor: pointer; font-family: var(--f-body); }
.az { columns: 3 260px; column-gap: 40px; margin: 24px 0 0; padding: 0; list-style: none; }
.az li { break-inside: avoid; padding: 10px 0; border-top: 1px solid var(--rule); }
.az a { font-size: 18px; font-weight: 700; text-decoration: none; }
.az a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.az .meta { display: block; font-size: 13px; color: var(--muted); }
.az-letter { break-after: avoid; padding-top: 18px; font-size: 28px; font-weight: 900; color: var(--accent); border: 0 !important; }

/* 14. Glossary, category tiles, search, prose, 404 ------------------------- */
.glossary { margin: 24px 0 0; max-width: 820px; }
.glossary dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-top: 22px; border-top: 1px solid var(--rule); font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.glossary dt .abbr { font-family: var(--f-mono); font-size: 14px; font-weight: 500; color: var(--soc); }
.glossary dt .term-link { margin-left: auto; font-size: 15px; font-weight: 600; color: var(--muted); text-decoration: none; }
.glossary dt .term-link:hover { color: var(--accent); }
.glossary dd { margin: 8px 0 22px; color: var(--body); }
.glossary dd + dd { margin-top: -12px; font-size: 14px; color: var(--muted); }
.glossary dt:target, .glossary dt:target + dd { background: var(--hl); }
.az-jump { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 18px; }
.az-jump a { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; font-family: var(--f-mono); font-size: 15px; font-weight: 600; text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm); }
.az-jump a:hover { border-color: var(--ink); }

.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 24px 0 8px; }
.cat-tile { display: flex; flex-direction: column; gap: 8px; padding: 22px; color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); }
.cat-tile .ico { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.4; }
.cat-tile h2 { font-size: var(--ct); line-height: 1.2; }
.cat-tile p { font-size: 15px; color: var(--body); }
.cat-tile .chip-n { margin-top: auto; font-size: 12px; color: var(--muted); }
.cat-tile:hover { border-color: var(--ink); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; padding: 24px 0; }
.results-status { margin: 8px 0 24px; color: var(--muted); }
.search-page-form { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.search-page-form .search { flex: 1 1 420px; max-width: 640px; height: 56px; background: var(--surface); }
.search-page-form .search input { font-size: 19px; }

.prose { max-width: 70ch; padding: 8px 0 24px; color: var(--body); }
.prose h2 { margin: 40px 0 12px; font-size: 28px; color: var(--ink); }
.prose h3 { margin: 28px 0 10px; font-size: 19px; color: var(--ink); }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose a { color: var(--accent); text-underline-offset: 4px; }
/* About: the four evidence grades and the ladder diagram */
.grades-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px 18px; align-items: center; margin: 0 0 20px; }
.grades-list dt, .grades-list dd { margin: 0; }
.about-ladder { max-width: 440px; margin: 4px 0 20px; }

.notfound { padding: 96px 0; text-align: center; }
.notfound .code { font-family: var(--f-mono); font-size: 112px; font-weight: 600; line-height: 1; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.notfound h1 { margin: 16px 0 12px; font-size: var(--h2); }
.notfound p { margin-bottom: 28px; color: var(--muted); }
.notfound .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* Reserved ad slots (CLAUDE.md §2): fixed heights so ads never shift layout. Unused until ads go live. */
.ad-slot { display: grid; place-items: center; min-height: 280px; margin: 40px 0; background: var(--surface-2); border-radius: var(--r); }
.ad-slot.is-leader { min-height: 90px; }
.ad-slot::before { content: "Advertisement"; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

/* 14b. Cookie consent banner (assets/js/consent.js; EU/EEA/UK/CH visitors only) */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 760px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; padding: 18px 22px; overflow: hidden;
  color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 10px 30px rgba(18, 19, 28, .18);
}
.consent::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--grad-stripe); }
.consent[hidden] { display: none; }
.consent-text { flex: 1 1 300px; margin: 0; font-size: 14px; line-height: 1.5; color: var(--body); }
.consent-text strong { font-size: 16px; color: var(--ink); }
.consent-text a { color: var(--accent); font-weight: 700; text-underline-offset: 3px; }
.consent-btns { display: flex; gap: 10px; }
.consent .btn { min-height: 44px; padding: 0 22px; }

/* 15. Responsive ----------------------------------------------------------- */
@media (max-width: 1300px) {
  .topbar-tag { display: none; }
}

@media (max-width: 1100px) {
  /* Top bar (tablets and phones): logo + theme toggle + menu button; util nav and search fold into a panel */
  .topbar-in { flex-wrap: wrap; gap: 8px; }
  .mini-logo { margin-right: auto; }
  .nav-toggle { display: inline-flex; width: 44px; }
  .nav-toggle .i-close { display: none; }
  .topbar.is-open .nav-toggle .i-menu { display: none; }
  .topbar.is-open .nav-toggle .i-close { display: block; }
  /* Without JS (no .js class) the panel simply stays open */
  .mast-panel { order: 5; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 4px; padding-bottom: 12px; }
  .js .mast-panel { display: none; }
  .js .topbar.is-open .mast-panel { display: flex; }
  html:not(.js) .nav-toggle { display: none; }
  .util-nav { flex-direction: column; margin-left: 0; }
  .util-nav a { padding: 0; font-size: 15px; }
  .mast-tools, .mast-tools form { width: 100%; }
  .mast-tools .search { flex: 1; min-width: 0; }

  .grid, .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .band-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar-tag { display: none; }
}

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 16px; }
  .hero-media .media { min-height: 0; }
  .profile-head { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  :root { --h1: 34px; --h2: 26px; --ct: 19px; --bar-h: 58px; }
  .wrap, .wrap-narrow { padding: 0 16px; }
  /* Phones: a smaller logo and an icon-only theme toggle */
  .wordmark { font-size: 21px; }
  .logo-tile { width: 28px; height: 28px; }
  .theme-toggle { padding: 0; width: 44px; }
  .theme-toggle .tt-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  /* Category strip: one horizontally scrolling row; main.js scrolls the active chip into view */
  .cat-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .cat-strip::-webkit-scrollbar { display: none; }
  .cat-strip .chip { flex: none; white-space: nowrap; }

  .hero-copy { padding: 22px; }
  .grid, .cat-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .band-list { grid-template-columns: minmax(0, 1fr); }
  .grades-list { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .grades-list dd { margin-bottom: 10px; }
  .stat-list { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .stat-list li { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; }
  .stat-list .val { text-align: right; font-size: 18px; }

  /* Table filters collapse behind a "Filters" button */
  .dt-tools { padding: 14px; }
  .dt-tools .search { flex: 1 1 100%; min-width: 0; }
  .dt-filter-toggle { display: inline-flex; min-height: 44px; }
  .dt-filters { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; }
  .dt.filters-open .dt-filters { display: flex; }
  .dt-field select { width: 100%; }
  .dt-count { margin-left: 0; }
  .dt-table th, .dt-table td { padding-left: 12px; padding-right: 12px; }

  .entry { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .entry-val { margin-left: 0; }
  .post-lead { aspect-ratio: 4 / 3; }
  .post-lead img[src*="img.youtube.com/"] { transform: scale(1.34); }
  .latest-list { grid-template-columns: minmax(0, 1fr); padding: 4px 16px; }
  .latest-list > .latest-item:nth-child(2) { border-top: 1px solid var(--rule); }
  .role-grades { grid-template-columns: minmax(0, 1fr); }
  .facts-table th { width: 42%; }
  .notfound .code { font-size: 84px; }
}

/* 16. Motion + print ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .cat-strip, .band, .foot, .dt-tools, .more, .dt-more, .consent, .ad-slot { display: none !important; }
  .dt-table tbody tr.dt-clip { display: table-row; }
  .dt-scroll { max-height: none; overflow: visible; }
  .dt-table th { position: static; }
  body { background: #fff !important; color: #000 !important; }
}
html:not(.js) .js-only { display: none; }
