:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --border: #D3DBE3;
  --border-strong: #B4C0CC;
  --ink: #12263A;
  --muted: #5A6B7C;
  --accent: #12263A;
  --soft: #E3EAF1;
  --green: #1F6F5C;
  --green-soft: #E1F0EB;
  --amber: #8A5200;
  --amber-soft: #FEF3DC;
  --blue: #1D6FE8;
  --route: #1D6FE8;
  --header-h: 56px;
  --tabs-h: 72px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; scroll-padding-top: calc(var(--header-h) + 12px); scroll-padding-bottom: calc(var(--tabs-h) + 12px); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; font-size: 17px; }
a { color: #075985; text-underline-offset: .16em; }
button, a, input, textarea, select, summary, [tabindex] { outline-offset: 2px; }
:focus-visible { outline: 3px solid #4386c4; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }

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

.ico {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------------- Header (56 px) ---------------- */
.appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--accent);
  color: #fff;
  z-index: 900;
}
.appbar-inner {
  max-width: 60rem;
  height: 100%;
  margin: 0 auto;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  text-decoration: none;
  color: #fff;
  min-height: 48px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
}
.brand h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.header-icon-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.header-icon-btn:hover { background: rgba(255, 255, 255, .14); }

.lang-panel {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 12px;
  left: 12px;
  max-width: 380px;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(18, 38, 58, .18);
  padding: 16px;
  z-index: 950;
}
.lang-panel p { margin: 0 0 10px; font-size: 16px; }

/* ---------------- Five-destination navigation ---------------- */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabs-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 910;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1 1 auto;
  min-width: 44px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 15px;
  line-height: 1.1;
  font-weight: 600;
  color: #5A6B7C;
  text-decoration: none;
  position: relative;
  padding: 4px 2px;
  white-space: nowrap;
}
.tabs a .ico { width: 22px; height: 22px; }
.tabs a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
}
.tabs a[aria-current="page"] .ico { stroke-width: 2.4; }
.tabs a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  width: 40px;
  height: 3px;
  background: var(--ink);
  border-radius: 0 0 3px 3px;
}
.nav-ready-dot {
  position: absolute;
  top: 8px;
  left: calc(50% + 9px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  pointer-events: none;
}
.nav-ready-dot[hidden] { display: none; }

/* ---------------- Main container ---------------- */
.wrap {
  max-width: 52rem;
  margin: 0 auto;
  width: 100%;
}
main.wrap {
  padding: calc(var(--header-h) + 16px) 16px calc(var(--tabs-h) + 24px);
}
.view-head { margin: 0 0 14px; }
/* The shared language control's "Translating" notice (y 54-80) must not cover
   the first view heading; give the heading block a little more top room on
   localized pages. */
html[data-tbw-lang-label] .view-head { padding-top: 16px; }
.view-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 750;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.45;
}
.section-label, h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 0 8px;
  line-height: 1.3;
}
.card h3, .worksheet h3 {
  font-size: 19px;
  color: var(--ink);
  margin: 0 0 8px;
}
.card h4 {
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 6px;
}

