:root {
  color-scheme: light dark;
  --bg: #f3f6fc;
  --card: #ffffff;
  --text: #17243b;
  --muted: #62718a;
  --border: #d8e0ee;
  --accent: #1657c8;
  --accent-text: #ffffff;
  --accent-soft: #e5eeff;
  --action: #ff963d;
  --action-text: #17243b;
  --big-from: #ffab57;
  --big-to: #ff8a2b;
  --big-border: #ed7b20;
  --private: #8a4b08;
  --private-soft: #fbe8d3;
  --private-text: #ffffff;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(20 40 76 / 5%), 0 4px 14px rgb(20 40 76 / 5%);
  --shadow-raised: 0 2px 6px rgb(20 40 76 / 8%), 0 12px 32px rgb(20 40 76 / 12%);
  --glass: rgb(255 255 255 / 78%);
  --radius: 16px;
  --tabs-height: 64px;
  --tabs-gap: max(env(safe-area-inset-bottom), 12px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2362718a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1423;
    --card: #152239;
    --text: #eaf0fc;
    --muted: #9aaac4;
    --border: #2b3c58;
    --accent: #87b4ff;
    --accent-text: #0a1a33;
    --accent-soft: #1b3359;
    --action: #ffa352;
    --big-from: #ffb366;
    --big-to: #ff8a2b;
    --big-border: #ffc18a;
    --private: #f0a95c;
    --private-soft: #3b2912;
    --private-text: #2a1703;
    --danger: #ff6b5e;
    --shadow: 0 0 0 1px rgb(255 255 255 / 5%);
    --shadow-raised: 0 0 0 1px rgb(255 255 255 / 8%), 0 12px 32px rgb(0 0 0 / 45%);
    --glass: rgb(21 34 57 / 78%);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aaac4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* The same daylight palette is used by the start scene and the form backdrop. */
@media (prefers-color-scheme: light) {
  :root {
    --scene-sky-top: #a4d9fa;
    --scene-sky-middle: #d4edfc;
    --scene-sky-bottom: #edf7fd;
    --scene-hills-top: #8bc7ed;
    --scene-hills-bottom: #63a5d3;
    --scene-hills-front: #75b2da;
    --scene-bushes: #4c91be;
    --scene-road-top: #6da8d1;
    --scene-road-bottom: #447ea9;
    --scene-verge-top: #8cbddd;
    --scene-stars: 0;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* Views slide in sideways when switching tabs; this keeps that from adding a horizontal scrollbar. */
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Swedish licence plate: blue country strip, black text on white. */
.plate {
  display: flex;
  flex: none;
  align-items: center;
  overflow: hidden;
  font-family: "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 20px;
  color: #111111;
  white-space: nowrap;
  background: #ffffff;
  border: 1.5px solid #111111;
  border-radius: 5px;
}

.plate[hidden] {
  display: none;
}

.plate-number {
  padding-right: 6px;
}

/* Centres the capitals exactly instead of relying on the font's line metrics. */
@supports (text-box: trim-both cap alphabetic) {
  .plate-number {
    padding-block: 5px;
    line-height: 1;
    text-box: trim-both cap alphabetic;
  }
}

.plate-country {
  display: grid;
  align-self: stretch;
  place-items: end center;
  width: 12px;
  margin-right: 5px;
  padding-bottom: 2px;
  font-family: system-ui, sans-serif;
  font-size: 0.5rem;
  letter-spacing: 0;
  line-height: 1;
  color: #ffffff;
  background: #003399;
}

.topbar-sync {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  padding: 6px 14px 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-text);
  white-space: nowrap;
  background: var(--accent);
  border: 0;
  border-radius: 99px;
}

.topbar-sync[hidden] {
  display: none;
}

.topbar-sync svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 12px calc(var(--tabs-height) + var(--tabs-gap) + 24px);
}

#view.enter {
  animation: view-in 0.35s var(--ease);
}

#view[data-from="left"] {
  --enter-x: -16px;
  --enter-y: 0;
}

