* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0b;
  --bg-elevated: #141416;
  --bg-card: #1a1a1d;
  --border: #2a2a2e;
  --border-strong: #3a3a40;
  --text: #e8e8ea;
  --text-dim: #9a9a9f;
  --text-faint: #6a6a70;
  --accent: #d4a574;
  --accent-dim: #8a6a4a;
  --score-low: #6b4f4f;
  --score-mid: #8a7a4a;
  --score-high: #4a7a5a;
}

body {
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 0;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 32px;
}

header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 40px;
  margin-bottom: 48px;
}

h1 {
  font-size: 2.8rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.15rem;
  font-style: italic;
  max-width: 720px;
}

.meta-bar {
  display: flex;
  gap: 32px;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-faint);
  flex-wrap: wrap;
}

.meta-bar span strong { color: var(--text-dim); font-weight: 500; }

h2 {
  font-size: 1.6rem;
  font-weight: 400;
  margin: 56px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

p { margin-bottom: 16px; color: var(--text-dim); }

.intro-prose p {
  font-size: 1.05rem;
  color: var(--text);
}

.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.sort-label {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-right: 4px;
}

button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

button:hover { border-color: var(--border-strong); color: var(--text); }
button.active { background: var(--accent-dim); color: var(--bg); border-color: var(--accent); }

.stories-grid {
  display: grid;
  gap: 16px;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.story-card.featured {
  border-color: rgba(212, 165, 116, 0.4);
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.04), var(--bg-card) 60%);
}

.story-card:hover { border-color: var(--border-strong); }
.story-card.featured:hover { border-color: var(--accent); }

.story-header {
  padding: 20px 24px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 20px;
  align-items: center;
}

