/* Styles for the detours map page (web/index.html). */

/* MapLibre needs its container to have a real height: html and body
   fill the window, and body is a flex row (the sidebar a fixed width,
   the map the rest) whose items stretch to its height. */
html,
body {
  height: 100%;
  margin: 0;
}

/* Design tokens: the page's colours, type and radii, named once. The map
   draws with mapview.js's own constants; the ones the legend repeats are
   here too (--detour-color, --route-grey, --color-closure). */
:root {
  /* The sidebar's width on wide screens, notch included (safe areas). */
  --sidebar-width: calc(320px + env(safe-area-inset-left, 0px));

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;

  --color-text: #1f2328;
  --color-text-secondary: #424850;
  --color-text-muted: #5c636b; /* 6:1 on white */
  --color-border: #e6e8eb;
  --color-border-strong: #c8ccd2;
  --color-outline: #999; /* rings around the legend's swatches */
  --color-surface: #fff;
  --color-surface-sunken: #f4f5f7;
  --color-hover: #f0f4ff;
  --color-selected: #fff7d6;
  --color-accent: #1a4fd6;
  --color-accent-soft: #e8eefc;
  --color-danger: #b00020;
  --color-warning-text: #8a6d00;

  --detour-color: #d500f9; /* mapview.js's DETOUR_COLOR */
  --route-grey: #4a4f55; /* mapview.js's DETOURED_ROUTE_COLOR */
  --color-closure: #3b3f45; /* mapview.js's CLOSURE_COLOR */

  --radius-sm: 4px;
  --radius-pill: 999px;
}

body {
  display: flex;
}

/* The route sidebar: fixed width, a column of status, search, then the
   route list, which alone scrolls (so the search box stays in view). */
#sidebar {
  flex: none; /* don't grow or shrink: always --sidebar-width */
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--color-text);
  font: var(--text-md)/1.4 var(--font);
}

#map {
  flex: 1; /* everything the sidebar doesn't use */
}

/* Keyboard focus, visible on everything (only when using a keyboard:
   :focus-visible skips mouse clicks). Full-width rows and cards draw it
   inside, where it isn't cut off by the scrolling list. */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.route-row:focus-visible,
.card-select:focus-visible,
.timing-group > summary:focus-visible,
#sheet-handle:focus-visible {
  outline-offset: -2px;
}
/* The panel title gets focus from script (on focusing a route); a ring
   there would only say where reading starts. */
#route-panel-title:focus {
  outline: none;
}

/* Read by screen readers, not shown: the standard clip pattern. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The `hidden` attribute is only a browser default (display: none), which
   any `display` rule here would beat; make it always win. */
[hidden] {
  display: none !important;
}

/* The two views below the status line (main.js shows one): the browse
   column (search, chips, list) and the route panel. Both fill the rest
   of the sidebar; `min-height: 0` lets them shrink so their insides
   scroll (see #route-list). */
#browse,
#route-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Banners over the map (index.html): #error (red), #stale (old data,
   amber) and #update (newer detours, a Reload button). At the bottom
   middle of the map (right of the sidebar; phones: above the sheet,
   below), where they cover neither the map key nor the zoom buttons.
   96px of width is kept free so they clear the credits' (i) button
   (bottom right); while the credits are open they move up above them
   (`--credits-height`, from mapview.js: OSM's credit must stay visible).
   `:empty` hides each until main.js fills it. */
.banner {
  position: absolute;
  bottom: calc(12px + var(--credits-height, 0px) + env(safe-area-inset-bottom, 0px));
  left: calc(var(--sidebar-width) + (100% - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(420px, calc(100% - var(--sidebar-width) - 96px));
  padding: 8px 12px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font: var(--text-md)/1.4 var(--font);
  transition: bottom 0.2s ease;
}
.banner:empty {
  display: none;
}
#error {
  border-color: var(--color-danger);
  background: var(--color-danger);
  color: #fff;
}
#stale {
  border-color: #d9a400;
  background: #fff4ce;
  color: #4d3500;
}
#update {
  border-color: #7aa7e0;
  background: #e8f1fc;
  color: #0b3a75;
}
#update button {
  margin-left: 4px;
}

/* The site's name, above the status line (wide screens only: see the
   phone rules). */
