:root {
  --ink: #1c1915;
  --muted: #5e584e;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e4d9c8;
  --route: #c65314;
  --er: #b42318;
  --hospital: #1d4a38;
  --rsia: #1d4e89;
  --clinic: #8a5a12;
  --gap: #9a3412;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.08);
  --panel: 26.5rem;
  --header: 5.6rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

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

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--ink);
  color: #f6f1e7;
}

.brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.85rem;
  min-width: 0;
  max-width: 100%;
}

.brand-text { min-width: 0; }

.logo {
  width: 3.25rem;
  height: 3.25rem;
  flex: none;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  object-fit: cover;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e7b089;
}

h1 {
  margin: 0.1rem 0 0;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.title-phone { display: none; }

.sub {
  margin: 0.15rem 0 0;
  color: #d9d0c3;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
}

.lang {
  display: flex;
  border: 1px solid #6b645b;
  border-radius: 999px;
  overflow: hidden;
}

.lang button {
  border: 0;
  background: transparent;
  color: #d9d0c3;
  min-height: 2.2rem;
  min-width: 2.5rem;
  padding: 0.2rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.lang button[aria-pressed="true"] {
  background: #f6f1e7;
  color: #1c1915;
}

.night-toggle {
  flex: none;
  border: 1px solid #6b645b;
  background: transparent;
  color: #d9d0c3;
  border-radius: 999px;
  min-height: 2.75rem;
  padding: 0 0.8rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.night-toggle[aria-pressed="true"] {
  background: #f6f1e7;
  color: #1c1915;
}

.ambulance {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: var(--er);
  color: white;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ambulance:hover { background: #8f1c14; }
.ambulance:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #e7b089;
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: var(--panel) 1fr;
  flex: 1;
  min-height: 0;
}

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

.tools {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 0.9rem 0.4rem;
}

.search { order: 1; }
.filters { order: 2; }
.segments { order: 3; }
.filter-toggle { display: none; }
.count { order: 5; }
.tools .list-notes { order: 6; }

.search input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid #d9cdb8;
  border-radius: 0.7rem;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.filters, .segments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.chip, .seg {
  border: 1px solid #d9cdb8;
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  min-height: 2.1rem;
  padding: 0.25rem 0.7rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

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

.count {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.blurb {
  margin: 0.35rem 0 0.2rem;
  font-size: 0.92rem;
  line-height: 1.4;
}

.about {
  margin: 0.35rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.about summary {
  cursor: pointer;
  color: var(--ink);
}

.list {
  overflow: auto;
  padding: 0 0.9rem 1.2rem;
  min-height: 0;
}

.site-footer {
  flex: none;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.site-footer a {
  color: var(--ink);
  font-weight: 600;
  text-underline-offset: 0.15em;
}

.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 0.9rem;
  padding: 0.8rem 0.85rem 0.75rem;
  margin-bottom: 0.55rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.card.selected {
  border-color: var(--route);
  box-shadow: inset 3px 0 0 var(--route), var(--shadow);
}

.card.gap {
  background: #fff6ee;
  border-color: #f0d2bc;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
}

.away {
  flex: none;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--route);
  white-space: nowrap;
}

.card h2 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.25;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.tag {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  background: #efe8dc;
  color: var(--muted);
}

.tag.er { background: #f8d6d2; color: var(--er); }
.tag.hours-off { background: #f8e7c4; color: #7a4b08; }
.tag.approx { background: transparent; border: 1px dashed #b08968; color: #7a4b08; }
.tag.detour { background: #e7eef8; color: var(--rsia); }

.meta, .note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.phone {
  display: inline-block;
  margin-top: 0.45rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.phone.missing {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

a.phone:hover { color: var(--route); }

.actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.card .card-extra { order: 1; }
.card .phone { order: 2; }
.card .actions { order: 3; }

.actions a,
.more {
  font-size: 0.86rem;
  color: var(--rsia);
}

.more {
  display: none;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.card-brief { display: none; }

.tags-brief,
.tags-detail { display: none; }

.empty {
  padding: 1rem 0.2rem;
  color: var(--muted);
}

.map-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#map {
  height: 100%;
  background: #e7e1d6;
}

.map-tools {
  position: absolute;
  z-index: 500;
  top: 0.7rem;
  right: 0.7rem;
  display: flex;
  gap: 0.4rem;
}

.map-tools button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  min-height: 2.4rem;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.locate { width: 1.1em; height: 1.1em; flex: none; }

.map-tools .legend-toggle,
.corner-tools,
.ambulance-float,
.sheet-handle { display: none; }

#route-fit { display: none; }

button, a, .card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.map-dock {
  position: absolute;
  z-index: 500;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 1.65rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  pointer-events: none;
}

.map-note {
  margin: 0;
  max-width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--ink);
  color: #f6f1e7;
  border-radius: 0.7rem;
  font-size: 0.88rem;
  pointer-events: auto;
}

.map-note-text { margin: 0; }

.map-note[hidden] { display: none !important; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0.6rem;
  list-style: none;
  background: rgba(255, 253, 248, 0.94);
  border-radius: 0.7rem;
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  pointer-events: auto;
}

.legend li { display: flex; align-items: center; gap: 0.3rem; }

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

.swatch.er { background: var(--er); }
.swatch.hospital { background: var(--hospital); }
.swatch.rsia { background: var(--rsia); }
.swatch.clinic { background: var(--clinic); }
.swatch.approx { background: transparent; border: 2px dashed #8a5a12; }
.swatch.route { background: var(--route); border-radius: 2px; height: 0.28rem; }
.swatch.ws { background: #0b3a4a; border-radius: 999px; width: 1.15rem; height: 0.55rem; }
.swatch.you {
  width: 0.55rem;
  height: 0.55rem;
  background: #1d4ed8;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.pin {
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.pin.hospital { background: var(--hospital); }
.pin.rsia { background: var(--rsia); }
.pin.clinic, .pin.puskesmas { background: var(--clinic); }
.pin.er {
  background: var(--er);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0;
}
.pin.approx {
  background: transparent;
  border: 2px dashed currentColor;
  box-shadow: none;
}
.pin.approx.hospital { color: var(--hospital); }
.pin.approx.rsia { color: var(--rsia); }
.pin.approx.clinic, .pin.approx.puskesmas { color: var(--clinic); }
.pin.gap {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.pin.gap span {
  display: block;
  width: 12px;
  height: 12px;
  margin: 8px;
  background: var(--gap);
  box-shadow: 0 0 0 2px #fffaf3;
  transform: rotate(45deg);
}
.pin.endpoint {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.pin.endpoint svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(28, 25, 21, 0.45));
}
.pin.endpoint .pin-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.swatch.flag {
  width: 0.78rem;
  height: 0.62rem;
  border: 1px solid var(--ink);
  border-radius: 1px;
  background-color: #f7f4ee;
  background-image:
    linear-gradient(45deg, var(--ink) 25%, transparent 25%),
    linear-gradient(-45deg, var(--ink) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--ink) 75%),
    linear-gradient(-45deg, transparent 75%, var(--ink) 75%);
  background-size: 0.36rem 0.36rem;
  background-position: 0 0, 0 0.18rem, 0.18rem -0.18rem, -0.18rem 0;
}
.pin.ws {
  background: #0b3a4a;
  color: #f4fbff;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pin.ws.finish {
  box-shadow: 0 0 0 2px #e7b089, 0 1px 4px rgba(0, 0, 0, 0.35);
}
.pin.here {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.leaflet-popup-content {
  margin: 0.55rem 0.7rem;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.92rem;
  line-height: 1.35;
}

.leaflet-popup-content strong {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.02rem;
}

body.map-full .shell {
  grid-template-columns: 1fr;
  height: 100vh;
}

body.map-full .panel { display: none; }
body.map-full .top { display: none; }

body.map-full .map-wrap,
body.map-full #map {
  height: 100%;
  min-height: 100%;
}

@media (pointer: coarse) {
  /* Fingers need a larger target than the drawn pin. */
  .pin::before {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
  }
}

@media (max-width: 860px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { height: 100dvh; }

  .top {
    flex: none;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    padding:
      max(0.45rem, env(safe-area-inset-top))
      max(0.75rem, env(safe-area-inset-right))
      0.45rem
      max(0.75rem, env(safe-area-inset-left));
  }
  .brand { display: block; flex: 1 1 auto; min-width: 0; }
  .logo, .eyebrow, .sub, .title-wide { display: none; }
  .title-phone { display: inline; }
  h1 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.2;
  }
  .head-actions { gap: 0.4rem; }
  .night-toggle,
  .lang button {
    min-height: 2.75rem;
    min-width: 2.75rem;
  }
  .lang button { padding: 0.1rem 0.5rem; }
  .top .ambulance { display: none; }
  .ambulance-float {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 500;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: 0.75rem;
    min-height: 3rem;
    padding: 0 1rem;
    font-size: 1rem;
    box-shadow: 0 6px 18px rgba(180, 35, 24, 0.4);
  }
  .leaflet-bottom .leaflet-control-attribution { margin-bottom: 5.25rem; }

  /* The map fills the screen. The list is a sheet that slides over it. */
  .shell {
    display: block;
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .map-wrap {
    position: absolute;
    z-index: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--peek, 7rem);
  }

  .map-tools,
  .map-dock { display: contents; }
  #expand { display: none; }
  #nearest {
    position: absolute;
    z-index: 500;
    left: 0.75rem;
    bottom: 0.75rem;
    min-height: 3rem;
    padding: 0 1.15rem 0 0.95rem;
    background: var(--rsia);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(29, 78, 137, 0.35);
  }
  .map-note.is-nearest {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }
  .map-note.is-nearest.show-return #route-fit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.75rem;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
  }
  .map-wrap.has-nearest .leaflet-control-attribution {
    margin-bottom: 7.25rem;
  }
  .map-wrap.has-nearest.show-return .leaflet-control-attribution {
    margin-bottom: 10.5rem;
  }
  .corner-tools {
    display: flex;
    gap: 0.4rem;
    position: absolute;
    z-index: 500;
    top: 0.75rem;
    right: max(0.75rem, env(safe-area-inset-right));
  }
  .map-tools .legend-toggle {
    display: inline-flex;
    position: static;
    min-height: 2.75rem;
    padding: 0 1rem;
  }
  .map-tools .legend-toggle[aria-expanded="true"],
  #stations-toggle[aria-pressed="true"] {
    background: var(--ink);
    color: #f6f1e7;
  }
  .legend {
    display: none;
    position: absolute;
    z-index: 500;
    top: 4.1rem;
    right: 0.75rem;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.5rem;
    max-width: calc(100% - 1.5rem);
    padding: 0.7rem 0.85rem;
    font-size: 0.88rem;
  }
  .map-wrap.legend-open .legend { display: flex; }
  .map-note {
    position: absolute;
    z-index: 500;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 4.5rem;
  }

  .leaflet-touch .leaflet-bar a {
    width: 2.75rem;
    height: 2.75rem;
    line-height: 2.75rem;
    font-size: 1.4rem;
  }
  .leaflet-container a.leaflet-popup-close-button {
    width: 2.5rem;
    height: 2.5rem;
    font: 1.5rem/2.5rem Tahoma, Verdana, sans-serif;
  }
  .leaflet-popup-content { max-width: calc(100vw - 4rem); }
  .popup-card > strong { display: block; padding-right: 1.8rem; }

  .panel {
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100% - 0.5rem);
    padding-bottom: env(safe-area-inset-bottom);
    border-right: 0;
    border-radius: 1.1rem 1.1rem 0 0;
    box-shadow: 0 -8px 28px rgba(28, 25, 21, 0.18);
    transform: translateY(calc(100% - var(--peek, 7rem)));
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
  }
  .panel.dragging { transition: none; }
  .sheet-handle {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.55rem 0 0.5rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: grab;
    touch-action: none;
  }
  .grabber {
    width: 2.75rem;
    height: 0.32rem;
    border-radius: 999px;
    background: #c9bca6;
  }
  .sheet-hint {
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 700;
  }
  .sheet-hint[hidden] { display: none; }
  .tools { flex: none; padding: 0 0.75rem 0.4rem; }
  .search { order: 1; }
  .segments { order: 2; }
  .filter-toggle {
    display: inline-flex;
    align-self: flex-start;
    order: 3;
    min-height: 2.75rem;
    margin-top: 0.6rem;
  }
  .filters { order: 4; }
  .count { order: 5; }
  .tools .list-notes { order: 6; }
  .search input { min-height: 3rem; }
  .count { display: none; }
  .segments {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0.6rem -0.75rem 0;
    padding: 0 0.75rem 0.1rem;
    scrollbar-width: none;
  }
  .filters {
    display: none;
    flex-wrap: wrap;
    overflow: visible;
    margin: 0.45rem 0 0;
    padding: 0;
  }
  .filters.is-open { display: flex; }
  .segments::-webkit-scrollbar { display: none; }
  .chip, .seg {
    flex: none;
    min-height: 2.75rem;
    padding: 0.3rem 0.95rem;
    font-size: 0.92rem;
  }
  .list {
    flex: 1;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0.2rem 0.75rem 1.2rem;
  }
  .site-footer {
    padding: 0.65rem 0.75rem 0.75rem;
  }
  .site-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
  }
  .list-notes {
    margin-top: 0.35rem;
    padding-bottom: 0.2rem;
  }

  .tags-full { display: none; }
  .tags-brief { display: flex; }
  .tags-detail { display: flex; }
  .card-brief { display: flex; }
  .card-extra { display: none; }
  .card.is-open .card-extra,
  .popup-card.is-open .card-extra { display: block; }
  .card.gap .card-extra { display: block; order: 1; }
  .card.gap .actions { order: 2; }
  .card.gap .card-brief,
  .card.gap .tags-detail { display: none; }
  .card.gap .note { color: var(--ink); }
  .card {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    column-gap: 0.5rem;
    row-gap: 0.4rem;
    align-items: stretch;
    padding: 0.75rem 0.8rem 0.7rem;
  }
  .card-top {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
  }
  .card h2 { flex: 1 1 11rem; min-width: 0; }
  .card-brief {
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 2.75rem;
  }
  .card-brief .more { margin-left: auto; flex: none; }
  .card .phone,
  .card .actions,
  .card .card-extra { order: unset; }
  .card .phone {
    grid-column: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    margin: 0;
    padding: 0 0.65rem;
    border-radius: 999px;
    background: var(--ink);
    color: #f6f1e7;
    font-size: 0.98rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
  }
  a.phone:hover { color: #fff; }
  .card .phone.missing {
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    border: 1px dashed #c9bca6;
    pointer-events: none;
  }
  .card .actions {
    grid-column: 2;
    margin: 0;
  }
  .card .card-extra { grid-column: 1 / -1; }
  .phone {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    margin-top: 0.25rem;
  }
  .actions { flex-wrap: wrap; gap: 0.5rem; }
  .actions a,
  .more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 0.85rem;
    border: 1px solid #cfd8e6;
    border-radius: 999px;
    background: #f4f7fc;
    color: var(--rsia);
    text-decoration: none;
    font-size: 0.9rem;
  }
  .card .actions a { flex: 1; width: 100%; }
}

body.night {
  --ink: #f4efe6;
  --muted: #c4b8a6;
  --paper: #161410;
  --card: #241f1a;
  --line: #3a342c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
  background: var(--paper);
  color: var(--ink);
}

body.night .top {
  background: #100e0c;
  color: #f6f1e7;
}

body.night .chip[aria-pressed="true"],
body.night .seg[aria-pressed="true"] {
  background: #f4efe6;
  border-color: #f4efe6;
  color: #1c1915;
}

body.night .search input,
body.night .chip,
body.night .seg {
  border-color: #4a433a;
  background: #241f1a;
  color: var(--ink);
}

body.night .chip[aria-pressed="true"],
body.night .seg[aria-pressed="true"] {
  background: #f4efe6;
  color: #1c1915;
}

body.night #map { background: #12110f; }

body.night .legend {
  background: rgba(22, 20, 16, 0.94);
  color: var(--ink);
}

body.night .card.gap {
  background: #2a2118;
  border-color: #6b3d28;
}

body.night .tag { background: #332e27; color: #e4d9c8; }
body.night .tag.er { background: #4a2420; color: #ffb4ab; }
body.night .tag.hours-off { background: #3d311c; color: #f0d7a4; }
body.night .tag.detour { background: #1c2a3d; color: #c5d7f2; }
body.night .map-note { background: #100e0c; color: #f6f1e7; }
body.night .pin.gap span { box-shadow: 0 0 0 2px #1c1915; }

body.night .leaflet-bar a,
body.night .leaflet-bar a:hover {
  background-color: #241f1a;
  color: #f4efe6;
  border-bottom-color: #3a342c;
}

body.night .leaflet-control-attribution {
  background: rgba(16, 14, 12, 0.88);
  color: #c4b8a6;
}

body.night .leaflet-control-attribution a { color: #e7b089; }

body.night .map-tools .legend-toggle[aria-expanded="true"],
body.night #stations-toggle[aria-pressed="true"] {
  background: #f4efe6;
  color: #1c1915;
}

@media (max-width: 860px) {
  body.night .card .phone {
    background: #f4efe6;
    color: #1c1915;
  }
  body.night .card .phone.missing {
    background: transparent;
    color: #c4b8a6;
    border-color: #6b645b;
  }
  body.night .map-note.is-nearest #route-fit {
    background: #f4efe6;
    color: #1c1915;
  }
}

@media (hover: none) {
  .chip:active, .seg:active, .card:active,
  .map-tools button:active, .actions a:active, .more:active {
    filter: brightness(0.92);
  }
}

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