/* =========================================================== design tokens */
:root {
  --bg:       #f7f8fa;
  --surface:  #ffffff;
  --sunk:     #f1f3f6;
  --ink:      #0c1016;
  --ink-2:    #48515f;
  --ink-3:    #8a93a2;
  --ink-4:    #aeb5c0;
  --hair:     #e2e6ec;
  --hair-2:   #edf0f4;
  --accent:   #0369a1;
  --accent-2: #0ea5e9;
  --up:       #047857;
  --down:     #be123c;
  /* Trend metalanguage. Deliberately distinct from the cyan used for links and
     AI markers, and from the green/red the market rail owns. */
  --breaking: #d97706;
  --rising:   #7c3aed;
  --shadow-lg:0 24px 70px rgba(12,16,22,.22);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --gut: 18px;
}

/* The dark palette lives in a custom property block applied two ways: by the
   media query when the reader has made no choice, and by [data-theme="dark"]
   when they have. The light block is guarded so an explicit light choice wins
   over a dark system setting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #070910;
    --surface:  #0c0f17;
    --sunk:     #0a0d14;
    --ink:      #eef1f6;
    --ink-2:    #a6b0c0;
    --ink-3:    #6e7789;
    --ink-4:    #545d6e;
    --hair:     #1b202b;
    --hair-2:   #141821;
    --accent:   #7dd3fc;
    --accent-2: #38bdf8;
    --up:       #34d399;
    --down:     #fb7185;
    --breaking: #fbbf24;
    --rising:   #a78bfa;
    --shadow-lg:0 28px 80px rgba(0,0,0,.72);
  }
}

:root[data-theme="dark"] {
    --bg:       #070910;
    --surface:  #0c0f17;
    --sunk:     #0a0d14;
    --ink:      #eef1f6;
    --ink-2:    #a6b0c0;
    --ink-3:    #6e7789;
    --ink-4:    #545d6e;
    --hair:     #1b202b;
    --hair-2:   #141821;
    --accent:   #7dd3fc;
    --accent-2: #38bdf8;
    --up:       #34d399;
    --down:     #fb7185;
    --breaking: #fbbf24;
    --rising:   #a78bfa;
    --shadow-lg:0 28px 80px rgba(0,0,0,.72);
}


* { box-sizing: border-box; }

/* Class rules like `.divider { display: flex }` outrank the browser default
   `[hidden] { display: none }`, so hidden blocks render anyway. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-2); color: #04121b; }

/* ================================================================= topbar */
/* Two rows sharing one grid: the mark spans both on the left, controls sit on
   the first, and the tabs get the entire remaining width on the second. The
   old single-row layout ran out of space around eleven tabs. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 7px var(--gut) 0;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(170%) blur(14px);
  backdrop-filter: saturate(170%) blur(14px);
  border-bottom: 1px solid var(--hair);
}

.brand {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  padding-right: 4px;
}
.brand-mark { width: 40px; height: 40px; display: block; }

/* Brand purples are fixed, not theme-derived: a logo that changes hue between
   light and dark stops being a logo. They are also deliberately NOT wired to
   --accent-2 -- the field already spends violet on "accelerating", and a brand
   colour that collides with a state colour would make the page lie. */
.brand-mark .pg-a { stop-color: #5B21B6; }
.brand-mark .pg-b { stop-color: #7C3AED; }
.brand-mark .pg-c { stop-color: #A78BFA; }

.bar-top {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 30px;
}
.bar-spacer { flex: 1 1 auto; }

.brand-name { font-size: 1.02rem; font-weight: 800; letter-spacing: -.005em; }

/* The live pip: the page's only moving element when nothing is happening. */
.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .54rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ink-3);
  flex: 0 0 auto;
}
.live i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--up);
  animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 65%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.live.is-working i { background: var(--accent-2); }

/* Tabs own the whole second row and may wrap onto a second line. */
.sections {
  grid-column: 2;
  min-width: 0;
  padding: 3px 0 5px;
}
.chips { display: flex; flex-wrap: wrap; gap: 3px 4px; }

