/**
 * Analysis Report Design System — theme.css
 * Neutral surfaces for documents; vibrant tokens for charts, tags, and indicators.
 */

/* -------------------------------------------------------------------------- */
/* Typography — load in HTML:                                               */
/* family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600 */
/* -------------------------------------------------------------------------- */

:root {
  /* —— Neutral UI —— */
  --page-bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f6f6f6;
  --text: #2d2d2d;
  --text-muted: #6b6b6b;
  --text-faint: #9a9790;
  --border: #e2e0dc;
  --border-light: #eeedeb;
  --shadow-card: 0 2px 10px rgba(45, 45, 45, 0.06);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;

  /* —— Fonts —— */
  --font-copy: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-numeric: "IBM Plex Mono", ui-monospace, "Cascadia Code", monospace;

  /* —— Chart colors (ordered cool → warm; same hexes, new indices) —— */
  --chart-1: #7eb8d9;
  --chart-1-soft: rgba(126, 184, 217, 0.22);
  --chart-2: #4fb8a8;
  --chart-2-soft: rgba(79, 184, 168, 0.22);
  --chart-3: #8b7fd8;
  --chart-3-soft: rgba(139, 127, 216, 0.22);
  --chart-4: #b87fb5;
  --chart-4-soft: rgba(184, 127, 181, 0.22);
  --chart-5: #9bbf8e;
  --chart-5-soft: rgba(155, 191, 142, 0.22);
  --chart-6: #f6d862;
  --chart-6-soft: rgba(246, 216, 98, 0.22);
  --chart-7: #e4a554;
  --chart-7-soft: rgba(228, 165, 84, 0.22);
  --chart-8: #e8927a;
  --chart-8-soft: rgba(232, 146, 122, 0.22);

  --positive: #3d9a85;
  --positive-soft: rgba(61, 154, 133, 0.18);
  --negative: #d9665c;
  --negative-soft: rgba(217, 102, 92, 0.18);
  --neutral-indicator: #8a8680;

  /* Chart axes / splits (slightly stronger than page grid) */
  --grid-line: rgba(45, 45, 45, 0.06);
  /* Page background grid — matches transcript-lab subtle 48px lines on white */
  --page-grid-line: rgba(0, 0, 0, 0.03);
  --axis-text: var(--text-muted);

  /* Aliases for tags / pills (hue names → slots in cool→warm order) */
  --tag-violet: var(--chart-3);
  --tag-violet-bg: var(--chart-3-soft);
  --tag-teal: var(--chart-2);
  --tag-teal-bg: var(--chart-2-soft);
  --tag-coral: var(--chart-8);
  --tag-coral-bg: var(--chart-8-soft);

  --link-text: color-mix(in srgb, var(--chart-2) 38%, var(--text));
  --link-hover: color-mix(in srgb, var(--chart-2) 22%, var(--text));
  --link-underline: color-mix(in srgb, var(--chart-2) 38%, transparent);
  --link-underline-hover: var(--chart-2);
  --focus-ring: var(--chart-2);

  /* —— Layout & spacing (report column, sections, surfaces) —— */
  --ds-content-max: 880px;
  --ds-page-padding-x: 32px;
  --ds-page-padding-y: 48px;
  --ds-page-padding-y-mobile: 28px;
  --ds-space-section-gap: 48px;
  --ds-space-component-gap: 24px;
  --ds-inset-surface-x: 18px;
  --ds-inset-surface-y: 16px;
  --ds-inset-surface-y-tight: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

body.ds-theme,
.ds-theme {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-copy);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Inline links — teal semantic accent; exclude chrome controls */
.ds-page a:not(.ds-nav-rail__link):not(.ds-tabs__btn) {
  color: var(--link-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--link-underline);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.ds-page a:not(.ds-nav-rail__link):not(.ds-tabs__btn):hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-underline-hover);
}

.ds-page a:not(.ds-nav-rail__link):not(.ds-tabs__btn):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Numbered lists — always 1) 2) … */
.ds-list-num {
  list-style: none;
  counter-reset: ds-num;
  padding: 0;
  margin: 0;
}

