/* ============================================================
   ruter base theme — Dansk Cykelturisme
   ------------------------------------------------------------
   Everything here lives in named cascade layers. Any CSS a
   product writes outside these layers wins over them, whatever
   its specificity, so extending the theme never needs
   !important or heavier selectors:

     1. change tokens       :root { --ruter-accent: #043465; }
     2. restyle a part      ruter-legend [data-part="item"] { … }
     3. add your own layer  @layer app { … }

   Load MapLibre's stylesheet through this file only (it is
   imported into ruter.vendor below). A separate unlayered
   <link> to maplibre-gl.css would override the map chrome.
   ============================================================ */

@layer ruter.vendor, ruter.tokens, ruter.base, ruter.components;

@import url("./maplibre-gl.74e94ccfd98f.css") layer(ruter.vendor);

/* ── Tokens ──────────────────────────────────────────────────
   Named by role, not by colour, so a product can re-skin
   without knowing how components use them.                    */

@layer ruter.tokens {
  :root {
    /* Type */
    --ruter-font: "Miki", ui-sans-serif, system-ui, sans-serif;
    --ruter-weight-regular: 400;
    --ruter-weight-bold: 700;
    --ruter-weight-heavy: 800;
    --ruter-text-xs: 0.75rem;
    --ruter-text-sm: 0.875rem;
    --ruter-text-base: 1rem;
    --ruter-text-lg: 1.125rem;
    --ruter-text-xl: 1.25rem;
    --ruter-leading: 1.4;

    /* Colour */
    --ruter-paper: #faf7f1;        /* page canvas */
    --ruter-paper-deep: #f3eee3;
    --ruter-surface: #ffffff;      /* cards, panels, controls */
    --ruter-ink: #12291d;          /* primary text */
    --ruter-ink-soft: #47594e;
    --ruter-ink-faint: #7d8a81;
    --ruter-border: #e9f2ee;
    --ruter-accent: #229966;
    --ruter-accent-strong: #17724b; /* fills under white text; worked out from the accent below */
    --ruter-accent-soft: #e9f2ee;   /* hover tint; worked out from the accent below */
    --ruter-on-accent: #ffffff;
    --ruter-danger: #d64933;        /* destructive actions */
    --ruter-danger-strong: #a03423; /* worked out from the danger colour, like the accent's */
    --ruter-danger-soft: #faece9;
    --ruter-on-danger: #ffffff;
    --ruter-focus: color-mix(in srgb, var(--ruter-accent) 45%, transparent);

    /* Translucent ink, so they sit on any background */
    --ruter-divider: rgb(0 0 0 / 0.12);        /* rules between rows */
    --ruter-outline: rgb(0 0 0 / 0.15);        /* outlined controls */
    --ruter-outline-strong: rgb(0 0 0 / 0.4);
    --ruter-wash: rgb(0 0 0 / 0.04);           /* hover on outlined controls */
    --ruter-press-shade: rgb(0 0 0 / 0.1);     /* over a control while it's pressed */
    --ruter-sunken: rgb(12 59 38 / 0.06);      /* track behind toggle groups */
    --ruter-highlight: color-mix(in srgb, var(--ruter-accent-strong) 9%, transparent);

    /* Shape & space */
    --ruter-radius: 8px;
    --ruter-radius-lg: 12px;       /* cards */
    --ruter-radius-pill: 999px;
    --ruter-space-1: 0.25rem;
    --ruter-space-2: 0.5rem;
    --ruter-space-3: 0.75rem;
    --ruter-space-4: 1rem;
    --ruter-space-5: 1.25rem;
    --ruter-space-6: 1.5rem;

    /* Control sizes: every control (buttons, pills, toggle group, select, dropdown-menu
       items, map buttons) is one of these fixed heights, picked
       with size="sm|md|lg" on the element. md is the default.     */
    --ruter-control-sm: 28px;
    --ruter-control-md: 36px;
    --ruter-control-lg: 44px;

    /* Elevation & motion */
    --ruter-shadow-1: 0 1px 2px rgb(18 41 29 / 0.06), 0 4px 12px -6px rgb(18 41 29 / 0.2);
    --ruter-shadow-2: 0 2px 4px rgb(18 41 29 / 0.06), 0 18px 40px -16px rgb(18 41 29 / 0.28);
    --ruter-ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* Cards: media size beside (orientation="horizontal") or above the body */
    --ruter-card-media-width: 10rem;
    --ruter-card-media-ratio: 16 / 9;

    /* Panels: width beside the map (set it on a panel for its own width),
       and the most of the map a bottom sheet (phones) may cover before its
       content scrolls */
    --ruter-panel-width: 22rem;
    --ruter-panel-height: 60%;

    /* Height of a product's sticky header: where linked-to items land */
    --ruter-scroll-offset: var(--ruter-space-6);

    /* Map — read by the map components at runtime.
       Numbers are unitless because MapLibre takes pixels.
       Data colours (--ruter-suitability-<key>, --ruter-surface-<key>,
       --ruter-transport-<key>) default to taxonomy.json; set them
       here only to override.                                       */
    --ruter-map-font: "Miki";
    --ruter-map-inset: var(--ruter-space-3);
    --ruter-map-scrim: rgb(0 0 0 / 0.15);       /* over a locked map */
    --ruter-map-hint-scrim: rgb(0 0 0 / 0.45);  /* behind the cooperative gestures hint */
    --ruter-route-color: var(--ruter-accent);
    --ruter-route-casing: var(--ruter-paper);
    --ruter-route-width: 5;
    --ruter-route-casing-width: 8;
    /* A hovered or selected road (<ruter-taxonomy-layer interactive>):
       a solid line over a wide, soft glow                           */
    --ruter-map-highlight: #3b82f6;
    --ruter-map-highlight-width: 4;
    --ruter-map-highlight-glow: rgb(147 197 253 / 0.5);
    --ruter-map-highlight-glow-width: 12;
    /* A cycle node network (<ruter-node-network-layer>): quiet lines
       and numbered nodes; the selected nodes in the accent. The
       selected fill is the strong accent, so white numbers on it
       stay at 5:1 or better.                                        */
    --ruter-node-line: var(--ruter-ink-faint);
    --ruter-node-line-width: 3;
    --ruter-node-radius: 11;
    --ruter-node-stroke-width: 2;
    --ruter-node-fill: var(--ruter-surface);
    --ruter-node-stroke: var(--ruter-ink-soft);
    --ruter-node-text: var(--ruter-ink);
    --ruter-node-selected-fill: var(--ruter-accent-strong);
    --ruter-node-selected-stroke: var(--ruter-surface);
    --ruter-node-selected-text: var(--ruter-on-accent);
  }

  /* The accent's shades follow --ruter-accent, so a product that sets
     only the accent gets matching fills and hover tints. The danger
     colour's shades follow --ruter-danger the same way. With the
     default accent they give the literal values above. The strong
     shade's lightness is capped at OKLCH 0.52, so white text on it
     stays at 5:1 or better whatever the accent. Set either token
     yourself to override it. Browsers without relative colours keep
     the literals.                                                   */
  @supports (color: oklch(from red l c h)) {
    :root {
      --ruter-accent-strong: oklch(from var(--ruter-accent) min(l - 0.116, 0.52) calc(c * 0.81) h);
      --ruter-accent-soft: oklch(from var(--ruter-accent) 0.953 calc(c * 0.085) h);
      --ruter-danger-strong: oklch(from var(--ruter-danger) min(l - 0.116, 0.52) calc(c * 0.81) h);
      --ruter-danger-soft: oklch(from var(--ruter-danger) 0.953 calc(c * 0.085) h);
    }
  }
}

/* ── Base: the structure primitives need to work ─────────── */

