:root {
  --bg: #f4f1e8;
  --panel: rgba(15, 23, 31, 0.95);
  --panel-soft: rgba(15, 23, 31, 0.82);
  --card: #ffffff;
  --text: #0f1720;
  --text-inverse: #f8fafc;
  --muted: #5c6770;
  --accent: #f26b1d;
  --accent-strong: #ff8a3d;
  --safe: #147451;
  --route: #f26b1d;
  --line: rgba(15, 23, 31, 0.08);
  --shadow: 0 14px 30px rgba(15, 23, 31, 0.14);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #fff7dd 0%, #f4f1e8 55%, #ece5d8 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 52vh 48vh;
  background: transparent;
}

.map-panel {
  position: relative;
  min-height: 320px;
}

#map {
  height: 100%;
  width: 100%;
}

.map-overlay {
  position: absolute;
  inset: 16px 16px auto 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.status-badge,
.map-legend {
  background: var(--panel-soft);
  color: var(--text-inverse);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.map-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 600;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.legend-swatch.route {
  background: var(--route);
}

.legend-swatch.house {
  background: var(--safe);
}

.legend-swatch.points {
  background: #f5d6bf;
  border: 1px solid var(--text);
}

.legend-swatch.drop {
  background: #f8f5ef;
  border: 2px solid var(--text);
}

.info-panel {
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  align-content: start;
}

.current-street-card,
.info-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

body[data-ui-mode="walk"] .app-shell {
  grid-template-rows: 60vh 40vh;
}

@media (max-width: 900px) {
  body[data-ui-mode="walk"] .map-legend,
  body[data-ui-mode="walk"] .import-card,
  body[data-ui-mode="walk"] .drop-plan-card,
  body[data-ui-mode="walk"] .next-streets-card,
  body[data-ui-mode="walk"] .status-card {
    display: none;
  }

  body[data-ui-mode="walk"] .info-panel {
    padding-top: 12px;
  }
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.1;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1;
}

.big-copy {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.supporting-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.95rem;
}

.number-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.compact-number-grid {
  gap: 8px;
  margin-top: 12px;
}

.compact-number-grid .number-pill {
  min-width: 52px;
  padding: 10px 12px;
  font-size: 1rem;
}

.number-pill {
  min-width: 64px;
  text-align: center;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #edf8f2;
  color: var(--safe);
  border: 2px solid rgba(20, 116, 81, 0.16);
  font-size: 1.2rem;
  font-weight: 800;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.number-pill.is-nearest {
  background: #ffe5d4;
  color: #9b3e00;
  border-color: rgba(242, 107, 29, 0.28);
}

.number-pill.is-complete {
  background: #edf0f2;
  color: #63717a;
  border-color: rgba(15, 23, 31, 0.08);
  text-decoration: line-through;
}

.next-streets {
  display: grid;
  gap: 10px;
}

.drop-plan-card {
  display: grid;
  gap: 12px;
}

.prep-card {
  display: grid;
  gap: 12px;
}

.next-street-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #f7f4ee;
}

.next-street-row strong {
  font-size: 1.05rem;
}

.next-street-row span {
  color: var(--muted);
  font-weight: 600;
}

.next-street-row.drop-plan-row {
  align-items: flex-start;
  flex-direction: column;
}

.next-street-row.drop-plan-row span {
  display: block;
  width: 100%;
}

.house-marker {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--safe);
  border: 3px solid rgba(255, 255, 255, 0.96);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(20, 116, 81, 0.34);
}

.house-marker.house-marker-nearest {
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(242, 107, 29, 0.34);
}

.drop-marker {
  width: 22px;
  height: 22px;
  transform: rotate(45deg);
  border-radius: 5px;
  background: #fff;
  border: 3px solid var(--text);
  box-shadow: 0 6px 16px rgba(15, 23, 31, 0.24);
}

.import-card {
  display: grid;
  gap: 12px;
}

.import-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.secondary-button {
  border: 0;
  background: #f3ede2;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  font: inherit;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  font: inherit;
}

.primary-button:disabled {
  opacity: 0.45;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

.text-input {
  width: 100%;
  border: 1px solid rgba(15, 23, 31, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  background: #fffdf8;
}

.file-input-shell {
  display: grid;
  gap: 4px;
  border: 2px dashed rgba(15, 23, 31, 0.16);
  border-radius: 18px;
  padding: 16px;
  background: #fbf8f2;
}

.file-input-shell span {
  font-weight: 800;
}

.file-input-shell small,
.pill-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill-note {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.progress-row {
  display: grid;
  gap: 8px;
}

progress {
  width: 100%;
  height: 12px;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: #efe8d8;
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, #f26b1d, #ff9b48);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, #f26b1d, #ff9b48);
  border-radius: 999px;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
}

.target-card {
  display: grid;
  gap: 10px;
}

.start-card {
  display: grid;
  gap: 12px;
}

.target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.target-copy {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.1;
}

.start-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.secondary-button.is-active {
  background: #ffe5d4;
  color: #9b3e00;
}

.start-marker {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #2563eb;
  border: 3px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.34);
}

.leaflet-tooltip.drop-tooltip {
  background: rgba(15, 23, 31, 0.92);
  border: 0;
  color: #fff;
  box-shadow: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
}

.leaflet-tooltip.drop-tooltip::before {
  display: none;
}

.leaflet-control-attribution {
  font-size: 0.7rem;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 440px);
    grid-template-rows: 100vh;
  }

  .info-panel {
    padding: 20px 20px 24px 0;
    max-height: 100vh;
    overflow: auto;
  }

  .map-panel {
    padding: 20px;
  }

  #map {
    border-radius: 28px;
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  body[data-ui-mode="walk"] .app-shell {
    grid-template-rows: 64vh 36vh;
  }

  .map-overlay {
    inset: 12px 12px auto 12px;
    flex-direction: column;
  }

  .map-legend {
    gap: 10px;
    font-size: 0.82rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .number-pill {
    min-width: 58px;
    padding: 12px 14px;
  }

  .start-actions {
    grid-template-columns: 1fr;
  }
}
