:root {
  color-scheme: light;

  --bg: #e9dfec;
  --bg-glow: #eef0da;
  --card: #faf5f9;
  /* Form controls sit a shade below the card they're on, so a field reads as a
     place to type rather than as part of the panel. */
  --field-bg: #f3eff4;
  --panel-border: #ddcedc;
  --ink: #17141a;
  --ink-muted: #8a8092;
  /* Field labels sit darker than --ink-muted and placeholders lighter than it,
     so the two never read as the same grey inside a form. */
  --ink-label: #4a4250;
  --ink-placeholder: #a9a1b0;
  --label: #279e92;
  --accent: #9c4fae;
  --accent-ink: #fdf7fb;
  /* A more saturated take on --accent, for the flash bar: it reads as the same
     purple as the buttons without competing with them. Kept dark enough that
     the bar's white text clears 4.5:1 against it. */
  --accent-bright: #a944c0;
  --danger: #b43b3b;
  --danger-bg: #f6e3e1;
  --success: #279e92;
  --success-bg: #e2f1ee;
  --radius: 3px;
  /* One height for every single-line control (inputs, selects, toggle
     buttons), so a select and the buttons beside it line up. */
  --control-height: 2.3rem;

  --font-sans:
    system-ui,
    -apple-system,
    sans-serif;
  --font-mono:
    ui-monospace,
    SFMono-Regular,
    "JetBrains Mono",
    Menlo,
    monospace;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
}

/* The green wash at the bottom of the page sits on its own fixed layer rather
   than on <body>, so it is anchored to the viewport and stays the same regardless
   of how long the page is. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 30%, var(--bg-glow));
}

.page {
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 0 1rem 3rem;
}

h1 {
  margin: 0 0 0.3rem;
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.tagline {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin: 0.4rem 0 1.25rem;
}

/* The index leads with the create card, not with its own name, so the h1 is a
   label above it rather than the page's largest text. */
.page-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
}

.create-card {
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
}

.create-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.create-card-text {
  max-width: 30rem;
  margin: 0 0 1.4rem;
  color: var(--ink-muted);
}

.create-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.create-card-note {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.library-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.library-header .tagline {
  margin-bottom: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--label);
  text-decoration: none;
}

.back-link:hover {
  opacity: 0.75;
}

.show-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.show-header .back-link {
  margin-bottom: 0;
}

.button-danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.walk-card-delete-form {
  margin: 0;
}

.walk-card-wrapper .walk-card-delete {
  display: block;
  width: 100%;
  background: var(--card);
  color: var(--danger);
  border: none;
  border-top: 1px solid var(--panel-border);
  border-radius: 0;
}

.walk-card-wrapper .walk-card-delete:hover {
  background: var(--danger-bg);
}

.show-header-delete {
  margin: 0;
}
.flash {
  margin: 0;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.flash.notice {
  background: var(--accent-bright);
  color: var(--accent-ink);
  font-weight: 600;
}

.flash.alert {
  background: var(--danger-bg);
  color: var(--danger);
}

form label {
  display: block;
  margin: 0.6rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-label);
}

/* .search-input is in the list because the index's filter box lives outside a
   <form>; it must not re-state these values or it drifts out of sync. */
form input,
form select,
form textarea,
.search-input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  box-sizing: border-box;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

form input,
form select,
.search-input {
  height: var(--control-height);
}

form textarea {
  resize: vertical;
}

/* The block display above would otherwise beat the UA stylesheet and lay the
   hidden duration/publish fields out as empty boxes. */
form input[type="hidden"] {
  display: none;
}

form input::placeholder,
form textarea::placeholder,
.search-input::placeholder {
  color: var(--ink-placeholder);
  opacity: 1;
}

form input:focus,
form select:focus,
form textarea:focus,
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}
form {
  margin: 1.5rem 0;
}

button,
.button,
input[type="submit"] {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 0.1s ease,
    opacity 0.15s ease;
}

button:hover,
.button:hover,
input[type="submit"]:hover {
  opacity: 0.85;
}

button:active,
.button:active,
input[type="submit"]:active {
  transform: scale(0.98);
}