#view[data-from="right"] {
  --enter-x: 16px;
  --enter-y: 0;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translate(var(--enter-x, 0), var(--enter-y, 10px));
  }
}

h2 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

h3 {
  margin: 20px 4px 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  cursor: pointer;
}

/* iOS gives date inputs a fixed width that overflows narrow forms and centres the value. */
input[type="datetime-local"] {
  display: block;
  min-width: 0;
}

input::-webkit-date-and-time-value {
  text-align: left;
}

@supports (-webkit-touch-callout: none) {
  input[type="datetime-local"] {
    -webkit-appearance: none;
  }
}

.field > .datetime {
  position: relative;
  display: block;
  font: inherit;
  color: inherit;
}

.datetime input,
.datetime input::-webkit-datetime-edit {
  color: transparent;
}

.datetime-text {
  position: absolute;
  inset: 1px 44px 1px 1px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.datetime-text:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

input[inputmode="numeric"] {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.with-button {
  display: flex;
  gap: 8px;
}

.arrival-time {
  align-items: flex-end;
}

.arrival-time > .field {
  flex: 1;
  min-width: 0;
}

.arrival-time > button {
  min-height: 48px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  max-width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 99px;
}

.chip.add {
  color: var(--muted);
  background: none;
  border: 1px dashed var(--border);
}

.icons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.icons label {
  position: relative;
}

.icons input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.icons span {
  display: grid;
  place-items: center;
  height: 48px;
  font-size: 1.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.icons input:checked + span {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
}

.icons input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.saved {
  margin: 0;
  padding: 0;
  list-style: none;
}

.saved li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}

.saved li + li {
  border-top: 1px solid var(--border);
}

.saved li > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.saved small {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.saved .icon {
  width: 40px;
  min-height: 40px;
  font-size: 1rem;
  color: var(--danger);
}

.geo-status {
  min-height: 1em;
  color: var(--muted);
}

button {
  font: inherit;
  cursor: pointer;
  transition:
    transform 0.15s var(--ease),
    background-color 0.2s,
    color 0.2s,
    opacity 0.2s;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary,
.secondary {
  min-height: 52px;
  padding: 12px 18px;
  font-weight: 700;
  border: 0;
  border-radius: 14px;
}

.primary {
  min-height: 60px;
  font-size: 1.15rem;
  color: var(--action-text);
  /* A plain colour: Chrome on Android drew a gradient background with darker squares in the rounded corners. */
  background: var(--action);
}

.primary:disabled {
  opacity: 0.6;
}

.secondary {
  min-height: 44px;
  color: var(--accent);
  background: var(--accent-soft);
}

.icon {
  flex: none;
  width: 48px;
  min-height: 48px;
  font-size: 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.link {
  padding: 8px;
  color: var(--accent);
  background: none;
  border: 0;
}

.danger {
  color: var(--danger);
}

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--bg);
  border-radius: 14px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 12px;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  transition:
    background-color 0.2s,
    color 0.2s;
}

.segmented input:checked + span {
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}

.segmented input[value="private"]:checked + span {
  color: var(--private-text);
  background: var(--private);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--private) 30%, transparent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

/* Where :has() works, the selection is a pill that slides between the options. */
@supports selector(:has(*)) {
  .segmented::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background: var(--accent);
    border-radius: 10px;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
    transition:
      transform 0.35s var(--ease),
      background-color 0.25s,
      box-shadow 0.25s;
  }

  .segmented:has(input[value="private"]:checked)::before {
    background: var(--private);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--private) 30%, transparent);
    transform: translateX(100%);
  }

  .segmented span {
    position: relative;
  }

  .segmented input:checked + span,
  .segmented input[value="private"]:checked + span {
    background: none;
    box-shadow: none;
  }
}

.start-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: calc(100dvh - var(--tabs-height) - var(--tabs-gap) - 100px);
  padding: 24px 8px;
}

#mobile-backdrop { display: none; }

.drive-scene {
  width: min(100%, 400px);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 32px;
  box-shadow: 0 16px 40px rgb(3 28 73 / 18%);
}

