/* Grandpa Norman's Book of Mormon Map
   Palette taken from his 2005 hand-drawn map: mint land wash, orange numbered
   discs with dark red numerals, rust lettering, blue water. The Old World
   chapter (not his) is drawn in indigo so the two never read as one source. */

:root {
  --paper: #F5F7F1;
  --paper-raised: #FCFDF9;
  --wash: #E4ECDD;
  --ink: #2F2A22;
  --ink-2: #5A5448;
  --rule: #CDD5C4;

  --marker: #EE6A24;        /* his orange discs */
  --marker-ink: #6B1A0A;    /* the dark red numerals */
  --marker-soft: #F8B27A;
  --marker-wash: #FCEBDD;
  --rust: #8A3A1C;          /* his map lettering */

  --indigo: #2C4A7C;        /* Old World: not from his gazetteer */
  --indigo-wash: #E3E9F3;
  --forest: #4C7A42;
  --lidar: #6E3A82;         /* LiDAR surveys: modern science, not his map */
  --lidar-wash: #F1E9F4;
  --sea: #3A76A6;

  --focus: #1E5BC6;
  --shadow: 0 1px 2px rgba(47, 42, 34, .18), 0 6px 18px rgba(47, 42, 34, .14);

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --caps: "Alegreya SC", "Alegreya", Georgia, serif;
  --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --panel-w: 420px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }

#map {
  position: fixed;
  inset: 0;
  background: #DDE6EC;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  left: var(--gutter);
  top: -60px;
  z-index: 2000;
  background: var(--paper-raised);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.skip-link:focus { top: var(--gutter); }

.tool svg, .icon-btn svg, .step-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Masthead: the title block of the atlas page ---------- */

.masthead {
  position: fixed;
  top: var(--gutter);
  left: var(--gutter);
  z-index: 1000;
  max-width: 440px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}

.masthead h1 {
  margin: 0;
  font-family: var(--caps);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: .05em;
  color: var(--rust);
}

.masthead-sub {
  margin: 4px 0 10px;
  font-style: italic;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink-2);
}

.chapters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.chapters button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.chapters button:hover { background: var(--wash); }
.chapters button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.chapters button[aria-pressed="true"] .swatch-gz { box-shadow: 0 0 0 1.5px var(--paper); }
.chapters button[aria-pressed="true"] .swatch-ow { background: #B9C8E4; }

.legend {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
}
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.swatch { display: inline-block; flex: none; }
.swatch-gz {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--marker);
}
.swatch-ow {
  width: 9px; height: 9px;
  background: var(--indigo);
  transform: rotate(45deg);
  margin: 0 1px;
}

/* ---------- Tools ---------- */

