:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171414;
  background: #e9e5dc;
  font-synthesis: none;
  --ink: #171414;
  --paper: #f5f2ea;
  --muted: #716a64;
  --rule: #cec7bc;
  --accent: #e44b2d;
  --amber: #ffb000;
  --plum: #7d3c64;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button,
a,
summary,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid #2185d0;
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  height: 100%;
  overflow: hidden;
}

.panel {
  position: relative;
  z-index: 3;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  box-shadow: 12px 0 30px rgb(28 22 20 / 9%);
}

.panel-header,
.control-section,
.results,
.methodology {
  padding: 24px 28px;
}

.panel-header {
  padding-top: 26px;
  padding-bottom: 25px;
  border-bottom: 1px solid var(--ink);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.wordmark-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 23px;
  padding-inline: 6px;
  color: #fff;
  background: var(--ink);
  letter-spacing: -0.04em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 340px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 4vw, 54px);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.045em;
}

.lede {
  max-width: 355px;
  margin-bottom: 0;
  color: #514b47;
  font-size: 14px;
  line-height: 1.55;
}

.data-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--ink);
}

.data-strip > div {
  min-width: 0;
  padding: 14px 12px 13px;
  border-right: 1px solid var(--rule);
}

.data-strip > div:first-child {
  padding-left: 28px;
}

.data-strip > div:last-child {
  border-right: 0;
}

.data-strip strong,
.data-strip span {
  display: block;
}

.data-strip strong {
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 21px;
  letter-spacing: -0.04em;
}

.data-strip span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.control-section,
.results {
  border-bottom: 1px solid var(--rule);
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.step-number {
  color: var(--accent);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
}

.point-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.point-button {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid #bdb5aa;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.point-button:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.point-button.selecting {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.point-letter {
  display: inline-flex;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-right: 9px;
  color: #fff;
  font-weight: 900;
  border-radius: 50%;
}

.point-a {
  background: var(--ink);
}

.point-b {
  color: var(--ink);
  background: var(--amber);
}

.point-button small,
.point-button b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point-button small {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.point-button b {
  max-width: 110px;
  font-size: 11px;
}

.route-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.text-button {
  padding: 3px 0;
  color: #554e49;
  font-size: 11px;
  font-weight: 700;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent);
}

.segment-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: #ded8ce;
}

.segment-control button {
  min-height: 38px;
  color: #625b55;
  font-size: 11px;
  font-weight: 750;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.segment-control button.active {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 1px 5px rgb(26 21 18 / 20%);
}

.range-row {
  display: grid;
  grid-template-columns: 122px 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
}

.range-row b {
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  height: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}

.results {
  min-height: 164px;
}

.empty-results,
.loading-results,
.error-results {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty-results p,
.loading-results p,
.error-results p {
  margin: 0;
}

.loading-results {
  gap: 10px;
}

.error-results {
  display: block;
  padding: 14px;
  color: #7d2820;
  background: #f4ddd5;
  text-align: left;
}

.error-results strong {
  display: block;
  margin-bottom: 5px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #cec6bb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink);
}

.result-hero strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 62px;
  font-weight: 500;
  line-height: 0.78;
  letter-spacing: -0.06em;
}

.result-hero span {
  max-width: 125px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--rule);
}

