/* ================================================================
   The Piggish Bank — style.css
   ================================================================ */

/* ── Reset & custom properties ──────────────────────────────── */
@font-face {
  font-family: 'Fraunces Local';
  src: url('/fonts/Fraunces-Variable.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #59cfc7;
  --color-primary-deep: #243332;
  --color-primary-soft: color-mix(in srgb, #59cfc7 28%, white);
  --color-on-primary-soft: #243332;
  --color-secondary: #332c24;
  --color-tertiary: #cf6c59;
  --color-tertiary-soft: color-mix(in srgb, #cf6c59 28%, white);
  --color-surface: #fbf7f1;
  --color-surface-low: #ffffff;
  --color-surface-mid: #eee6dc;
  --color-text: #243332;
  --color-text-muted: #5d7a78;
  --color-line: #5d7a78;
  --color-line-muted: color-mix(in srgb, #5d7a78 28%, white);
  --flow-line-color: #5f6464;
  --flow-line-alpha: 0.46;
  --color-error: #cf6c59;
  --color-scrim: #000000;
  --trend-series-1: #59cfc7;
  --trend-series-2: #cf6c59;
  --trend-series-3: #cf9559;
  --trend-series-4: #408a9f;
  --trend-series-5: #8a3f2c;
  --trend-series-6: #9f405e;
  --trend-series-7: #5d7a78;
  --trend-series-8: #332c24;
  --inflow-circle-large: #59cfc7;
  --inflow-circle-medium: #cf9559;
  --inflow-circle-small: #cf6c59;
  --outflow-circle-large: #408a9f;
  --outflow-circle-medium: #8a3f2c;
  --outflow-circle-small: #9f405e;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 28px;
  --radius-full: 999px;

  --shadow-none: none;
  --shadow-sm: 0 1px 3px rgba(29, 27, 32, 0.12), 0 1px 2px rgba(29, 27, 32, 0.14);
  --shadow-md: 0 2px 6px rgba(29, 27, 32, 0.14), 0 1px 2px rgba(29, 27, 32, 0.18);
  --shadow-lg: 0 4px 10px rgba(29, 27, 32, 0.16), 0 2px 4px rgba(29, 27, 32, 0.18);

  --page-bg: #ffffff;
  --text: var(--color-text);
  --text-muted: var(--color-text-muted);
  --card-bg: #ffffff;
  --pool-size: 230px;
  --radius: var(--radius-md);
  --shadow: var(--shadow-sm);
  --shadow-lift: var(--shadow-lg);
  --font: system-ui, sans-serif;
  --brand-font: 'Fraunces Local', 'Fraunces', Georgia, serif;
  --canvas-width: 5000px;
  --canvas-height: 3000px;
}

html, body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--text);
  overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 180;

  min-height: 70px;
  padding: 0 2.25rem;
  border-bottom: 1px solid var(--color-surface);
  background: white;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  overflow: visible;
}

main {
  min-height: 100%;
}

.site-title {
  justify-self: start;
  width: clamp(8rem, 12vw, 12rem);
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--color-primary);
  /* font-family: var(--brand-font); */
  font-size: clamp(.9rem, 1.45vw, 1.25rem);
  font-weight: 700;
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 80, 'WONK' 1, 'opsz' 72, 'wght' 700;
  line-height: 1.2;
  letter-spacing: 1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-wordmark {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.site-title[href] {
  text-decoration: none;
}

.header-actions {
  justify-self: end;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.header-help-link.is-active {
  background: color-mix(in srgb, var(--color-primary) 13%, transparent);
  color: var(--color-primary);
}

.app-view {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-view[hidden] {
  display: none;
}

/* Keep the graph measurable while Trends is active. Graph layout and stored
   node offsets depend on real canvas dimensions, which display:none removes. */
#money-view.is-view-hidden {
  position: fixed;
  inset: 0;
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.view-menu {
  position: static;
  display: flex;
  justify-self: center;
  align-items: center;
  align-self: stretch;
  gap: 1.25rem;
  flex: 0 0 auto;
}

.view-menu-link {
  position: relative;
  min-height: 70px;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 2rem;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.16s ease;
}

.view-menu-link:hover {
  color: var(--color-text);
}

.view-menu-link.is-active {
  color: var(--color-primary);
}

.view-menu-link.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--color-primary);
}

.money-tools {
  position: static;
  justify-self: end;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: 0;
}

body[data-view="trends"] .money-tool-button[data-tool-action="reset-zoom"],
body[data-view="trends"] .money-tool-button[data-tool-action="compact-money"] {
  display: none;
}

.money-toolbar {
  position: static;
  width: auto;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  max-height: none;
  overflow: visible;
}

.theme-panel {
  position: fixed;
  right: 1rem;
  top: 4.5rem;
  width: min(320px, calc(100vw - 2rem));
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card-bg) 97%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  gap: 0.7rem;
}

.theme-panel[hidden] {
  display: none;
}

.theme-list {
  display: grid;
  gap: 0.45rem;
}

.theme-option {
  all: unset;
  box-sizing: border-box;
  min-height: 38px;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 0.55rem;
  color: var(--color-text);
  cursor: pointer;
}

.theme-option:hover,
.theme-option:focus-visible,
.theme-option.is-active {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  outline: none;
}

.theme-swatch {
  height: 22px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.theme-name {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.15;
}

.money-tool-button {
  all: unset;
  box-sizing: border-box;
  position: relative;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  appearance: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.money-tool-button:hover,
.money-tool-button:focus-visible {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  outline: none;
}

.money-tool-button:hover,
.money-tool-button:focus-visible {
  z-index: 2;
}

.money-tool-button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.money-tool-button::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: calc(100% + 0.55rem);
  transform: translateX(-50%);
  min-width: max-content;
  padding: 0.32rem 0.55rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-text) 92%, transparent);
  color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.money-tool-button:hover::after,
.money-tool-button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 2px);
}

.money-tool-button:last-child::after {
  right: 0;
  left: auto;
  transform: none;
}

.money-tool-button:last-child:hover::after,
.money-tool-button:last-child:focus-visible::after {
  transform: translateY(2px);
}

.tool-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  font-family: 'Material Symbols Outlined';
  font-size: 28px;
  font-style: normal;
  font-weight: 300;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

#site-title {
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  font-weight: 500;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--color-primary), var(--color-tertiary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

#site-subtitle {
  color: var(--text-muted);
  margin-top: 0.45rem;
  font-size: 1.05rem;
  font-weight: 500;
}

/* ── Viz root container ──────────────────────────────────────── */
/* Help and issue reporting */
.help-main {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 7.5rem clamp(1rem, 4vw, 3rem) 3rem;
  background:
    radial-gradient(circle at 12% 12%, color-mix(in srgb, var(--color-primary) 11%, transparent), transparent 32rem),
    var(--page-bg);
}

.help-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: start;
  gap: clamp(1rem, 2.4vw, 1.75rem);
}

.help-card {
  min-width: 0;
  padding: clamp(1.4rem, 3vw, 2.25rem);
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card-bg) 96%, transparent);
  box-shadow: 0 18px 45px rgba(18, 39, 64, 0.08);
}

.fine-print-card {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--color-primary) 9%, var(--card-bg)), var(--card-bg) 72%);
}

.report-card {
  grid-column: 1 / -1;
}

.help-card .eyebrow {
  margin: 0 0 0.65rem;
  color: var(--color-primary);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.help-card h1,
.help-card h2 {
  margin: 0;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.help-card h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.95rem);
}

.fine-print-copy {
  margin-top: 1.35rem;
  display: grid;
  gap: 1rem;
  color: var(--color-text-muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.faq-intro,
.report-intro {
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.report-intro {
  display: grid;
  gap: 0.8rem;
}

.help-faq-list {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.65rem;
}

.help-faq-item {
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-md);
  background: var(--color-surface-low);
  overflow: hidden;
}

.help-faq-item summary {
  padding: 0.9rem 1rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.94rem;
  font-weight: 650;
  line-height: 1.35;
  list-style: none;
  cursor: pointer;
}

.help-faq-item summary::-webkit-details-marker {
  display: none;
}

.help-faq-item summary:hover,
.help-faq-item summary:focus-visible {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  outline: none;
}

.help-faq-item summary .material-symbols-outlined {
  flex: 0 0 auto;
  color: var(--color-primary);
  transition: transform 160ms ease;
}

.help-faq-item[open] summary .material-symbols-outlined {
  transform: rotate(180deg);
}

.help-faq-answer {
  padding: 0 1rem 1rem;
  color: var(--color-text-muted);
  display: grid;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.issue-report-form {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.issue-report-form label {
  min-width: 0;
  display: grid;
  gap: 0.45rem;
  color: var(--color-text);
  font-size: 0.82rem;
  font-weight: 600;
}

.issue-report-form label:nth-of-type(3),
.issue-report-form label:nth-of-type(4) {
  grid-column: 1 / -1;
}

.issue-report-form label em {
  color: var(--color-text-muted);
  font-weight: 400;
}

.issue-report-form input,
.issue-report-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-md);
  background: var(--color-surface-low);
  color: var(--color-text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.issue-report-form input {
  min-height: 46px;
  padding: 0.7rem 0.8rem;
}

.issue-report-form textarea {
  min-height: 150px;
  padding: 0.8rem;
  resize: vertical;
}

.issue-report-form input::placeholder,
.issue-report-form textarea::placeholder {
  color: color-mix(in srgb, var(--color-text-muted) 72%, transparent);
}

.issue-report-form input:focus,
.issue-report-form textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 16%, transparent);
}

.issue-report-form small {
  color: var(--color-error);
  font-size: 0.75rem;
  font-weight: 500;
}

.report-submit {
  min-height: 46px;
  justify-self: start;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-on-primary-soft);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.report-submit:hover,
.report-submit:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  outline: none;
}

.form-status,
.form-errors {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 500;
}

.form-status {
  background: color-mix(in srgb, var(--color-primary) 13%, transparent);
  color: var(--color-text);
}

.form-errors {
  background: color-mix(in srgb, var(--color-error) 13%, transparent);
  color: var(--color-error);
}

#viz-root {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 8.5rem 1.5rem 2rem;
  display: block;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#viz-root.is-panning {
  cursor: grabbing;
}

