/* Light is what is written here; what dark changes follows below. Which of the
   two it is, theme.js says with an attribute on the root: the visitor's choice,
   or else what the device has. So nothing here asks the device itself. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f1f3f5;
  --text: #1b1f24;
  --text-muted: #5c6670;
  --border: #d9dee3;
  --accent: #0b5cad;
  --shadow: 0 2px 12px rgb(0 0 0 / 0.18);

  /* one per mode id, see DRAW_ORDER in app.js */
  --mode-subway: #0b5cad;
  --mode-tram: #d42a2a;
  --mode-bus: #7b3fa0;
  --mode-suburban: #1e8a3c;
  --mode-regional: #4d5a66;
  --mode-longdistance: #d97200;
  --mode-other: #7a7a7a;

  /* ahead of the timetable: a cool colour, apart from the scale of the delays and from every mode */
  --delay-early: #008fae;
  --delay-ok: #2a9d4b;
  --delay-minor: #d9a400;
  --delay-major: #e8710a;
  --delay-severe: #d32f2f;
  --delay-none: #8a9099;
  /* the flag with the question mark on a vehicle without a reported delay: dark enough for the white mark on it, on either map */
  --delay-unknown: #5c6670;

  /* the visitor's own position; lighter than the blue of the U-Bahn, which may be right under it */
  --location: #1a8ef0;

  /* laid over the map outside the area, and the line along its edge */
  --veil: rgb(226 229 233 / 0.66);
  --veil-line: rgb(11 92 173 / 0.55);

  /* The map is toned down so that the vehicles stand out. */
  --map-filter: saturate(0.5) brightness(1.04);
  --gap: 12px;
  /* Installed as an app the page reaches under notches and the home indicator. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c2026;
  --bg-subtle: #272c34;
  --text: #e8ebee;
  --text-muted: #9aa4ae;
  --border: #39404a;
  --accent: #6fb1f2;
  --shadow: 0 2px 14px rgb(0 0 0 / 0.55);
  --mode-regional: #7d8b99;
  --veil: rgb(10 11 14 / 0.6);
  --veil-line: rgb(111 177 242 / 0.6);
  /* Light becomes dark and the hues stay: the map may be any style or set of tiles, and few come in a dark version. */
  --map-filter: invert(1) hue-rotate(180deg) saturate(0.45) brightness(0.92) contrast(0.92);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-subtle);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

/* The icons on the page's own buttons (ICONS in app.js): shapes in the colour
   of the text around them, in a box that whatever holds it centres as a whole. */
.icon { display: block; flex: none; width: 20px; height: 20px; fill: currentColor; }
[hidden] { display: none !important; }

#map {
  position: absolute;
  inset: 0;
  background: var(--bg-subtle);
}

/* what MapLibre draws; app.js lays its own canvas over it */
.maplibregl-canvas { filter: var(--map-filter); }
.overlay-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.maplibregl-map { font-family: inherit; }
.maplibregl-map.clickable .maplibregl-canvas-container { cursor: pointer; }

/* (a button with one of the page's own icons, not a picture of MapLibre's) */
.maplibregl-ctrl-group.own-icon button { display: grid; place-items: center; color: var(--text); }
/* the controls of MapLibre in the colours of the cards */
.maplibregl-ctrl-group,
.maplibregl-ctrl.maplibregl-ctrl-attrib {
  background: var(--bg);
  color: var(--text-muted);
}
.maplibregl-ctrl-group button + button { border-top-color: var(--border); }
.maplibregl-ctrl-attrib a { color: var(--accent); }
/* the marker for a newer version, next to the running one */
.maplibregl-ctrl-attrib a.update { font-weight: 650; white-space: nowrap; }
.maplibregl-ctrl-bottom-right { bottom: var(--safe-bottom); right: var(--safe-right); }
/* Their icons are dark drawings. The hues stay: the one for the visitor's position is blue while it is on, and red while it fails. */
:root[data-theme="dark"] .maplibregl-ctrl-icon,
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1) hue-rotate(180deg); }

/* ---------- cards ---------- */

