/* ============================================================= *
 * SMM SoK - light "datasheet" surface with a copper accent
 * and a ring-glyph motif.
 * ============================================================= */

:root {
  color-scheme: light;

  --bg:        #EFF2F6;
  --panel:     #FFFFFF;
  --panel-2:   #F1F4F8;
  --raise:     #E7ECF2;
  --line:      #D3DBE4;
  --line-soft: #E3E8EE;
  --grid-line: #E6EBF1;

  --text:   #16212C;
  --muted:  #4F5E6D;
  --faint:  #8290A0;

  --copper:     #AD6A1E;
  --copper-dim: #D9B488;
  --copper-glow: rgba(173,106,30,.16);

  --header-bg: rgba(239,242,246,.85);

  /* era hues: three clearly distinct colors, away from the copper accent */
  --era1: #3D6FB3;
  --era2: #2E9284;
  --era3: #C2532F;
  --era1-soft: rgba(61,111,179,.10);
  --era2-soft: rgba(46,146,132,.10);
  --era3-soft: rgba(194,83,47,.10);

  --ok:   #2E8B63;
  --warn: #C2402F;

  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --disp: "Space Grotesk", var(--sans);

  --radius: 9px;
  --maxw: 1320px;
}

/* wide screens (QHD/4K, incl. large monitors rotated to portrait): let the
   content use more width so the table fits without a horizontal scrollbar */
@media (min-width: 1600px) { :root { --maxw: 1560px; } }
@media (min-width: 2000px) { :root { --maxw: 1780px; } }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* faint die-grid texture on the substrate */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

a { color: var(--copper); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 50;
  background: var(--copper); color: #fff; padding: 8px 14px;
  border-radius: 6px; font-weight: 600; transition: top .15s;
}
.skip:focus { top: 12px; text-decoration: none; }

/* ----------------------------------------------------------------- hero */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 28px 30px;
}
.hero-inner { width: 100%; text-align: center; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--copper); margin: 0 0 14px;
}
h1 {
  font-family: var(--disp);
  font-weight: 600;
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.04;
  letter-spacing: -.015em;
  margin: 0 0 18px;
}
h1 .smm { color: var(--copper); white-space: nowrap; }
.lede {
  max-width: 62ch; color: var(--muted); font-size: 16px; margin: 0 auto 24px;
}

.hero-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 34px; margin-bottom: 24px; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat .num {
  font-family: var(--disp); font-weight: 700;
  font-size: 30px; line-height: 1; color: var(--text);
}
.stat .lbl {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); margin-top: 6px;
}

.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; }
.hero-links a, .hero-links .cite-link {
  font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  padding: 7px 13px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--text);
  background: var(--panel); cursor: pointer; line-height: 1.3;
}
.hero-links a:hover, .hero-links .cite-link:hover { border-color: var(--copper-dim); color: var(--copper); text-decoration: none; }
.hero-links .cite-link { border-color: var(--copper-dim); }
.hero-links .cite-link.copied { color: var(--ok); border-color: var(--ok); }

/* info boxes: 2-up cards; an open box grows in place inside its own column */
/* single column so every box is full-width and consistent: each expands in
   place when clicked (no reordering / jumping) and the wide tree fits. */