.ds-list-num > li {
  counter-increment: ds-num;
  position: relative;
  padding-left: 2.25em;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.ds-list-num > li:last-child {
  margin-bottom: 0;
}

.ds-list-num > li::before {
  content: counter(ds-num) ") ";
  position: absolute;
  left: 0;
  font-family: var(--font-numeric);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}

.ds-list-num strong {
  color: var(--text);
}

/* Subtle line grid on page (same technique as transcript-lab/styles.css) */
body.ds-theme::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--page-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--page-grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

body.ds-theme {
  overflow-x: hidden;
}

.ds-font-numeric {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------- */
/* Layout                                                                      */
/* -------------------------------------------------------------------------- */

/* Outer layout: leaves room for fixed section rail on wide viewports */
.ds-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding-left: 0;
  padding-right: 0;
}

@media (min-width: 1100px) {
  .ds-layout {
    padding-left: 52px;
  }
}

.ds-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--ds-content-max);
  margin: 0 auto;
  padding: var(--ds-page-padding-y) var(--ds-page-padding-x) 72px;
}

@media (max-width: 768px) {
  .ds-page {
    padding: var(--ds-page-padding-y-mobile) 20px 56px;
  }
}

/* Consistent vertical rhythm: uniform gaps inside sections; section gap controls page rhythm */
.ds-showcase-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--ds-space-component-gap);
  width: 100%;
  min-width: 0;
  margin-bottom: var(--ds-space-section-gap);
}

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

.ds-showcase-section > .ds-part-header:first-child {
  margin-top: 0;
}

/* Section titles / figures align to the content column; surfaces span full column width */
.ds-showcase-section > .ds-section-title,
.ds-showcase-section > .ds-part-header {
  flex-shrink: 0;
}

.ds-showcase-section figure {
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  min-width: 0;
}

.ds-showcase-section > .ds-chart,
.ds-showcase-section > .ds-table-wrap,
.ds-showcase-section > .ds-tabs,
.ds-showcase-section > .ds-metric-grid,
.ds-showcase-section > .ds-insights-grid,
.ds-showcase-section > .ds-exec-summary,
.ds-showcase-section > .ds-stack {
  width: 100%;
  min-width: 0;
}

[id^="sec-"] {
  scroll-margin-top: 96px;
}

/* Left rail: dots always visible; section titles appear when hovering the rail */
.ds-nav-rail {
  display: none;
}

@media (min-width: 1100px) {
  .ds-nav-rail {
    display: block;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    padding: 14px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    box-shadow: var(--shadow-card);
    max-height: min(82vh, 640px);
    overflow-x: visible;
    overflow-y: auto;
  }
}

.ds-nav-rail__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ds-nav-rail__link {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s ease, gap 0.2s ease;
}

.ds-nav-rail__link:hover,
.ds-nav-rail__link:focus-visible {
  background: var(--surface-subtle);
  outline: none;
}

.ds-nav-rail__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-light);
  transition: background 0.15s ease, transform 0.15s ease;
}

.ds-nav-rail__link:hover .ds-nav-rail__dot,
.ds-nav-rail__link:focus-visible .ds-nav-rail__dot {
  background: var(--chart-2);
  transform: scale(1.15);
}

.ds-nav-rail__label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-muted);
  transition: opacity 0.2s ease, max-width 0.22s ease, margin 0.2s ease;
}

.ds-nav-rail:hover .ds-nav-rail__label,
.ds-nav-rail:focus-within .ds-nav-rail__label {
  opacity: 1;
  max-width: 200px;
  margin-left: 8px;
}

.ds-nav-rail:hover .ds-nav-rail__link,
.ds-nav-rail:focus-within .ds-nav-rail__link {
  gap: 4px;
}

.ds-nav-rail__link.is-active .ds-nav-rail__dot {
  background: var(--chart-2);
  box-shadow: 0 0 0 1px var(--chart-2-soft);
}

