:root {
  --ink: #1b1f23;
  --muted: #4a5560;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --rule: #c9cdd2;
  --link: #0b4f8a;
  --focus: #b3470d;
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

header, main, footer { max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
header { padding-top: 1.25rem; }
footer { padding-top: 1rem; padding-bottom: 2rem; color: var(--muted); border-top: 1px solid var(--rule); margin-top: 2rem; }

h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 0.25rem; }
h2 { font-size: 1.6rem; line-height: 1.25; margin: 2.25rem 0 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.25rem; margin: 1.5rem 0 0.4rem; }
h4 { font-size: 1rem; margin: 0 0 0.25rem; }
p, li, blockquote, td, th { max-width: 46rem; }
.lede { margin: 0 0 0.75rem; color: var(--muted); }

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#map:focus-visible, .table-scroll:focus-visible { outline-offset: -3px; }

.skip { position: absolute; left: 0.5rem; top: -4rem; background: var(--panel); padding: 0.5rem 0.75rem; border: 2px solid var(--focus); z-index: 2000; }
.skip:focus { top: 0.5rem; }


nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0; margin: 0.5rem 0 0; }
nav a { display: inline-block; padding: 0.35rem 0; }

.layers { border: 1px solid var(--rule); padding: 0.6rem 0.9rem 0.7rem; margin: 0.75rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; background: var(--panel); }
.layers .group-title { margin: 0; font-weight: 600; flex-basis: 100%; max-width: none; }
label { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 1.75rem; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
select, input[type="search"] { font: inherit; padding: 0.5rem 0.65rem; border: 1px solid var(--muted); border-radius: 0.25rem; background: var(--panel); color: var(--ink); max-width: 100%; }
label[for="route-select"], label[for="corner-filter"] { font-weight: 600; margin-right: 0.5rem; }

#map { height: 62vh; min-height: 22rem; border: 1px solid var(--muted); background: #f1efe9; }
.leaflet-container { font: inherit; }
.leaflet-container a { color: var(--link); }
.street-label { background: #ffffff; border: 0; border-radius: 2px; box-shadow: none; color: #2c353d; font-size: 0.72rem; font-weight: 600; padding: 1px 5px; white-space: nowrap; }
.leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-scale-line { background: #ffffff; color: var(--ink); }
.leaflet-container .leaflet-control-attribution a { text-decoration: underline; }
.leaflet-container .leaflet-control-scale-line { text-shadow: none; }
.street-label::before { display: none; }
.end-marker { border: 0; background-repeat: no-repeat; background-size: 28px 28px; }
.end-a { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Ccircle cx='14' cy='14' r='12' fill='%231b1f23' stroke='%23fff' stroke-width='2'/%3E%3Ctext x='14' y='19' text-anchor='middle' font-family='sans-serif' font-size='14' font-weight='700' fill='%23fff'%3EA%3C/text%3E%3C/svg%3E"); }
.end-b { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Ccircle cx='14' cy='14' r='12' fill='%231b1f23' stroke='%23fff' stroke-width='2'/%3E%3Ctext x='14' y='19' text-anchor='middle' font-family='sans-serif' font-size='14' font-weight='700' fill='%23fff'%3EB%3C/text%3E%3C/svg%3E"); }

.credit { color: var(--muted); font-size: 0.93rem; margin: 0.4rem 0 0; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.25rem 1.5rem; margin: 0.6rem 0 0; padding: 0.75rem 1rem; background: var(--panel); border: 1px solid var(--rule); }
.legend h3 { grid-column: 1 / -1; margin: 0.4rem 0 0; font-size: 0.95rem; }
.legend h3:first-child { margin-top: 0; }
.legend div { display: flex; align-items: center; gap: 0.5rem; font-size: 0.93rem; }
.legend svg { flex: 0 0 2.4rem; }

.verdict { background: var(--panel); border: 1px solid var(--rule); border-left: 0.4rem solid var(--ink); padding: 0.75rem 1rem; margin: 0.75rem 0; }
.verdict p { margin: 0.2rem 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--rule); border-top-width: 0.4rem; padding: 0.75rem 1rem 1rem; }
.card h3 { margin: 0 0 0.3rem; display: flex; align-items: center; gap: 0.5rem; }
.card .facts { margin: 0.3rem 0 0.6rem; padding: 0; list-style: none; }
.card .facts li { padding: 0.1rem 0; }
.card ol { padding-left: 1.4rem; margin: 0.4rem 0 0; }
.card ol li { margin: 0.35rem 0; }
.card .flag { font-weight: 600; }
.none { color: var(--muted); }

table { border-collapse: collapse; background: var(--panel); margin: 0.5rem 0 1rem; width: 100%; max-width: 46rem; }
caption { text-align: left; font-weight: 600; padding: 0.3rem 0; }
th, td { border: 1px solid var(--rule); padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
td, th { overflow-wrap: anywhere; }
thead th { background: #eef0f2; }
.table-scroll { max-height: 26rem; overflow: auto; border: 1px solid var(--rule); max-width: 100%; }
.table-scroll table { margin: 0; max-width: none; }
.table-scroll thead th { position: sticky; top: 0; }

blockquote { margin: 0.75rem 0; padding: 0.5rem 1rem; border-left: 0.3rem solid var(--rule); background: var(--panel); }
blockquote footer { all: unset; display: block; color: var(--muted); font-size: 0.93rem; padding-bottom: 0.5rem; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.status-grid > div { background: var(--panel); border: 1px solid var(--rule); padding: 0.75rem 1rem; }
.status-grid ul { padding-left: 1.2rem; margin: 0.4rem 0; }
.status-grid li { margin: 0.4rem 0; }

@media (max-width: 40rem) {
  h1 { font-size: 1.75rem; }
  #map { height: 55vh; }
  .card ol { padding-left: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Leaflet pulls the second scale line 2px over the first; keep them apart so each has its own background. */
.leaflet-container .leaflet-control-scale-line:not(:first-child) { margin-top: 0; }