.hero-boxes {
  margin-top: 30px;
  /* minmax(0,…) lets a box shrink below its widest child (the ~800px tree) so
     it fits the viewport and the child scrolls, instead of stretching all boxes
     past the screen width and getting clipped. */
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 12px; align-items: start;
  text-align: left;
}
.explainer, .explainer-body { min-width: 0; }
.tax-tree-wrap { max-width: 100%; }
.explainer {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel);
}
.explainer[open] { border-color: var(--copper-dim); box-shadow: 0 2px 14px rgba(22,33,44,.06); }
.explainer summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.explainer summary::-webkit-details-marker { display: none; }
.explainer summary:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: var(--radius); }
.explainer-q { font-family: var(--disp); font-weight: 600; font-size: 16px; color: var(--text); }
.explainer-tag {
  font-family: var(--mono); font-size: 11px; color: var(--copper);
  border: 1px solid var(--copper-dim); border-radius: 5px; padding: 1px 7px;
}
.explainer-chev {
  margin-left: auto; font-family: var(--mono); font-size: 18px; line-height: 1;
  color: var(--faint); transition: transform .2s;
}
.explainer[open] .explainer-chev { transform: rotate(45deg); color: var(--copper); }
.explainer-body { padding: 0 16px 16px; border-top: 1px solid var(--line-soft); }
.explainer-body p { color: var(--muted); font-size: 14.5px; margin: 14px 0 0; max-width: 92ch; }
/* "what is SMM?" text flows up to its floated figure, so don't cap it */
.explainer-body:has(.smm-fig) p { max-width: none; }
.explainer-body strong { color: var(--text); font-weight: 600; }
.explainer-body code { font-family: var(--mono); font-size: 12.5px; color: var(--copper); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.explainer-facts {
  list-style: none; padding: 0; margin: 16px 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 18px;
}
.explainer-facts li { font-size: 13.5px; color: var(--text); border-left: 2px solid var(--copper-dim); padding-left: 10px; }
.explainer-facts li span {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 2px;
}
.explainer-more { font-size: 13px !important; }
.explainer-h {
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--faint);
  margin: 20px 0 10px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}

.explainer-body::after { content: ""; display: block; clear: both; }

/* SMM protection-rings figure */
.smm-fig { float: right; width: 188px; margin: 2px 0 10px 20px; text-align: center; }
.smm-fig svg { width: 172px; height: 172px; }
.ring-band { stroke: var(--line); stroke-width: 1; }
.ring-band.b1 { fill: rgba(228,166,94,.05); }
.ring-band.b2 { fill: rgba(228,166,94,.09); }
.ring-band.b3 { fill: rgba(228,166,94,.15); }
.ring-core { fill: var(--copper); stroke: var(--copper); }
.ring-lab { text-anchor: middle; font-family: var(--mono); font-size: 8px; fill: var(--muted); }
.ring-core-lab { text-anchor: middle; font-family: var(--disp); font-weight: 700; font-size: 13px; fill: #1a1206; }
.ring-core-sub { text-anchor: middle; font-family: var(--mono); font-size: 7.5px; fill: #1a1206; }
.smm-fig figcaption { font-size: 11px; color: var(--faint); margin-top: 6px; line-height: 1.35; }

/* interactive classification tree (Fig. 2) */
.tax-tree-wrap {
  /* fits fully when the viewport has room (tall/portrait screens); scrolls
     only when the tree is taller/wider than the space available */
  margin-top: 14px; overflow: auto; max-height: 85vh;
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--bg); padding: 6px;
}
#tax-tree-svg { display: block; }
.tax-edge { fill: none; stroke: var(--line); stroke-width: 1.4; }
.tax-node { outline: none; }
.tax-node .tn-box { fill: var(--panel-2); stroke: var(--line); stroke-width: 1.2; transition: stroke .12s, fill .12s; }
.tax-node .tn-tab { fill: var(--c, var(--faint)); }
.tax-node text { fill: var(--text); font-family: var(--sans); font-size: 11px; pointer-events: none; }
.tax-node:hover .tn-box,
.tax-node:focus-visible .tn-box { stroke: var(--c, var(--copper)); }
.tax-node.sel .tn-box { stroke: var(--c, var(--copper)); stroke-width: 2; fill: var(--copper-glow); }
.tax-node.sel text { font-weight: 600; }

/* root colour key under the tree */
.tax-legend-roots { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0 !important; }
.root-key { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.root-key .tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }

@media (max-width: 560px) {
  .smm-fig { float: none; width: 100%; margin: 0 0 14px; }
}

/* ------------------------------------------------------- phone / narrow */
@media (max-width: 560px) {
  /* never let the page itself scroll sideways; inner boxes scroll instead */
  html, body { overflow-x: hidden; }

  .hero { padding: 30px 16px 18px; }
  .hero-stats { gap: 16px 22px; margin-bottom: 18px; }
  .hero-links { gap: 6px 8px; }

  .explainer-body { padding: 0 12px 14px; }
  .explainer-facts { grid-template-columns: 1fr; }

  /* phone: the box keeps the screen width; content that doesn't fit scrolls
     inside it (the wide tree scrolls horizontally, BibTeX horizontally too) */
  .tax-tree-wrap { -webkit-overflow-scrolling: touch; max-height: 70vh; overflow: auto; }
  .cite-block pre { -webkit-overflow-scrolling: touch; overflow: auto; }

  .active-filters { padding: 0 12px; }

  /* table cards */
  .layout { padding: 14px 12px 40px; }
  tbody tr.row { padding: 11px 12px 11px 15px; }
  .td-name { min-width: 0; }
  .td-name .nm { font-size: 14px; }
  .td-flag { margin-right: 12px; }
  .detail-inner { padding: 11px 13px 13px; font-size: 13px; }
  .dfield .dv { word-break: break-word; }
}

/* indicator + era legends inside the explainer */
.legend-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.legend-list li { display: flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); }
.legend-list li > span:last-child { margin-left: 8px; }
.legend-list strong { color: var(--text); }
.legend-list .glyph { flex: none; }
.era-legend .era-dot { width: 13px; height: 13px; border-radius: 3px; flex: none; }
.era-dot[data-era="1"] { background: var(--era1); }
.era-dot[data-era="2"] { background: var(--era2); }
.era-dot[data-era="3"] { background: var(--era3); }

