:root {
  color-scheme: light;
  --ink: #101820;
  --muted: #52606d;
  --paper: #f8f7f2;
  --line: #d9ded7;
  --mint: #9be3c5;
  --teal: #006d77;
  --coral: #ef6f6c;
  --gold: #f4c95d;
  --violet: #5941a9;
  --night: #18212b;
  --topbar-h: 70px;
  --bottomnav-h: 0px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  height: 100svh;
  padding-bottom: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgb(16 24 32 / 4%), transparent 240px),
    var(--paper);
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100svh;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 14px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgb(16 24 32 / 10%);
  background: rgb(248 247 242 / 90%);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--night);
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.topnav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}

.topnav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.topnav a:hover {
  background: #edf5f0;
  color: var(--ink);
}

.topnav a.active,
.bottomnav a.active {
  background: var(--night);
  color: white;
}

.app-page:not(.active) {
  display: none !important;
}

.bottomnav {
  display: none;
}

main {
  height: calc(100svh - var(--topbar-h) - var(--bottomnav-h));
  overflow: hidden;
}

.app-page.active {
  overflow: hidden;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: clamp(28px, 5vw, 72px);
  height: min(350px, 34svh);
  align-items: center;
  padding: clamp(36px, 7vw, 84px) clamp(18px, 4vw, 52px) 30px;
}

.hero-copy {
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.7rem, 8vw, 6.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
}

.hero-copy p:last-child {
  max-width: 54ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
}

.route-map {
  position: relative;
  height: 100%;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid rgb(16 24 32 / 12%);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(155 227 197 / 72%), rgb(244 201 93 / 48%)),
    #e8ece9;
  box-shadow: 0 28px 80px rgb(16 24 32 / 16%);
}

.real-map {
  background: #dfe8e3;
  isolation: isolate;
}

.map-status {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border: 1px solid rgb(16 24 32 / 12%);
  border-radius: 8px;
  background: rgb(255 255 255 / 88%);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 10px 28px rgb(16 24 32 / 14%);
  backdrop-filter: blur(14px);
}

.icon-action {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #c8d2ce;
  border-radius: 8px;
  background: white;
  color: var(--teal);
  font-weight: 900;
}

.real-map p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.leaflet-container {
  z-index: 1;
  width: 100%;
  height: 100%;
  font: inherit;
}

.leaflet-popup-content {
  margin: 10px 12px;
  min-width: 180px;
}

.map-popup strong,
.map-popup span {
  display: block;
}

.map-popup strong {
  margin-bottom: 4px;
}

.map-popup span {
  color: #52606d;
  font-size: 0.82rem;
  line-height: 1.4;
}

.map-popup a {
  display: inline-flex;
  margin-top: 8px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.map-grid {
  position: absolute;
  inset: -40px;
  background:
    linear-gradient(90deg, rgb(16 24 32 / 10%) 1px, transparent 1px),
    linear-gradient(0deg, rgb(16 24 32 / 10%) 1px, transparent 1px),
    linear-gradient(35deg, transparent 47%, rgb(0 109 119 / 28%) 48% 52%, transparent 53%);
  background-size: 54px 54px, 54px 54px, 180px 180px;
  transform: rotate(-7deg) scale(1.1);
}

.route-map svg {
  position: absolute;
  inset: 8% 5%;
  width: 90%;
  height: 84%;
  fill: none;
  stroke: var(--night);
  stroke-linecap: round;
  stroke-width: 8;
  filter: drop-shadow(0 8px 0 rgb(255 255 255 / 70%));
}

.pin {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 3px solid white;
  border-radius: 999px;
  background: var(--coral);
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 28px rgb(16 24 32 / 24%);
}

.pin-a {
  left: 16%;
  top: 63%;
}

.pin-b {
  left: 46%;
  top: 43%;
  background: var(--teal);
}

.pin-c {
  right: 19%;
  top: 53%;
  background: var(--violet);
}

.pin-d {
  right: 13%;
  top: 20%;
  background: var(--gold);
  color: var(--ink);
}

.planner-band,
.room-band,
.crawl-band {
  padding: clamp(28px, 6vw, 72px) clamp(18px, 4vw, 52px);
}

.planner-band {
  height: calc(100svh - var(--topbar-h) - var(--bottomnav-h) - min(350px, 34svh));
  overflow: hidden;
  background: white;
  border-block: 1px solid var(--line);
}

.planner-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
  max-width: 1220px;
  margin: 0 auto;
}