.chips button {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: .715rem;
  font-weight: 600;
  letter-spacing: .03em;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
}
.chips button:hover { color: var(--ink); background: var(--sunk); }
.chips button[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent-2) 13%, transparent); }

.topbar-meta { display: contents; }
.readout {
  font-size: .64rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge {
  padding: 3px 8px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.badge.is-ai {
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
  color: var(--accent);
}
#refresh {
  display: grid;
  place-items: center;
  width: 26px; height: 24px;
  border: 1px solid var(--hair);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  flex: 0 0 auto;
}
#refresh:hover { color: var(--accent); border-color: var(--accent-2); }
#refresh[disabled] { opacity: .5; cursor: progress; }
#refresh .icon { width: 13px; height: 13px; }
#refresh[disabled] .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================== market rail */
.rail {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 var(--gut);
  height: 34px;
  align-items: stretch;
  background: var(--sunk);
  border-bottom: 1px solid var(--hair);
}
.rail::-webkit-scrollbar { display: none; }

.quote {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px 0 0;
  margin-right: 15px;
  border-right: 1px solid var(--hair);
}
.quote:last-child { border-right: 0; margin-right: 0; }
.quote-label { font-size: .58rem; font-weight: 700; letter-spacing: .1em; color: var(--ink-4); }
.quote-price { font-size: .76rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.quote-chg { font-size: .66rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.quote-chg.up { color: var(--up); }
.quote-chg.down { color: var(--down); }
.quote-chg.flat { color: var(--ink-4); }
.quote.is-stale { opacity: .45; }
.quote svg { display: block; }

/* =================================================================== main */
main { max-width: 1680px; margin: 0 auto; padding: 0 var(--gut) 60px; }

.status {
  padding: 90px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: .82rem;
  letter-spacing: .04em;
}

/* =============================================================== the field */
/* One packed surface on a 16-track grid with a FIXED row height, so every span
   is an exact multiple and dense flow can genuinely backfill. Text is clamped
   per block so nothing overflows its cell. */
.field {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-auto-rows: 54px;
  grid-auto-flow: row dense;
  gap: 9px;
  padding-top: 12px;
}

/* Each story is wrapped in an <a>, which is the actual grid child. Anchors are
   inline by default, which collapses the track and clips headlines. */
.story-link { display: block; min-width: 0; height: 100%; }

.story {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0 0 7px;
  border-bottom: 1px solid var(--hair-2);
}

.story h2, .story h3, .story h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -.015em;
  transition: color .12s;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story:hover h2, .story:hover h3, .story:hover h4 { color: var(--accent); }

.art {
  display: block;
  width: 100%;
  /* Zero basis: text takes what it needs and the art absorbs the remainder.
     With `auto` the image claimed its natural height first and squeezed the
     headline out of the bottom of the block. */
  flex: 1 1 0;
  min-height: 0;
  object-fit: cover;
  background: var(--hair-2);
  border-radius: 3px;
  margin-bottom: 7px;
}

.dek {
  margin: 5px 0 0;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .8rem;
  line-height: 1.4;
}

/* Type scale falls with rank -------------------------------------------- */
.lvl-1 h2 { font-size: clamp(1.7rem, 2.5vw, 2.5rem); line-height: 1.04; letter-spacing: -.026em; }
.lvl-1 .dek { font-size: .92rem; line-height: 1.45; margin-top: 7px; }
.lvl-1 .art { margin-bottom: 11px; }

.lvl-2 h3 { font-size: 1.08rem; line-height: 1.18; }
.lvl-2 .dek { font-size: .81rem; }

.lvl-3 h3 { font-size: .95rem; line-height: 1.2; }
.lvl-4 h4 { font-size: .845rem; line-height: 1.22; font-weight: 600; }
.lvl-5 h4 { font-size: .795rem; line-height: 1.24; font-weight: 600; }
.lvl-6 h4 { font-size: .755rem; line-height: 1.26; font-weight: 500; color: var(--ink-2); }
.lvl-6:hover h4 { color: var(--accent); }

/* Art beside the text in a wide, short block. */
.art-side .story, .story.art-side { flex-direction: row; gap: 9px; align-items: stretch; }
.art-side .art-thumb {
  width: 68px; flex: 0 0 auto; height: 100%;
  margin: 0; align-self: stretch;
}
.art-side .body { min-width: 0; flex: 1; display: flex; flex-direction: column; }

/* meta line ------------------------------------------------------------- */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 5px;
  font-size: .615rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
.lvl-1 .meta, .lvl-2 .meta { font-size: .66rem; padding-top: 7px; }
.meta .sep { color: var(--ink-4); }
.meta .ai {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent); font-weight: 600;
}
.meta .ai::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent-2);
}