/* citation block */
.cite-block { position: relative; margin-top: 12px; }
.cite-block pre {
  margin: 0; overflow-x: auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; font-family: var(--mono); font-size: 12.5px;
  color: var(--text); line-height: 1.55; white-space: pre;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; padding: 5px 9px; cursor: pointer;
}
.copy-btn:hover { border-color: var(--copper-dim); color: var(--copper); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* ----------------------------------------------------------- controls */
.controls {
  position: sticky; top: 0; z-index: 30;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.controls-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 11px 28px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1 1 320px; min-width: 200px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
#search {
  width: 100%; padding: 10px 12px 10px 36px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--sans); font-size: 14px;
}
#search:focus { outline: none; border-color: var(--copper-dim); box-shadow: 0 0 0 3px var(--copper-glow); }

.dataset-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dataset-toggle button {
  background: var(--panel); color: var(--muted); border: 0;
  padding: 9px 14px; font-family: var(--mono); font-size: 12px;
  cursor: pointer; border-right: 1px solid var(--line);
}
.dataset-toggle button:last-child { border-right: 0; }
.dataset-toggle button.active { background: var(--copper); color: #fff; font-weight: 600; }
.dataset-toggle button i { font-size: 11px; margin-right: 5px; }

.filters-toggle { display: none; }

.result-count {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  margin-left: auto; white-space: nowrap;
}
.result-count #count { color: var(--copper); font-weight: 600; }

.active-filters {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 28px; display: flex; flex-wrap: wrap; gap: 7px;
}
.active-filters:not(:empty) { padding-bottom: 11px; }
.chip {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--raise); border: 1px solid var(--line);
  color: var(--text); padding: 4px 8px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip:hover { border-color: var(--warn); color: var(--warn); }
.chip .x { font-weight: 700; opacity: .7; }

/* ------------------------------------------------------------- layout */
.layout {
  max-width: var(--maxw); margin: 0 auto;
  padding: 24px 28px 60px;
  display: grid; grid-template-columns: 244px 1fr; gap: 28px;
  align-items: start;
}

/* ------------------------------------------------------------ sidebar */
.sidebar {
  position: sticky; top: 74px;
  max-height: calc(100vh - 92px); overflow-y: auto;
  padding-right: 4px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-head h2 { font-family: var(--disp); font-size: 15px; margin: 0; letter-spacing: .02em; }
.reset, .linklike {
  background: none; border: 0; color: var(--faint);
  font-family: var(--mono); font-size: 11.5px; cursor: pointer; padding: 0;
}
.reset:hover, .linklike:hover { color: var(--copper); }
.linklike { color: var(--copper); text-decoration: underline; }

.facet { border-top: 1px solid var(--line-soft); padding: 14px 0; }
.facet:first-child { border-top: 0; }
.facet > h3 {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
  margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center;
}
.opt {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 0; cursor: pointer; font-size: 13.5px; color: var(--muted);
  user-select: none;
}
.opt:hover { color: var(--text); }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.box {
  width: 15px; height: 15px; flex: none; border-radius: 4px;
  border: 1.5px solid var(--line); background: var(--panel);
  display: grid; place-items: center; transition: .12s;
}
.opt input:checked + .box { background: var(--copper); border-color: var(--copper); }
.opt input:checked + .box::after { content: ""; width: 8px; height: 8px; background: #fff; clip-path: polygon(14% 47%,0 61%,40% 100%,100% 18%,84% 4%,38% 70%); }
.opt input:focus-visible + .box { box-shadow: 0 0 0 3px var(--copper-glow); }
.opt .cnt { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.opt.disabled { opacity: .38; cursor: default; }

/* taxonomy tree indentation + connector */
.tree .opt { position: relative; }
.tree .lvl-1 { margin-left: 16px; }
.tree .lvl-2 { margin-left: 32px; }
.tree .lvl-3 { margin-left: 48px; }
.tree .lvl-1::before, .tree .lvl-2::before, .tree .lvl-3::before {
  content: ""; position: absolute; left: -10px; top: 0; bottom: 0;
  border-left: 1px solid var(--line-soft);
}
.tree .tag-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* ---------------------------------------------------------- the table */
.main-col { min-width: 0; }

/* always-visible era key above the table; buttons double as filters */
.era-key { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.era-key button {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px 6px 9px; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; color: var(--muted); line-height: 1.3;
}
.era-key .era-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--c); flex: none; }
.era-key .era-name { font-weight: 600; color: var(--text); }
.era-key .era-span { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.era-key button:hover { border-color: var(--c); }
.era-key button.active { border-color: var(--c); background: var(--c-soft); }
.era-key button.active .era-name { color: var(--c); }
.era-key button[data-era="1"] { --c: var(--era1); --c-soft: var(--era1-soft); }
.era-key button[data-era="2"] { --c: var(--era2); --c-soft: var(--era2-soft); }
.era-key button[data-era="3"] { --c: var(--era3); --c-soft: var(--era3-soft); }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel-2);
  text-align: left; font-family: var(--mono); font-weight: 500;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
thead th.sortable:hover { color: var(--copper); }
thead th .arrow { color: var(--copper); font-size: 10px; margin-left: 4px; opacity: 0; }
thead th[aria-sort="ascending"]  .arrow { opacity: 1; }
thead th[aria-sort="descending"] .arrow { opacity: 1; }
thead th.col-center { text-align: center; }

tbody tr.row { border-bottom: 1px solid var(--line-soft); cursor: pointer; }
tbody tr.row:hover { background: var(--panel); }
tbody td { padding: 11px 12px; vertical-align: top; }

.td-mark { width: 36px; padding: 0; position: relative; vertical-align: top; text-align: center; }
.era-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
[data-era="1"] .era-bar { background: var(--era1); }
[data-era="2"] .era-bar { background: var(--era2); }
[data-era="3"] .era-bar { background: var(--era3); }
.td-mark .kind-ico { font-size: 14px; margin-left: 6px; margin-top: 13px; display: inline-block; }

.td-name { min-width: 230px; }
.name-line { display: flex; align-items: flex-start; gap: 7px; }
.name-wrap { min-width: 0; }
.kind-ico { flex: none; }
.kind-attack { color: #2f6493; }    /* study / research paper */
.kind-advisory { color: #b3402f; }  /* vendor advisory / bug */
.name-line .nm { font-weight: 600; color: var(--text); font-size: 14.5px; }
a.nm:hover { color: var(--copper); }
.name-line .ext-arrow { font-size: 11px; color: var(--faint); }
.name-sub { display: none; font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 3px; }

.td-year { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.td-venue { white-space: nowrap; }
.venue-name { color: var(--text); }
.venue-type {
  display: inline-block; margin-top: 3px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line);
  color: var(--muted);
}
.vt-Academia { border-color: #9cbada; color: #2f6493; }
.vt-Hacker-community { border-color: var(--copper-dim); color: var(--copper); }
.vt-Industry { border-color: #b3c7a6; color: #4d7038; }

.td-class { min-width: 250px; }
.class-path { font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.45; }
.class-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tagchip {
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 7px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--panel-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.tagchip .tag-dot { width: 6px; height: 6px; border-radius: 50%; }

/* root tag colors */
.root-Plat-config { --c: #4E79A8; }
.root-SMM-code    { --c: #C07F23; }
.root-Concept     { --c: #7E5AAE; }
.tagchip .tag-dot { background: var(--c, var(--faint)); }

/* ring glyphs for src/e2e/auto (echo Fig.1 ring motif) */
.col-center, .td-flag { text-align: center; }
.glyph {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 1.6px solid var(--faint); position: relative; vertical-align: middle;
}
.glyph.full { background: var(--copper); border-color: var(--copper); }
.glyph.partial { border-color: var(--copper); }
.glyph.partial::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--copper); clip-path: inset(0 50% 0 0); }
.glyph.none { background: transparent; }
.glyph.ext  { display: none; }
.ext-ref {
  font-family: var(--mono); font-size: 11px; color: var(--copper);
}
.ext-ref::before { content: "["; color: var(--faint); }
.ext-ref::after  { content: "]"; color: var(--faint); }
.flag-yes { color: var(--copper); }
.flag-no  { color: var(--faint); }

.td-toggle { width: 30px; text-align: center; }
.expand-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); width: 24px; height: 24px; cursor: pointer;
  font-family: var(--mono); line-height: 1; font-size: 13px;
}
.expand-btn:hover { border-color: var(--copper-dim); color: var(--copper); }

tr.detail-row td { padding: 0 12px; background: var(--panel); }
.detail-inner {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 12px 26px; padding: 14px 4px 18px; border-top: 1px dashed var(--line);
}
.detail-row[hidden] { display: none; }
.dfield .dk {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); display: block; margin-bottom: 2px;
}
.dfield .dv { color: var(--text); font-size: 13px; }
.dfield .dv.empty { color: var(--faint); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* contribute + footer */
.contribute {
  margin-top: 34px; padding: 22px 24px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel);
}
.contribute h2 { font-family: var(--disp); font-size: 18px; margin: 0 0 10px; }
.contribute p { color: var(--muted); max-width: 72ch; margin: 0 0 10px; }
.contribute code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: var(--copper); }

.site-footer {
  border-top: 1px solid var(--line);
  max-width: var(--maxw); margin: 0 auto; padding: 26px 28px 50px;
  color: var(--muted); font-size: 13px;
}
.site-footer strong { color: var(--text); font-weight: 600; }
.footer-note { margin-top: 10px; color: var(--faint); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.legend-glyph { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--faint); vertical-align: middle; }
.legend-glyph.full { background: var(--copper); border-color: var(--copper); }
.legend-glyph.partial { position: relative; border-color: var(--copper); overflow: hidden; }
.legend-glyph.partial::after { content:""; position:absolute; inset:0; background: var(--copper); clip-path: inset(0 50% 0 0); }
.legend-ext { font-family: var(--mono); color: var(--copper); }
.leg { display: inline-flex; align-items: center; gap: 5px; }

/* --------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .hero { padding: 34px 20px 22px; }
  .hero-boxes { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; padding: 18px 16px 50px; }
  .active-filters { padding-left: 16px; padding-right: 16px; }

  /* controls: stack vertically, each element full-width and readable */
  .controls-inner { flex-direction: column; align-items: stretch; gap: 9px; padding: 11px 16px; }
  .search-wrap { flex: 1 1 auto; min-width: 0; }
  .dataset-toggle { display: flex; width: 100%; }
  .dataset-toggle button { flex: 1 1 0; justify-content: center; padding: 10px 6px; font-size: 12.5px; }
  .result-count { margin-left: 0; text-align: center; }
  /* era key: full-width stacked, easy to tap */
  .era-key button { width: 100%; justify-content: flex-start; }

  .filters-toggle {
    display: block; width: 100%; text-align: center;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; cursor: pointer;
  }
  .filters-toggle[aria-expanded="true"] { border-color: var(--copper-dim); color: var(--copper); }
  .sidebar {
    position: static; max-height: none; overflow: visible;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; margin-bottom: 18px; display: none;
  }
  .sidebar.open { display: block; }

  /* table → cards */
  .table-scroll { border: 0; overflow: visible; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr.row {
    border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 12px; padding: 12px 12px 12px 16px; position: relative;
  }
  .td-mark { position: static; width: auto; padding: 2px 0; text-align: left; }
  .td-mark .era-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; height: auto; border-radius: var(--radius) 0 0 var(--radius); }
  .td-mark .kind-ico { margin-left: 0; font-size: 15px; }
  tbody td { padding: 4px 0; }
  .name-sub { display: block; }
  .td-venue .venue-name { display: none; } /* shown in name-sub */
  .td-year { display: none; }
  .td-flag::before {
    content: attr(data-label); font-family: var(--mono); font-size: 10px;
    letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
    margin-right: 8px;
  }
  .td-flag { display: inline-block; width: auto; margin-right: 18px; }
  .td-toggle { position: absolute; right: 10px; top: 10px; width: auto; }

  /* detail: single-column stack, pulled up flush against its summary card */
  tr.detail-row { margin: -12px 0 12px; }
  tr.detail-row td { padding: 0; }
  /* expanded detail fills the full card width: multi-column when there's room
     (landscape / wide), collapsing to one column only when truly narrow */
  .detail-inner {
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 12px 22px;
    padding: 12px 16px 14px;
    border: 1px solid var(--line); border-top: 1px dashed var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}

/* search "why it matched" hint under the row name */
.match-hint {
  margin-top: 3px; font-size: 11.5px; color: var(--muted);
  font-family: var(--mono); line-height: 1.35;
  overflow-wrap: anywhere;
}
.match-hint .mh-field { color: var(--faint); }
.match-hint .mh-mark {
  background: var(--copper-glow); color: var(--copper);
  border-radius: 3px; padding: 0 2px; font-weight: 600;
}

/* "Landscape by era" stats table */
.era-stats-wrap { margin-top: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-soft); border-radius: var(--radius); }
#era-stats { border-collapse: collapse; width: 100%; font-size: 13px; }
#era-stats th, #era-stats td { padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
#era-stats thead th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--faint); background: var(--panel-2); font-weight: 500; }
#era-stats tbody tr:last-child th, #era-stats tbody tr:last-child td { border-bottom: 0; }
#era-stats .es-corner { text-align: left; }
#era-stats .es-era { text-align: left; font-weight: 600; color: var(--text); white-space: nowrap; }
#era-stats .es-era .era-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block;
  vertical-align: -1px; margin-right: 8px; }
#era-stats tbody tr[data-era="1"] .era-dot { background: var(--era1); }
#era-stats tbody tr[data-era="2"] .era-dot { background: var(--era2); }
#era-stats tbody tr[data-era="3"] .era-dot { background: var(--era3); }
#era-stats td:last-child { font-weight: 700; color: var(--copper); }
#era-stats thead th:last-child { color: var(--copper); }
