/* =========================================================
   Base reset & variables
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* =========================================================
   Site title bar -- fixed chrome above everything else
   (sidebar + results area both sit below it), including the
   translation banner, which slots in just underneath it.
   ========================================================= */
#site-title-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--title-bar-h);
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}
#site-title-icon { flex-shrink: 0; display: block; }
#site-title-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The cycling word ("Fair" / one of TITLE_OTHER_WORDS): a fixed-width
   slot (sized in JS to the widest candidate word, so swapping in a
   longer or shorter word never reflows the rest of the title) with the
   word right-aligned inside it, so it always sits flush against
   "Fossil Fuel..." regardless of how much slack the slot has on a given
   word. */
.title-word-slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.3em;
  vertical-align: bottom;
}
.title-word-slot .title-word {
  position: absolute;
  top: 0;
  right: 0;
  white-space: nowrap;
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), opacity .35s ease;
}
/* Swiping up (Fair -> other word): incoming rises from below, outgoing
   exits upward. Swiping down (other word -> Fair): the reverse. */
.title-word-slot .title-word.title-word-entering-up {
  transform: translateY(100%);
  opacity: 0;
}
.title-word-slot .title-word.title-word-leaving-up {
  transform: translateY(-100%);
  opacity: 0;
}
.title-word-slot .title-word.title-word-entering-down {
  transform: translateY(-100%);
  opacity: 0;
}
.title-word-slot .title-word.title-word-leaving-down {
  transform: translateY(100%);
  opacity: 0;
}

/* =========================================================
   Translation banner
   ========================================================= */
#translation-banner {
  position: fixed;
  top: var(--title-bar-h);
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #fefce8;
  border-bottom: 1px solid #fde047;
  color: #713f12;
  font-size: 13px;
  line-height: 1.5;
}
#translation-banner[hidden] { display: none; }
#translation-banner-text { flex: 1; }
#translation-banner-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #713f12;
  padding: 0 0.25rem;
  opacity: 0.7;
}
#translation-banner-dismiss:hover { opacity: 1; }

/* Layout always sits below the title bar; push it down further still
   when the banner is also visible (class toggled by JS). */
.layout-split { height: calc(100vh - var(--title-bar-h)); margin-top: var(--title-bar-h); }
#splash-overlay { padding-top: var(--title-bar-h); }
/* --banner-h is measured from the banner's actual rendered height (see
   _updateBannerHeightVar() in main.js) -- some languages' translated
   text wraps to two lines where English fits on one, so a fixed
   estimate would undershoot and let the layout below overlap it. The
   2.75rem fallback only matters for the instant between first paint and
   that first measurement. */
body.banner-visible .layout-split { height: calc(100vh - var(--title-bar-h) - var(--banner-h, 2.75rem)); margin-top: calc(var(--title-bar-h) + var(--banner-h, 2.75rem)); }
body.banner-visible #splash-overlay { padding-top: calc(var(--title-bar-h) + var(--banner-h, 2.75rem)); }

@media (prefers-color-scheme: dark) {
  #translation-banner {
    background: #422006;
    border-color: #78350f;
    color: #fef3c7;
  }
  #translation-banner-dismiss { color: #fef3c7; }
}

:root {
  --title-bar-h: 48px;
  --sidebar-w: 320px;
  --sidebar-expanded-w: 100vw;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bg-sidebar: #f8fafc;
  --bg-main: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --tooltip-word-color: #0369a1;
  --radius: 6px;
  --transition: 0.25s ease;
  --positive: #15803d;
  --negative: #c2410c;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-main);
  height: 100vh;
  overflow: hidden;
}

/* =========================================================
   Layout
   ========================================================= */
.layout-split {
  display: flex;
  /* height/margin-top set near the top of this file, above the title
     bar's own rules -- kept together with the site-title-bar/banner
     positioning they depend on rather than duplicated here. */
}

/* =========================================================
   Sidebar
   ========================================================= */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
  z-index: 10;
}

#sidebar.expanded {
  width: 60vw;
  min-width: 60vw;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9;
}
#sidebar-overlay.visible { display: block; }

#sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

#sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#lang-picker {
  position: relative;
}

#lang-current {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
#lang-current:hover { background: var(--border); color: var(--text); }