.planner-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.planner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.source-pill,
.route-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf5f0;
  color: #31433d;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.source-pill {
  background: #fff4d6;
  color: #5a4507;
}

.route-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 2px;
}

.controls {
  align-self: start;
  display: grid;
  gap: 18px;
  max-height: 100%;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
}

.search-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: min(720px, calc(100svh - 28px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: white;
  box-shadow: 0 28px 80px rgb(16 24 32 / 28%);
}

.search-dialog::backdrop {
  background: rgb(16 24 32 / 44%);
  backdrop-filter: blur(5px);
}

.dialog-frame {
  display: grid;
  gap: 14px;
  max-height: min(720px, calc(100svh - 28px));
  margin: 0;
  padding: 16px;
  overflow: auto;
}

.dialog-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  font-size: 1.4rem;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

label span,
legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #cbd5d2;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid #cbd5d2;
  border-radius: 8px;
  background: white;
}

.segmented button,
.status-row button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  background: var(--night);
  color: white;
}

.primary-action,
.ghost-action {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-action {
  border: 0;
  background: var(--coral);
  color: white;
}

.ghost-action {
  border: 1px solid #bcc8c3;
  background: white;
  color: var(--ink);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  max-width: 1220px;
  margin: 0 auto 18px;
}

.section-head > span,
#routeMeta {
  color: var(--muted);
  font-weight: 800;
}

#venues {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.venue-list {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.venue,
.crawl-stop,
.room-panel,
.timeline {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.venue {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.venue:hover,
.venue:focus-visible {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgb(0 109 119 / 12%);
  transform: translateY(-1px);
}

.venue-order,
.stop-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: var(--mint);
  color: var(--ink);
  font-weight: 900;
}

.venue-detail {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.5;
}

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

.tags span,
.venue-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3f0;
  color: #42504c;
  font-size: 0.78rem;
  font-weight: 800;
}

.venue-stats {
  display: grid;
  gap: 6px;
  justify-items: end;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 140px;
  place-items: center;
  gap: 6px;
  border: 1px dashed #b9c5c0;
  border-radius: 8px;
  background: #f7faf8;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
}

.room-band {
  height: calc(100svh - var(--topbar-h) - var(--bottomnav-h));
  overflow: hidden;
  background: #eef5f1;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 18px;
  height: calc(100% - 82px);
  min-height: 0;
  max-width: 1220px;
  margin: 0 auto;
}

.room-panel,
.timeline {
  padding: 18px;
}

.room-code {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--night);
  color: var(--mint);
  font-weight: 900;
}

.room-panel p {
  margin: 14px 0;
  color: var(--muted);
  line-height: 1.6;
}

.avatars {
  display: flex;
  gap: 8px;
}

.avatars span,
.avatars button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 900;
}

.avatars span:nth-child(2) {
  background: var(--coral);
  color: white;
}

.avatars span:nth-child(3) {
  background: var(--violet);
  color: white;
}

.timeline {
  min-height: 150px;
  overflow: auto;
}

.timeline-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #edf0ed;
  color: var(--muted);
  line-height: 1.5;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item strong {
  color: var(--ink);
}

.crawl-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  height: calc(100% - 82px);
  min-height: 0;
  max-width: 1220px;
  margin: 0 auto;
  overflow-x: auto;
  padding-bottom: 6px;
}

.crawl-stop {
  min-width: 220px;
  overflow: auto;
  padding: 14px;
}

.crawl-band {
  height: calc(100svh - var(--topbar-h) - var(--bottomnav-h));
  overflow: hidden;
}

