:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.972 0.004 145);
  --surface-strong: oklch(0.936 0.007 145);
  --ink: oklch(0.17 0.025 238);
  --muted: oklch(0.45 0.02 238);
  --navy: oklch(0.24 0.045 238);
  --navy-strong: oklch(0.18 0.05 238);
  --primary: oklch(0.48 0.105 140);
  --primary-soft: oklch(0.9 0.045 140);
  --oak: oklch(0.58 0.11 72);
  --oak-soft: oklch(0.91 0.055 78);
  --warning: oklch(0.62 0.13 70);
  --danger: oklch(0.52 0.15 28);
  --line: oklch(0.86 0.008 238);
  --map-water: oklch(0.84 0.045 220);
  --map-land: oklch(0.88 0.032 122);
  --map-ridge: oklch(0.68 0.055 125);
  --shadow-tight: 0 6px 8px oklch(0.17 0.025 238 / 0.12);
  --z-sticky: 20;
  --z-overlay: 40;
  --z-tooltip: 50;
  --app-bar-height: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--app-bar-height);
  padding: 12px clamp(16px, 3vw, 32px);
  background: var(--navy-strong);
  color: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--oak);
  color: var(--bg);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: oklch(0.85 0.018 238);
  font-size: .76rem;
}

.mode-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.mode-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: .75rem;
  font-weight: 750;
  white-space: nowrap;
}

.mode-pill-delayed,
.status-badge-delayed {
  background: var(--oak-soft);
  color: oklch(0.28 0.08 72);
}

.mode-pill-live,
.status-badge-live {
  background: var(--primary);
  color: var(--bg);
}

.mode-pill-stale,
.status-badge-stale {
  background: oklch(0.9 0.045 28);
  color: oklch(0.32 0.11 28);
}

.ghost-button {
  min-height: 38px;
  border: 1px solid oklch(0.72 0.024 238);
  border-radius: 999px;
  padding: 0 14px;
  background: transparent;
  color: var(--bg);
  font-weight: 720;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: oklch(1 0 0 / .1);
}

.tracker {
  display: grid;
  height: calc(100dvh - var(--app-bar-height));
  min-height: 0;
}

.trail-panel {
  display: none;
}

.map-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.map-toolbar {
  position: absolute;
  z-index: var(--z-sticky);
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(540px, 100%);
  min-height: 42px;
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--navy);
  color: var(--bg);
  box-shadow: var(--shadow-tight);
  font-weight: 680;
  pointer-events: auto;
}

.strip-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--oak);
}

.app-shell[data-mode="live"] .strip-dot {
  background: var(--primary);
}

.app-shell[data-mode="stale"] .strip-dot {
  background: var(--danger);
}

.demo-links {
  display: none;
}

.demo-links button {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 11px;
  background: var(--bg);
  color: var(--navy);
  font-size: .75rem;
  font-weight: 740;
  box-shadow: var(--shadow-tight);
}

.map-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.terrain-map {
  width: 100%;
  height: 100%;
  display: block;
}

.contour {
  fill: none;
  stroke: oklch(0.54 0.045 130 / .42);
  stroke-width: 2;
  filter: url(#soften);
}

.ridge {
  fill: none;
  stroke: oklch(0.42 0.055 135 / .4);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 2 26;
}

.planned-route {
  fill: none;
  stroke: var(--navy);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 16 15;
  opacity: .52;
}

.completed-route {
  fill: none;
  stroke: var(--oak);
  stroke-width: 9;
  stroke-linecap: round;
}

.app-shell[data-mode="live"] .completed-route {
  stroke: var(--primary);
}

.app-shell[data-mode="stale"] .completed-route {
  stroke: oklch(0.46 0.04 238);
}

.waypoints circle {
  fill: var(--bg);
  stroke: var(--navy);
  stroke-width: 4;
}

.location-marker {
  position: absolute;
  left: 39.6%;
  top: 42.6%;
  width: 66px;
  height: 66px;
  transform: translate(-50%, -50%);
}

.marker-pulse,
.marker-pin {
  position: absolute;
  inset: 0;
  margin: auto;
  border-radius: 999px;
}

.marker-pulse {
  width: 62px;
  height: 62px;
  background: var(--oak);
  opacity: .22;
}

.marker-pin {
  width: 24px;
  height: 24px;
  border: 4px solid var(--bg);
  background: var(--oak);
  box-shadow: var(--shadow-tight);
}

.app-shell[data-mode="live"] .marker-pulse {
  background: var(--primary);
  animation: markerPulse 1.9s ease-out infinite;
}

.app-shell[data-mode="live"] .marker-pin {
  background: var(--primary);
}

.app-shell[data-mode="stale"] .marker-pulse {
  background: oklch(0.52 0.025 238);
  opacity: .14;
}

.app-shell[data-mode="stale"] .marker-pin {
  background: oklch(0.48 0.018 238);
}

.map-readout {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 166px;
  display: grid;
  gap: 4px;
  max-width: 360px;
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-tight);
}

