.drive {
  max-width: 900px;
  margin: auto;
}
.drive h2 {
  font-size: clamp(26px, 6vw, 40px);
  margin: 10px 0;
}
.drive button {
  min-height: 54px;
  font-size: 17px;
  padding: 14px 20px;
}
.drive label {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}
.drive input,
.drive select {
  font-size: 18px;
  min-height: 52px;
  max-width: 100%;
  width: 100%;
}
.drive-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.drive-map {
  display: block;
  background: #e5ece7;
  width: 100%;
  height: 300px;
  border-radius: 18px;
}
.drive small {
  display: block;
  color: #536252;
  margin: 8px 0;
}
.drive-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.drive-stats > div {
  background: #fff;
  border: 1px solid #dce3d9;
  border-radius: 14px;
  padding: 16px;
}
.drive-stats strong,
.drive-stats dd {
  display: block;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 750;
  margin: 5px 0 0;
}
.drive-stats span,
.drive-stats dt {
  font-size: 14px;
  color: #536252;
}
.drive-controls {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: #f4f6ef;
  padding: 16px 0 max(16px, env(safe-area-inset-bottom));
  z-index: 3;
}
.drive-controls .danger {
  background: #a73e31;
  color: white;
  min-height: 66px;
  border: 0;
}
.drive-arrival,
#drive-exit {
  padding: 22px;
  background: #e4f2df;
  border: 1px solid #acc1a4;
  border-radius: 16px;
  margin: 18px 0;
}
.drive-arrival button {
  display: block;
  width: 100%;
  margin: 10px 0;
}
.drive-message {
  padding: 16px;
  border-radius: 12px;
  background: #fff1d6;
  overflow-wrap: anywhere;
}
.drive-note {
  font-size: 13px;
  color: #60705e;
  line-height: 1.6;
}
.drive details {
  border: 1px solid #d1ddcb;
  border-radius: 12px;
  padding: 18px;
  margin: 20px 0;
}
.drive summary {
  cursor: pointer;
  min-height: 32px;
}
.drive-field-list {
  display: grid;
  gap: 10px;
  margin-top: 15px;
}
.drive form > .primary {
  width: 100%;
  margin: 16px 0;
}
.drive button:disabled {
  opacity: 0.55;
}
.drive button:focus-visible {
  outline: 3px solid #bd943b;
  outline-offset: 3px;
}
.journal .drive-stats dd {
  font-size: 20px;
}
.journal .drive-map {
  height: 260px;
}
@media (max-width: 520px) {
  .drive-top {
    align-items: flex-start;
  }
  .drive-top button {
    min-width: 100px;
  }
  .drive-map {
    height: 260px;
  }
  .drive-stats > div {
    padding: 12px;
  }
  .drive-controls button {
    padding: 12px;
  }
  .wrap:has(.drive) > #title,
  .wrap:has(.drive) > #intro,
  .wrap:has(.drive) > .ey {
    display: none;
  }
}

