:root {
  --div-lo: #2a78d6; --div-mid: #f0efec; --div-hi: #c44e52;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --div-lo: #4b94eb; --div-mid: #323230; --div-hi: #df6568; }
}
:root[data-theme="dark"] { --div-lo: #4b94eb; --div-mid: #323230; --div-hi: #df6568; }

ul.sub li { margin: 0.35rem 0; }
section { margin-top: 2.25rem; }
.controls { gap: 0.5rem 1rem; margin: 0.65rem 0; }
.controls input[type="search"] { width: 15rem; }
.seg button { font-size: 12px; }
.tiles { gap: 0.7rem 1.75rem; margin: 0.75rem 0 1rem; padding: 0.6rem 0.95rem; }
.tiles .tile { min-width: 115px; }
.tiles .d { font-size: 10.5px; color: var(--muted); }
.legend { gap: 0.25rem 0.9rem; font-size: 11.5px; margin: 0.45rem 0; }
.legend i.ramp { width: 130px; }
.two { gap: 1.75rem; }
@media (max-width: 920px) { .two { grid-template-columns: 1fr; } }

.chart { position: relative; width: 100%; min-width: 0; overflow-x: auto; }
.chart svg { display: block; width: 100%; max-width: 100%; overflow: visible; font-family: inherit; }
.svg-scroll { overflow-x: auto; }
.svg-scroll svg { min-width: 520px; cursor: crosshair; }
.axis-lbl { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.hover-guide { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 4 3; pointer-events: none; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-dot { stroke: var(--bg); stroke-width: 1.2; pointer-events: none; }

/* Ranked horizontal bar rows (full opacity preserved on hover; outline highlights inspected bar) */
.bar-list { max-width: 980px; }
.bar-scroll { max-height: 28rem; overflow-y: auto; scrollbar-gutter: stable; padding-right: 4px; }
.bar-row {
  display: grid; grid-template-columns: minmax(11rem, 16rem) minmax(0, 1fr) 8.5rem;
  align-items: center; gap: 0.6rem; padding: 0.2rem 0.25rem; border-bottom: 1px solid var(--surface);
  font-size: 11.5px;
}
.bar-row:hover { background: var(--surface); }
.bar-row:hover .bar-fill { outline: 1.5px solid var(--text); outline-offset: -1.5px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 10px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; }
.bar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val b { color: var(--text); font-weight: 600; }

/* Stacked 100% horizontal comparison bars */
.stack-row {
  display: grid; grid-template-columns: minmax(11rem, 16rem) minmax(0, 1fr) 5.5rem;
  align-items: center; gap: 0.6rem; padding: 0.25rem 0; border-bottom: 1px solid var(--surface);
  font-size: 11.5px;
}
.stack-bar { display: flex; height: 14px; width: 100%; border-radius: 2px; overflow: hidden; background: var(--surface); }
.stack-bar > i { display: block; height: 100%; }

/* Paired bars (author concentration) */
.pair-row {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 9rem;
  align-items: center; gap: 0.6rem; padding: 0.3rem 0.2rem; border-bottom: 1px solid var(--surface);
  font-size: 11.5px;
}
.pair-row:hover { background: var(--surface); }
.pair-bars { display: flex; flex-direction: column; gap: 3px; }
.pair-bars .bar-track { height: 7px; }

/* Heatmaps */
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 11px; }
table.heat th { font-weight: 400; color: var(--muted); padding: 2px 5px; white-space: nowrap; }
table.heat th.col-h { cursor: pointer; text-align: center; font-size: 10.5px; }
table.heat th.col-h:hover { color: var(--text); text-decoration: underline; }
table.heat th.row-h { text-align: right; position: sticky; left: 0; background: var(--bg); z-index: 1; padding-right: 8px; }
table.heat td.cell {
  min-width: 54px; height: 22px; text-align: center; font-variant-numeric: tabular-nums;
  border-radius: 2px; padding: 0 4px; font-size: 10.5px; cursor: default;
}

#geo-heatmap table { margin-inline-end: 3rem; }
#geo-heatmap thead th { vertical-align: bottom; }
#geo-heatmap thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); }
#geo-heatmap .discipline-col, #geo-heatmap td.cell { width: 64px; min-width: 64px; }
#geo-heatmap .discipline-col { position: relative; height: 4.5rem; padding: 0; }
#geo-heatmap thead button {
  font: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: pointer;
}
#geo-heatmap .discipline-col button {
  position: absolute; left: calc(50% - 0.5em); bottom: 3px;
  transform: rotate(-35deg); transform-origin: bottom left;
}
#geo-heatmap thead button:hover,
#geo-heatmap th[aria-sort] button { color: var(--text); text-decoration: underline; }
#geo-heatmap th[aria-sort] button { font-weight: 600; }

table.data { font-size: 11.5px; max-width: 1100px; }
table.data th, table.data td { white-space: nowrap; }
table.data th { font-size: 11px; }

@media (max-width: 600px) {
  .bar-row { grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr) 6.5rem; }
  .stack-row { grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr) 4.2rem; }
}