button:disabled,
input[type="submit"]:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.button-generate {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.button-generate::after {
  content: " \2192";
}

.button-generate:disabled::after {
  content: "";
}

.generate-row {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}

.generate-row .button-generate {
  flex: 1;
}

.button-stop {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 3rem;
  padding: 0;
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* The display above is specific enough to beat the UA stylesheet's [hidden]. */
.button-stop[hidden] {
  display: none;
}

.stop-icon {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  background: currentColor;
}

.button-publish {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  background: var(--label);
  border-color: var(--label);
  color: var(--accent-ink);
}

.button-generate:disabled,
.button-publish:disabled {
  /* The generic button:disabled opacity (0.5) washes these out to a pale
     tint closer to the flash/notice colors than to the button's own accent —
     fade them less so a generating/publishing button still reads as itself. */
  opacity: 0.8;
}

.spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.5em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner[hidden] {
  display: none;
}

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

.link-button {
  border: none !important;
  background: none !important;
  color: var(--ink-muted) !important;
  text-decoration: underline;
  text-transform: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font-family: var(--font-sans) !important;
  font-size: 0.85rem !important;
  font-weight: 400 !important;
}

.test-result {
  font-size: 0.85rem;
  margin-top: 0.6rem;
}

.test-result.success {
  color: var(--success);
}

.test-result.error {
  color: var(--danger);
}

/* Two shapes of failure, told apart at a glance: a quiet line under the field
   it names, and a bordered banner for everything with no field behind it. */
.field-error {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
}

/* The same mark in both: a pseudo-element under a field, where there is no
   element to hang it on, and a real span in the banner. */
.field-error::before,
.error-banner-mark {
  flex: 0 0 auto;
  width: 1.3em;
  height: 1.3em;
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1.2em;
  text-align: center;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.field-error::before {
  content: "!";
}

.error-banner {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

/* Both are empty until the generator controller fills them, and the flex
   displays above would otherwise beat the UA stylesheet's [hidden]. */
.field-error[hidden],
.error-banner[hidden] {
  display: none;
}

/* The field keeps the tint until it holds something, so it stays findable
   after scrolling away from the message under it. */
form input.is-invalid,
form textarea.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

form input.is-invalid:focus,
form textarea.is-invalid:focus {
  border-color: var(--danger);
}

/* A folded step says nothing about what is inside it, so the border carries
   the error up to the summary the walker can actually see. */
.step-row:has(.is-invalid) {
  border-color: var(--danger);
}

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

.library-title + .empty {
  margin-top: 0.6rem;
}

/* Library (index) */

.search-field {
  display: block;
  /* Shrinks before the heading it shares the row with, and drops to a full-width
     field of its own once there isn't room for both. */
  flex: 0 1 18rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Everything else comes from the shared field rules near the top. */
.search-input {
  max-width: 24rem;
  margin-top: 0;
  font-size: 0.9rem;
  /* The stroke repeats --ink-placeholder's value because a custom property
     can't be referenced from inside a data URI; keep the two in step. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a9a1b0' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='6.8' cy='6.8' r='4.3'/%3E%3Cpath d='M10.1 10.1l3.4 3.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.6rem center;
  background-size: 0.95rem;
  padding-left: 2.1rem;
}

.search-empty {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

.walk-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  /* auto-fill, not auto-fit: the search filter hides cards with [hidden], and
     auto-fit would collapse the now-empty tracks and blow the last remaining
     card up to the full row width. align-items keeps a card's height its own
     rather than its row's, so it doesn't change as neighbours are filtered out. */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
  gap: 1rem;
}

.walk-card-wrapper {
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.walk-grid li:nth-child(7n+1) .walk-card-wrapper { transform: rotate(-1.4deg); }
.walk-grid li:nth-child(7n+2) .walk-card-wrapper { transform: rotate(0.9deg); }
.walk-grid li:nth-child(7n+3) .walk-card-wrapper { transform: rotate(-0.6deg); }
.walk-grid li:nth-child(7n+4) .walk-card-wrapper { transform: rotate(1.6deg); }
.walk-grid li:nth-child(7n+5) .walk-card-wrapper { transform: rotate(-1.9deg); }
.walk-grid li:nth-child(7n+6) .walk-card-wrapper { transform: rotate(0.5deg); }
.walk-grid li:nth-child(7n+7) .walk-card-wrapper { transform: rotate(-0.9deg); }

.walk-card-wrapper:hover {
  border-color: var(--accent);
  transform: rotate(0deg) scale(1.02);
}

.walk-card {
  display: block;
  text-decoration: none;
}

.walk-card-image {
  position: relative;
  height: 130px;
  background: var(--panel-border);
  border-bottom: 1px solid var(--ink);
}

.walk-card-map {
  position: absolute;
  inset: 0;
  /* Leaflet's own panes are positioned with explicit z-index, which would
     otherwise sit above the badge despite it being later in paint order. */
  z-index: 0;
}

.walk-card-badge {
  z-index: 1;
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  padding: 0.15rem 0.5rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--ink);
  color: var(--card);
  border-radius: var(--radius);
}

.walk-card-body {
  padding: 1rem;
}

.walk-card-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.walk-card-meta {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--label);
}

.walk-card-time {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Generator steps (new tour page) */

.progress-bar {
  display: flex;
  gap: 0.4rem;
  margin: 0.25rem 0 1.5rem;
}

.progress-step {
  flex: 1;
  height: 4px;
  border-radius: var(--radius);
  background: var(--panel-border);
}

.progress-step.done {
  background: var(--ink);
}

.step-row {
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
}

.step-row summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
}

.step-row summary::-webkit-details-marker {
  display: none;
}

.step-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--label);
  white-space: nowrap;
}

/* The collapsed state of a step is a pill on the right of its summary: grey
   while the step has nothing in it, green once it does. */
.step-badge {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  padding: 0.15rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink-muted);
  background: var(--bg);
  border-radius: 999px;
}

.step-badge--set {
  color: var(--success);
  background: var(--success-bg);
}

.step-badge--error {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Only the AI step's badge reports a connection, so only it gets the dot. */
.step-badge-ai.step-badge--set::before {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-right: 0.4em;
  vertical-align: 0.1em;
  border-radius: 50%;
  background: currentColor;
}

.step-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--panel-border);
}