.card {
  position: absolute;
  z-index: 1000;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.controls {
  /* (above the details: on a narrow screen they may reach up to it, and what hangs at it goes over them) */
  z-index: 1001;
  top: calc(var(--gap) + var(--safe-top));
  left: calc(var(--gap) + var(--safe-left));
  width: 336px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.title { display: flex; align-items: baseline; gap: 8px; }
.title h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
/* the name of the area takes the room between the title and the buttons, on several lines if need be */
.title p { flex: 1; min-width: 0; margin: 0; color: var(--text-muted); font-size: 13px; }

/* the round buttons in the title row: the gear that opens the settings, and
   on a small screen the lens that opens the search (see there) */
.settings-open, .display-toggle, .search-open, .search-close {
  display: grid;
  place-items: center;
  flex: none;
  align-self: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bg-subtle);
  cursor: pointer;
}
.settings-open, .display-toggle, .search-open { margin: -4px 0; color: var(--text-muted); }
.settings-open:hover, .settings-open[aria-expanded="true"], .display-toggle:hover { color: var(--text); }

/* The settings: a small box that hangs at the gear, with a tip that points to
   it, over the rest of the card. (The gear is 30 wide and ends where the card's
   padding begins: the tip sits under its middle.) */
.bubble {
  position: absolute;
  z-index: 3;
  top: 46px;
  right: 6px;
  width: 236px;
  padding: 2px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.bubble::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 16px;
  width: 12px;
  height: 12px;
  border: solid var(--border);
  border-width: 1px 0 0 1px;
  background: var(--bg);
  transform: rotate(45deg);
}
/* A setting: what it is called, and under it the choice. */
.setting { display: grid; gap: 4px; margin-top: 10px; }
.setting > :first-child { color: var(--text-muted); }
.setting .segmented button { padding: 5px 6px; }
.language {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.language:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- search ---------- */

.search { position: relative; display: flex; gap: 6px; color: var(--text-muted); }
/* the lens in the field */
.search-sign { position: absolute; left: 7px; top: calc(50% - 10px); pointer-events: none; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px 6px 31px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.search input::placeholder { color: var(--text-muted); opacity: 1; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* the two buttons that open and shut the search where it is not always there, see the small screens below */
.search-open, .search-close { display: none; }

/* what is found, hanging below the field over the rest of the card and the map */
.search-drop {
  display: none;
  position: absolute;
  z-index: 1;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: min(50vh, 330px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
  color: var(--text);
}
.search.open .search-drop { display: block; }
.search-results { list-style: none; margin: 0; padding: 4px 0; }
.search-results:empty, .search-note:empty { display: none; }
.search-results li { display: flex; align-items: center; gap: 9px; padding: 7px 10px; cursor: pointer; }
.search-results li:hover, .search-results li[aria-selected="true"] { background: var(--bg-subtle); }
/* up to six dots in three columns, so that the names begin below one another */
.search-results .dots { display: grid; flex: none; grid-template-columns: repeat(3, 8px); gap: 2px; }
.search-results .swatch { width: 8px; height: 8px; background: var(--chip-color); }
.search-results .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* a line: where it goes, and below that in small print who runs it */
.search-results .line .name { display: grid; min-width: 0; line-height: 1.25; }
.search-results .line .to, .search-results .line .agency { overflow: hidden; text-overflow: ellipsis; }
.search-results .line .agency { color: var(--text-muted); font-size: 12px; }
.search-results .badge { flex: none; }
/* the headings of lines and stops, where both were found */
.search-heading {
  padding: 6px 10px 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  cursor: default;
}
.search-results li.search-heading:hover { background: none; }
.search-note { margin: 0; padding: 9px 10px; color: var(--text-muted); font-size: 13px; }

/* Its dot stands in the column of the dots in the filters below it (a chip
   has a border of 1 and a padding of 7 before its dot, of 11, and 6 after),
   and so what it says begins where their names do. */
.status {
  margin: 0;
  padding-left: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.status .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--delay-none);
  flex: none;
}
.status[data-state="live"] .dot { background: var(--delay-ok); animation: pulse 2s ease-out infinite; }
.status[data-state="error"] .dot { background: var(--delay-severe); }
/* No realtime data at all: the line is a warning that is not overlooked, with
   a sign in place of the dot. (The ground is --delay-major, thinned.) */
.status .warn { display: none; color: var(--delay-major); }
.status .warn .icon { width: 18px; height: 18px; }
/* (as wide as the search field and the row of filters, not wider) */
.status[data-state="outage"] {
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgb(232 113 10 / 0.16);
  color: var(--text);
  font-weight: 600;
}
.status[data-state="outage"] .dot { display: none; }
.status[data-state="outage"] .warn { display: block; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(42 157 75 / 0.55); }
  100% { box-shadow: 0 0 0 8px rgb(42 157 75 / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none !important; }
  /* the sheets come to rest at once */
  .panel, .dialog { transition: none !important; }
  .chips { scroll-behavior: auto !important; }
  /* the icon that turns while the visitor's position is looked for */
  .maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon { animation: none !important; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* the arrows at the ends of the row where it scrolls, see the small screens below */
/* (min-width: or the card would grow as wide as the row instead of the row scrolling) */
.chips-row { position: relative; min-width: 0; }
.chips-more { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.chip .swatch { background: var(--chip-color); }
.chip .count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="false"] { color: var(--text-muted); background: var(--bg-subtle); }
.chip[aria-pressed="false"] .swatch { background: transparent; box-shadow: inset 0 0 0 2px var(--delay-none); }
.chip[aria-pressed="false"] .name { text-decoration: line-through; }

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.swatch[data-delay="early"] { background: var(--delay-early); }
.swatch[data-delay="ok"] { background: var(--delay-ok); }
.swatch[data-delay="minor"] { background: var(--delay-minor); }
.swatch[data-delay="major"] { background: var(--delay-major); }
.swatch[data-delay="severe"] { background: var(--delay-severe); }
.swatch[data-delay="none"] { background: var(--delay-none); }

.segmented {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
}
.segmented-label { color: var(--text-muted); margin-right: 8px; }
.segmented button {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}
.segmented button + button { border-left: 0; }
.segmented button:first-of-type { border-radius: 8px 0 0 8px; }
.segmented button:last-of-type { border-radius: 0 8px 8px 0; }
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend li { display: inline-flex; align-items: center; gap: 5px; }

.hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}
/* a button that reads as a link: the way to "how it works", in the line that says what the positions are */
.link { padding: 0; border: 0; background: none; text-decoration: underline; cursor: pointer; }
.link:hover, .link:focus-visible { color: var(--accent); }

/* the operator's own links, at the foot of the card: small, and always in view */
.links { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; line-height: 1.35; }
.links a { color: var(--text-muted); }
.links a:hover, .links a:focus-visible { color: var(--accent); }
/* a sample of the grey that lies over the map outside the area */
.swatch.veil {
  margin-right: 6px;
  vertical-align: -1px;
  border-radius: 3px;
  background: var(--veil);
  box-shadow: inset 0 0 0 1.5px var(--veil-line);
}

button:focus-visible, select:focus-visible, .row:focus-visible, .panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- detail panel ---------- */

.panel {
  top: calc(var(--gap) + var(--safe-top));
  right: calc(var(--gap) + var(--safe-right));
  width: 340px;
  max-height: calc(100% - 2 * var(--gap) - 24px - var(--safe-top) - var(--safe-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* What the details are of stays; what is listed scrolls below it. */
#panel-head { flex: none; }
#panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* the bar that moves the details where they are a sheet, see the small screens below */
.handle { display: none; }

.close {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bg-subtle);
  cursor: pointer;
}

.panel-head { padding: 14px 48px 10px 14px; border-bottom: 1px solid var(--border); }
.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.panel-head .sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.panel-head .notes { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-muted); }
.panel-head .notes li { padding-left: 14px; position: relative; }
.panel-head .notes li::before { content: "•"; position: absolute; left: 3px; }
.panel-head .alert { color: var(--delay-severe); font-weight: 600; }
.panel-empty { padding: 14px; color: var(--text-muted); margin: 0; }

.badge {
  display: inline-block;
  min-width: 30px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--badge-color, var(--mode-other));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.rows { list-style: none; margin: 0; padding: 4px 0; }
.row {
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--bg-subtle); }
.row .time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .platform { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.row.cancelled .name, .row.cancelled .time { text-decoration: line-through; color: var(--text-muted); }

/* the vehicles of a line: the stop ahead and the delay, under a heading that says where they go */
.row.vehicle { grid-template-columns: 1fr auto; }
.rows-head { margin: 0; padding: 10px 14px 0; color: var(--text-muted); font-size: 13px; font-weight: 650; }
/* From a trip back to the line it was chosen from: a row above the head, left of the button that closes. */
.back-row { padding: 10px 48px 0 12px; }
.back-row + .panel-head { padding-top: 8px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* --time-chars: how many characters a clock time has at most in the visitor's language (app.js sets it) */
.row { --time-width: calc(var(--time-chars, 5) * 1ch + 4px); }
.row.departure { grid-template-columns: var(--time-width) 30px auto 1fr auto; }
.row.stop { grid-template-columns: 14px var(--time-width) 30px 1fr auto; }
.row.stop.past { color: var(--text-muted); }
.row.stop.next .name { font-weight: 650; }

/* the line with a dot per stop along the left edge of a trip */
.row.stop .rail { position: relative; align-self: stretch; }
.row.stop .rail::before {
  content: "";
  position: absolute;
  left: 5px;
  top: -6px;
  bottom: -6px;
  width: 3px;
  background: var(--badge-color);
  opacity: 0.85;
}
li:first-child > .row.stop .rail::before { top: 50%; }
li:last-child > .row.stop .rail::before { bottom: 50%; }
.row.stop .rail::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--badge-color);
}
.row.stop.past .rail::before, .row.stop.past .rail::after { opacity: 0.4; }
.row.stop.next .rail::after { background: var(--badge-color); }

/* As text a delay is one class "hotter" than as a dot: the yellow is too pale to read on the card. */
.delay { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delay[data-delay="early"] { color: var(--delay-early); }
.delay[data-delay="ok"] { color: var(--delay-ok); }
.delay[data-delay="minor"] { color: var(--delay-major); }
.delay[data-delay="major"], .delay[data-delay="severe"] { color: var(--delay-severe); }

/* ---------- tooltip & banner ---------- */

.tooltip {
  position: absolute;
  z-index: 1100;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner {
  position: absolute;
  z-index: 1200;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* ---------- display mode ---------- */

/* The controls hidden (see "display mode" in app.js): of the card its title
   row stays, with what the page is and the button that brings the rest back –
   and the status line where it is a warning. On a screen on a wall
   (display=fixed) nothing is to be touched: no buttons at all, on the card or
   in the corner of the map, and no details. The legend of the delays stays
   there, as nobody can look up what a colour means. */
:root[data-display] .controls { width: auto; max-width: 336px; }
:root[data-display=""] .controls > :not(.title, .status),
:root[data-display="fixed"] .controls > :not(.title, .status, .legend),
:root[data-display] .status:not([data-state="outage"], [data-state="error"]),
:root[data-display] .title .settings-open,
:root[data-display] .title .search-open,
:root[data-display="fixed"] .title button,
:root[data-display="fixed"] .maplibregl-ctrl-group,
:root[data-display="fixed"] .panel { display: none; }
/* the way out of a screen on a wall: it shows for a moment when the screen is touched */
.display-leave {
  position: absolute;
  z-index: 1200;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- how it works ---------- */

/* A dialog over the page, in the middle of it; the browser lays it and its
   backdrop on top of everything else. What is in it fills it to the edge and
   scrolls where it is too long, so that a click on the dialog itself can only
   be one beside it (app.js closes it then). */
.dialog {
  width: min(480px, calc(100% - 2 * var(--gap)));
  max-height: calc(100% - 2 * var(--gap) - var(--safe-top) - var(--safe-bottom));
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* (only while it is open: a closed dialog is not displayed at all) */
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog-body { overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 18px; }
.dialog h2 { margin: 0 36px 2px 0; font-size: 16px; font-weight: 650; }
.dialog h3 { margin: 14px 0 3px; font-size: 14px; font-weight: 650; }
.dialog p { margin: 0; line-height: 1.45; }
.dialog a { color: var(--accent); }
.dialog .about-source { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }

/* ---------- small screens: controls on top, details as bottom sheet ---------- */

@media (max-width: 720px) {
  :root { --gap: 8px; }

  .controls {
    width: auto;
    right: calc(var(--gap) + var(--safe-right));
    padding: 9px 12px;
    gap: 7px;
  }
  .title h1 { font-size: 16px; }
  /* The search is a button with a lens in the title row. Opened, the field
     takes the place of that row, with a button to shut it again. */
  .search-open, .search-close { display: grid; }
  .search-close { width: 34px; height: 34px; color: var(--text); }
  .search { display: none; }
  .controls.searching .title { display: none; }
  .controls.searching .search { display: flex; }
  /* (16 px: with less, Safari on a phone zooms the page in when the field gets the focus) */
  .search input { padding-top: 5px; padding-bottom: 5px; font-size: 16px; }
  /* clear of the departures, which cover the lower half */
  .search-drop { max-height: min(40vh, 330px); }
  /* One row of chips that scrolls sideways, out to the edges of the card. */
  .chips-row { margin: 0 -12px; }
  /* (scroll-padding: a chip that gets the keyboard focus comes to rest clear of the arrows) */
  .chips { flex-wrap: nowrap; overflow-x: auto; padding: 0 12px 2px; scrollbar-width: none; scroll-behavior: smooth; scroll-padding-inline: 64px; }
  .chips::-webkit-scrollbar { display: none; }
  /* Where the row goes on (app.js knows), the chips fade out under an arrow
     that moves the row on: without it nothing shows that there are more. */
  .chips-more {
    position: absolute;
    top: 0;
    bottom: 2px;
    right: 0;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 6px;
    border: 0;
    border-radius: 0 12px 12px 0;
    background: linear-gradient(to right, transparent, var(--bg) 50%);
    /* Only the round button takes the finger: a swipe that begins on the fade still moves the row. */
    pointer-events: none;
  }
  .chips-more.back {
    right: auto;
    left: 0;
    justify-content: flex-start;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(to left, transparent, var(--bg) 50%);
  }
  .chips-more span {
    pointer-events: auto;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
    display: grid;
    place-items: center;
  }

  /* The details are a sheet from the bottom: as high as what they show, up to
     about half the screen (SHEET_MIDDLE in app.js), until the bar at its top
     or its head has moved it. Then app.js gives it its height, and it glides
     there – but follows a finger that drags it at once. */
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 48%;
    border-radius: 14px 14px 0 0;
    padding-bottom: var(--safe-bottom);
    transition: height 180ms ease;
  }
  .panel.sized { max-height: none; }
  .panel.dragging, .dialog.dragging { transition: none; }
  /* The bar: all of the top edge takes the finger, the stroke in its middle shows where. */
  .handle {
    display: block;
    flex: none;
    position: relative;
    width: 100%;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 14px 14px 0 0;
    background: none;
    cursor: grab;
  }
  .handle::before {
    content: "";
    position: absolute;
    left: calc(50% - 18px);
    top: 8px;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
  }
  /* (a finger on these moves the sheet, not the page under it) */
  .handle, #panel-head, #about-title { touch-action: none; }
  /* No button to close on the sheets: they are dragged down, or the map
     beside them is tapped. The button is still there for a screen reader and
     for the keyboard, and shows itself when it has the focus. */
  .panel .close, .dialog .close {
    top: 18px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .panel .close:focus-visible, .dialog .close:focus-visible {
    width: 32px;
    height: 32px;
    overflow: visible;
    clip-path: none;
  }
  /* (so what is at their top has the whole width) */
  .panel .panel-head, .panel .back-row { padding-right: 14px; }
  .dialog h2 { margin-right: 0; }
  .panel .panel-head { padding-top: 2px; }
  .panel .back-row { padding-top: 0; }
  .panel .back-row + .panel-head { padding-top: 6px; }
  /* "How it works" is a sheet from the bottom too, over the details if they
     are open. Its bar and its heading drag it down to close it. */
  .dialog {
    top: auto;
    width: 100%;
    max-width: none;
    max-height: 82%;
    margin: 0;
    border-radius: 14px 14px 0 0;
    padding-bottom: var(--safe-bottom);
    transition: transform 180ms ease;
  }
  .dialog .dialog-body { padding-top: 2px; }
  .banner { bottom: auto; top: 50%; }
}