#viz-root.is-panning * {
  cursor: grabbing;
}

#graph-world {
  position: relative;
  z-index: 2;
  width: var(--canvas-width);
  height: var(--canvas-height);
  transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1));
  transform-origin: 0 0;
  pointer-events: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: subpixel-antialiased;
}

@supports (zoom: 1) {
  #graph-world {
    zoom: var(--zoom, 1);
    transform: translate(var(--pan-x-zoomed, 0px), var(--pan-y-zoomed, 0px));
  }
}

#graph-layout {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) var(--pool-size) minmax(220px, 1fr);
  align-items: center;
  column-gap: clamp(2rem, 7.5vw, 6.5rem);
  pointer-events: none;
}

.node-cluster-panel {
  --cluster-accent: var(--color-primary);
  position: absolute;
  z-index: 3;
  min-width: 420px;
  pointer-events: none;
}

.node-cluster-panel[hidden] {
  display: none;
}

.incoming-cluster-panel {
  --cluster-accent: var(--inflow-circle-large);
  box-shadow: -20px 0 24px color-mix(in srgb, var(--color-primary-deep) 15%, transparent);
}

.outgoing-cluster-panel {
  --cluster-accent: var(--outflow-circle-large);
  box-shadow: 20px 0 24px color-mix(in srgb, var(--color-primary-deep) 15%, transparent);
}

.node-cluster-header {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--color-text);
}

.node-cluster-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--cluster-accent) 15%, transparent);
  color: var(--cluster-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-variation-settings: 'FILL' 0, 'wght' 600, 'GRAD' 0, 'opsz' 40;
}

.node-cluster-heading {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.node-cluster-heading h2 {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(1.35rem, 1.6vw, 2rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.node-cluster-total {
  color: var(--cluster-accent);
  font-size: clamp(1.05rem, 1.25vw, 1.45rem);
  font-weight: 650;
  line-height: 1.2;
}

.node-column {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8rem;
  pointer-events: none;
}

.incoming-column {
  align-items: flex-end;
}

.outgoing-column {
  align-items: flex-start;
}

.pool-stage {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* SVG sits absolutely over the entire viz-root */
#flow-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
  shape-rendering: geometricPrecision;
}

#flow-svg path {
  shape-rendering: geometricPrecision;
}

#flow-svg path.flow-line-path {
  opacity: 0;
}

#flow-svg path.flow-line-path.is-visible {
  opacity: var(--flow-line-alpha);
}

#flow-svg .flow-dollar-symbol {
  fill: var(--color-tertiary);
  stroke: none;
  font-family: var(--font);
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

#flow-svg .flow-dash-symbol {
  stroke: var(--color-tertiary);
  stroke-width: 2px;
  stroke-linecap: round;
  pointer-events: none;
  user-select: none;
}

/* ── Pool / fund node ────────────────────────────────────────── */
#pool-node {
  --root-node-size: 190px;
  position: relative;
  z-index: 2;
  width: max(var(--pool-size), var(--root-node-size));
  height: max(216px, calc(var(--root-node-size) + 26px));
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-deep);
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px));
  transition: transform 0.12s ease;
  will-change: transform;
}

#pool-node.is-dragging {
  cursor: grabbing;
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px)) scale(1.03);
  transition: none;
}

#pool-node.is-layouting {
  transition: none;
}

.pool-icon-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--root-node-size);
  height: var(--root-node-size);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.pool-icon-backdrop.has-custom-image {
  border-radius: 0;
  background: transparent;
}

.pool-custom-image:not([hidden]) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

html[data-theme="newspaper"] .pool-custom-image {
  filter: grayscale(1);
}

html[data-theme="newspaper"] .site-wordmark {
  filter: grayscale(1);
}

/* ── Flow zone spacer ────────────────────────────────────────── */
#flow-zone {
  display: none;
}

/* ── Project cards row ───────────────────────────────────────── */
#source-nodes,
#cards-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(156px, var(--flow-card-max-size, 340px)));
  align-content: center;
  align-items: start;
  gap: 1.1rem;
  width: 100%;
  max-height: 100%;
  overflow: visible;
  pointer-events: none;
}

#source-nodes {
  justify-content: end;
  justify-items: end;
}

#cards-row {
  justify-content: start;
  justify-items: start;
}

/* ── Individual project card ─────────────────────────────────── */
.flow-card {
  background: var(--flow-card-color, var(--inflow-circle-small));
  border-radius: var(--radius-full);
  box-shadow: var(--shadow);
  --flow-card-diameter: min(var(--flow-card-size, 178px), var(--flow-card-max-size, 340px));
  width: var(--flow-card-diameter);
  height: var(--flow-card-diameter);
  aspect-ratio: 1;
  min-width: var(--flow-card-diameter);
  min-height: var(--flow-card-diameter);
  flex: 0 0 var(--flow-card-diameter);
  overflow: visible;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px));
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease;
  outline: none;
}

.flow-card:hover,
.flow-card:focus-visible {
  transform: translate(var(--drag-x, 0px), calc(var(--drag-y, 0px) - 8px)) scale(1.03);
  box-shadow: var(--shadow-lift);
}

.flow-card:focus-visible {
  box-shadow: var(--shadow-lift), 0 0 0 4px color-mix(in srgb, var(--color-primary) 24%, transparent);
}

.flow-card:active {
  transform: translate(var(--drag-x, 0px), calc(var(--drag-y, 0px) - 4px)) scale(1.01);
}

.flow-card.is-dragging {
  cursor: grabbing;
  transform: translate(var(--drag-x, 0px), var(--drag-y, 0px)) scale(1.02);
  box-shadow: var(--shadow-lift);
  transition: box-shadow 0.22s ease;
}

.flow-card.is-layouting {
  transition: none;
}

.card-header {
  padding: 0 11%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  width: 100%;
}

.card-header .card-name {
  font-family: var(--font);
  font-weight: 300;
  color: #fff;
  font-size: clamp(0.52rem, var(--flow-card-name-size, 0.78rem), 1.45rem);
  line-height: 1.14;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: subpixel-antialiased;
  text-shadow: none;
}

.card-body {
  padding: 4.5% 12% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.28rem;
}

.card-name {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
}

.card-amount {
  color: #fff;
  font-size: clamp(0.68rem, var(--flow-card-amount-size, 1.08rem), 2.2rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: subpixel-antialiased;
  text-shadow: none;
}

.card-funding-status {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.5rem;
  opacity: 0.6;
}

html[data-amount-format="compact"] .card-amount {
  font-size: clamp(0.82rem, calc(var(--flow-card-amount-size, 1.08rem) + 4px), 2.64rem);
}

html[data-amount-format="compact"] .flow-card[data-flow-card-size="large"] .card-amount {
  font-size: clamp(1rem, calc(var(--flow-card-amount-size, 1.08rem) + 8px), 3rem);
}

/* Statistics section */
#stats-section {
  height: 100vh;
  height: 100dvh;
  background: var(--page-bg);
  overflow: hidden;
}

.stats-inner {
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 70px 0 0 0;
  display: grid;
  grid-template-columns: minmax(350px, 450px) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(1.5rem, 3vw, 3.5rem);
  overflow: hidden;
}

.trends-left-column,
.trends-right-column {
  min-width: 0;
  min-height: 0;
}

.trends-left-column {
  padding: 26px 0 0 clamp(1.5rem, 3vw, 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.trends-right-column {
  padding: 26px clamp(1.5rem, 3vw, 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.trends-chart-container {
  min-width: 0;
}

.trends-eyebrow {
  margin-bottom: 0.55rem;
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.trends-hero-copy h1,
.trends-hero-copy h2 {
  display: flex;
  flex-direction: column;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(2rem, 3vw, 3.15rem);
  font-variation-settings: 'SOFT' 70, 'WONK' 1, 'opsz' 96, 'wght' 700;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.trends-hero-copy h1 span:last-child,
.trends-hero-copy h2 span:last-child {
  position: relative;
  width: fit-content;
}

.trends-hero-copy h1 span:last-child::after,
.trends-hero-copy h2 span:last-child::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 3%;
  bottom: -0.22rem;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-tertiary);
  transform: rotate(-1deg);
}

.trends-hero-copy > p:last-child {
  max-width: 36rem;
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: clamp(0.9rem, 1vw, 1.02rem);
  font-weight: 500;
  line-height: 1.55;
}

.trends-overview {
  /* display: grid; */
  display: none;
  grid-template-columns: repeat(3, minmax(0, 360px));
  justify-content: end;
  gap: 1rem;
  margin-bottom: clamp(1.25rem, 2.4vw, 2rem);
}

.trends-overview--columns-2 {
  grid-template-columns: repeat(2, minmax(0, 360px));
}

.trends-overview--columns-1 {
  grid-template-columns: minmax(0, 360px);
}

.trends-overview-card {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 360px;
  min-height: 110px;
  padding: 14px clamp(14px, 1.45vw, 20px);
  border: 1px solid color-mix(in srgb, var(--overview-accent) 20%, transparent);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card-bg) 94%, var(--overview-accent) 6%);
  box-shadow: 0 12px 22px color-mix(in srgb, var(--color-scrim) 7%, transparent);
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow: hidden;
}

button.trends-overview-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

button.trends-overview-card:hover,
button.trends-overview-card:focus-visible {
  border-color: var(--overview-accent);
  box-shadow: 0 16px 28px color-mix(in srgb, var(--overview-accent) 18%, transparent);
  transform: translateY(-2px);
}

button.trends-overview-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--overview-accent) 38%, transparent);
  outline-offset: 2px;
}

