:root {
  --nav-h: 68px;
  --panel-w: 380px;
}

.planner-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.planner {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
  min-height: 420px;
}

/* PANEL */
.planner-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--line);
}

.panel-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.01em;
}

.panel-intro {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.panel-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--ink-3);
}

.search {
  position: relative;
  margin-top: 16px;
}

.search input,
.route-name input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #cfe0d5;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  outline: none;
}

.search input:focus,
.route-name input:focus {
  border-color: var(--green);
  background: #fff;
}

.search-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 32, 26, .12);
}

.search-results button {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.search-results button:hover,
.search-results button:focus-visible {
  background: var(--bg);
  color: var(--green-deep);
}

.search-empty {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink-3);
}

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

.route-stats {
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.route-stats strong {
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* One cell per junction (chip + trailing arrow) so rows line up and never
   start with an arrow. */
.panel-route .chain {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: 14px 0;
  margin-top: 16px;
  min-height: 0;
}

.chain-item {
  display: flex;
  align-items: center;
}

.chain-item .arrow {
  width: 22px;
  text-align: center;
}

.knoop {
  position: relative;
  flex: none;
}

.knoop-num.wide {
  font-size: 12px;
  letter-spacing: -.4px;
}

.knoop[data-order]::after {
  content: attr(data-order);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-sizing: border-box;
}

.knoop.passed {
  box-shadow: none;
  background: #cfe0d5;
}

.knoop.passed .knoop-num {
  color: #6f8a78;
}

.knoop.passed[data-order]::after {
  background: #8a938c;
}

.panel-empty {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-3);
}

.route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.btn:disabled {
  opacity: .45;
  cursor: default;
}

.btn-secondary {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--green);
  color: var(--green-deep);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 5px rgba(16, 137, 63, .28);
}

.btn-primary:not(:disabled):hover {
  background: var(--green-deep);
}

.route-name {
  display: block;
  margin-bottom: 14px;
}

.route-name span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.panel-note {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}

.panel-credits {
  margin-top: auto;
  padding: 16px 24px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.panel-credits span {
  display: block;
}

/* MAP */
.planner-map {
  position: relative;
  min-height: 0;
  background: #e9ede8;
}

#map {
  position: absolute;
  inset: 0;
}

.map-toast {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 32, 26, .92);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

.map-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  background: rgba(245, 246, 243, .82);
  backdrop-filter: blur(3px);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #cfe0d5;
  border-top-color: var(--green);
  animation: spin .8s linear infinite;
}

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

.maplibregl-ctrl-attrib {
  font-family: 'Archivo', system-ui, sans-serif;
  font-size: 11px;
}

.maplibregl-ctrl-attrib a {
  color: var(--green-deep);
}

/* MOBILE: map on top, panel as a bottom sheet */
@media (max-width: 860px) {
  .planner {
    display: flex;
    flex-direction: column;
  }

  .planner-map {
    flex: 1;
  }

  .planner-panel {
    order: 2;
    flex: none;
    max-height: 46vh;
    max-height: 46dvh;
    border-right: none;
    border-top: 1px solid var(--line);
  }

  .panel-section {
    padding: 16px 20px;
  }

  .panel-title,
  .panel-intro {
    display: none;
  }

  .search {
    margin-top: 0;
  }

  .panel-credits {
    padding: 12px 20px;
  }

  .map-toast {
    bottom: 14px;
  }
}

.planner-page [hidden] {
  display: none !important;
}

/* SHARE DIALOG */
.btn-wide {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
}

.share-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: none;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(20, 32, 26, .25);
}

.share-dialog::backdrop {
  background: rgba(20, 32, 26, .45);
}

.share-body {
  position: relative;
  padding: 28px 28px 24px;
}

.share-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.share-close:hover {
  color: var(--ink);
}

.share-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.3px;
  padding-right: 36px;
}

.share-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.share-qr {
  width: min(260px, 100%);
  margin: 20px auto 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.share-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.share-too-long {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.share-link {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.share-link input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink-2);
}

.share-open {
  display: block;
  margin-top: 10px;
  text-align: center;
  color: #fff;
}

.share-open:hover {
  color: #fff;
}

.share-foot {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

@media (min-width: 861px) {
  .share-open {
    display: none;
  }
}

/* ROUTE PAGE (route.html: shared-link landing) */
.route-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.route-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px 60px;
}

.route-card {
  width: min(480px, 100%);
  padding: 28px;
  border: 1px solid var(--card-line);
  border-radius: 20px;
  background: #fff;
}

.route-card .panel-eyebrow {
  display: block;
}

.route-title {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.4px;
  line-height: 1.15;
}

.route-card .route-stats {
  margin-top: 6px;
  font-size: 14px;
}

.route-card .chain {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: 14px 0;
  margin-top: 18px;
}

.route-body {
  margin-top: 22px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.route-open {
  display: block;
  margin-top: 14px;
  text-align: center;
  color: #fff;
}

.route-open:hover {
  color: #fff;
}

.route-planner {
  display: block;
  text-align: center;
}

.route-qr-wrap {
  display: none;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.route-scan {
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
}

.route-qr-wrap .share-qr {
  width: min(220px, 100%);
  margin-top: 12px;
}

.route-stores-label {
  margin-top: 24px;
  font-size: 13px;
  color: var(--ink-2);
}

.route-card .stores {
  margin-top: 10px;
}

@media (min-width: 861px) {
  .route-qr-wrap {
    display: block;
  }
}