/* ---------------- Buttons & inputs ---------------- */
.btn, .primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 44px;
  max-width: 100%;
  border-radius: 12px;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  text-align: center;
  gap: 8px;
  text-decoration: none;
  border: 1.5px solid transparent;
}
.btn.primary, .primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover:not(:disabled), .primary:hover:not(:disabled) { background: #1d3b58; }
.btn.ghost, .secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn.ghost:hover:not(:disabled), .secondary:hover:not(:disabled) { background: var(--soft); }
.btn.green {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn.green:hover:not(:disabled) { background: #18594a; }

label {
  display: block;
  font-weight: 650;
  font-size: 16px;
  margin: 14px 0 4px;
  color: var(--ink);
}
form > label:first-child { margin-top: 0; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  min-height: 48px;
  font-size: 17px;
  line-height: 1.4;
}
textarea { display: block; resize: vertical; min-height: 96px; }
.hint, .notice, .privacy-note, .map-key, .privacy-line {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}
.hint { margin: 4px 0 10px; }
.privacy-line { margin: 8px 2px 0; }
.shortcut-hint { display: none; margin: 6px 2px 0; }
@media (pointer: fine) {
  .shortcut-hint { display: block; }
}
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 0;
}
.status {
  color: var(--muted);
  font-size: 15px;
  min-height: 1.2em;
  margin: 8px 0;
}

/* ---------------- Ask box (mock 1-ask) ---------------- */
.ask-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
}
.ask-box-muted {
  border-width: 1.5px;
  border-color: var(--border-strong);
  align-items: center;
}
.ask-box textarea,
.ask-box input[type="search"] {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  padding: 10px 0;
  min-height: 48px;
  resize: none;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
}
.ask-box textarea { max-height: 128px; overflow-y: auto; }
.ask-box:focus-within {
  box-shadow: 0 0 0 3px rgba(67, 134, 196, .35);
}
.ask-box .search-ico { color: #7C8D9E; flex: none; }

/* ---------------- Chips & full-width rows ---------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  min-height: 48px;
  min-width: 44px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip:hover { background: #d4e0ec; }
.chip-all { background: var(--surface); border-color: var(--border-strong); }

.row-list { display: flex; flex-direction: column; gap: 8px; }
.row {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  min-height: 54px;
  text-align: left;
  text-decoration: none;
}
.row:hover:not(:disabled) { background: #f8fafc; border-color: var(--border-strong); }
.row small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
  margin-top: 2px;
}
.row .go { margin-left: auto; color: #7C8D9E; }
.row-shaded {
  background: var(--soft);
  border-color: var(--border-strong);
}
.back-row {
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------------- Cards, answers, citations ---------------- */
.card, .worksheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.card p { margin: 8px 0; }
.answer-text, .passage p { white-space: pre-wrap; font-size: 17px; line-height: 1.45; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--green-soft);
  color: var(--green);
  margin-bottom: 10px;
}
.tag.tag-blue { background: var(--soft); color: var(--ink); }
.tag.tag-amber, .tag.waiting { background: var(--amber-soft); color: var(--amber); }

.asked-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
  margin-bottom: 10px;
}
.asked-bar-text {
  flex: 1;
  font-size: 17px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.understood-note {
  margin: 0 2px 10px;
  font-size: 15px;
  color: var(--muted);
}

.cite-sup {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  position: relative;
  top: -0.22em;
  padding: 0 3px;
  cursor: pointer;
  text-decoration: underline;
}

.sources-list { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.src-row {
  width: 100%;
  background: transparent;
  border: 0;
  border-top: 1px solid #E6EBF0;
  padding: 10px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  min-height: 54px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}
.src-row:first-of-type { border-top: 0; }
.src-row:hover { background: #f8fafc; border-radius: 10px; }
.src-row small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
  margin-top: 2px;
}
.src-row .go { margin-left: auto; color: #7C8D9E; }
.src-num {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.progress-track {
  height: 8px;
  background: var(--soft);
  border-radius: 4px;
  margin-top: 14px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 8%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.5s linear;
}

.citation-code {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 6px;
}
.historical { color: var(--amber); font-weight: 700; }

.potential-references {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.potential-guidance {
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 6px;
  margin: 8px 0;
}
.potential-actions { margin-top: 8px; }
.passage { border-top: 1px solid var(--border); padding: 12px 0; }
.passage:first-of-type { border-top: 0; }
.passage h3, .passage h4 { font-size: 17px; margin: 0 0 4px; color: var(--ink); }
.citation { color: var(--muted); font-size: 15px; margin: 2px 0 8px; }

/* ---------------- Ask footer / About collapse ---------------- */
.ask-footer-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.disclaimer-copy, .about-lead {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 10px;
}
.about-details, .map-how-details, .coordinate-tools, .answer-excerpts {
  margin: 10px 0;
}
summary {
  cursor: pointer;
  color: #075985;
  font-weight: 700;
  font-size: 16px;
  min-height: 48px;
  min-width: 44px;
  display: flex;
  align-items: center;
  padding: 6px 0;
}
.helper-seo-overview {
  margin-top: 8px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--muted);
  font-size: 15px;
}
.helper-seo-overview h3 { font-size: 17px; color: var(--ink); margin: 0 0 10px; }
.helper-seo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0; }
.helper-seo-card { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.helper-seo-card h4 { margin: 0 0 4px; font-size: 16px; }
.helper-seo-card h4 a { display: inline-flex; align-items: center; min-height: 48px; min-width: 44px; }
.helper-seo-card p { margin: 0; font-size: 15px; }
.helper-seo-faq { margin: 12px 0; display: grid; gap: 10px; }
.helper-seo-faq div { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.helper-seo-faq dt { font-weight: 700; color: var(--ink); font-size: 15.5px; margin-bottom: 4px; }
.helper-seo-faq dd { margin: 0; font-size: 15px; }
.helper-seo-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.helper-seo-links a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  min-width: 44px;
  font-size: 15px;
  font-weight: 600;
}
.add-phone-row { margin-top: 12px; }

/* ---------------- Forms & Checkboxes ---------------- */
.search-box-wrap { margin-bottom: 12px; }
.form-list-row {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.form-list-copy { flex: 1 1 200px; }
.form-row-btn { flex: none; }
.form-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid label { margin-top: 6px; }
.hint-inline {
  display: block;
  font-weight: 400;
  font-size: 15px;
  color: var(--muted);
  margin: 2px 0 6px;
}
.ps-agreed {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 4px;
  font-size: 16px;
}
.ps-agreed label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin: 0;
  cursor: pointer;
}
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 48px;
  min-width: 44px;
  min-height: 48px;
  padding: 0;
  margin: 0;
  flex: none;
  border: 0;
  background: transparent;
  position: relative;
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
}
input[type="checkbox"]:checked::before {
  background: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: translate(-50%, -62%) rotate(45deg);
}
.rrecs-dispute-boxes label { font-weight: 500; margin-right: 10px; }
.ps-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 0;
}
.forms { display: grid; gap: 10px; }
.form-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.form-item p { color: var(--muted); font-size: 15px; margin: 4px 0 0; }

/* ---------------- Library ---------------- */
.library-quick-chips { margin: 12px 0 6px; }
.library-browse { margin-top: 12px; }

/* ---------------- Route Map (Map-First Full Bleed) ---------------- */
body.view-map .appbar { display: none; }
body.view-map main.wrap {
  padding: 0;
  max-width: none;
}
.map-viewport {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--tabs-h);
  overflow: hidden;
  background: #e6edf3;
  --sheet-height: 215px;
}
#routeMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #e6edf3;
  z-index: 0;
}