.ds-nav-rail__link.is-active .ds-nav-rail__label {
  color: var(--text);
  font-weight: 600;
}

/* Figure legend key (color ↔ meaning ↔ value) */
.ds-figure-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* Section-level legend under a table: vertical rhythm comes from .ds-showcase-section gap */
.ds-showcase-section > .ds-figure-meta {
  margin-top: 0;
}

.ds-figure-meta__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.ds-legend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ds-legend-table th,
.ds-legend-table td {
  padding: 6px 10px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.ds-legend-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ds-legend-table td.ds-lt-num {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

.ds-legend-table tr:last-child th,
.ds-legend-table tr:last-child td {
  border-bottom: none;
}

.ds-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
}

/* Prose & executive summary */
.ds-prose {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.ds-prose p {
  margin: 0 0 12px;
  max-width: 62ch;
}

.ds-prose p:last-child {
  margin-bottom: 0;
}

.ds-exec-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}

.ds-exec-summary__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.ds-exec-summary__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--text);
}

.ds-exec-summary .ds-list-num {
  font-size: 14px;
  line-height: 1.55;
}

.ds-exec-summary strong {
  color: var(--text);
  font-weight: 600;
}

/* Key insights (dashboard-style cards) */
.ds-insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 960px) {
  .ds-insights-grid {
    grid-template-columns: 1fr;
  }
}

.ds-insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.ds-insight-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.ds-insight-card__name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
  color: var(--text);
}

.ds-insight-card__area {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.ds-insight-card__stats {
  display: flex;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.ds-insight-card__stat {
  flex: 1;
  min-width: 0;
}

.ds-insight-card__stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.ds-insight-card__stat-val {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  color: var(--text);
}

.ds-insight-card__body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.ds-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ds-stack-lg {
  gap: 2rem;
}

.ds-stack--dense {
  gap: 14px;
}

.ds-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.ds-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .ds-grid-3 {
    grid-template-columns: 1fr;
  }
  .ds-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------------------- */
/* Report header & footer                                                      */
/* -------------------------------------------------------------------------- */

.ds-report-header {
  margin-bottom: 40px;
}

.ds-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.ds-report-title {
  font-size: clamp(1.75rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--text);
}

.ds-report-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 52ch;
  margin: 0;
}

.ds-report-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

/* Nested chrome demo inside a bordered surface — avoid double outer margins */
.ds-report-header.ds-chart {
  margin-bottom: 0;
}

.ds-report-footer.ds-chart {
  margin-top: 0;
}

/* -------------------------------------------------------------------------- */
/* Section titles & dividers                                                   */
/* -------------------------------------------------------------------------- */

.ds-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.ds-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.ds-section-title__num {
  font-family: var(--font-numeric);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}

.ds-divider {
  height: 1px;
  background: var(--border-light);
  margin: 28px 0;
  border: 0;
}

.ds-divider-strong {
  height: 0;
  margin: 40px 0 28px;
  padding-bottom: 12px;
  border: none;
  border-bottom: 2px solid var(--text);
}

.ds-part-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0;
}