.drive-scene svg { display: block; width: 100%; height: 100%; }
.road-marks { animation: road-roll 1.2s linear infinite; }
.car-bounce { animation: car-roll 0.65s ease-in-out infinite alternate; }
.wheel-rear { transform-origin: 98px 328px; }
.wheel-front { transform-origin: 272px 345px; }
.wheel { animation: wheel-roll 0.8s linear infinite; }

.departure-button {
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
  width: min(100%, 400px);
  min-height: 130px;
  padding: 24px 48px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(160deg, #ffa727, #ff7c12 55%, #e53b13);
  border-radius: 24px;
}

.departure-button > span { position: absolute; right: 24px; }
.start-screen.arriving .drive-car { animation: drive-in 0.65s ease-out both; }
.start-screen.leaving { animation: departure-wait 0.55s linear; }
.start-screen.leaving .drive-car { animation: drive-away 0.55s ease-in forwards; }
.start-screen.leaving .departure-button { pointer-events: none; }

@keyframes road-roll { to { stroke-dashoffset: 130; } }
@keyframes car-roll { to { transform: translateY(-1.5px); } }
@keyframes wheel-roll { to { transform: rotate(360deg); } }
/* Follow the road edge's 94 / 512 slope, keeping the car in its lane. */
@keyframes drive-away { to { transform: translate(550px, 101px); } }
@keyframes drive-in { from { transform: translate(-550px, -101px); } }
/* The parent animation lets the shared leave helper wait for the car. */
@keyframes departure-wait { to { opacity: 1; } }

@media (max-width: 600px) {
  body:has(#tabs:not([hidden])) {
    min-height: 100dvh;
    isolation: isolate;
  }

  body:has(.start-screen) {
    background: var(--scene-sky-middle, #03235c);
  }

  body:has(#tabs:not([hidden])):not(:has(.start-screen)) #mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
  }

  #mobile-backdrop > svg {
    display: block;
    width: 100%;
    height: 100%;
    transform: scale(1.04);
    filter: blur(8px);
  }

  #mobile-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--bg) 65%, transparent);
  }

  #mobile-backdrop * { animation: none; }
  #mobile-backdrop.car-away .drive-car { display: none; }

  .month > h3, .empty, .done-km .muted { color: var(--text); }

  body:has(.start-screen) .topbar { background: transparent; }
  body:has(.start-screen) main { padding: 0; }
  #view.enter:has(.start-screen) { animation: none; }
  .start-screen { min-height: 0; padding: 0; }

  .drive-scene {
    position: fixed;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .departure-button {
    position: fixed;
    bottom: calc(var(--tabs-height) + var(--tabs-gap) + 24px);
    width: calc(100% - 24px);
    min-height: clamp(110px, 16dvh, 144px);
    box-shadow: 0 8px 24px rgb(0 24 62 / 25%);
  }

}

@media (max-width: 600px) and (prefers-color-scheme: dark) {
  body:has(.start-screen) :is(.topbar, .tabs) {
    --accent: #b7d4ff;
    --accent-text: #102548;
    --muted: #d2e4ff;
    --glass: rgb(3 28 73 / 78%);
  }
}

.big-button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  padding: 24px 20px;
  /* Plain hex colours rather than color-mix(): Chrome on Android drew a color-mix
     gradient on the primary button with darker squares in the rounded corners. */
  background: linear-gradient(160deg, var(--big-from), var(--big-to));
  border: 1px solid var(--big-border);
  border-radius: 24px;
}

.big-icon {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 10px;
  background: color-mix(in srgb, var(--action-text) 10%, transparent);
  border: 10px solid color-mix(in srgb, var(--action-text) 5%, transparent);
  border-radius: 50%;
}

.big-icon svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.big-label {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.big-hint {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.75;
}

.done-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 28px;
  text-align: center;
}

.done-badge {
  position: relative;
  width: 104px;
  height: 104px;
  margin-bottom: 18px;
}

