:root {
  color-scheme: light;
  --ink: #0b1f33;
  --muted: #5b6875;
  --line: #d6dde4;
  --soft: #f1f5f7;
  --paper: #ffffff;
  --accent: #0b7895;
  --accent-dark: #075a70;
  --gold: #d99518;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  font-family: var(--sans);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="search"] {
  min-height: 44px;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 64px);
}

h2,
p {
  margin-top: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 90px);
  align-items: start;
}

.controls {
  position: sticky;
  top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  background: #f7f9fa;
}

.controls-heading,
.results-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

h2 {
  margin-bottom: 20px;
  font-family: var(--sans);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.setting__label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.scenario-controls {
  display: grid;
  gap: 20px;
}

.range-heading {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.range-heading .setting__label {
  margin-bottom: 0;
}

.range-value,
.fixed-value {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting--range input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 6px 0 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.setting--range input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(
    to right,
    var(--ink) 0,
    var(--ink) var(--range-position),
    #b9c3cb var(--range-position),
    #b9c3cb 100%
  );
}

.setting--range input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.setting--range input[type="range"]::-moz-range-track {
  height: 3px;
  background: #b9c3cb;
}

.setting--range input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--ink);
}

.setting--range input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.7rem;
}

.range-ticks {
  display: grid;
  grid-template-columns: repeat(var(--tick-count), 1fr);
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.range-ticks span {
  position: relative;
  pointer-events: none;
  text-align: center;
}

.range-ticks span:first-child {
  text-align: left;
}

.range-ticks span:last-child {
  text-align: right;
}

.setting--fixed {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.setting--fixed .setting__label {
  margin-bottom: 0;
}

.setting select {
  width: 100%;
  padding: 9px 34px 9px 11px;
  border: 1px solid #aab6c0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

.setting select:disabled {
  color: var(--ink);
  opacity: 1;
}

.results {
  min-width: 0;
}

.results-header {
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.results-header h2 {
  margin-bottom: 0;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #81909c;
}

.view-toggle button {
  min-height: 38px;
  padding: 7px 14px;
  border: 0;
  border-right: 1px solid #81909c;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.view-toggle button:last-child {
  border-right: 0;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.result-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.duration-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
}

.duration-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend-swatch {
  width: 20px;
  height: 9px;
  border: 1px solid;
}

.legend-swatch--total {
  border-color: #355d7b;
  background: #7899b0;
}

.legend-swatch--permit {
  border-color: #7b263c;
  background: #b75a70;
}

.uncertainty-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.uncertainty-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.search-field input {
  width: 165px;
  padding: 8px 11px;
  border: 1px solid #aab6c0;
  border-radius: 0;
}

.axis-wrap {
  margin-left: 204px;
  margin-right: 124px;
}

.axis-title {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.axis {
  position: relative;
  height: 24px;
  padding-bottom: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
}

.axis span::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  height: 7px;
  border-left: 1px solid #aab6c0;
}

.axis span:first-child {
  text-align: left;
  transform: none;
}

.axis span:first-child::after {
  left: 1px;
}

.axis span:last-child {
  text-align: right;
  transform: translateX(-100%);
}

.axis span:last-child::after {
  right: 0;
  left: auto;
}

.ranking-chart {
  max-height: 690px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-gutter: stable;
}

.city-row {
  display: grid;
  grid-template-columns: 34px 160px minmax(230px, 1fr) 104px;
  gap: 5px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid #e7ebee;
}

.city-row[hidden] {
  display: none;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
  text-align: right;
}

.city-name {
  padding-left: 8px;
  font-size: 0.93rem;
  font-weight: 730;
  line-height: 1.12;
}

.city-name span {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 600;
}

.city-name em {
  color: #8a5b08;
  font-style: normal;
  font-weight: 750;
}

.plot {
  position: relative;
  height: 42px;
  border-right: 1px solid #d2d9df;
  background-image: repeating-linear-gradient(
    to right,
    #d2d9df 0,
    #d2d9df 1px,
    transparent 1px,
    transparent 25%
  );
}

.plot::before {
  content: "";
  position: absolute;
  inset: 20px 0 auto;
  border-top: 1px solid #edf0f2;
}

.duration-bar {
  position: absolute;
  left: 0;
  border: 1px solid;
}

.duration-bar--total {
  top: 4px;
  height: 13px;
  border-color: #355d7b;
  background: color-mix(in srgb, #7899b0 68%, white);
  color: #244c6a;
}

.duration-bar--permit {
  top: 25px;
  height: 13px;
  border-color: #7b263c;
  background: color-mix(in srgb, #b75a70 82%, white);
  color: #7b263c;
}

.duration-bar--clipped::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 1px;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.ci {
  position: absolute;
  height: 2px;
  background: currentColor;
}

.ci--total {
  top: 10px;
  color: #244c6a;
}

.ci--permit {
  top: 31px;
  color: #7b263c;
}

.ci::before,
.ci::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 1px;
  height: 10px;
  background: currentColor;
}

.ci::before {
  left: 0;
}

.ci::after {
  right: 0;
}

.ci--clipped::after {
  top: -2px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  background: transparent;
  transform: rotate(45deg);
}

.value {
  display: grid;
  gap: 3px;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  text-align: right;
}

.value__total {
  color: #244c6a;
}

.value__permit {
  color: #7b263c;
}

.time-series-section {
  padding-top: 22px;
}

.time-series-chart {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  width: 100%;
  min-height: 390px;
}

.time-chart-panel h4 {
  margin: 0 0 8px 60px;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.time-chart-panel--total h4 {
  color: #355d7b;
}

.time-chart-panel--permit h4 {
  color: #7b263c;
}

.time-series-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.time-grid {
  stroke: #d6dde4;
  stroke-width: 1;
}

.time-grid--vertical {
  stroke: #e7ebee;
}

.time-axis {
  stroke: #7f8b95;
  stroke-width: 1;
}

.time-axis-label,
.time-axis-title,
.time-series-label {
  fill: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
}

.time-axis-title {
  font-size: 12px;
  font-weight: 650;
}

.time-band {
  stroke: none;
}

.time-band--total {
  fill: color-mix(in srgb, #7899b0 22%, transparent);
}

.time-band--permit {
  fill: color-mix(in srgb, #b75a70 18%, transparent);
}

.time-line {
  fill: none;
  stroke-width: 2.25;
}

.time-line--total,
.time-point--total {
  stroke: #355d7b;
}

.time-line--permit,
.time-point--permit {
  stroke: #7b263c;
}

.time-point {
  fill: var(--paper);
  stroke-width: 1.5;
}

.time-series-label {
  font-weight: 700;
}

.time-series-label--total {
  fill: #355d7b;
}

.time-series-label--permit {
  fill: #7b263c;
}

.page-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  max-width: 22ch;
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.page-credit {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.page-credit a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.page-credit a:hover {
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 70%, white);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  main {
    padding: 24px 18px 42px;
  }

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

  .controls {
    position: static;
  }

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

@media (max-width: 600px) {
  .scenario-controls {
    grid-template-columns: 1fr;
  }

  .results-header,
  .result-tools {
    display: block;
  }

  .view-toggle {
    display: flex;
    margin-top: 14px;
  }

  .view-toggle button {
    flex: 1;
  }

  .result-tools > * {
    margin-bottom: 12px;
  }

  .search-field input {
    width: 100%;
  }

  .axis {
    font-size: 0.68rem;
  }

  .axis-wrap {
    margin-left: 131px;
    margin-right: 94px;
  }

  .city-row {
    grid-template-columns: 25px 96px minmax(140px, 1fr) 74px;
  }

  .city-name {
    font-size: 0.82rem;
  }

  .value {
    font-size: 0.78rem;
  }

  .time-series-chart {
    grid-template-columns: 1fr;
    gap: 26px;
    min-height: 620px;
  }
}
