:root {
  --ink: #1c1c1c; --soft: #5d6066; --line: #dcdde0; --day1: #b8322a; --day2: #1d5fa6; --here: #0a7cff; --ok: #1f7a45; --sos: #c8102e;
  --top: calc(12px + env(safe-area-inset-top)); --right: calc(12px + env(safe-area-inset-right));
  --bottom: calc(12px + env(safe-area-inset-bottom)); --left: calc(12px + env(safe-area-inset-left));
}
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
#map { position: fixed; inset: 0; background: #e2dfda; }
.leaflet-control-attribution { font-size: 10px; padding-left: calc(4px + env(safe-area-inset-left)); padding-bottom: env(safe-area-inset-bottom); }

/* Labels: each is moved to a clear spot beside its point, and is hidden when there is none. */
.label-anchor { pointer-events: none; }
.label { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; visibility: hidden; }
.label.shown { visibility: visible; }

/* Place names */
.stop {
  padding: 3px 7px; border-radius: 4px; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
  font: 600 13px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); text-align: center;
}
.stop small { display: none; font-size: 11px; font-weight: 400; }
.stop.close small { display: block; }

/* Summits: a small dark triangle on the road, grey on a stretch not being taken. Tapped, it shows a name with the elevation under it. */
.peak { display: grid; place-items: center; -webkit-tap-highlight-color: transparent; }
.peak svg { display: block; width: 16px; height: 16px; overflow: visible; }
.peak path { fill: var(--ink); stroke: #fff; stroke-width: 3; stroke-linejoin: round; paint-order: stroke; }
.peak.off path { fill: #9b9ea4; }
.summit, .found {
  padding: 2px 6px 3px; border-radius: 4px; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  font: 600 12px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); text-align: center;
}
.summit small, .found small { display: block; font-size: 11px; font-weight: 400; color: var(--soft); font-variant-numeric: tabular-nums; }
.summit.off { color: var(--soft); }

/* A road that could be taken instead: its name over the difference, on a chip beside it. */
.chip {
  pointer-events: auto; cursor: pointer; display: block; padding: 3px 8px 4px; border-radius: 9px; border: 1.5px solid; text-align: left;
  font: 12px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
}
.chip b, .chip span { display: block; }
.chip span { font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.day1 { color: var(--day1); border-color: var(--day1); }
.chip.day2 { color: var(--day2); border-color: var(--day2); }

/* Small round controls in the corners */
.round {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--ink); background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / 0.3);
  font: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.round svg { width: 22px; height: 22px; }
#corner { position: fixed; z-index: 1000; top: var(--top); right: var(--right); display: grid; gap: 8px; }
#about i { font: italic 700 19px/1 Georgia, "Times New Roman", serif; }

#offline .check, #offline #offline-percent { display: none; }
#offline[data-state="pending"] { color: #9a9da3; }
#offline[data-state="detailed"] { color: var(--ok); }
#offline[data-state="detailed"] .arrow { display: none; }
#offline[data-state="detailed"] .check { display: block; }
#offline[data-state="saving"] { background: conic-gradient(var(--here) calc(var(--progress, 0) * 1turn), #d8dade 0); }
#offline[data-state="saving"] .arrow { display: none; }
#offline[data-state="saving"] #offline-percent {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}

#locate { position: fixed; z-index: 1000; right: var(--right); bottom: calc(var(--bottom) + 14px); width: 52px; height: 52px; color: #7b7e85; }
#locate svg { width: 24px; height: 24px; }
#locate[data-mode="on"] { color: var(--here); }
#locate[data-mode="follow"] { color: #fff; background: var(--here); }

/* SOS, alone in its own corner so it is not hit by a tap meant for another control. It asks before dialing. */
#sos {
  position: fixed; z-index: 1000; top: var(--top); left: var(--left); width: 48px; height: 48px; padding: 0; border: 2px solid #fff; border-radius: 50%;
  cursor: pointer; color: #fff; background: var(--sos); box-shadow: 0 1px 6px rgb(0 0 0 / 0.35);
  font: 800 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: 0.04em; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.confirm {
  box-sizing: border-box; width: min(320px, calc(100vw - 32px)); padding: 20px 18px 16px; border: 0; border-radius: 18px;
  color: var(--ink); background: #fff; box-shadow: 0 8px 40px rgb(0 0 0 / 0.4); text-align: center;
}
.confirm::backdrop { background: rgb(20 20 20 / 0.55); }
.confirm h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.2; }
.confirm p { margin: 0 0 8px; font-size: 15px; }
.confirm .fine { color: var(--soft); font-size: 13px; }
.confirm form { margin: 0; }
.confirm a, .confirm button {
  box-sizing: border-box; display: grid; place-items: center; width: 100%; border: 0; border-radius: 14px; cursor: pointer;
  font: 700 17px/1 system-ui, -apple-system, "Segoe UI", sans-serif; text-decoration: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.confirm a { height: 60px; margin: 16px 0 10px; color: #fff; background: var(--sos); font-size: 20px; }
.confirm button { height: 50px; color: var(--ink); background: #e9eaec; }
#roadside-confirm a { background: var(--ink); }
.confirm button.alt { margin: 0 0 10px; background: #fff; box-shadow: inset 0 0 0 2px #c9cbd0; }

/* The one bar, floating at the bottom: each day's miles while planning, the countdown to sunset on the road */
#bar {
  position: fixed; z-index: 1000; left: var(--left); bottom: calc(var(--bottom) + 14px); box-sizing: border-box;
  max-width: min(420px, calc(100vw - var(--left) - var(--right) - 62px)); padding: 8px 13px 9px; border-radius: 16px;
  background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / 0.3); font-size: 13px; font-variant-numeric: tabular-nums;
}
#bar p { margin: 0; }
/* A tap on the bar opens it upward on the next gas, playground and rest area: a small chevron at its top says so. */
#bar:not([data-mode="note"]) { cursor: pointer; }
#bar .more { display: block; grid-column: 1 / -1; width: 100%; height: 10px; margin: -3px 0 1px; padding: 0; border: 0; color: #a9acb2; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#bar .more svg { display: block; width: 18px; height: 8px; margin: 0 auto; }
#bar .more[aria-expanded="true"] svg { transform: rotate(180deg); }
#bar.open { width: 100%; }
#bar .nexts { grid-column: 1 / -1; margin: 2px -13px 7px; border-bottom: 1px solid var(--line); }
#bar .next {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: center; box-sizing: border-box; width: 100%; min-height: 48px;
  padding: 5px 13px; border: 0; color: var(--ink); background: none; font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
#bar .next small { grid-column: 1; color: var(--soft); font-size: 11px; }
#bar .next b { grid-column: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bar .next span { grid-column: 2; grid-row: 1 / span 2; font-weight: 600; }
#bar .next[aria-pressed="true"] small { color: var(--ok); font-weight: 600; }
#bar .next:disabled { cursor: default; }
#bar .next:disabled b { font-weight: 400; color: var(--soft); }
#bar .next:active:enabled { background: #f0f1f3; }
#bar[data-mode="plan"] { display: grid; grid-template-columns: auto auto auto; column-gap: 9px; row-gap: 2px; align-items: baseline; }
#bar[data-mode="plan"].open { grid-template-columns: auto auto auto 1fr; } /* the days keep to the left under the rows */
#bar .day { display: contents; }
#bar .day b { grid-column: 1; font-weight: 600; }
#bar .day b::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--day1); }
#bar .day[data-day="2"] b::before { background: var(--day2); }
#bar .day span { font-weight: 600; text-align: right; }
#bar .day em { font-style: normal; color: var(--soft); }
#bar[data-mode="road"] { width: 100%; }
#bar .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
#bar .head small { font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--soft); }
#bar .strip { height: 6px; margin: 5px 0 4px; border-radius: 3px; background: #b5dfc3; overflow: hidden; } /* the daylight left: driving, then rest */
#bar .strip i { display: block; height: 100%; border-radius: 3px; background: var(--day1); }
#bar[data-day="2"] .strip i { background: var(--day2); }
#bar .budget { font-weight: 600; }
#bar .line { color: var(--soft); font-size: 12px; }
#bar[data-mode="note"] .line { color: inherit; font-size: 13px; font-weight: 600; }
#bar.late .head, #bar.late .budget { color: #a3261f; }
#bar.late .strip i { background: #a3261f; }
#bar.off { color: #fff; background: #a3261f; }
#bar.off .head, #bar.off .line, #bar.off .head small, #bar.off .more, #bar.off .next, #bar.off .next small, #bar.off .next:disabled b { color: #fff; }
#bar.off .nexts { border-color: rgb(255 255 255 / 0.4); }
#bar.off .next:active:enabled { background: rgb(255 255 255 / 0.15); }
#bar.off .line { font-size: 13px; font-weight: 600; }

/* A small popover beside the corner buttons. It closes when anything outside it is tapped. */
#pop {
  position: fixed; z-index: 1001; top: var(--top); right: calc(var(--right) + 52px); width: min(250px, calc(100vw - 100px));
  padding: 10px 12px; border-radius: 12px; background: #fff; box-shadow: 0 2px 12px rgb(0 0 0 / 0.3); font-size: 13px;
}
#pop p { margin: 0 0 7px; }
#pop p:last-child { margin-bottom: 0; }
#pop .fine { color: var(--soft); font-size: 12px; }
#pop button { font: inherit; font-weight: 600; color: #fff; background: var(--ink); border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; }
#pop button:disabled { opacity: 0.6; cursor: default; }
#pop button + p { margin-top: 7px; }
#pop progress { width: 100%; height: 8px; }