#lang-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  z-index: 100;
  min-width: 100%;
  overflow: hidden;
}
#lang-dropdown[hidden] { display: none; }

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  padding: 7px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.lang-option:hover { background: #f1f5f9; }

#lang-picker svg { display: block; flex-shrink: 0; border-radius: 2px; }

#expand-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
#expand-btn:hover { background: var(--border); color: var(--text); }

/* =========================================================
   Form fields
   ========================================================= */
.field-block {
  margin-bottom: 20px;
}

.field-block label,
.slider-group-fieldset legend {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
select:disabled { opacity: 0.55; cursor: not-allowed; }

/* Sliders */
.slider-with-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.55; cursor: not-allowed; }

.slider-value-display {
  min-width: 42px;
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Radio group */
.radio-group-fieldset,
.radio-mirror-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  margin: 0;
}
.radio-group-fieldset legend,
.radio-mirror-fieldset legend {
  padding: 0 6px;
  font-weight: 600;
  line-height: 1.4;
}
.radio-mirror-fieldset .radio-mirror-select {
  margin-top: 2px;
}
.field-block label.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.4;
  color: var(--text);
}
.field-block label.radio-option input[type="radio"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Slider group */
.slider-group-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
}
.slider-group-fieldset legend {
  padding: 0 6px;
}
.slider-group-row {
  margin-top: 10px;
}
.slider-group-row label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Field explanation: short version (collapsed sidebar) */
.field-explanation-short {
  margin-top: 2px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: normal;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Field explanation: long version (expanded sidebar) */
.field-explanation {
  margin-top: 8px;
  padding: 8px 10px;
  background: #eff6ff;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}

/* =========================================================
   Main results area — flex column, holds tab-bar + tab-panels
   ========================================================= */
#results-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
   Tab bar
   ========================================================= */
#tab-bar {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
#tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* =========================================================
   Tab panels
   ========================================================= */
#tab-panels {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 24px 32px;
}

.advanced-fields { max-width: 480px; }

.placeholder-text {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 40px;
}

/* =========================================================
   Chart toolbar: country picker, fuel picker, remove-elements toggle
   ========================================================= */
#chart-toolbar,
#stack-chart-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.picker {
  position: relative;
  display: inline-block;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.toolbar-btn:hover { background: var(--bg-sidebar); border-color: var(--accent); }
.toolbar-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.toolbar-btn.active:hover { background: var(--accent-hover); }

/* Remove Elements is destructive (it hides chart glyphs), so its "on"
   state uses the warning colour instead of the generic accent above. */
#remove-elements-btn.active {
  background: var(--negative);
  border-color: var(--negative);
}
#remove-elements-btn.active:hover { background: var(--negative); }

#cp-count, #fp-count, #traces-count, #sp-count { color: var(--text-muted); font-weight: normal; }

.picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  width: 300px;
  max-height: 440px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.picker-dropdown[hidden] { display: none; }

.cp-section { padding: 8px 0 4px; }
.cp-section + .cp-section { border-top: 1px solid var(--border); }

.cp-section-title {
  padding: 2px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.cp-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.cp-label:hover { background: #f1f5f9; }
.cp-label input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }
.cp-group { font-weight: 600; }

.dl-dropdown {
  width: 170px;
  max-height: none;
  padding: 4px 0;
}
.dl-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.dl-menu-item:hover { background: #f1f5f9; }

.picker-search {
  display: block;
  width: calc(100% - 24px);
  margin: 4px 12px 6px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}
.picker-search:focus { border-color: var(--accent); }

.fp-fuel-icon {
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
  flex-shrink: 0;
}

#results-placeholder {
  color: var(--text-muted);
  margin-top: 60px;
  text-align: center;
  font-size: 15px;
}

.results-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Debug section */
#debug-section {
  margin-bottom: 20px;
  font-size: 11px;
  color: #94a3b8;
}
#debug-section > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: #94a3b8;
  font-size: 11px;
}
#debug-section > summary::before { content: '▶ '; }
#debug-section[open] > summary::before { content: '▼ '; }

#debug-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.debug-group { }
.debug-group-title {
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.6;
}
.debug-key { color: #94a3b8; }
.debug-val { color: #475569; font-variant-numeric: tabular-nums; text-align: right; }

/* =========================================================
   Country Details tab
   ========================================================= */
#cd-dev-notice {
  color: #dc2626;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 14px;
}

#cd-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.cd-country-block {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.cd-country-block:last-child { border-bottom: none; }

.cd-country-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  margin: 0 0 14px;
}
.cd-country-title .cd-flag { font-size: 26px; line-height: 1; }

.cd-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text);
}

.cd-overview-table th,
.cd-support-table th,
.cd-phaseout-table th:first-child { width: 360px; }