.readout-label,
.stat-label,
.feed-time,
.status-kicker {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.map-readout strong {
  font-size: 1.02rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  font-size: .78rem;
}

.mobile-sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: var(--z-sticky);
  border-radius: 16px;
  padding: 10px 14px 14px;
  background: var(--bg);
  box-shadow: var(--shadow-tight);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .88rem;
}

.compact-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.compact-stats span {
  display: grid;
  gap: 3px;
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: .76rem;
}

.compact-stats strong {
  color: var(--ink);
  font-size: 1rem;
}

.password-gate {
  position: absolute;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
  place-items: center;
  padding: 20px;
  background: oklch(0.17 0.025 238 / .34);
}

.app-shell[data-mode="gate"] .password-gate {
  display: grid;
}

.app-shell[data-mode="gate"] .terrain-map,
.app-shell[data-mode="gate"] .location-marker,
.app-shell[data-mode="gate"] .map-readout {
  filter: blur(2px) saturate(.75);
}

.gate-panel {
  width: min(360px, 100%);
  border-radius: 16px;
  padding: 22px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-tight);
}

.lock-icon {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--primary);
  color: var(--bg);
  font-size: .78rem;
  font-weight: 760;
}

.gate-panel h2 {
  margin: 14px 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.025em;
  line-height: 1.12;
  text-wrap: balance;
}

.gate-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.gate-panel label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: var(--ink);
  font-weight: 720;
}

.gate-panel input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink);
}

.gate-panel input::placeholder {
  color: oklch(0.38 0.018 238);
}

.gate-panel input:focus-visible,
.gate-panel button:focus-visible,
.demo-links button:focus-visible,
.ghost-button:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}

.gate-panel button {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--bg);
  font-weight: 800;
}

.gate-note {
  margin-top: 12px !important;
  font-size: .8rem;
}

.password-gate.is-wrong .gate-panel {
  animation: gateWrong .22s ease-out;
}

.panel-section,
.stats-grid {
  border-bottom: 1px solid var(--line);
  padding: 20px;
}

.identity-section {
  display: flex;
  gap: 14px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--navy);
  color: var(--bg);
  font-weight: 850;
  font-size: 1.3rem;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 1.5rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

p {
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}

.status-card {
  display: grid;
  gap: 10px;
  background: var(--surface);
}

.status-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-line {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 780;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.status-detail {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--line);
}

.stat {
  display: grid;
  gap: 4px;
  padding: 16px;
  background: var(--bg);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 820;
  letter-spacing: -0.03em;
}

.feed {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feed li {
  display: grid;
  gap: 3px;
}

.feed strong {
  color: var(--ink);
  font-size: .95rem;
}

.feed span:last-child {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}

.watermark {
  padding: 18px 20px 22px;
  color: var(--muted);
  font-size: .82rem;
}

@keyframes markerPulse {
  0% {
    transform: scale(.72);
    opacity: .35;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes gateWrong {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-7px);
  }
  70% {
    transform: translateX(7px);
  }
}

@media (min-width: 820px) {
  .tracker {
    grid-template-columns: minmax(340px, 390px) minmax(0, 1fr);
  }

  .trail-panel {
    display: block;
    height: 100%;
    overflow: auto;
    background: var(--bg);
    border-right: 1px solid var(--line);
  }

  .mobile-sheet {
    display: none;
  }

  .map-readout {
    left: 22px;
    right: auto;
    bottom: 24px;
  }

  .map-toolbar {
    top: 20px;
    left: 20px;
    right: 20px;
  }
}

@media (max-width: 560px) {
  :root {
    --app-bar-height: 66px;
  }

  .app-bar {
    padding: 10px 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .brand-subtitle {
    display: none;
  }

  .mode-pill {
    display: none;
  }

  .ghost-button {
    min-height: 36px;
    padding: 0 12px;
  }

  .status-strip {
    width: 100%;
    font-size: .9rem;
  }

  .map-toolbar {
    left: 12px;
    right: 12px;
  }
}

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