:root {
  color-scheme: light;
  --ink: #14221b;
  --muted: #3d4f45;
  --line: #d5e0d8;
  --paper: #f4f7f5;
  --card: #ffffff;
  --green: #046c4e;
  --green-dark: #064e3b;
  --red: #9f1239;
  --amber: #b45309;
  --focus: #046c4e;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
}

img { max-width: 100%; height: auto; }

button, a, input, select { font: inherit; }

button, .btn {
  min-height: 44px;
  border-radius: 14px;
  border: 0;
  padding: 12px 16px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  width: min(40rem, calc(100% - 1.5rem));
  margin: 0 auto;
}

.site-header { padding: 12px 0 4px; }

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  flex: 0 0 auto;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0;
}

.eyebrow, .kicker {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green-dark);
}

.header-actions, .choice-row, .stack, .status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-actions { margin-top: 10px; }

.header-actions .btn, .header-actions button {
  flex: 1 1 9rem;
}

.btn.primary, button.primary { background: var(--green); color: white; }
.btn.dark, button.dark { background: #1f2933; color: white; }
.btn.secondary, button.secondary { background: white; color: var(--ink); border: 2px solid var(--line); }
.btn.quiet, button.quiet {
  background: transparent;
  color: var(--muted);
  border: 0;
  min-height: 44px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.amber, button.amber { background: #c2410c; color: white; }
.btn.wide, button.wide, a.wide { width: 100%; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 12px 0;
}

.stats strong { font-size: 1.25rem; }

.progress {
  flex: 1 1 100%;
  height: 12px;
  background: #e5eee8;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--green);
  width: 0;
}

#question-banner, #next-stop { scroll-margin-top: calc(8px + env(safe-area-inset-top)); }

.next-card, .store-card, .panel, .note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin: 12px 0;
}

.next-card {
  border: 3px solid var(--red);
  box-shadow: 0 8px 24px rgba(159, 18, 57, 0.08);
}

.next-card h2, .store-card h3 {
  font-size: 1.45rem;
  line-height: 1.2;
  margin: 4px 0;
}

.address, .hours, .meta { margin: 4px 0; }

.address { font-size: 1.05rem; }

.hours { font-weight: 800; }

.distance { font-size: 1.15rem; margin: 8px 0 12px; }

.about { color: var(--muted); font-weight: 650; }

.stack .btn, .stack button, .stack a.btn { width: 100%; }

.hint { color: var(--muted); margin: 6px 0 0; font-size: 1rem; }

.choice-row button[aria-pressed="true"] {
  background: white;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 2px var(--green);
}

.segment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #e7eee9;
  border-radius: 16px;
  padding: 6px;
}

.segment button { flex: 1 1 8rem; background: transparent; }

.question {
  background: var(--green-dark);
  color: white;
  border-radius: 18px;
  padding: 16px;
  margin: 12px 0;
}

.question .btn.secondary { color: var(--ink); }

.map-panel { padding: 0; overflow: hidden; }

.map-bar, .legend, .map-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

#village-map { height: 200px; width: 100%; touch-action: pan-y; }
#village-map.can-drag { touch-action: none; }

.leaflet-control-zoom a {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
  font-size: 22px !important;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.95rem; }
.dot { width: 14px; height: 14px; border-radius: 999px; display: inline-block; }
.dot.home { background: #d97706; }
.dot.next { background: var(--red); }
.dot.soon { background: var(--green); }
.dot.done { background: #94a3b8; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tabs button { flex: 1 1 8rem; background: #e7eee9; }
.tabs button[aria-selected="true"] { background: white; box-shadow: inset 0 0 0 2px var(--green-dark); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; font-weight: 700; }
select, input[type="text"] {
  min-height: 48px;
  border-radius: 12px;
  border: 2px solid var(--line);
  padding: 10px 12px;
  width: 100%;
  background: white;
  color: var(--ink);
}

.city-row { margin: 8px 0 4px; }

.checked-card .status-actions button[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--green-dark); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fde8ee;
  color: var(--red);
  font-weight: 800;
  font-size: 0.9rem;
}

.badge.neutral { background: #eef2f0; color: var(--muted); }
.badge.live { background: #e3f6ec; color: var(--green-dark); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 18, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.modal .sheet {
  background: white;
  width: min(36rem, 100%);
  border-radius: 20px;
  padding: 16px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.sheet h2 { margin: 0 0 8px; font-size: 1.4rem; }

.sheet ol { padding-left: 1.2rem; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(28rem, calc(100% - 24px));
  background: #1f2933;
  color: white;
  border-radius: 16px;
  padding: 12px 14px;
}

.pick-banner {
  background: #fff7ed;
  border: 2px solid var(--amber);
  border-radius: 16px;
  padding: 12px;
  margin: 12px 0;
}

.empty { text-align: center; }

.list-status { color: var(--muted); margin: 8px 0; }

@media (min-width: 720px) {
  .modal { align-items: center; }
  h1 { font-size: 1.6rem; }
}
