:root {
  --background: #f8f9fa;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-solid: #ffffff;
  --surface-muted: #edf0f3;
  --surface-strong: #dfe6ec;
  --text: #191c1d;
  --text-muted: #4c5662;
  --line: #c7d0db;
  --primary: #005da7;
  --primary-strong: #004883;
  --focus: #ffda4b;
  --danger: #a63a2c;
  --success: #1d6a57;
  --shadow: 0 18px 48px rgba(25, 28, 29, 0.14);
  --header-height: 76px;
  --panel-width: min(400px, calc(100vw - 48px));
  --collection-panel-width: min(720px, calc(50vw - 36px));
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  border: 0;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.app-header {
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(248, 249, 250, 0.94);
  border-bottom: 1px solid rgba(199, 208, 219, 0.7);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  height: var(--header-height);
  inset: 0 0 auto;
  padding: 0 36px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.file-mode-warning {
  background: #fff1c8;
  border-bottom: 1px solid #e7c435;
  color: #554500;
  font-weight: 700;
  line-height: 1.45;
  padding: 14px 24px;
  position: relative;
  z-index: 30;
}

.brand {
  color: var(--primary);
  font-size: clamp(1rem, 1.45vw, 1.34rem);
  font-weight: 700;
  line-height: 1.12;
  max-width: 470px;
  text-decoration: none;
}

.site-nav {
  align-items: center;
  display: flex;
  gap: 34px;
  justify-content: center;
}

.site-nav a {
  border-bottom: 3px solid transparent;
  color: #39424d;
  font-weight: 600;
  padding: 12px 0 10px;
  text-decoration: none;
}

.site-nav a.active,
.site-nav a:hover {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.language-toggle {
  align-items: center;
  color: #39424d;
  display: flex;
  font-weight: 600;
  gap: 6px;
  justify-self: end;
}

.language-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: inherit;
  padding: 8px 4px;
}

.language-button.active {
  color: var(--primary);
}

.map-page {
  min-height: calc(100dvh - var(--header-height));
  overflow: hidden;
  position: relative;
}

.map-canvas {
  inset: 0;
  min-height: calc(100dvh - var(--header-height));
  position: absolute;
}

.map-canvas::after {
  background:
    linear-gradient(90deg, rgba(236, 241, 245, 0.28), rgba(236, 241, 245, 0.02)),
    linear-gradient(180deg, rgba(248, 249, 250, 0.02), rgba(25, 28, 29, 0.04));
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.mapboxgl-canvas {
  filter: saturate(1.08) contrast(1.01);
}

.mapboxgl-ctrl-bottom-left,
.mapboxgl-ctrl-bottom-right {
  z-index: 2;
}

.map-panel {
  background: var(--surface);
  border: 1px solid rgba(199, 208, 219, 0.72);
  border-radius: 8px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 3;
}

.workflow-panel,
.public-panel {
  margin: 24px 0 24px 36px;
  max-height: calc(100dvh - var(--header-height) - 48px);
  overflow-y: auto;
  padding: 34px 34px 28px;
  width: var(--panel-width);
}

.collection-page .workflow-panel {
  min-width: 0;
  width: var(--panel-width);
}

.panel-kicker {
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1.08;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.3rem;
  line-height: 1.25;
}

h3 {
  font-size: 1.05rem;
  line-height: 1.35;
}

.panel-copy,
.markdown-content,
.contact-lines {
  color: var(--text-muted);
  line-height: 1.6;
}

.stacked-form,
.journey-builder,
.city-form {
  display: grid;
  gap: 20px;
}

.stacked-form {
  margin-top: 32px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.timeline-header h2,
.timeline-header h3 {
  color: #39424d;
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin: 0;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.city-search input {
  background: rgba(247, 249, 251, 0.95);
  border: 1px solid transparent;
  border-bottom-color: #aab8c8;
  border-radius: 8px 8px 0 0;
  color: var(--text);
  min-height: 54px;
  padding: 14px 0;
  width: 100%;
}

.field input,
.field select,
.city-search input {
  padding-inline: 0;
}

.field textarea {
  border: 1px solid #d5dde7;
  border-radius: 8px;
  min-height: 108px;
  padding: 14px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.city-search input:focus {
  border-bottom-color: var(--primary);
  outline-offset: 0;
}

.primary-button,
.secondary-button,
.city-search button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 54px;
  padding: 12px 18px;
  text-decoration: none;
  width: 100%;
}

.primary-button,
.city-search button {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
}

.primary-button:hover,
.city-search button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  background: var(--surface-solid);
  border: 1px solid #8290a0;
  color: #27313d;
}

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

.section-rule {
  border-top: 1px solid rgba(199, 208, 219, 0.68);
  margin-top: 8px;
}

.city-search {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

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

.selected-city-summary {
  background: rgba(212, 227, 255, 0.72);
  border-radius: 8px;
  color: var(--primary-strong);
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 0;
  padding: 10px 12px;
}

.next-city-button {
  justify-self: stretch;
}

#memories {
  min-height: 162px;
}

.city-search button {
  min-width: 150px;
  width: auto;
}

.city-search-action {
  white-space: nowrap;
}

.search-results {
  display: grid;
  gap: 8px;
}

.result-button,
.trajectory-button {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d5dde7;
  border-radius: 8px;
  color: var(--text);
  padding: 14px;
  text-align: left;
  width: 100%;
}

.result-button:hover,
.trajectory-button:hover,
.trajectory-button.selected {
  border-color: var(--primary);
}

.trajectory-button.selected {
  background: rgba(212, 227, 255, 0.72);
  box-shadow: inset 4px 0 0 var(--danger);
}

.result-button strong,
.trajectory-button strong {
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
}

.result-button span,
.trajectory-button span {
  color: var(--text-muted);
  display: block;
  line-height: 1.45;
}

.city-form {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d5dde7;
  border-radius: 8px;
  padding: 20px;
}

.city-form-heading,
.timeline-header,
.journey-item {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.city-form-heading h3 {
  font-size: 1.28rem;
  margin: 0;
}

.icon-button {
  background: transparent;
  border: 1px solid #d5dde7;
  border-radius: 8px;
  color: #39424d;
  height: 36px;
  line-height: 1;
  width: 36px;
}

.number-field {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(80px, 1fr) auto;
}

.number-field span {
  color: var(--text-muted);
}

.timeline-section {
  display: grid;
  gap: 12px;
}

.count-pill {
  align-items: center;
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 700;
  justify-content: center;
  min-height: 28px;
  min-width: 28px;
  padding: 4px 10px;
}

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

.journey-item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d5dde7;
  border-radius: 8px;
  padding: 14px;
}

.journey-copy {
  min-width: 0;
}

.journey-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.journey-item strong {
  display: block;
}

.journey-copy span {
  color: var(--text-muted);
  display: block;
  font-size: 0.92rem;
  margin-top: 4px;
}

.duration-field .number-field {
  grid-template-columns: minmax(96px, 128px) auto;
  justify-content: start;
  width: max-content;
  max-width: 100%;
}

.sequence-dot {
  align-items: center;
  background: var(--surface-solid);
  border: 4px solid var(--primary);
  border-radius: 999px;
  color: var(--primary);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  line-height: 1;
  margin: 0;
  width: 30px;
}

.journey-marker,
.public-marker {
  align-items: center;
  background: transparent;
  color: #fff;
  display: grid;
  font-size: 0.76rem;
  font-weight: 900;
  height: 42px;
  justify-items: center;
  line-height: 1;
  position: absolute;
  width: 34px;
}

.journey-marker::before,
.public-marker::before {
  background: var(--primary);
  border: 3px solid var(--surface-solid);
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 10px 18px rgba(25, 28, 29, 0.22);
  content: "";
  height: 28px;
  inset: 1px auto auto 3px;
  position: absolute;
  transform: rotate(-45deg);
  width: 28px;
}

.journey-marker span,
.public-marker span {
  align-items: center;
  display: flex;
  height: 26px;
  justify-content: center;
  margin-top: 2px;
  position: relative;
  width: 26px;
  z-index: 1;
}

.mini-button {
  background: var(--surface-solid);
  border: 1px solid #d5dde7;
  border-radius: 6px;
  color: #27313d;
  font-size: 0.86rem;
  font-weight: 700;
  min-height: 32px;
  padding: 6px 10px;
}

.public-marker {
  color: #554500;
  height: 35px;
  width: 34px;
}

.public-marker::before {
  background: #e7c435;
  border-width: 2px;
  height: 24px;
  inset-inline-start: 3px;
  width: 24px;
}

.journey-marker.pending::before {
  border-style: dashed;
}

.action-row,
.modal-actions {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.departure-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.departure-heading > label:first-child {
  flex: 1 1 170px;
}

.field .current-city-toggle {
  align-items: center;
  background: rgba(212, 227, 255, 0.46);
  border: 1px solid rgba(0, 93, 167, 0.22);
  border-radius: 8px;
  color: #27313d;
  display: flex;
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 700;
  gap: 7px;
  letter-spacing: 0;
  min-height: 0;
  padding: 7px 10px;
  text-transform: none;
}

.current-city-toggle input {
  accent-color: var(--primary);
  height: 16px;
  margin: 0;
  min-height: 0;
  width: 16px;
}

.current-city-label {
  color: var(--success);
  font-weight: 800;
}

.status-message,
.inline-status,
.empty-state {
  border-radius: 8px;
  color: var(--text-muted);
  line-height: 1.5;
}

.demo-banner {
  background: rgba(255, 225, 117, 0.28);
  border: 1px solid rgba(231, 196, 53, 0.82);
  border-radius: 8px;
  color: #554500;
  font-weight: 700;
  line-height: 1.5;
  margin: 14px 0;
  padding: 12px 14px;
}

.demo-action {
  margin-top: -4px;
}

.status-message:not(:empty) {
  background: rgba(237, 240, 243, 0.94);
  border-left: 4px solid var(--primary);
  margin: 16px 0;
  padding: 12px 14px;
}

.status-message.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.status-message.success {
  border-left-color: var(--success);
  color: var(--success);
}

.inline-status {
  font-size: 0.92rem;
  margin: 0;
}

.empty-state {
  background: rgba(237, 240, 243, 0.86);
  padding: 16px;
}

.trajectory-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.public-filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 20px 0 24px;
}

.compact-field input,
.compact-field select {
  min-height: 46px;
}

.trajectory-button small {
  color: var(--text-muted);
  display: block;
  line-height: 1.45;
}

.mapboxgl-popup-content {
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  max-width: min(340px, calc(100vw - 48px));
  padding: 18px;
}

.public-popup {
  color: var(--text-muted);
  line-height: 1.5;
}

.public-popup h3 {
  color: var(--text);
  margin-bottom: 12px;
}

.popup-meta {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.public-popup dl {
  margin: 0;
}

.public-popup dt {
  color: #39424d;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-top: 10px;
  text-transform: uppercase;
}

.public-popup dd {
  margin: 4px 0 0;
}

.research-modal {
  background: var(--surface-solid);
  border: 1px solid rgba(199, 208, 219, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  max-width: min(760px, calc(100vw - 32px));
  padding: 0;
  width: 100%;
}

.research-modal::backdrop {
  backdrop-filter: blur(10px);
  background: rgba(25, 28, 29, 0.42);
}

.compact-modal {
  max-width: 560px;
}

.city-narrative-modal {
  max-width: min(760px, calc(100vw - 32px));
}

.city-narrative-modal .city-form {
  background: transparent;
  border: 0;
  gap: 0;
  padding: 0;
}

.city-narrative-modal .city-form-heading {
  border-bottom: 1px solid #d5dde7;
  padding: 24px 28px 18px;
}

.city-narrative-modal .city-form-heading h2 {
  margin-bottom: 0;
}

.modal-form-scroll {
  display: grid;
  gap: 20px;
  max-height: min(58dvh, 560px);
  overflow-y: auto;
  padding: 24px 28px;
}

.city-modal-actions {
  grid-template-columns: 1fr;
  padding-inline: 28px;
}

.city-form-status {
  margin: 0 28px 16px;
}

.modal-header {
  align-items: start;
  border-bottom: 1px solid #d5dde7;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 28px 34px 18px;
}

.modal-header h2 {
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  margin-bottom: 0;
}

.consent-logo {
  display: block;
  height: auto;
  margin-bottom: 18px;
  max-width: min(280px, 100%);
}

.modal-scroll {
  max-height: min(58dvh, 640px);
  overflow-y: auto;
}

.markdown-content {
  padding: 24px 34px;
}

.markdown-content h2,
.markdown-content h3 {
  color: var(--text);
  margin-top: 24px;
}

.markdown-content h2:first-child,
.markdown-content h3:first-child {
  margin-top: 0;
}

.markdown-content p:last-child,
.markdown-content ul:last-child {
  margin-bottom: 0;
}

.markdown-content ul {
  display: grid;
  gap: 8px;
  padding-left: 20px;
}

.research-modal .status-message {
  margin-inline: 34px;
}

.modal-actions {
  border-top: 1px solid #d5dde7;
  padding: 18px 34px 28px;
}

.placeholder-copy {
  color: var(--text-muted);
  line-height: 1.6;
}

.research-modal .placeholder-copy {
  padding: 24px 34px;
}

.support-prompt {
  background: var(--surface-solid);
  border: 1px solid rgba(199, 208, 219, 0.9);
  border-radius: 8px;
  bottom: 24px;
  box-shadow: var(--shadow);
  max-height: calc(100dvh - var(--header-height) - 48px);
  max-width: min(430px, calc(100vw - 32px));
  overflow-y: auto;
  padding: 22px 58px 22px 24px;
  position: fixed;
  right: 24px;
  width: 100%;
  z-index: 18;
}

.support-prompt[hidden] {
  display: none;
}

.support-prompt h2 {
  margin-bottom: 12px;
}

.support-intro {
  color: var(--text-strong);
  font-weight: 700;
  margin-bottom: 10px;
}

.support-resources {
  color: var(--text-muted);
  display: grid;
  gap: 10px;
  line-height: 1.45;
  list-style: none;
  margin: 0;
  padding: 0;
}

.support-resources li {
  display: grid;
  gap: 2px;
}

.support-resources strong {
  color: var(--text-strong);
  font-size: 0.94rem;
}

.support-resources a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.support-prompt .placeholder-copy {
  margin-bottom: 0;
}

.support-close {
  position: absolute;
  right: 16px;
  top: 16px;
}

.withdraw-warning-copy {
  margin-bottom: 0;
}

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

.danger-fill-button:hover {
  background: #842d22;
}

.public-panel h1 {
  margin-bottom: 18px;
}

.about-page {
  margin: 0 auto;
  max-width: 980px;
  padding: clamp(42px, 7vw, 88px) 24px 88px;
}

.about-hero h1 {
  max-width: 760px;
}

.researcher-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 22px;
  grid-template-columns: 1.5fr 1fr 1fr;
  margin: 34px 0 56px;
  padding: 24px;
}

.researcher-strip h2 {
  color: #39424d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.researcher-strip p {
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.researcher-strip a,
.contact-lines a {
  color: var(--primary);
}

.about-content {
  display: grid;
  gap: 42px;
  max-width: 760px;
}

.about-content article {
  border-top: 1px solid rgba(199, 208, 219, 0.78);
  padding-top: 24px;
}

.about-content .markdown-content {
  padding: 0;
}

.about-content p {
  color: var(--text-muted);
  line-height: 1.65;
}

.research-team-profile {
  align-items: start;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
}

.research-team-profile h3 {
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.research-team-profile p:last-child {
  margin-bottom: 0;
}

.research-team-photo {
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(199, 208, 219, 0.78);
  border-radius: 8px;
  display: block;
  object-fit: cover;
  object-position: center 22%;
  width: 100%;
}

.app-footer {
  background: var(--surface-solid);
  border-top: 1px solid rgba(199, 208, 219, 0.78);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.3;
  padding: 6px 20px;
  text-align: center;
}

.app-footer a {
  color: var(--primary);
  font-weight: 700;
}

.contact-lines p {
  margin-bottom: 8px;
}

@media (max-width: 760px) {
  :root {
    --header-height: auto;
  }

  .app-header {
    gap: 10px 16px;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 86px;
    padding: 16px;
  }

  .site-nav {
    gap: 20px;
    justify-content: flex-start;
    order: 3;
    overflow-x: auto;
  }

  .language-toggle {
    justify-self: start;
    order: 2;
  }

  .map-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 112px);
    overflow: visible;
  }

  .map-canvas {
    min-height: 42dvh;
    position: relative;
  }

  .workflow-panel,
  .public-panel {
    border-radius: 8px 8px 0 0;
    box-shadow: none;
    margin: -10px 0 0;
    max-height: none;
    overflow: visible;
    padding: 28px 20px 36px;
    width: 100%;
  }

  .collection-page .workflow-panel {
    min-width: 0;
    width: 100%;
  }

  .city-search,
  .action-row,
  .modal-actions,
  .public-filters {
    grid-template-columns: 1fr;
  }

  .city-search button {
    width: 100%;
  }

  .research-modal {
    max-height: calc(100dvh - 24px);
    max-width: calc(100vw - 16px);
  }

  .modal-header,
  .markdown-content,
  .modal-actions,
  .research-modal .placeholder-copy {
    padding-inline: 20px;
  }

  .research-modal .status-message {
    margin-inline: 20px;
  }

  .city-narrative-modal .city-form-heading,
  .modal-form-scroll,
  .city-modal-actions {
    padding-inline: 20px;
  }

  .about-page {
    padding-inline: 16px;
  }

  .researcher-strip {
    grid-template-columns: 1fr;
  }

  .research-team-profile {
    grid-template-columns: 1fr;
  }

  .research-team-photo {
    max-width: 190px;
  }

  .support-prompt {
    bottom: 16px;
    max-height: calc(100dvh - 32px);
    right: 16px;
  }

  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-language-toggle {
    justify-self: start;
  }
}
