* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  padding: 20px 16px 56px;
  -webkit-font-smoothing: antialiased;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
}
h1 {
  margin: 0;
  font: 800 26px var(--sans);
  letter-spacing: -0.6px;
}
.tag {
  color: var(--dim);
  font: 500 13px var(--sans);
  margin: 6px 0 0;
  max-width: 680px;
  line-height: 1.5;
}
.right {
  text-align: right;
}
.note {
  font: 600 11px var(--mono);
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}
a.glink {
  display: inline-block;
  margin-top: 6px;
  font: 700 11px var(--mono);
  color: var(--orange);
  text-decoration: none;
}
a.glink:hover {
  text-decoration: underline;
}
html {
  scroll-behavior: smooth;
}
section {
  margin-top: 28px;
}
section[id] {
  scroll-margin-top: 56px;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
.eyebrow {
  font: 700 11px var(--mono);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.eyebrow .k {
  color: var(--dim2);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
/* clickable help bubble next to a control: tap or hover to explain it */
.metric-cell {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.metric-cell .help {
  margin-left: 0;
}
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--ink2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
}
/* gold herald hairline — the shared Pheme card signature */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--gold) 55%, transparent),
    transparent
  );
  opacity: 0.25;
  transition: opacity 0.2s ease;
}
.stat .v {
  font: 800 24px var(--sans);
  letter-spacing: -0.5px;
  color: var(--fog);
  line-height: 1.1;
}
.stat .l {
  font: 600 11px var(--mono);
  color: var(--dim2);
  margin-top: 5px;
  line-height: 1.35;
}
/* .stat--link: only the KPI-strip cards that actually open the detail
   modal get the pointer cursor + hover lift — the read-only scorecard
   stat cards rendered by loadScorecard() stay plain .stat. */
.stat--link {
  cursor: pointer;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.stat--link:hover {
  transform: translateY(-2px);
  border-color: var(--orange);
  box-shadow: 0 4px 20px rgba(240, 85, 48, 0.15);
}
.stat--link:hover::before {
  opacity: 0.9;
}
/* ground-up rethink: a hero summary + chapter rhythm so the page reads as
   a guided tour instead of a wall of tables */
.dhero {
  padding: 30px 0 4px;
}
.dhero h1 {
  display: block;
  font: 600 clamp(28px, 4.6vw, 48px) var(--font-display);
  letter-spacing: -0.3px;
  line-height: 1.04;
  color: var(--fog);
  margin: 0;
  max-width: 760px;
}
.dhero h1 em {
  font-style: normal;
  color: var(--orange);
}
.dhero .sub {
  font: 500 16px var(--sans);
  color: var(--dim);
  margin: 16px 0 0;
  max-width: 660px;
  line-height: 1.55;
}
.dhero .sub b {
  color: var(--fog);
  font-weight: 600;
}
#kpi-strip .strip {
  margin-top: 26px;
}
#kpi-strip .stat .v {
  font-size: 27px;
}
.chapter {
  display: flex;
  align-items: baseline;
  gap: 13px;
  margin: 52px 0 20px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 64px;
}
.chapter .cn {
  font: 800 13px var(--mono);
  color: var(--orange);
}
.chapter h2 {
  font: 800 23px var(--sans);
  letter-spacing: -0.5px;
  color: var(--fog);
  margin: 0;
}
.chapter .ck {
  font: 500 13px var(--sans);
  color: var(--dim2);
  margin-left: auto;
  text-align: right;
  max-width: 360px;
  line-height: 1.45;
}
section[id] {
  scroll-margin-top: 60px;
}
@media (max-width: 720px) {
  .chapter .ck {
    font-size: 12px;
    max-width: 100%;
    text-align: left;
    margin-left: 0;
    margin-top: 4px;
  }
}
.grid {
  display: grid;
  /* min(320px, 100%) instead of a bare 320px floor — on a 320px-wide phone
     (iPhone SE class, still real traffic) the bare floor forced every card
     to be exactly viewport-width *before* padding, guaranteeing horizontal
     overflow (measured: 16px on /us/explore and /us/live). min() caps the
     floor at whatever space is actually available so cards never force a
     scrollbar, while still preferring a full 320px column everywhere wider.
     */
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}
.card {
  background: linear-gradient(180deg, var(--ink2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.card h3 {
  margin: 0 0 2px;
  font: 700 14px var(--sans);
  color: var(--fog);
  line-height: 1.3;
}
.card .sub {
  font: 500 11px var(--mono);
  color: var(--dim2);
  margin-bottom: 10px;
}
.limits-callout {
  border-left: 3px solid var(--orange);
  background: var(--ink2);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 12px 14px;
  margin-top: 16px;
}
.limits-callout ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.6;
  font: 500 13px var(--sans);
  color: var(--fog);
}
.limits-callout li + li {
  margin-top: 6px;
}
.compbar {
  margin-bottom: 14px;
}
.compbar .top {
  display: flex;
  justify-content: space-between;
  font: 600 12px var(--sans);
  margin-bottom: 5px;
}
.compbar .top b {
  color: var(--fog);
}
.compbar .top span {
  color: var(--dim2);
  font: 500 11px var(--mono);
}
.seg {
  display: flex;
  height: 18px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--ink2);
}
.seg i {
  display: block;
  height: 100%;
  width: 0;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
}
.keys span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 500 11px var(--mono);
  color: var(--dim);
}
.sw {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
  flex: none;
}
.evbar {
  position: relative;
  height: 36px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  background: var(--ink2);
  margin: 20px 0 4px;
}
.evbar i {
  height: 100%;
  display: flex;
  align-items: center;
  font: 800 13px var(--sans);
  color: #0b0f17;
  padding: 0 10px;
  width: 0;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}
