:root {
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.1);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.12);
  --thumb-alt: #8fbcef; /* every other mile of a route outline */
  --brand: #c47f06; /* logo amber: the "latest reading" dot, used sparingly */
  --brand-glow: rgba(196, 127, 6, 0.35);
  --good: #0ca30c;
  --warn: #b77900;
  --bad: #d03b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --top: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #222221;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --border: rgba(255, 255, 255, 0.1);
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.18);
    --thumb-alt: #a9d0fa;
    --brand: #f0b429;
    --brand-glow: rgba(240, 180, 41, 0.75);
    --warn: #fab219;
    --bad: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* even on elements whose class sets a display */
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 680; }
h2 { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
a { color: var(--accent); }
code { font-size: 0.92em; }
.muted { color: var(--muted); }
.bad { color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.loading { padding: 40px 20px; text-align: center; }

button, input {
  font: inherit;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--accent-soft); color: var(--text); }
a.button { display: inline-block; padding: 8px 14px; border-radius: 10px; text-decoration: none; font-weight: 600; border: 1px solid var(--border); color: var(--text); background: var(--raised); }
a.button.primary { background: var(--accent); border-color: transparent; color: #fff; }
.account-page .card > a.button { justify-self: start; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app header ---------- */
.top {
  position: sticky; top: 0; z-index: 1000;
  height: var(--top);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand img { width: 30px; height: 30px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 { margin-bottom: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--page); border: 1px solid var(--border);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.pill.warn { color: var(--warn); }
.pill.live { color: var(--bad); }
.pill.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.note { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--page); color: var(--text-2); font-size: 14px; }

/* ---------- sign in / empty ---------- */
.login { max-width: 400px; margin: 12vh auto; display: grid; gap: 12px; }
.login p { margin: 0; }
.login { margin: 12vh 16px; }
@media (min-width: 440px) { .login { margin: 12vh auto; } }
.login h1 { font-size: 24px; }
.token-login summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.token-login form { display: grid; gap: 10px; margin-top: 10px; }
.g-slot { min-height: 44px; }
.g-native {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px;
  font-weight: 600; background: var(--raised); border: 1px solid var(--border);
}
.g-native svg { width: 18px; height: 18px; }
.g-native:disabled { opacity: 0.6; }

/* ---------- account bits in the header ---------- */
.who { flex: none; max-width: 40vw; margin-right: 8px; padding: 5px 8px; font: inherit; font-size: 13px; color: var(--text); background: var(--raised); border: 1px solid var(--border); border-radius: 8px; }
.account-link { flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--accent-soft); color: var(--text); font-size: 12px; font-weight: 700; text-decoration: none; }
.account-link img { width: 100%; height: 100%; object-fit: cover; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px max(16px, env(safe-area-inset-left)); background: var(--accent-soft); border-bottom: 1px solid var(--border); font-size: 14px; }
.banner p { margin: 0; flex: 1 1 260px; }
.banner .bad { flex-basis: 100%; }
body.page-trip .banner { display: none; }

/* ---------- account page ---------- */
.account-page { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 16px; }
.account-page .card { display: grid; gap: 10px; }
.account-page .card > button, .account-page .card > #invite { justify-self: start; }
.account-page h2 { margin: 0; }
.account-page h3 { margin: 6px 0 0; font-size: 14px; }
.account-page p { margin: 0; }
.me { display: flex; align-items: center; gap: 12px; }
.me img { width: 44px; height: 44px; border-radius: 50%; }
.me div { display: grid; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.rows li:first-child { border-top: 0; }
.rows li > span:first-child { display: grid; min-width: 0; }
.rows small { font-size: 12.5px; }
.rows select { max-width: 45%; padding: 5px 8px; font: inherit; font-size: 13px; color: var(--text); background: var(--raised); border: 1px solid var(--border); border-radius: 8px; }
.invite-form { display: flex; gap: 8px; flex-wrap: wrap; }
.muted.small { font-size: 13px; }
.invite-form input { flex: 1 1 200px; min-width: 0; padding: 8px 10px; font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--border); border-radius: 10px; }
.login .steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.login > a.button { justify-self: start; }
.invite-link { display: flex; gap: 8px; margin-top: 4px; }
.invite-link input { flex: 1; min-width: 0; font-size: 13px; }
.empty { max-width: 520px; margin: 14vh auto; text-align: center; padding: 0 16px; }

/* ---------- trip list ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 24px 16px 48px; }
.list-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.list-head h1 { font-size: 32px; }
.week { display: flex; gap: 28px; }
.week div { display: grid; }
.week b { font-size: 22px; font-weight: 650; }
.week span { color: var(--muted); font-size: 13px; }
.day { margin-bottom: 28px; }
.day h2 { margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.trip-card { padding: 0; overflow: hidden; color: inherit; text-decoration: none; transition: transform 0.15s, box-shadow 0.15s; }
.trip-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 12px 28px rgba(0,0,0,.1); }
.thumb {
  height: 132px; display: grid; place-items: center;
  background:
    radial-gradient(circle at 1px 1px, var(--grid) 1px, transparent 0) 0 0 / 14px 14px,
    var(--page);
  border-bottom: 1px solid var(--border);
}
.thumb svg { width: 100%; height: 100%; display: block; }
/* A card's driving score: the same colored ring as on its page, over the map's corner. */
.thumb { position: relative; }
.card-score { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid var(--muted); background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.card-score[hidden] { display: none; }
.card-score b { font-size: 17px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.card-score small { font-size: 8.5px; color: var(--muted); line-height: 1.1; }
.card-score.good { border-color: var(--good); }
.card-score.ok { border-color: var(--warn); }
.card-score.low { border-color: var(--bad); }
.thumb-casing { fill: none; stroke: var(--surface); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.thumb-line { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: butt; stroke-linejoin: round; }
/* Every other mile, so the length of a drive shows at a glance. */
.thumb-line.alt { stroke: var(--thumb-alt); }
.thumb-start { fill: var(--good); stroke: var(--surface); stroke-width: 2.5; }
.thumb-end { fill: var(--text); stroke: var(--surface); stroke-width: 2.5; }
.trip-card-body { padding: 12px 16px 14px; display: grid; gap: 2px; }
.trip-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; }
.trip-card-stats { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 6px; color: var(--text-2); font-size: 14px; }
.trip-card-stats b { color: var(--text); font-weight: 650; }

.see-map, .day-head a { font-size: 14px; font-weight: 600; text-decoration: none; }
.see-map { display: inline-block; margin-top: 6px; }
.day-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.day .day-head h2 { margin-bottom: 0; }
.day-head .muted { font-size: 14px; }
.day-head a { margin-left: auto; }
.thumb-stop { fill: var(--surface); stroke: var(--text-2); stroke-width: 2; }

/* An outing: linked trips in one card, and the list of trips in the multi-trip views. */
.legs { list-style: none; margin: 10px 0 0; padding: 0; display: grid; font-size: 14px; }
.legs a {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.legs a:hover, .legs a:focus-visible { background: var(--accent-soft); }
.legs a b { font-weight: 650; font-variant-numeric: tabular-nums; }
.legs a span { color: var(--text-2); }
.legs .pill { margin-left: auto; }
.leg-stop { position: relative; padding: 2px 0 2px 18px; color: var(--muted); font-size: 13px; }
.leg-stop::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; border-left: 2px dotted var(--axis); }
.row-day { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin: 12px 0 2px; }
.row-day:first-child { margin-top: 0; }
.place-rows .row-day { margin: 10px 0 0; }
.place-rows .row-day:first-child { margin-top: 0; }
.outing-nav, .period-nav { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 14px; }
.outing-nav span { color: var(--text-2); }
/* The whole outing, then each trip in it: one page, switched here. Scrolls sideways when long. */
.stretches { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.stretches::-webkit-scrollbar { display: none; }
.stretches a { flex: none; display: flex; flex-direction: column; gap: 1px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); color: var(--text); text-decoration: none; font-size: 13px; }
.stretches a b { font-weight: 650; font-variant-numeric: tabular-nums; }
.stretches a small { font-size: 11.5px; color: var(--muted); }
.stretches a:hover { border-color: var(--accent); }
.stretches a[aria-current] { border-color: var(--accent); background: var(--accent-soft); }
.outing-nav a, .period-nav a { font-weight: 600; text-decoration: none; }

/* ---------- one trip: map first, no app header (the page has its own way back) ---------- */
body.page-trip main { max-width: none; padding: 0; }
body.page-trip { --top: 0px; }
body.page-trip .top { display: none; }
.main-nav { display: flex; gap: 2px; flex: 1; min-width: 0; margin: 0 12px; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.main-nav.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
.main-nav.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.main-nav a { flex: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; font-weight: 550; color: var(--text-2); text-decoration: none; }
.main-nav a:hover { color: var(--text); background: var(--accent-soft); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--raised); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.cost-assume > summary { cursor: pointer; list-style: none; display: grid; gap: 4px; }
.cost-assume > summary::-webkit-details-marker { display: none; }
.cost-assume > summary h2::after { content: " ›"; color: var(--muted); }
.cost-assume[open] > summary h2::after { content: " ⌄"; }
.cost-assume[open] > summary .hint { display: none; }
.cost-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.ok { color: var(--good); }
.save-state.bad { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.place[data-state="saving"] input { opacity: 0.6; }
.place[data-state="failed"] input { border-color: var(--bad); }
.board.unranked { opacity: 0.75; }
.trip {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "head map" "side map";
  height: calc(100dvh - var(--top));
}
.trip-head { grid-area: head; padding: 18px 20px 4px; }
.trip-head h1 { font-size: 24px; margin-top: 10px; }
.trip-head p { margin: 2px 0 0; }
.back { font-size: 14px; font-weight: 600; text-decoration: none; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pills:empty { display: none; }
/* One column no wider than the panel: without minmax(0, …) a long unbroken line (a folded
   section's summary, the headline numbers) widens the column past the panel and gets cut off. */
.trip-side { grid-area: side; overflow-y: auto; padding: 4px 20px 24px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; }
.trip-map { grid-area: map; position: relative; min-height: 0; border-left: 1px solid var(--border); }
#map { position: absolute; inset: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 20px; font-weight: 650; white-space: nowrap; }
.stat small { font-size: 12px; font-weight: 500; color: var(--text-2); margin-left: 3px; }

.control { display: grid; gap: 6px; margin-top: 14px; }
.control:first-of-type { margin-top: 0; }
.control > span { font-size: 13px; color: var(--text-2); font-weight: 550; }
.seg { display: flex; flex-wrap: wrap; background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1 0 auto; min-width: 18%; border: 0; background: transparent; padding: 6px 4px; border-radius: 7px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.legend { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.legend .bar { flex: 1; height: 8px; border-radius: 4px; }
#rt-legend .hint { margin-top: 4px; }

.engine-stats { margin-bottom: 4px; }
.engine-list { display: grid; margin: 10px 0 0; font-size: 14px; }
.engine-list div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.engine-list dt { color: var(--text-2); }
.engine-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-label { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.row-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.row-area { fill: var(--accent-soft); }

.share { position: relative; margin-left: auto; }
.share-pop > summary { list-style: none; cursor: pointer; color: var(--accent); font-weight: 600; }
.share-pop > summary::-webkit-details-marker { display: none; }
.share-btn.on::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good, #3fc66b); margin-right: 6px; vertical-align: 1px; }
.share-box { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000; width: min(340px, calc(100vw - 32px));
  display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 28px rgb(0 0 0 / 0.35); }
.share-box .primary { justify-self: start; }
.share-row { display: flex; gap: 6px; }
.share-row input { flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
.share-row button { padding: 6px 12px; }
.share-box .hint { margin: 0; }
.share-box .ghost { justify-self: start; padding: 4px 8px; font-size: 13px; }

.gas-note { margin: 6px 0 0; }
.gas-note .hint { margin: 0 0 4px; }
.about { font-size: 13px; color: var(--muted); }
.about summary { cursor: pointer; list-style: none; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: " ⓘ"; }
.about p { margin: 6px 0 0; color: var(--text-2); }
.sec-meta { margin: -6px 0 8px; font-size: 13px; color: var(--muted); }
.sub { font-size: 13px; font-weight: 650; margin: 16px 0 0; color: var(--text); text-transform: none; letter-spacing: 0; }
.sub span { color: var(--text-2); font-weight: 500; margin-left: 4px; }
.waste-list dt small { display: block; color: var(--muted); font-size: 12px; }

/* trip side panel: sections divided by hairlines, no boxes */
.side-sec { padding: 18px 0; border-top: 1px solid var(--border); }
.side-sec:first-child { border-top: 0; padding-top: 10px; }
.side-sec h2 { margin-bottom: 10px; }
.side-sec h2 span { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); margin-left: 6px; }
.side-sec > .hint:first-of-type { margin-top: 0; }
.figs.trip-figs { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 10px; }
.trip-figs .fig b { font-size: 26px; white-space: nowrap; }
/* The smallest phones: the four numbers two by two rather than squeezed onto one row. */
@media (max-width: 360px) { .figs.trip-figs { grid-template-columns: repeat(2, auto); } }
.trip-figs .fig span { white-space: nowrap; }
.trip-figs .fig small { font-size: 14px; }
.sub-line { margin: 10px 0 0; font-size: 14px; color: var(--text-2); }
.split { display: grid; gap: 12px; }
.split-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.split-name b, .split-val b { display: block; font-size: 15px; font-weight: 650; }
.split-name span, .split-val span { display: block; font-size: 12px; color: var(--muted); }
.split-val { text-align: right; min-width: 84px; }
.split-val small { font-size: 12px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.split-bar { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.split-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.waste-bar { display: flex; gap: 2px; height: 12px; margin: 4px 0 12px; }
.waste-bar i { display: block; height: 100%; border-radius: 3px; }
.waste-bar i { flex-basis: 0; min-width: 3px; }
.w-braking { background: #e5484d; }
.w-idle { background: #e8b931; }
.w-rich { background: #b25cf6; }
.w-drive { background: var(--accent); }
.w-cut { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

/* trip cost */
.cost-bar { display: flex; gap: 2px; height: 12px; margin: 4px 0 12px; }
.cost-bar i { display: block; height: 100%; border-radius: 3px; min-width: 3px; }
.c-fuel { background: #2a78d6; }
.c-time { background: #e8b931; }
.c-wear { background: #8f8d86; }
.c-value { background: #5f5d58; }
.c-carbon { background: #0ca30c; }
.c-other { background: #b25cf6; }
.cost-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px 24px; align-items: start; }
.cost-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.cost-form label .hint { margin: 0; font-weight: 400; font-size: 12px; }
.cost-input { display: flex; align-items: center; gap: 8px; }
.cost-input input { width: 110px; font: inherit; font-variant-numeric: tabular-nums; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); color: var(--text); }
.cost-input small { color: var(--muted); font-weight: 500; font-size: 12px; }
.cost-form > button { justify-self: start; align-self: end; }

/* shared line charts and heatmaps (plot.js) */
.chart-host { position: relative; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.dash { stroke-dasharray: 4 4; }
.band { stroke: none; opacity: 0.16; }
.s1 { stroke: var(--accent); fill: var(--accent); }
.s2 { stroke: #e8890c; fill: #e8890c; }
.s3 { stroke: #c9a20b; fill: #c9a20b; }
.s4 { stroke: var(--text-2); fill: var(--text-2); }
.s5 { stroke: #d03b3b; fill: #d03b3b; }
.line.s1, .line.s2, .line.s3, .line.s4, .line.s5 { fill: none; }
.mark { stroke: var(--text-2); stroke-dasharray: 2 4; }
.mark.s2 { stroke: #e8890c; }
.mark-dot { fill: var(--raised); stroke: var(--text); stroke-width: 2; }
.mark-label { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--page); stroke-width: 4px; stroke-linejoin: round; }
.cursor-dot.s1, .cursor-dot.s2, .cursor-dot.s3, .cursor-dot.s4, .cursor-dot.s5 { stroke: var(--raised); stroke-width: 2; }
.plot-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.plot-legend i, .chart-tip i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.plot-legend i.s1, .chart-tip i.s1 { background: var(--accent); }
.plot-legend i.s2, .chart-tip i.s2 { background: #e8890c; }
.plot-legend i.s3, .chart-tip i.s3 { background: #c9a20b; }
.plot-legend i.s4, .chart-tip i.s4 { background: var(--text-2); }
.plot-legend i.s5, .chart-tip i.s5 { background: #d03b3b; }
.chart-tip span { margin-left: 8px; }
.heat-canvas { position: relative; }
.heat-canvas canvas { display: block; }

/* repeated trips */
.board { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.board a { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: inherit; text-decoration: none; }
.board a:hover, .board a:focus-visible { background: var(--accent-soft); }
.board-when b, .board-val b { display: block; font-weight: 650; font-variant-numeric: tabular-nums; }
.board-when small, .board-val small { display: block; color: var(--muted); font-size: 12px; }
.board-val { text-align: right; }
.rank { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 700; font-size: 13px; color: var(--text-2); background: var(--grid); font-variant-numeric: tabular-nums; }
.rank.r1 { background: #e8b931; color: #1a1400; }
.rank.r2 { background: #c3c2b7; color: #1a1a19; }
.rank.r3 { background: #c98a4b; color: #1a0e00; }
.route-pill { margin-right: 6px; padding: 1px 7px; font-size: 11px; }
.board-tabs { max-width: 560px; margin: 24px 0 8px; }
.route-thumbs { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.route-thumbs figure { margin: 0; width: 200px; }
.route-thumbs .thumb { height: 110px; border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); }
.route-thumbs figcaption { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.route-table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.route-table th, .route-table td { padding: 6px 14px 6px 0; text-align: left; border-bottom: 1px solid var(--border); }
.route-table thead th { color: var(--muted); font-weight: 550; font-size: 12px; }
.route-table td.win { font-weight: 700; color: var(--good); }
.places { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 16px; }
.place { display: grid; gap: 4px; font-size: 12px; }
.place input { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); color: var(--text); }
.waste-list { display: grid; margin: 0; font-size: 14px; }
.waste-list div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.waste-list dt { color: var(--text); }
.waste-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }
.how { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.how summary { cursor: pointer; color: var(--muted); }
.how p { margin: 6px 0 0; }
.health { margin: 0; font-size: 14px; color: var(--text-2); }
.health .bad { color: var(--bad); font-weight: 650; }

/* insights: one calm page, sections divided by space and hairlines rather than boxed panels */
.head-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.insights { max-width: 880px; margin: 0 auto; }
.insights h1 { font-size: 34px; margin-top: 10px; }
.insights > .muted { margin: 4px 0 0; }
.figs { display: flex; flex-wrap: wrap; gap: 20px 44px; margin: 28px 0 0; padding-bottom: 32px; border-bottom: 1px solid var(--border); }
.fig { display: grid; gap: 2px; }
.fig b { font-size: 34px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fig small { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.fig span { color: var(--muted); font-size: 13px; }
.ins-sec { padding: 40px 0; border-bottom: 1px solid var(--border); }
.ins-sec:last-child { border-bottom: 0; }
.ins-sec h2 { font-size: 20px; font-weight: 650; color: var(--text); text-transform: none; letter-spacing: -0.01em; margin: 0; }
.ins-sec h3 { font-size: 14px; font-weight: 650; margin: 30px 0 6px; }
.ins-sec h3 span { color: var(--text-2); font-weight: 500; margin-left: 6px; }
.lede { color: var(--text-2); font-size: 14px; margin: 6px 0 16px; max-width: 66ch; }
.ins-chart { display: block; }
.curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.curve-thin { stroke-dasharray: 3 5; stroke-opacity: 0.75; }
.curve-area { fill: var(--accent-soft); }
.raw-dots circle { fill: var(--text-2); fill-opacity: 0.2; }
.fit-line { stroke: var(--brand); stroke-width: 2; }
.heat-wrap { position: relative; overflow-x: auto; }
.heat { display: block; }
.heat-cell { cursor: pointer; }
.heat-cell:hover { stroke: var(--text); stroke-width: 1.5; }
.heat-label { fill: var(--text-2); }
.heat-legend { max-width: 360px; margin-top: 4px; }
.same-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.same-pair { font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.same-pair b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.same-pair[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.diverge a { display: grid; gap: 0; }
.diverge a span { font-size: 13px; }

/* map overlays */
.map-controls {
  position: absolute; z-index: 600; top: 12px; left: 12px; max-width: calc(100% - 24px);
  display: grid; gap: 6px; padding: 8px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.map-controls .ctl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.map-controls .ctl > span { width: 42px; flex: none; font-size: 12px; color: var(--muted); font-weight: 550; }
.map-controls .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; background: transparent; border: 0; padding: 0; }
.map-controls .seg button { min-width: 0; flex: none; padding: 5px 9px; font-size: 13px; }
.chip { flex: none; padding: 5px 9px; font-size: 13px; font-weight: 550; border-radius: 7px; color: var(--text-2); background: transparent; border: 1px solid var(--border); margin-left: auto; }
.chip[aria-pressed="true"] { color: var(--text); background: var(--raised); }
.map-legend {
  position: absolute; z-index: 500; left: 12px; bottom: 12px; width: min(340px, calc(100% - 80px));
  padding: 6px 10px 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border);
}
.map-legend .legend { margin-top: 0; }
.map-legend .hint { margin: 2px 0 0; font-size: 12px; }
.leaflet-tooltip.moment {
  background: rgba(15, 15, 14, 0.86); color: #f0efec; border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px; font-weight: 600; padding: 3px 7px; border-radius: 7px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); line-height: 1.35;
}
.leaflet-tooltip.moment::before { border-top-color: rgba(15, 15, 14, 0.86); }
/* A named place on the map: amber like the brand dot, so it doesn't read as a moment of the drive. */
.leaflet-tooltip.place-label {
  background: #f0b429; color: #0b0b0b; border: 0; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.leaflet-tooltip.place-label::before { border-right-color: #f0b429; }
.place-row:focus-within span { color: var(--text); }
.readout {
  position: absolute; z-index: 500; top: 12px; right: 12px; min-width: 170px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 10px 12px; pointer-events: none;
}
.readout-time { font-size: 12px; color: var(--muted); }
.readout-speed { font-size: 28px; font-weight: 700; line-height: 1.1; }
.readout-speed small { font-size: 13px; font-weight: 500; color: var(--text-2); }
.readout dl { display: grid; grid-template-columns: auto auto; gap: 1px 14px; margin: 6px 0 0; font-size: 13px; }
.readout dt { color: var(--muted); }
.readout dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.map-status {
  position: absolute; z-index: 500; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px;
  color: var(--text-2); background: var(--page);
}
.map-status progress { width: 220px; accent-color: var(--accent); }

/* Leaflet theming */
.leaflet-container { font: inherit; background: var(--page); }
/* The map is always dark, whatever the page theme: route colors are tuned for it. */
.tiles-dark { filter: grayscale(1) invert(1) contrast(0.8) brightness(0.85); }
#map, .trip-map .leaflet-container { background: #1b1b1a; }
.leaflet-bar { border: 1px solid var(--border) !important; border-radius: 10px !important; overflow: hidden; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
/* Trip end and hover position: the logo's glowing amber dot. */
.end-dot { box-sizing: border-box; border-radius: 50%; background: #fff; border: 4px solid #0b0b0b; box-shadow: 0 0 0 2px #fff; }
.end-dot.ring { background: #0b0b0b; border: 3px solid var(--brand); }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* charts */
.chart-host { position: relative; }
.friction { display: block; width: 100%; max-width: 300px; margin: 0 auto; touch-action: none; }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-label { fill: var(--text-2); font-size: 11px; font-weight: 550; }
.speed-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.speed-area { fill: var(--accent-soft); }
.crosshair { stroke: var(--text-2); stroke-width: 1; }
.cursor-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; filter: drop-shadow(0 0 4px var(--brand-glow)); }
.dots circle { fill: var(--accent); fill-opacity: 0.45; }
.cursor-ring { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.chart-tip {
  position: absolute; top: -2px; pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--surface); font-size: 12px; padding: 2px 8px; border-radius: 6px;
}
.chart-tip span { opacity: 0.7; margin-left: 4px; }
.peaks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.peaks span { display: block; font-size: 12px; color: var(--muted); }
.peaks b { font-size: 17px; font-weight: 650; }
.peaks p { grid-column: 1 / -1; margin: 0; }

/* ---------- phones and narrow windows: map on top, details below ---------- */
@media (max-width: 860px) {
  .trip {
    display: block; height: auto;
  }
  .trip-head { padding: 14px 16px 12px; }
  .trip-head h1 { font-size: 21px; margin-top: 6px; }
  .trip-map { height: 62dvh; border-left: 0; border-top: 1px solid var(--border); }
  .trip-side { overflow: visible; padding: 14px 16px 32px; }
  .readout { top: auto; bottom: 74px; right: 8px; min-width: 150px; padding: 8px 10px; }
  .map-controls { top: 8px; left: 8px; right: 8px; max-width: none; padding: 6px; }
  .map-legend { left: 8px; bottom: 8px; }
  .map-legend .hint { display: none; }
  .readout-speed { font-size: 22px; }
  .list-head h1 { font-size: 28px; }
  .week { gap: 20px; }
  .week b { font-size: 19px; }
  .cards { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .brand { font-size: 0; gap: 0; }
  .main-nav { margin: 0 8px; }
  .main-nav a { padding: 6px 8px; }
}

/* Where you could save (trip page) */
.drive-score { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.drive-score p { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.drive-score-num { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--muted); }
.drive-score-num b { font-size: 24px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.drive-score-num small { font-size: 9px; color: var(--muted); text-align: center; line-height: 1.1; max-width: 48px; }
.drive-score.good .drive-score-num { border-color: var(--good, #2e9e5b); }
.drive-score.ok .drive-score-num { border-color: var(--warn, #d9a21b); }
.drive-score.low .drive-score-num { border-color: var(--bad, #d0453a); }
/* score lines: name, a bar on one scale, the amount; each opens to say more */
.coach-list details > summary { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; cursor: pointer; list-style: none; padding: 4px 0; }
.coach-list details > summary::-webkit-details-marker { display: none; }
.coach-name { font-size: 15px; font-weight: 600; white-space: nowrap; }
.coach-name::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); transition: transform 0.15s; }
.coach-list details[open] .coach-name::before { transform: rotate(90deg); }
.coach-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.coach-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--warn); }
.coach-list summary b { font-weight: 650; font-variant-numeric: tabular-nums; }
.coach-body { padding: 2px 0 6px 1em; }
.coach .drive-score { margin-bottom: 10px; }
.coach-rest { display: flex; justify-content: space-between; padding: 4px 0 0 1em; font-size: 14px; color: var(--muted); }
.coach-rest b { font-weight: 600; font-variant-numeric: tabular-nums; }
.coach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.coach-list li p { margin: 4px 0 0; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.coach-list li p.hint { font-size: 12.5px; color: var(--muted); }
.coach-stops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.coach-stops button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.coach-stops button:hover { border-color: var(--accent); }
.coach-stops small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.coach-target { margin-top: 8px; max-width: 260px; }

/* Ruler ticks across the route (every minute, or every few cents of gas) */
.tick { pointer-events: none; }
.tick i { position: absolute; left: 50%; top: 0; width: 2px; margin-left: -1px; border-radius: 1px; background: rgba(255, 255, 255, 0.8); box-shadow: 0 0 0 1px rgba(11, 11, 11, 0.7); }
.tick.major i { background: #fff; width: 2.5px; margin-left: -1.25px; }
.tick-label { pointer-events: none; }
.tick-label span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 11px; font-weight: 650; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 3px #0b0b0b, 0 0 3px #0b0b0b, 0 0 2px #0b0b0b; }
.marks-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.marks-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.marks-key i { width: 2px; height: 11px; background: #fff; border-radius: 1px; box-shadow: 0 0 0 1px rgba(11, 11, 11, 0.7); }
.seg.marks { background: transparent; border: 0; padding: 0; flex-wrap: nowrap; }
.seg.marks button { min-width: 0; flex: none; padding: 3px 8px; font-size: 12px; }
.act-error { display: block; margin-top: 4px; font-size: 13px; }

/* folded detail sections: one line each (title, key number), opening to the full section */
.folds { padding: 6px 0; }
.fold { border-top: 1px solid var(--border); }
.folds .fold:first-child { border-top: 0; }
.fold[hidden] { display: none; }
.fold > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 13px 0; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; white-space: nowrap; }
.fold > summary h2::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); transition: transform 0.15s; }
.fold[open] > summary h2::before { transform: rotate(90deg); }
.fold > summary span { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fold-body { padding: 0 0 16px; }
.fold-body > :first-child { margin-top: 0; }
.sub-line:empty { display: none; }
.about-sec { padding: 6px 0; }
.about-sec .fold { border-top: 0; }
.about-sec [data-about]:empty { display: none; }
.about-sec h3 { font-size: 13px; font-weight: 650; margin: 12px 0 2px; color: var(--text); }
.about-sec [data-about]:first-child h3 { margin-top: 0; }
.about-sec p { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.45; }

/* A trip's places, each with a name to type. */
.place-rows { display: grid; gap: 6px; margin-top: 8px; }
.place-row { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.place-row small { display: block; color: var(--muted); font-size: 12px; line-height: 1.2; }
.place-row input { min-width: 0; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; }
.places-sec .hint { margin: 8px 0 0; }
/* A drive between two places: a link along a dotted line, like the road between them. */
.drive-row {
  display: grid; margin: 0 0 0 4px; padding: 4px 8px 4px 16px; border-left: 2px dotted var(--axis); border-radius: 0 8px 8px 0;
  color: inherit; text-decoration: none; font-size: 13px;
}
.drive-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.drive-row span { color: var(--text-2); }
.drive-row:hover, .drive-row:focus-visible { background: var(--accent-soft); }
/* A stop in the middle of a drive: inside its dotted line. */
.place-row.along { margin: -6px 0 0 4px; padding: 6px 0 4px 16px; border-left: 2px dotted var(--axis); grid-template-columns: calc(9.5em - 22px) 1fr; }
.ins-tow { margin: 0 0 16px; max-width: 360px; }
.cost-form h3 { grid-column: 1 / -1; margin: 8px 0 -6px; font-size: 15px; }
.towing-nav button.link { white-space: nowrap; }