.trends-overview-card-inflation {
  --overview-accent: var(--color-primary);
}

.trends-overview-card-charts {
  --overview-accent: var(--color-tertiary);
}

.trends-overview-card-updated {
  --overview-accent: var(--color-secondary);
}

.trends-overview-icon {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, color-mix(in srgb, var(--overview-icon-background, var(--overview-accent)) 72%, var(--color-surface-low)), var(--overview-icon-background, var(--overview-accent)));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--overview-accent) 28%, transparent);
  color: var(--overview-icon-color, var(--color-surface-low));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.trends-overview-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.trends-overview-label {
  color: var(--color-text);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trends-overview-copy strong {
  overflow: hidden;
  color: var(--overview-value-color, var(--overview-accent));
  font-size: clamp(1.2rem, 1.65vw, 1.7rem);
  font-weight: 750;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trends-overview-copy > span:last-child {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.stats-sidebar {
  min-width: 0;
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
  padding: 1.25rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card-bg) 96%, transparent);
  box-shadow: 0 12px 36px color-mix(in srgb, var(--color-scrim) 7%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.stats-sidebar-title {
  margin: 0 0 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stats-nav {
  display: grid;
  gap: 0.5rem;
}

.stats-nav-link {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-md);
  background: var(--color-surface-low);
  color: var(--color-text);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.stats-nav-link:hover,
.stats-nav-link:focus-visible {
  border-color: color-mix(in srgb, var(--color-primary) 58%, var(--color-line-muted));
  background: color-mix(in srgb, var(--color-primary-soft) 38%, var(--color-surface-low));
  transform: translateX(2px);
}

.stats-nav-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.stats-nav-link.is-active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary-soft) 66%, var(--color-surface-low));
  color: var(--color-primary-deep);
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.stats-nav-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface-low));
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stats-nav-arrow {
  color: var(--color-text-muted);
  font-size: 1.15rem;
  transition: transform 160ms ease;
}

.stats-nav-link.is-active .stats-nav-arrow {
  color: var(--color-primary);
  transform: translateX(2px);
}

.stats-sidebar-note {
  margin-top: 1.1rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--color-primary) 22%, var(--color-line-muted));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-primary-soft) 32%, var(--color-surface-low));
  color: var(--color-text-muted);
  display: none;
  align-items: flex-start;
  gap: 0.7rem;
}

.stats-sidebar-note .material-symbols-outlined {
  flex: 0 0 auto;
  color: var(--color-primary);
  font-size: 1.55rem;
}

.stats-sidebar-note p {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.stats-grid {
  min-width: 0;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 140ms ease, transform 180ms ease;
}

.stats-grid.is-changing {
  opacity: 0;
  transform: translateY(5px);
}

.stat-card {
  min-width: 0;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card-bg) 97%, transparent);
  box-shadow: 0 14px 40px color-mix(in srgb, var(--color-scrim) 8%, transparent);
  overflow: hidden;
}

.stats-empty {
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.stat-card-header {
  min-height: 98px;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--color-line-muted);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.stat-card-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, color-mix(in srgb, var(--color-primary) 68%, var(--color-surface-low)), var(--color-primary));
  box-shadow: 0 7px 16px color-mix(in srgb, var(--color-primary) 25%, transparent);
  color: var(--color-surface-low);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
}

.stat-card-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.stat-card-eyebrow {
  color: var(--color-primary);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card h1,
.stat-card h3 {
  margin-top: 0.1rem;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  font-variation-settings: 'SOFT' 70, 'WONK' 1, 'opsz' 72, 'wght' 700;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.stat-summary {
  max-width: 48rem;
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.trend-route-chart-summary {
  padding: 1.25rem 1.5rem;
  background: color-mix(in srgb, var(--page-bg) 74%, transparent);
}

.trend-route-chart-summary .stat-chart-panel-header h2,
.stat-cause-effect-header h2 {
  margin-top: 0.08rem;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(1.15rem, 1.5vw, 1.4rem);
  font-weight: 700;
  line-height: 1.15;
}

.trend-route-latest-readings {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
}

.trend-route-latest-readings .stat-latest-series {
  padding: 0.8rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
}

.trend-route-event-sources {
  max-width: 52rem;
  margin-top: 0.65rem;
}

.trend-route-directory {
  padding: clamp(1.2rem, 2.6vw, 2rem);
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card-bg) 97%, transparent);
}

.trend-route-directory > h2 {
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(1.55rem, 2vw, 2.1rem);
}

.trend-route-directory-list {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem;
}

.trend-route-directory-category {
  padding: 1rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-lg);
  background: var(--page-bg);
}

.trend-route-directory-category h3 {
  color: var(--color-primary-deep);
  font-family: var(--brand-font);
  font-size: 1.1rem;
}