.story-num {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.story-card.featured .story-num {
  color: var(--accent);
}

.story-title-line {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.story-title {
  font-size: 1.15rem;
  color: var(--text);
  font-weight: 400;
}

.story-card.featured .story-title {
  color: var(--accent);
}

.story-attribution {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.story-attribution .actual {
  color: var(--accent);
}

.story-attribution .guess-correct {
  color: #4a8a5a;
}

.story-attribution .guess-wrong {
  color: #8a4a4a;
}

.scores {
  display: flex;
  gap: 12px;
  align-items: center;
}

.score-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  min-width: 56px;
}

.score-label {
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-value {
  font-size: 1.1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.score-value.low { color: #b07070; }
.score-value.mid { color: #c4a868; }
.score-value.high { color: #7aa888; }

.expand-icon {
  color: var(--text-faint);
  transition: transform 0.2s ease;
  font-size: 1.2rem;
}

.story-card.expanded .expand-icon {
  transform: rotate(90deg);
}

.story-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.story-card.expanded .story-body {
  max-height: 8000px;
}

.story-content {
  padding: 0 24px 24px 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.story-section {
  margin-bottom: 20px;
}

.story-section:last-child { margin-bottom: 0; }

.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-weight: 500;
}

.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sources-list li {
  color: var(--text-dim);
  font-size: 0.92rem;
  padding-left: 16px;
  position: relative;
}

.sources-list li::before {
  content: "-";
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

.story-text {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 24px;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.75;
  max-height: 600px;
  overflow-y: auto;
}

.story-text-placeholder {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.reasoning {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
}

.reasoning em {
  color: var(--accent);
  font-style: normal;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  color: var(--text);
  font-weight: 300;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-detail {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.pattern-callout {
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.06), rgba(212, 165, 116, 0.02));
  border: 1px solid rgba(212, 165, 116, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 24px 28px;
  margin: 32px 0;
}

.pattern-callout h3 {
  color: var(--accent);
  font-style: italic;
  margin-bottom: 12px;
}

.pattern-callout p {
  color: var(--text);
  margin-bottom: 12px;
}

.pattern-callout p:last-child { margin-bottom: 0; }

footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}

/* --- Thinking-trace tooltip trigger + scrollable hover popover ----------- */

.thinking-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-style: italic;
  cursor: pointer;
  border-radius: 4px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.thinking-trigger:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: rgba(212, 165, 116, 0.05);
}

.thinking-trigger .trigger-icon {
  font-size: 0.9rem;
  font-style: normal;
}

.thinking-meta {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-left: 10px;
  font-style: italic;
}

.tooltip-panel {
  position: absolute;
  z-index: 50;
  width: 540px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow:
    0 4px 12px -4px rgba(0, 0, 0, 0.5),
    0 12px 32px 0 rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.tooltip-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tooltip-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 12px;
}

.tooltip-panel.placement-bottom::before { top: -12px; }
.tooltip-panel.placement-top::before    { bottom: -12px; }

.tt-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.tt-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 500;
}

.tt-sub {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-style: italic;
}

.tt-body {
  max-height: 50vh;
  overflow-y: auto;
  padding: 14px 18px 16px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-dim);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
}

.tt-body::-webkit-scrollbar { width: 8px; }
.tt-body::-webkit-scrollbar-track { background: transparent; }
.tt-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

/* --- Rendered markdown (story text + thinking trace) -------------------- */

.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body p {
  margin: 0 0 1em;
  color: inherit;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--text);
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 1.4em 0 0.5em;
  padding: 0;
  border: none;
  line-height: 1.25;
}

.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.08rem; color: var(--accent); font-style: italic; }
.markdown-body h4 { font-size: 0.98rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

.markdown-body strong { color: var(--text); font-weight: 600; }
.markdown-body em { color: var(--accent); font-style: italic; }

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.markdown-body li {
  margin-bottom: 0.4em;
}

.markdown-body li > p { margin: 0 0 0.4em; }

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.6em 0;
}

.markdown-body blockquote {
  border-left: 2px solid var(--accent-dim);
  margin: 0 0 1em;
  padding: 0.2em 0 0.2em 1em;
  color: var(--text-dim);
  font-style: italic;
}

.markdown-body code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
}

.markdown-body pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 1em;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

.markdown-body a:hover { border-bottom-color: var(--accent); }

/* --- Lede ----------------------------------------------------------------- */

.lede {
  margin: 0 0 28px;
  padding: 0;
}

.lede-line {
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 2rem;
  line-height: 1.2;
  color: var(--text);
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
}

.lede-sub {
  font-size: 1.05rem;
  color: var(--text-dim);
  font-style: italic;
  max-width: 760px;
  margin: 0;
}

.lede-sub em {
  color: var(--accent);
  font-style: italic;
}

/* --- Hero chart wrapper --------------------------------------------------- */

.hero-viz {
  margin: 8px 0 48px;
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.025), transparent 70%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 24px 16px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.8fr);
  gap: 32px;
  align-items: stretch;
}

.hero-chart-col { min-width: 0; display: flex; flex-direction: column; }
.hero-legend-col {
  border-left: 1px solid var(--border);
  padding-left: 24px;
  /* Position context so the inner list can be absolutely sized to
     match the grid-row height (set by the chart column beside it).
     Without this, the list's content forces the grid row taller. */
  position: relative;
  min-height: 0;
}

.hero-legend-col .hl-inner {
  position: absolute;
  inset: 0 0 0 24px;
  display: flex;
  flex-direction: column;
}

.hl-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 14px;
  font-weight: 500;
}

.hl-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  counter-reset: hl;
  overflow-y: auto;
  /* Fill the remainder of the grid row (which the chart column sets via
     its SVG aspect ratio). flex:1 + min-height:0 lets us shrink inside
     a flex column under the eyebrow. */
  flex: 1 1 0;
  min-height: 0;
  scrollbar-gutter: stable;
}

.hl-list::-webkit-scrollbar { width: 8px; }
.hl-list::-webkit-scrollbar-track { background: transparent; }
.hl-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.hl-list::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

.hl-row {
  display: grid;
  grid-template-columns: 12px 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
  border: 1px solid transparent;
}

.hl-row:hover,
.hl-row.is-active {
  background: rgba(212, 165, 116, 0.06);
  border-color: var(--border);
}

