:root {
  --bg: #0e1116;
  --panel: #161b22;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #e69a37;
  --emis: #5b9bd5;
  --cost: #2e8b57;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

#app { max-width: 1200px; margin: 0 auto; padding: 16px 20px 48px; }

header h1 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }

/* D67 (2026-05-26): top row of the header — page title on the left,
   account widget on the right. The widget collapses to a small chip on
   narrow screens. */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.account-header { display: flex; align-items: center; }
.account-header-placeholder {
  display: inline-block;
  min-width: 60px;
  height: 28px;
  color: transparent;
}
.account-header-signin {
  /* Inherits .view-btn .small .primary. Just makes sure the corner-of-page
     chip lines up with the page title visually. */
  margin-top: 2px;
}
.account-header-menu {
  position: relative;
}
.account-header-menu > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 999px;
  user-select: none;
}
.account-header-menu > summary::-webkit-details-marker { display: none; }
.account-header-menu > summary:hover { border-color: var(--accent); }
.account-header-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid #30363d;
}
.account-header-name {
  font-size: 12px; font-weight: 600; color: var(--fg);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-header-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 8px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.account-header-email {
  font-size: 11px; color: var(--muted); padding: 2px 6px 6px;
  border-bottom: 1px solid #30363d; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-header-action {
  background: transparent;
  color: var(--fg);
  border: none;
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit; font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.account-header-action:hover:not(:disabled) { background: #1c2128; }
.account-header-action:disabled { color: var(--muted); cursor: default; }
.account-header-signout { color: #d97757; }

.toolbar { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.view-buttons, .values-toggle { display: flex; gap: 8px; flex-wrap: wrap; }

/* U-10: region dropdown picker (replaces the 50-button grid) */
.region-picker { display: flex; align-items: center; }
.region-select {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.region-select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.region-select option { background: var(--panel); color: var(--fg); }

/* U-12: year slider sits directly above the chart instead of in the toolbar */
.year-slider-above-chart {
  margin: 4px 0 8px;
  padding: 6px 12px 12px;
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
}

.year-slider { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.year-slider-track {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
}
.year-slider-track input[type="range"] {
  flex: 1;
  width: 100%;
  accent-color: var(--accent);
}
.year-boundary-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--muted);
  pointer-events: none;
  transform: translateX(-1px);
  opacity: 0.6;
  z-index: 1;
}
.year-boundary-marker::after {
  content: "projection →";
  position: absolute;
  left: 4px;
  bottom: -14px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-style: italic;
}
.year-slider .year-display {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
  min-width: 10ch;
  text-align: right;
}
.year-slider .year-display.projected {
  color: var(--muted);
  font-style: italic;
}
.year-slider .year-bounds {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.year-slider .year-range-subtitle {
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  margin-left: 12px;
  flex-basis: 100%;
  text-align: right;
}

.view-btn {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.view-btn:hover:not(:disabled) { border-color: var(--accent); }
.view-btn.active { background: var(--accent); color: #1a1200; border-color: var(--accent); }
.view-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* B-22: meta line is a row of discrete chips, not one dense text string */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
}
.meta-chip {
  background: #1a1f26;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 2px 9px;
  font-size: 11px;
  color: var(--muted);
}
.meta-chip.meta-source { font-variant-numeric: tabular-nums; }
.meta-chip.projected { color: var(--accent); border-color: rgba(230, 154, 55, 0.4); }
.meta-chip.scenario { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.meta-chip.warn { color: #f0b429; border-color: rgba(240, 180, 41, 0.4); }

/* B-17: grid-reliability banner — surfaces unserved energy on brownout years */
/* Calm informational note (not an alarm box) — surfaces the model's
   supply-gap diagnostic without the jarring full-amber treatment. */
.reliability-banner {
  margin: 0 0 12px;
  padding: 7px 12px;
  border-left: 3px solid rgba(240, 180, 41, 0.55);
  border-radius: 0 6px 6px 0;
  background: rgba(240, 180, 41, 0.05);
  color: var(--fg);
  font-size: 12px;
  line-height: 1.5;
}
.reliability-banner.severe {
  border-left-color: rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.05);
}
.reliability-banner strong { font-weight: 600; color: #d8a43a; }
.reliability-banner.severe strong { color: #e26d6d; }

/* Item 7: scenario-vs-default impact deltas, above the chart */
.impact-delta {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.impact-delta-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 8px;
}
.impact-delta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.impact-card {
  background: #0e1116;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 10px;
}
.impact-card-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.impact-card-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.impact-card-delta {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  color: var(--muted);
}
.impact-card-delta.up { color: #e0833a; }
.impact-card-delta.down { color: #3fb98a; }
.impact-card-delta.flat { color: var(--muted); font-style: italic; }

/* B-20: color legend for the source fuels + Storage/Hydrogen carriers */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  font-size: 11px;
  color: var(--muted);
}
.legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

/* Item 5: Quads-to-familiar-units callout — sits below the legend so
   the chart's Quad numbers have an everyday-scale anchor. */
.quad-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  font-size: 12px;
}
.quad-callout-lead {
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.quad-chip { color: var(--fg); }
.quad-chip strong { font-variant-numeric: tabular-nums; }
.quad-chip-sub { color: var(--muted); font-size: 11px; }
.quad-chip-fun strong { color: var(--accent); }
.quad-callout-foot {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

.panel {
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 8px 12px;
}
.panel summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px 18px;
  margin-top: 10px;
}
.control-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; }
.control-name { color: var(--muted); }
.control-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.control-row output { text-align: right; font-variant-numeric: tabular-nums; }

/* 2026-05-26: replaces the Consumption/Emissions/Cost toggle. Sits
   directly above the SVG; carries "<region> · <year> consumption" on the
   left and the live total in Quads on the right. */
.chart-title {
  margin: 0 0 6px;
  padding: 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  /* 2026-05-26: head + value grouped in the middle, separated by the
     standard gap. Was space-between which pinned them to opposite
     edges of the chart. */
  justify-content: center;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
}
.chart-title-head { color: var(--fg); }
.chart-title-value {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.chart, .trend-chart {
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 8px;
}
.trend-chart { padding: 12px 14px 8px; }
.trend-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 4px;
}
.trend-title {
  margin: 0; font-size: 14px; font-weight: 600; color: var(--fg);
}
.trend-metric-label {
  font-size: 12px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.trend-metric-select {
  background: #0e1116; color: var(--fg);
  border: 1px solid #30363d; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; cursor: pointer;
}
.trend-metric-select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.trend-plot { width: 100%; }
.trend-foot {
  margin: 4px 0 0; font-size: 11px; color: var(--muted);
}
.trend-key { font-weight: 600; }
.trend-key-scenario { color: var(--accent); }
.trend-key-default { color: var(--muted); }
.trend-key + .trend-key { margin-left: 10px; }
.trend-svg { display: block; width: 100%; height: auto; color: var(--muted); }
.trend-svg .trend-line { fill: none; stroke-width: 2.5; }
.trend-svg .trend-line.default { stroke: var(--muted); stroke-width: 1.8; stroke-dasharray: 5 4; }
.trend-svg .trend-line.scenario { stroke: var(--accent); }
.trend-svg .trend-marker { stroke: var(--fg); stroke-opacity: 0.5; stroke-dasharray: 3 3; }
.trend-svg .trend-dot.default { fill: var(--muted); }
.trend-svg .trend-dot.scenario { fill: var(--accent); }
.trend-svg .trend-marker-label { fill: var(--fg); font-size: 11px; font-weight: 600; }
.trend-svg .trend-axis-title { fill: var(--muted); font-size: 10px; }
.trend-svg text { fill: currentColor; font-size: 10px; }
.trend-svg .domain, .trend-svg .tick line { stroke: #30363d; }
.trend-svg .trend-grid .tick line { stroke: #20262d; }
.trend-svg .trend-grid .domain { stroke: none; }

.empty { color: var(--muted); padding: 24px; }

.pruned-note {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  margin: 4px 12px 12px;
  padding: 6px 10px;
  border-left: 2px solid rgba(255, 200, 0, 0.4);
  background: rgba(255, 200, 0, 0.04);
}

/* U-06: Methodology panel — explains EIA captured-energy convention
   plus v2model projection-side caveats. Collapsed by default. */
.methodology-panel summary { color: var(--fg); font-size: 13px; font-weight: 600; }
.methodology-body { padding: 8px 0 4px; font-size: 12px; line-height: 1.55; color: var(--fg); }
.methodology-body p { margin: 0 0 10px; }
.methodology-body a { color: var(--accent); }
.methodology-body code {
  font-family: ui-monospace, monospace;
  background: #0e1116;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.methodology-body .methodology-fineprint { color: var(--muted); font-size: 11px; }

/* Orientation block under the header (added 2026-05-26). Visually calmer
   than the panels — no border, just a tinted band — so it reads as
   "context" not "control". Lead paragraph at body-size, details opens to
   smaller meta text. */
.intro {
  margin: 8px 0 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #161b22 0%, #131820 100%);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  display: flex;
  gap: 18px;
  align-items: stretch;
  flex-wrap: wrap;
}
.intro-text { flex: 1 1 380px; min-width: 0; }

/* Brief assistant callout, filling the empty right side of the intro band. */
.intro-assistant {
  flex: 0 1 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(230, 154, 55, 0.06);
  border: 1px solid rgba(230, 154, 55, 0.35);
  border-radius: 6px;
}
.intro-assistant-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.intro-assistant-body { margin: 0; font-size: 12px; line-height: 1.5; color: var(--fg); }
.intro-assistant-body em { font-style: italic; color: var(--muted); }
.intro-assistant-btn {
  align-self: flex-start;
  margin-top: auto;
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #1a1205;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.intro-lead {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg);
  max-width: 78ch;
}
.intro-lead strong { color: var(--accent); font-weight: 600; }
.intro-lead em { font-style: italic; color: var(--fg); }
.intro-arch-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 10px 0 4px;
  padding: 8px 14px; border-radius: 8px;
  background: rgba(230, 154, 58, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent); font-weight: 600; font-size: 13px;
  text-decoration: none; line-height: 1.3;
  transition: background 0.15s, transform 0.05s;
}
.intro-arch-link:hover { background: rgba(230, 154, 58, 0.22); }
.intro-arch-link:active { transform: translateY(1px); }
.intro-more { margin-top: 8px; }
.intro-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}
.intro-more summary:hover { color: var(--fg); }
.intro-more-body {
  padding: 6px 0 2px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg);
  max-width: 78ch;
}
.intro-more-body p { margin: 0 0 8px; }
.intro-more-body p:last-child { margin-bottom: 0; }
.intro-more-body em { color: var(--accent); font-style: normal; }

/* D67 account section in the basket pane — sign-in CTA when anonymous,
   identity badge + sign-out when authenticated. Sits above the saved-
   baskets list. */
.account-section {
  margin-top: 12px;
  padding: 8px 10px;
  background: #0e1116;
  border: 1px solid #30363d;
  border-radius: 6px;
  font-size: 12px;
}
.account-signin-cta { display: flex; flex-direction: column; gap: 6px; }
.account-signin-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.account-blurb { margin: 0; color: var(--muted); line-height: 1.5; }
.account-blurb strong { color: var(--fg); font-weight: 600; }
.account-head { display: flex; align-items: center; gap: 10px; }
.account-identity { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.account-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid #30363d; flex-shrink: 0;
}
.account-who { display: flex; flex-direction: column; min-width: 0; }
.account-name { color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { color: var(--muted); font-size: 11px; }
.account-import-prompt {
  margin-top: 8px;
  padding: 8px;
  background: #161b22;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  display: flex; flex-direction: column; gap: 6px;
}
.account-import-prompt p { margin: 0; color: var(--fg); line-height: 1.5; }

/* Scenario builder — three-pane layout */
.scenario-panel summary { color: var(--fg); font-size: 13px; font-weight: 600; }
.scenario-status { color: var(--muted); font-weight: 400; font-size: 12px; }
.scenario-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 2fr) minmax(240px, 1fr);
  gap: 12px;
  margin-top: 12px;
  min-height: 320px;
}
.scenario-pane {
  background: #0e1116;
  border: 1px solid #30363d;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: 480px;
}
.scenario-pane-title {
  margin: 0;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid #30363d;
}
.scenario-pane-body { padding: 8px 12px; overflow-y: auto; flex: 1; font-size: 12px; }
.scenario-empty { color: var(--muted); font-style: italic; margin: 6px 0; }
.scenario-err { color: #f87171; font-style: italic; margin-top: 6px; display: block; }

/* Out-of-range "may be unrealistic" acknowledgment gate (basket pane). */
.unrealistic-gate {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(230, 154, 58, 0.10);
}
.unrealistic-gate-title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}
.unrealistic-gate-intro {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--fg);
  line-height: 1.4;
}
.unrealistic-gate-list {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 12px;
  color: var(--fg);
  line-height: 1.5;
}
.unrealistic-gate-list strong { color: var(--accent); }
.unrealistic-gate-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.catalog-cat, .catalog-sub { margin: 4px 0; }
.catalog-cat > summary { padding: 4px 0; font-weight: 600; color: var(--fg); cursor: pointer; }
.catalog-sub > summary { padding: 3px 0 3px 12px; color: var(--muted); cursor: pointer; font-size: 11px; }
.catalog-levers { list-style: none; padding: 0 0 0 24px; margin: 4px 0; }
.catalog-lever-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  text-align: left;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  width: 100%;
  font-size: 12px;
}
.catalog-lever-btn:hover { background: #1a1f26; }
.catalog-lever-btn.active { background: #1a1f26; outline: 1px solid var(--accent); }
.catalog-lever-btn.overridden { color: var(--accent); font-weight: 600; }
.catalog-lever-btn.overridden::before { content: "● "; }

.editor-header h4 { margin: 0; font-size: 13px; }
.editor-sub { color: var(--muted); font-size: 11px; margin: 2px 0 8px; font-family: ui-monospace, monospace; }
.editor-desc { color: var(--fg); font-size: 12px; line-height: 1.5; margin: 0 0 8px; }

/* Item 7: plain-English example callout in the editor pane */
.editor-example {
  color: var(--fg);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-left: 2px solid var(--accent);
  background: rgba(230, 154, 55, 0.06);
  border-radius: 0 4px 4px 0;
}
/* Item 6: current-default line in the editor pane */
.editor-default {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 11px;
}
.editor-default-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}
.editor-default-value {
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-weight: 600;
}
.editor-form { display: grid; gap: 8px; margin-bottom: 8px; }
.editor-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; }
.editor-row-label { color: var(--muted); font-size: 11px; }
.editor-unit-suffix { color: var(--muted); font-size: 12px; font-weight: 600; }
.editor-row select,
.editor-row input[type="number"] {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: var(--fg);
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
}
.editor-row input[type="number"]:focus,
.editor-row select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.editor-hint { color: var(--muted); font-size: 11px; font-style: italic; margin: 4px 0; }
.editor-actions { display: flex; gap: 8px; margin-top: 12px; }

/* G + H: input-mode tabs in the editor pane (Scalar / Steps / Curve) */
.editor-tabs {
  display: flex;
  gap: 0;
  margin: 8px 0;
  border-bottom: 1px solid #30363d;
}
.editor-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.editor-tab:hover { color: var(--fg); }
.editor-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.editor-sub-container { margin: 8px 0; }

/* G: step-function table */
.step-editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin: 8px 0;
}
.step-editor-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  padding: 4px 6px;
  border-bottom: 1px solid #30363d;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.step-editor-table td { padding: 4px 6px; }
.step-editor-table input {
  width: 100%;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: var(--fg);
  padding: 3px 6px;
  font: inherit;
  font-size: 11px;
}
.step-editor-table td:last-child { width: 28px; text-align: center; }

/* H: curve editor SVG */
.curve-editor-svg {
  width: 100%;
  height: auto;
  display: block;
  background: #0e1116;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}
.curve-editor-svg .curve-bg { fill: #161b22; }
.curve-editor-svg .curve-zero {
  stroke: #30363d;
  stroke-dasharray: 2 2;
  stroke-width: 1;
}
.curve-editor-svg .curve-tick {
  fill: var(--muted);
  font-size: 9px;
}
.curve-editor-svg .curve-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.curve-editor-svg .curve-point-label {
  fill: var(--fg);
  font-size: 9px;
  pointer-events: none;
}
.curve-editor-svg .curve-handle {
  fill: var(--accent);
  stroke: #1a1200;
  stroke-width: 1.5;
  cursor: grab;
  touch-action: none;
}
.curve-editor-svg .curve-handle:hover { fill: #ffb84d; stroke: #fff; }
.curve-editor-svg .curve-handle:active { cursor: grabbing; }
.view-btn.primary { background: var(--accent); color: #1a1200; border-color: var(--accent); font-weight: 600; }
.view-btn.primary:disabled { background: #30363d; color: #6e7681; border-color: #30363d; }
.view-btn.small { padding: 2px 8px; font-size: 11px; }

.basket-list { list-style: none; padding: 0; margin: 0; }
.basket-item {
  padding: 8px;
  margin-bottom: 6px;
  background: #161b22;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}
.basket-item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.basket-item-label { font-weight: 600; font-size: 12px; color: var(--fg); }
.basket-item-detail { margin: 4px 0 0; color: var(--accent); font-family: ui-monospace, monospace; font-size: 11px; }
.basket-item-path { margin: 2px 0 0; color: var(--muted); font-family: ui-monospace, monospace; font-size: 10px; word-break: break-all; }
.basket-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #30363d; }

/* Item 9: named-basket library in the basket pane */
.saved-baskets { margin-top: 12px; padding-top: 12px; border-top: 1px solid #30363d; }
.saved-baskets-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}
.saved-basket-list { list-style: none; padding: 0; margin: 8px 0 0; }
.saved-basket-item { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.saved-basket-name {
  flex: 1;
  font-size: 11px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-pane { min-height: 240px; max-height: 360px; }
}

/* sankey */
.sankey-svg { display: block; width: 100%; height: auto; }
.sankey-svg .node-label, .sankey-svg .link-value {
  pointer-events: none;
  font-family: Arial, Helvetica, "Helvetica Neue", sans-serif;
}
.sankey-svg .node-name { font-weight: 700; }
.sankey-svg .node-value { font-weight: 700; opacity: 0.85; }
.sankey-svg .link-value { font-weight: 700; fill: #111; }
.sankey-svg path { transition: stroke-opacity 0.15s; }
.sankey-svg path:hover { stroke-opacity: 0.75; }
.sankey-svg .node-hit { cursor: pointer; }
.sankey-svg path { cursor: pointer; }

.sankey-tooltip {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 1000;
  background: #1a1f26;
  color: var(--fg);
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 6px 10px;
  font: 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.sankey-tooltip .tip-title { color: var(--accent); font-weight: 600; }
.sankey-tooltip .tip-value { color: var(--fg); font-variant-numeric: tabular-nums; }
.sankey-tooltip .tip-arrow { color: var(--muted); padding: 0 4px; }
.sankey-tooltip .tip-note {
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  display: inline-block;
  max-width: 280px;
  white-space: normal;
  margin-top: 2px;
}

/* D68 Phase 3: rich tooltip surface — generation-source cost+emissions
   panel with the [Details ▾] / × pinning affordance. */
.sankey-tooltip .tip-extras {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.sankey-tooltip .tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 6px;
  margin-bottom: 4px;
}
.sankey-tooltip .tip-close {
  cursor: pointer;
  color: var(--muted);
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
  user-select: none;
}
.sankey-tooltip .tip-close:hover { color: var(--fg); }
.sankey-tooltip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 1px 0;
}
.sankey-tooltip .tip-row-key {
  color: var(--muted);
  font-size: 11px;
}
.sankey-tooltip .tip-row-val {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.sankey-tooltip .tip-row-units {
  color: var(--muted);
  font-size: 10px;
}
.sankey-tooltip .tip-row-effective {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #30363d;
}
.sankey-tooltip .tip-row-effective .tip-row-val { font-weight: 600; }
.sankey-tooltip .tip-hint {
  margin-top: 6px;
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  font-style: italic;
}
.sankey-tooltip .tip-row-muted {
  color: var(--muted);
  font-style: italic;
  font-size: 11px;
}
.sankey-tooltip .tip-dest-note {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #30363d;
  font-size: 10.5px;
  color: var(--muted);
  font-style: italic;
  white-space: normal;
}
.sankey-tooltip .tip-section-header {
  margin: 8px 0 2px 0;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sankey-tooltip .tip-row-note {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  margin: 1px 0 4px 6px;
  white-space: normal;
}
/* Pinned (expanded) state lets the user click inside the tooltip. */
.sankey-tooltip.pinned {
  pointer-events: auto;
  max-width: 380px;
  white-space: normal;
}
.sankey-tooltip.pinned .tip-row { padding: 2px 0; }
.sankey-tooltip .tip-consumption {
  color: var(--muted);
  font-size: 11px;
  margin: -2px 0 6px 6px;
}
.sankey-tooltip .tip-citations,
.sankey-tooltip .tip-method,
.sankey-tooltip .tip-assumptions {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #30363d;
  color: var(--muted);
  font-size: 10.5px;
}
.sankey-tooltip .tip-citations strong,
.sankey-tooltip .tip-method strong {
  color: var(--fg);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}
.sankey-tooltip .tip-citations ul {
  margin: 0;
  padding-left: 16px;
}
.sankey-tooltip .tip-citations li { margin: 2px 0; }
.sankey-tooltip .tip-method-note { margin: 2px 0; font-style: italic; }
.sankey-tooltip .tip-assumptions { font-style: italic; }

/* Quality badges. L1 = primary federal/IEA-grade data; L2 = derived
   from L1; L3 = peer-reviewed literature; L4 = transcribed unverified
   (carries a warning-color cue). */
.sankey-tooltip .quality-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 700;
  text-align: center;
  color: #111;
  vertical-align: middle;
  line-height: 14px;
}
.sankey-tooltip .quality-badge.q-L1 { background: #4ade80; }   /* green */
.sankey-tooltip .quality-badge.q-L2 { background: #bef264; }   /* yellow-green */
.sankey-tooltip .quality-badge.q-L3 { background: #fbbf24; }   /* amber */
.sankey-tooltip .quality-badge.q-L4 { background: #fb923c; color: #fff; }  /* orange + warning cue */

/* D68 Phase 3 projection marker — shown next to a value the engine
   recomputed for the current projection year (Wright's law + policy +
   fuel-cost updates). Distinguishes engine-derived from static-research. */
.sankey-tooltip .tip-proj {
  color: var(--accent);
  font-size: 11px;
  vertical-align: middle;
  cursor: help;
}

/* ── D69 P2: scenario assistant (right-docked hideable chat column) ── */
.assistant-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  padding: 10px 16px;
  border: 1px solid var(--accent, #2f81f7);
  border-radius: 22px;
  background: var(--accent, #2f81f7);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.assistant-toggle.is-open { opacity: 0.55; }

.assistant-pane {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--asst-w, 400px);
  max-width: 96vw;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid #30363d;
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.4);
  padding: 12px 14px;
  box-sizing: border-box;
}
.assistant-pane[hidden] { display: none; }

/* Push the page left so the pane sits beside it (no overlap), rather than
   floating over the chart + scenario builder. #app is centered max-width;
   reserving right-margin reflows it into the remaining space. */
#app { transition: margin-right 0.2s ease; }
body.assistant-open #app { margin-right: var(--asst-w, 400px); }
body.assistant-open .assistant-toggle { display: none; }

.asst-header { display: flex; align-items: center; gap: 8px; }
.asst-title { font-weight: 700; }
.asst-tier {
  font-size: 0.72rem;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 1px 8px;
}
.asst-skip {
  margin-left: auto;
  background: none;
  border: 1px solid #30363d;
  border-radius: 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 2px 9px;
  cursor: pointer;
}
.asst-skip:hover { color: var(--fg); border-color: var(--accent); }
.asst-close {
  margin-left: 8px;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.asst-intro { font-size: 0.8rem; color: #8b949e; margin: 8px 0; }

.asst-upsell {
  font-size: 0.8rem;
  background: #16202c;
  border: 1px solid #1f6feb55;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.asst-link {
  background: none;
  border: none;
  color: var(--accent, #2f81f7);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.asst-input-row { display: flex; gap: 6px; }
.asst-input {
  flex: 1;
  resize: vertical;
  background: #010409;
  color: inherit;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}
.asst-send {
  align-self: stretch;
  padding: 0 14px;
  border: 1px solid var(--accent, #2f81f7);
  border-radius: 8px;
  background: var(--accent, #2f81f7);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.asst-send:disabled { opacity: 0.5; cursor: default; }

.asst-speed {
  background: #0d1117;
  color: var(--muted);
  border: 1px solid #30363d;
  border-radius: 10px;
  font: inherit;
  font-size: 0.72rem;
  padding: 1px 4px;
}
.asst-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.asst-quick-chip {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 14px;
  color: var(--fg);
  font: inherit;
  font-size: 0.76rem;
  padding: 4px 10px;
  cursor: pointer;
}
.asst-quick-chip:hover { border-color: var(--accent); }
.asst-upsell-text { display: block; }
.asst-upsell-actions { display: flex; gap: 14px; margin-top: 6px; }
.asst-muted { color: var(--muted); text-decoration: none; }
.asst-muted:hover { color: var(--fg); }

/* Basket items are draggable back onto the editor (plus an Edit button). */
.basket-item { cursor: grab; }
.basket-item.dragging { opacity: 0.5; }
.editor-drop-active { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 6px; }

/* Transcript: conventional order (oldest first, newest at the bottom),
   grows to fill the space between the intro and the bottom-pinned input. */
.asst-log { margin-top: 12px; overflow-y: auto; flex: 1; }
.asst-turn { border-top: 1px solid #21262d; padding: 10px 0; }
.asst-turn:first-child { border-top: none; }

.asst-msg { font-size: 0.86rem; white-space: pre-wrap; word-wrap: break-word; }
.asst-user {
  font-weight: 600;
  color: var(--accent);
  background: #161b22;
  border-radius: 8px;
  padding: 6px 9px;
  margin-bottom: 6px;
}
.asst-bot { color: #c9d1d9; margin-bottom: 6px; }

.asst-proposals { display: flex; flex-direction: column; gap: 6px; }
.asst-chip {
  background: #0f1b12;
  border: 1px solid #2ea04355;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.82rem;
}
.asst-chip-error { background: #1b1011; border-color: #f8514955; }
.asst-chip-head { font-weight: 600; }
.asst-chip-why { color: #8b949e; font-size: 0.78rem; margin-top: 2px; }
.asst-chip-warn { color: #d29922; font-size: 0.76rem; margin-top: 3px; }

.asst-clarify {
  background: #16202c;
  border: 1px solid #1f6feb55;
  border-radius: 8px;
  padding: 8px 10px;
}
.asst-clarify-q { font-weight: 600; font-size: 0.84rem; }
.asst-clarify-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.asst-opt {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 14px;
  padding: 3px 10px;
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
