:root {
  --panel-bg: rgba(255, 255, 255, 0.95);
  --text: #16202a;
  --muted: #667385;
  --border: #d9dee5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

#map {
  position: absolute;
  inset: 0;
  background: #eceff2;
}

.panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 260px;
  padding: 14px 16px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(20, 30, 40, 0.16);
  backdrop-filter: blur(4px);
}

.panel h1 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 650;
}

.sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.field b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  padding: 5px 6px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

input[type="range"] {
  margin: 0;
  accent-color: #3b6ea5;
}

.checkbox {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.checkbox input {
  margin: 0;
  accent-color: #3b6ea5;
}

.legend {
  margin-bottom: 8px;
}

.ramp {
  height: 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.ramp-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.note {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.credit {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.credit a {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: #3b6ea5;
  text-decoration: none;
}

.credit a:hover,
.credit a:focus-visible {
  text-decoration: underline;
}

/* ---------- ruler ---------- */

/* Beside its own toggle rather than under the main panel, which on a short
   window reaches most of the way down the left edge. */
.ruler {
  position: absolute;
  top: 12px;
  right: 56px;
  z-index: 1000;
  width: 230px;
  padding: 10px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(20, 30, 40, 0.16);
  backdrop-filter: blur(4px);
  font-variant-numeric: tabular-nums;
}

.ruler-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.ruler-head button {
  padding: 1px 7px;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}

.ruler-head button:hover {
  color: var(--text);
}

/* ---------- routes that actually run it ---------- */

.rides:not(:empty) {
  margin-top: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

.ride-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.ride-head span {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}

.ride-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 8px;
  width: 100%;
  margin-bottom: 3px;
  padding: 4px 6px;
  font: inherit;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.ride-row:hover {
  border-color: #3b6ea5;
}

.ride-row.active {
  border-color: #3b6ea5;
  box-shadow: inset 0 0 0 1px #3b6ea5;
}

.ride-name {
  font-weight: 650;
  font-size: 13px;
}

.ride-time {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ride-delta {
  color: #b5462f;
  font-size: 11px;
}

.ride-detail {
  grid-column: 1 / -1;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}

.ride-empty {
  font-size: 11px;
  color: var(--muted);
}

.ride-more {
  display: block;
  width: 100%;
  padding: 3px 6px;
  font: inherit;
  font-size: 11px;
  text-align: left;
  color: #3b6ea5;
  background: none;
  border: 0;
  cursor: pointer;
}

.ride-more:hover {
  text-decoration: underline;
}


/* The toggle sits with the zoom buttons, so it borrows their chrome. */
.ruler-toggle a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.ruler-toggle a.active {
  background: #3b6ea5;
  color: #fff;
}

.ruler-vertex {
  border: 2px solid #16202a;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 30, 40, 0.4);
  cursor: grab;
}

.ruler-on .leaflet-container {
  cursor: crosshair;
}

/* Present to crawlers and screen readers, absent from the map. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.leaflet-container {
  font: inherit;
}

.cell-popup {
  font-variant-numeric: tabular-nums;
  min-width: 190px;
}

.cell-popup b {
  font-size: 17px;
}

.stat-label {
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 12px;
  font-size: 12px;
}

.stats span:nth-child(odd) {
  color: var(--muted);
}

.spark-slot {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.spark {
  display: block;
  max-width: 100%;
  height: auto;
}

.spark-tick {
  font-size: 9px;
  fill: var(--muted);
}

@media (max-width: 560px) {
  /* Short of the right edge: the zoom buttons and the ride-time toggle live
     there, and a full-width panel buries them. */
  .panel {
    width: auto;
    right: 56px;
  }

  /* The panel now spans the window, so the ruler drops to the bottom edge. */
  .ruler {
    top: auto;
    right: 12px;
    bottom: 22px;
    width: auto;
    max-width: 260px;
    max-height: 52vh;
    overflow-y: auto;
  }

  /* With a route list open the two boxes want more than one phone screen, so
     they split it and the controls scroll inside the panel. */
  .ruler-on .panel {
    max-height: 40vh;
    overflow-y: auto;
  }

  .rides:not(:empty) {
    max-height: none; /* the whole box scrolls instead */
  }

  /* Keyboard shortcuts on a phone are not worth the height they cost, and the
     full note would push the box back up under the panel. */
  .ruler .note {
    display: none;
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.lang-switch {
  display: flex;
  flex: none;
  gap: 4px;
  margin-top: 1px;
}

.lang-switch button {
  padding: 2px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  line-height: 0;
  cursor: pointer;
  opacity: 0.45;
}

.lang-switch button:hover,
.lang-switch button:focus-visible,
.lang-switch button[aria-pressed="true"] {
  opacity: 1;
}

.lang-switch button[aria-pressed="true"] {
  border-color: var(--border);
}