.tools {
  position: fixed;
  top: var(--gutter);
  right: var(--gutter);
  z-index: 1000;
  display: flex;
  gap: 6px;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
}
.tool:hover { background: var(--paper-raised); border-color: #AEB8A3; }
.tool[aria-expanded="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--wash); color: var(--ink); }

/* ---------- Basemap switcher ---------- */

.basemaps {
  position: fixed;
  right: calc(var(--gutter) + 46px);
  bottom: 28px;
  z-index: 900;
  margin: 0;
  padding: 0;
  border: 0;
}
.basemap-options {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 3px;
  gap: 2px;
}
.basemap-options label {
  position: relative;
  display: block;
}
.basemap-options input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.basemap-options span {
  display: block;
  padding: 4px 10px;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.basemap-options input:checked + span { background: var(--ink); color: var(--paper); }
.basemap-options input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.basemap-options label:hover span { color: var(--ink); }
.basemap-options input:checked:hover + span { color: var(--paper); }

/* ---------- LiDAR toggle (separate from the basemap choice) ---------- */

.lidar-toggle {
  position: fixed;
  right: calc(var(--gutter) + 46px);
  bottom: 70px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.lidar-toggle[hidden] { display: none; }
.lidar-toggle:hover { color: var(--ink); border-color: #AEB8A3; }
.lidar-check {
  width: 15px; height: 15px;
  border: 1.5px solid #6E3A82;
  border-radius: 2px;
  background: var(--paper-raised);
}
.lidar-toggle[aria-pressed="true"] { color: var(--lidar); border-color: #B79BC2; background: var(--lidar-wash); }
.lidar-toggle[aria-pressed="true"] .lidar-check {
  background: repeating-linear-gradient(45deg, var(--lidar) 0 2px, transparent 2px 5px);
}

/* ---------- Finder ---------- */

.finder {
  position: fixed;
  left: var(--gutter);
  top: var(--finder-top, 190px);
  bottom: var(--gutter);
  width: 360px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.finder[hidden] { display: none; }

.finder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 4px 16px;
}
.finder h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--rust);
}

.finder input[type="search"] {
  margin: 4px 16px 8px;
  padding: 8px 11px;
  border: 1px solid #B6BFAA;
  border-radius: 4px;
  background: var(--paper-raised);
  font-size: 16px;
}

.starts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 16px 8px;
}
.starts button {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 14px;
}
.starts button:hover { border-color: var(--ink-2); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 6px;
}
.filters label {
  display: grid;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-2);
}
.filters select {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid #B6BFAA;
  border-radius: 4px;
  background: var(--paper-raised);
  font-size: 14.5px;
  color: var(--ink);
}

.finder-count {
  margin: 2px 16px 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.place-list {
  list-style: none;
  margin: 0;
  padding: 0 6px 10px;
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid var(--rule);
}
.place-list li + li { border-top: 1px solid #E3E8DC; }
.place-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 2px 10px;
  align-items: start;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 3px;
}
.place-list button:hover { background: var(--wash); }
.place-list button[aria-current="true"] { background: var(--marker-wash); }
.place-list .li-name { font-family: var(--serif); font-size: 16.5px; font-weight: 500; line-height: 1.25; }
.place-list .li-sub {
  grid-column: 2;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.place-list .li-mark { grid-row: span 2; justify-self: center; margin-top: 1px; }

/* small markers used in lists and panel headings */
.mini-disc {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--marker);
  color: var(--marker-ink);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  position: relative;
}
.mini-disc.is-area { background: var(--paper-raised); box-shadow: inset 0 0 0 2.5px var(--marker); }
.mini-disc.is-natural { background: var(--marker-soft); }
.mini-diamond {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  margin: 3px;
  background: var(--indigo);
  transform: rotate(45deg);
  border-radius: 2px;
}
.mini-diamond > span {
  transform: rotate(-45deg);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 12px;
}
.mini-diamond.is-branch { background: #fff; box-shadow: inset 0 0 0 2.5px var(--indigo); }
.mini-diamond.is-branch > span { width: 6px; height: 6px; background: var(--indigo); }
.place-list .list-subhead {
  padding: 10px 10px 2px 50px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--indigo);
  border-top: 1px solid var(--rule);
}
.place-list .list-subhead[hidden] { display: none; }
.mini-route {
  display: inline-block;
  width: 26px;
  height: 0;
  margin-top: 12px;
  border-top: 2.5px dashed var(--indigo);
}
.star {
  position: absolute;
  top: -6px;
  right: -7px;
  width: 15px; height: 15px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-raised);
  color: var(--marker-ink);
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 0 0 1px var(--marker);
}

/* ---------- Detail panel ---------- */

.panel {
  position: fixed;
  top: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  width: var(--panel-w);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.panel[hidden] { display: none; }

.panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: var(--paper);
}
.sheet-grip { display: none; }

.panel-scroll {
  overflow-y: auto;
  padding: 0 0 24px;
  flex: 1;
  overscroll-behavior: contain;
}

.source-band {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 52px 9px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--rule);
}
.source-band.is-gz { background: var(--marker-wash); color: var(--marker-ink); }
.source-band.is-ow { background: var(--indigo-wash); color: var(--indigo); }
.source-band.is-lidar { background: var(--lidar-wash); color: var(--lidar); }
.swatch-lidar, .mini-lidar {
  display: inline-block;
  border: 1.5px dashed var(--lidar);
  background: repeating-linear-gradient(45deg, rgba(110,58,130,.45) 0 1.5px, transparent 1.5px 5px);
}
.swatch-lidar { width: 12px; height: 12px; }
.mini-lidar { width: 24px; height: 24px; margin: 1px; border-radius: 2px; }
.panel-head .mini-lidar { width: 32px; height: 32px; margin-top: 4px; }

.panel-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px 20px 6px;
}
.panel-head .mini-disc { width: 38px; height: 38px; font-size: 17px; margin-top: 3px; }
.panel-head .mini-diamond { width: 28px; height: 28px; margin: 7px 5px; }
.panel-head .mini-diamond > span { font-size: 14px; }
.panel-head .mini-diamond.is-branch { background: #fff; box-shadow: inset 0 0 0 2.5px var(--indigo); }
.mini-diamond.is-branch > span { width: 6px; height: 6px; background: var(--indigo); }
.place-list .list-subhead {
  padding: 10px 10px 2px 50px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--indigo);
  border-top: 1px solid var(--rule);
}
.place-list .list-subhead[hidden] { display: none; }
.mini-route { width: 34px; margin-top: 20px; }