/* ============================================================ hover panel */
.panel {
  position: absolute;
  z-index: 60;
  width: min(880px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px) scale(.985);
  transform-origin: top left;
  transition: opacity .16s ease, transform .16s cubic-bezier(.2,.8,.3,1);
}
.panel.is-open { opacity: 1; transform: none; }

.panel-kicker {
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 10px;
}

.panel-main {
  padding: 17px 16px 16px 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.panel-main .panel-kicker { margin-bottom: 0; }

.panel-figure { display: none; }
.panel-figure.has-img { display: block; }
.panel-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 7px;
  background: var(--hair-2);
  display: block;
}

.panel-headline {
  margin: 0;
  font-size: 1.13rem;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.014em;
}

.panel-depths {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--sunk);
  border-radius: 7px;
  align-self: flex-start;
}
.panel-depths button {
  padding: 4px 13px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: .69rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.panel-depths button:hover { color: var(--ink); }
.panel-depths button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.16); }

.panel-summary {
  font-size: .855rem;
  line-height: 1.6;
  color: var(--ink-2);
  min-height: 5.4em;
  white-space: pre-wrap;
}
.panel-summary.is-loading { color: var(--ink-4); }
.panel-note { margin: 0; font-size: .6rem; color: var(--ink-4); line-height: 1.4; }

.panel-side {
  padding: 17px 18px 16px 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--hair);
  background: var(--sunk);
}

.coverage {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column;
  overflow-y: auto;
  /* The rows use a negative margin to bleed their hover state to the edge,
     which otherwise pushes a stray horizontal scrollbar into the panel. */
  overflow-x: hidden;
  max-height: 336px;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}
.coverage li + li { border-top: 1px solid var(--hair-2); }
.coverage li a {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 8px;
  margin: 0 -8px;
  border-radius: 7px;
  transition: background .1s;
}
.coverage li a:hover { background: color-mix(in srgb, var(--accent-2) 10%, transparent); }