.trend-route-directory-category p {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.trend-route-directory-category ul {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.35rem;
  list-style: none;
}

.trend-route-directory-category a {
  color: var(--color-primary-deep);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.35;
}

.stat-card-date {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stat-card-date strong {
  color: var(--color-text);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
}

.stat-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.stat-card-charts {
  min-width: 0;
  padding: 1rem 1.5rem 1.35rem;
  background: radial-gradient(circle at 98% 100%, color-mix(in srgb, var(--color-primary) 10%, transparent) 0 2px, transparent 3px) 0 0 / 10px 10px,
    var(--color-surface-low);
}

.stat-chart-tabs {
  min-width: 0;
  padding: 0.22rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-full);
  background: var(--color-text-muted);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.stat-chart-tabs::-webkit-scrollbar {
  display: none;
}

.stat-chart-tab {
  all: unset;
  box-sizing: border-box;
  min-width: min(220px, 34%);
  min-height: 40px;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: white;
  display: inline-flex;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.stat-chart-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.stat-chart-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.stat-chart-tab.is-active {
  border-color: var(--color-primary);
  background: var(--color-surface-low);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary-deep);
}

.stat-chart-viewport {
  min-width: 0;
  margin-top: 0.9rem;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 140ms ease, transform 180ms ease;
}

.stat-chart-viewport.is-changing {
  opacity: 0;
  transform: translateY(5px);
}

.stat-chart-panel {
  min-width: 0;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-lg);
  background: white;
  overflow: hidden;
}

.stat-chart-panel[hidden],
.stat-card[hidden] {
  display: none !important;
}

.stat-chart-panel-header {
  min-height: 68px;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--color-line-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stat-chart-kicker {
  color: var(--color-primary);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-chart-panel-header h4 {
  margin-top: 0.16rem;
  color: var(--color-text);
  font-size: clamp(0.96rem, 1.3vw, 1.14rem);
  font-weight: 700;
  line-height: 1.25;
}

.stat-chart-updated {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 0.67rem;
  font-weight: 600;
  white-space: nowrap;
}

.stat-chart-stage {
  min-height: 390px;
  padding: 1.15rem 1.2rem 0.8rem;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  align-items: stretch;
}

.stat-chart-primary-sources {
  min-height: 42px;
  padding: 0.65rem 1.2rem 0.75rem;
  border-top: 1px solid var(--color-line-muted);
  background:
    radial-gradient(circle at 98% 100%, color-mix(in srgb, var(--color-primary) 8%, transparent) 0 2px, transparent 3px) 0 0 / 10px 10px,
    color-mix(in srgb, var(--color-surface-low) 90%, var(--color-surface-mid));
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.2rem 0.65rem;
  color: #666;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.4;
}

.stat-chart-primary-sources > span {
  font-size: 0.57rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-chart-primary-sources a {
  color: #666;
  font-weight: 500;
  text-decoration: none;
}

.stat-chart-primary-sources a:hover,
.stat-chart-primary-sources a:focus-visible {
  color: var(--color-text-muted);
  text-decoration: underline;
}

.stat-latest-readings {
  min-width: 0;
  padding: 0.5rem 1.15rem 0.5rem 0;
  border-right: 1px solid var(--color-line-muted);
  display: flex;
  flex-direction: column;
}

.stat-latest-heading {
  margin-bottom: 0.7rem;
  color: var(--color-text-muted);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-latest-series {
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--color-line-muted);
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.stat-latest-series:last-child {
  border-bottom: 0;
}

.stat-latest-label {
  overflow: hidden;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.stat-series-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--stat-series-color);
}

.stat-latest-series strong {
  color: var(--color-primary-deep);
  font-size: clamp(1.3rem, 2vw, 1.75rem);
  font-weight: 750;
  line-height: 1.05;
}

.stat-latest-series > span:last-child {
  color: var(--color-text-muted);
  font-size: 0.65rem;
  font-weight: 500;
}

.stat-chart-canvas {
  min-width: 0;
  display: flex;
  align-items: center;
}

.stat-chart-canvas .stat-chart {
  min-height: 330px;
  max-height: 800px;
}

.stat-grid-line {
  stroke: var(--color-line-muted);
  stroke-width: 1;
}

.stat-axis-line,
.stat-axis-tick {
  stroke: var(--color-line);
  stroke-width: 1.15;
}

.stat-axis-label {
  fill: var(--color-text-muted);
  font-size: 11px;
  font-weight: 500;
}

.stat-axis-title,
.stat-value-label {
  fill: var(--color-on-primary-soft);
  font-size: 10px;
  font-weight: 500;
}

.stat-area {
  opacity: 0.12;
}

.stat-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-line--series {
  stroke-width: 3;
}

.stat-legend-item text {
  fill: var(--text);
  font-size: 10px;
  font-weight: 500;
}

.stat-point-wrap {
  cursor: pointer;
  outline: none;
}

.stat-point-hit {
  fill: transparent;
}

.stat-point {
  stroke: var(--color-surface);
  stroke-width: 2;
  transition: r 0.15s ease, stroke-width 0.15s ease;
}

.stat-point--series {
  stroke-width: 1.5;
}

.stat-point-value {
  stroke: var(--color-surface-low);
  stroke-width: 1px;
  paint-order: stroke fill;
  pointer-events: none;
  font-size: 6px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-point-tooltip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.stat-point-tooltip rect {
  fill: color-mix(in srgb, var(--color-text) 94%, transparent);
  stroke: color-mix(in srgb, var(--color-surface) 88%, transparent);
  stroke-width: 1;
}

.stat-point-tooltip text {
  fill: #fff;
  font-size: 11px;
  font-weight: 500;
}

.stat-point-wrap:hover .stat-point,
.stat-point-wrap:focus .stat-point {
  r: 7;
  stroke-width: 3;
}

.stat-point-wrap:hover .stat-point--series,
.stat-point-wrap:focus .stat-point--series {
  r: 5.4;
  stroke-width: 2.4;
}

.stat-point-wrap:hover .stat-point-tooltip,
.stat-point-wrap:focus .stat-point-tooltip {
  opacity: 1;
}

.stat-cause-effect-viewport {
  border-top: 1px solid var(--color-line-muted);
  background: color-mix(in srgb, var(--card-bg) 98%, var(--color-primary-soft));
}

.stat-cause-effect-panel {
  padding: 1.35rem 1.5rem 1.55rem;
}

.stat-cause-effect-panel[hidden] {
  display: none !important;
}

.stat-cause-effect-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-cause-effect-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-primary) 13%, var(--color-surface-low));
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-cause-effect-eyebrow {
  color: var(--color-primary);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-cause-effect-header h4 {
  margin-top: 0.08rem;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(1.15rem, 1.5vw, 1.4rem);
  font-variation-settings: 'SOFT' 70, 'WONK' 1, 'opsz' 48, 'wght' 700;
  font-weight: 700;
  line-height: 1.15;
}

.stat-cause-effect-timeline {
  position: relative;
  margin: 1.1rem 0 0 1.2rem;
  padding: 0 0 0 1.55rem;
  border-left: 1px solid color-mix(in srgb, var(--color-primary) 32%, var(--color-line-muted));
  list-style: none;
}

.stat-cause-effect-event {
  position: relative;
  padding: 0 0 1.6rem;
}

.stat-cause-effect-event:last-child {
  padding-bottom: 0;
}

.stat-cause-effect-dot {
  position: absolute;
  top: 0.22rem;
  left: calc(-1.55rem - 5px);
  width: 9px;
  height: 9px;
  border: 2px solid var(--card-bg);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 22%, transparent);
}

.stat-cause-effect-timeframe {
  color: var(--color-primary-deep);
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.stat-cause-effect-timeframe.is-increasing {
  color: #b42318;
}

.stat-cause-effect-timeframe.is-decreasing {
  color: #16794d;
}

.stat-cause-effect-timeframe.is-neutral {
  color: var(--color-text-muted);
}

.stat-cause-effect-direction-icon {
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1;
}

.stat-cause-effect-event p {
  max-width: 52rem;
  margin-top: 0.3rem;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.55;
}

.stat-cause-effect-sources-trigger {
  margin: 0 0 0 0.4rem;
  padding: 0.18rem 0.38rem;
  border: 1px solid var(--color-surface-mid);
  background: var(--page-bg);
  border-radius: 6px;
  color: var(--color-on-primary-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  vertical-align: 0.08em;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.stat-cause-effect-sources-trigger .material-symbols-outlined {
  font-size: 0.9rem;
  line-height: 1;
}

.stat-cause-effect-sources-trigger:hover,
.stat-cause-effect-sources-trigger:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  text-decoration: underline;
}

.stat-cause-effect-sources-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.trend-source-dialog {
  position: fixed;
  inset: 0;
  z-index: 220;
  pointer-events: none;
}

.trend-source-dialog.hidden {
  display: none;
}

.trend-source-dialog-card {
  position: absolute;
  top: var(--bubble-top, 1rem);
  left: var(--bubble-left, 1rem);
  width: min(420px, calc(100vw - 1.5rem));
  max-height: min(72vh, 620px);
  padding: 1.4rem 1.2rem 1.4rem 1.4rem;
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  background: var(--color-surface-low);
  color: var(--color-text);
  overflow: visible;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  transform-origin: var(--bubble-tail-offset, 50%) 50%;
  animation: trend-source-bubble-in 160ms ease both;
}

@keyframes trend-source-bubble-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.trend-source-dialog-card::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}

.trend-source-dialog-card[data-tail-edge="left"]::before {
  left: -13px;
  top: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 13px solid var(--color-surface-low);
}

.trend-source-dialog-card[data-tail-edge="right"]::before {
  right: -13px;
  top: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 13px solid var(--color-surface-low);
}

.trend-source-dialog-card[data-tail-edge="top"]::before {
  top: -13px;
  left: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-right: 11px solid transparent;
  border-bottom: 13px solid var(--color-surface-low);
  border-left: 11px solid transparent;
}

.trend-source-dialog-card[data-tail-edge="bottom"]::before {
  bottom: -13px;
  left: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-top: 13px solid var(--color-surface-low);
  border-right: 11px solid transparent;
  border-left: 11px solid transparent;
}

.trend-source-dialog-close {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.trend-source-dialog-close:hover,
.trend-source-dialog-close:focus-visible {
  background: var(--color-primary-soft);
}

.trend-source-dialog-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.trend-source-dialog-header {
  padding-right: 3rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.trend-source-dialog-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trend-source-dialog-eyebrow {
  color: var(--color-text-muted);
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.trend-source-dialog-header h2 {
  margin: 0.08rem 0 0;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: 1.35rem;
}

.trend-source-dialog-context {
  margin: 1rem 0 0.7rem;
  color: var(--color-primary-deep);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-card-footer {
  min-height: 48px;
  padding: 1rem 1.5rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.stat-sources,
.stat-related {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem 0.55rem;
  color: var(--color-text-muted);
  font-size: .8rem;
  line-height: 1.35;
}

.stat-sources a,
.stat-related a {
  color: var(--color-primary);
  font-weight: 500;
  text-decoration: none;
}

.stat-sources a:hover,
.stat-related a:hover {
  text-decoration: underline;
}

.trends-footer {
  min-height: 58px;
  padding: 0.9rem 0.2rem 0;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.7rem;
  font-weight: 500;
}

.trends-footer > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.trends-footer .material-symbols-outlined {
  color: var(--color-primary);
  font-size: 1.2rem;
}

@media (prefers-reduced-motion: reduce) {
  .stats-grid,
  .stat-chart-viewport,
  .stats-nav-link,
  .stats-nav-arrow {
    transition: none;
  }
}

@media (max-width: 1180px) {
  .stats-inner {
    grid-template-columns: minmax(235px, 310px) minmax(0, 1fr);
    gap: clamp(1.25rem, 2.2vw, 2rem);
  }

  .trends-hero-copy {
    max-width: 56rem;
  }

  .trends-overview-card {
    min-height: 122px;
    padding: 1rem 0.8rem;
    gap: 0.7rem;
  }

  .trends-overview-icon {
    width: 50px;
    height: 50px;
    font-size: 1.55rem;
  }

  .stat-chart-stage {
    grid-template-columns: minmax(125px, 155px) minmax(0, 1fr);
  }
}

/* ── Detail / info panel ─────────────────────────────────────── */
#detail-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

#detail-panel.hidden {
  pointer-events: none;
}

.panel-card {
  position: absolute;
  top: var(--bubble-top, 1rem);
  left: var(--bubble-left, 1rem);
  background: var(--color-surface-low);
  border: 1px solid var(--color-line-muted);
  border-radius: var(--radius-xl);
  width: min(420px, calc(100vw - 1.5rem));
  padding: 1.4rem 1.2rem 1.4rem 1.4rem;
  max-height: min(72vh, 620px);
  overflow: visible;
  opacity: 0;
  visibility: hidden;
  pointer-events: auto;
  transform: scale(0.96);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  box-shadow: var(--shadow-lg);
}

#detail-panel:not(.hidden) .panel-card {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

#panel-content {
  max-height: calc(min(72vh, 620px) - 2.8rem);
  overflow-y: hidden;
}

.panel-card::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}

.panel-card[data-tail-edge="left"]::before {
  left: -13px;
  top: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 13px solid var(--color-surface-low);
}

.panel-card[data-tail-edge="right"]::before {
  right: -13px;
  top: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 13px solid var(--color-surface-low);
}

.panel-card[data-tail-edge="top"]::before {
  top: -13px;
  left: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 13px solid var(--color-surface-low);
}

.panel-card[data-tail-edge="bottom"]::before {
  bottom: -13px;
  left: calc(var(--bubble-tail-offset, 50%) - 11px);
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 13px solid var(--color-surface-low);
}

.panel-close {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: transparent;
  appearance: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  color: var(--text-muted);
}

.panel-close:hover {
  background: var(--page-bg);
  transform: scale(1.1);
}

/* Panel content layout */
.panel-header {
  margin-bottom: 1rem;
  padding-right: 2rem;
}

#panel-title {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

.panel-desc {
  font-size: 0.87rem;
  color: var(--text-muted);
  margin-top: 12px;
  line-height: 1.45;
  font-weight: 500;
}

.panel-stats {
  display: grid;
  gap: 0.55rem;
  /*background: var(--color-primary-soft);*/
  border-radius: var(--radius-lg);
  padding: 0.75rem 0;
  margin-bottom: 1rem;
}

.panel-stat-row,
.panel-added-row {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.panel-added-row
{
  display: none;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
  white-space: nowrap;
}

.stat-amount {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  color: var(--color-error);
}

.stat-amount--lost {
  color: var(--color-secondary);
}

.panel-amount-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.panel-funding-status {
  color: var(--color-primary-deep);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-added-date {
  color: var(--color-text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.25;
}

.sources-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 0.7rem;
}

.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 300px;
}

.sources-list li a {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.8rem 0.5rem;
  background: var(--color-surface-mid);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, box-shadow 0.15s, transform 0.18s;
}

.sources-list li a:hover {
  background: var(--color-surface);
}

.sources-list .find-more-sources a {
  border: 1px solid var(--color-surface-mid);
  background: transparent;
  color: var(--color-primary-deep);
}

.sources-list .find-more-sources a:hover {
  background: var(--color-surface);
}

.source-arrow {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.2;
  opacity: 0.8;
}

.source-copy {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.2rem;
}

.source-title {
  line-height: 1.25;
  word-break: break-word;
}

.source-url {
  display: block;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 400;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-sources {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

/* ── Loading overlay ─────────────────────────────────────────── */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: fixed;
  inset: 0;
  background: var(--page-bg);
  z-index: 300;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: opacity 0.4s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(var(--color-primary), var(--color-surface));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-msg {
  color: var(--color-error);
  font-weight: 500;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 800px) {
  .help-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  #stats-section {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .stats-inner {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 5.8rem 1rem 1.5rem;
    display: block;
    overflow: visible;
  }

  .trends-left-column,
  .trends-right-column {
    padding: 0;
    overflow: visible;
  }

  .trends-left-column {
    margin-bottom: 1.3rem;
  }

  .stats-sidebar {
    margin-top: 1.3rem;
    padding: 0.9rem;
    overflow: hidden;
  }

  .stats-sidebar-title {
    margin-bottom: 0.6rem;
  }

  .stats-nav {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .stats-nav::-webkit-scrollbar {
    display: none;
  }

  .stats-nav-link {
    width: min(210px, 72vw);
    flex: 0 0 min(210px, 72vw);
    white-space: nowrap;
  }

  .stats-sidebar-note {
    display: none;
  }

  .stat-chart-stage {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .stat-latest-readings {
    padding: 0 0 0.9rem;
    border-right: 0;
    border-bottom: 1px solid var(--color-line-muted);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
  }

  .stat-latest-heading {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .stat-latest-series {
    padding: 0.45rem 0;
    border-right: 1px dashed var(--color-line-muted);
    border-bottom: 0;
  }

  .stat-latest-series:last-child {
    border-right: 0;
  }

  .stat-chart-canvas .stat-chart {
    min-height: 280px;
  }
}

@media (max-width: 640px) {
  :root { --pool-size: 230px; }
  .site-header {
    min-height: 112px;
    padding: 0;
    grid-template-columns: 0.65rem 36px 36px minmax(0, 1fr) 36px 36px 0.65rem;
    grid-template-rows: 64px 48px;
    gap: 0;
  }
  .site-title {
    grid-column: 4;
    grid-row: 1;
    justify-self: center;
    width: min(8.5rem, 100%);
    max-width: 8.5rem;
    font-size: 0.82rem;
  }
  .header-actions,
  .money-tools,
  .money-toolbar {
    display: contents;
  }
  .money-tool-button[data-tool-action="reset-zoom"] {
    grid-column: 2;
    grid-row: 1;
  }
  .money-tool-button[data-tool-action="compact-money"] {
    grid-column: 3;
    grid-row: 1;
  }
  .money-tool-button[data-tool-action="theme"] {
    grid-column: 5;
    grid-row: 1;
  }
  .header-help-link {
    grid-column: 6;
    grid-row: 1;
  }
  .view-menu {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 48px;
    justify-self: stretch;
    align-self: stretch;
    justify-content: center;
    gap: 0.8rem;
    background: var(--page-bg);
  }
  .view-menu-link {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 48px;
    padding: 0 1rem;
    width: 50%;
  }
  .theme-panel {
    top: 4.25rem;
  }
  .stats-inner {
    padding-top: 8.25rem;
  }
  .help-main {
    padding: 8.25rem 0.75rem 2rem;
  }
  .help-card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }
  .issue-report-form {
    grid-template-columns: minmax(0, 1fr);
  }
  .issue-report-form label,
  .issue-report-form label:nth-of-type(3),
  .issue-report-form label:nth-of-type(4) {
    grid-column: 1;
  }
  #graph-layout {
    grid-template-columns: minmax(96px, 1fr) var(--pool-size) minmax(96px, 1fr);
    column-gap: 1.25rem;
  }
  #source-nodes,
  #cards-row {
    grid-template-columns: minmax(96px, 1fr);
    gap: 0.65rem;
  }
  .flow-card {
    --flow-card-max-size: 178px;
  }
  #viz-root { padding: 7.5rem 1rem 2rem; }
  #flow-zone { height: 70px; }
  .card-header {
    padding: 0 0.8rem;
  }
  .card-body {
    padding: 0.42rem 0.8rem 0;
  }
  .card-header .card-name {
    font-size: clamp(0.5rem, var(--flow-card-name-size, 0.72rem), 1.12rem);
  }
  .card-amount {
    font-size: clamp(0.64rem, var(--flow-card-amount-size, 0.92rem), 1.5rem);
  }
  html[data-amount-format="compact"] .card-amount {
    font-size: clamp(0.76rem, calc(var(--flow-card-amount-size, 0.92rem) + 4px), 1.8rem);
  }
  .flow-card[data-flow-card-size="large"] .card-header .card-name {
    font-size: clamp(0.65rem, var(--flow-card-name-size, 0.72rem), 1.35rem);
  }
  html[data-amount-format="compact"] .flow-card[data-flow-card-size="large"] .card-amount {
    font-size: clamp(0.9rem, calc(var(--flow-card-amount-size, 0.92rem) + 8px), 2.2rem);
  }
  .stat-amount { font-size: 1.5rem; }
  .trends-hero-copy h1,
  .trends-hero-copy h2 {
    font-size: clamp(2.2rem, 11vw, 3.25rem);
  }
  .trends-overview {
    grid-template-columns: minmax(0, 360px);
  }
  .trends-overview-card {
    min-height: 104px;
    padding: 1rem;
  }
  .trends-overview-icon {
    width: 58px;
    height: 58px;
  }
  .stat-card-header {
    align-items: flex-start;
    padding: 1rem;
    flex-wrap: wrap;
  }
  .stat-card-icon {
    width: 42px;
    height: 42px;
  }
  .stat-card-date {
    width: 100%;
    padding-left: 3.6rem;
    align-items: flex-start;
  }
  .stat-card-charts {
    padding: 0.8rem 0.8rem 1rem;
  }
  .stat-chart-tabs {
    /* border-radius: var(--radius-lg); */
  }
  .stat-chart-tab {
    min-width: min(260px, 84vw);
  }
  .stat-chart-panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .stat-chart-updated {
    white-space: normal;
  }
  .stat-chart-stage {
    padding: 0.9rem 0.8rem 0.4rem;
  }
  .stat-latest-readings {
    grid-template-columns: minmax(0, 1fr);
  }
  .stat-latest-series {
    border-right: 0;
    border-bottom: 1px dashed var(--color-line-muted);
  }
  .stat-chart-canvas {
    overflow-x: auto;
  }
  .stat-chart-canvas .stat-chart {
    min-width: 520px;
  }
  .stat-card-footer,
  .trends-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .stat-cause-effect-panel {
    padding: 1.1rem 1rem 1.3rem;
  }
  .stat-cause-effect-timeline {
    margin-left: 0.55rem;
    padding-left: 1.2rem;
  }
  .stat-cause-effect-dot {
    left: calc(-1.2rem - 5px);
  }
  .stat-axis-label { font-size: 10px; }
}

@media (max-width: 400px) {
  .site-header {
    grid-template-columns: 0.4rem 30px 30px minmax(0, 1fr) 30px 30px 0.4rem;
  }
  .site-title {
    width: min(7.5rem, 100%);
    max-width: 7.5rem;
    font-size: 0.75rem;
  }
  .view-menu {
    gap: 0.5rem;
  }
  .view-menu-link {
    font-size: 0.78rem;
    padding: 0 0.8rem;
    width: 50%;
  }
  .money-toolbar {
    gap: 0.1rem;
  }
  .money-tool-button {
    width: 30px;
    height: 34px;
    min-height: 34px;
  }
  .tool-icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
  }
  .flow-card {
    --flow-card-max-size: 154px;
  }
  .card-header .card-name {
    font-size: clamp(0.48rem, var(--flow-card-name-size, 0.68rem), 0.96rem);
  }
  .card-amount {
    font-size: clamp(0.62rem, var(--flow-card-amount-size, 0.88rem), 1.26rem);
  }
  html[data-amount-format="compact"] .card-amount {
    font-size: clamp(0.72rem, calc(var(--flow-card-amount-size, 0.88rem) + 4px), 1.5rem);
  }
  .flow-card[data-flow-card-size="large"] .card-header .card-name {
    font-size: clamp(0.6rem, var(--flow-card-name-size, 0.68rem), 1.15rem);
  }
  html[data-amount-format="compact"] .flow-card[data-flow-card-size="large"] .card-amount {
    font-size: clamp(0.82rem, calc(var(--flow-card-amount-size, 0.88rem) + 8px), 1.8rem);
  }
}

/* ── Sankey money-flow layout ─────────────────────────────────── */
:root {
  --canvas-width: 1600px;
  --canvas-height: 820px;
  --sankey-panel-width: 400px;
  --sankey-row-height: 54px;
}

#viz-root {
  padding: 14.75rem 1.5rem 10rem;
}

body.graph-explainer-collapsed #viz-root {
  padding-bottom: 1rem;
}

.graph-summary {
  position: fixed;
  top: 96px;
  left: clamp(1.5rem, 3vw, 3rem);
  right: clamp(1.5rem, 3vw, 3rem);
  z-index: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(0, 734px);
  align-items: start;
  gap: clamp(2rem, 5vw, 6rem);
  opacity: 1;
  pointer-events: none;
  transition: opacity 650ms cubic-bezier(0.4, 0, 0.2, 1);
}

.graph-summary.is-chart-overlapped {
  opacity: 0.1;
}

.graph-summary-intro {
  min-width: 0;
}

.graph-summary-intro h1,
.graph-summary-intro h2 {
  margin: 0;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: clamp(2rem, 3vw, 3.15rem);
  font-weight: 700;
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 45, 'WONK' 1, 'opsz' 72, 'wght' 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.graph-summary-intro h1 span,
.graph-summary-intro h2 span {
  display: block;
}

.graph-summary-intro p {
  max-width: 32rem;
  margin: 0.9rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.94rem;
  font-weight: 480;
  line-height: 1.5;
}

.graph-summary-metrics {
  width: 100%;
  max-width: 734px;
  min-width: 0;
  min-height: 110px;
  margin-left: auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 400px));
  justify-content: end;
  justify-self: end;
  gap: 14px;
  pointer-events: auto;
}

.summary-metric {
  --summary-accent: var(--color-primary);
  width: 100%;
  max-width: 360px;
  min-width: 0;
  min-height: 110px;
  padding: 14px clamp(14px, 1.45vw, 20px);
  border: 1px solid color-mix(in srgb, var(--summary-accent) 20%, transparent);
  /* color-mix(in srgb, var(--summary-accent) 24%, var(--color-line-muted)); */
  border-radius: 18px;
  background: color-mix(in srgb, var(--summary-accent) 6%, var(--color-surface-low));
  box-shadow: 0 12px 30px color-mix(in srgb, var(--color-primary-deep) 8%, transparent);
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.summary-metric-spending {
  --summary-accent: var(--outflow-circle-medium);
}

.summary-metric-cuts {
  --summary-accent: var(--inflow-circle-medium);
}

.summary-metric-icon {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--summary-accent) 76%, white),
    var(--summary-accent)
  );
  box-shadow: 0 10px 22px color-mix(in srgb, var(--summary-accent) 26%, transparent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}

.summary-metric-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.summary-metric-label {
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  line-height: 1.2;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-metric strong {
  overflow: hidden;
  color: var(--summary-accent);
  font-size: clamp(1.2rem, 1.65vw, 1.7rem);
  font-weight: 760;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-metric-detail {
  display: none;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="trends"] .graph-summary {
  display: none;
}

#graph-layout {
  grid-template-columns: var(--sankey-panel-width) minmax(220px, 280px) var(--sankey-panel-width);
  column-gap: 140px;
  justify-content: center;
  align-items: center;
  padding: 26px 0;
}

.node-panel-carousel {
  --cluster-accent: var(--color-primary);
  --preview-step: 100px;
  position: relative;
  z-index: 3;
  width: var(--sankey-panel-width);
  min-width: 0;
  padding-bottom: 18px;
  cursor: grab;
  pointer-events: auto;
  perspective: 1400px;
}

.incoming-panel-carousel {
  --cluster-accent: var(--inflow-circle-large);
}

.outgoing-panel-carousel {
  --cluster-accent: var(--outflow-circle-large);
}

.node-cluster-panel {
  position: relative;
  z-index: 30;
  width: 100%;
  min-width: 0;
  height: auto;
  max-height: none;
  gap: 0;
  overflow: hidden;
  border: 0px solid var(--color-line-muted);
  border-radius: 20px;
  background: var(--color-surface-low);
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 1;
  transform: translate3d(0, 0, 0) rotateY(0) scale(1);
  transform-origin: center top;
  backface-visibility: hidden;
  transition:
    opacity 220ms ease,
    transform 220ms cubic-bezier(0.4, 0, 0.7, 0.2),
    box-shadow 220ms ease;
}

.incoming-panel-carousel.is-page-rotating-out .node-cluster-panel,
.incoming-panel-carousel.is-page-rotating-in .node-cluster-panel {
  opacity: 0.76;
  transform: translate3d(-72px, 0, -110px) rotateY(-13deg) scale(0.95);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--color-primary-deep) 7%, transparent);
}

.outgoing-panel-carousel.is-page-rotating-out .node-cluster-panel,
.outgoing-panel-carousel.is-page-rotating-in .node-cluster-panel {
  opacity: 0.76;
  transform: translate3d(72px, 0, -110px) rotateY(13deg) scale(0.95);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--color-primary-deep) 7%, transparent);
}