.panel h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--ink);
}
.panel-kind {
  margin: 3px 0 0;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink-2);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 20px 2px;
  margin: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 13.5px;
}
.facts li {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 1px 10px;
  background: var(--paper-raised);
  color: var(--ink-2);
}
.facts .status-known { border-color: #8DA585; color: #33582C; background: #EAF2E6; }
.facts .status-proposed { border-color: #9AAAC8; color: var(--indigo); background: var(--indigo-wash); }
.facts .status-unknown { border-color: #C6B8A0; color: #6A5531; background: #F5EFE3; }

.panel section { padding: 14px 20px 0; }
.panel h3 {
  margin: 0 0 4px;
  font-size: 18.5px;
  font-weight: 500;
  font-style: italic;
  color: var(--rust);
}
.panel p { margin: 0 0 8px; max-width: 62ch; }

.panel section.voice {
  margin: 14px 14px 0;
  padding: 12px 14px 6px;
  border-left: 4px solid var(--marker);
  background: var(--marker-wash);
  border-radius: 0 4px 4px 0;
}
.panel section.voice.is-ow {
  border-left-color: var(--indigo);
  background: var(--indigo-wash);
}
.panel section.voice.is-ow h3 { color: var(--indigo); }
.panel section.voice.is-lidar {
  border-left-color: var(--lidar);
  background: var(--lidar-wash);
  font-size: 16px;
}

.entry-links { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 4px; }
.entry-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: none;
  padding: 2px 0;
  font-family: var(--serif);
  font-size: 16.5px;
  color: var(--sea);
  text-decoration: none;
  text-align: left;
}
.entry-link > span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.entry-link:hover { color: var(--ink); }

.gz-quote {
  margin: 0 0 8px;
  font-size: 17.5px;
  line-height: 1.5;
}
.gz-site { font-style: italic; }
.gz-site b { font-style: normal; font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--marker-ink); }
.norman-quote {
  margin: 10px 0 8px;
  padding: 8px 0 0;
  border-top: 1px solid #C9D3E4;
}
.norman-quote blockquote { margin: 0; font-style: italic; }
.norman-quote figcaption { font-family: var(--sans); font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }

.refs {
  margin: 4px 0 8px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-2);
}

.pointlist {
  list-style: none;
  margin: 2px 0 6px;
  padding: 0;
  font-family: var(--sans);
  font-size: 14.5px;
}
.pointlist li { padding: 3px 0; }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--sea);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-align: left;
}
.link-btn:hover { color: var(--ink); }
.pointlist .prec { color: var(--ink-2); }

.sources { margin: 0; padding-left: 18px; font-family: var(--sans); font-size: 14px; }
.sources li { margin: 2px 0; overflow-wrap: anywhere; }
a { color: var(--sea); text-underline-offset: 2px; }
a:hover { color: var(--ink); }

.quiet h3 {
  font-family: var(--sans);
  font-style: normal;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.quiet p { font-size: 15.5px; color: var(--ink-2); }
.related-notes ul { margin: 0; padding-left: 18px; font-family: var(--sans); font-size: 15px; }
.related-notes li { margin: 3px 0; }
.note-draft { color: var(--ink-2); font-size: 13.5px; }
a.tool { color: var(--ink); text-decoration: none; }

.photo { margin: 4px 0 6px; }
.photo img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  display: block;
  border-radius: 3px;
  background: var(--wash);
}
.photo figcaption { font-family: var(--sans); font-size: 13.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.35; }
.photo .credit { display: block; font-size: 12.5px; margin-top: 1px; }

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px 0;
}
.action {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 5px 12px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
}
.action:hover { border-color: var(--ink-2); }
.action.is-primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }

/* ---------- Dates block inside "What archaeology says": neutral, no colour coding ---------- */

.datefit {
  margin: 4px 0 4px;
  padding: 8px 12px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-raised);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.4;
}
.datefit h4 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; color: var(--ink-2); }
.datefit dl { margin: 0; }
.datefit dl > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; padding: 2px 0; }
.datefit dt { color: var(--ink-2); }
.datefit dd { margin: 0; color: var(--ink); }
.panel .datefit p { margin: 4px 0 2px; }
.datefit-label { font-weight: 700; color: var(--ink); }
.datefit-line { color: var(--ink); }
.panel p.datefit-foot { margin: 4px 0 8px; font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); }