.crawl-stop-head {
  display: flex;
  gap: 10px;
  align-items: start;
  min-height: 84px;
}

.crawl-stop-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.status-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 12px 0;
}

.status-row button {
  border: 1px solid #d7dfdc;
  background: #f7faf8;
}

.status-row button.done {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.photo-drop {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px dashed #aab7b2;
  border-radius: 8px;
  background: #fbfcfb;
}

.photo-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.photo-drop span {
  color: var(--muted);
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.photo-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

@media (max-width: 920px) {
  .hero,
  .planner-panel,
  .room-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    height: 28svh;
  }

  .route-map {
    min-height: 180px;
  }

  .planner-band {
    height: calc(100svh - var(--topbar-h) - var(--bottomnav-h) - 28svh);
  }

  .crawl-board {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .crawl-stop {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  :root {
    --topbar-h: 62px;
    --bottomnav-h: calc(80px + env(safe-area-inset-bottom));
  }

  body {
    padding-bottom: 0;
  }

  .topbar {
    align-items: center;
    min-height: 62px;
    padding: 10px 14px;
  }

  .topnav {
    display: none;
  }

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

  .brand small {
    display: none;
  }

  .bottomnav {
    position: fixed;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 6px;
    border: 1px solid rgb(16 24 32 / 14%);
    border-radius: 18px;
    background: rgb(255 255 255 / 92%);
    box-shadow: 0 16px 44px rgb(16 24 32 / 18%);
    backdrop-filter: blur(16px);
  }

  .bottomnav a {
    display: grid;
    min-height: 54px;
    place-items: center;
    gap: 2px;
    border-radius: 13px;
    color: var(--muted);
    text-decoration: none;
  }

  .bottomnav span {
    font-weight: 900;
    line-height: 1;
  }

  .bottomnav small {
    font-size: 0.72rem;
    line-height: 1;
  }

  h1 {
    font-size: 1.52rem;
    line-height: 1.04;
    margin-bottom: 0;
  }

  h2 {
    font-size: 1.45rem;
  }

  .hero {
    display: block;
    height: 34svh;
    min-height: 220px;
    max-height: 300px;
    padding: 10px 14px;
  }

  .hero-copy {
    display: none;
  }

  .hero-copy p:last-child {
    display: none;
  }

  .route-map {
    min-height: 0;
    height: 100%;
    box-shadow: 0 16px 36px rgb(16 24 32 / 14%);
  }

  .pin {
    width: 34px;
    height: 34px;
    border-width: 2px;
    font-size: 0.82rem;
  }

  .planner-band,
  .room-band,
  .crawl-band {
    padding: 14px;
  }

  .planner-band {
    height: calc(100svh - var(--topbar-h) - var(--bottomnav-h) - clamp(220px, 34svh, 300px));
  }

  .planner-panel,
  .room-grid {
    gap: 12px;
  }

  .planner-panel {
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .controls {
    gap: 8px;
    padding: 10px;
    overflow: visible;
  }

  select {
    min-height: 40px;
  }

  .primary-action,
  .planner-actions .ghost-action {
    width: 100%;
    min-height: 42px;
  }

  .venue,
  .crawl-stop,
  .room-panel,
  .timeline {
    border-radius: 8px;
  }

  .planner-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .planner-actions {
    align-items: center;
    justify-content: space-between;
  }

  .planner-actions .ghost-action {
    width: auto;
    min-width: 112px;
  }

  .source-pill {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .route-summary {
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }

  .map-status {
    right: 8px;
    bottom: 8px;
    left: 8px;
  }

  .search-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100svh - 20px);
  }

  .dialog-frame {
    padding: 12px;
  }

  .venue {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .venue-stats {
    grid-column: 2;
    grid-auto-flow: column;
    justify-content: start;
    justify-items: start;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .status-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-row button {
    min-height: 44px;
    padding: 0 6px;
    font-size: 0.78rem;
  }
}