.metric-grid > div {
  padding: 13px 8px 12px 0;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.metric-grid > div:nth-child(even) {
  padding-left: 14px;
  border-right: 0;
}

.metric-grid > div:nth-child(n + 3) {
  border-bottom: 0;
}

.metric-grid b,
.metric-grid span {
  display: block;
}

.metric-grid b {
  font-size: 18px;
  line-height: 1;
}

.metric-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.trip-summary {
  display: flex;
  gap: 15px;
  padding-block: 10px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.trip-summary span:not(:last-child)::after {
  content: "·";
  margin-left: 15px;
  color: #aca49b;
}

.encounter-list {
  margin-top: 12px;
}

.encounter-list h3 {
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.encounter-row {
  display: grid;
  grid-template-columns: 25px 1fr 8px;
  width: 100%;
  align-items: center;
  gap: 9px;
  min-height: 43px;
  padding: 5px 0;
  color: var(--ink);
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}

.encounter-row:hover b {
  color: var(--accent);
}

.encounter-index {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.encounter-copy b,
.encounter-copy small {
  display: block;
}

.encounter-copy b {
  font-size: 11px;
}

.encounter-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.alignment {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.alignment.aligned {
  background: #36a168;
}

.alignment.uncertain {
  background: #b8b0a5;
}

.overflow-note,
.result-footnote {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.no-hits {
  display: grid;
  gap: 4px;
  padding: 15px;
  color: #4f4843;
  background: #e6e1d8;
}

.no-hits strong {
  font-size: 12px;
}

.no-hits span {
  font-size: 10px;
  line-height: 1.4;
}

.methodology {
  color: #4f4944;
  font-size: 11px;
  line-height: 1.55;
}

.methodology summary {
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.methodology div {
  padding-top: 14px;
}

.methodology p:last-child {
  margin-bottom: 0;
}

.methodology a {
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 2px;
}

.methodology code {
  font-size: 10px;
}

.map-wrap {
  position: relative;
  min-width: 0;
  background: #d4d0c8;
}

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

#map.setting-point,
#map.setting-point .leaflet-interactive {
  cursor: crosshair;
}

.map-title-card,
.map-instruction,
.map-legend {
  position: absolute;
  z-index: 600;
  color: var(--ink);
  background: rgb(250 247 240 / 94%);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 rgb(23 20 20 / 14%);
  backdrop-filter: blur(5px);
}

.map-title-card {
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #35a26c;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgb(53 162 108 / 18%);
}

.map-instruction {
  top: 18px;
  right: 18px;
  padding: 10px 12px;
  color: #fff;
  background: var(--ink);
  font-size: 10px;
  font-weight: 700;
}

.map-legend {
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 13px;
  padding: 9px 11px;
  font-size: 9px;
  font-weight: 700;
  box-shadow: none;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-camera,
.legend-hit {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-camera {
  background: #a84d82;
}

.legend-hit {
  background: var(--amber);
  border: 1px solid var(--ink);
}

.legend-route {
  display: block;
  width: 14px;
  height: 3px;
  background: var(--accent);
}

.point-marker {
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  background: var(--ink);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(0 0 0 / 28%);
}

.point-marker.end-marker {
  color: var(--ink);
  background: var(--amber);
}

.camera-popup {
  display: grid;
  gap: 4px;
  min-width: 190px;
  font-family: Inter, ui-sans-serif, sans-serif;
}

.camera-popup small {
  color: var(--accent);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.camera-popup strong {
  margin-bottom: 3px;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 500;
}

.camera-popup span {
  color: #5b554f;
  font-size: 10px;
}

.camera-popup a {
  margin-top: 4px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 750;
}

.leaflet-control-attribution {
  font-size: 8px !important;
}

.leaflet-control-zoom a {
  color: var(--ink) !important;
  background: var(--paper) !important;
  border-color: var(--ink) !important;
}

@media (max-width: 760px) {
  html,
  body,
  #app {
    height: auto;
    min-height: 100%;
  }

  .app-shell {
    display: flex;
    height: auto;
    min-height: 100vh;
    flex-direction: column;
    overflow: visible;
  }

  .panel {
    order: 2;
    overflow: visible;
    border-top: 1px solid var(--ink);
    border-right: 0;
  }

  .map-wrap {
    order: 1;
    height: 58vh;
    min-height: 420px;
  }

  .panel-header,
  .control-section,
  .results,
  .methodology {
    padding-right: 20px;
    padding-left: 20px;
  }

  .panel-header {
    padding-top: 22px;
  }

  h1 {
    max-width: 100%;
    font-size: 44px;
  }

  .data-strip > div:first-child {
    padding-left: 20px;
  }

  .map-instruction {
    top: auto;
    right: auto;
    bottom: 55px;
    left: 12px;
  }

  .map-title-card {
    top: 12px;
    left: 12px;
  }

  .map-legend {
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