.step-row[open] .step-body {
  padding-top: 1rem;
}

.label-optional {
  font-weight: 400;
  color: var(--ink-muted);
}

/* A labelled control inside a step, where the label is a mono caption rather
   than the bold sans one plain fields use. */
.field {
  display: block;
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
}

.field-label {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--label);
}

/* Duration sits among plain bold-sans labels, so its caption matches them. */
.field-label-plain {
  font-family: var(--font-sans);
  text-transform: none;
  font-size: 0.9rem;
  letter-spacing: normal;
  color: var(--ink-label);
}

/* Both start right under the mono caption, so a select and a toggle group in
   the same row share a top edge. */
.field input,
.field select,
.field .toggle-group {
  margin-top: 0;
}

/* Model and Effort read as one row of settings; they stack when there isn't
   room for two columns. */
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 560px) {
  .field-pair {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.step-ai .hint {
  margin-top: 0.9rem;
}

/* Suggested interests: they fill the field above, so they're quieter than the
   uppercase mono buttons elsewhere. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

/* Outlined, but quieter than the duration buttons below them: muted text on no
   fill, so they read as suggestions under the field rather than a second set of
   controls. */
.chip {
  padding: 0.12rem 0.4rem;
  font-family: var(--font-sans);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--panel-border);
}

.chip:hover {
  color: var(--accent);
  background: var(--card);
  border-color: var(--accent);
  opacity: 1;
}

/* Secondary disclosure inside a step (further instructions, the key's safety
   note) — a text link, not another card. */
.sub-details {
  margin-top: 1rem;
}

.sub-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.sub-details > summary::-webkit-details-marker {
  display: none;
}

.sub-details > summary::before {
  content: "\25B8";
  font-size: 0.75em;
}

.sub-details[open] > summary::before {
  content: "\25BE";
}

.sub-details-quiet > summary {
  color: var(--ink-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.sub-details .hint {
  margin-top: 0.4rem;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.toggle-button {
  /* Equal widths, but min-width:0 lets them shrink below their label rather
     than overflowing the panel; the shortest viewport wraps them instead. */
  flex: 1 1 5.5rem;
  min-width: 0;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  height: var(--control-height);
  padding: 0.25rem;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--ink-label);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.toggle-button.active {
  border-color: var(--accent);
  background: var(--card);
  color: var(--accent);
}

/* type="text" + masked glyphs, not type="password" — the field needs to look
   like a password field without the browser treating it as one: the "save
   password?" prompt is keyed off input[type=password] and fires on *any*
   real form submission on the page (here, publishing the tour), not just
   the field's own form. */
.api-key-input {
  -webkit-text-security: disc;
  text-security: disc;
}

/* One field-looking box holding the input plus its stored-key affordances, so
   the check and Forget sit inside the border rather than under it. */
.api-key-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--control-height);
  padding: 0 0.6rem;
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.api-key-field:focus-within {
  border-color: var(--accent);
}

.api-key-field.is-set {
  background: var(--success-bg);
  border-color: var(--success);
}

.api-key-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding-left: 0;
  padding-right: 0;
  background: transparent;
  border: none;
}

.api-key-field input:focus {
  outline: none;
}

.api-key-check {
  color: var(--success);
  font-weight: 700;
}

.api-key-forget {
  flex: none;
  padding: 0;
  font-family: var(--font-sans);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: none;
  border: none;
  text-decoration: underline;
}

/* Both only mean anything once a key is stored. */
.api-key-field:not(.is-set) .api-key-check,
.api-key-field:not(.is-set) .api-key-forget {
  display: none;
}

.step-ai .button {
  margin-top: 0.9rem;
}

.map {
  margin-top: 1.5rem;
  height: 360px;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.scroll-to-map {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  /* Above Leaflet's own panes and controls (which top out at 1000). */
  z-index: 1100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* The generic button rule sets display:inline-block, which would otherwise
   beat the UA stylesheet's [hidden] and keep the button on screen. */
.scroll-to-map[hidden] {
  display: none;
}

/* Tints the raw OSM tiles toward the page's muted purple/pink palette instead
   of leaving them in their default saturated colors, which otherwise clash
   with everything else on the page. Markers/popups live outside this pane
   (see map_controller.js), so they're unaffected. */
.leaflet-tile-pane {
  filter: saturate(80%);
}

/* Matches the zoom buttons it stacks under (see .leaflet-bar in leaflet.css). */
.map-reset-view {
  font-size: 18px;
  font-weight: 700;
}

.map-marker span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.stop-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stop-list .stop {
  display: flex;
  gap: 0.75rem;
  /* Breathing room when stop_list_controller.js scrolls a marker's stop to the
     top of the viewport. */
  scroll-margin-top: 1rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  /* Slow on the way out so the highlight recedes rather than snapping off; the
     .stop--highlighted rule speeds the entry back up. */
  transition:
    border-color 0.6s ease,
    box-shadow 0.6s ease,
    background 0.6s ease,
    transform 0.6s ease;
}

.stop-list .stop:nth-child(5n+1) { transform: rotate(-0.5deg); }
.stop-list .stop:nth-child(5n+2) { transform: rotate(0.35deg); }
.stop-list .stop:nth-child(5n+3) { transform: rotate(-0.25deg); }
.stop-list .stop:nth-child(5n+4) { transform: rotate(0.55deg); }
.stop-list .stop:nth-child(5n+5) { transform: rotate(-0.4deg); }

.stop-list .stop.stop--highlighted,
.stop-preview.stop--highlighted {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px var(--accent),
    0 6px 18px rgba(156, 79, 174, 0.35);
  background: #f3e6f4;
  transform: rotate(0deg) scale(1.02);
  transition-duration: 0.15s;
}

.stop-index {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

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

.stop-title {
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
}

.stop-description {
  margin: 0;
  color: var(--ink-muted);
}

/* On a phone the index circle and its gap cost real width next to the title and
   squeeze the description into a narrow column — stack it above instead. */
@media (max-width: 480px) {
  .stop-list .stop {
    flex-direction: column;
    gap: 0.5rem;
  }

  .stop-list .stop .stop-index {
    align-self: center;
  }
}

.stop-preview-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.stop-preview {
  padding: 1rem;
  margin-bottom: 0.8rem;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  /* Same as .stop-list .stop: breathing room when stop_list_controller.js
     scrolls a marker's card to the top, and a highlight that recedes slowly. */
  scroll-margin-top: 1rem;
  transition:
    border-color 0.6s ease,
    box-shadow 0.6s ease,
    background 0.6s ease,
    transform 0.6s ease;
}

.stop-preview h3 {
  font-size: 1rem;
  margin: 0 0 0.3rem;
}

.stop-preview p {
  margin: 0 0 0.4rem;
  color: var(--ink-muted);
}

.stop-preview-pending {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  border-style: dashed;
}

.stop-preview-pending .spinner {
  /* The spinner leads the label here, unlike inside a button. */
  margin-left: 0;
}

.refine-row {
  padding: 1rem;
  background: var(--card);
  border: 1px dashed var(--ink);
  border-radius: var(--radius);
}

.refine-row label {
  margin-top: 0;
}

.refine-row .button {
  margin-top: 0.9rem;
}

.stop-preview-coords {
  font-size: 0.78rem;
  color: var(--ink-muted);
}
