:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #ddd4c6;
  --rust: #8f2d1c;
  --primary: #1e3a5f;
  --alternate: #8a4b12;
  --shadow: 0 10px 30px rgba(40, 28, 16, 0.12);
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Palatino, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}

button, input { font: inherit; }

#app {
  display: flex;
  height: 100%;
  min-height: 100%;
}

#panel {
  width: 400px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.mast {
  padding: 22px 22px 8px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rust);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 640;
  font-size: 40px;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.dek {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 15px;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 22px 0;
}

.compare div {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 8px;
}

.compare strong {
  display: block;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  margin-top: 4px;
}

.compare em {
  display: block;
  margin-top: 4px;
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.route-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.route-name.primary { color: var(--primary); }
.route-name.alternate { color: var(--alternate); }
.route-name.both { color: var(--ink); }

.split-line {
  margin: 10px 22px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.scroll {
  overflow: auto;
  padding: 8px 22px 28px;
  min-height: 0;
}

section { margin-top: 18px; }

h2 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 520;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.hint, .match, .method p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

#top10 {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#top10 button {
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 10px 44px;
  position: relative;
  cursor: pointer;
  color: inherit;
}

#top10 button:hover,
#top10 button.active {
  border-color: #c4b49a;
  background: #fffdf8;
}

#top10 button.active {
  box-shadow: inset 3px 0 0 var(--rust);
}

.rank {
  position: absolute;
  left: 12px;
  top: 12px;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--rust);
}

.place {
  display: block;
  font-weight: 700;
  line-height: 1.25;
  margin: 2px 0 3px;
}

.blurb {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.35;
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.checks label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.3;
}

.text-btn, .preset {
  background: transparent;
  border: 0;
  color: var(--rust);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.preset {
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}

.preset:hover, .text-btn:hover { color: var(--rust); }

.filter-block { margin-bottom: 12px; }

.filter-block p {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
}

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

.chip:focus-visible, #top10 button:focus-visible, .preset:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

.method {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.method summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 8px;
}

main { position: relative; flex: 1; min-width: 0; }

#map { position: absolute; inset: 0; }

#legend {
  position: absolute;
  left: 14px;
  bottom: 28px;
  z-index: 2;
  background: rgba(244, 239, 230, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px 12px;
  width: 210px;
  box-shadow: var(--shadow);
}

#legend strong {
  display: block;
  font-family: var(--serif);
  font-size: 15px;
  margin-bottom: 6px;
}

.ramp {
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, #e6dfd4, #f2c56b, #e4843a, #c83b2c, #6e1220);
  margin-bottom: 4px;
}

.ramp-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

#legend .key {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

#status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

#status.error { background: var(--rust); }

.maplibregl-popup-content {
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--sans);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.pop .kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rust);
  font-weight: 700;
}

.pop h3 {
  margin: 4px 0 6px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 560;
  line-height: 1.15;
}

.pop p { margin: 0 0 8px; line-height: 1.4; font-size: 14px; }

.bars { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }

.bar-row { display: grid; grid-template-columns: 72px 1fr 32px; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }

.bar-track { background: var(--paper-2); height: 7px; border-radius: 99px; overflow: hidden; }

.bar-fill { height: 100%; background: var(--rust); border-radius: 99px; }

.sev-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  margin-right: 6px;
}

@media (max-width: 860px) {
  #app { flex-direction: column; height: auto; }
  main { height: 70vh; flex: none; }
  #panel { width: 100%; border-right: 0; border-top: 1px solid var(--line); }
  .scroll { overflow: visible; }
  h1 { font-size: 34px; }
}