.hl-row.featured.is-active,
.hl-row.featured:hover {
  background: rgba(212, 165, 116, 0.12);
  border-color: rgba(212, 165, 116, 0.45);
}

.hl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.hl-dot.dot-low  { background: #b07070; }
.hl-dot.dot-mid  { background: #c4a868; }
.hl-dot.dot-high { background: #7aa888; }
.hl-dot.featured {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.25);
}

.hl-num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.hl-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.hl-name {
  font-size: 0.92rem;
  color: var(--text);
}

.hl-row.featured .hl-name { color: var(--accent); }

.hl-star { color: var(--accent); font-size: 0.78rem; }

.hl-title {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.hl-scores {
  display: flex;
  gap: 6px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
}

.hl-score {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.hl-score.low  { color: #b07070; }
.hl-score.mid  { color: #c4a868; }
.hl-score.high { color: #7aa888; }

/* Chart bubble dim/active states for paired hover */
.chart-cluster.is-active .dot-halo { opacity: 0.4; }
.chart-cluster.is-active .dot-main { stroke: var(--text); stroke-width: 2; }
.chart-cluster.is-dim { opacity: 0.32; }
.chart-cluster.featured.is-dim { opacity: 0.4; }

.chart-host { width: 100%; }
/* Removed the prior max-height clamp - it was cutting the SVG and forcing
   the caption to overlap the bottom labels. The SVG scales naturally by
   its viewBox aspect ratio. */
.chart-svg { width: 100%; height: auto; display: block; }

.chart-legend {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.legend-swatch.dot-low  { background: #b07070; }
.legend-swatch.dot-mid  { background: #c4a868; }
.legend-swatch.dot-high { background: #7aa888; }
.legend-swatch.dot-featured {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.25);
}

.legend-size {
  margin-left: auto;
  gap: 4px;
}

.legend-bubble {
  display: inline-block;
  background: var(--text-faint);
  border-radius: 50%;
  margin-right: 2px;
  opacity: 0.7;
}

.legend-bubble.s1 { width: 6px;  height: 6px; }
.legend-bubble.s2 { width: 10px; height: 10px; }
.legend-bubble.s3 { width: 16px; height: 16px; }

/* --- Chart internals ------------------------------------------------------ */

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.55;
}

.chart-grid-faint {
  opacity: 0.22;
}

.chart-axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart-median {
  stroke: var(--accent-dim);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}

.chart-trend {
  stroke: var(--accent-dim);
  stroke-width: 1;
  stroke-dasharray: 2 5;
  opacity: 0.5;
}

.chart-tick {
  fill: var(--text-faint);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
}

.chart-axis-label {
  fill: var(--text-faint);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.12em;
}

.chart-annotation {
  fill: var(--accent-dim);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 10px;
  font-style: italic;
  letter-spacing: 0.06em;
}

/* Dot variants -- composed of halo + main + label inside <g class="chart-dot ..."> */

.chart-dot { cursor: pointer; }
.chart-dot .dot-main { transition: r 0.18s ease, stroke-width 0.18s ease; }
.chart-dot .dot-halo {
  fill: currentColor;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.chart-dot.dot-low  { color: #b07070; }
.chart-dot.dot-low  .dot-main { fill: #b07070; }
.chart-dot.dot-mid  { color: #c4a868; }
.chart-dot.dot-mid  .dot-main { fill: #c4a868; }
.chart-dot.dot-high { color: #7aa888; }
.chart-dot.dot-high .dot-main { fill: #7aa888; }

.chart-dot.featured { color: var(--accent); }
.chart-dot.featured .dot-main {
  fill: var(--accent);
  stroke: rgba(212, 165, 116, 0.6);
  stroke-width: 2;
}

.chart-dot:hover .dot-halo,
.chart-dot:focus-within .dot-halo { opacity: 0.28; }
.chart-dot:hover .dot-main { stroke: var(--text); stroke-width: 1.5; }
.chart-dot.featured:hover .dot-main { stroke: var(--text); stroke-width: 2.5; }

/* Chart name-labels (used by thinking-length scatter for individual points) */
.chart-name-label {
  fill: var(--text-dim);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 12.5px;
  font-style: italic;
  pointer-events: none;
  transition: fill 0.15s ease;
}

.chart-name-label.featured {
  fill: var(--accent);
  font-weight: 500;
  font-style: normal;
  font-size: 13px;
}

.chart-dot:hover .chart-name-label {
  fill: var(--text);
}

/* Leader line for thinking-length scatter (straight short line) */
.chart-leader {
  stroke: var(--border-strong);
  stroke-width: 0.7;
  opacity: 0.6;
}

/* Transparent hit-target */
.chart-hit {
  fill: transparent;
  cursor: pointer;
}

/* --- Cluster bubbles + side cards --------------------------------------- */

.chart-cluster {
  cursor: pointer;
}

.chart-cluster .dot-main { transition: stroke-width 0.18s ease; }

.chart-cluster.dot-low  { color: #b07070; }
.chart-cluster.dot-low  .dot-main { fill: #b07070; }
.chart-cluster.dot-mid  { color: #c4a868; }
.chart-cluster.dot-mid  .dot-main { fill: #c4a868; }
.chart-cluster.dot-high { color: #7aa888; }
.chart-cluster.dot-high .dot-main { fill: #7aa888; }

.chart-cluster.featured { color: var(--accent); }
.chart-cluster.featured .dot-main {
  fill: var(--accent);
  stroke: rgba(212, 165, 116, 0.55);
  stroke-width: 2;
}

.chart-cluster .dot-halo {
  fill: currentColor;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.chart-cluster:hover .dot-halo { opacity: 0.28; }
.chart-cluster:hover .dot-main { stroke: var(--text); stroke-width: 1.6; }
.chart-cluster.featured:hover .dot-main { stroke: var(--text); stroke-width: 2.4; }

/* Subtle count text inside the bubble */
.cluster-count {
  fill: rgba(20, 20, 22, 0.55);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

/* Curved connector line from bubble to card */
.cluster-leader {
  stroke: var(--border-strong);
  stroke-width: 0.8;
  opacity: 0.55;
  transition: opacity 0.18s ease, stroke 0.18s ease;
}

.cluster-leader.featured {
  stroke: var(--accent-dim);
  opacity: 0.7;
}

/* Floating cluster names (no card background, just text) */
.cluster-name {
  fill: var(--text-dim);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 12.5px;
  font-style: italic;
  pointer-events: none;
  transition: fill 0.15s ease;
}

.cluster-name.featured {
  fill: var(--accent);
  font-style: normal;
  font-weight: 500;
}

.cluster-name-row { cursor: pointer; }
.cluster-name-row:hover .cluster-name { fill: var(--text); }

/* --- Status badges + non-success cards ------------------------------- */

.story-card.status-refused,
.story-card.status-loop_collapse,
.story-card.status-partial {
  background: linear-gradient(180deg, rgba(140, 80, 80, 0.04), var(--bg-card) 60%);
  border-color: rgba(140, 80, 80, 0.25);
}

.story-card.status-loop_collapse {
  background: linear-gradient(180deg, rgba(180, 140, 80, 0.05), var(--bg-card) 60%);
  border-color: rgba(180, 140, 80, 0.28);
}

.story-card.status-partial {
  background: linear-gradient(180deg, rgba(120, 120, 130, 0.04), var(--bg-card) 60%);
  border-color: rgba(120, 120, 130, 0.28);
}

.status-pill {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill-refused {
  background: rgba(140, 70, 70, 0.18);
  color: #c98080;
  border: 1px solid rgba(140, 70, 70, 0.4);
}

.status-pill-loop_collapse {
  background: rgba(180, 140, 70, 0.16);
  color: #d4a574;
  border: 1px solid rgba(180, 140, 70, 0.4);
}

.status-pill-partial {
  background: rgba(120, 120, 130, 0.18);
  color: var(--text-dim);
  border: 1px solid rgba(120, 120, 130, 0.4);
}

.status-callout {
  border-radius: 4px;
  padding: 16px 20px;
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.status-callout-refused { border-left-color: #c98080; }
.status-callout-loop { border-left-color: #d4a574; }
.status-callout-partial { border-left-color: var(--text-dim); }

.status-callout-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 500;
}

.status-callout-body {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.status-callout-foot {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 10px;
  font-style: italic;
}

.story-lab {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

/* --- Compact-table status row + badges ------------------------------- */

.ct-status-badge {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 500;
}
.ct-status-refused {
  background: rgba(140, 70, 70, 0.15);
  color: #c98080;
}
.ct-status-loop_collapse {
  background: rgba(180, 140, 70, 0.15);
  color: #d4a574;
}
.ct-status-partial {
  background: rgba(120, 120, 130, 0.15);
  color: var(--text-dim);
}

.ct-row.ct-row-refused .ct-title,
.ct-row.ct-row-loop_collapse .ct-title,
.ct-row.ct-row-partial .ct-title {
  color: var(--text-dim);
  font-style: italic;
}

.ct-bar-num-empty { color: var(--text-faint) !important; }
.ct-bar-cell-empty { color: var(--text-faint); text-align: center; }

/* --- Name frequency chart -------------------------------------------- */

.chart-host-names { padding: 8px 0; }

.name-legend {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.name-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.name-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.name-legend-swatch.cluster-m { background: var(--accent); }
.name-legend-swatch.cluster-e { background: #c98080; }
.name-legend-swatch.cluster-l { background: #7aa888; }
.name-legend-swatch.cluster-other { background: var(--border-strong); }

.name-legend-detail {
  font-style: italic;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-left: 4px;
}

.name-section {
  margin: 12px 0 56px;
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.025), transparent 60%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
}

.name-intro {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 18px;
  max-width: 880px;
}

.name-intro em {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.name-row { cursor: default; }

.name-label {
  fill: var(--text);
  font-family: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-size: 13px;
}

.name-row.cluster-m .name-label { fill: var(--accent); font-weight: 500; }
.name-row.cluster-e .name-label { fill: #c98080; font-weight: 500; }
.name-row.cluster-l .name-label { fill: #7aa888; font-weight: 500; }

.name-bar {
  fill: var(--text-faint);
  transition: fill 0.15s ease;
}

.name-row.cluster-m .name-bar { fill: var(--accent); }
.name-row.cluster-e .name-bar { fill: #c98080; }
.name-row.cluster-l .name-bar { fill: #7aa888; }
.name-row.cluster-other .name-bar { fill: var(--border-strong); }

.name-row:hover .name-bar { fill: var(--text); }

.name-count {
  fill: var(--text);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
}

.name-uses {
  fill: var(--text-faint);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

/* --- Default-literary section ---------------------------------------- */

.literary-section {
  margin: 16px 0 64px;
  background: linear-gradient(180deg, rgba(120, 140, 170, 0.04), transparent 70%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
}

.literary-intro {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 22px;
  max-width: 880px;
}

.literary-intro em {
  color: var(--accent);
  font-style: italic;
}

/* --- Combine experiment section -------------------------------------- */

.combine-section {
  margin: 16px 0 64px;
  background: linear-gradient(180deg, rgba(122, 168, 136, 0.04), transparent 70%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
}

.combine-intro {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 22px;
  max-width: 900px;
}

.combine-intro em {
  color: var(--accent);
  font-style: italic;
}

.combine-grid {
  display: grid;
  gap: 16px;
}

.combine-card .combine-header {
  grid-template-columns: 44px 1fr auto auto;
}

.combine-num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-align: center;
}

.combine-scores {
  gap: 8px;
}

.axis-pill { min-width: 72px; }
.axis-pill .score-label { font-size: 0.6rem; }
.axis-empty { color: var(--text-faint); font-size: 1rem; }

.combine-outcome {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: baseline;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.combine-outcome-genuine-synthesis {
  color: #7aa888;
  border-color: rgba(122, 168, 136, 0.5);
  background: rgba(122, 168, 136, 0.08);
}

.combine-outcome-selection,
.combine-outcome-selection-with-polish {
  color: #c4a868;
  border-color: rgba(196, 168, 104, 0.4);
  background: rgba(196, 168, 104, 0.06);
}

.combine-outcome-single-input-expansion {
  color: #b07070;
  border-color: rgba(176, 112, 112, 0.4);
  background: rgba(176, 112, 112, 0.06);
}

.combine-inputs {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 4px;
}

.combine-inputs li {
  color: var(--text-dim);
  font-size: 0.92rem;
  padding-left: 18px;
  position: relative;
}

.combine-inputs li::before {
  content: ">";
  position: absolute;
  left: 0;
  color: var(--accent-dim);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.combine-inputs .combine-refusal-line {
  color: var(--text-faint);
  font-style: italic;
  font-size: 0.85rem;
}

.combine-inputs .combine-refusal-line::before { content: ""; }

.combine-card.featured {
  border-color: rgba(122, 168, 136, 0.45);
  background: linear-gradient(180deg, rgba(122, 168, 136, 0.05), var(--bg-card) 60%);
}

.combine-card.featured .combine-num { color: #7aa888; }
.combine-card.featured .story-title { color: #7aa888; }

/* --- Chart info popup (richer hover panel for chart points) ------------ */

.chart-info-panel {
  width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow:
    0 6px 16px -4px rgba(0, 0, 0, 0.55),
    0 16px 36px 0 rgba(0, 0, 0, 0.4);
}

.chart-info-panel .ci-header {
  display: flex;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.chart-info-panel .ci-num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.chart-info-panel .ci-titles { min-width: 0; }

.chart-info-panel .ci-title {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 3px;
}

.chart-info-panel .ci-model {
  font-size: 0.82rem;
  color: var(--accent);
  font-style: italic;
}

.chart-info-panel .ci-body {
  padding: 12px 16px 14px;
}

.chart-info-panel .ci-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-info-panel .ci-stat {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
}

.chart-info-panel .ci-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.chart-info-panel .ci-stat-val {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

.chart-info-panel .ci-stat-val.low  { color: #b07070; }
.chart-info-panel .ci-stat-val.mid  { color: #c4a868; }
.chart-info-panel .ci-stat-val.high { color: #7aa888; }

.chart-info-panel .ci-stat-max {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 1px;
}

.chart-info-panel .ci-guess {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.chart-info-panel .ci-guess .guess-correct { color: #4a8a5a; }
.chart-info-panel .ci-guess .guess-wrong   { color: #8a4a4a; }

.chart-info-panel .ci-notes {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.55;
  font-style: italic;
  border-left: 2px solid var(--accent-dim);
  padding-left: 10px;
  margin-bottom: 10px;
}

.chart-info-panel .ci-cta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-align: right;
}

.chart-info-panel .ci-section-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 6px 0 4px;
  font-weight: 500;
}

.chart-info-panel .ci-premise {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 11px;
}

/* --- Cluster popup (multiple stories at one coordinate) ----------------- */

.cluster-popup {
  width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.cluster-popup .cp-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.cluster-popup .cp-header-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.cluster-popup .cp-header-stats {
  display: flex;
  gap: 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.cluster-popup .cp-stat em {
  font-style: italic;
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-right: 4px;
}

.cluster-popup .cp-stat strong {
  color: var(--text);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 500;
}

.cluster-popup .cp-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 50vh;
  overflow-y: auto;
}

.cluster-popup .cp-row {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}

.cluster-popup .cp-row:last-child { border-bottom: none; }

.cluster-popup .cp-row:hover {
  background: rgba(212, 165, 116, 0.07);
}

.cluster-popup .cp-row.featured {
  background: rgba(212, 165, 116, 0.05);
}

.cluster-popup .cp-row.featured:hover {
  background: rgba(212, 165, 116, 0.13);
}

.cluster-popup .cp-row-main {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 2px;
}

.cluster-popup .cp-num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.cluster-popup .cp-title {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.3;
}

.cluster-popup .cp-row.featured .cp-title { color: var(--accent); }

.cluster-popup .cp-row-sub {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-left: 32px;
}

.cluster-popup .cp-model {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
}

.cluster-popup .cp-guess {
  font-size: 0.85rem;
  font-weight: 500;
}
.cluster-popup .cp-guess.guess-correct { color: #4a8a5a; }
.cluster-popup .cp-guess.guess-wrong   { color: #8a4a4a; }

.cluster-popup .cp-cta {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-align: right;
}

/* --- Charts grid (small charts row) -------------------------------------- */

.charts-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  margin: 40px 0;
}

.chart-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 22px;
}

.chart-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 14px;
  font-weight: 500;
}

.chart-caption {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 10px;
  line-height: 1.5;
}

.summary-grid-compact {
  margin: 0;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-grid-compact .stat-box {
  padding: 14px 16px;
}

.summary-grid-compact .stat-value {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.summary-grid-compact .stat-label { font-size: 0.7rem; }
.summary-grid-compact .stat-detail { font-size: 0.78rem; }

/* --- Compact comparison table -------------------------------------------- */

.compact-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.ct {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ct thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.ct th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  white-space: nowrap;
}

.ct th.ct-bar-head { width: 140px; }
.ct th.ct-think-head { width: 160px; }
.ct th.ct-num { width: 36px; }
.ct th.ct-guess { width: 44px; text-align: center; }

.ct td {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.ct tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.ct tbody tr:hover {
  background: rgba(212, 165, 116, 0.04);
}

.ct-row.is-featured {
  background: linear-gradient(90deg, rgba(212, 165, 116, 0.07), transparent 70%);
}

.ct-row.is-featured:hover {
  background: linear-gradient(90deg, rgba(212, 165, 116, 0.12), rgba(212, 165, 116, 0.02));
}

.ct-num {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
}

.ct-row.is-featured .ct-num { color: var(--accent); }

.ct-title {
  color: var(--text);
  font-size: 0.95rem;
}

.ct-row.is-featured .ct-title { color: var(--accent); }

.ct-star {
  color: var(--accent);
  font-size: 0.75rem;
  margin-left: 4px;
}

.ct-model {
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
}

.ct-bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 14px;
}

.ct-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ct-bar-fill {
  height: 100%;
  border-radius: 1px;
  transition: width 0.25s ease;
}

.ct-bar-fill.low  { background: linear-gradient(90deg, #6b4f4f, #b07070); }
.ct-bar-fill.mid  { background: linear-gradient(90deg, #8a7a4a, #c4a868); }
.ct-bar-fill.high { background: linear-gradient(90deg, #4a7a5a, #7aa888); }

.ct-bar-num {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.82rem;
  min-width: 14px;
  text-align: right;
}

.ct-bar-num.low  { color: #b07070; }
.ct-bar-num.mid  { color: #c4a868; }
.ct-bar-num.high { color: #7aa888; }

.ct-think {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ct-think-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ct-think-fill {
  height: 100%;
  background: var(--accent-dim);
  opacity: 0.7;
}

.ct-think-num {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
  color: var(--text-faint);
  min-width: 48px;
  text-align: right;
}

.ct-guess {
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
}

.ct-guess.guess-correct { color: #4a8a5a; }
.ct-guess.guess-wrong   { color: #8a4a4a; }

@media (max-width: 860px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-info-panel,
  .cluster-popup { width: calc(100vw - 32px); max-width: 420px; }
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .hero-legend-col {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 18px;
  }
  .hero-viz { padding: 16px 12px 12px; }
}

@media (max-width: 720px) {
  .container { padding: 40px 20px; }
  h1 { font-size: 2rem; }
  .lede-line { font-size: 1.4rem; }
  .story-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }
  .story-num { display: none; }
  .scores { grid-column: 1 / -1; justify-content: flex-start; }
  .expand-icon { display: none; }
  .tooltip-panel { width: calc(100vw - 32px); }
  .ct-model, .ct th.ct-think-head, .ct td:nth-child(6) { display: none; }
  .ct th.ct-bar-head { width: auto; }
  .cluster-popup .cp-row-sub { padding-left: 0; }
}
