/* BXSwiss taxonomy UI - plain CSS, no external resources. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #1f2328;
  background: #fafbfc;
}

a { color: #0a5cc2; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f0f2f5;
  padding: 0 4px;
  border-radius: 3px;
}

.muted { color: #6a737d; }
.small { font-size: 0.85em; }
.warn  { color: #b14700; font-weight: 500; }

/* Color utilities for taxonomy-coverage states */
.text-green { color: #1a7f37; }
.text-red   { color: #cf222e; }

/* Override visited/hover/active link colors on the BXSwiss coverage page
so the green/red state is preserved (the global <a> rule would otherwise
overpower it). Narrowly scoped to .bx-tx-list. */
.bx-tx-list a.text-green,
.bx-tx-list a.text-green:visited,
.bx-tx-list a.text-green:hover,
.bx-tx-list a.text-green:active { color: #1a7f37; }
.bx-tx-list a.text-red,
.bx-tx-list a.text-red:visited,
.bx-tx-list a.text-red:hover,
.bx-tx-list a.text-red:active { color: #cf222e; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: #b31a21;
  color: #fff;
  border-bottom: 1px solid #8a1419;
}
.topbar a { color: #fff; }
.topbar .brand a {
  font-weight: 600;
  font-size: 1.15em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar .brand .muted { color: #bcc4cc; }
.topbar nav a {
  margin-left: 16px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover { border-bottom-color: #fff; text-decoration: none; }

/* Content */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

h1 { font-size: 1.6em; margin: 0 0 12px; }
h2 { font-size: 1.2em; margin: 24px 0 8px; }
h3 { font-size: 1.0em; margin: 16px 0 6px; }

section { margin: 24px 0; }
section h2 { border-bottom: 1px solid #d0d7de; padding-bottom: 4px; }

/* Tile dashboard */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}
.tile {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 12px 14px;
}
.tile-label { font-size: 0.85em; color: #6a737d; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value { font-size: 1.6em; font-weight: 600; margin-top: 4px; }
.tile-asset { border-left: 4px solid #1f883d; }
.tile-deterministic { border-left: 4px solid #2f6feb; }
.tile-human-review { border-left: 4px solid #cf222e; }
.tile-unclassified { border-left: 4px solid #6a737d; }

/* Landing page tile cards (one per top-level section).
   Default is flex so tiles grow around fixed-width arrows (.tile-arrow).
   Arrow-less sections collapse to a CSS Grid via :has() so any tile
   count (2, 4, 6, ...) lays out without an empty trailing column. */
.landing-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  max-width: 1080px;
  margin: 32px auto;
}
.landing-tiles:not(:has(.tile-arrow)) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
/* Home landing only: cap card width so a trailing card on a wrapped row
   does not flex-grow into a full-width banner. */
.landing-tiles.home-tiles .tile-card {
  max-width: 260px;
}
.tile-card {
  flex: 1 1 200px;
  display: block;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 24px 20px;
  text-align: center;
  text-decoration: none;
  color: #1f2328;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.tile-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
  border-color: #b6e3ff;
  text-decoration: none;
}
.tile-card .icon {
  font-size: 2.4em;
  margin-bottom: 10px;
  color: #b31a21;
}
.tile-card .title {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 4px;
}
.tile-card .desc {
  font-size: 0.85em;
  color: #6a737d;
  line-height: 1.35;
}

.tile-arrow {
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6a737d;
  font-size: 1.6em;
  align-self: center;
}
@media (max-width: 680px) {
  .tile-arrow { display: none; }
}

/* Two column */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #d0d7de;
  font-size: 0.9em;
}
table.data th, table.data td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #eaecef;
  vertical-align: top;
}
table.data th { background: #f6f8fa; font-weight: 600; }
table.data tr:hover td { background: #f6f8fa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.path { font-family: ui-monospace, monospace; font-size: 0.85em; word-break: break-word; }

/* Definition lists */
dl.kv {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 4px 12px;
  margin: 0;
}
dl.kv dt { font-weight: 500; color: #6a737d; }
dl.kv dd { margin: 0; word-break: break-word; }

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 0.78em;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-asset { background: #dafbe1; color: #1a7f37; border-color: #aceebb; }
.badge-status { background: #fff1e5; color: #bc4c00; border-color: #ffce9c; }
.badge-deterministic { background: #ddf4ff; color: #b31a21; border-color: #b6e3ff; }
.badge-human-review { background: #ffebe9; color: #cf222e; border-color: #ffcecb; }
.badge-unclassified { background: #eaeef2; color: #57606a; border-color: #d0d7de; }

/* Exchanges - URL verdict badges (GitHub Primer palette) */
.badge-verified  { background: #dafbe1; color: #1a7f37; border-color: #aceebb; }
.badge-uncertain { background: #fff1e5; color: #bc4c00; border-color: #ffce9c; }
.badge-mismatch  { background: #ffebe9; color: #cf222e; border-color: #ffcecb; }
.badge-failed    { background: #ffebe9; color: #cf222e; border-color: #ffcecb; }
.badge-pending   { background: #eaeef2; color: #57606a; border-color: #d0d7de; }

/* Expression Paths - source grounding & audit badges */
.badge-cited         { background: #dafbe1; color: #1a7f37; border-color: #aceebb; }
.badge-needs-research { background: #fff1e5; color: #bc4c00; border-color: #ffce9c; }
.badge-no-direct     { background: #ffebe9; color: #cf222e; border-color: #ffcecb; }
.badge-uncited       { background: #eaeef2; color: #57606a; border-color: #d0d7de; }
.badge-watchlist     { background: #ddf4ff; color: #0969da; border-color: #b6e3ff; }

/* Landing section header */
.landing-section {
  max-width: 900px;
  margin: 24px auto 8px;
  font-size: 1.0em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #57606a;
  border-bottom: 1px solid #d0d7de;
  padding-bottom: 4px;
}
.landing-section:first-of-type { margin-top: 12px; }

/* Body preformatted text */
pre.body {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  max-height: 320px;
  overflow: auto;
}

/* Filters */
form.filters {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 12px 0;
}
form.filters .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 6px 0;
}
form.filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.82em;
  color: #57606a;
}
form.filters label.grow { flex: 1 1 240px; }
form.filters input[type=text],
form.filters input[type=number],
form.filters select {
  margin-top: 2px;
  padding: 4px 6px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
form.filters button,
a.button {
  background: #1f883d;
  color: #fff;
  border: 1px solid #1a7f37;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font: inherit;
}
form.filters button:hover,
a.button:hover {
  background: #1a7f37;
  text-decoration: none;
}
a.button { background: #57606a; border-color: #4a525a; }
a.button:hover { background: #4a525a; }

/* Pagination */
.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

/* Breadcrumb / hierarchy slug */
.breadcrumb {
  font-size: 0.85em;
  color: #6a737d;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.breadcrumb a {
  color: #0a5cc2;
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #6a737d; padding: 0 2px; }
.breadcrumb .current { color: #1f2328; font-weight: 500; }

/* Footer */
.footer {
  text-align: center;
  padding: 14px;
  border-top: 1px solid #d0d7de;
  margin-top: 30px;
}

/* Taxonomy tree (hierarchical, <details>/<summary>-based) */
ul.tax-tree, ul.tax-tree ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
ul.tax-tree ul {
  padding-left: 18px;
  border-left: 1px dashed #d0d7de;
  margin: 2px 0 4px 6px;
}
ul.tax-tree > li {
  padding: 1px 0;
}
ul.tax-tree details {
  margin: 0;
}
ul.tax-tree summary {
  cursor: pointer;
  list-style: none;
  display: list-item;
  padding: 1px 0;
  user-select: none;
}
ul.tax-tree summary::-webkit-details-marker { display: none; }
ul.tax-tree summary::marker { content: ""; }
ul.tax-tree summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  margin-left: -2px;
  color: #57606a;
  font-size: 0.85em;
}
ul.tax-tree details[open] > summary::before {
  content: "▾";
}
ul.tax-tree a.tax-label { font-weight: 500; }
ul.tax-tree .tax-count { margin-left: 2px; }
ul.tax-tree li.selected > a.tax-label,
ul.tax-tree li.selected > details > summary > a.tax-label {
  font-weight: 600;
  color: #bc4c00;
  background: #fff1e5;
  padding: 0 4px;
  border-radius: 3px;
}
ul.tax-tree details[open] > summary > a.tax-label { font-size: inherit; }

/* Drilldown */
section.drilldown {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 24px;
}
.path { font-family: ui-monospace, monospace; font-size: 0.9em; word-break: break-word; }

/* Responsive */
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar nav { margin-top: 6px; }
  .topbar nav a { margin-left: 0; margin-right: 12px; }
  form.filters .filter-row { flex-direction: column; align-items: stretch; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { margin-top: 6px; }
  .landing-tiles:not(:has(.tile-arrow)) { grid-template-columns: 1fr; }
}

/* Flash messages (admin reload feedback) */
ul.flashes { list-style: none; padding: 0; margin: 12px 0; }
.flash { padding: 8px 12px; border-radius: 4px; margin-bottom: 6px; }
.flash-success { background: #dafbe1; color: #1a7f37; border: 1px solid #1f883d; }
.flash-error   { background: #ffebe9; color: #cf222e; border: 1px solid #cf222e; }

/* /admin reload button (scoped so it doesn't bleed into other bare <button>s) */
form[action$="/admin"] button[type="submit"] {
  background: #1f883d;
  color: #fff;
  border: 1px solid #1a7f37;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  font: inherit;
}

/* Logout button (rightmost in topbar) */
.logout-form { margin-left: auto; }
.logout-form button {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font: inherit;
}
.logout-form button:hover { background: rgba(255, 255, 255, 0.15); }

/* Login page — no branding, no hints */
body.login-page {
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}
.login-container { width: 100%; max-width: 320px; padding: 24px; }
.login-form {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85em;
  color: #57606a;
}
.login-form input {
  padding: 6px 8px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font: inherit;
}
.login-form button {
  background: #1f883d;
  color: #fff;
  border: 1px solid #1a7f37;
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}
.login-error { color: #cf222e; font-size: 0.9em; margin: 0; }

/* Expression Mechanisms: nested mechanism rows under family disclosures */
.family-tree-item > .mechanisms {
  margin-left: 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid #d0d7de;
}

/* Exchange product/service classification (Step 1) */
.ep-tile {
  display: block;
  padding: 16px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  color: inherit;
}
.ep-tile:hover { border-color: #b6e3ff; }
.ep-quote {
  background: #f6f8fa;
  border-left: 3px solid #d0d7de;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  margin: 6px 0;
}
.ep-pill {
  display: inline-block;
  font-size: 0.75em;
  padding: 1px 6px;
  border-radius: 8px;
  background: #eaeef2;
  color: #57606a;
  margin-right: 4px;
}

/* Topics viewer (scoped under .topics-page) */

.topics-page {
--ink: #1a1a1a;
  --ink-muted: #6a6a6a;
  --line: #e5e5e5;
  --bg-soft: #f7f7f5;
  --accent: #0f4c5c;
  --accent-face: #5b8a96;
}

.topics-page /* tag-viewer — minimal hand-rolled stylesheet */



* { box-sizing: border-box; }

.topics-page /* topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: #fbfbf9;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topics-page .meta {
  margin-left: auto;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.topics-page /* Timeline page uses full available horizontal space. */
body.timeline-page main {
  max-width: none;
  width: 100%;
}

.topics-page /* index — toolbar + tag table */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.topics-page .sort {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.topics-page .sort button {
  border: 1px solid var(--line);
  background: white;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.topics-page .sort button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.topics-page .muted { color: var(--ink-muted); font-size: 0.85rem; }

.topics-page table.tags {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.topics-page table.tags th, .topics-page table.tags td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.topics-page table.tags th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid #d5d5d3;
}

.topics-page table.tags .col-name { width: 65%; }

.topics-page table.tags .col-count { width: 25%; }

.topics-page table.tags .col-flags { width: 10%; }

.topics-page table.tags .num { text-align: right; font-variant-numeric: tabular-nums; }

.topics-page table.tags tbody tr.is-hidden { display: none; }

.topics-page .badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: #e7f0f2;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  border: 1px solid #cfdfe2;
}

.topics-page /* detail */
.crumbs { font-size: 0.85rem; margin-bottom: 0.5rem; }

.topics-page .crumbs a { color: var(--ink-muted); }

.topics-page .tag-head h1 {
  margin: 0.1rem 0 0.25rem;
  font-size: 1.55rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.topics-page .tag-head h1 .badge { vertical-align: middle; margin-left: 0.4rem; }

.topics-page .tag-head .lede { color: var(--ink-muted); margin: 0 0 1.1rem; }

.topics-page table.meta {
  border-collapse: collapse;
  margin: 0 0 1.25rem;
}

.topics-page table.meta th, .topics-page table.meta td {
  padding: 0.35rem 0.9rem 0.35rem 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.topics-page table.meta th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  width: 11rem;
}

.topics-page .members { margin: 0; padding: 0; list-style: none; }

.topics-page .members li { display: inline-block; margin-right: 0.4rem; }

.topics-page figure.chart {
  margin: 0 0 2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fdfdfb;
}

.topics-page figure.chart img {
  display: block;
  width: 100%;
  height: auto;
}

.topics-page figure.chart figcaption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.topics-page .placeholder {
  border: 1px dashed var(--line);
  padding: 1rem 1.2rem;
  border-radius: 6px;
  background: #fcfcf9;
}

.topics-page .placeholder h2 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.topics-page .placeholder p { margin: 0; }

.topics-page /* topbar nav (added with /timeline) */
.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.topics-page /* timeline page */
.timeline-head {
  margin: 0 0 1rem;
}

.topics-page .timeline-head h1 {
  margin: 0.1rem 0 0.3rem;
  font-size: 1.55rem;
}

.topics-page .timeline-head .lede {
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
}

.topics-page .timeline-status {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.topics-page .timeline-status.error {
  color: #c0392b;
  background: #fcefee;
  border: 1px solid #f3c8c4;
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
}

.topics-page .timeline-status button {
  margin-left: 0.5rem;
  border: 1px solid var(--line);
  background: white;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.topics-page .timeline-figure {
  margin: 0 0 1.5rem;
  padding: 1rem 1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fdfdfb;
}

.topics-page .timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.topics-page .timeline-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.topics-page .timeline-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.topics-page .timeline-viewport {
  position: relative;
  overflow-x: hidden;
}

.topics-page .timeline-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}

.topics-page .timeline-grid line {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.topics-page .timeline-year-line {
  stroke: var(--ink-muted);
  stroke-width: 1.5;
  shape-rendering: crispEdges;
}

.topics-page .timeline-year-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}

.topics-page .timeline-marker {
  stroke: #fdfdfb;
  stroke-width: 1.5;
  fill: var(--family-misc);
}

.topics-page .timeline-marker.family-1 { fill: var(--family-1); }

.topics-page .timeline-marker.family-2 { fill: var(--family-2); }

.topics-page .timeline-marker.family-3 { fill: var(--family-3); }

.topics-page .timeline-marker.family-4 { fill: var(--family-4); }

.topics-page .timeline-marker.family-5 { fill: var(--family-5); }

.topics-page .timeline-marker.family-6 { fill: var(--family-6); }

.topics-page .timeline-marker.family-7 { fill: var(--family-7); }

.topics-page .timeline-hit {
  fill: transparent;
}

.topics-page .timeline-mark:hover .timeline-marker, .topics-page .timeline-mark:focus-visible .timeline-marker {
  stroke: var(--accent-face);
  stroke-width: 2.5;
  outline: none;
}

.topics-page .timeline-mark:focus-visible {
  outline: none;
}

.topics-page .timeline-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  background: white;
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--ink);
}

.topics-page .timeline-tooltip .tt-name {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
}

.topics-page .timeline-tooltip .tt-meta {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.topics-page .timeline-tooltip .tt-flag {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  background: #e7f0f2;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.topics-page .timeline-tooltip .tt-shape {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.topics-page .timeline-data {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 1rem;
}

.topics-page .timeline-data > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 0.3rem 0;
}

.topics-page .timeline-data > summary:hover {
  color: var(--ink);
}

.topics-page .timeline-data table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  table-layout: fixed;
}

.topics-page .timeline-data th, .topics-page .timeline-data td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  vertical-align: middle;
}

.topics-page .timeline-data th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.topics-page .timeline-data .col-tag { width: 45%; }

.topics-page .timeline-data .col-count { width: 15%; text-align: right; font-variant-numeric: tabular-nums; }

.topics-page .timeline-data .col-debut { width: 15%; font-variant-numeric: tabular-nums; }

.topics-page .timeline-data .col-family { width: 15%; }

.topics-page .timeline-data .col-flag { width: 10%; }

.topics-page .timeline-data code {
  font-size: 0.95em;
}

.topics-page /* family palette (validated against #fdfdfb, .topics-page dataviz skill reference) */
.timeline {
  --family-misc: #0f4c5c;   /* accent (existing); used for misc + merge */
  --family-1: #2a78d6;      /* blue */
  --family-2: #eb6834;      /* orange */
  --family-3: #1baf7a;      /* aqua */
  --family-4: #eda100;      /* yellow */
  --family-5: #e87ba4;      /* magenta */
  --family-6: #008300;      /* green */
  --family-7: #4a3aa7;      /* violet */
}

.topics-page /* ============================================================
   Buckets page (/buckets, .topics-page /bucket/<label>)
   ============================================================ */
body.buckets-page main { max-width: none; width: 100%; }

.topics-page .buckets-head { margin: 0 0 1rem; }

.topics-page .buckets-head h1 { margin: 0.1rem 0 0.3rem; font-size: 1.55rem; }

.topics-page .buckets-head .lede { color: var(--ink-muted); margin: 0 0 0.8rem; }

.topics-page .buckets-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.topics-page .buckets-toolbar input[type=search] {
  flex: 1 1 280px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  min-width: 240px;
}

.topics-page .buckets-toolbar .sort { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--ink-muted); }

.topics-page .buckets-toolbar .sort-btn {
  border: 1px solid var(--line);
  background: white;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.topics-page .buckets-toolbar .sort-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.topics-page .buckets-count { color: var(--ink-muted); font-size: 0.85rem; margin-left: auto; }

.topics-page .buckets-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}

.topics-page .buckets-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 1.4fr 130px 110px;
  gap: 1.2rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.topics-page .buckets-row:hover { background: #fafaf8; }

.topics-page .buckets-row:hover .buckets-label { color: var(--accent); }

.topics-page .buckets-cell { min-width: 0; }

.topics-page .buckets-cell-label { display: flex; flex-direction: column; gap: 0.15rem; }

.topics-page .buckets-label { font-weight: 600; font-size: 0.95rem; }

.topics-page .buckets-rationale { color: var(--ink-muted); font-size: 0.78rem; line-height: 1.35; }

.topics-page .buckets-cell-spark { min-height: 30px; }

.topics-page .buckets-sparkline { width: 100%; height: 30px; display: block; }

.topics-page .buckets-sparkline--full { width: 100%; height: 200px; display: block; }

.topics-page .buckets-cell-count { display: flex; flex-direction: column; gap: 0.1rem; align-items: flex-end; }

.topics-page .buckets-total { font-weight: 600; font-variant-numeric: tabular-nums; }

.topics-page .buckets-members { color: var(--ink-muted); font-size: 0.78rem; }

.topics-page .buckets-sparkline-tooltip {
  background: white;
  border: 1px solid var(--line);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-size: 0.78rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink);
  z-index: 100;
}

.topics-page .bucket-pattern {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.topics-page .bucket-pattern.flaring, .topics-page .bucket-pattern.flaring-debut { background: #fde9d4; color: #b95100; }

.topics-page .bucket-pattern.fading, .topics-page .bucket-pattern.debut-and-fade { background: #e3e8eb; color: var(--ink-muted); }

.topics-page .bucket-pattern.steady { background: #e7f0f2; color: var(--accent); }

.topics-page .bucket-pattern.ephemeral { background: #f5e6e3; color: #c0392b; }

.topics-page .bucket-pattern.insufficient-data { background: #efefef; color: var(--ink-muted); }

.topics-page /* Bucket detail page */
.bucket-head { margin: 0 0 1.2rem; }

.topics-page .bucket-head h1 { margin: 0.1rem 0 0.3rem; font-size: 1.7rem; }

.topics-page .bucket-head .lede { color: var(--ink-muted); margin: 0 0 0.6rem; }

.topics-page .bucket-meta { color: var(--ink-muted); font-size: 0.85rem; margin: 0.2rem 0; }

.topics-page .bucket-meta code { background: var(--bg-soft); padding: 0.05em 0.35em; border-radius: 3px; }

.topics-page .bucket-chart {
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fdfdfb;
}

.topics-page .bucket-chart figcaption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.topics-page .bucket-members h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 0.6rem;
}

.topics-page .bucket-members-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.3rem 0.8rem;
}

.topics-page .bucket-members-list li code { font-size: 0.85em; }

/* View toggle (topbar pill — rendered inside the topbar, unscoped).
   Specificity: .topbar .view-toggle beats the global .topbar nav a rule. */
.topbar .view-toggle {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.78rem;
  margin-left: 0.5rem;
}
.topbar .view-toggle a {
  padding: 0.25rem 0.6rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  border-bottom: none !important;
  margin-left: 0 !important;
}
.topbar .view-toggle a.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.topbar .view-toggle a:not(.active):hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 700px) {
  .buckets-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .buckets-cell-count, .buckets-cell-pattern { align-items: flex-start; }
}

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .topbar-nav { order: 1; }
  .meta { width: 100%; }
}

.topics-page /* ============================================================
   Article list (tag.html, .topics-page bucket.html)
   ============================================================ */
.articles-section { margin: 1.5rem 0; }

.topics-page .articles-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 0.6rem;
}

.topics-page .articles-toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.topics-page .articles-toolbar input[type=search] {
  flex: 1 1 240px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  min-width: 200px;
}

.topics-page .articles-toolbar .sort-btn {
  border: 1px solid var(--line);
  background: white;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.topics-page .articles-toolbar .sort-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.topics-page table.articles-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.topics-page table.articles-table th, .topics-page table.articles-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.88rem;
  word-wrap: break-word;
}

.topics-page table.articles-table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid #d5d5d3;
}

.topics-page table.articles-table .col-date { width: 11%; font-variant-numeric: tabular-nums; }

.topics-page table.articles-table .col-desc { width: 76%; }

.topics-page table.articles-table .col-source { width: 13%; color: var(--ink-muted); }

.topics-page table.articles-table tbody tr.is-hidden { display: none; }

.topics-page .articles-sections { font-size: 0.78rem; margin-top: 0.2rem; color: var(--ink-muted); }

.topics-page .articles-footer { margin-top: 0.5rem; }

.topics-page /* drill-down chrome on bucket detail page */
.week-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  margin: 0 0 0.8rem;
  background: #e7f0f2;
  border: 1px solid #cfdfe2;
  border-radius: 4px;
  font-size: 0.85rem;
}

.topics-page .week-badge code { background: white; padding: 0.05em 0.35em; border-radius: 3px; }

@media (max-width: 700px) {
  table.articles-table .col-source { display: none; }
  table.articles-table .col-desc { width: 89%; }
}