#site-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 0;
}
#site-header img {
  border-radius: var(--radius-sm);
}
.site-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.site-tag {
  padding: 1px 6px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 500;
}

/* The status line (how many detours, as of when), at the top of the
   sidebar. Hidden while empty, like the banners. */
#status {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
#status:empty {
  display: none;
}

/* The search, and on phones the "Modes" button beside it. */
#search-row {
  flex: none;
  display: flex;
  gap: 8px;
  margin: 8px 12px;
}
/* With a magnifier drawn in its left padding. */
#search {
  flex: 1;
  min-width: 0;
  padding: 7px 8px 7px 30px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235c636b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E")
    no-repeat 9px 50%;
  color: var(--color-text);
  font: inherit;
}
#search:focus {
  border-color: var(--color-accent);
}

/* The phones' "Modes" button (shown below 700 px): a chip's outline,
   and a chip's "on" look while some modes are off, so a filter shows
   with the chips closed. A caret says it opens something. */
#modes-toggle {
  display: none;
  flex: none;
  padding: 0 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
#modes-toggle::after {
  content: "\00a0\25be"; /* a no-break space and a small down triangle */
}
#modes-toggle[aria-expanded="true"]::after {
  content: "\00a0\25b4"; /* up */
}
#modes-toggle.filtering {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

/* Mode chips: toggles that wrap onto a second line when needed. */
#mode-chips {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--color-border);
}
/* Off: an outline. On: a soft accent tint and a check (the state isn't
   told by colour alone). */
.chip {
  padding: 3px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
}
.chip:hover {
  background: var(--color-hover);
}
.chip[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}
.chip[aria-pressed="true"]::before {
  content: "\2713\00a0"; /* a check and a no-break space */
}
/* The search has no routes of this mode: muted and dashed, still
   clickable. Not opacity: that leaves the text too faint to read. */
.chip.unavailable {
  border-style: dashed;
  color: var(--color-text-muted);
}
.chip.unavailable[aria-pressed="true"] {
  background: var(--color-surface);
}

/* The scrolling part. `min-height: 0` lets a flex item shrink below its
   content's height; without it the list grows past the window instead
   of scrolling. */
#route-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.route-list-empty {
  margin: 12px;
  color: var(--color-text-muted);
}

/* Route list: one section per group, its heading stuck to the top of
   the list while its rows scroll under it. */