body:has(.drive-running) > .top,
body:has(.drive-running) > .nav,
.wrap:has(.drive-running) > #storage-note {
  display: none;
}
.drive-running {
  padding-bottom: 90px;
}
.drive-running .drive-controls {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 900px;
  box-shadow: 0 -5px 20px #183b2a15;
}
.drive-back {
  border: 0;
  background: transparent;
  color: #29563c;
  font-size: 14px !important;
  min-height: 40px !important;
  padding: 6px 0 !important;
  display: block;
}
.drive-running .drive-map {
  height: 240px;
}
@media (min-width: 700px) {
  .drive-running .drive-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Map remains mounted behind all drive states. */
.drive.drive-scene {
  position: fixed;
  inset: calc(64px + env(safe-area-inset-top)) 0 calc(78px + env(safe-area-inset-bottom));
  max-width: none;
  padding: 0;
  z-index: 30;
  background: #dce7d8;
  overflow: hidden;
}
#drive-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #dce7d8;
}
.drive-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 100px;
  display: flex;
  gap: 10px;
  z-index: 2;
  pointer-events: none;
}
.drive-hud > div {
  background: #fffffff0;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 3px 12px #152d2520;
  min-width: 0;
}
.drive-hud > div:last-child {
  flex: 1;
}
.drive-hud small {
  margin: 0 0 4px;
  font-size: 12px;
}
.drive-hud strong {
  font-size: 15px;
}
.drive-map-tools {
  position: absolute;
  right: 10px;
  top: 12px;
  display: grid;
  gap: 8px;
  z-index: 3;
}
.drive-map-tools button {
  background: #fffffff5;
  border: 0;
  border-radius: 14px;
  width: 78px;
  min-height: 64px;
  padding: 8px;
  font-size: 26px;
  box-shadow: 0 3px 10px #152d2520;
}
.drive-map-tools small {
  font-size: 10px;
  margin: 2px 0;
}
.drive-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 43%;
  overflow-y: auto;
  padding: 22px 18px 18px;
  background: #f8fbf7f5;
  border-radius: 26px 26px 0 0;
  z-index: 4;
  box-shadow: 0 -4px 24px #10281925;
}
.drive-sheet:before {
  content: '';
  display: block;
  width: 44px;
  height: 5px;
  border-radius: 8px;
  background: #cfd9d1;
  margin: -12px auto 16px;
}
.drive-sheet h2 {
  font-size: 23px;
}
.drive-sheet-small .drive-sheet {
  max-height: 100px;
}
.drive-sheet #drive-map,
.drive-sheet .drive-map-wrap {
  display: none;
}
.drive-scene .drive-controls {
  position: static;
  transform: none;
  width: auto;
  box-shadow: none;
  padding: 8px 0;
  background: transparent;
}
.drive-scene .drive-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0;
}
.drive-scene .drive-stats > div {
  padding: 9px;
}
.drive-scene .drive-stats strong,
.drive-scene .drive-stats dd {
  font-size: 17px;
}
.drive-scene .drive-stats span,
.drive-scene .drive-stats dt {
  font-size: 11px;
}
.drive-scene details {
  padding: 12px;
  margin: 12px 0;
}
.drive-scene .primary {
  background: #265a38;
  color: white;
  border: 0;
  border-radius: 14px;
}
.drive-scene .drive-start-main {
  width: 100%;
}
.drive-scene .drive-arrival {
  margin: 8px 0;
  padding: 14px;
}
.drive-scene #drive-discard {
  margin-top: 12px;
  width: 100%;
  background: #fff0ec;
  color: #963f30;
  border: 1px solid #d5a295;
}
.drive-scene .leaflet-control-attribution {
  max-width: 90vw;
  font-size: 9px;
}
.drive-scene .leaflet-bottom {
  bottom: 44%;
}
body:has(.drive-scene) > .top {
  display: flex;
}
@media (min-width: 800px) {
  .drive-sheet {
    left: 20px;
    bottom: 20px;
    right: auto;
    width: 410px;
    max-height: 62%;
    border-radius: 24px;
  }
  .drive-hud {
    right: 120px;
  }
  .drive-scene .leaflet-bottom {
    bottom: 0;
  }
}