@layer ruter.base {
  ruter-map {
    display: block;
    position: relative;
    min-height: 240px;
  }

  ruter-map > [data-part="canvas"] {
    position: absolute;
    inset: 0;
  }

  /* A map that fills the screen keeps what sits at its edges clear of a
     phone's notch, rounded corners and home indicator. The insets are 0
     unless the page's viewport meta has viewport-fit=cover. */
  ruter-map:is(:fullscreen, [data-fullscreen]) {
    --_ruter-safe-top: env(safe-area-inset-top, 0px);
    --_ruter-safe-right: env(safe-area-inset-right, 0px);
    --_ruter-safe-bottom: env(safe-area-inset-bottom, 0px);
    --_ruter-safe-left: env(safe-area-inset-left, 0px);
  }

  /* Control areas sit in the map's corners, under the lock's scrim (z-index 3).
     Only their contents take clicks, so the map still pans between them. */
  ruter-map-controls {
    position: absolute;
    z-index: 2;
    top: calc(var(--ruter-map-inset) + var(--_ruter-safe-top, 0px));
    right: calc(var(--ruter-map-inset) + var(--_ruter-safe-right, 0px));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: calc(100% - 2 * var(--ruter-map-inset));
    pointer-events: none;
  }

  ruter-map-controls > * {
    pointer-events: auto;
  }

  ruter-map-controls[position^="bottom"] {
    top: auto;
    bottom: calc(var(--ruter-map-inset) + var(--_ruter-safe-bottom, 0px));
  }

  ruter-map-controls[position$="left"] {
    right: auto;
    left: calc(var(--ruter-map-inset) + var(--_ruter-safe-left, 0px));
    align-items: flex-start;
  }

  /* The lock button has the top-left corner; an area there goes below it */
  ruter-map[gestures="locked"] > ruter-map-controls[position="top-left"] {
    top: calc(2 * var(--ruter-map-inset) + var(--_ruter-control-height, 36px) + var(--_ruter-safe-top, 0px));
  }

  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-scale, ruter-map-attribution, ruter-map-terrain, ruter-map-globe, ruter-map-button) {
    display: block;
  }

  ruter-map-attribution > [data-part="text"][hidden] {
    display: none;
  }

  /* <ruter-map-fullscreen> where the browser has no element full screen.
     Important, so the page's own size for the map (often inline) gives way. */
  ruter-map[data-fullscreen="pseudo"] {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
  }

  /* gestures="…" stacks its scrim and hints inside the map, so their
     z-indexes never reach the page. */
  ruter-map[gestures] {
    isolation: isolate;
  }

  /* gestures="locked": a scrim over the map, its controls and legend (z-index
     2) catches the click that activates it; the lock button is on top. */

  ruter-map > [data-part="lock-scrim"] {
    position: absolute;
    inset: 0;
    z-index: 3;
  }

  ruter-map[data-state="unlocked"] > [data-part="lock-scrim"] {
    visibility: hidden;
    pointer-events: none;
  }

  ruter-map > [data-part="lock"] {
    position: absolute;
    z-index: 4;
    display: inline-flex;
    align-items: center;
  }

  ruter-taxonomy-layer,
  ruter-route-line,
  ruter-node-network-layer {
    display: none;
  }

  ruter-location-search {
    position: relative;
    display: block;
  }

  ruter-location-search [data-part="field"] {
    position: relative;
  }

  ruter-location-search [data-part="listbox"] {
    list-style: none;
    margin: 0;
  }

  /* Read out, not shown: the label (the placeholder says it) and the
     live region. Show the label with ruter-location-search
     [data-part="label"] { position: static; … } */
  ruter-location-search :is([data-part="label"], [data-part="status"]) {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  ruter-location-search :is([data-part="listbox"], [data-part="message"])[hidden] {
    display: none;
  }

  ruter-legend {
    display: block;
  }

  ruter-legend [data-part="list"] {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  ruter-accordion {
    display: block;
  }

  ruter-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
  }

  ruter-badge [data-part="icon"] {
    display: block;
    flex: none;
  }

  ruter-button {
    display: inline-flex;
    vertical-align: middle;
  }

  /* Fills the host, so widening <ruter-button> widens the button */
  ruter-button > :is(button, a) {
    flex: auto;
  }

  /* Controls act on a tap: no wait for a double-tap zoom (nor a page zoom
     from tapping zoom in twice), and a long press doesn't select the label */
  :is(ruter-button > :is(button, a), ruter-pills [data-part="item"], ruter-toggle-group [data-part="item"],
    ruter-legend [data-part="toggle"], ruter-panel [data-part="close"], ruter-map > [data-part="lock"]) {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }

  /* No grey flash over the whole map when a tap on the scrim activates it */
  ruter-map > [data-part="lock-scrim"] {
    -webkit-tap-highlight-color: transparent;
  }

  ruter-button [data-part="icon"] {
    display: block;
    flex: none;
  }

  ruter-icon {
    --_ruter-icon-size: var(--ruter-icon-size, 1em);
    display: inline-block;
    flex: none;
    inline-size: var(--_ruter-icon-size);
    block-size: var(--_ruter-icon-size);
    vertical-align: -0.125em;
  }

  ruter-icon > svg {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    stroke-width: var(--ruter-icon-stroke, 2);
  }

  ruter-pills {
    display: flex;
    flex-wrap: wrap;
  }

  ruter-toggle-group {
    display: inline-flex;
  }

  ruter-toggle-group[orientation="vertical"] {
    flex-direction: column;
  }

  /* One <form> per option (e.g. a server-side language switch) */
  ruter-toggle-group form {
    display: contents;
  }

  /* Items can be <label>s wrapping a radio or checkbox: hide the input, keep it focusable */
  :is(ruter-pills, ruter-toggle-group) [data-part="item"]:has(> input) {
    position: relative;
  }

  :is(ruter-pills, ruter-toggle-group) [data-part="item"] > input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  /* align="end|center" is also the legacy HTML presentational attribute,
     which browsers map to text-align on the element. The menu's content
     inherits from it, so the text inside would follow where the content is
     placed. Inherit as any element does (an author rule beats the hint). */
  ruter-dropdown-menu {
    display: inline-block;
    text-align: inherit;
  }

  /* The theme draws the chevron on the host, over the select */
  ruter-select {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
  }

  ruter-select > select {
    appearance: none;
  }

  ruter-select::after {
    pointer-events: none;
  }

  /* Until the element upgrades and makes the content a popover */
  ruter-dropdown-menu:not(:defined) [data-part="content"] {
    display: none;
  }

  ruter-card {
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

  /* Popups (RuterPopup subclasses; add new popovers to these lists): a
     column of header, content and footer where only the content scrolls.
     Closed, they're hidden, once their closing animation (data-ending-style)
     has run. */
  :is(ruter-panel) {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  :is(ruter-panel):not([open], [data-ending-style]) {
    visibility: hidden;
  }

  :is(ruter-panel) > :is([data-part="header"], [data-part="footer"]) {
    flex: none;
  }

  :is(ruter-panel) > [data-part="content"] {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* A panel floats over its map, above the map's controls, legend and lock
     (an app's own UI, so a locked map doesn't block it). Beside the map on wider screens, full height; a bottom sheet on
     phones, as tall as its content up to --ruter-panel-height. */
  ruter-panel {
    position: absolute;
    z-index: 5;
    top: calc(var(--ruter-map-inset) + var(--_ruter-safe-top, 0px));
    bottom: calc(var(--ruter-map-inset) + var(--_ruter-safe-bottom, 0px));
    inset-inline-start: calc(var(--ruter-map-inset) + var(--_ruter-safe-left, 0px));
    width: min(var(--ruter-panel-width), 100% - 2 * var(--ruter-map-inset));
  }

  ruter-panel[side="end"] {
    inset-inline: auto calc(var(--ruter-map-inset) + var(--_ruter-safe-right, 0px));
  }

  @media (max-width: 639px) {
    ruter-panel,
    ruter-panel[side="end"] {
      inset: auto 0 0;
      width: auto;
      max-height: var(--ruter-panel-height);
      /* clear of the home indicator when the map fills the screen */
      padding-bottom: var(--_ruter-safe-bottom, 0px);
    }

    /* The header is the bottom sheet's drag handle: swipe it down to close. */
    ruter-panel > [data-part="header"] {
      touch-action: none;
    }
  }

  /* A link part stretches over the whole card. Other links, buttons and
     fields in a linked card sit above it, so they stay usable. */
  ruter-card [data-part="link"]::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  ruter-card:has([data-part="link"]) :is(a[href], button, input, select, textarea, label, summary, [tabindex]):not([data-part="link"]) {
    position: relative;
    z-index: 1;
  }
}

/* ── Components ──────────────────────────────────────────── */

@layer ruter.components {
  /* Control sizes. size="sm|md|lg" on a control element picks its
     fixed height, text size and inline padding; md is the default.
     The --_ruter-control-* properties are internal: set the
     --ruter-control-<size> tokens instead.                      */

  :is(ruter-button, ruter-pills, ruter-toggle-group, ruter-dropdown-menu, ruter-select, ruter-location-search, ruter-map) {
    --_ruter-control-height: var(--ruter-control-md);
    --_ruter-control-text: var(--ruter-text-sm);
    --_ruter-control-padding: 14px;
  }

  :is(ruter-button, ruter-pills, ruter-toggle-group, ruter-dropdown-menu, ruter-select, ruter-location-search, ruter-map)[size="sm"] {
    --_ruter-control-height: var(--ruter-control-sm);
    --_ruter-control-text: var(--ruter-text-xs);
    --_ruter-control-padding: 10px;
  }

  :is(ruter-button, ruter-pills, ruter-toggle-group, ruter-dropdown-menu, ruter-select, ruter-location-search, ruter-map)[size="lg"] {
    --_ruter-control-height: var(--ruter-control-lg);
    --_ruter-control-text: var(--ruter-text-base);
    --_ruter-control-padding: 18px;
  }

  /* Button variants. variant="primary|outline|ghost|muted|surface" on
     <ruter-button> (also a dropdown menu's trigger); outline|ghost|muted
     on <ruter-pills> (primary would leave nothing to show selection
     with) and <ruter-select>. Defaults: primary for buttons, outline
     for pills and selects.
     The --_ruter-button-* properties are internal. The -bg ones are
     read as `background`, so one can layer a tint over a fill.   */

  :is(ruter-button, ruter-pills, ruter-select)[variant="ghost"] {
    --_ruter-button-bg: transparent;
    --_ruter-button-fg: var(--ruter-ink-soft);
    --_ruter-button-border: transparent;
    --_ruter-button-hover-bg: var(--ruter-accent-soft);
    --_ruter-button-hover-fg: var(--ruter-accent-strong);
    --_ruter-button-hover-border: transparent;
  }

  ruter-pills,
  ruter-select,
  :is(ruter-button, ruter-pills, ruter-select)[variant="outline"] {
    --_ruter-button-bg: transparent;
    --_ruter-button-fg: var(--ruter-ink);
    --_ruter-button-border: var(--ruter-outline);
    --_ruter-button-hover-bg: var(--ruter-wash);
    --_ruter-button-hover-fg: var(--ruter-ink);
    --_ruter-button-hover-border: var(--ruter-outline-strong);
  }

  /* An outline button is filled with the surface, as shadcn's is, so it
     reads the same on a tinted panel or over a map. The hover tint is
     translucent, so it goes over the fill rather than replacing it.
     Pills and selects stay see-through, like shadcn's toggles and selects. */
  ruter-button[variant="outline"] {
    --_ruter-button-bg: var(--ruter-surface);
    --_ruter-button-hover-bg: linear-gradient(var(--ruter-wash), var(--ruter-wash)) var(--ruter-surface);
  }

  :is(ruter-button, ruter-pills, ruter-select)[variant="muted"] {
    --_ruter-button-bg: var(--ruter-sunken);
    --_ruter-button-fg: var(--ruter-ink);
    --_ruter-button-border: transparent;
    --_ruter-button-hover-bg: color-mix(in srgb, var(--ruter-accent-strong) 12%, transparent);
    --_ruter-button-hover-fg: var(--ruter-ink);
    --_ruter-button-hover-border: transparent;
  }

  /* The map's lock-button look: white, a 2px border, a shadow, the
     accent border on hover. <ruter-map> draws its lock button with it,
     and variant="surface" gives an app's buttons over a map the same
     look. (Map controls are outline buttons on a white fill.) */
  ruter-map,
  ruter-button[variant="surface"] {
    --_ruter-button-bg: var(--ruter-surface);
    --_ruter-button-fg: var(--ruter-ink);
    --_ruter-button-border: var(--ruter-border);
    --_ruter-button-hover-bg: var(--ruter-paper);
    --_ruter-button-hover-fg: var(--ruter-ink);
    --_ruter-button-hover-border: var(--ruter-accent);
  }

  /* Colour. color="accent|neutral|danger" on <ruter-button> and
     <ruter-badge> picks the hue; variant picks how it's applied.
     Without it nothing changes: a primary button and every badge use
     the accent, and the other button variants are neutral.
     color="neutral" only changes a primary button (an ink fill): the
     other variants are neutral already.
     The --_ruter-color-* properties are internal.                */

  :is(ruter-button, ruter-badge) {
    --_ruter-color: var(--ruter-accent);
    --_ruter-color-strong: var(--ruter-accent-strong);
    --_ruter-color-soft: var(--ruter-accent-soft);
    --_ruter-on-color: var(--ruter-on-accent);
    --_ruter-color-hover: color-mix(in srgb, var(--_ruter-color-strong) 80%, var(--ruter-ink));
  }

  :is(ruter-button, ruter-badge)[color="danger"] {
    --_ruter-color: var(--ruter-danger);
    --_ruter-color-strong: var(--ruter-danger-strong);
    --_ruter-color-soft: var(--ruter-danger-soft);
    --_ruter-on-color: var(--ruter-on-danger);
  }

  :is(ruter-button, ruter-badge)[color="neutral"] {
    --_ruter-color: var(--ruter-ink-soft);
    --_ruter-color-strong: var(--ruter-ink);
    --_ruter-color-soft: var(--ruter-wash);
    --_ruter-on-color: var(--ruter-surface);
    --_ruter-color-hover: var(--ruter-ink-soft);
  }

  /* A standalone button fills with the strong shade: white bold text on
     --ruter-accent is under 4.5:1 at control sizes. */
  ruter-button,
  ruter-button[variant="primary"] {
    --_ruter-button-bg: var(--_ruter-color-strong);
    --_ruter-button-fg: var(--_ruter-on-color);
    --_ruter-button-border: var(--_ruter-color-strong);
    --_ruter-button-hover-bg: var(--_ruter-color-hover);
    --_ruter-button-hover-fg: var(--_ruter-on-color);
    --_ruter-button-hover-border: var(--_ruter-color-hover);
  }

  ruter-button[color]:not([color="neutral"])[variant="outline"] {
    --_ruter-button-fg: var(--_ruter-color-strong);
    --_ruter-button-border: var(--_ruter-color);
    --_ruter-button-hover-bg: linear-gradient(var(--_ruter-color-soft), var(--_ruter-color-soft)) var(--ruter-surface);
    --_ruter-button-hover-fg: var(--_ruter-color-strong);
    --_ruter-button-hover-border: var(--_ruter-color-strong);
  }

  ruter-button[color]:not([color="neutral"])[variant="ghost"] {
    --_ruter-button-fg: var(--_ruter-color-strong);
    --_ruter-button-hover-bg: var(--_ruter-color-soft);
    --_ruter-button-hover-fg: var(--_ruter-color-strong);
  }

  ruter-button[color]:not([color="neutral"])[variant="muted"] {
    --_ruter-button-bg: color-mix(in srgb, var(--_ruter-color-strong) 8%, transparent);
    --_ruter-button-fg: var(--_ruter-color-strong);
    --_ruter-button-hover-bg: color-mix(in srgb, var(--_ruter-color-strong) 14%, transparent);
    --_ruter-button-hover-fg: var(--_ruter-color-strong);
  }

  ruter-button[color]:not([color="neutral"])[variant="surface"] {
    --_ruter-button-fg: var(--_ruter-color-strong);
    --_ruter-button-hover-fg: var(--_ruter-color-strong);
    --_ruter-button-hover-border: var(--_ruter-color);
  }

  /* Map */

  ruter-map {
    font-family: var(--ruter-font);
    color: var(--ruter-ink);
    background: var(--ruter-paper-deep);
    border-radius: var(--ruter-radius);
    overflow: hidden;
  }

  ruter-map .maplibregl-map {
    font-family: inherit;
  }

  /* Map controls are <ruter-button variant="outline" square>s at the map's
     size (36px at md), filled like any outline button so the map doesn't
     show through, with a soft shadow. Tints go over the fill.
     <ruter-button-group> joins several, as the zoom buttons are.
     An app's own outline buttons in a corner area, on their own, in a
     group or as a dropdown menu's trigger, look the same: the shadow, the
     "on" state and the disabled look. */

  ruter-map-controls {
    gap: var(--ruter-space-2);
  }

  /* Take the size from <ruter-map> rather than the button's own default */
  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button) > ruter-button:not([size]) {
    --_ruter-control-height: inherit;
    --_ruter-control-text: inherit;
    --_ruter-control-padding: inherit;
  }

  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button, ruter-map-attribution) > ruter-button[variant] > [data-part="button"],
  :is(ruter-map-controls, ruter-map-controls > :is(ruter-dropdown-menu, ruter-button-group)) > ruter-button[variant="outline"] > :is(button, a) {
    box-shadow: var(--ruter-shadow-1);
    -webkit-tap-highlight-color: transparent;
  }

  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button, ruter-map-attribution) > ruter-button[variant] > [data-part="button"]:focus-visible,
  :is(ruter-map-controls, ruter-map-controls > :is(ruter-dropdown-menu, ruter-button-group)) > ruter-button[variant="outline"] > :is(button, a):focus-visible {
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  /* Faded, the map would show through: grey the icon instead, and no hover tint */
  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button, ruter-map-attribution) > ruter-button[variant] > [data-part="button"]:disabled,
  :is(ruter-map-controls, ruter-map-controls > :is(ruter-dropdown-menu, ruter-button-group)) > ruter-button[variant="outline"] > :is(button:disabled, [aria-disabled="true"]) {
    opacity: 1;
    color: var(--ruter-ink-faint);
    background: var(--_ruter-button-bg);
    cursor: default;
  }

  /* On: a pressed toggle, an open panel's button or menu, a followed position */
  :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button, ruter-map-attribution) > ruter-button[variant] > [data-part="button"]:is([aria-pressed="true"], [aria-expanded="true"]),
  :is(ruter-map-controls, ruter-map-controls > :is(ruter-dropdown-menu, ruter-button-group)) > ruter-button[variant="outline"] > :is(button, a):is([aria-pressed="true"], [aria-expanded="true"]) {
    --_tint: var(--ruter-accent-soft);
    color: var(--ruter-accent-strong);
    background: linear-gradient(var(--_tint), var(--_tint)) var(--ruter-surface);
    border-color: var(--ruter-accent);
  }

  /* A group casts one shadow, not one per button */
  ruter-button-group:has(> :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button)),
  ruter-map-controls > ruter-button-group:has(> ruter-button[variant="outline"]) {
    box-shadow: var(--ruter-shadow-1);
  }

  ruter-button-group :is(ruter-map-zoom-in, ruter-map-zoom-out, ruter-map-compass, ruter-map-geolocate, ruter-map-fullscreen,
    ruter-map-terrain, ruter-map-globe, ruter-map-button, ruter-map-attribution) > ruter-button[variant] > [data-part="button"]:not(:focus-visible),
  ruter-map-controls > ruter-button-group > ruter-button[variant="outline"] > :is(button, a):not(:focus-visible) {
    box-shadow: none;
  }

  /* The geolocate button stays pressed while the map has moved off the
     position, but without the tint. As specific as the "on" rule above
     and then some, so it wins over it. */
  ruter-map-geolocate[data-state="background"] > ruter-button[variant] > [data-part="button"][aria-pressed="true"] {
    --_tint: transparent;
    color: var(--ruter-ink);
    border-color: var(--ruter-outline);
  }

  ruter-map-geolocate[data-state="locating"] [data-part="icon"] {
    animation: ruter-map-locating 1s ease-in-out infinite alternate;
  }

  @keyframes ruter-map-locating {
    to { opacity: 0.35; }
  }

  ruter-map-geolocate[data-state="error"] [data-part="icon"] {
    color: var(--ruter-ink-faint);
  }

  /* The position: a dot, and a circle for its accuracy (sized inline) */

  ruter-map [data-part="user-location"] {
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border: 3px solid var(--ruter-surface);
    border-radius: 50%;
    background: var(--ruter-accent);
    box-shadow: 0 0 0 1px var(--ruter-outline), var(--ruter-shadow-1);
  }

  ruter-map [data-part="accuracy"] {
    box-sizing: border-box;
    border: 1px solid color-mix(in srgb, var(--ruter-accent) 40%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--ruter-accent) 12%, transparent);
    pointer-events: none;
  }

  /* Attribution: a small round info button (sm, whatever the map's size)
     that opens into a pill of credits */

  ruter-map-attribution {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    max-width: 100%;
    border-radius: var(--ruter-radius-pill);
    font-size: var(--ruter-text-xs);
    line-height: 1.3;
    color: var(--ruter-ink-soft);
  }

  /* The credits and the scale sit on a frosted backing: the map shows
     through, blurred, so the busy map doesn't run into the small text. */
  ruter-map-attribution[open] {
    background: color-mix(in srgb, var(--ruter-surface) 85%, transparent);
    -webkit-backdrop-filter: blur(8px) saturate(1.4);
    backdrop-filter: blur(8px) saturate(1.4);
  }

  ruter-map-attribution > ruter-button {
    flex: none;
  }

  ruter-map-attribution > [data-part="text"] {
    padding: 4px var(--ruter-space-2) 4px var(--ruter-space-3);
  }

  ruter-map-attribution a {
    color: inherit;
  }

  /* Scale: a bar to scale with the distance inside it */

  ruter-map-scale [data-part="bar"] {
    box-sizing: border-box;
    padding: 0 4px;
    border: 2px solid var(--ruter-ink-soft);
    border-top: 0;
    background: color-mix(in srgb, var(--ruter-surface) 75%, transparent);
    -webkit-backdrop-filter: blur(8px) saturate(1.4);
    backdrop-filter: blur(8px) saturate(1.4);
    font-size: var(--ruter-text-xs);
    line-height: 1.4;
    color: var(--ruter-ink);
    white-space: nowrap;
  }

  ruter-map:fullscreen,
  ruter-map[data-fullscreen] {
    border-radius: 0;
  }

  ruter-map .maplibregl-popup-content {
    font-family: var(--ruter-font);
    color: var(--ruter-ink);
    background: var(--ruter-surface);
    border: 2px solid var(--ruter-border);
    border-radius: var(--ruter-radius);
    box-shadow: var(--ruter-shadow-2);
    padding: var(--ruter-space-3) var(--ruter-space-4);
  }

  /* gestures="cooperative": MapLibre's hint ("Use Ctrl + scroll…"), in the
     theme's type, under the controls rather than over the whole page. */

  ruter-map .maplibregl-cooperative-gesture-screen {
    z-index: 1;
    padding: var(--ruter-space-6);
    background: var(--ruter-map-hint-scrim);
    color: var(--ruter-on-accent);
    font-family: var(--ruter-font);
    font-size: var(--ruter-text-lg);
    font-weight: var(--ruter-weight-bold);
    line-height: var(--ruter-leading);
    text-align: center;
  }

  /* gestures="locked": a round lock icon and, while locked, the label as an accent
     pill beside it. Once active only the icon shows; the label stays as the
     button's accessible name. data-pulse hints at it when the user wheels or
     pinches over the locked map. */

  ruter-map > [data-part="lock-scrim"] {
    background: var(--ruter-map-scrim);
    cursor: pointer;
    transition: opacity 0.3s, visibility 0.3s;
  }

  ruter-map[data-state="unlocked"] > [data-part="lock-scrim"] {
    opacity: 0;
  }

  ruter-map > [data-part="lock"] {
    top: calc(var(--ruter-map-inset) + var(--_ruter-safe-top, 0px));
    left: calc(var(--ruter-map-inset) + var(--_ruter-safe-left, 0px));
    gap: calc(var(--ruter-space-2) + 4px); /* + the label's 4px ring */
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: var(--_ruter-control-text);
    color: var(--_ruter-button-fg);
    cursor: pointer;
    transform-origin: left center;
    -webkit-tap-highlight-color: transparent;
  }

  ruter-map > [data-part="lock"]:focus-visible {
    outline: none;
  }

  ruter-map > [data-part="lock"] [data-part="lock-icon"] {
    box-sizing: border-box;
    flex: none;
    width: var(--_ruter-control-height);
    height: var(--_ruter-control-height);
    padding: calc(var(--_ruter-control-height) * 0.22);
    background-color: var(--_ruter-button-bg);
    border: 2px solid var(--_ruter-button-border);
    border-radius: var(--ruter-radius-pill);
    box-shadow: var(--ruter-shadow-1);
    transition: border-color 0.15s, background-color 0.15s;
  }

  /* Hovering or pressing the locked map does the button too: a click anywhere activates it */
  @media (hover: hover) {
    ruter-map > [data-part="lock"]:hover [data-part="lock-icon"],
    ruter-map[data-state="locked"] > [data-part="lock-scrim"]:hover ~ [data-part="lock"] [data-part="lock-icon"] {
      background-color: var(--_ruter-button-hover-bg);
      border-color: var(--_ruter-button-hover-border);
    }
  }

  ruter-map > [data-part="lock"]:active [data-part="lock-icon"],
  ruter-map[data-state="locked"] > [data-part="lock-scrim"]:active ~ [data-part="lock"] [data-part="lock-icon"] {
    background-color: var(--_ruter-button-hover-bg);
    border-color: var(--_ruter-button-hover-border);
  }

  ruter-map > [data-part="lock"]:focus-visible [data-part="lock-icon"] {
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-map > [data-part="lock"] [data-part="lock-label"] {
    display: inline-flex;
    align-items: center;
    height: calc(var(--_ruter-control-height) - 12px);
    padding-inline: var(--ruter-space-2);
    background: var(--ruter-accent);
    color: var(--ruter-on-accent);
    border-radius: var(--ruter-radius-pill);
    box-shadow: 0 0 0 4px var(--ruter-surface), var(--ruter-shadow-1);
    white-space: nowrap;
  }

  @media (hover: hover) {
    ruter-map > [data-part="lock"]:hover [data-part="lock-label"],
    ruter-map[data-state="locked"] > [data-part="lock-scrim"]:hover ~ [data-part="lock"] [data-part="lock-label"] {
      background: var(--ruter-accent-strong);
    }
  }

  ruter-map > [data-part="lock"]:active [data-part="lock-label"],
  ruter-map[data-state="locked"] > [data-part="lock-scrim"]:active ~ [data-part="lock"] [data-part="lock-label"] {
    background: var(--ruter-accent-strong);
  }

  ruter-map[data-state="unlocked"] > [data-part="lock"] [data-part="lock-label"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }

  ruter-map > [data-part="lock"][data-pulse] {
    animation: ruter-map-lock-pulse 0.45s var(--ruter-ease-out);
  }

  ruter-map > [data-part="lock"][data-pulse] [data-part="lock-icon"] {
    animation: ruter-map-lock-glow 0.45s var(--ruter-ease-out);
  }

  @keyframes ruter-map-lock-pulse {
    30% { scale: 1.08; }
  }

  @keyframes ruter-map-lock-glow {
    30% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ruter-accent) 40%, transparent); }
  }

  /* A legend placed inside a map floats over it */
  ruter-map > ruter-legend {
    position: absolute;
    left: calc(var(--ruter-map-inset) + var(--_ruter-safe-left, 0px));
    bottom: calc(var(--ruter-map-inset) + var(--_ruter-safe-bottom, 0px));
    z-index: 2;
    max-width: calc(100% - 2 * var(--ruter-map-inset));
    background: var(--ruter-surface);
    border-radius: var(--ruter-radius);
    box-shadow: var(--ruter-shadow-2);
    padding: var(--ruter-space-3);
  }

  /* Legend */

  ruter-legend {
    font-family: var(--ruter-font);
    font-size: var(--ruter-text-sm);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink);
  }

  ruter-legend [data-part="heading"] {
    margin: 0 0 var(--ruter-space-2);
    font-size: var(--ruter-text-xs);
    font-weight: var(--ruter-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ruter-ink-soft);
  }

  ruter-legend [data-part="list"] {
    display: grid;
    gap: var(--ruter-space-1);
  }

  ruter-legend[orientation="horizontal"] [data-part="list"] {
    grid-auto-flow: column;
    gap: var(--ruter-space-3);
  }

  ruter-legend [data-part="item"] {
    display: flex;
    align-items: center;
    gap: var(--ruter-space-2);
  }

  ruter-legend [data-part="swatch"] {
    flex: none;
    width: 1.5rem;
    height: 0.375rem;
    border-radius: var(--ruter-radius-pill);
    background: var(--ruter-swatch);
  }

  /* Toggle legends (filters) */
  ruter-legend [data-part="toggle"] {
    all: unset;
    display: flex;
    align-items: center;
    gap: var(--ruter-space-2);
    margin: calc(-1 * var(--ruter-space-1));
    padding: var(--ruter-space-1);
    border-radius: calc(var(--ruter-radius) / 2);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  @media (hover: hover) {
    ruter-legend [data-part="toggle"]:hover {
      background: var(--ruter-accent-soft);
    }
  }

  ruter-legend [data-part="toggle"]:active {
    background: var(--ruter-accent-soft);
  }

  ruter-legend [data-part="toggle"]:focus-visible {
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-legend [data-part="item"][data-state="off"] [data-part="swatch"] {
    opacity: 0.25;
  }

  ruter-legend [data-part="item"][data-state="off"] [data-part="label"] {
    color: var(--ruter-ink-faint);
    text-decoration: line-through;
  }

  /* Width scales: the swatch shows the line weight, not a colour */
  ruter-legend[data-kind="width"] [data-part="swatch"] {
    height: calc(var(--ruter-swatch-width) * 1px);
    background: var(--ruter-ink-soft);
  }

  /* Dashed categories (ferry, railway) */
  ruter-legend [data-part="item"][data-dashed] [data-part="swatch"] {
    height: 0;
    background: none;
    border-top: 3px dashed var(--ruter-swatch);
    border-radius: 0;
  }

  /* Accordion */

  ruter-accordion {
    font-family: var(--ruter-font);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink);
    border-top: 1px solid var(--ruter-divider);
  }

  ruter-accordion [data-part="item"] {
    border-bottom: 1px solid var(--ruter-divider);
    scroll-margin-top: var(--ruter-scroll-offset);
    transition: background-color 0.6s var(--ruter-ease-out);
  }

  /* Just arrived at via a link: tint it, bleeding into the gutter so text doesn't move */
  ruter-accordion [data-part="item"][data-state="targeted"] {
    margin-inline: calc(-1 * var(--ruter-space-3));
    padding-inline: var(--ruter-space-3);
    border-radius: var(--ruter-radius);
    background: var(--ruter-highlight);
  }

  ruter-accordion [data-part="trigger"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ruter-space-4);
    padding: var(--ruter-space-4) 0;
    font-size: var(--ruter-text-base);
    font-weight: var(--ruter-weight-bold);
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* Clicking it toggles; it shouldn't also select its text */
    -webkit-user-select: none;
    user-select: none;
  }

  ruter-accordion [data-part="trigger"]::-webkit-details-marker {
    display: none;
  }

  @media (hover: hover) {
    ruter-accordion [data-part="trigger"]:hover {
      color: var(--ruter-accent-strong);
    }
  }

  ruter-accordion [data-part="trigger"]:active {
    color: var(--ruter-accent-strong);
  }

  ruter-accordion [data-part="trigger"]:focus-visible {
    outline: none;
    border-radius: calc(var(--ruter-radius) / 2);
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  /* A heading inside the trigger (Base UI's Accordion.Header) looks like
     the trigger's own text, whatever its level */
  ruter-accordion [data-part="trigger"] > [data-part="header"] {
    margin: 0;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
  }

  ruter-accordion [data-part="trigger"][data-disabled] {
    cursor: not-allowed;
    color: var(--ruter-ink-faint);
  }

  /* A plus that becomes a minus: icons/plus.svg, its two strokes masked
     separately so the upright can fold away. Drawn in CSS, so it shows
     without JavaScript too. */
  ruter-accordion [data-part="marker"] {
    position: relative;
    flex: none;
    width: 1.25em;
    height: 1.25em;
  }

  ruter-accordion [data-part="marker"]::before,
  ruter-accordion [data-part="marker"]::after {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    mask: no-repeat center / 100%;
  }

  ruter-accordion [data-part="marker"]::before {
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M5 12h14'/></svg>");
  }

  ruter-accordion [data-part="marker"]::after {
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M12 5v14'/></svg>");
    transition: transform 0.2s var(--ruter-ease-out);
  }

  ruter-accordion [open] > [data-part="trigger"] [data-part="marker"]::after {
    transform: scaleY(0);
  }

  /* Slide the content open and shut. ::details-content wraps everything
     after the summary; a 0fr → 1fr grid row animates to the content's
     own height, and content-visibility is held over (allow-discrete) so
     the closing slide is visible before the browser hides the content.
     Browsers without ::details-content snap open and shut as before. */
  ruter-accordion [data-part="item"]::details-content {
    display: grid;
    grid-template-rows: 0fr;
    /* Clip only vertically, so focus rings at the sides still show */
    overflow: visible clip;
    transition:
      grid-template-rows 0.2s var(--ruter-ease-out),
      content-visibility 0.2s allow-discrete;
  }

  ruter-accordion [data-part="item"][open]::details-content {
    grid-template-rows: 1fr;
  }

  ruter-accordion [data-part="content"] {
    min-height: 0;
    max-width: 68ch;
    color: var(--ruter-ink-soft);
  }

  /* The space below the content. Padding would set a floor under the
     collapsing row, so the last 1.25rem would snap rather than slide. */
  ruter-accordion [data-part="content"]::after {
    content: "";
    display: block;
    height: 1.25rem;
  }

  ruter-accordion [data-part="content"] > :first-child {
    margin-top: 0;
  }

  ruter-accordion [data-part="content"] > :last-child {
    margin-bottom: 0;
  }

  /* Badge. A static label (a facility, a certification), not a control,
     so its sizes sit below the control heights: sm 22px, md 28px,
     lg 36px (lines up with md controls). An optional icon part
     comes first; inline SVGs drawn with currentColor follow the
     variant. The --_ruter-badge-* properties are internal.       */

  ruter-badge {
    --_ruter-badge-height: 28px;
    --_ruter-badge-text: var(--ruter-text-sm);
    --_ruter-badge-padding: 12px;
    --_ruter-badge-gap: 6px;
    --_ruter-badge-fg: var(--_ruter-color-strong);
    --_ruter-badge-bg: transparent;
    --_ruter-badge-border: var(--_ruter-color-strong);
    box-sizing: border-box;
    gap: var(--_ruter-badge-gap);
    block-size: var(--_ruter-badge-height);
    padding: 0 var(--_ruter-badge-padding);
    font-family: var(--ruter-font);
    font-size: var(--_ruter-badge-text);
    font-weight: var(--ruter-weight-bold);
    line-height: 1;
    white-space: nowrap;
    color: var(--_ruter-badge-fg);
    background: var(--_ruter-badge-bg);
    border: 1px solid var(--_ruter-badge-border);
    border-radius: var(--ruter-radius-pill);
  }

  ruter-badge[size="sm"] {
    --_ruter-badge-height: 22px;
    --_ruter-badge-text: var(--ruter-text-xs);
    --_ruter-badge-padding: 8px;
    --_ruter-badge-gap: 4px;
  }

  ruter-badge[size="lg"] {
    --_ruter-badge-height: var(--ruter-control-md);
    --_ruter-badge-text: var(--ruter-text-base);
    --_ruter-badge-padding: 14px;
    --_ruter-badge-gap: 8px;
  }

  ruter-badge[variant="primary"] {
    --_ruter-badge-fg: var(--_ruter-on-color);
    --_ruter-badge-bg: var(--_ruter-color-strong);
  }

  ruter-badge[variant="muted"] {
    --_ruter-badge-bg: var(--ruter-sunken);
    --_ruter-badge-border: transparent;
  }

  ruter-badge[color][variant="muted"] {
    --_ruter-badge-bg: color-mix(in srgb, var(--_ruter-color-strong) 8%, transparent);
  }

  /* The icon is a circle's worth of the badge: a 2px ring inside the
     border all round, so a round logo sits evenly in the pill end. */
  ruter-badge [data-part="icon"] {
    inline-size: calc(var(--_ruter-badge-height) - 6px);
    block-size: calc(var(--_ruter-badge-height) - 6px);
    object-fit: contain;
  }

  ruter-badge:has(> [data-part="icon"]:first-child) {
    padding-inline-start: 2px;
  }

  /* Button. Wraps one native <button> or <a>, which keeps its own
     semantics, focus and form behaviour. Optional icon parts sit
     before or after the text, sized to it. Rounded corners by
     default; shape="pill" for a fully rounded marketing button.
     square makes it as wide as it is tall, for an icon on its own
     (a circle with shape="pill"). inset="top|bottom|start|end", or
     bare for all four, pulls a ghost button out by its padding so
     its content lines up with the text around it.                */

  ruter-button {
    --_ruter-button-inset-block: calc((var(--_ruter-control-height) - var(--_ruter-control-text) * var(--ruter-leading)) / 2);
    --_ruter-button-inset-inline: var(--_ruter-control-padding);
    font-family: var(--ruter-font);
  }

  /* The icon is 1.25 × the text: the inset is the space round it */
  ruter-button[square] {
    --_ruter-button-inset-block: calc((var(--_ruter-control-height) - var(--_ruter-control-text) * 1.25) / 2);
    --_ruter-button-inset-inline: var(--_ruter-button-inset-block);
  }

  ruter-button:is([inset=""], [inset~="top"]) {
    margin-block-start: calc(-1 * var(--_ruter-button-inset-block));
  }

  ruter-button:is([inset=""], [inset~="bottom"]) {
    margin-block-end: calc(-1 * var(--_ruter-button-inset-block));
  }

  ruter-button:is([inset=""], [inset~="start"]) {
    margin-inline-start: calc(-1 * var(--_ruter-button-inset-inline));
  }

  ruter-button:is([inset=""], [inset~="end"]) {
    margin-inline-end: calc(-1 * var(--_ruter-button-inset-inline));
  }

  ruter-button > :is(button, a) {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ruter-space-2);
    block-size: var(--_ruter-control-height);
    margin: 0;
    padding: 0 var(--_ruter-control-padding);
    font: inherit;
    font-size: var(--_ruter-control-text);
    font-weight: var(--ruter-weight-bold);
    line-height: var(--ruter-leading);
    white-space: nowrap;
    color: var(--_ruter-button-fg);
    text-decoration: none;
    background: var(--_ruter-button-bg);
    border: 1px solid var(--_ruter-button-border);
    border-radius: var(--ruter-radius);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  /* shape="pill" fully rounds the ends, for marketing calls to action */
  ruter-button[shape="pill"] > :is(button, a) {
    border-radius: var(--ruter-radius-pill);
  }

  ruter-button[square] > :is(button, a) {
    inline-size: var(--_ruter-control-height);
    padding: 0;
  }

  /* Before the focus rule, whose ring replaces the shadow */
  ruter-button[variant="surface"] > :is(button, a) {
    border-width: 2px;
    box-shadow: var(--ruter-shadow-1);
  }

  /* Expanded (e.g. the trigger of an open dropdown menu), it's in its hover
     look; pressed, in its hover look with the press shade over it, so a
     click shows even under the pointer that was already hovering. Hover
     only where there is one: on a touch screen it would stick after a tap. */
  @media (hover: hover) {
    ruter-button > :is(button, a):hover {
      color: var(--_ruter-button-hover-fg);
      border-color: var(--_ruter-button-hover-border);
      background: var(--_ruter-button-hover-bg);
    }
  }

  ruter-button > :is(button, a):is(:active, [aria-expanded="true"]) {
    color: var(--_ruter-button-hover-fg);
    border-color: var(--_ruter-button-hover-border);
    background: var(--_ruter-button-hover-bg);
  }

  ruter-button > :is(button, a):active {
    background: linear-gradient(var(--ruter-press-shade), var(--ruter-press-shade)), var(--_ruter-button-hover-bg);
  }

  ruter-button > :is(button, a):focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  /* A link can't be disabled natively: aria-disabled="true" (and no href)
     greys it out and stops clicks. */
  ruter-button > :is(button:disabled, [aria-disabled="true"]) {
    opacity: 0.5;
    cursor: not-allowed;
  }

  ruter-button > a[aria-disabled="true"] {
    pointer-events: none;
  }

  ruter-button [data-part="icon"] {
    inline-size: 1.25em;
    block-size: 1.25em;
    object-fit: contain;
  }

  /* Icon. 1em by default, so it follows the text it sits in;
     size="sm|md|lg" pins it to 16, 20 or 24px.                 */

  ruter-icon[size="sm"] { --_ruter-icon-size: 16px; }
  ruter-icon[size="md"] { --_ruter-icon-size: 20px; }
  ruter-icon[size="lg"] { --_ruter-icon-size: 24px; }

  /* Pills and toggle groups share the "on" selector:
     links           aria-current="page"
     toggle buttons  aria-pressed="true"
     tabs            aria-selected="true"
     inputs          <label><input type=radio|checkbox> …</label>
     anything else   data-state="on"                                */

  /* Pills */

  ruter-pills {
    gap: var(--ruter-space-2);
    font-family: var(--ruter-font);
    font-size: var(--_ruter-control-text);
    line-height: var(--ruter-leading);
  }

  ruter-pills [data-part="item"] {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: var(--ruter-space-2);
    block-size: var(--_ruter-control-height);
    margin: 0;
    padding: 0 var(--_ruter-control-padding);
    font: inherit;
    white-space: nowrap;
    color: var(--_ruter-button-fg);
    text-decoration: none;
    background: var(--_ruter-button-bg);
    border: 1px solid var(--_ruter-button-border);
    border-radius: var(--ruter-radius-pill);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  @media (hover: hover) {
    ruter-pills [data-part="item"]:hover {
      color: var(--_ruter-button-hover-fg);
      border-color: var(--_ruter-button-hover-border);
      background: var(--_ruter-button-hover-bg);
    }
  }

  ruter-pills [data-part="item"]:active {
    color: var(--_ruter-button-hover-fg);
    border-color: var(--_ruter-button-hover-border);
    background: var(--_ruter-button-hover-bg);
  }

  ruter-pills [data-part="item"]:is(:focus-visible, :has(> input:focus-visible)) {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-pills [data-part="item"]:is(
      [aria-current]:not([aria-current="false"]),
      [aria-pressed="true"],
      [aria-selected="true"],
      [data-state="on"],
      :has(> input:checked)
    ) {
    color: var(--ruter-on-accent);
    background: var(--ruter-accent-strong);
    border-color: var(--ruter-accent-strong);
  }

  ruter-pills [data-part="item"]:is(:disabled, [aria-disabled="true"], :has(> input:disabled)) {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* Button group: joins its buttons into one bar (or a column with
     orientation="vertical"), rounding only the ends. The buttons overlap by a
     border; at rest each hides the edge it shares with the next, so there's
     one line between them (borders can be translucent: two would show
     darker). A hovered, focused or pressed button shows all its edges, in
     front of its neighbours.
     Holds <ruter-button>s, or map controls (which are <ruter-button>s).
     A surface group casts one shadow, not one per button. */

  ruter-button-group {
    --_ruter-button-group-border: 1px;
    display: inline-flex;
    vertical-align: middle;
    border-radius: var(--ruter-radius);
  }

  ruter-button-group[orientation="vertical"] {
    flex-direction: column;
    align-items: stretch;
  }

  ruter-button-group:has(ruter-button[variant="surface"]) {
    --_ruter-button-group-border: 2px;
    box-shadow: var(--ruter-shadow-1);
  }

  ruter-button-group ruter-button > :is(button, a):not(:focus-visible) {
    box-shadow: none;
  }

  ruter-button-group ruter-button > :is(button, a):is(:hover, :active, :focus-visible, [aria-pressed="true"], [aria-expanded="true"]) {
    position: relative;
    z-index: 1;
  }

  ruter-button-group:not([orientation="vertical"]) > * + * {
    margin-inline-start: calc(-1 * var(--_ruter-button-group-border));
  }

  ruter-button-group[orientation="vertical"] > * + * {
    margin-block-start: calc(-1 * var(--_ruter-button-group-border));
  }

  ruter-button-group:not([orientation="vertical"]) > :not(:last-child) ruter-button > :is(button, a):not(:hover, :active, :focus-visible, [aria-pressed="true"], [aria-expanded="true"]),
  ruter-button-group:not([orientation="vertical"]) > ruter-button:not(:last-child) > :is(button, a):not(:hover, :active, :focus-visible, [aria-pressed="true"], [aria-expanded="true"]) {
    border-inline-end-color: transparent;
  }

  ruter-button-group[orientation="vertical"] > :not(:last-child) ruter-button > :is(button, a):not(:hover, :active, :focus-visible, [aria-pressed="true"], [aria-expanded="true"]),
  ruter-button-group[orientation="vertical"] > ruter-button:not(:last-child) > :is(button, a):not(:hover, :active, :focus-visible, [aria-pressed="true"], [aria-expanded="true"]) {
    border-block-end-color: transparent;
  }

  ruter-button-group:not([orientation="vertical"]) > :not(:first-child) ruter-button > :is(button, a),
  ruter-button-group:not([orientation="vertical"]) > ruter-button:not(:first-child) > :is(button, a) {
    border-start-start-radius: 0;
    border-end-start-radius: 0;
  }

  ruter-button-group:not([orientation="vertical"]) > :not(:last-child) ruter-button > :is(button, a),
  ruter-button-group:not([orientation="vertical"]) > ruter-button:not(:last-child) > :is(button, a) {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }

  ruter-button-group[orientation="vertical"] > :not(:first-child) ruter-button > :is(button, a),
  ruter-button-group[orientation="vertical"] > ruter-button:not(:first-child) > :is(button, a) {
    border-start-start-radius: 0;
    border-start-end-radius: 0;
  }

  ruter-button-group[orientation="vertical"] > :not(:last-child) ruter-button > :is(button, a),
  ruter-button-group[orientation="vertical"] > ruter-button:not(:last-child) > :is(button, a) {
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }

  /* Toggle group */

  /* The track is the control height; items sit inside its inset */
  ruter-toggle-group {
    --_ruter-toggle-group-inset: 3px;
    box-sizing: border-box;
    block-size: var(--_ruter-control-height);
    gap: 2px;
    padding: var(--_ruter-toggle-group-inset);
    font-family: var(--ruter-font);
    background: var(--ruter-sunken);
    border-radius: var(--ruter-radius-pill);
  }

  /* A vertical track grows with its items; its ends round like a horizontal one's */
  ruter-toggle-group[orientation="vertical"] {
    block-size: auto;
    border-radius: calc(var(--_ruter-control-height) / 2);
  }

  ruter-toggle-group [data-part="item"] {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ruter-space-1);
    block-size: calc(var(--_ruter-control-height) - 2 * var(--_ruter-toggle-group-inset));
    margin: 0;
    padding: 0 calc(var(--_ruter-control-padding) - var(--_ruter-toggle-group-inset));
    font: inherit;
    font-size: var(--_ruter-control-text);
    font-weight: var(--ruter-weight-bold);
    line-height: var(--ruter-leading);
    letter-spacing: 0.04em;
    white-space: nowrap;
    color: var(--ruter-accent-strong);
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: var(--ruter-radius-pill);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  @media (hover: hover) {
    ruter-toggle-group [data-part="item"]:hover {
      background: color-mix(in srgb, var(--ruter-surface) 90%, transparent);
    }
  }

  ruter-toggle-group [data-part="item"]:active {
    background: color-mix(in srgb, var(--ruter-surface) 90%, transparent);
  }

  ruter-toggle-group [data-part="item"]:is(:focus-visible, :has(> input:focus-visible)) {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-toggle-group [data-part="item"]:is(
      [aria-current]:not([aria-current="false"]),
      [aria-pressed="true"],
      [aria-selected="true"],
      [data-state="on"],
      :has(> input:checked)
    ) {
    color: var(--ruter-on-accent);
    background: var(--ruter-accent);
  }

  ruter-toggle-group [data-part="item"]:is(:disabled, [aria-disabled="true"], [data-disabled], :has(> input:disabled)) {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* Dropdown menu */

  ruter-dropdown-menu {
    font-family: var(--ruter-font);
  }

  /* The trigger is the app's own element (usually a <ruter-button>'s
     button), so the menu doesn't style it. One that isn't a button
     (a badge, an avatar) gets a pointer and the focus ring.       */
  ruter-dropdown-menu [data-part="trigger"][role="button"]:not(button) {
    cursor: pointer;
  }

  ruter-dropdown-menu [data-part="trigger"][role="button"]:not(button):focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  /* Deprecated: what's drawn in the trigger is the app's own (an icon
     turned off aria-expanded="true", say). Kept for compatibility: a
     caret in the trigger's text colour, icons/chevron-down.svg, 1.25 ×
     the text like a button's icon (the same chevron as <ruter-select>'s).
     The drawn chevron is the middle half of its box, so the box overhangs
     the end by a quarter to line the chevron up with the trigger's
     padding. It turns over while the menu is open. */
  ruter-dropdown-menu [data-part="chevron"] {
    display: inline-block;
    flex: none;
    inline-size: 1.25em;
    block-size: 1.25em;
    margin-inline-end: -0.3125em;
    vertical-align: middle;
    background: currentColor;
    mask: no-repeat center / 100%;
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  }

  ruter-dropdown-menu[data-state="open"] [data-part="chevron"] {
    transform: rotate(180deg);
  }

  /* The content is a popover in the top layer, placed by anchor positioning
     (Base UI's Menu.Positioner API): side="top|right|bottom|left|inline-start|
     inline-end" is the trigger's edge it opens from, align="start|center|end"
     where along that edge, side-offset / align-offset (px, set by the element)
     nudge it. It flips when it would overflow. The --_ruter-menu-* properties
     are internal.                                                           */
  ruter-dropdown-menu [data-part="content"] {
    --_ruter-dropdown-menu-side-offset: 6px;
    --_ruter-dropdown-menu-align-offset: 0px;
    --_ruter-menu-span-x: span-x-end;
    --_ruter-menu-span-y: span-y-end;
    --_ruter-menu-align-start: var(--_ruter-dropdown-menu-align-offset);
    --_ruter-menu-align-end: 0px;
    box-sizing: border-box;
    inset: auto;
    margin: 0;
    margin-block-start: var(--_ruter-dropdown-menu-side-offset);
    margin-inline: var(--_ruter-menu-align-start) var(--_ruter-menu-align-end);
    position-area: bottom var(--_ruter-menu-span-x);
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    min-width: 190px;
    /* the small viewport, so it ends above a phone's browser toolbars */
    max-height: 70vh;
    max-height: 70svh;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0.4rem;
    font-family: var(--ruter-font);
    color: var(--ruter-ink);
    background: var(--ruter-surface);
    border: 1px solid var(--ruter-divider);
    border-radius: var(--ruter-radius);
    box-shadow: var(--ruter-shadow-2);
  }

  ruter-dropdown-menu[side="top"] [data-part="content"] {
    margin-block: 0 var(--_ruter-dropdown-menu-side-offset);
    position-area: top var(--_ruter-menu-span-x);
  }

  ruter-dropdown-menu:is([side="left"], [side="right"], [side="inline-start"], [side="inline-end"]) [data-part="content"] {
    margin: 0;
    margin-block: var(--_ruter-menu-align-start) var(--_ruter-menu-align-end);
  }

  ruter-dropdown-menu[side="left"] [data-part="content"] {
    margin-right: var(--_ruter-dropdown-menu-side-offset);
    position-area: left var(--_ruter-menu-span-y);
  }

  ruter-dropdown-menu[side="right"] [data-part="content"] {
    margin-left: var(--_ruter-dropdown-menu-side-offset);
    position-area: right var(--_ruter-menu-span-y);
  }

  ruter-dropdown-menu[side="inline-start"] [data-part="content"] {
    margin-inline-end: var(--_ruter-dropdown-menu-side-offset);
    position-area: x-start var(--_ruter-menu-span-y);
  }

  ruter-dropdown-menu[side="inline-end"] [data-part="content"] {
    margin-inline-start: var(--_ruter-dropdown-menu-side-offset);
    position-area: x-end var(--_ruter-menu-span-y);
  }

  ruter-dropdown-menu[align="center"] [data-part="content"] {
    --_ruter-menu-span-x: span-all;
    --_ruter-menu-span-y: span-all;
    --_ruter-menu-align-start: 0px;
  }

  /* placement="end" is the old name for align="end" */
  ruter-dropdown-menu:is([align="end"], [placement="end"]:not([align])) [data-part="content"] {
    --_ruter-menu-span-x: span-x-start;
    --_ruter-menu-span-y: span-y-start;
    --_ruter-menu-align-start: 0px;
    --_ruter-menu-align-end: var(--_ruter-dropdown-menu-align-offset);
  }

  ruter-dropdown-menu [data-part="content"]:popover-open {
    display: grid;
    gap: 2px;
  }

  /* It fades in and out. The element sets data-starting-style for the
     first frame of opening and data-ending-style while it closes; a closed
     popover leaves the top layer at once, so display and overlay transition
     discretely to keep it on screen while it fades. */
  ruter-dropdown-menu [data-part="content"] {
    transition:
      opacity 0.15s var(--ruter-ease-out),
      display 0.15s allow-discrete,
      overlay 0.15s allow-discrete;
  }

  ruter-dropdown-menu [data-part="content"]:is([data-starting-style], [data-ending-style]) {
    opacity: 0;
  }

  ruter-dropdown-menu [data-part="content"][data-ending-style] {
    pointer-events: none;
  }

  ruter-dropdown-menu [data-part="item"] {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: var(--ruter-space-2);
    width: 100%;
    block-size: var(--_ruter-control-height);
    margin: 0;
    padding: 0 var(--_ruter-control-padding);
    font: inherit;
    font-size: var(--_ruter-control-text);
    font-weight: var(--ruter-weight-bold);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink-soft);
    text-align: start;
    text-decoration: none;
    white-space: nowrap;
    background: transparent;
    border: 0;
    border-radius: var(--ruter-radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  ruter-dropdown-menu [data-part="item"]:is(:active, :focus-visible, [data-highlighted], [aria-current]:not([aria-current="false"])) {
    outline: none;
    color: var(--ruter-accent-strong);
    background: var(--ruter-accent-soft);
  }

  @media (hover: hover) {
    ruter-dropdown-menu [data-part="item"]:hover {
      outline: none;
      color: var(--ruter-accent-strong);
      background: var(--ruter-accent-soft);
    }
  }

  ruter-dropdown-menu [data-part="item"]:focus-visible {
    box-shadow: inset 0 0 0 2px var(--ruter-focus);
  }

  ruter-dropdown-menu [data-part="item"]:is(:disabled, [aria-disabled="true"]) {
    color: var(--ruter-ink-faint);
    background: transparent;
    cursor: not-allowed;
  }

  ruter-dropdown-menu [data-part="swatch"] {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ruter-swatch, currentColor);
  }

  ruter-dropdown-menu [data-part="separator"] {
    height: 1px;
    margin: var(--ruter-space-1) 0;
    background: var(--ruter-divider);
  }

  /* Select */

  /* Location search: a field over a map, so on the surface, with the
     select's outline and focus ring; the suggestions drop under it in
     the dropdown menu's card. */
  ruter-location-search {
    font-family: var(--ruter-font);
    color: var(--ruter-ink);
  }

  ruter-location-search [data-part="icon"] {
    position: absolute;
    inset-block: 0;
    inset-inline-start: var(--_ruter-control-padding);
    margin-block: auto;
    inline-size: 1.25em;
    block-size: 1.25em;
    font-size: var(--_ruter-control-text);
    color: var(--ruter-ink-soft);
    pointer-events: none;
  }

  ruter-location-search [data-part="input"] {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    block-size: var(--_ruter-control-height);
    margin: 0;
    padding-block: 0;
    padding-inline: calc(var(--_ruter-control-padding) + 1.25em + var(--ruter-space-2)) var(--_ruter-control-padding);
    font: inherit;
    font-size: var(--_ruter-control-text);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink);
    background: var(--ruter-surface);
    border: 1px solid var(--ruter-outline);
    border-radius: var(--ruter-radius);
    transition: border-color 0.15s;
  }

  ruter-location-search [data-part="input"]::placeholder {
    color: var(--ruter-ink-faint);
    opacity: 1;
  }

  @media (hover: hover) {
    ruter-location-search [data-part="input"]:hover {
      border-color: var(--ruter-outline-strong);
    }
  }

  ruter-location-search [data-part="input"]:focus-visible {
    outline: none;
    border-color: var(--ruter-accent);
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  /* iOS zooms the page into a focused field set under 16px */
  @media (pointer: coarse) {
    ruter-location-search [data-part="input"] {
      font-size: max(16px, var(--_ruter-control-text));
    }
  }

  ruter-location-search :is([data-part="listbox"], [data-part="message"]) {
    position: absolute;
    z-index: 10;
    inset-inline: 0;
    inset-block-start: calc(100% + 6px);
    box-sizing: border-box;
    max-height: min(20rem, 60vh);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0.4rem;
    background: var(--ruter-surface);
    border: 1px solid var(--ruter-divider);
    border-radius: var(--ruter-radius);
    box-shadow: var(--ruter-shadow-2);
  }

  ruter-location-search [data-part="message"] {
    padding: var(--ruter-space-2) var(--ruter-space-3);
    font-size: var(--ruter-text-sm);
    color: var(--ruter-ink-soft);
  }

  ruter-location-search[data-state="error"] [data-part="message"] {
    color: var(--ruter-danger-strong);
  }

  ruter-location-search [data-part="option"] {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: var(--ruter-space-2) var(--ruter-space-3);
    border-radius: var(--ruter-radius);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  ruter-location-search [data-part="option-label"] {
    font-size: var(--ruter-text-sm);
    font-weight: var(--ruter-weight-bold);
  }

  ruter-location-search [data-part="option-detail"] {
    font-size: var(--ruter-text-xs);
    color: var(--ruter-ink-soft);
  }

  ruter-location-search [data-part="option"][data-highlighted] {
    color: var(--ruter-accent-strong);
    background: var(--ruter-accent-soft);
    box-shadow: inset 0 0 0 2px var(--ruter-focus);
  }

  @media (hover: hover) {
    ruter-location-search [data-part="option"]:hover {
      color: var(--ruter-accent-strong);
      background: var(--ruter-accent-soft);
    }
  }

  ruter-select {
    font-family: var(--ruter-font);
  }

  ruter-select > select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    block-size: var(--_ruter-control-height);
    margin: 0;
    /* room for the chevron: its drawn width plus the gap to the text */
    padding-block: 0;
    padding-inline: var(--_ruter-control-padding) calc(var(--_ruter-control-padding) + var(--_ruter-select-chevron) * 0.75 + var(--ruter-space-2));
    font: inherit;
    font-size: var(--_ruter-control-text);
    line-height: var(--ruter-leading);
    color: var(--_ruter-button-fg);
    background: var(--_ruter-button-bg);
    border: 1px solid var(--_ruter-button-border);
    border-radius: var(--ruter-radius);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
  }

  /* iOS zooms the page into a focused field set under 16px, and doesn't
     zoom back out */
  @media (pointer: coarse) {
    ruter-select > select {
      font-size: max(16px, var(--_ruter-control-text));
    }
  }

  ruter-select[shape="pill"] > select {
    border-radius: var(--ruter-radius-pill);
  }

  @media (hover: hover) {
    ruter-select > select:hover {
      color: var(--_ruter-button-hover-fg);
      border-color: var(--_ruter-button-hover-border);
      background: var(--_ruter-button-hover-bg);
    }
  }

  ruter-select > select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-select > select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* icons/chevron-down.svg, 1.25 × the text like a button's icon. The
     drawn chevron is the middle half of its box, so the box overhangs
     the padding by a quarter to line the chevron up with it. */
  ruter-select {
    --_ruter-select-chevron: calc(var(--_ruter-control-text) * 1.25);
  }

  ruter-select::after {
    content: "";
    position: absolute;
    inset-inline-end: calc(var(--_ruter-control-padding) - var(--_ruter-select-chevron) * 0.25);
    top: 50%;
    translate: 0 -50%;
    width: var(--_ruter-select-chevron);
    height: var(--_ruter-select-chevron);
    background: var(--_ruter-button-fg);
    mask: no-repeat center / 100%;
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  }

  ruter-select:has(> select:disabled)::after {
    opacity: 0.5;
  }

  /* Card

     <ruter-card>
       [data-part="media"]          image above the body (beside it when horizontal)
       [data-part="header"]
         [data-part="icon"]         leading dot, icon or thumbnail
         [data-part="title"]
           [data-part="link"]       stretches over the card
         [data-part="description"]
         [data-part="action"]       trailing arrow, button or menu
       [data-part="content"]
       [data-part="footer"]         actions, pushed to the bottom

     variant="surface|outline|muted" (default surface), size="sm|md|lg"
     (padding and title size, default md), orientation="horizontal".
     The --_ruter-card-* properties are internal.                 */

  ruter-card {
    --_ruter-card-padding: var(--ruter-space-5);
    --_ruter-card-gap: var(--ruter-space-3);
    --_ruter-card-title: var(--ruter-text-lg);
    --_ruter-card-radius: var(--ruter-radius-lg);
    --_ruter-card-bg: var(--ruter-surface);
    --_ruter-card-border: var(--ruter-divider);
    --_ruter-card-shadow: var(--ruter-shadow-1);
    --_ruter-card-hover-bg: var(--_ruter-card-bg);
    --_ruter-card-hover-border: color-mix(in srgb, var(--ruter-accent) 40%, transparent);
    --_ruter-card-hover-shadow: var(--ruter-shadow-2);
    gap: var(--_ruter-card-gap);
    padding: var(--_ruter-card-padding);
    font-family: var(--ruter-font);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink);
    background: var(--_ruter-card-bg);
    border: 1px solid var(--_ruter-card-border);
    border-radius: var(--_ruter-card-radius);
    box-shadow: var(--_ruter-card-shadow);
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  }

  ruter-card[variant="outline"] {
    --_ruter-card-bg: transparent;
    --_ruter-card-shadow: none;
    --_ruter-card-hover-border: var(--ruter-outline-strong);
    --_ruter-card-hover-shadow: none;
  }

  ruter-card[variant="muted"] {
    --_ruter-card-bg: var(--ruter-sunken);
    --_ruter-card-border: transparent;
    --_ruter-card-shadow: none;
    --_ruter-card-hover-bg: color-mix(in srgb, var(--ruter-accent-strong) 12%, transparent);
    --_ruter-card-hover-border: transparent;
    --_ruter-card-hover-shadow: none;
  }

  ruter-card[size="sm"] {
    --_ruter-card-padding: var(--ruter-space-3);
    --_ruter-card-gap: var(--ruter-space-2);
    --_ruter-card-title: var(--ruter-text-base);
  }

  ruter-card[size="lg"] {
    --_ruter-card-padding: var(--ruter-space-6);
    --_ruter-card-gap: var(--ruter-space-4);
    --_ruter-card-title: var(--ruter-text-xl);
  }

  /* Linked cards respond as a whole: they change colour under a pointer
     and while pressed. They don't move. */
  @media (hover: hover) {
    ruter-card:has([data-part="link"]):hover {
      background: var(--_ruter-card-hover-bg);
      border-color: var(--_ruter-card-hover-border);
      box-shadow: var(--_ruter-card-hover-shadow);
    }
  }

  ruter-card:has([data-part="link"]:active) {
    background: var(--_ruter-card-hover-bg);
    border-color: var(--_ruter-card-hover-border);
  }

  ruter-card:has([data-part="link"]:focus-visible) {
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  ruter-card [data-part="link"] {
    color: var(--ruter-accent-strong);
    text-decoration: none;
    outline: none;
  }

  /* Header: [icon] title / description [action]. Title and description
     stay together, centred beside an icon taller than they are. Empty
     tracks take no space, so the gaps are margins, not grid gaps.  */
  ruter-card [data-part="header"] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr auto auto 1fr;
    align-items: center;
  }

  ruter-card [data-part="header"] > * {
    grid-column: 2;
  }

  ruter-card [data-part="header"] > [data-part="title"] {
    grid-row: 2;
  }

  ruter-card [data-part="header"] > [data-part="description"] {
    grid-row: 3;
  }

  ruter-card [data-part="header"] > [data-part="icon"] {
    grid-column: 1;
    grid-row: 1 / -1;
    margin-inline-end: var(--ruter-space-4);
  }

  ruter-card [data-part="header"] > [data-part="action"] {
    grid-column: 3;
    grid-row: 1 / -1;
    margin-inline-start: var(--ruter-space-4);
  }

  ruter-card [data-part="header"] > [data-part="description"] {
    margin-top: var(--ruter-space-1);
  }

  ruter-card [data-part="title"] {
    margin: 0;
    font-size: var(--_ruter-card-title);
    font-weight: var(--ruter-weight-bold);
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }

  ruter-card [data-part="description"] {
    margin: 0;
    font-size: var(--ruter-text-sm);
    line-height: 1.5;
    color: var(--ruter-ink-soft);
  }

  /* Not a nested badge's icon, which shares the part name */
  ruter-card [data-part="icon"]:not(ruter-badge > *) {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ruter-accent);
  }

  ruter-card [data-part="icon"] > :is(img, svg) {
    display: block;
  }

  ruter-card [data-part="icon"] > img {
    border-radius: var(--ruter-radius);
    object-fit: cover;
  }

  ruter-card [data-part="action"] {
    display: flex;
    align-items: center;
    justify-self: end;
    color: var(--ruter-accent);
  }

  ruter-card [data-part="content"] > :first-child { margin-top: 0; }
  ruter-card [data-part="content"] > :last-child { margin-bottom: 0; }

  ruter-card [data-part="footer"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ruter-space-2) var(--ruter-space-4);
    margin-top: auto;
  }

  ruter-card [data-part="footer"] > a {
    font-size: var(--ruter-text-sm);
    font-weight: var(--ruter-weight-bold);
    color: var(--ruter-accent-strong);
    text-decoration: none;
  }

  @media (hover: hover) {
    ruter-card [data-part="footer"] > a:hover {
      text-decoration: underline;
    }
  }

  /* Media bleeds to the card's edges */
  ruter-card > [data-part="media"] {
    margin-inline: calc(-1 * var(--_ruter-card-padding));
    aspect-ratio: var(--ruter-card-media-ratio);
    overflow: hidden;
    background: var(--ruter-paper-deep);
  }

  ruter-card > [data-part="media"]:first-child {
    margin-top: calc(-1 * var(--_ruter-card-padding));
    border-start-start-radius: calc(var(--_ruter-card-radius) - 1px);
    border-start-end-radius: calc(var(--_ruter-card-radius) - 1px);
  }

  ruter-card > [data-part="media"]:last-child {
    margin-bottom: calc(-1 * var(--_ruter-card-padding));
    border-end-start-radius: calc(var(--_ruter-card-radius) - 1px);
    border-end-end-radius: calc(var(--_ruter-card-radius) - 1px);
  }

  ruter-card [data-part="media"] :is(img, video) {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Horizontal: the media fills the start side, at full height. It
     narrows on small screens (vw, since padding percentages would
     resolve against the card's parent, not the card).          */
  ruter-card[orientation="horizontal"] {
    --_ruter-card-media-width: min(var(--ruter-card-media-width), 30vw);
  }

  ruter-card[orientation="horizontal"]:has(> [data-part="media"]) {
    padding-inline-start: calc(var(--_ruter-card-media-width) + var(--_ruter-card-padding));
  }

  ruter-card[orientation="horizontal"] > [data-part="media"] {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: var(--_ruter-card-media-width);
    margin: 0;
    aspect-ratio: auto;
    border-radius: 0;
    border-start-start-radius: calc(var(--_ruter-card-radius) - 1px);
    border-end-start-radius: calc(var(--_ruter-card-radius) - 1px);
  }

  /* Popups: the surface and parts every popup shares

     [data-part="header"]
       [data-part="title"]
       [data-part="close"]          a round icon button at the end
     [data-part="content"]          scrolls
     [data-part="footer"]           actions                       */

  :is(ruter-panel) {
    font-family: var(--ruter-font);
    line-height: var(--ruter-leading);
    color: var(--ruter-ink);
    background: var(--ruter-surface);
    border: 1px solid var(--ruter-divider);
    border-radius: var(--ruter-radius-lg);
    box-shadow: var(--ruter-shadow-2);
  }

  :is(ruter-panel) > [data-part="header"] {
    display: flex;
    align-items: center;
    gap: var(--ruter-space-3);
    padding: var(--ruter-space-2) var(--ruter-space-2) var(--ruter-space-2) var(--ruter-space-5);
    min-height: var(--ruter-control-lg);
    border-bottom: 1px solid var(--ruter-divider);
  }

  :is(ruter-panel) [data-part="title"] {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--ruter-text-lg);
    font-weight: var(--ruter-weight-bold);
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }

  :is(ruter-panel) [data-part="close"] {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: var(--ruter-control-md);
    height: var(--ruter-control-md);
    margin: 0 0 0 auto;
    padding: 0;
    font: inherit;
    font-size: 20px; /* the icon's size */
    color: var(--ruter-ink-soft);
    background: transparent;
    border: 0;
    border-radius: var(--ruter-radius-pill);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  @media (hover: hover) {
    :is(ruter-panel) [data-part="close"]:hover {
      color: var(--ruter-ink);
      background: var(--ruter-wash);
    }
  }

  :is(ruter-panel) [data-part="close"]:active {
    color: var(--ruter-ink);
    background: var(--ruter-wash);
  }

  :is(ruter-panel) [data-part="close"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ruter-focus);
  }

  :is(ruter-panel) > [data-part="content"] {
    padding: var(--ruter-space-5);
  }

  :is(ruter-panel) > [data-part="footer"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ruter-space-2);
    padding: var(--ruter-space-3) var(--ruter-space-5);
    border-top: 1px solid var(--ruter-divider);
  }

  /* Panel: slides in from its side as it fades in, and back out as it
     closes. On phones it slides up from below, without the fade: a sheet
     is a solid thing. data-starting-style is its first frame open,
     data-ending-style the time it takes to close. */

  ruter-panel {
    transition: translate 0.3s var(--ruter-ease-out), opacity 0.2s;
  }

  ruter-panel:is(:not([open]), [data-starting-style], [data-ending-style]) {
    translate: calc(-100% - var(--ruter-map-inset)) 0;
    opacity: 0;
  }

  ruter-panel[side="end"]:is(:not([open]), [data-starting-style], [data-ending-style]) {
    translate: calc(100% + var(--ruter-map-inset)) 0;
  }

  @media (max-width: 639px) {
    ruter-panel,
    ruter-panel[side="end"] {
      border-width: 1px 0 0;
      border-end-start-radius: 0;
      border-end-end-radius: 0;
    }

    ruter-panel:is(:not([open]), [data-starting-style], [data-ending-style]),
    ruter-panel[side="end"]:is(:not([open]), [data-starting-style], [data-ending-style]) {
      translate: 0 100%;
      opacity: 1;
    }
  }

  /* A bottom sheet in hand (its header dragged) or springing from a drag:
     the element moves it, not the transitions. Pulled up, it lifts off the
     map's bottom edge by up to 40px; a skirt in its colour fills the gap
     (the map clips it the rest of the time). */
  ruter-panel[data-swiping] {
    translate: 0 var(--ruter-panel-swipe-y, 0px);
    opacity: 1;
    transition: none;
    user-select: none;
    box-shadow: 0 48px 0 var(--ruter-surface), var(--ruter-shadow-2);
  }

  /* The masked icons (the dropdown and select chevrons, the accordion
     marker) are painted with a currentColor background, which forced
     colours would replace with the page's. Opting them out keeps that
     background, and currentColor is still the forced text colour. The
     select's chevron is in the button colour, so it gets ButtonText. */
  @media (forced-colors: active) {
    ruter-dropdown-menu [data-part="chevron"],
    ruter-accordion [data-part="marker"]::before,
    ruter-accordion [data-part="marker"]::after,
    ruter-select::after {
      forced-color-adjust: none;
    }

    ruter-select::after {
      background: ButtonText;
    }
  }

  /* Forced colours drop the highlight's tint: outline the active
     suggestion instead */
  @media (forced-colors: active) {
    ruter-location-search [data-part="option"][data-highlighted] {
      outline: 2px solid Highlight;
      outline-offset: -2px;
    }
  }

  /* Asked for less transparency, the frosted backings are solid */
  @media (prefers-reduced-transparency: reduce) {
    ruter-map-attribution[open],
    ruter-map-scale [data-part="bar"] {
      background: var(--ruter-surface);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }

  /* Pressed, the other controls darken by the press shade over whatever
     they show (at rest, hovered or on), so a click or tap shows at once.
     Last in the layer, so it sits over their on looks. */
  :is(ruter-pills [data-part="item"], ruter-toggle-group [data-part="item"], ruter-legend [data-part="toggle"],
    ruter-panel [data-part="close"], ruter-dropdown-menu [data-part="item"]):active:not(:disabled, [aria-disabled="true"], [data-disabled]),
  ruter-map > [data-part="lock"]:active :is([data-part="lock-icon"], [data-part="lock-label"]),
  ruter-map[data-state="locked"] > [data-part="lock-scrim"]:active ~ [data-part="lock"] :is([data-part="lock-icon"], [data-part="lock-label"]) {
    background-image: linear-gradient(var(--ruter-press-shade), var(--ruter-press-shade));
  }

  /* Reduced motion keeps what fades and changes colour, which helps tell
     what happened, and drops what moves: things arrive and leave where they
     stand. */
  @media (prefers-reduced-motion: reduce) {
    /* Panels, bottom sheets too, fade in and out in place */
    ruter-panel {
      transition: opacity 0.2s;
    }

    ruter-panel:is(:not([open]), [data-starting-style], [data-ending-style]),
    ruter-panel[side="end"]:is(:not([open]), [data-starting-style], [data-ending-style]) {
      translate: none;
      opacity: 0;
    }

    ruter-accordion [data-part="item"]::details-content {
      transition: none;
    }

    ruter-map-geolocate[data-state="locating"] [data-part="icon"] {
      animation: none;
    }

    /* Keep the glow, drop the movement */
    ruter-map > [data-part="lock"][data-pulse] {
      animation: none;
    }
  }
}
