:root {
  --ink: #16211e;
  --mist: #eef1e7;
  --sand: #d8c7a5;
  --fern: #325847;
  --fern-deep: #223a31;
  --route-start: #2460dc;
  --route-end: #e62828;
  --route-button-start: #5e7ec2;
  --route-button-end: #bf6767;
  --line: rgba(22, 33, 30, 0.12);
  --font-sans: "Space Grotesk", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 199, 165, 0.55), transparent 28%),
    radial-gradient(circle at bottom right, rgba(50, 88, 71, 0.22), transparent 35%),
    linear-gradient(135deg, #f3efe6 0%, #e7ecdf 45%, #dde6d8 100%);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
}

.app-shell-spacer {
  flex: 1 1 18px;
  min-height: 18px;
}

.map-view {
  position: relative;
  width: 100%;
  min-height: 58vh;
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.45);
  transition: filter 180ms ease, opacity 180ms ease;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.controls-grid {
  display: grid;
  gap: 12px;
}

#area-field {
  width: 100%;
}

.control-field {
  min-width: 0;
}

.route-pair-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.route-direction-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  color: rgba(22, 33, 30, 0.64);
  font-size: 1.05rem;
  font-weight: 700;
}

.route-panel {
  display: grid;
  gap: 12px;
}

select,
button,
.download-link {
  font: inherit;
}

select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(22, 33, 30, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

.route-strip {
  display: grid;
  gap: 10px;
  transition: opacity 160ms ease, filter 160ms ease;
}

.scenario-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.scenario-title-meta,
.scenario-title-note {
  display: inline-block;
}

.scenario-title-note {
  margin-left: 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(22, 33, 30, 0.58);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  transition: opacity 160ms ease, filter 160ms ease;
}

.app-footer {
  margin-top: 0;
}

.note {
  margin: 0 2px;
  font-size: 0.76rem;
  line-height: 1.35;
  color: rgba(22, 33, 30, 0.56);
}

.note-line {
  display: block;
}

.route-strip.is-stale,
.button-row.is-stale,
.map-view.is-stale {
  opacity: 0.62;
  filter: grayscale(0.24);
}

.map-view.is-stale::after {
  content: attr(data-loading-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 14px 16px;
  background: linear-gradient(to bottom, rgba(238, 241, 231, 0.52), rgba(238, 241, 231, 0.12));
  color: rgba(22, 33, 30, 0.82);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  z-index: 700;
  pointer-events: all;
  backdrop-filter: blur(1px);
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:disabled,
select:disabled {
  cursor: default;
  opacity: 0.65;
}

button {
  border: none;
  background: linear-gradient(135deg, var(--route-button-start), var(--route-button-end));
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

#new-route-button {
  border: 1px solid rgba(22, 33, 30, 0.14);
  background: rgba(255, 255, 255, 0.78);
  color: var(--route-start);
  text-shadow: none;
}

#new-route-button .button-gradient-text {
  display: inline-block;
  background: linear-gradient(135deg, var(--route-start), var(--route-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.download-link {
  border: 1px solid rgba(22, 33, 30, 0.16);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 700;
}

.download-link.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.bike-rental-links {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(22, 33, 30, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
}

.bike-rental-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.bike-rental-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
}

.bike-rental-group p {
  min-width: 9.8rem;
  margin: 0;
  color: rgba(22, 33, 30, 0.62);
  font-size: 0.84rem;
  font-weight: 700;
}

.bike-rental-group a {
  color: var(--fern-deep);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
}

.error-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(148, 35, 35, 0.08);
  color: #8f1b1b;
}

.hidden {
  display: none;
}

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

@media (max-width: 980px) {
  .app-shell {
    padding: 16px 12px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .app-shell-spacer {
    flex-basis: 16px;
    min-height: 16px;
  }

  select {
    padding: 11px 13px;
    border-radius: 14px;
  }

  .route-strip {
    gap: 8px;
  }

  .scenario-title {
    font-size: 1rem;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.75rem;
  }

  .scenario-title-meta {
    min-width: 0;
  }

  .scenario-title-note {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 0.72rem;
    text-align: right;
  }

  .controls-grid {
    gap: 12px;
  }

  .route-pair-row {
    gap: 12px;
  }

  .route-panel {
    gap: 10px;
  }

  .app-footer {
    padding-top: 0;
  }

  .button-row {
    width: 100%;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .bike-rental-group {
    gap: 6px 10px;
  }

  .bike-rental-group p {
    flex-basis: 100%;
    min-width: 0;
  }

  .note {
    font-size: 0.72rem;
  }

  button,
  .download-link {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    white-space: nowrap;
  }

  .map-view {
    min-height: 44vh;
    border-radius: 20px;
  }
}