.route-section h2 {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 8px 12px 4px;
  background: var(--color-surface-sunken);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* A row: badge | name (takes the slack, cut with "...") | count. */
.route-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 12px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.route-row:hover {
  background: var(--color-hover);
}

/* The defaults here are the fallback for a null color/text_color; the
   route's own colors are set inline by dom.js's routeBadge when present. */
.badge {
  flex: none;
  min-width: 2.6em;
  padding: 1px 5px;
  border-radius: 3px;
  background: #555555;
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.route-row .name {
  flex: 1;
  min-width: 0; /* lets a flex item shrink below its text, so ellipsis works */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-row .count {
  flex: none;
  color: var(--color-danger);
  font-size: var(--text-xs);
}
/* "Near you": past the first rows, a button for the rest. */
.near-more {
  display: block;
  margin: 6px 12px 10px;
}
/* "Near you": how far, on its own line under the name. */
.route-row .distance {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* "Not on the map": unmatched detours, each a <details>. */
.unmatched-note {
  margin: 6px 12px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.unmatched {
  padding: 4px 12px;
  font-size: var(--text-sm);
}
.unmatched summary {
  display: flex; /* name | timing, like a route row */
  gap: 8px;
  cursor: pointer;
}
.unmatched summary .name {
  flex: 1;
}
.unmatched summary .count {
  flex: none;
  color: var(--color-danger);
  font-size: var(--text-xs);
}
.unmatched p {
  margin: 4px 0 4px 12px;
  color: var(--color-text-secondary);
}
.unmatched .message {
  white-space: pre-line;
}

/* Routes without shapes: listed, but greyed. */
.route-row.no-shapes {
  opacity: 0.65; /* var(--color-text) text stays above 4.5:1 contrast */
}

/* --- Safe areas --------------------------------------------------------- */

/* With viewport-fit=cover (index.html) the page runs under a phone's
   notch, rounded corners and home indicator; env(safe-area-inset-*) says
   how far, and is 0 elsewhere (desktops, phones without them). Whatever
   sits at an edge moves in by it. The sidebar grows by its left inset,
   so its content keeps 320 px (the banners centre on the rest). */
#sidebar {
  box-sizing: border-box;
  padding-left: env(safe-area-inset-left, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 700px) {
  #sidebar {
    padding-top: env(safe-area-inset-top, 0px);
  }
}
/* The phone's status bar, in the app added to the home screen: the page
   runs under it (viewport-fit=cover). From iOS 26, WebKit hit-tests 4 px
   below the middle of the top edge, walks up to the first fixed element,
   and fills the status bar with its background-color if it's solid and
   over 10 px each way; otherwise it blurs the page's top, map controls
   and all. So: a real element (a pseudo-element with pointer-events:
   none was passed through to the map, which has no colour), fixed, full
   width, as tall as the status bar, solid white, over everything at that
   point. 0 tall in a browser tab and on desktops, where it's never hit. */
:root {
  --top-edge-height: env(safe-area-inset-top, 0px);
}
/* In the installed app (home screen) the blur runs ~44 px past the
   status bar, so the bar covers that too (github.com/rexdotsh/
   ios-pwa-top-blur: a fixed opaque bar 44 px + the inset tall). Only
   with a status-bar inset: min(44px, inset x 1000) is 0 without one
   (an installed app on Android, below its status bar) and 44 px with. */
@media (display-mode: standalone) {
  :root {
    --top-edge-height: calc(
      env(safe-area-inset-top, 0px) + min(44px, env(safe-area-inset-top, 0px) * 1000)
    );
  }
}
#top-edge {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: var(--top-edge-height);
  background-color: var(--color-surface);
}
.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right {
  top: var(--top-edge-height);
}
.maplibregl-ctrl-top-right,
.maplibregl-ctrl-bottom-right {
  right: env(safe-area-inset-right, 0px);
}
.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Mobile: the sidebar becomes a bottom sheet ---------------------------- */

/* The handle only exists on narrow screens. */
#sheet-handle {
  display: none;
}

/* Below 700 px the map fills the screen and the sidebar sits over its
   bottom as a sheet. Its height comes from main.js (sheet.js's
   `sheetPx`, as `--sheet-height` on <html>), the same number the
   map's fit and pan leave room for; MapLibre's bottom controls (the
   attribution) sit just above it. */
@media (max-width: 699px) {
  /* The map is full width here, with the sheet over its bottom. */
  .banner {
    bottom: calc(var(--sheet-height, 50vh) + 12px + var(--credits-height, 0px));
    left: 50%;
    max-width: calc(100% - 96px);
  }
  body {
    display: block;
  }
  #map {
    position: fixed;
    inset: 0;
  }
  /* The map's left edge is the screen's here (a landscape notch). */
  .maplibregl-ctrl-top-left,
  .maplibregl-ctrl-bottom-left {
    left: env(safe-area-inset-left, 0px);
  }
  #sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding-right: env(safe-area-inset-right, 0px);
    z-index: 2; /* over the map's controls */
    width: auto;
    height: var(--sheet-height, 50vh);
    /* Full height stays below the top bar (#top-edge), handle in view. */
    max-height: calc(100% - var(--top-edge-height));
    overflow: hidden; /* peek shows the handle and status, nothing more */
    border-right: none;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -2px 12px rgb(0 0 0 / 20%);
    transition: height 0.2s ease;
  }
  /* Peek: only the handle and status line. `visibility` (not display)
     keeps the layout; hidden content also leaves the tab order. */
  #sidebar[data-sheet="peek"] > :not(#sheet-handle, #status) {
    visibility: hidden;
  }
  /* The sheet's header: a drag here moves the sheet (main.js), so the
     browser mustn't scroll or zoom from it. */
  #sheet-handle,
  #status {
    touch-action: none;
  }
  /* The sheet's room goes to the list; the status line says what it is. */
  #site-header {
    display: none;
  }
  /* Fingers: rows and choices at least 44 px tall. */
  .route-row,
  .chooser-choice {
    min-height: 44px;
  }
  .chip,
  .panel-header .back,
  .panel-header .whole-route,
  .panel-header .share,
  .near-more {
    min-height: 36px;
  }
  /* 16 px: iOS zooms the page into any smaller text field it focuses. */
  #search {
    font-size: var(--text-lg);
  }
  /* The chips take two rows here: closed behind "Modes" until opened. */
  #modes-toggle {
    display: block;
    min-height: 44px;
  }
  #mode-chips:not(.open) {
    display: none;
  }
  /* The line above the list is the chips' own; with them closed, the
     search row draws it (padding, not margin, so it spans the sheet). */
  #search-row {
    margin: 0;
    padding: 8px 12px;
  }
  #browse:not(:has(#mode-chips.open)) #search-row {
    border-bottom: 1px solid var(--color-border);
  }
  #sheet-handle {
    display: block;
    flex: none;
    width: 100%;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
  }
  /* The grip: a short grey bar in the handle's middle. */
  #sheet-handle::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto;
    border-radius: 2px;
    background: var(--color-outline);
  }
  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: var(--sheet-height, 50vh);
    transition: bottom 0.2s ease;
  }
}