.node-panel-carousel.is-page-rotating-in .node-cluster-panel {
  transition: none;
}

.node-panel-carousel.is-page-rotating-in.is-page-rotating-in-active .node-cluster-panel {
  opacity: 1;
  transform: translate3d(0, 0, 0) rotateY(0) scale(1);
  box-shadow: 0 16px 38px color-mix(in srgb, var(--color-primary-deep) 10%, transparent);
  transition:
    opacity 320ms ease,
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 320ms ease;
}

.incoming-cluster-panel,
.outgoing-cluster-panel {
  align-items: stretch;
}

.node-cluster-header {
  min-height: 110px;
  padding: 22px 24px 18px;
  gap: 15px;
  border-bottom: 0;
}

.node-cluster-icon {
  order: 2;
  width: 52px;
  height: 52px;
  flex-basis: 52px;
  margin-left: auto;
  font-size: 28px;
}

.node-cluster-heading {
  order: 1;
  gap: 2px;
}

.node-cluster-eyebrow {
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.node-cluster-heading h2 {
  font-family: var(--brand-font);
  font-size: 1.35rem;
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 45, 'WONK' 1, 'opsz' 42, 'wght' 700;
  line-height: 1.05;
}

.node-cluster-total {
  display: none;
}

#source-nodes,
#cards-row {
  display: block;
  width: 100%;
  min-height: 0;
  max-height: none;
  padding: 0 0 10px;
  overflow: visible;
}