.evbar .mid {
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--fog);
  transform: translateX(-50%);
  z-index: 2;
}
.evbar .midlab {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  font: 700 10px var(--mono);
  color: var(--dim);
  z-index: 2;
}
.bgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 6px;
  margin-top: 14px;
}
.bg {
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 7px 9px;
  font: 600 12px var(--sans);
}
.bg .ab {
  color: var(--fog);
  font-weight: 800;
}
.bg .m {
  font: 600 11px var(--mono);
}
.rank {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font: 600 12px var(--mono);
}
.rank:last-child {
  border-bottom: none;
}
.rank .n {
  color: var(--dim);
  font-family: var(--sans);
  font-weight: 500;
}
.rank b {
  color: var(--fog);
}
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
input.search {
  flex: 1;
  min-width: 160px;
  background: var(--ink2);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font: 600 13px var(--sans);
  outline: none;
}
input.search:focus {
  border-color: var(--dim2);
}
button {
  font-family: var(--sans);
  cursor: pointer;
}
.swing-slider:focus-visible {
  outline-offset: 5px;
}
thead th:focus-visible {
  outline-offset: -2px;
}
/* .btn now lives in pheme.css (canonical); removed the local copy */
.tblwrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  max-height: 520px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font: 600 12px var(--mono);
}
thead th {
  position: sticky;
  top: 0;
  background: var(--panel2);
  color: var(--dim);
  text-align: right;
  padding: 9px 10px;
  font: 700 11px var(--mono);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--line2);
}
thead th:first-child,
tbody td:first-child {
  text-align: left;
}
thead th:hover {
  color: var(--fog);
}
thead th .ar {
  color: var(--orange);
}
tbody td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  white-space: nowrap;
}
tbody tr {
  cursor: pointer;
}
tbody tr:hover,
tbody tr.hot {
  background: var(--panel2);
}
tbody tr.hot td:first-child {
  color: var(--orange);
}
tbody td:first-child {
  color: var(--fog);
  font-weight: 800;
  font-family: var(--sans);
}
.lean.d {
  color: var(--orange);
}
.lean.r {
  color: var(--teal);
}
.muted {
  color: var(--dim2);
}
svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
}
.empty p {
  color: var(--dim);
  font: 500 13px var(--sans);
  max-width: 560px;
  margin: 0 auto 14px;
  line-height: 1.5;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 600 11px var(--mono);
  color: var(--dim);
}
.method {
  color: var(--dim);
  font: 500 13px var(--sans);
  line-height: 1.6;
  max-width: 780px;
}
.method b {
  color: var(--fog);
}
.method code {
  font: 600 12px var(--mono);
  color: var(--gold);
}
/* state detail */
#state-detail .card {
  border-color: var(--line2);
}
.sd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.sd-name {
  font: 800 22px var(--sans);
  color: var(--fog);
  letter-spacing: -0.4px;
}
.sd-meta {
  font: 600 12px var(--mono);
  color: var(--dim);
  margin-top: 3px;
}
.sd-close {
  border: none;
  background: transparent;
  color: var(--dim2);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.sd-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  margin: 13px 0;
}
.sd-stat {
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.sd-stat .v {
  font: 800 17px var(--sans);
  color: var(--fog);
}
.sd-stat .l {
  font: 600 10px var(--mono);
  color: var(--dim2);
  margin-top: 3px;
  line-height: 1.3;
}
.sd-stat .l b {
  color: var(--teal);
}
.sd-stat .l b.lo {
  color: var(--orange);
}
/* swingometer */
.swing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 18px;
  margin-bottom: 4px;
}
.swing-top {
  display: flex;
  justify-content: space-between;
  font: 600 12px var(--sans);
  margin-bottom: 4px;
}
.swing-val {
  font: 700 11px var(--mono);
  color: var(--dim);
}
.swing-slider {
  width: 100%;
  accent-color: var(--orange);
  cursor: pointer;
}
.swing-base-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.swing-base-toggle button {
  cursor: pointer;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--dim);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font: 700 11px var(--sans);
}
.swing-base-toggle button.on {
  background: var(--teal);
  color: #0b0f17;
  border-color: var(--teal);
}
.swing-base-toggle button:disabled {
  cursor: default;
  opacity: 0.5;
}
.swing-base-note {
  font: 500 10px var(--mono);
  color: var(--dim2);
}
.sbar {
  position: relative;
  height: 34px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  background: var(--ink2);
  margin: 20px 0 4px;
}
.sbar i {
  height: 100%;
  display: flex;
  align-items: center;
  font: 800 13px var(--sans);
  color: #0b0f17;
  padding: 0 10px;
}
.sbar .mid {
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--fog);
  transform: translateX(-50%);
  z-index: 2;
}
.sbar .midlab {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  font: 700 10px var(--mono);
  color: var(--dim);
  z-index: 2;
}
/* compare two states */
.cmp-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cmp-pick select {
  flex: 1;
  min-width: 130px;
  background: var(--ink2);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  font: 600 13px var(--sans);
  outline: none;
}
.cmp-pick select:focus-visible {
  border-color: var(--dim2);
}
.cmp-vs {
  font: 700 11px var(--mono);
  color: var(--dim2);
}
.cmp-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font: 600 13px var(--mono);
}
.cmp-grid.cmp-head {
  font: 800 14px var(--sans);
  color: var(--fog);
  border-bottom: 1px solid var(--line2);
}
.cmp-head .cmp-sub {
  display: block;
  font: 500 10px var(--mono);
  color: var(--dim2);
  margin-top: 2px;
}
.cmp-lab {
  color: var(--dim);
  font: 600 12px var(--sans);
}
.cmp-win {
  color: var(--fog);
  font-weight: 800;
}
/* live news pulse */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.ncard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ncard .nrow {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ntopic {
  font: 700 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line2);
}
.ndate {
  font: 600 10px var(--mono);
  color: var(--dim2);
  margin-left: auto;
}
.nhead {
  font: 700 13px var(--sans);
  color: var(--fog);
  line-height: 1.3;
}
.nsrc {
  font: 600 10px var(--mono);
  color: var(--dim2);
}
.nsrc .nst {
  color: var(--gold);
}
.nimp {
  font: 500 11px var(--sans);
  color: var(--dim);
  line-height: 1.4;
}
.nsim {
  font: 700 11px var(--mono);
  color: var(--orange);
  text-decoration: none;
  margin-top: 2px;
}
.nsim:hover,
.nsim:focus-visible {
  text-decoration: underline;
  outline: none;
}
.ncard .nfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}
.nwhy {
  font: 700 10px var(--mono);
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  transition:
    color 0.12s,
    border-color 0.12s;
}
.nwhy:hover,
.nwhy:focus-visible {
  color: var(--fog);
  border-color: var(--teal);
  outline: none;
}
/* compare scenarios */
.scn-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 12px 0;
}
.scn-h {
  font: 700 13px var(--sans);
  color: var(--fog);
  line-height: 1.3;
  min-height: 34px;
}
.scn-meta {
  font: 600 10px var(--mono);
  color: var(--dim2);
  text-transform: capitalize;
  margin: 3px 0 7px;
}
.scn-stat {
  font: 600 12px var(--mono);
  color: var(--dim);
  margin-top: 6px;
}
footer {
  text-align: center;
  margin-top: 34px;
  font: 500 11px var(--mono);
  color: var(--dim2);
}
a {
  color: var(--teal);
}
/* 3D hero cartogram */
#hero3d {
  position: relative;
  height: min(58vh, 520px);
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--ink2);
}
#hc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hero-seg {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: calc(100% - 130px);
  z-index: 3;
}
.hero-seg button {
  cursor: pointer;
  border: 1px solid var(--line2);
  background: rgba(20, 25, 37, 0.82);
  color: var(--dim);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font: 700 11px var(--sans);
  backdrop-filter: blur(6px);
}
.hero-seg button.on {
  background: var(--teal);
  color: #0b0f17;
  border-color: var(--teal);
}
.hero-modebtn {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 3;
  cursor: pointer;
  border: 1px solid var(--line2);
  background: rgba(20, 25, 37, 0.82);
  color: var(--dim);
  border-radius: var(--radius-md);
  padding: 6px 11px;
  font: 700 11px var(--sans);
  backdrop-filter: blur(6px);
}
.hero-modebtn:hover,
.hero-modebtn:focus-visible {
  color: var(--fog);
  border-color: var(--dim2);
  outline: none;
}
.hero-tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  transform: translate(-50%, -118%);
  background: rgba(20, 25, 37, 0.95);
  border: 1px solid var(--line2);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font: 700 12px var(--sans);
  color: var(--fog);
  white-space: nowrap;
  display: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.hero-tip .v {
  color: var(--gold);
  font-family: var(--mono);
}
.hero-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  background: rgba(20, 25, 37, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font: 600 11px var(--mono);
  color: var(--dim);
  backdrop-filter: blur(6px);
  max-width: 200px;
}
.hero-legend .ramp {
  height: 8px;
  border-radius: 4px;
  margin: 6px 0 4px;
}
.hero-legend .ends {
  display: flex;
  justify-content: space-between;
  color: var(--dim2);
}
.hero-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: var(--ink2);
  color: var(--dim);
  font: 600 13px var(--mono);
}
.hero-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  font: 500 10px var(--mono);
  color: var(--dim2);
  pointer-events: none;
}
@media (max-width: 760px) {
  .hero-seg {
    max-width: calc(100% - 24px);
  }
  .hero-legend {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .wrap *,
  .wrap *::before,
  .wrap *::after {
    transition: none !important;
    animation: none !important;
  }
  .seg i,
  .evbar i {
    transition: none !important;
  }
}
/* ---- phone polish: stack rigid grids + bigger tap targets ---- */
@media (max-width: 560px) {
  .scn-cols {
    grid-template-columns: 1fr;
  }
  .swing-grid {
    grid-template-columns: 1fr;
  }
  .sd-stats {
    grid-template-columns: 1fr 1fr;
  }
}