/* While a finger drags the sheet it follows it at once (main.js). */
@media (max-width: 699px) {
  .sheet-dragging #sidebar,
  .sheet-dragging .maplibregl-ctrl-bottom-left,
  .sheet-dragging .maplibregl-ctrl-bottom-right {
    transition: none;
  }
}

@media (max-width: 699px) and (prefers-reduced-motion: reduce) {
  #sidebar,
  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .banner {
    transition: none;
  }
}

/* --- The map's legend (mapview.js addLegend) ----------------------------- */

/* The legend draws the map's look: grey detoured routes, everything
   detour in the accent (:root's colours). */
.legend {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 0 0 2px rgb(0 0 0 / 10%);
  color: var(--color-text);
  font: var(--text-xs)/1.5 var(--font);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  flex: none;
  width: 24px;
}
/* "Map key": opens and closes the rows (closed by default on phones). */
.legend summary {
  cursor: pointer;
  font-weight: 600;
}
.legend[open] summary {
  margin-bottom: 2px;
}
/* A detoured route: a thin grey line. */
.legend-route {
  border-top: 3px solid var(--route-grey);
}
/* Skipped: the grey route with a light accent band (35%) in its middle. */
.legend-skipped {
  height: 6px;
  background:
    linear-gradient(to bottom, transparent 1.5px, var(--route-grey) 1.5px 4.5px, transparent 4.5px)
      0 0 / 100% 100% no-repeat,
    linear-gradient(
      to right,
      transparent 0 6px,
      color-mix(in srgb, var(--detour-color) 35%, transparent) 6px 18px,
      transparent 18px
    );
}
/* Focused: the route in its own color (--route-color, set by mapview.js),
   its skipped part faded white (SKIPPED_FADE_OPACITY 0.65: 35% of the
   color shows), and the direction arrows on it. */
.legend-route-focused {
  border-top: 4px solid var(--route-color);
}
.legend-skipped-focused {
  height: 4px;
  background: linear-gradient(
    to right,
    var(--route-color) 0 6px,
    color-mix(in srgb, var(--route-color) 35%, #fff) 6px 18px,
    var(--route-color) 18px
  );
}
.legend-arrows {
  position: relative;
  height: 6px;
  background: var(--route-color);
}
.legend-arrows::after {
  content: "\203A  \203A"; /* two chevrons (›), white like the map's */
  position: absolute;
  inset: -6px 0 0;
  color: #fff;
  font: bold 12px/1 system-ui, sans-serif;
  text-align: center;
  white-space: pre;
}
/* The detour path: accent dashes over white, outlined so the white gaps
   show on the legend's white too. */
.legend-path {
  box-sizing: border-box;
  height: 6px;
  border: 1px solid var(--color-border-strong);
  background: repeating-linear-gradient(
    to right,
    var(--detour-color) 0 6px,
    #fff 6px 10px
  );
}
/* Zoomed out: an accent circle with the route number (as drawn). */
.legend-marker {
  box-sizing: border-box; /* 22 px with its border; + margins = 24 px */
  width: 22px;
  height: 22px;
  margin: 0 1px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--detour-color);
  box-shadow: 0 0 0 1px var(--color-outline);
  color: #fff;
  font: bold 9px/18px system-ui, sans-serif;
  text-align: center;
}
.legend-marker::after {
  content: "49";
}
/* A start: a solid accent dot, white ring (as drawn). */
.legend-start {
  box-sizing: border-box; /* 14 px with its border; + margins = 24 px */
  width: 14px;
  height: 14px;
  margin: 0 5px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--detour-color);
  box-shadow: 0 0 0 1px var(--color-outline);
}
/* A closed stop: a dark grey dot, white ring, white cross (as drawn;
   mapview.js's CLOSURE_COLOR). */