.logo {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 5px;
  object-fit: contain;
  background: var(--hair-2);
  margin-top: 1px;
}
.logo-fallback {
  display: grid; place-items: center;
  font-size: .55rem; font-weight: 800; color: #fff;
}
.cov-body { min-width: 0; }
.cov-head { display: flex; align-items: baseline; gap: 6px; }
.cov-src {
  font-size: .61rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.cov-when { font-size: .58rem; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.cov-title { font-size: .775rem; line-height: 1.36; color: var(--ink); margin-top: 1px; }

.panel-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  border-top: 1px solid var(--hair);
  background: var(--surface);
  font-size: .62rem;
  color: var(--ink-3);
  min-width: 0;
}
.panel-stat {
  flex: 0 0 auto;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
}
.panel-why {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
}
.panel-why::before { content: "· "; color: var(--ink-4); }

/* ================================================================== foot */
.foot {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px var(--gut) 44px;
  border-top: 1px solid var(--hair);
  color: var(--ink-4);
  font-size: .69rem;
  line-height: 1.6;
}
.foot p { margin: 0 0 3px; max-width: 86ch; }

/* ============================================================ responsive */
/* Spans are inline styles on a 16-track grid, so narrowing is mostly a matter
   of reducing the track count and letting dense flow repack. */
@media (max-width: 1440px) {
  .field { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .field { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
  .panel { grid-template-columns: 1fr; }
  .panel-side { border-left: 0; border-top: 1px solid var(--hair); }
  .coverage { max-height: 210px; }
}

@media (max-width: 780px) {
  .field { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  :root { --gut: 12px; }
  .topbar { column-gap: 9px; padding: 6px var(--gut) 0; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { font-size: .86rem; letter-spacing: -.005em; }
  .bar-top { height: 26px; gap: 7px; }
  .readout, .badge { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .rail { position: static; }
  /* One column, natural heights: fixed rows are a desktop packing device. */
  .field { grid-template-columns: 1fr; grid-auto-rows: auto; gap: 0; }
  .story-link { grid-column: span 1 !important; grid-row: span 1 !important; }
  .story { padding: 11px 0; height: auto; }
  .story .art { aspect-ratio: 16/9; flex: 0 0 auto; }
  .lvl-1 h2 { font-size: 1.6rem; }
  .foot { padding: 18px var(--gut) 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================== map mode */
.modes {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--sunk);
  border-radius: 7px;
  flex: 0 0 auto;
}
.modes button {
  padding: 4px 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.modes button:hover { color: var(--ink); }
.modes button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.mapview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--gut);
  padding-top: 12px;
  align-items: start;
}

.map-wrap { min-width: 0; }
.map { width: 100%; }

.map-svg {
  width: 100%;
  height: auto;
  display: block;
  background:
    radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--accent-2) 6%, transparent), transparent 70%),
    var(--sunk);
  border: 1px solid var(--hair);
  border-radius: 10px;
}

.graticule line { stroke: var(--ink-3); stroke-width: .4; opacity: .22; }

.land path {
  fill: color-mix(in srgb, var(--ink-3) 40%, transparent);
  stroke: color-mix(in srgb, var(--ink-2) 55%, transparent);
  stroke-width: .6;
  vector-effect: non-scaling-stroke;   /* keeps borders hairline at any scale */
}

/* --- pins --------------------------------------------------------------- */
.pin { cursor: pointer; }
.pin-dot {
  fill: var(--accent-2);
  stroke: var(--surface);
  stroke-width: .8;
  transition: r .14s ease;
}
.pin-halo { fill: var(--accent-2); opacity: .13; pointer-events: none; }
.pin-tether { stroke: var(--ink-3); stroke-width: .5; opacity: .45; }

/* Same trend language as the field: colour means change, nothing else. */
.pin[data-trend="breaking"] .pin-dot  { fill: var(--breaking); }
.pin[data-trend="breaking"] .pin-halo { fill: var(--breaking); opacity: .22; animation: ping 2.8s ease-out infinite; }
.pin[data-trend="rising"] .pin-dot    { fill: var(--rising); }
.pin[data-trend="rising"] .pin-halo   { fill: var(--rising); opacity: .2; }
.pin[data-cooling] .pin-dot  { fill: var(--ink-3); opacity: .55; }
.pin[data-cooling] .pin-halo { opacity: .05; }

@keyframes ping {
  0%   { transform: scale(.6); opacity: .34; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

.pin:hover .pin-dot { stroke: var(--accent); stroke-width: 1.4; }
.pin:hover .pin-halo { opacity: .3; }

.map-legend {
  margin: 9px 2px 0;
  font-size: .66rem;
  line-height: 1.5;
  color: var(--ink-4);
  max-width: 78ch;
}

/* --- the tray ----------------------------------------------------------- */
.tray {
  min-width: 0;
  border-left: 1px solid var(--hair);
  padding-left: var(--gut);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.tray-head {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.tray-list { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; }
.tray-row { display: block; }
.tray-row article {
  position: relative;
  padding: 8px 0;
  border-bottom: 1px solid var(--hair-2);
}
.tray-row h4 {
  margin: 0;
  font-size: .78rem;
  line-height: 1.28;
  font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  transition: color .12s;
}
.tray-row:hover h4 { color: var(--accent); }
.tray-row .meta { margin-top: 4px; padding-top: 0; font-size: .59rem; }

@media (max-width: 980px) {
  .mapview { grid-template-columns: 1fr; }
  .tray {
    border-left: 0;
    border-top: 1px solid var(--hair);
    padding-left: 0;
    padding-top: 14px;
    max-height: none;
  }
  .tray-list { max-height: 340px; }
}

@media (max-width: 560px) {
  .modes button { padding: 4px 9px; font-size: .66rem; }
  .map-legend { font-size: .62rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pin[data-trend="breaking"] .pin-halo { animation: none; }
}

/* ==================================================== the attention band */
.band {
  display: flex;
  gap: 2px;
  padding: 0 var(--gut);
  height: 30px;
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
}

.seg {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 0;
  border-top: 2px solid var(--hair);
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background .14s, color .14s, border-color .14s;
}
.seg:hover { background: var(--sunk); color: var(--ink); }
.seg[aria-pressed="true"] { background: var(--sunk); color: var(--accent); border-top-color: var(--accent-2); }

.seg-name {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg-meta { font-size: .58rem; font-variant-numeric: tabular-nums; color: var(--ink-4); flex: 0 0 auto; }

/* Activity, as a weight on the top rule. Colour stays reserved for change. */
.seg.level-elevated { border-top-color: color-mix(in srgb, var(--rising) 60%, transparent); }
.seg.level-elevated .seg-meta { color: var(--rising); }
.seg.level-high { border-top-color: var(--breaking); }
.seg.level-high .seg-name { color: var(--ink); }
.seg.level-high .seg-meta { color: var(--breaking); font-weight: 700; }
.seg.level-gathering { border-top-style: dotted; }

/* ================================================== living state marks */
.mark-breaking     { color: var(--breaking); }
.mark-accelerating { color: var(--rising); }
.mark-developing   { color: var(--accent); }
.mark-fading       { color: var(--ink-4); }

/* ========================================================== the portal */
.panel.is-portal { width: min(1120px, calc(100vw - 28px)); grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
.panel.is-portal .panel-extra { display: block; }

.panel-extra {
  grid-column: 1 / -1;
  display: none;
  border-top: 1px solid var(--hair);
  background: var(--panel-2, var(--sunk));
  padding: 4px 18px 12px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}

.pl-section { padding: 12px 0; border-bottom: 1px solid var(--hair-2); }
.pl-section:last-child { border-bottom: 0; }

.pl-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; }
.pl-title {
  font-size: .56rem; font-weight: 700; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-4);
}
.pl-aside { font-size: .58rem; color: var(--ink-4); }

/* --- what's new --------------------------------------------------------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl-row { display: flex; gap: 12px; padding: 4px 0; position: relative; }
.tl-row::before {
  content: ""; position: absolute; left: 53px; top: 0; bottom: 0;
  width: 1px; background: var(--hair);
}
.tl-row:first-child::before { top: 50%; }
.tl-row:last-child::before { bottom: 50%; }

.tl-when { flex: 0 0 46px; text-align: right; font-variant-numeric: tabular-nums; }
.tl-day { display: block; font-size: .52rem; font-weight: 700; letter-spacing: .1em; color: var(--ink-4); }
.tl-time { font-size: .63rem; color: var(--ink-3); }

.tl-what { flex: 1; min-width: 0; padding-left: 14px; position: relative; }
.tl-what::before {
  content: ""; position: absolute; left: -4px; top: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 3px var(--panel-2, var(--sunk));
}
.tl-src {
  display: block; font-size: .55rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4);
}
.tl-title { font-size: .75rem; line-height: 1.34; color: var(--ink-2); }

/* --- written sections --------------------------------------------------- */
.aspect { font-size: .77rem; line-height: 1.55; color: var(--ink-2); }
.aspect-absent { margin: 0; color: var(--ink-4); font-size: .72rem; }
.aspect-note { margin: 0 0 7px; color: var(--ink-2); }

.diff-row { display: flex; gap: 9px; padding: 3px 0; align-items: baseline; }
.diff-src {
  flex: 0 0 84px; font-size: .58rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.diff-emph { flex: 1; min-width: 0; font-size: .75rem; line-height: 1.4; }

.sig-head { margin: 0 0 6px; font-weight: 600; color: var(--ink); font-size: .82rem; }
.sig { margin: 0; padding-left: 15px; }
.sig li { margin: 3px 0; font-size: .75rem; line-height: 1.45; }

/* --- related ------------------------------------------------------------ */
.rel { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rel a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 8px; margin: 0 -8px; border-radius: 6px;
  transition: background .12s;
}
.rel a:hover { background: color-mix(in srgb, var(--accent-2) 10%, transparent); }
.rel-title { font-size: .76rem; line-height: 1.32; }
.rel-why {
  font-size: .56rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent);
}

@media (max-width: 1100px) {
  .panel.is-portal { grid-template-columns: 1fr; }
  .panel-extra { max-height: 240px; }
}
@media (max-width: 560px) {
  .band { height: 26px; padding: 0 8px; }
  .seg { padding: 0 6px; }
  .seg-name { font-size: .54rem; letter-spacing: .07em; }
}

/* ======================================================= You & topic tabs */
.chips button.chip-you {
  position: relative;
  font-weight: 700;
  color: var(--accent);
}
.chips button.chip-you::after {
  content: "";
  position: absolute; right: 3px; top: 5px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent-2);
  opacity: 0;
}
/* A quiet dot until the reader has told PolyGrid anything. */
.chips button.chip-you.is-fresh::after { opacity: .85; }
.chips button.chip-you[aria-pressed="true"] { background: var(--accent-2); color: #04121b; }
.chips button.chip-you[aria-pressed="true"]::after { display: none; }

/* Dynamic subject tabs sit apart from the permanent sections. */
.chips button.chip-topic {
  margin-left: 2px;
  color: var(--breaking);
  border: 1px dashed color-mix(in srgb, var(--breaking) 45%, transparent);
}
.chips button.chip-topic::before { content: "\201A"; visibility: hidden; width: 0; }
.chips button.chip-topic:hover { border-style: solid; }
.chips button.chip-topic[aria-pressed="true"] {
  background: color-mix(in srgb, var(--breaking) 20%, transparent);
  border-style: solid;
  color: var(--breaking);
}

/* ========================================================= interest picker */
.tune {
  margin: 12px 0 4px;
  padding: 14px 16px;
  background: var(--sunk);
  border: 1px solid var(--hair);
  border-radius: 10px;
}
.tune-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 11px;
}
.tune-reset {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .62rem; letter-spacing: .06em;
  color: var(--ink-4); text-transform: uppercase;
}
.tune-reset:hover { color: var(--down); }

.tune-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tune-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit; font-size: .76rem; font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.tune-chip:hover { border-color: var(--accent-2); color: var(--ink); }
.tune-chip.on {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 15%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.tune-emoji { font-size: .95rem; line-height: 1; }

.tune-note {
  margin: 11px 0 0;
  font-size: .66rem; line-height: 1.5; color: var(--ink-4);
  max-width: 80ch;
}

/* ====================================================== more / less voting */
.panel-tune {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto; flex: 0 0 auto;
}
.tune-ask {
  font-size: .56rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-4);
}
.tune-vote {
  padding: 3px 9px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: transparent;
  color: var(--ink-3);
  font: inherit; font-size: .62rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.vote-more:hover { border-color: var(--up); color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.vote-less:hover { border-color: var(--down); color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.tune-said { font-size: .62rem; font-weight: 600; color: var(--accent); }
.tune-why {
  font-size: .6rem; color: var(--ink-4);
  max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 560px) {
  .tune { padding: 11px 12px; }
  .tune-chip { font-size: .72rem; padding: 5px 10px 5px 8px; }
  .panel-tune { margin-left: 0; width: 100%; padding-top: 6px; }
  .tune-why { display: none; }
}


/* ============================================================== appearance */
.theme {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--sunk);
  border-radius: 7px;
}
.theme button {
  display: grid; place-items: center;
  width: 24px; height: 22px;
  border: 0; border-radius: 5px;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.theme button svg { width: 13px; height: 13px; fill: currentColor; }
.theme button:hover { color: var(--ink-2); }
.theme button.on { background: var(--surface); color: var(--accent); }

/* ======================================================== section identity */
.chip-emoji { font-size: .78rem; line-height: 1; margin-right: 1px; }
.chips button { display: inline-flex; align-items: center; gap: 4px; }

/* A single tinted underline per section. Enough to tell them apart, far short
   of painting every tab a different colour. */
.chips button[class*="chip-"]:not(.chip-you):not(.chip-topic):not(.chip-cross) {
  border-bottom: 2px solid transparent;
  border-radius: 5px 5px 3px 3px;
}
.chip-us[aria-pressed="false"]       { border-bottom-color: color-mix(in srgb, #60a5fa 55%, transparent); }
.chip-world[aria-pressed="false"]    { border-bottom-color: color-mix(in srgb, #34d399 55%, transparent); }
.chip-politics[aria-pressed="false"] { border-bottom-color: color-mix(in srgb, #f472b6 55%, transparent); }
.chip-business[aria-pressed="false"] { border-bottom-color: color-mix(in srgb, #fbbf24 55%, transparent); }
.chip-tech[aria-pressed="false"]     { border-bottom-color: color-mix(in srgb, #a78bfa 55%, transparent); }
.chip-sports[aria-pressed="false"]   { border-bottom-color: color-mix(in srgb, #fb923c 55%, transparent); }
.chip-culture[aria-pressed="false"]  { border-bottom-color: color-mix(in srgb, #22d3ee 55%, transparent); }

.chip-cross {
  border: 1px solid color-mix(in srgb, var(--up) 40%, transparent);
  color: var(--ink-2);
}
.chip-cross:hover { border-color: var(--up); }
.chip-cross[aria-pressed="true"] {
  background: color-mix(in srgb, var(--up) 20%, transparent);
  border-color: var(--up);
  color: var(--up);
}

/* ========================================================== more stories */
.more-wrap { display: flex; justify-content: center; padding: 22px 0 6px; }
.more-stories {
  padding: 9px 26px;
  border: 1px solid var(--hair);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit; font-size: .78rem; font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: border-color .14s, color .14s, background .14s;
}
.more-stories:hover {
  border-color: var(--accent-2);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
}

/* An image that has not painted should not read as a black hole. */
.art {
  background:
    repeating-linear-gradient(
      135deg,
      color-mix(in srgb, var(--ink-3) 9%, transparent) 0 6px,
      transparent 6px 12px
    ),
    var(--hair-2);
}

/* Only headlines open the portal, so only headlines should look interactive. */
.story h2, .story h3, .story h4, .tray-row h4 { cursor: pointer; }

/* ============================================================== threads */
/* Stories belonging to one of the dynamic topics carry a corner bracket in
   that thread's colour. A bracket, not a border, so it cannot be confused with
   the trend marks; and only ~1 story in 10 has one.
   Hovering any member lights the rest — that is the point of the marker. */
:root {
  --thread-0: #e11d48;
  --thread-1: #0d9488;
  --thread-2: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --thread-0: #fb7185;
    --thread-1: #2dd4bf;
    --thread-2: #fdba74;
  }
}
:root[data-theme="dark"] {
  --thread-0: #fb7185;
  --thread-1: #2dd4bf;
  --thread-2: #fdba74;
}

.story[data-thread]::after {
  content: "";
  position: absolute;
  left: -5px;
  top: -3px;
  width: 22px;
  height: 22px;
  border-left: 2px solid var(--thread);
  border-top: 2px solid var(--thread);
  border-radius: 4px 0 0 0;
  opacity: .62;
  transition: opacity .16s ease, width .16s ease, height .16s ease;
  pointer-events: none;
}
.story[data-thread="0"] { --thread: var(--thread-0); }
.story[data-thread="1"] { --thread: var(--thread-1); }
.story[data-thread="2"] { --thread: var(--thread-2); }

/* Everything in the same thread responds together. */
.thread-lit::after { opacity: 1; width: 38px; height: 38px; }
.thread-lit { background: color-mix(in srgb, var(--thread) 10%, transparent); }

/* The rest of the page steps back so the thread reads as a set. */
body.threading .story:not(.thread-lit) { opacity: .42; }
.story { transition: opacity .16s ease, background .16s ease; }

@media (prefers-reduced-motion: reduce) {
  .story[data-thread]::after, .story { transition: none; }
}