/* ---------- Distance tool ---------- */

.measure-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 34px;
  border: 2px solid rgba(0,0,0,.2);
  border-radius: 4px;
  background: var(--paper);
  background-clip: padding-box;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.measure-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.measure-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
body.is-measuring #map { cursor: crosshair; }
body.is-measuring .stepper { display: none !important; }

.measure {
  position: fixed;
  top: 76px;
  right: var(--gutter);
  z-index: 1003;
  width: 360px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 10px 16px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
}
.measure[hidden] { display: none; }
.measure-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -6px 0 0; }
.measure h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--rust); }
.measure p { margin: 4px 0; }
.measure-help { color: var(--ink-2); font-size: 14px; }
.measure-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.measure label { display: grid; gap: 2px; font-size: 13.5px; color: var(--ink-2); }
.measure select, .measure input {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid #B6BFAA;
  border-radius: 4px;
  background: var(--paper-raised);
  font-size: 15px;
  color: var(--ink);
}
.measure-result { font-size: 15.5px; }
.measure-result b { font-size: 18px; }
.measure-days { margin-top: 6px; }
.measure-caveat { margin-top: 8px !important; padding-top: 8px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-2); }
.leaflet-tooltip.measure-tip {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  padding: 1px 8px;
  border: 1px solid var(--ink);
  background: var(--paper-raised);
  color: var(--ink);
}

/* ---------- Journey stepper ---------- */