.node-panel-carousel.has-multiple-pages #source-nodes,
.node-panel-carousel.has-multiple-pages #cards-row {
  min-height: calc((var(--sankey-row-height) + 6px) * 9 + 10px);
}

.flow-card {
  --flow-card-diameter: auto;
  position: relative;
  width: calc(100% - 24px);
  min-width: 0;
  height: var(--sankey-row-height);
  min-height: var(--sankey-row-height);
  margin: 0 12px 2px;
  aspect-ratio: auto;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--flow-card-color) 10%, transparent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--flow-card-color) 5%, var(--color-surface-low));
  box-shadow: none;
  color: var(--color-text);
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  cursor: pointer;
  transform: none;
  transition: background 0.16s ease, color 0.16s ease;
}

.flow-card-new-ribbon {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  min-width: 30px;
  padding: 4px 7px 4px 6px;
  border-radius: 0 14px 0 11px;
  background: color-mix(in srgb, var(--color-tertiary) 86%, #9f2435);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--color-tertiary) 24%, transparent);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.09em;
  text-align: center;
  pointer-events: none;
}

.flow-card:last-child {
  /* border-bottom: 1px solid color-mix(in srgb, var(--flow-card-color) 26%, var(--color-line-muted)); */
}

.flow-card:hover,
.flow-card:focus-visible,
.flow-card:active {
  transform: none;
  border-color: color-mix(in srgb, var(--flow-card-color) 52%, var(--color-line-muted));
  box-shadow: 0 7px 16px color-mix(in srgb, var(--flow-card-color) 10%, transparent);
  background: color-mix(in srgb, var(--flow-card-color) 10%, var(--color-surface-low));
}

.flow-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--flow-card-color) 38%, transparent);
  outline-offset: -3px;
}