.done-check {
  position: relative;
  width: 100%;
  height: 100%;
  animation: pop 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

.done-check circle {
  fill: var(--accent);
}

.done-check path {
  fill: none;
  stroke: var(--accent-text);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
  animation: draw 0.4s 0.35s var(--ease) forwards;
}

@keyframes pop {
  from {
    transform: scale(0);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Twelve pieces that burst out from behind the check, each at its own angle and distance. */
.confetti {
  position: absolute;
  top: 50%;
  left: 50%;
}

.confetti i {
  position: absolute;
  top: -6px;
  left: -4px;
  width: 8px;
  height: 12px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  animation: confetti 0.95s 0.3s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.confetti i:nth-child(3n + 2) {
  background: var(--private);
}

.confetti i:nth-child(3n) {
  background: #f2c230;
}

.confetti i:nth-child(4n) {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.confetti i:nth-child(1) { --a: 8deg; --d: 92px; }
.confetti i:nth-child(2) { --a: 34deg; --d: 74px; }
.confetti i:nth-child(3) { --a: 63deg; --d: 104px; }
.confetti i:nth-child(4) { --a: 88deg; --d: 82px; }
.confetti i:nth-child(5) { --a: 121deg; --d: 96px; }
.confetti i:nth-child(6) { --a: 149deg; --d: 72px; }
.confetti i:nth-child(7) { --a: 178deg; --d: 100px; }
.confetti i:nth-child(8) { --a: 207deg; --d: 80px; }
.confetti i:nth-child(9) { --a: 238deg; --d: 106px; }
.confetti i:nth-child(10) { --a: 268deg; --d: 76px; }
.confetti i:nth-child(11) { --a: 298deg; --d: 98px; }
.confetti i:nth-child(12) { --a: 330deg; --d: 84px; }

@keyframes confetti {
  0% {
    opacity: 1;
    transform: rotate(var(--a)) translateY(0) scale(0.3);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) rotate(200deg);
  }
}

.done-screen > :not(.done-badge) {
  animation: rise 0.45s var(--ease) both;
}

.done-screen > :nth-child(2) {
  animation-delay: 0.45s;
}

.done-screen > :nth-child(3) {
  animation-delay: 0.55s;
}

.done-screen > :nth-child(4) {
  animation-delay: 0.65s;
}

.done-screen > :nth-child(5) {
  animation-delay: 0.75s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.done-screen h2 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.done-km {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 2px 0 22px;
}

.done-km strong {
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.done-facts {
  align-self: stretch;
  text-align: left;
}

.new-trip {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  margin-top: 18px;
}

.new-trip svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 2px;
}

.form-head h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.form-head p {
  margin-top: 3px;
  font-size: 0.9rem;
}

.form-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 16px;
  transition:
    color 0.25s,
    background-color 0.25s;
}

.form-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

form:has(input[value="private"]:checked) .form-icon {
  color: var(--private);
  background: var(--private-soft);
}

.ongoing-screen {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.facts {
  display: grid;
  gap: 12px;
  margin: 0;
}

.facts dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.facts dd {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ongoing {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: 14px;
}

.pulse {
  flex: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  }
  100% {
    box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

.distance {
  margin: -6px 0 0;
  min-height: 1em;
  font-weight: 600;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 8px;
}

.year {
  width: auto;
  min-width: 100px;
  font-weight: 700;
  background-color: var(--card);
}

.toolbar .secondary {
  min-height: 48px;
}

.trips {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.trips li + li {
  border-top: 1px solid var(--border);
}

.trip-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
}

.trip-row:active:not(:disabled) {
  background: var(--bg);
  transform: none;
}

.trip-row small {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.when {
  font-weight: 700;
}

.where {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.km {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge {
  display: inline-block !important;
  padding: 1px 7px;
  font-weight: 600;
  color: var(--accent) !important;
  background: var(--accent-soft);
  border-radius: 99px;
}

.badge.private {
  color: var(--private) !important;
  background: var(--private-soft);
}

.completion {
  gap: 8px;
  text-align: left;
  color: var(--private);
  background: var(--private-soft);
}

.completion p {
  margin: 0;
}

.done-screen > .completion {
  align-self: stretch;
  margin-top: 14px;
}

.trip-row .completion-label {
  color: var(--private);
  font-weight: 600;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.stat strong {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat small {
  color: var(--muted);
}

.rules {
  gap: 16px;
}

.rule {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
  border-left: 4px solid var(--border);
}

.rule span {
  font-size: 0.9rem;
  color: var(--muted);
}

.rule.ok {
  border-color: var(--accent);
}

.rule.warn {
  border-color: var(--danger);
}

.bar {
  height: 8px;
  margin-top: 4px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.6s var(--ease);
}

.months {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.months th,
.months td {
  padding: 10px 14px;
  text-align: right;
}

.months th:first-child,
.months td:first-child {
  text-align: left;
  text-transform: capitalize;
}

.months th {
  font-size: 0.8rem;
  color: var(--muted);
}

.months tbody tr {
  border-top: 1px solid var(--border);
}

.tabs {
  position: fixed;
  right: 12px;
  bottom: var(--tabs-gap);
  left: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 536px;
  margin: 0 auto;
  padding: 0 4px;
  background: var(--glass);
  border-radius: 24px;
  box-shadow: var(--shadow-raised);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
}

.tabs[hidden] {
  display: none;
}

.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: var(--tabs-height);
  padding: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
}

.tabs button:active:not(:disabled) {
  transform: none;
}

.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 30px;
}

.tab-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  border-radius: 99px;
  opacity: 0;
  transform: scaleX(0.4);
  transition:
    transform 0.3s var(--ease),
    opacity 0.2s;
}

.tab-icon svg {
  position: relative;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}

.tabs button:active .tab-icon svg {
  transform: scale(0.88);
}

.tabs button.active {
  color: var(--accent);
}

.tabs button.active .tab-icon::before {
  opacity: 1;
  transform: none;
}

.tabs button.active .tab-icon svg {
  stroke-width: 2.3;
}

.sync {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--private);
  background: var(--private-soft);
  border: 0;
  border-radius: 99px;
}

.sync,
.topbar-sync {
  min-height: 44px;
}

.storage-notice {
  max-width: 536px;
  margin: 8px max(12px, calc((100% - 536px) / 2)) 16px;
  gap: 8px;
  font-size: 0.9rem;
}

.storage-notice[hidden] {
  display: none;
}

.storage-notice p {
  margin: 0;
  color: var(--muted);
}

.sync.error {
  color: #fff;
  background: var(--danger);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-x: hidden;
  overscroll-behavior: contain;
  margin: auto auto 0;
  padding: 0;
  color: inherit;
  background: var(--card);
  border: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-raised);
}

.sheet[open] {
  animation: sheet-in 0.42s var(--ease);
}

.sheet.switching {
  pointer-events: none;
}

.sheet::backdrop {
  background: rgb(0 0 0 / 40%);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sheet[open]::backdrop {
  animation: fade-in 0.3s ease-out;
}

.sheet.leaving {
  animation: sheet-out 0.22s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.sheet.leaving::backdrop {
  animation: fade-out 0.22s ease-in forwards;
}

.sheet form::before {
  content: "";
  align-self: center;
  width: 40px;
  height: 5px;
  margin: -6px 0 -4px;
  background: var(--border);
  border-radius: 99px;
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

.sheet form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px calc(env(safe-area-inset-bottom) + 20px);
}

.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet p {
  margin: 0;
}

.benefits {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.benefits li {
  position: relative;
  padding-left: 30px;
}

.benefits li::before {
  content: "✓";
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
}

fieldset {
  /* Fieldsets are at least as wide as their content by default, which let wide inputs push past the sheet. */
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabs-height) + var(--tabs-gap) + 12px);
  left: 16px;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px;
  font-weight: 600;
  color: #fff;
  background: #192b48;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  animation: toast-in 0.25s var(--ease);
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.toast.leaving {
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-out {
  to {
    transform: translateY(8px);
    opacity: 0;
  }
}

.toast.error {
  background: var(--danger);
}

.toast[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::backdrop {
    transition: none !important;
    animation: none !important;
  }

  .done-check path {
    stroke-dashoffset: 0;
  }
}
