:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --ink: #000000;
  --muted: #222222;
  --line: #000000;
  --paper: #ffffff;
  --white: #ffffff;
  --accent: #000000;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
  box-shadow: none !important;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.sidebar {
  z-index: 10;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper);
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 20px 17px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

sup {
  font-size: 8px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 7px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #000000;
  background: #000000;
  color: #ffffff;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.control-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.mode-section {
  padding-top: 14px;
}

.segmented,
.density-style {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 2px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.segmented button,
.density-style button {
  min-height: 32px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #586269;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.segmented button.active,
.density-style button.active {
  background: #000000;
  color: #ffffff;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 11px;
}

.section-heading > span,
.text-button {
  color: var(--muted);
  font-size: 10px;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
  text-decoration: underline;
}

.city-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.origin-list {
  display: grid;
  gap: 6px;
}

.origin-row {
  display: grid;
  min-height: 52px;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--sample-colour);
  border-radius: 4px;
  background: var(--white);
}

.origin-index {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  background: var(--sample-colour);
  color: var(--white);
  font-size: 9px;
  font-weight: 800;
}

.origin-details,
.origin-row small {
  display: block;
}

.origin-details {
  min-width: 0;
}

.origin-details input {
  display: block;
  width: 100%;
  height: 24px;
  padding: 1px 3px;
  border: 0;
  border-bottom: 1px solid #000000;
  background: #ffffff;
  color: #000000;
  font-size: 11px;
  font-weight: 700;
}

.origin-details input:focus {
  outline: 2px solid #000000;
  outline-offset: -1px;
}

.origin-row small {
  margin-top: 3px;
  overflow: hidden;
  color: #000000;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.origin-row button {
  display: grid;
  width: 27px;
  height: 27px;
  padding: 7px;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.origin-row button:hover {
  background: #000000;
  color: #ffffff;
}

.origin-empty {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.city-group-label {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

.city-group-label:first-child {
  margin-top: 0;
}

.city-option {
  display: flex;
  min-width: 0;
  height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: #566168;
  cursor: pointer;
}

.city-option:hover {
  background: var(--white);
}

.city-option.selected {
  border-color: color-mix(in srgb, var(--city-colour) 55%, #9ba2a5);
  background: var(--white);
  color: var(--ink);
}

.city-option .swatch {
  width: 13px;
  height: 0;
  flex: 0 0 auto;
  border-top: 2px solid var(--city-colour);
}

.city-option.pattern-1 .swatch {
  border-top-style: dashed;
}

.city-option.pattern-2 .swatch {
  border-top-style: dotted;
}

.city-option.pattern-3 .swatch {
  border-top-style: dashed;
}

.city-option.pattern-4 .swatch {
  border-top-style: dashed;
}

.city-option.pattern-5 .swatch {
  border-top-style: dashed;
}

.city-option span:last-child {
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layers-section h2 {
  margin-bottom: 10px;
}

.layer-row {
  display: grid;
  min-height: 34px;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.layer-symbol {
  display: block;
  width: 16px;
}

.rings-symbol {
  height: 8px;
  border-top: 2px solid #287b74;
  border-bottom: 1px solid #287b74;
  border-radius: 50%;
}

.local-symbol {
  height: 0;
  border-top: 2px solid #292f33;
}

.combined-symbol {
  height: 4px;
  border-top: 2px dashed #e0563f;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.ring-legend {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.ring-legend span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.ring-legend i {
  display: block;
  width: 100%;
  height: 6px;
  border-top: var(--weight) solid var(--accent);
}

.summary {
  padding: 15px 20px 13px;
}

.summary-heading {
  margin-bottom: 8px;
}

.comparison-table {
  border-top: 1px solid var(--line);
}

.comparison-header,
.comparison-row {
  display: grid;
  grid-template-columns: minmax(78px, 1.5fr) repeat(3, 0.7fr);
  align-items: center;
  min-height: 27px;
  border-bottom: 1px solid var(--line);
  column-gap: 5px;
}

.comparison-header {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.comparison-header span:first-child {
  text-align: left;
}

.comparison-row {
  font-size: 10px;
}

.comparison-row > span {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-row i {
  display: block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--city-colour);
}

.comparison-row strong {
  text-align: right;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.summary-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  font-size: 11px;
  font-weight: 750;
}

.summary-title .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--city-colour);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric strong,
.metric span {
  display: block;
}

.metric strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.metric span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

footer {
  padding: 0 20px 20px;
  color: #7a8388;
  font-size: 9px;
  line-height: 1.4;
}

.map-panel,
#map {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
}

.map-panel {
  overflow: hidden;
  background: #ffffff;
}

.origin-marker {
  display: grid;
  width: 25px;
  height: 25px;
  padding: 0;
  place-items: center;
  border: 2px solid #ffffff;
  outline: 1px solid #000000;
  background: var(--sample-colour);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  cursor: grab;
}

.origin-marker:active {
  cursor: grabbing;
}

.profile-panel {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border: 0;
  border-top: 1px solid #000000;
  background: #ffffff;
}

.profile-panel > header {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 7px 12px;
  border-bottom: 1px solid var(--line);
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scale-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #000000;
}

.scale-toggle button {
  min-width: 54px;
  height: 29px;
  padding: 0 9px;
  border: 0;
  background: #ffffff;
  color: #000000;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.scale-toggle button + button {
  border-left: 1px solid #000000;
}

.scale-toggle button.active {
  background: #000000;
  color: #ffffff;
}

.profile-panel > header h2 {
  font-size: 15px;
}

.profile-panel > header .icon-button {
  width: 29px;
  height: 29px;
}

.profile-panel.collapsed #profile-chart {
  display: none;
}

.profile-panel.collapsed {
  right: auto;
  width: 320px;
}

.profile-panel.collapsed > header {
  border-bottom: 0;
}

.profile-panel.collapsed .icon-button svg {
  transform: rotate(180deg);
}

#profile-chart {
  padding: 0;
}

#profile-chart svg {
  display: block;
  width: 100%;
  height: 250px;
  overflow: visible;
}

.profile-grid line {
  stroke: #777777;
  stroke-width: 1;
}

.profile-grid text,
.profile-axis text,
.profile-y-label {
  fill: #000000;
  font-family: inherit;
  font-size: 12px;
  stroke: none;
}

.profile-lines polyline {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.profile-direct-label {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 4px;
}

.profile-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  padding: 0 8px 4px 68px;
}

.profile-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #000000;
  font-size: 12px;
}

.profile-legend i {
  width: 18px;
  height: 0;
  border-top: 2px solid var(--sample-colour);
}

.profile-legend strong {
  color: var(--sample-colour);
  font-size: 11px;
}

.reset-view {
  position: absolute;
  z-index: 2;
  right: 10px;
  bottom: 28px;
  display: flex;
  height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid #000000;
  background: #ffffff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.reset-view svg {
  width: 15px;
}

.empty-state {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border: 1px solid var(--line);
  background: var(--white);
  text-align: center;
  transform: translate(-50%, -50%);
}

.empty-state strong {
  font-size: 13px;
}

.empty-state span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.maplibregl-popup-content {
  min-width: 190px;
  padding: 11px 12px;
  border: 1px solid #000000;
}

.popup-city {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

.popup-city span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--city-colour);
}

.popup-title {
  font-size: 12px;
  font-weight: 750;
}

.popup-value {
  margin-top: 7px;
  font-size: 18px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.popup-value small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.popup-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

dialog {
  width: min(520px, calc(100vw - 30px));
  padding: 0;
  border: 1px solid #000000;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(24 32 39 / 40%);
}

dialog form {
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.dialog-heading h2 {
  font-size: 20px;
}

dialog p {
  color: #4f5b62;
  font-size: 12px;
  line-height: 1.55;
}

dialog .scope-note {
  margin-bottom: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}

.sheet-handle {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .map-panel {
    position: absolute;
    inset: 0;
  }

  .sidebar {
    position: absolute;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    height: min(48dvh, 430px);
    padding-top: 13px;
    border-top: 1px solid #000000;
    border-right: 0;
    transition: transform 180ms ease;
  }

  .sidebar.collapsed {
    transform: translateY(calc(100% - 52px));
  }

  .sheet-handle {
    position: absolute;
    top: 0;
    left: 50%;
    display: block;
    width: 54px;
    height: 13px;
    padding: 4px 12px;
    border: 0;
    background: transparent;
    transform: translateX(-50%);
  }

  .sheet-handle span {
    display: block;
    height: 3px;
    border-radius: 2px;
    background: #a5adaf;
  }

  .brand {
    align-items: center;
    padding: 7px 16px 10px;
  }

  h1 {
    font-size: 19px;
  }

  .brand .eyebrow,
  .brand .icon-button {
    display: none;
  }

  .control-section {
    padding: 13px 16px;
  }

  .mode-section {
    padding-top: 10px;
  }

  .city-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .city-option {
    padding: 0 6px;
    gap: 5px;
  }

  .city-option span:last-child {
    font-size: 9px;
  }

  .summary,
  footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .profile-panel {
    top: 0;
    bottom: auto;
    left: 0;
    width: 100%;
  }

  .profile-panel > header {
    height: 43px;
  }

  #profile-chart svg {
    height: 210px;
  }

  .profile-panel.collapsed {
    width: 300px;
  }

  .reset-view {
    right: 10px;
    bottom: calc(min(48dvh, 430px) + 10px);
  }

  .sidebar.collapsed + .map-panel .reset-view {
    bottom: 62px;
  }

  .maplibregl-ctrl-top-right {
    top: 4px;
    right: 2px;
  }
}

@media (max-width: 420px) {
  .city-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