/* Shared indentation style for a row that's a sub-item of the row above
   it (e.g. "Fossil Fuels Extracted" under "Country Group") -- applies
   across every Country Details table, not just the Overview one. */
tr.cd-indent-row th {
  padding-left: 28px;
  font-weight: 400;
  color: var(--text-muted);
}

.cd-dependence-table th, .cd-dependence-table td,
.cd-phaseout-table th, .cd-phaseout-table td { text-align: center; }
.cd-dependence-table th:first-child, .cd-dependence-table td:first-child,
.cd-phaseout-table th:first-child, .cd-phaseout-table td:first-child {
  text-align: left;
  width: 360px;
}

.cd-phaseout-charts {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 14px 0 4px;
}
.cd-fuel-chart-block { flex: 0 0 auto; }
.cd-fuel-chart-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-align: center;
}
.cd-fuel-chart { width: 260px; height: 150px; display: block; }
.cd-chart-axis, .cd-chart-tick { stroke: var(--border); stroke-width: 1; }
.cd-chart-tick-label { font-size: 9px; fill: var(--text-muted); }
.cd-chart-axis-title { font-size: 9px; font-weight: 600; fill: var(--text-muted); }
.cd-chart-line { fill: none; stroke-width: 2; }
.cd-chart-hit-area { fill: none; stroke: transparent; stroke-width: 14; cursor: crosshair; }
.cd-chart-marker { stroke: #fff; stroke-width: 1.5; }
.cd-chart-marker[hidden] { display: none; }

/* Tables */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 8px;
}
.result-table th, .result-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
}
.result-table th { background: #f1f5f9; font-weight: 600; }
.result-table tr:hover td { background: #f8fafc; }

#results-tables h3, .dev-chart-table h3 {
  margin: 24px 0 8px;
  font-size: 14px;
  color: var(--text);
}
#results-tables h3:first-child { margin-top: 0; }
.dev-chart-table { margin-top: 8px; }
.dev-chart-table table { max-width: 100%; }
.dev-chart-table td { font-variant-numeric: tabular-nums; }

.no-data {
  color: var(--text-muted);
  font-size: 13px;
  margin: 12px 0;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

#results-loading {
  text-align: center;
  margin-top: 60px;
  color: var(--text-muted);
}

#results-error {
  margin-top: 60px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  color: #b91c1c;
  font-size: 13px;
}

/* =========================================================
   Support tab
   ========================================================= */
.support-content {
  max-width: 720px;
}
.support-heading {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}
.support-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 24px;
}
.support-text ul {
  margin: 10px 0 10px 20px;
}
.support-text li {
  margin-bottom: 8px;
}
.support-content .field-block {
  margin-bottom: 28px;
  max-width: 480px;
}

/* =========================================================
   Splash screen
   ========================================================= */
#splash-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
#splash-overlay[hidden] { display: none; }

#splash-card {
  width: 60%;
  max-height: 60vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#splash-content {
  padding: 32px 36px 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
#splash-content p { margin-bottom: 1em; }
#splash-content p:last-child { margin-bottom: 0; }
#splash-content ul { margin: 0.25em 0 1em 1.5em; }
#splash-content li { margin-bottom: 0.5em; }

#splash-footer {
  padding: 16px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  flex-shrink: 0;
}

#splash-lang-picker {
  position: relative;
}

#splash-lang-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -4px 12px rgba(0,0,0,.1);
  z-index: 100;
  min-width: 100%;
  overflow: hidden;
}
#splash-lang-dropdown[hidden] { display: none; }

#splash-close {
  padding: 10px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
#splash-close:hover { background: var(--accent-hover); }

/* =========================================================
   Tooltip words  [[text|id]]
   ========================================================= */
.tooltip-word {
  color: var(--tooltip-word-color);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
  cursor: help;
}
/* A tooltip-word whose text is itself a link (e.g. a "Caveats" citation) --
   let the dashed tooltip-word underline carry the whole styling rather
   than stacking the browser's own solid link underline on top of it. */
.tooltip-word a {
  color: inherit;
  text-decoration: inherit;
}

/* =========================================================
   Tooltip popup
   ========================================================= */
#tooltip-popup {
  position: fixed;
  z-index: 1000;
  max-width: 360px;
  background: #1e293b;
  color: #f8fafc;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
}
#tooltip-popup[hidden] { display: none; }