.legend-closure {
  box-sizing: border-box; /* 16 px with its border; + margins = 24 px */
  position: relative;
  width: 16px;
  height: 16px;
  margin: 0 4px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--color-closure);
  box-shadow: 0 0 0 1px var(--color-outline);
}
.legend-closure::before,
.legend-closure::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 1.75px;
  border-radius: 1px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(45deg);
}
.legend-closure::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
/* Back on route: a hollow accent ring (as drawn). */
.legend-rejoin {
  box-sizing: border-box; /* 10 px with its border; + margins = 24 px */
  width: 10px;
  height: 10px;
  margin: 0 7px;
  border: 2.5px solid var(--detour-color);
  border-radius: 50%;
  background: #fff;
}

/* --- The route panel ---------------------------------------------------- */

.panel-header {
  flex: none;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-tools {
  display: flex;
  gap: 6px;
}
/* The page's buttons (the route panel's, "Show N more", Reload): one
   look, white with an accent label. */
.panel-header .whole-route,
.panel-header .share,
.near-more,
#update button {
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.panel-header .whole-route:hover,
.panel-header .share:hover,
.near-more:hover,
#update button:hover {
  background: var(--color-hover);
}
.panel-header .back {
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}
.panel-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  font-size: var(--text-lg);
}
.panel-header .directions {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* The scrolling part, like #route-list. */
.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.panel-note {
  margin: 12px;
  color: var(--color-text-muted);
}
.panel-note.error {
  color: var(--color-danger);
  white-space: pre-line;
}

/* Group headings look like the list's section headings. */
.timing-group .group-heading,
.timing-group > summary {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 8px 12px 4px;
  background: var(--color-surface-sunken);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.timing-group > summary {
  cursor: pointer;
}
.timing-ended .detour-card {
  color: var(--color-text-muted);
}

.detour-card {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  cursor: pointer;
}
.detour-card:hover {
  background: var(--color-hover);
}
.detour-card.selected {
  background: var(--color-selected);
}
.detour-card h3 {
  margin: 0 0 2px;
  font-size: var(--text-md);
}
/* The headline's button looks like a heading. */
.card-select {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.detour-card p {
  margin: 2px 0;
}
/* A stop closure's card: says so first. */
.detour-card .kind-tag {
  display: inline-block;
  margin: 0 0 4px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--color-closure);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
}
.detour-card .when {
  color: var(--color-text-muted);
}
.detour-card .unplaced {
  color: var(--color-warning-text);
  font-style: italic;
}
.detour-card .message {
  margin-top: 6px;
  white-space: pre-line;
}
/* The detour's turns, numbered. */
.detour-card .steps {
  margin: 6px 0 2px;
  padding-left: 22px;
}
.detour-card .steps li {
  padding: 1px 0;
}
/* The raw message, collapsed when the turns are listed. */
.detour-card .original {
  margin-top: 4px;
  color: var(--color-text-secondary);
}
.detour-card .original summary {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
}
.detour-card .original .message {
  margin-top: 2px;
}
.detour-card .issues {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.detour-card .issues summary {
  cursor: pointer;
}
.detour-card .issues ul {
  margin: 2px 0;
  padding-left: 18px;
}

/* The map's chooser (several routes under a click): a column of buttons,
   each a route badge and its text, like the sidebar's rows. */
.chooser {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: var(--text-sm)/1.4 var(--font);
}
.chooser-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chooser-choice:hover,
.chooser-choice:focus-visible {
  background: var(--color-hover);
}