.drive-sheet:before {
  display: none;
}
.drive-sheet {
  padding-top: 0;
}
.drive-sheet-heading {
  position: sticky;
  top: 0;
  z-index: 6;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fbf7;
  border: 0;
  border-bottom: 1px solid #dce7db;
  text-align: left;
  color: #244e32;
  padding: 14px 4px !important;
  font-size: 15px !important;
  font-weight: 700;
}
.drive-sheet-heading svg {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}
.drive-sheet-heading[aria-expanded='false'] svg {
  transform: rotate(180deg);
}
.drive-sheet-small .drive-sheet {
  max-height: none;
  padding-bottom: 4px;
}
.drive-sheet-small .leaflet-bottom {
  bottom: 70px;
}
#drive-sheet-content {
  padding-top: 12px;
}
.drive-tractor {
  background: none;
  border: 0;
  transition: transform 0.6s linear;
}
.drive-tractor-heading {
  width: 40px;
  height: 54px;
  filter: drop-shadow(0 2px 3px #10231999);
}
.drive-tractor svg {
  width: 100%;
  height: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .drive-tractor {
    transition: none;
  }
}
@media (min-width: 800px) {
  .drive-sheet-small .leaflet-bottom {
    bottom: 0;
  }
}
.drive-work-fields fieldset {
  border: 1px solid #d1dece;
  border-radius: 12px;
  padding: 12px;
  margin: 14px 0;
  background: #fff;
}
.drive-work-fields legend {
  font-weight: 700;
  color: #28583b;
}
.drive-work-fields .two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.drive-work-fields textarea {
  width: 100%;
  min-height: 80px;
  font-size: 16px;
}
.drive-work-fields label {
  margin: 10px 0;
}
.drive-work-fields button {
  font-size: 14px;
  min-height: 44px;
  padding: 8px 12px;
}
.drive-work-settings[open] {
  overflow-wrap: anywhere;
}
.drive-sheet:has(#drive-setup) {
  max-height: 62%;
}
.drive-sheet-small .drive-sheet:has(#drive-setup) {
  max-height: none;
}
.field-note-picker {
  position: fixed;
  inset: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #dce7d8;
  overflow: hidden;
}
.field-note-picker .note-map {
  position: absolute;
  inset: 0;
}
.note-picker-panel {
  position: absolute;
  z-index: 1000;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: #f8fbf7;
  max-height: 45%;
  overflow: auto;
  box-shadow: 0 -4px 24px #10281925;
}
.note-picker-panel h2 {
  font-size: 21px;
  margin: 0 0 10px;
}
.note-picker-panel button {
  min-height: 46px;
  border: 1px solid #c9d8ca;
  border-radius: 12px;
  padding: 10px 14px;
  background: white;
  color: #245538;
  font: inherit;
}
.note-picker-modes,
.note-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.note-picker-modes button {
  flex: 1;
}
.note-picker-modes [aria-pressed='true'],
.note-picker-panel .primary {
  background: #265a38;
  color: white;
}
.note-picker-panel button:disabled {
  opacity: 0.45;
}
.note-picker-panel p {
  font-size: 14px;
  line-height: 1.5;
}
.note-map-handle span {
  display: block;
  width: 24px;
  height: 24px;
  background: #f59e0b;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px #0008;
}
.field-note-picker .leaflet-bottom {
  bottom: 45%;
}
.drive-field-list [hidden] {
  display: none;
}
.drive-sheet:has(#drive-target-picker) {
  max-height: 62%;
}
/* Recovery and exit preferences stay inside the expandable drive sheet. */
.drive-auto-settings,
.drive-reviews {
  margin-top: 14px;
  padding: 12px 14px;
  background: #f4f7f1;
  border: 1px solid #dce6d6;
  border-radius: 13px;
}
.drive-auto-settings > summary,
.drive-reviews > summary {
  min-height: 32px;
  font-weight: 650;
  cursor: pointer;
  color: #28563a;
}
.drive-auto-settings label {
  margin-top: 12px;
}
.drive-auto-settings .drive-note {
  font-size: 12px;
  line-height: 1.5;
  color: #536c58;
  margin-top: 10px;
}
.drive-auto-settings #drive-recover {
  width: 100%;
  margin-top: 10px;
}
.drive-reviews button {
  display: block;
  width: 100%;
  margin-top: 9px;
  text-align: left;
}
.drive-auto-ended {
  background: #e4f1df;
  border-left: 3px solid #54834c;
  padding: 10px 12px;
  border-radius: 8px;
  color: #294c32;
}
#drive-new-after-review {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.drive-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dce6d6;
}
.drive [hidden] {
  display: none !important;
}
.drive:not(:has(#drive-setup)):not(.drive-running):not(:has(.drive-arrival))
  .drive-hud
  > div:last-child {
  display: none;
}
.drive-mode-status {
  font-size: 13px;
  font-weight: 650;
  color: #346143;
}
.drive-mode-status:before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #4c925c;
}
.drive-mode-bar #drive-toggle {
  font-size: 13px;
  min-height: 44px;
  padding: 9px 12px;
  white-space: nowrap;
}
.drive .drive-search-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 18px;
  font-size: 15px;
  line-height: 1.4;
}
.drive .drive-search-switch input {
  appearance: none;
  flex: none;
  width: 48px;
  min-width: 48px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid #a4b5a2;
  border-radius: 18px;
  background: #d4ddd0;
  cursor: pointer;
}
.drive-search-switch input:before {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px #0002;
  transition: transform 0.15s;
}
.drive .drive-search-switch input:checked {
  background: #28623a;
  border-color: #28623a;
}
.drive-search-switch input:checked:before {
  transform: translateX(20px);
}
.drive-search-switch input:focus-visible {
  outline: 3px solid #a97d24;
  outline-offset: 3px;
}
.drive-searching {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  margin: 6px 0;
  color: #28543a;
  font-size: 18px;
  font-weight: 650;
}
.drive-searching > span {
  width: 20px;
  height: 20px;
  border: 2px solid #c9dccc;
  border-top-color: #28623a;
  border-radius: 50%;
  animation: drive-search-spin 1.2s linear infinite;
}
.drive:has(.drive-searching) .drive-hud > div:last-child {
  display: none;
}
.drive #drive-begin {
  display: block;
  width: 100%;
  margin: 18px 0 8px;
  min-height: 58px;
  font-size: 20px;
}
.drive #drive-cancel {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
}
.drive .drive-extra-settings {
  background: #f1f5ed;
  margin: 16px 0;
  padding: 12px;
}
.drive .drive-extra-settings summary {
  font-size: 14px;
  font-weight: 650;
}
.drive #drive-setup > p {
  font-size: 12px;
  line-height: 1.5;
  color: #61735f;
}
.drive .drive-work-fields > h3 {
  font-size: 18px;
}
@keyframes drive-search-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .drive-searching > span {
    animation: none;
  }
  .drive-search-switch input:before {
    transition: none;
  }
}
.drive-sheet-content small.drive-note,
.drive small.drive-note {
  display: block;
  margin: 7px 0 12px;
  font-size: 12px;
  color: #546a58;
}