.ds-part-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.ds-part-header .ds-note {
  font-size: 12px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------- */
/* Metric tiles                                                                */
/* -------------------------------------------------------------------------- */

.ds-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.ds-metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ds-metric-tile {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.ds-metric-tile__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.ds-metric-tile__value {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 26px;
  line-height: 1.1;
  color: var(--text);
}

.ds-metric-tile__value .ds-unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

.ds-metric-tile__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.ds-metric-tile--accent {
  border-color: var(--chart-1-soft);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-subtle) 100%);
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                      */
/* -------------------------------------------------------------------------- */

.ds-table-wrap {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ds-table caption {
  caption-side: top;
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.ds-table thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ds-table thead th.ds-th-num {
  text-align: right;
  font-family: var(--font-numeric);
}

.ds-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.ds-table tbody td.ds-td-num {
  text-align: right;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.ds-table tbody tr:hover td {
  background: var(--surface-subtle);
}

.ds-table tbody tr:last-child td {
  border-bottom: none;
}

.ds-table .ds-row-highlight td {
  background: var(--surface-subtle);
  font-weight: 600;
}

/* -------------------------------------------------------------------------- */
/* Progress                                                                    */
/* -------------------------------------------------------------------------- */

.ds-progress {
  width: 100%;
}

.ds-progress__track {
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--border-light);
  overflow: hidden;
}

.ds-progress__fill {
  height: 100%;
  border-radius: var(--radius-sm);
  background: var(--text);
  transition: width 0.5s ease;
}

.ds-progress__meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.ds-progress--thin .ds-progress__track {
  height: 5px;
}

/* Color variants */
.ds-progress__fill--1 {
  background: var(--chart-1);
}
.ds-progress__fill--2 {
  background: var(--chart-2);
}
.ds-progress__fill--3 {
  background: var(--chart-3);
}

/* -------------------------------------------------------------------------- */
/* Charts — use CSS variables on SVG fills / strokes                           */
/* -------------------------------------------------------------------------- */

.ds-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--ds-inset-surface-y) var(--ds-inset-surface-x) var(--ds-inset-surface-y-tight);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ds-chart__title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}

/* Apache ECharts mount nodes — explicit height required for canvas */
.ds-echarts {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 260px;
  min-height: 200px;
}

.ds-echarts--tall {
  height: 300px;
}

/* Default: single column uses full content width; use --pie-contained for a centered cap */
.ds-echarts--pie {
  height: 340px;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.ds-echarts--pie-contained {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Full-width pie/donut (alias — same as default single-column behavior) */
.ds-echarts--pie-full {
  max-width: 100%;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* Square canvas so Venn circles stay round (uniform scale) */
.ds-echarts--venn {
  width: min(100%, 360px);
  height: 360px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  overflow: visible;
}

.ds-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.ds-chart-svg text {
  font-family: var(--font-numeric);
  font-size: 10px;
  fill: var(--axis-text);
}

.ds-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
}

.ds-chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.ds-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ds-swatch--1 {
  background: var(--chart-1);
}
.ds-swatch--2 {
  background: var(--chart-2);
}
.ds-swatch--3 {
  background: var(--chart-3);
}
.ds-swatch--4 {
  background: var(--chart-4);
}
.ds-swatch--5 {
  background: var(--chart-5);
}
.ds-swatch--6 {
  background: var(--chart-6);
}
.ds-swatch--7 {
  background: var(--chart-7);
}
.ds-swatch--8 {
  background: var(--chart-8);
}

/* Histogram = bar chart styling; stacked uses stacked rects */

/* -------------------------------------------------------------------------- */
/* Tags & pills                                                                */
/* -------------------------------------------------------------------------- */

.ds-tag {
  display: inline-block;
  font-family: var(--font-numeric);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--border-light);
  color: var(--text-muted);
}

.ds-tag--neutral {
  background: var(--border-light);
  color: var(--text-muted);
}

/* Tag text colors align with chart 1→8 (cool → warm) */
.ds-tag--1 {
  background: var(--chart-1-soft);
  color: #3d6a8e;
}
.ds-tag--2 {
  background: var(--chart-2-soft);
  color: #2a7d70;
}
.ds-tag--3 {
  background: var(--chart-3-soft);
  color: #5e52a3;
}
.ds-tag--4 {
  background: var(--chart-4-soft);
  color: #7a4d77;
}
.ds-tag--5 {
  background: var(--chart-5-soft);
  color: #4d6b42;
}
.ds-tag--6 {
  background: var(--chart-6-soft);
  color: #8a7a18;
}
.ds-tag--7 {
  background: var(--chart-7-soft);
  color: #9a6f28;
}
.ds-tag--8 {
  background: var(--chart-8-soft);
  color: #b85a42;
}
.ds-tag--pos {
  background: var(--positive-soft);
  color: var(--positive);
}
.ds-tag--neg {
  background: var(--negative-soft);
  color: var(--negative);
}

.ds-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.ds-pill--soft {
  border-color: transparent;
  background: var(--surface-subtle);
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------- */
/* Tooltip                                                                     */
/* -------------------------------------------------------------------------- */

.ds-tip {
  position: relative;
  display: inline-block;
  cursor: help;
  border-bottom: 1px dotted var(--border);
  color: inherit;
}

.ds-tip__bubble {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  max-width: 280px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: #1e1e1e;
  color: #fafaf8;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  font-family: var(--font-copy);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.ds-tip__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 14px;
  border: 6px solid transparent;
  border-top-color: #1e1e1e;
}

.ds-tip:hover .ds-tip__bubble,
.ds-tip:focus-within .ds-tip__bubble {
  visibility: visible;
  opacity: 1;
}

/* Click-to-toggle detail (no hover reveal) */
.ds-tip--click {
  cursor: pointer;
  border-bottom-style: solid;
  border-bottom-color: var(--chart-2);
}

.ds-tip--click:hover .ds-tip__bubble,
.ds-tip--click:focus:not(.is-open) .ds-tip__bubble {
  visibility: hidden;
  opacity: 0;
}

.ds-tip--click.is-open .ds-tip__bubble {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* -------------------------------------------------------------------------- */
/* Tabs                                                                        */
/* -------------------------------------------------------------------------- */

.ds-tabs {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.ds-tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.ds-tabs__tab {
  flex: 1;
  min-width: 0;
}

.ds-tabs__btn {
  width: 100%;
  margin: 0;
  padding: 11px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-copy);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.ds-tabs__btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.ds-tabs__btn[aria-selected="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--text);
}

.ds-tabs__panel {
  padding: var(--ds-inset-surface-y) var(--ds-inset-surface-x);
  display: none;
}

.ds-tabs__panel--active {
  display: block;
}

.ds-tabs__panel .ds-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ds-tabs__panel p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.ds-tabs__panel p:last-child {
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------- */
/* Venn / diagram note                                                         */
/* -------------------------------------------------------------------------- */

.ds-diagram-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.ds-chart > .ds-diagram-note:first-child {
  margin-bottom: 10px;
}

.ds-chart > .ds-diagram-note:not(:first-child) {
  margin-top: 10px;
}

/* Lead line under a section title (replaces ad hoc negative margins) */
.ds-section-lead {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 62ch;
}

/* -------------------------------------------------------------------------- */
/* Report pages — prompt analysis strip & warnings                             */
/* -------------------------------------------------------------------------- */

.ds-stat-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ds-stat-rail__cell {
  padding: 20px 14px;
  text-align: center;
  color: #fff;
}

.ds-stat-rail__val {
  font-family: var(--font-numeric);
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.ds-stat-rail__lbl {
  font-size: 13px;
  margin-top: 6px;
  opacity: 0.92;
}

.ds-stat-rail__cell--a {
  background: var(--text);
}
.ds-stat-rail__cell--b {
  background: var(--chart-2);
}
.ds-stat-rail__cell--c {
  background: var(--chart-3);
}
.ds-stat-rail__cell--d {
  background: var(--chart-8);
}
.ds-stat-rail__cell--e {
  background: var(--chart-4);
}

.ds-banner {
  margin-top: 28px;
  padding: 22px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.ds-banner__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.ds-banner p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
}

.ds-banner strong {
  color: var(--text);
  font-weight: 600;
}

.ds-text-warn {
  color: var(--negative);
  font-weight: 600;
}

.ds-prompt-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px 0 14px;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page-bg) 92%, transparent);
  backdrop-filter: blur(10px);
}

.ds-prompt-nav__brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ds-prompt-nav__brand span {
  font-weight: 400;
  color: var(--text-muted);
}

.ds-prompt-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.ds-prompt-nav__links a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.ds-prompt-nav__links a:hover {
  color: var(--text);
}

.ds-prompt-nav__links a.is-active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--chart-2);
}

@media (max-width: 768px) {
  .ds-stat-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ds-prompt-nav__links {
    display: none;
  }
}

.ds-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-badge-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ds-badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
