/* /walk page styles: mobile-first, works at 360-390 px, no horizontal scroll.
   Phase 2j: same look as the rain page (public/index.html): its background,
   text colours, Plus Jakarta Sans, white 22 px cards without borders, and
   its pill scale (13 px / 700 on a warm pastel). Phase 2k: the rain page's
   orange is the accent everywhere (selected / active states as the rain
   page's active tab: #FF8A3D with white text; hover #F07526). */
:root {
  --bg: #FFF6E9;          /* rain --bg */
  --card: #ffffff;        /* rain --card-bg */
  --text: #4A3626;        /* rain --text */
  --muted: #7A6A57;       /* rain --text-soft */
  --softer: #9A8B78;      /* rain --text-softer */
  --pill: #FFE3BE;        /* rain header pills */
  --pill-hover: #FFD79E;
  --pill-text: #8A5A2B;
  --tab: #FFF1E4;         /* rain .tab-btn */
  --tab-text: #B5651D;
  --field-line: #FFD9AE;  /* rain inputs / secondary button border */
  --accent: #FF8A3D;      /* rain --primary, active tab */
  --accent-hover: #F07526; /* rain --primary-hover */
  --accent-text: #ffffff;
  --line: #F0E2CE;
  --error: #b42318;
  --route: #FF8A3D;       /* selected route tab = active tab; route line #F07526 (app.js) */
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; }

/* Header: title + pills on one row, subtitle full width below (as on the rain page). */
.top { max-width: 480px; margin: 0 auto; padding: 18px 18px 0; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.top h1 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.2; text-wrap: balance; }
.subtitle { margin: -8px 0 14px; color: var(--softer); font-size: 12px; line-height: 1.5; }
.top-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  flex: none; display: inline-flex; align-items: center; min-height: 36px; border: none; background: var(--pill); color: var(--pill-text);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.lang-toggle:hover { background: var(--pill-hover); }

main { max-width: 480px; margin: 0 auto; padding: 0 18px 32px; }
.card { background: var(--card); border: none; border-radius: 22px; padding: 14px; margin: 0 0 10px; }
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 800; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Buttons and chips: the rain page's tab/pill scale, labels on one line. */
.btn, .chip, .tab {
  min-height: 36px; border: none; background: var(--tab); color: var(--tab-text);
  font: inherit; font-size: 13px; font-weight: 700; line-height: 1.2; white-space: nowrap; cursor: pointer;
}
.btn { border-radius: 12px; padding: 8px 11px; }
.row .btn { flex: 1 1 auto; }
.btn.active { background: var(--accent); color: var(--accent-text); }
.btn.primary {
  width: 100%; min-height: 46px; background: var(--accent); color: var(--accent-text); border-radius: 16px;
  font-size: 15px; font-weight: 800; padding: 12px; margin-top: 2px;
}
.btn.primary:not(:disabled):hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* Start-button icons (Phase 2k). */
.btn .icon { flex: none; width: 14px; height: 14px; }
.row .btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 9px; }
.btn.active .icon-star path { fill: currentColor; }
/* Keyboard focus ring in the accent colour. */
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .lang-toggle:focus-visible, .place-btn:focus-visible, .als-btn:focus-visible,
.custom input:focus-visible, .text-input:focus-visible, .options input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.status { margin: 8px 0 0; min-height: 1.2em; color: var(--muted); font-size: 12.5px; }
.status:empty { display: none; }
.status.error { color: var(--error); }
.map { height: 55vh; min-height: 280px; max-height: 520px; border-radius: 16px; border: none; margin-top: 12px; }
.data-attribution { margin: 4px 2px 0; color: var(--softer); font-size: 11.5px; }