/* Leaflet attribution stays visible above the sheet */
.map-viewport .leaflet-bottom.leaflet-right {
  bottom: calc(var(--sheet-height, 215px) + 6px);
  right: 8px;
  z-index: 5;
  transition: bottom 0.18s ease;
}
.map-viewport .leaflet-control-attribution {
  font-size: 11px;
  background: rgba(255, 255, 255, .86);
  padding: 2px 6px;
  border-radius: 6px;
}
.map-viewport .leaflet-control-zoom { display: none; }

/* Floating Search Pill */
.map-search-wrap {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  max-width: 480px;
  z-index: 20;
}
/* The shared language control occupies the top-right 44px (y 8-52). Keep the
   floating map search pill and its Go button below it on localized pages. */
html[data-tbw-lang-label] .map-search-wrap {
  top: max(66px, calc(env(safe-area-inset-top) + 66px));
}
.map-search-pill {
  height: 52px;
  background: var(--surface);
  border-radius: 26px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .24);
  display: flex;
  align-items: center;
  padding: 0 4px 0 14px;
  gap: 8px;
}
.map-search-pill .search-ico { color: var(--muted); }
.map-search-pill input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  min-height: 48px;
  padding: 6px 0;
  font-size: 16px;
  color: var(--ink);
}
.map-search-go {
  min-width: 48px;
  min-height: 48px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 0 14px;
}
.map-search-results {
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(18, 38, 58, .22);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.map-search-result-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid #E6EBF0;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  display: flex;
  align-items: center;
}
.map-search-result-btn:first-child { border-top: 0; }
.map-search-result-btn:hover { background: var(--soft); }
.map-search-status {
  margin: 6px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .14);
  font-size: 15px;
  color: var(--ink);
}