.stepper {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: min(520px, calc(100vw - 2 * var(--gutter)));
  background: var(--indigo);
  color: #fff;
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.stepper[hidden] { display: none; }
.step-btn {
  width: 38px; height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  display: grid;
  place-items: center;
}
.step-btn:hover:not(:disabled) { background: rgba(255,255,255,.28); }
.step-btn:disabled { opacity: .35; cursor: default; }
.step-btn:focus-visible { outline-color: #fff; }
.step-status {
  min-width: 0;
  padding: 0 10px;
  text-align: center;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-status b { font-weight: 700; }
.step-status .step-start {
  border: 0;
  background: none;
  color: #fff;
  font-weight: 700;
  padding: 6px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Map markers ---------- */

.leaflet-container { font-family: var(--sans); }

.gz-marker, .ow-marker, .ow-alt, .route-label, .gz-dot { background: none; border: 0; }

.gz-badge {
  position: absolute;
  left: 0; top: 0;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--marker);
  color: var(--marker-ink);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.85), 0 1px 3px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.gz-badge.is-natural { background: var(--marker-soft); }
.gz-badge.is-group { box-shadow: 0 0 0 2px var(--marker), 0 0 0 3.5px rgba(255,255,255,.9), 0 1px 4px rgba(0,0,0,.35); }
.gz-badge.is-area {
  background: var(--paper-raised);
  box-shadow: inset 0 0 0 2.5px var(--marker), 0 1px 3px rgba(0,0,0,.3);
}
.gz-badge .star-in {
  font-size: 9px;
  margin: -7px -3px 0 0;
  line-height: 1;
}
.gz-badge:has(.star-in) { grid-auto-flow: column; gap: 0; }

.gz-area-name {
  position: absolute;
  left: 31px;
  top: 3px;
  white-space: nowrap;
  font-family: var(--caps);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .16em;
  color: #3B2A1E;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px rgba(255,255,255,.9);
  pointer-events: none;
}

.leaflet-marker-icon:focus, path.leaflet-interactive:focus { outline: none; }
.leaflet-marker-icon:focus-visible .gz-badge,
.leaflet-marker-icon:focus-visible .ow-diamond,
.leaflet-marker-icon:focus-visible .ow-alt-shape,
.leaflet-marker-icon:focus-visible .route-text {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.is-selected .gz-badge { transform: scale(1.28); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px #fff, 0 2px 6px rgba(0,0,0,.4); }
.is-selected .ow-diamond { transform: rotate(45deg) scale(1.25); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.is-dim { opacity: .22; }

.ow-diamond {
  position: absolute;
  left: 3px; top: 3px;
  width: 22px; height: 22px;
  background: var(--indigo);
  border-radius: 2px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1.5px #fff, 0 1px 4px rgba(0,0,0,.4);
  display: grid;
  place-items: center;
  transition: transform .15s ease;
}
.ow-diamond > span {
  transform: rotate(-45deg);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
}
.ow-name {
  position: absolute;
  left: 32px;
  top: 4px;
  white-space: nowrap;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 15px;
  color: var(--indigo);
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff;
  pointer-events: none;
}
.ow-diamond.is-branch {
  background: #fff;
  border: 3px solid var(--indigo);
}
.ow-core {
  width: 7px; height: 7px;
  background: var(--indigo);
  transform: none !important;
}
.is-far .ow-diamond.is-branch .ow-core { display: none; }
.ow-alt-shape {
  position: absolute;
  left: 3px; top: 3px;
  width: 12px; height: 12px;
  border: 2.5px solid var(--indigo);
  background: #fff;
  transform: rotate(45deg);
  border-radius: 1px;
}

.route-text {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  color: var(--indigo);
  background: rgba(252, 253, 249, .88);
  border: 1px solid #B9C5DC;
  border-radius: 999px;
  padding: 1px 10px;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.lidar-label { background: none; border: 0; }
.lidar-text {
  display: inline-block;
  transform: translate(-50%, -115%);
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--lidar);
  background: rgba(252, 253, 249, .9);
  border: 1px dashed var(--lidar);
  border-radius: 3px;
  padding: 0 6px;
  cursor: pointer;
}
.lidar-label.is-selected .lidar-text { background: var(--lidar); color: #fff; border-style: solid; }
.leaflet-marker-icon:focus-visible .lidar-text { outline: 3px solid var(--focus); outline-offset: 2px; }
.is-far .lidar-label { display: none; }
.is-low .ow-name { display: none; }

/* Quiet the terrain tiles toward the palette of his hand-tinted map */
#map[data-base="terrain"] .leaflet-tile-pane { filter: saturate(.62) contrast(.92) brightness(1.05); }

/* far zoom: numbered discs become dots so the overview stays readable */
.is-far .gz-badge { width: 10px; height: 10px; left: 8px; top: 8px; font-size: 0; }
.is-far .gz-badge .star-in { display: none; }
.is-far .gz-badge.is-area { box-shadow: inset 0 0 0 2px var(--marker); }
.is-far .gz-area-name, .is-far .ow-name { display: none; }
.is-far .ow-diamond { width: 13px; height: 13px; left: 7px; top: 7px; }
.is-far .ow-diamond > span { display: none; }
.is-far .ow-diamond.is-branch {
  background: #fff;
  border: 3px solid var(--indigo);
}
.ow-core {
  width: 7px; height: 7px;
  background: var(--indigo);
  transform: none !important;
}
.is-far .ow-diamond.is-branch .ow-core { display: none; }
.ow-alt-shape { width: 8px; height: 8px; border-width: 2px; left: 5px; top: 5px; }
.is-mid .gz-area-name, .in-group .gz-area-name, .in-group .ow-name { display: none; }

.leaflet-tooltip.place-tip {
  font-family: var(--serif);
  font-size: 15px;
  padding: 2px 8px;
  border-color: var(--rule);
  color: var(--ink);
}
.leaflet-tooltip.alt-tip {
  font-family: var(--sans);
  font-size: 13px;
  padding: 1px 6px;
  background: rgba(252,253,249,.92);
}

.leaflet-control-attribution {
  font-family: var(--sans);
  font-size: 11.5px;
  background: rgba(245, 247, 241, .85) !important;
}
.leaflet-control-zoom a { color: var(--ink) !important; }

/* ---------- Dialogs ---------- */

dialog {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(32, 36, 30, .55); }

.scan-dialog {
  width: min(1200px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
  max-width: none;
  max-height: none;
}
.scan-dialog[open] { display: flex; flex-direction: column; }
.scan-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding: 12px 12px 10px 18px;
  border-bottom: 1px solid var(--rule);
}
.scan-head h2 { margin: 0; font-family: var(--caps); font-weight: 700; letter-spacing: .05em; font-size: 20px; color: var(--rust); }
.scan-head p { margin: 2px 0 0; font-family: var(--sans); font-size: 14px; color: var(--ink-2); }
.scan-map { flex: 1; background: #EDEFE8; }

.about-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
}
.about-inner { position: relative; padding: 22px 28px 26px; }
.about-close { position: absolute; top: 10px; right: 10px; }
.about-dialog h2 {
  margin: 0 40px 4px 0;
  font-family: var(--caps);
  font-weight: 700;
  letter-spacing: .05em;
  font-size: 26px;
  color: var(--rust);
}
.about-dialog h3 {
  margin: 20px 0 4px;
  font-size: 19px;
  font-style: italic;
  font-weight: 500;
  color: var(--rust);
}
.about-dialog p { margin: 0 0 10px; max-width: 64ch; }
.about-dialog cite { font-style: italic; }
#about-tiles { font-family: var(--sans); font-size: 14.5px; color: var(--ink-2); }

.noscript { position: fixed; inset: auto 16px 16px; background: var(--paper); padding: 12px; z-index: 3000; }

/* ---------- Medium screens: stack tools under the masthead ---------- */


/* ---------- Phones and narrow windows ---------- */

@media (max-width: 760px) {
  :root { --gutter: 10px; }

  .masthead {
    left: var(--gutter);
    right: calc(var(--gutter) + 174px);
    max-width: none;
    padding: 9px 11px 8px;
  }
  .masthead h1 { font-size: 16.5px; letter-spacing: .03em; }
  .masthead-sub { display: none; }
  .legend { display: none; }
  .chapters {
    margin: 6px -11px -2px;
    padding: 0 11px 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
  }
  .chapters::-webkit-scrollbar { display: none; }
  .chapters button { font-size: 14px; padding: 3px 9px; }

  .tools { gap: 4px; }
  .tool { width: 39px; min-height: 40px; padding: 0; justify-content: center; }
  .tool-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .finder {
    left: 0; right: 0; bottom: 0;
    top: var(--finder-top, 100px);
    width: auto;
    border-radius: 12px 12px 0 0;
    border-bottom: 0;
  }

  .panel {
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: auto;
    height: 56vh;
    height: 56dvh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.22);
    transition: height .25s ease;
  }
  .panel.is-expanded { height: calc(100dvh - 70px); }
  .sheet-grip {
    display: grid;
    place-items: center;
    height: 22px;
    border: 0;
    background: transparent;
    flex: none;
  }
  .sheet-grip span { width: 44px; height: 5px; border-radius: 3px; background: #B3BBA8; }
  .panel-close { top: 14px; }
  .source-band { padding-left: 16px; padding-right: 52px; }
  .panel-head { padding: 12px 16px 4px; }
  .panel h2 { font-size: 23px; }
  .panel section { padding: 12px 16px 0; }
  .panel section.voice { margin: 12px 10px 0; }
  .facts { padding: 6px 16px 2px; }
  .panel-actions { padding: 12px 16px 0; }
  .photo img { height: 170px; }

  .basemaps { right: auto; left: var(--gutter); bottom: 40px; }
  .lidar-toggle { right: auto; left: var(--gutter); bottom: 82px; padding: 4px 10px 4px 8px; font-size: 13.5px; }
  body.has-panel .lidar-toggle { display: none; }
  .leaflet-control-attribution { font-size: 10.5px; }
  .basemap-options span { padding: 4px 8px; font-size: 13.5px; }
  .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 30px; }

  .stepper { bottom: 84px; }
  .measure {
    top: auto; left: 0; right: 0; bottom: 0;
    transform: none;
    width: auto;
    max-height: 60dvh;
    border-radius: 12px 12px 0 0;
    border-bottom: 0;
    padding: 8px 16px 14px;
  }
  body.is-measuring .basemaps, body.is-measuring .lidar-toggle { display: none; }
  .measure-btn span { display: none; }
  .measure-btn { padding: 0 7px; }
  body.has-panel .stepper { bottom: calc(56dvh + 10px); }
  body.has-panel .basemaps { display: none; }

  .scan-dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .about-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .about-inner { padding: 18px 18px 22px; }
}

@media (min-width: 761px) {
  body.has-panel .basemaps { right: calc(var(--panel-w) + var(--gutter) * 2 + 46px); }
  body.has-panel .lidar-toggle { right: calc(var(--panel-w) + var(--gutter) * 2 + 46px); }
  body.has-panel .leaflet-bottom.leaflet-right { right: calc(var(--panel-w) + var(--gutter)); }
  body.has-panel .stepper { left: calc((100vw - var(--panel-w) - var(--gutter)) / 2); }
  body.has-panel .tools { right: calc(var(--panel-w) + var(--gutter) * 2); }
}

@media (min-width: 761px) and (max-width: 1560px) {
  body.has-panel .tool { width: 42px; padding: 0; justify-content: center; }
  body.has-panel .tool-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (min-width: 761px) and (max-width: 1240px) {
  .tools { flex-direction: column; align-items: flex-end; }
  .measure { top: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