/* Duration: chips and the custom input share one row (wrap only if they cannot fit). */
.dur-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chips { display: contents; }
.chip { border-radius: 999px; padding: 8px; font-size: 12.5px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.custom { display: inline-flex; align-items: center; gap: 3px; margin: 0 0 0 2px; white-space: nowrap; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.custom input {
  width: 3.4em; min-height: 36px; padding: 6px; font: inherit; font-size: 13px; text-align: center; color: var(--text);
  border: 1.5px solid var(--field-line); border-radius: 12px; background: #fff; -moz-appearance: textfield; appearance: textfield;
}
.custom input::-webkit-outer-spin-button, .custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.custom input::placeholder { color: var(--softer); font-size: 12px; }

.options { padding-top: 8px; padding-bottom: 8px; }
.options label { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 2px 0; font-size: 13px; font-weight: 600; }
.options input { flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border-radius: 999px; padding: 6px 14px; }
.tab[aria-selected="true"] { background: var(--route); color: #fff; }
.stats, .notes { list-style: none; margin: 10px 0 0; padding: 0; }
.stats li { display: inline-block; margin: 0 14px 4px 0; font-weight: 700; }
.notes li { margin: 6px 0 0; padding: 8px 10px; background: var(--tab); border-radius: 12px; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.landsd-logo { display: block; width: 36px; height: 36px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.pet-label { font-size: 0.85rem; font-weight: 600; }
.leaflet-container { font: inherit; }

/* Saved places (Phase 2c). The sheet sits at the bottom of the screen so every
   button is within thumb reach on a phone. */
.saved-box { margin-top: 10px; }
.saved-list, .manage-list, .als-results { list-style: none; margin: 0; padding: 0; }
.saved-list li + li, .als-results li + li { margin-top: 6px; }
.place-btn, .als-btn {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit; cursor: pointer; overflow-wrap: anywhere;
}
.saved-box .row { margin-top: 10px; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 2000; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2001; max-height: 85vh; overflow-y: auto;
  max-width: 720px; margin: 0 auto; background: var(--card); border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.icon-btn { flex: none; width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.2rem; color: var(--muted); cursor: pointer; }
.text-input { display: block; width: 100%; padding: 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; }
.field-label { display: block; margin: 8px 0 6px; font-weight: 600; }
.name-address { margin: 0 0 4px; color: var(--muted); overflow-wrap: anywhere; }
.confirm-text { margin: 4px 0 8px; font-size: 1.05rem; overflow-wrap: anywhere; }
.als-results { margin-top: 8px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1 1 0; min-height: 48px; margin-top: 0; }
.btn.wide { width: 100%; margin-top: 10px; min-height: 48px; }
.btn.danger { background: var(--error); color: #fff; border-color: var(--error); font-weight: 600; }
.manage-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.manage-list .place-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.manage-list .btn { flex: none; padding: 8px 12px; min-height: 44px; }
.device-only { margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; }
body.sheet-open { overflow: hidden; }

/* Footer notes (Phase 2d): always shown, below the route controls. */
.page-notes { margin: 20px 0 0; padding: 12px 2px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.note-list { margin: 0; padding: 0 0 0 1.1em; }
.note-list li + li { margin-top: 4px; }
.page-notes .data-attribution { margin: 10px 0 0; }
.btn.primary[aria-busy="true"] { opacity: 0.75; cursor: progress; }

/* Phase 2e: the map sits below the generate button; a hint above it while
   picking, so it is visible when the map is scrolled into view. */
.map-area { margin-top: 12px; }
.map-area .map { margin-top: 0; }
.map-status { margin: 0 2px 6px; font-weight: 600; color: var(--text); }
.map-status.error { color: var(--error); }
.marker-popup { min-width: 140px; }
.marker-popup .place-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.marker-popup .btn { width: 100%; min-height: 44px; }

/* Header: back link to the rain page next to the language toggle (Phase 2f). */
.top-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.back-link { display: inline-block; text-decoration: none; white-space: nowrap; }

/* Phase 2j: saved places, sheet and footer in the rain page's style. */
.place-btn, .als-btn { border: none; background: var(--tab); color: var(--text); border-radius: 12px; font-size: 13px; font-weight: 600; }
.place-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.sheet { max-width: 480px; border-radius: 22px 22px 0 0; }
.sheet-head h2 { font-size: 15px; font-weight: 800; }
.text-input { border: 1.5px solid var(--field-line); border-radius: 14px; font-size: 14px; }
.field-label { font-size: 13px; font-weight: 700; }
.confirm-text { font-size: 15px; }
.manage-list .btn { white-space: nowrap; }
.btn.danger { background: var(--error); color: #fff; font-weight: 700; }
.device-only { color: var(--softer); font-size: 12px; }
.page-notes { border-top-color: var(--line); color: var(--softer); font-size: 12px; line-height: 1.5; }
.map-status { font-size: 13px; }
.marker-popup .btn { white-space: nowrap; }
/* English placeholder "Custom" is wider than "自訂"; the English chips leave room for it. */
html[lang="en"] .custom input { width: 4.7em; padding: 6px 3px; }

/* Corgi run (Phase 3a): 44 px sprite anchored at the paws (corgi.js), soft
   shadow under the paws, never takes taps or drags from the map. */
.leaflet-corgi-pane, .leaflet-corgi-pane * { pointer-events: none !important; }
.corgi { pointer-events: none !important; background: none; border: none; }
.corgi::before {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 26px; height: 6px; margin-left: -13px;
  border-radius: 50%; background: radial-gradient(ellipse at center, rgba(74, 54, 38, 0.28) 0%, rgba(74, 54, 38, 0) 70%);
}
.corgi-sprite { position: absolute; inset: 0; transform: translate(var(--sx, 0px), var(--sy, 0px)); }
.corgi[data-face="W"] .corgi-sprite { transform: translate(var(--sx, 0px), var(--sy, 0px)) scaleX(-1); }
.corgi::before { transform: translate(var(--sx, 0px), var(--sy, 0px)); } /* the shadow follows the sitting corgi */
.corgi-img { position: absolute; left: 0; top: 0; width: 44px; height: 44px; display: none; user-select: none; -webkit-user-drag: none; }
.corgi[data-pose="run"][data-frame="0"] .f0, .corgi[data-pose="run"][data-frame="1"] .f1,
.corgi[data-pose="run"][data-frame="2"] .f2, .corgi[data-pose="run"][data-frame="3"] .f3,
.corgi[data-pose="sit"] .sit { display: block; }
.replay-btn { margin-top: 6px; }
.replay-btn[hidden] { display: none; }