/* Floating round buttons (Layers, My location) & Undo pill */
.map-fab-stack {
  position: absolute;
  right: 12px;
  bottom: calc(var(--sheet-height, 240px) + 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 15;
  transition: bottom 0.18s ease;
}
.map-fab {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.map-fab-locate { color: var(--blue); }
.map-fab-locate.is-following { background: var(--blue); color: #fff; }

.map-undo-pill {
  position: absolute;
  left: 12px;
  bottom: calc(var(--sheet-height, 240px) + 12px);
  width: auto;
  padding: 0 16px;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  z-index: 15;
  transition: bottom 0.18s ease;
}

.map-layers-menu {
  position: absolute;
  right: 72px;
  bottom: calc(var(--sheet-height, 215px) + 64px);
  width: min(290px, calc(100vw - 92px));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(18, 38, 58, .24);
  overflow: hidden;
  z-index: 25;
}
.map-layers-menu button {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid #E6EBF0;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.map-layers-menu button:first-child { border-top: 0; }
.map-layers-menu button[aria-checked="true"] {
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
}

/* My-location blue dot */
.me-location-dot {
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--blue);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(29, 111, 232, .25);
}

/* Bottom sheet */
.map-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sheet-height, 240px);
  max-height: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -3px 16px rgba(0, 0, 0, .22);
  z-index: 18;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.18s ease;
}
.map-sheet.is-dragging { transition: none; }
.sheet-grab-btn {
  width: 100%;
  min-height: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: none;
  touch-action: none;
  cursor: grab;
}
.sheet-grab-btn:active { cursor: grabbing; }
.sheet-grab-bar {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: #C5CED8;
}
.sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.map-sheet[data-sheet-state="peek"] .sheet-scroll {
  padding-bottom: 10px;
}
.map-sheet[data-sheet-state="peek"] .sheet-half-section,
.map-sheet[data-sheet-state="peek"] .sheet-full-section,
.map-sheet[data-sheet-state="peek"] #mapStatus {
  display: none;
}
.map-sheet[data-sheet-state="half"] .sheet-hint,
.map-sheet[data-sheet-state="half"] .pin-seg,
.map-sheet[data-sheet-state="half"] #sheetPeekActions,
.map-sheet[data-sheet-state="half"] .sheet-full-section,
.map-sheet[data-sheet-state="half"] #mapStatus {
  display: none;
}
.map-sheet[data-sheet-state="full"] #sheetPeekActions,
.map-sheet[data-sheet-state="full"] #sheetHalfActions {
  display: none;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0;
}
.sheet-title {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 750;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}
.sheet-meta {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  flex: none;
}
.sheet-hint { margin: 2px 0 6px; line-height: 1.32; }
.pin-panel-coords { margin: 0 0 8px; font-weight: 600; color: var(--ink); }