.flow-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--flow-card-color) 74%, white),
    var(--flow-card-color)
  );
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Material Symbols Outlined";
  font-size: 1.3rem;
  font-weight: 300;
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 20;
  letter-spacing: normal;
  line-height: 1;
}

.card-header {
  width: auto;
  min-width: 0;
  padding: 0;
  justify-content: flex-start;
  text-align: left;
}

.card-header .card-name {
  color: var(--color-text);
  font-size: 0.82rem;
  font-weight: 560;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-body {
  min-width: max-content;
  padding: 0;
  align-items: flex-end;
  gap: 2px;
}

.card-amount,
html[data-amount-format="compact"] .card-amount,
html[data-amount-format="compact"] .flow-card[data-flow-card-size="large"] .card-amount {
  color: color-mix(in srgb, var(--flow-card-color) 72%, var(--color-text));
  font-size: 0.9rem;
  font-weight: 720;
  line-height: 1.1;
}

.card-funding-status {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  opacity: 1;
}

.flow-card-chevron {
  color: color-mix(in srgb, var(--flow-card-color) 72%, var(--color-text));
  font-size: 18px;
}

.sankey-pagination {
  min-height: 62px;
  padding: 8px 12px 11px;
  border-top: 0px solid var(--color-line-muted);
  /* background: color-mix(in srgb, var(--cluster-accent) 20%, transparent); */
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 9px;
}

.sankey-page-button {
  all: unset;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border: 0px solid color-mix(in srgb, var(--cluster-accent) 28%, var(--color-line-muted));
  border-radius: var(--radius-full);
  background: white;
  color: var(--cluster-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.sankey-page-button:hover,
.sankey-page-button:focus-visible {
  border-color: var(--cluster-accent);
  background: color-mix(in srgb, var(--cluster-accent) 14%, var(--color-surface-low));
  transform: translateY(-1px);
}

.sankey-page-button:focus-visible,
.sankey-page-preview:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--cluster-accent) 36%, transparent);
  outline-offset: 2px;
}

.sankey-page-button:disabled {
  opacity: 0.34;
  cursor: default;
  transform: none;
}

.sankey-page-button .material-symbols-outlined {
  font-size: 21px;
}

.sankey-page-status {
  min-width: 0;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.64rem;
  font-weight: 550;
  line-height: 1.2;
}

#outflow-page-summary, #inflow-page-summary
{
  display: none;
}

.sankey-page-status strong {
  color: var(--cluster-accent);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sankey-page-preview-stack {
  position: absolute;
  z-index: 1;
  inset: 0 0 18px;
  pointer-events: none;
}

.sankey-page-preview {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  z-index: calc(20 - var(--preview-depth, 1));
  top: 0;
  bottom: 0;
  overflow: hidden;
  border: 0px solid color-mix(in srgb, var(--cluster-accent) 34%, var(--color-line-muted));
  border-radius: 20px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--cluster-accent) 7%, var(--color-surface-low)),
      var(--color-surface-low)
    );
  box-shadow:
    0 18px 46px color-mix(in srgb, var(--color-primary-deep) 15%, transparent),
    0 3px 10px color-mix(in srgb, var(--cluster-accent) 9%, transparent);
  color: var(--color-text-muted);
  display: block;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  opacity: 1;
  backface-visibility: hidden;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    opacity 220ms ease,
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.incoming-panel-carousel .sankey-page-preview {
  left: calc(var(--preview-depth, 1) * var(--preview-step) * -1);
  right: calc(var(--preview-depth, 1) * var(--preview-step));
  transform: rotateY(5deg) scale(calc(1 - var(--preview-depth, 1) * 0.045));
  transform-origin: right center;
}

.outgoing-panel-carousel .sankey-page-preview {
  left: calc(var(--preview-depth, 1) * var(--preview-step));
  right: calc(var(--preview-depth, 1) * var(--preview-step) * -1);
  transform: rotateY(-5deg) scale(calc(1 - var(--preview-depth, 1) * 0.1));
  transform-origin: left center;
}

.sankey-page-preview[hidden] {
  display: none;
}

.sankey-page-preview:hover {
  border-color: var(--cluster-accent);
  background: color-mix(in srgb, var(--cluster-accent) 12%, var(--color-surface-low));
  box-shadow:
    0 22px 52px color-mix(in srgb, var(--color-primary-deep) 18%, transparent),
    0 4px 12px color-mix(in srgb, var(--cluster-accent) 13%, transparent);
}

.sankey-page-preview-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  padding: 23px 24px 18px;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  letter-spacing: 0;
  pointer-events: none;
}

.sankey-page-preview-header small {
  color: var(--color-text-muted);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.sankey-page-preview-header b {
  max-width: 12rem;
  color: var(--color-text);
  font-family: var(--brand-font);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.08;
}

.sankey-page-preview-list {
  position: absolute;
  top: 110px;
  left: 0;
  right: 0;
  bottom: 62px;
  padding: 0 12px 10px;
  display: grid;
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 6px;
  overflow: hidden;
  pointer-events: none;
}

.sankey-page-preview-row {
  min-height: 0;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--preview-row-color) 26%, var(--color-line-muted));
  border-radius: 13px;
  background: color-mix(in srgb, var(--preview-row-color) 5%, var(--color-surface-low));
  color: var(--color-text);
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 9px;
  letter-spacing: 0;
}

.sankey-page-preview-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--preview-row-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Material Symbols Outlined";
  font-size: 1.05rem;
  font-weight: 300;
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 20;
  letter-spacing: normal;
}

.sankey-page-preview-name {
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sankey-page-preview-amount {
  color: color-mix(in srgb, var(--preview-row-color) 72%, var(--color-text));
  font-size: 0.72rem;
  font-weight: 720;
  white-space: nowrap;
}

.sankey-page-preview-chevron {
  color: color-mix(in srgb, var(--preview-row-color) 72%, var(--color-text));
  font-size: 16px;
}

.sankey-page-preview-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 62px;
  padding: 0 18px;
  border-top: 0px solid color-mix(in srgb, var(--cluster-accent) 16%, var(--color-line-muted));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
}

.sankey-page-preview-footer strong {
  color: var(--cluster-accent);
  font-size: 0.72rem;
}

.incoming-panel-carousel.is-page-rotating-out .sankey-page-preview.is-selected-preview {
  opacity: 1;
  transform:
    translate3d(calc(var(--preview-depth, 1) * var(--preview-step)), 0, 80px)
    rotateY(0)
    scale(1);
}

.outgoing-panel-carousel.is-page-rotating-out .sankey-page-preview.is-selected-preview {
  opacity: 1;
  transform:
    translate3d(calc(var(--preview-depth, 1) * var(--preview-step) * -1), 0, 80px)
    rotateY(0)
    scale(1);
}

#flow-svg {
  opacity: 1;
  transition: opacity 170ms ease;
}

#flow-svg.is-page-changing {
  opacity: 0;
}

#flow-svg path.flow-line-path {
  opacity: 0;
  mix-blend-mode: multiply;
}

#flow-svg path.flow-line-path.is-visible {
  opacity: 0.48;
}

#flow-svg .flow-dollar-symbol {
  display: block;
  filter: none;
}

#flow-svg .flow-dash-symbol {
  display: block;
  filter: none;
}

#pool-node {
  cursor: grab;
  transform: none;
}

.pool-icon-backdrop {
  overflow: hidden;
  /* box-shadow:
    0 0 22px color-mix(in srgb, var(--color-primary) 24%, transparent); */
}

.pool-icon-backdrop.has-custom-image {
  padding: 10px;
  /* border-radius: var(--radius-full);
  background: var(--color-surface-low); */
}

.graph-explainer-drawer {
  --graph-explainer-bottom: 1.25rem;
  position: fixed;
  left: 1.5rem;
  right: 1.5rem;
  bottom: var(--graph-explainer-bottom);
  z-index: 150;
  pointer-events: none;
  transform: translateY(0);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.graph-explainer-drawer.is-collapsed {
  transform: translateY(calc(100% + var(--graph-explainer-bottom)));
}

.graph-explainer-toggle {
  position: absolute;
  left: 50%;
  top: 1px;
  z-index: 2;
  width: 58px;
  height: 24px;
  border: 1px solid var(--color-surface);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: color-mix(in srgb, var(--color-surface-low) 97%, transparent);
  box-shadow: 0 -8px 20px color-mix(in srgb, var(--color-primary-deep) 9%, transparent);
  color: var(--color-primary-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.graph-explainer-toggle:hover,
.graph-explainer-toggle:focus-visible {
  background: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface-low));
  color: var(--color-primary-deep);
}

.graph-explainer-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 45%, transparent);
  outline-offset: 2px;
}

.graph-explainer-toggle .material-symbols-outlined {
  font-size: 24px;
  transition: transform 220ms ease;
}

.graph-explainer-toggle.has-first-visit-hint {
  animation: graph-explainer-tab-hint 1s ease-in-out 400ms 5;
}

@keyframes graph-explainer-tab-hint {
  0%, 100% {
    background: color-mix(in srgb, var(--color-surface-low) 97%, transparent);
    box-shadow: 0 -8px 20px color-mix(in srgb, var(--color-primary-deep) 9%, transparent);
  }
  50% {
    background: color-mix(in srgb, var(--color-primary) 15%, var(--color-surface-low));
    box-shadow:
      0 -10px 28px color-mix(in srgb, var(--color-primary) 26%, transparent),
      0 0 0 4px color-mix(in srgb, var(--color-primary) 10%, transparent);
  }
}

