:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #6e6c67;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --band: rgba(42, 120, 214, 0.16);
  --accent-soft: #e8f1fc;
  --up: #b42f2f;
  --down: #006300;
  --warning-bg: #fff6e0;
  --warning-border: #f0c564;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #222220;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --band: rgba(57, 135, 229, 0.22);
    --accent-soft: #1c2b3f;
    --up: #e66767;
    --down: #0ca30c;
    --warning-bg: #2d2615;
    --warning-border: #8a6a1c;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  font-weight: 650;
}

a {
  color: var(--series-1);
}

[hidden] {
  display: none !important;
}

/* Header */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  fill: var(--series-1);
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.tagline,
.updated,
.hero-meta,
.lead,
.footer {
  color: var(--ink-2);
}

.updated {
  font-size: 0.875rem;
}

/* Segmented controls */

.fuel-switch,
.range-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.fuel-switch {
  margin-bottom: 20px;
}

.fuel-switch button,
.range-switch button {
  font: inherit;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  padding: 8px 18px;
  cursor: pointer;
}

.range-switch button {
  padding: 4px 12px;
  font-size: 0.875rem;
}

.fuel-switch button[aria-checked="true"],
.range-switch button[aria-checked="true"] {
  background: var(--series-1);
  color: #ffffff;
  font-weight: 600;
}

.fuel-switch button:focus-visible,
.range-switch button:focus-visible,
.chart-hit:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

.loading {
  color: var(--ink-2);
  padding: 48px 0;
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.hero > div,
.card,
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hero > div {
  padding: 24px;
}

.hero-forecast {
  background: var(--accent-soft) !important;
}

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.hero-price {
  font-size: clamp(2.75rem, 9vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 12px;
}

.unit {
  font-size: 0.4em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
  margin-left: 0.3em;
}

.hero-range {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero-meta {
  font-size: 0.9375rem;
}

/* Events */

.events {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.event {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
}

.event-date {
  flex: none;
  text-align: center;
  min-width: 52px;
  padding-top: 2px;
}

.event-day {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.event-month {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.event strong {
  display: block;
}

.event p {
  color: var(--ink-2);
  font-size: 0.9375rem;
}

/* Cards */

.card {
  padding: 20px 24px 24px;
  margin-bottom: 16px;
}

.card h2 {
  margin-bottom: 12px;
}

.card h3 {
  font-size: 0.9375rem;
  font-weight: 650;
  margin: 20px 0 6px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.card-head h2 {
  margin: 0;
}

.prose p + p {
  margin-top: 10px;
}

.prose p,
.lead {
  max-width: 68ch;
}

.lead {
  margin-bottom: 16px;
}

/* Chart */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key {
  display: inline-block;
  width: 18px;
}

.key-price {
  border-top: 2px solid var(--series-1);
}

.key-band {
  height: 10px;
  border-radius: 3px;
  background: var(--band);
  border: 1px solid var(--series-1);
}

.key-band-50 {
  height: 10px;
  border-radius: 3px;
  background: var(--series-1);
  opacity: 0.45;
}

.chart {
  position: relative;
  height: 320px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart text {
  fill: var(--ink-muted);
  font: 12px var(--font);
  font-variant-numeric: tabular-nums;
}

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

.today-line {
  stroke: var(--axis);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.line-price,
.line-forecast {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
}

.line-forecast {
  stroke-dasharray: 5 4;
}


.area-band {
  fill: var(--band);
}

.area-band-50 {
  fill: var(--series-1);
  fill-opacity: 0.25;
}

.crosshair {
  stroke: var(--ink-muted);
  stroke-width: 1;
}

.marker {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.tooltip {
  position: absolute;
  top: 8px;
  pointer-events: none;
  min-width: 170px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  font-size: 0.8125rem;
}

.tooltip-date {
  color: var(--ink-2);
  margin-bottom: 6px;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
}

.tooltip-row strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}

.tooltip-row .key {
  width: 12px;
}

/* Tables */

.table-view {
  margin-top: 12px;
  font-size: 0.875rem;
}

.table-view summary {
  cursor: pointer;
  color: var(--ink-2);
}

.table-scroll {
  overflow-x: auto;
  max-height: 360px;
  margin-top: 8px;
}

#accuracy .table-scroll {
  max-height: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  font-weight: 600;
  color: var(--ink-2);
  font-size: 0.8125rem;
  position: sticky;
  top: 0;
  background: var(--surface);
}

/* Day by day */

.days,
.stations {
  list-style: none;
  padding: 0;
  margin: 0;
}

.day {
  display: grid;
  grid-template-columns: 84px 52px minmax(0, 1fr) 52px 64px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}

.day:first-child {
  border-top: 0;
}

.day-name {
  font-weight: 600;
  line-height: 1.2;
}

.day-name small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.day-low,
.day-high {
  font-size: 0.875rem;
  color: var(--ink-2);
}

.day-low {
  text-align: right;
}

.day-mid {
  text-align: right;
  font-weight: 650;
}

.day-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--grid);
}

.day-fill,
.day-fill-50 {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: var(--series-1);
}

.day-fill {
  opacity: 0.3;
}

.day-today {
  position: absolute;
  top: -5px;
  bottom: -5px;
  border-left: 1px dashed var(--ink-muted);
}

.day-dot {
  position: absolute;
  top: -3px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
}

.day-chance {
  grid-column: 3;
  margin-top: -8px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: pre;
}

.day-event {
  display: inline-block;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
}

.note {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* Station prices */

.station {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--grid);
}

.station:first-child {
  border-top: 0;
}

.station-name {
  font-weight: 600;
}

.station-meta {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.station-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.station-price strong {
  font-size: 1.125rem;
}

.station-price small {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Driver tiles */

.drivers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile-label {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.tile-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tile-value small {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-left: 4px;
}

.tile-change {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.tile-note {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: auto;
}

.spark {
  height: 36px;
  margin: 6px 0 4px;
}

.spark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.spark path {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
}

.spark circle {
  fill: var(--series-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.change-up {
  color: var(--up);
}

.change-down {
  color: var(--down);
}

/* Sources */

.sources {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9375rem;
}

.sources li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--grid);
}

.sources li:last-child {
  border-bottom: 0;
}

.source-status {
  color: var(--ink-2);
  font-size: 0.875rem;
}

.source-error {
  color: var(--up);
}

.footer {
  font-size: 0.8125rem;
  margin-top: 24px;
}

@media (max-width: 760px) {
  .page {
    padding-top: 20px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .drivers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card {
    padding: 16px;
  }

  .chart {
    height: 260px;
  }

  .day {
    grid-template-columns: 68px 44px minmax(0, 1fr) 44px 52px;
    gap: 8px;
    font-size: 0.9375rem;
  }
}