.pin-seg {
  display: flex;
  gap: 6px;
  margin: 6px 0 8px;
}
.pin-seg-btn {
  flex: 1 1 0;
  min-height: 48px;
  min-width: 44px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.15;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 5px;
  text-align: center;
}
.pin-seg-btn.is-selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 6px;
  flex: none;
}
.sheet-action-pair {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.sheet-action-pair .btn { flex: 1 1 0; min-width: 44px; padding: 4px 10px; font-size: 16px; }

.straight-line-label { margin: 4px 0 2px; font-weight: 600; }
.stop-list {
  list-style: none;
  padding: 0;
  margin: 0 0 6px;
}
.stop-list li { margin: 0; }
.stop-row-btn {
  width: 100%;
  min-height: 48px;
  padding: 6px 4px;
  border: 0;
  border-top: 1px solid #E6EBF0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}
.stop-row-btn:hover { background: #f8fafc; border-radius: 10px; }
.stop-badge {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.stop-copy { flex: 1; min-width: 0; }
.stop-copy small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 15px;
}
.stop-dist {
  margin-left: auto;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.sheet-group {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Existing map markers & panels */
.route-pin { width: 34px; height: 34px; position: relative; }
.route-pin svg { display: block; filter: drop-shadow(0 1px 2px #0007); }
.route-pin-mailbox { color: #15803d; }
.route-pin-park-point { color: #7c3aed; }
.route-pin-front-door { color: #eab308; }
.route-pin-connect-pick { outline: 3px solid #12263a; outline-offset: 2px; border-radius: 8px; }
.route-pin-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0; font-size: 15px; }
.route-pin-mini { vertical-align: -2px; margin-right: 4px; }
.map-controls-below {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0 6px;
}
.map-control-item { margin: 0; }
.panel-box {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px;
  background: var(--soft);
  margin: 10px 0;
}
.panel-box p { margin: 4px 0 8px; font-size: 15px; }
.proximity-note { border-color: #b45309; background: #fffbeb; }
#pinPanel .pin-kind-active { background: #d5e0eb; border-color: var(--accent); }
#undoClickToggle[aria-pressed="true"] { background: #d5e0eb; border-color: var(--accent); color: var(--ink); }
.connect-row { border-top: 1px solid var(--border); padding: 10px 0 4px; }
#connectCandidates { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
#followLocation {
  background: #172554;
  color: #fff;
  border: 2px solid #172554;
  font-weight: 700;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
}
#followLocation[aria-pressed="true"] { background: #0f172a; outline: 3px solid #93c5fd; outline-offset: 2px; }
#followLocation:disabled { background: #334155; border-color: #334155; color: #fff; opacity: 1; cursor: default; }
.android-download-box h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.checksum-link { margin-top: 4px; }

@media (pointer: coarse) {
  .leaflet-marker-icon .route-pin::after { content: ""; position: absolute; inset: -5px; }
}

/* ---------------- First-visit disclaimer dialog ---------------- */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -6rem;
  z-index: 2000;
  background: #fff;
  color: var(--ink);
  padding: 12px 16px;
  min-height: 48px;
  min-width: 44px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
}
.skip-link:focus { top: 8px; }
#veil {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(18, 38, 58, .58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#veil .box {
  background: var(--surface);
  width: 100%;
  max-width: 32rem;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border-radius: 16px;
  padding: 20px;
  border-top: 5px solid var(--accent);
  box-shadow: 0 12px 32px rgba(18, 38, 58, .28);
}
#veil h2 { margin: 0 0 12px; font-size: 22px; }
#veil p { color: var(--muted); font-size: 16px; margin: 0 0 12px; }
#veil button { margin-top: 6px; }
.dialog-open { overflow: hidden; }
#printSheet { display: none; }
.noscript { max-width: 52rem; margin: 80px auto 16px; padding: 16px; font-size: 17px; }

/* ---------------- Desktop >= 760px: top-row navigation ---------------- */
@media (min-width: 760px) {
  html { scroll-padding-bottom: 16px; }
  body.view-map .appbar { display: block; }
  .tabs {
    top: 0;
    bottom: auto;
    left: auto;
    right: max(68px, calc((100vw - 60rem) / 2 + 64px));
    height: var(--header-h);
    background: transparent;
    border-top: 0;
    padding-bottom: 0;
    gap: 4px;
    align-items: center;
  }
  .tabs a {
    flex: none;
    flex-direction: row;
    gap: 6px;
    padding: 0 12px;
    border-radius: 10px;
    color: #DCE6F0;
    min-height: 48px;
    height: 48px;
  }
  .tabs a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
  .tabs a[aria-current="page"] {
    color: #fff;
    background: rgba(255, 255, 255, .2);
  }
  .tabs a[aria-current="page"]::before { display: none; }
  .nav-ready-dot {
    top: 10px;
    left: 26px;
    background: #34D399;
    border-color: var(--ink);
  }

  main.wrap {
    padding: calc(var(--header-h) + 24px) 24px 40px;
  }
  .map-viewport {
    top: var(--header-h);
    bottom: 0;
  }
  .map-viewport .leaflet-control-zoom {
    display: block;
    margin-top: 76px;
    margin-left: 12px;
  }
  .map-viewport .leaflet-control-zoom a,
  .map-viewport .leaflet-touch .leaflet-bar a {
    width: 44px !important;
    height: 48px !important;
    line-height: 48px !important;
    font-size: 20px !important;
    color: var(--ink);
  }
  .map-sheet {
    left: 16px;
    right: auto;
    width: 440px;
    max-width: calc(100vw - 32px);
  }
  .map-fab-stack {
    bottom: 24px;
  }
  .map-undo-pill {
    left: 472px;
    bottom: 24px;
  }
}

@media (max-width: 759px) {
  .map-viewport[data-sheet-state="full"] .map-fab-stack,
  .map-viewport[data-sheet-state="full"] .map-undo-pill,
  .map-viewport[data-sheet-state="full"] .map-layers-menu {
    display: none;
  }
}

@media (max-width: 600px) {
  .form-grid.two { grid-template-columns: 1fr; gap: 6px; }
}

/* Narrow phones (320x568 iPhone SE) */
@media (max-width: 360px) {
  .appbar-inner { padding: 0 8px 0 12px; gap: 6px; }
  .brand h1 { font-size: 18px; }
  .tabs a {
    padding: 4px 1px;
    font-size: 15px;
    letter-spacing: -0.025em;
  }
  .tabs a .ico { width: 20px; height: 20px; }
  main.wrap { padding: calc(var(--header-h) + 12px) 12px calc(var(--tabs-h) + 28px); }
  .btn, .primary, .secondary { padding: 6px 12px; font-size: 16px; }
  .ask-box { padding: 4px 4px 4px 10px; gap: 6px; }
  .asked-bar { padding: 6px 6px 6px 10px; gap: 6px; }
  .helper-seo-grid { grid-template-columns: 1fr; }
  .map-search-wrap { left: 8px; right: 8px; }
  .map-search-pill { padding: 0 4px 0 10px; gap: 6px; }
  .map-layers-menu { right: 68px; width: min(236px, calc(100vw - 78px)); }
  .sheet-scroll { padding: 0 12px 14px; }
  .map-sheet[data-sheet-state="peek"] .sheet-scroll { padding-bottom: 8px; }
  .sheet-title { font-size: 18px; }
  .pin-seg { gap: 4px; margin: 5px 0 6px; }
  .pin-seg-btn { gap: 4px; padding: 4px 3px; font-size: 15px; letter-spacing: -0.02em; }
  .pin-dot { width: 9px; height: 9px; }
  .sheet-action-pair { gap: 6px; margin-top: 4px; }
  .sheet-action-pair .btn { padding: 4px 6px; font-size: 15px; }
  .map-viewport[data-sheet-state="half"] .map-fab-stack {
    flex-direction: row;
    bottom: calc(var(--sheet-height, 315px) + 10px);
  }
  .map-viewport[data-sheet-state="half"] .map-undo-pill {
    bottom: calc(var(--sheet-height, 315px) + 10px);
  }
  .map-controls-below { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
}

/* Site-wide language switcher (server/page-localization.js + translate/tbw-lang.js):
   hide the standalone English-only fallback button/panel and reserve top-right
   clearance so .tbw-lang-trigger settles inside the 56 px header without overlap. */
html[data-tbw-lang-label] #langBtn,
html[data-tbw-lang-label] #langPanel {
  display: none !important;
}
html[data-tbw-lang-label] #veil {
  padding-top: 60px;
}
html[data-tbw-lang-label] #veil .box {
  max-height: calc(100dvh - 76px);
}
@media (max-width: 759px) {
  html[data-tbw-lang-label] .appbar-inner {
    padding-right: 148px;
  }
}
/* English shows the full pill (drag handle + globe/Language + collapse dock,
   ~214 px wide, fixed at right: 8px) while every other language shows the
   44 px globe. At <=419 px the pill reaches into the brand: reserve the whole
   control plus an 8 px gutter and ellipsise #headerTitle, so the switcher never
   overlaps the title (T13) on the narrow English helper page. */
@media (max-width: 419px) {
  html[data-tbw-lang-label]:lang(en) .appbar-inner {
    padding-right: calc(env(safe-area-inset-right, 0px) + 230px);
  }
  html[data-tbw-lang-label]:lang(en) .brand {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  html[data-tbw-lang-label]:lang(en) #headerTitle {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (min-width: 760px) {
  html[data-tbw-lang-label] .tabs {
    right: max(156px, calc((100vw - 60rem) / 2 + 152px));
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

@media print {
  body { background: #fff; color: #000; }
  body > * { display: none !important; }
  #printSheet { display: block !important; font: 11pt/1.45 sans-serif; }
  #printSheet h1 { font-size: 17pt; margin: 0 0 8pt; }
  #printSheet h2 { font-size: 12pt; margin: 14pt 0 4pt; break-after: avoid; }
  #printSheet p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4pt 0 10pt; }
  #printSheet .print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8pt 16pt; }
  #printSheet .print-meta p { break-inside: avoid; }
  #printSheet li { margin-bottom: 5pt; }
  #printSheet svg { width: 100%; height: 240px; }
}