#tooltip-popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.tooltip-table {
  border-collapse: collapse;
  font-size: 12px;
}
.tooltip-table td {
  padding: 2px 0;
  vertical-align: top;
  white-space: nowrap;
}
.tooltip-table td:first-child {
  white-space: normal;
  padding-right: 10px;
  color: #cbd5e1;
}
.tooltip-table td:nth-child(2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
}
.tooltip-table td:nth-child(3) {
  color: #94a3b8;
}

/* =========================================================
   Scatter chart (capacity per capita vs. phaseout year)
   ========================================================= */
#scatter-chart {
  margin: 4px 0 28px;
}

.scatter-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: inherit;
}

.chart-axis-label {
  font-size: 12px;
  font-weight: 700;
  cursor: help;
}
.chart-axis-label.provides { fill: var(--positive); }
.chart-axis-label.needs    { fill: var(--negative); }

.chart-axis-arrow {
  fill: none;
  stroke-width: 1.5;
  cursor: help;
  pointer-events: all; /* fill:none shapes only hit-test their stroke by default -- make the whole outline's interior clickable/hoverable too */
}
.chart-axis-arrow.provides { stroke: var(--positive); }
.chart-axis-arrow.needs    { stroke: var(--negative); }

.chart-avg-line {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}
.chart-avg-label {
  font-size: 11px;
  fill: var(--text-muted);
  cursor: help;
}

.chart-axis-tick {
  font-size: 10px;
  fill: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
}
/* Multiples of 5 not part of the chart's normal tick set: rendered but
   invisible until a hovered area snaps to that year (see
   _highlightAxisYear() in main.js), then revealed bold via
   .chart-axis-tick--active -- same position, no re-render needed. Shared
   by the tick <text> and its .chart-axis-tick-bg backing <rect> (below),
   so the opacity toggle is tag-agnostic; the bold/ink recolor only makes
   sense for the text. */
.chart-axis-tick-extra {
  opacity: 0;
}
.chart-axis-tick--active {
  opacity: 1 !important;
}
text.chart-axis-tick--active {
  font-weight: 700;
  fill: var(--text);
}
.chart-axis-tickmark {
  stroke: var(--text-muted);
  stroke-width: 1;
}
/* Backing rect for a hover-revealed extra tick, so its label stays
   legible even when it lands over another (always-visible) label --
   hidden at rest, revealed together with its text via the shared
   .chart-axis-tick--active rule above. */
.chart-axis-tick-bg {
  fill: var(--bg-main);
  opacity: 0;
  pointer-events: none;
}
.chart-break-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.chart-break-slash {
  stroke: var(--text-muted);
  stroke-width: 2;
}

.chart-point {
  cursor: pointer;
}
#scatter-chart.remove-mode .chart-point { cursor: crosshair; }
#scatter-chart.remove-mode .chart-point:hover use { opacity: .25 !important; }
.chart-point-label {
  font-size: 9px;
  font-weight: 600;
  fill: var(--text-muted);
  pointer-events: none;
}

/* Traces: grey "ghost" history left by earlier scenarios (see the
   Use Traces toggle). Purely decorative -- no hover/click behaviour --
   so both the dots and the connecting arrows opt out of pointer events
   entirely, unlike the live glyphs they trail behind. */
.chart-trace-dot {
  fill: #888;
  pointer-events: none;
}
.chart-trace-arrow {
  stroke: #888;
  stroke-width: 1.5;
  fill: none;
  pointer-events: none;
}

.chart-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 0;
  text-align: center;
}
.chart-empty-msg {
  fill: var(--text-muted);
  font-size: 12px;
  text-anchor: middle;
}

/* =========================================================
   Stacked area chart (emissions decay by country/fuel)
   ========================================================= */
#stacked-area-chart {
  margin: 4px 0 28px;
}

.stack-area-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: inherit;
}

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

.stack-axis-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-muted);
}

.stack-y-tick {
  text-anchor: end;
}

.stack-area {
  cursor: pointer;
}
.stack-area:hover,
.stack-area:focus-visible {
  opacity: 0.85;
}

.stack-bar {
  cursor: pointer;
}
.stack-bar:hover,
.stack-bar:focus-visible {
  opacity: 0.85;
}

/* The break "cut" through the stacked bands: a thick surface-color line
   painted over the areas, with the thinner dashed .chart-break-line drawn
   on top of it (see renderStackedAreaChart()). */
.stack-break-gap {
  stroke: var(--bg-main);
  stroke-width: 5;
}

.stack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.stack-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.stack-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