.graph-explainer-drawer.is-collapsed .graph-explainer-toggle .material-symbols-outlined {
  transform: rotate(180deg);
}

.graph-explainer {
  position: relative;
  min-height: 126px;
  padding: 20px 24px;
  border: 1px solid var(--color-surface);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-surface-low) 97%, transparent);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--color-primary-deep) 9%, transparent);
  color: var(--color-text);
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr)) minmax(310px, 1.5fr);
  align-items: center;
  gap: clamp(18px, 3vw, 46px);
  overflow: hidden;
  pointer-events: auto;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.graph-explainer-lead,
.graph-explainer-tip {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.graph-explainer-tip {
  --explainer-accent: var(--color-primary);
  position: relative;
  align-self: stretch;
  min-height: 72px;
  margin-top: -20px;
  margin-bottom: -20px;
  padding-left: clamp(16px, 2vw, 30px);
}

.graph-explainer-tip::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7.5%;
  width: 1px;
  height: 85%;
  background: var(--color-surface);
  pointer-events: none;
}

.graph-explainer-tip:nth-child(2) {
  --explainer-accent: var(--inflow-circle-large);
}

.graph-explainer-tip:nth-child(3) {
  --explainer-accent: var(--outflow-circle-medium);
}

.graph-explainer-tip:nth-child(4) {
  --explainer-accent: var(--color-primary);
  margin-right: -24px;
  background-image: url('/assets/panel-botright.png');
  background-origin: border-box;
  background-position: right bottom;
  background-repeat: no-repeat;
  background-size: 30%;
}

.graph-explainer-tip:nth-child(4) > span:last-child {
  position: relative;
  z-index: 1;
  max-width: 210px;
}

html[data-theme="newspaper"] .graph-explainer a {
  filter: grayscale(1);
}

html[data-theme="newspaper"] .graph-explainer-tip:nth-child(4) {
  background-image: none;
}

html[data-theme="newspaper"] .graph-explainer-tip:nth-child(4)::after {
  content: '';
  position: absolute;
  z-index: 0;
  inset: 0;
  background-image: url('/assets/panel-botright.png');
  background-position: right bottom;
  background-repeat: no-repeat;
  background-size: auto 100%;
  filter: grayscale(1);
  pointer-events: none;
}

html[data-theme="newspaper"] .graph-explainer-tip:nth-child(4) > * {
  position: relative;
  z-index: 1;
}

.graph-explainer-lead > span:last-child,
.graph-explainer-tip > span:last-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.graph-explainer strong {
  font-size: 0.88rem;
  line-height: 1.2;
}

.graph-explainer strong + span {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.graph-explainer-icon,
.graph-explainer-tip > .material-symbols-outlined {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border: 0px solid color-mix(in srgb, var(--explainer-accent, var(--color-primary)) 34%, transparent);
  border-radius: var(--radius-full);
  color: var(--explainer-accent, var(--color-primary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 27px;
}

.graph-explainer-icon {
  background: color-mix(in srgb, var(--color-primary) 22%, transparent) !important;
  color: #fff;
  /* box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary) 25%, transparent); */
}

body[data-view="trends"] .graph-explainer-drawer {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .node-cluster-panel,
  .sankey-page-preview,
  #flow-svg,
  .graph-explainer-drawer,
  .graph-explainer-toggle .material-symbols-outlined,
  .graph-summary {
    transition: none;
  }

  .graph-explainer-toggle.has-first-visit-hint {
    animation: none;
  }
}

@media (max-width: 800px) {
  .graph-explainer-tip:nth-child(4)
  {
    background-image: none;
  }

  .sankey-pagination {
    grid-template-columns: 70px minmax(0, 1fr) 70px;
  }

  .sankey-page-button {
    width: 70px;
    height: 70px;
  }
}

@media (max-width: 1100px) {
  :root {
    --sankey-panel-width: 390px;
  }

  #graph-layout {
    grid-template-columns: var(--sankey-panel-width) 220px var(--sankey-panel-width);
    column-gap: 110px;
  }

  .graph-summary {
    grid-template-columns: minmax(270px, 1fr) minmax(0, 734px);
    gap: 2rem;
  }

  .graph-summary-intro h1,
  .graph-summary-intro h2 {
    font-size: 1.5rem;
  }

  .graph-summary-intro p {
    font-size: 0.82rem;
    line-height: 1;
  }

  .summary-metric {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 9px;
    padding: 0 12px;
  }

  .summary-metric-icon {
    width: 42px;
    height: 42px;
    font-size: 23px;
  }

  .graph-explainer {
    grid-template-columns: minmax(290px, 1.5fr) repeat(2, minmax(170px, 1fr));
  }

  .graph-explainer-tip:last-child {
    display: none;
  }
}

@media (max-width: 900px) {
  #viz-root {
    padding-top: 12.5rem;
  }

  .graph-summary {
    top: 82px;
    display: block;
  }

  .graph-summary-intro {
    /* display: none; */
  }
}

@media (max-width: 799px) {
  .graph-explainer-drawer {
    --graph-explainer-bottom: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
  }

  .graph-explainer {
    min-height: 94px;
    padding: 14px 16px;
    grid-template-columns: minmax(0, 1fr);
  }

  .graph-explainer-tip {
    display: none;
  }
}

@media (max-width: 700px) {
  :root {
    --sankey-panel-width: 360px;
    --sankey-row-height: 52px;
  }

  .node-panel-carousel {
    --preview-step: 62px;
  }

  #viz-root {
    padding: 12.5rem 0.75rem 8.5rem;
  }

  .graph-summary {
    top: 82px;
    left: 0.75rem;
    right: 0.75rem;
    display: block;
  }

  .graph-summary-intro {
    /* display: none; */
  }

  .graph-summary-metrics {
    display: none;
    min-height: 92px;
    padding: 12px 4px;
  }

  .summary-metric {
    min-height: 72px;
    padding: 0 8px;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    border-radius: 12px;
  }

  .summary-metric-icon {
    display: none;
  }

  .summary-metric-label {
    font-size: 0.6rem;
  }

  .summary-metric strong {
    font-size: 0.9rem;
  }

  .summary-metric-detail {
    font-size: 0.58rem;
  }

  #graph-layout {
    grid-template-columns: var(--sankey-panel-width) 190px var(--sankey-panel-width);
    column-gap: 72px;
  }

  .node-cluster-header {
    min-height: 100px;
    padding: 16px 18px;
  }

  .flow-card {
    padding: 0 14px;
    gap: 10px;
  }

}

@media (max-width: 640px) {
  :root {
    --sankey-panel-width: min(288px, calc(100vw - 48px));
    --sankey-row-height: 88px;
  }

  #graph-layout {
    grid-template-columns: var(--sankey-panel-width) 170px var(--sankey-panel-width);
    column-gap: 40px;
  }

  .node-panel-carousel {
    --preview-step: 0px;
  }

  .incoming-panel-carousel .sankey-page-preview,
  .outgoing-panel-carousel .sankey-page-preview {
    left: 0;
    right: 0;
    transform: translateY(calc(var(--preview-depth, 1) * 5px))
      scale(calc(1 - var(--preview-depth, 1) * 0.018));
    transform-origin: center;
  }

  .incoming-panel-carousel.is-page-rotating-out .sankey-page-preview.is-selected-preview,
  .outgoing-panel-carousel.is-page-rotating-out .sankey-page-preview.is-selected-preview {
    transform: translate3d(0, 0, 80px) rotateY(0) scale(1);
  }

  #viz-root {
    padding-top: 15rem;
    padding-right: 0.25rem;
    padding-left: 0.25rem;
  }

  .graph-summary {
    top: 124px;
  }

  .graph-explainer {
    max-height: calc(100vh - 9rem);
    max-height: calc(100dvh - 9rem);
    padding: 10px 16px;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .graph-explainer-lead,
  .graph-explainer-tip,
  .graph-explainer-tip:last-child {
    min-height: 72px;
    margin: 0;
    padding: 10px 0;
    display: flex;
    align-self: auto;
  }

  .graph-explainer-tip::before {
    top: 0;
    width: 100%;
    height: 1px;
  }

  .graph-explainer-tip:nth-child(4) {
    margin-right: 0;
  }

  .graph-explainer-tip:nth-child(4) > span:last-child {
    max-width: none;
  }

  .graph-explainer-icon,
  .graph-explainer-tip > .material-symbols-outlined {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    font-size: 24px;
  }

  .flow-card {
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    grid-template-rows: auto auto;
    grid-template-areas:
      "icon title chevron"
      "icon amount chevron";
    align-content: center;
    gap: 0 10px;
  }

  .flow-card-icon {
    grid-area: icon;
  }

  .card-header {
    grid-area: title;
    align-self: end;
  }

  .card-header .card-name,
  .flow-card[data-flow-card-size="large"] .card-header .card-name {
    width: 100%;
    display: -webkit-box;
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .card-body {
    grid-area: amount;
    min-width: 0;
    align-self: start;
    align-items: baseline;
    justify-content: flex-start;
    flex-direction: row;
    gap: 0.35rem;
  }

  .card-amount,
  html[data-amount-format="compact"] .card-amount,
  html[data-amount-format="compact"] .flow-card[data-flow-card-size="large"] .card-amount {
    font-size: 1.3rem;
    white-space: nowrap;
  }

  .flow-card-chevron {
    grid-area: chevron;
  }
}
