:root {
  --sky: #b8e0e8;
  --ocean: #3d91ad;
  --land: #82bb6f;
  --land-light: #a1cd82;
  --paper: #fff7dc;
  --ink: #263d46;
  --ink-soft: #58717a;
  --coral: #eb7453;
  --white: #fffef8;
  --line: rgba(38, 61, 70, .17);
  --display: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --utility: "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  min-width: 320px;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background: var(--sky);
  overflow: hidden;
}

button, input, select { font: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  width: min(100%, 1380px);
  height: 64px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
  padding: 10px 32px 6px;
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.brand-mark svg {
  width: 23px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.brand strong { font: 700 16px/1 var(--display); }

.network-state {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink-soft);
  font: 700 9px/1 var(--utility);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.network-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3c9c5b;
  box-shadow: 0 0 0 3px rgba(60,156,91,.15);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 24px;
  width: min(100%, 1380px);
  height: calc(100dvh - 64px);
  margin: 0 auto;
  padding: 8px 32px 24px;
}

.world-panel {
  position: relative;
  min-height: 0;
  overflow: visible;
}

.intro {
  position: relative;
  z-index: 2;
  padding-top: clamp(18px, 4vh, 42px);
}

.eyebrow {
  margin: 0 0 9px;
  color: #2e7089;
  font: 700 9px/1 var(--utility);
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font: 800 clamp(48px, 5vw, 72px)/.9 var(--display);
  letter-spacing: -.055em;
}

.intro-copy {
  width: min(275px, 30vw);
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.globe-wrap {
  position: absolute;
  inset: 40px -80px -60px 65px;
  min-width: 640px;
}

.globe {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.earth { fill: url(#ocean-shade); }
.earth-light { fill: url(#earth-light); pointer-events: none; }
.earth-outline { fill: none; stroke: rgba(29,64,77,.72); stroke-width: 4; }
.globe-shadow { fill: rgba(39,77,89,.16); }
.grid-lines { fill: none; stroke: rgba(255,255,255,.2); stroke-width: 1.3; }
.land-mass { fill: var(--land); stroke: rgba(42,91,65,.28); stroke-width: 2; stroke-linejoin: round; }
.land-mass path:nth-child(2n) { fill: var(--land-light); }

.journey-line {
  fill: none;
  stroke: var(--paper);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 12 10;
  opacity: 0;
}

.journey-line.is-ready { opacity: .74; }
.journey-line.is-travelling { animation: route-march .8s linear infinite; }
.package-track { fill: none; stroke: transparent; pointer-events: none; }
.package-marker { opacity: 0; pointer-events: none; transition: opacity .16s ease; }
.package-marker.is-visible { opacity: 1; }
.package-halo { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.package-body { fill: var(--coral); stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.package-fold { fill: none; stroke: var(--paper); stroke-width: 1.5; stroke-linejoin: round; }
.package-marker.is-delivered .package-halo { fill: #f4d575; }

.map-marker { transition: opacity .16s ease; }
.map-marker .marker-ring { fill: var(--paper); stroke: var(--ink); stroke-width: 3; }
.map-marker .marker-core { fill: var(--coral); }
.map-marker text { fill: var(--ink); font: 700 9px/1 var(--utility); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; }
.map-marker.is-muted { opacity: .22; }
.map-marker.is-stamped .marker-core { fill: #e8b74a; }
.map-marker.is-skipped .marker-core { fill: #849399; }
.map-marker.is-departure .marker-ring { stroke: var(--coral); stroke-width: 5; }

.dispatch {
  position: relative;
  z-index: 3;
  display: flex;
  width: 100%;
  height: min(calc(100% - 30px), 610px);
  align-self: center;
  flex-direction: column;
  padding: 25px;
  border: 1px solid rgba(38,61,70,.22);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(44,91,105,.14);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font: 800 28px/1 var(--display);
  letter-spacing: -.03em;
}

.panel-header span {
  color: var(--ink-soft);
  font: 700 8px/1 var(--utility);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.route-help {
  margin: 11px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.35;
}

.departure-setting {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.departure-setting > span {
  color: var(--ink-soft);
  font: 700 8px/1 var(--utility);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.departure-setting select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255,255,255,.4);
  font-size: 10px;
}

.route-builder {
  min-height: 0;
  flex: 1 1 auto;
  padding: 15px 0;
}

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

.route-loading {
  padding: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

.route-stop {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  gap: 8px;
  min-height: 50px;
  align-items: center;
  padding: 8px 9px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.36);
}

.route-stop.is-excluded {
  color: var(--ink-soft);
  background: transparent;
}

.route-stop.is-departure { border-color: rgba(235,116,83,.55); }

.stop-sequence {
  color: #2e7089;
  font: 700 8px/1 var(--utility);
}

.route-stop.is-excluded .stop-sequence { color: var(--ink-soft); }
.stop-meta { display: flex; gap: 6px; align-items: center; min-width: 0; }
.stop-meta strong { min-width: 0; font: 800 13px/1 var(--display); }
.departure-tag { padding: 3px 5px; border-radius: 999px; color: #9c3e31; background: rgba(235,116,83,.12); font: 700 6px/1 var(--utility); text-transform: uppercase; }

.order-controls {
  display: flex;
  gap: 2px;
  min-width: 46px;
  justify-content: flex-end;
}

.order-button {
  display: grid;
  width: 22px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: rgba(38,61,70,.07);
  font: 800 13px/1 var(--body);
  cursor: pointer;
}

.order-button:hover:not(:disabled) { color: var(--white); background: #2e7089; }
.order-button:disabled { opacity: .25; cursor: default; }

.stop-check {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
}

.stop-check:hover { background: rgba(38,61,70,.07); }
.stop-check input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-shape { position: relative; width: 14px; height: 14px; border: 1.5px solid currentColor; border-radius: 50%; }
.check-shape::before, .check-shape::after { content: ""; position: absolute; top: 5px; left: 3px; width: 6px; height: 1.5px; border-radius: 2px; background: currentColor; }
.check-shape::after { transform: rotate(90deg); }
.stop-check input:checked + .check-shape::after { display: none; }
.stop-check input:focus-visible + .check-shape { outline: 3px solid var(--ink); outline-offset: 3px; }
.toggle-copy { font: 700 8px/1 var(--utility); text-transform: uppercase; }

.journey-status {
  display: flex;
  gap: 8px;
  min-height: 34px;
  align-items: center;
  padding: 7px 0;
  color: var(--ink-soft);
  font-size: 10px;
}

.status-icon { width: 8px; height: 8px; border: 1.5px solid #2e7089; border-radius: 50%; }
.journey-status.is-running .status-icon { border-color: var(--coral) transparent var(--coral) var(--coral); animation: spin .7s linear infinite; }
.journey-status.is-success .status-icon { border-color: #3c9c5b; background: #3c9c5b; }
.journey-status.is-error { color: #9c3e31; }
.journey-status.is-error .status-icon { border-color: var(--coral); background: var(--coral); }

.send-button {
  display: flex;
  flex: 0 0 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: var(--white);
  background: var(--coral);
  font: 800 13px/1 var(--display);
  cursor: pointer;
}

.send-button:hover:not(:disabled) { background: #dc6648; }
.send-button:disabled { opacity: .45; cursor: wait; }
.send-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.passport {
  position: absolute;
  z-index: 4;
  inset: 12px;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 18px;
  border-radius: 14px;
  background: var(--white);
}

.passport[hidden] { display: none; }
.passport-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.passport-heading h3 { margin: 0; font: 800 18px/1 var(--display); }
.passport-actions { display: grid; justify-items: end; gap: 6px; }
.departure-label { max-width: 170px; color: #2e7089; font: 700 8px/1.3 var(--utility); text-align: right; }
.result-buttons { display: flex; gap: 5px; }
.result-button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--paper); font: 700 8px/1 var(--utility); cursor: pointer; }
.result-button:hover:not(:disabled) { border-color: #2e7089; }
.result-button:disabled { opacity: .35; cursor: wait; }

.stamp-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  flex: 1 1 auto;
  align-content: center;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.stamp {
  display: grid;
  width: min(100%, 94px);
  aspect-ratio: 1;
  place-items: center;
  justify-self: center;
  padding: 6px;
  border: 2px dashed #2e7089;
  border-radius: 50%;
  color: #2e7089;
  opacity: 0;
  transform: scale(.92) rotate(-3deg);
}

.stamp:nth-child(2n) { color: #b65745; border-color: #b65745; transform: scale(.92) rotate(3deg); }
.stamp.is-visible { opacity: .86; transform: scale(1) rotate(-3deg); transition: opacity .18s ease, transform .18s ease; }
.stamp:nth-child(2n).is-visible { transform: scale(1) rotate(3deg); }
.stamp > span {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px solid currentColor;
  border-radius: 50%;
  text-align: center;
}
.stamp-sequence { font: 700 6px/1 var(--utility); letter-spacing: .08em; }
.stamp strong { max-width: 72px; font: 800 10px/.95 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.stamp small { max-width: 70px; font: 700 6px/1.15 var(--utility); text-transform: uppercase; }
.skipped-list { display: grid; gap: 5px; margin-top: 8px; }
.skipped-item { padding: 7px 9px; border-radius: 7px; color: var(--ink-soft); background: #eeeee5; font-size: 9px; }

.route-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.route-total span { color: var(--ink-soft); font: 700 8px/1 var(--utility); letter-spacing: .06em; text-transform: uppercase; }
.route-total strong { font: 800 22px/1 var(--display); }

@keyframes route-march { to { stroke-dashoffset: -22; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 901px) {
  .globe-wrap {
    inset: auto;
    top: clamp(76px, 8.3vh, 110px);
    left: calc(290px - clamp(725px, 69.5vw, 940px));
    width: clamp(1450px, 139vw, 1880px);
    min-width: 0;
    aspect-ratio: 800 / 620;
  }
}

@media (max-width: 900px) {
  .site-header { height: 54px; padding: 8px 12px 4px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand strong { font-size: 14px; }
  .network-state { font-size: 0; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(225px, 44%) minmax(0, 56%); gap: 8px; height: calc(100dvh - 54px); padding: 0 10px 10px; }
  .intro { padding: 8px 0 0 4px; }
  .eyebrow { margin-bottom: 5px; font-size: 7px; }
  h1 { font-size: clamp(34px, 8vw, 48px); }
  .intro-copy { width: min(220px, 43vw); margin-top: 9px; font-size: 9px; line-height: 1.4; }
  .globe-wrap {
    inset: auto;
    top: clamp(24px, 4vh, 40px);
    left: calc(50% - clamp(330px, 81vw, 725px));
    width: clamp(660px, 162vw, 1450px);
    min-width: 0;
    aspect-ratio: 800 / 620;
  }
  .dispatch { height: 100%; padding: 14px; border-radius: 15px; }
  .panel-header { padding-bottom: 9px; }
  .panel-header h2 { font-size: 21px; }
  .route-help { margin-top: 6px; font-size: 8px; }
  .departure-setting { margin-top: 5px; }
  .departure-setting select { height: 27px; font-size: 8px; }
  .route-builder { padding: 6px 0; }
  .route-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .route-stop { grid-template-columns: 17px minmax(0, 1fr) auto auto; gap: 4px; min-height: 39px; padding: 5px; }
  .stop-sequence { font-size: 6px; }
  .stop-meta strong { font-size: 10px; }
  .departure-tag { display: none; }
  .order-controls { min-width: 38px; }
  .order-button { width: 18px; height: 24px; font-size: 11px; }
  .stop-check { gap: 4px; padding: 4px 5px; }
  .toggle-copy { font-size: 6px; }
  .journey-status { min-height: 28px; padding: 4px 0; font-size: 8px; }
  .send-button { flex-basis: 40px; font-size: 11px; }
  .passport { inset: 7px; padding: 13px; }
  .stamp-list { gap: 6px; }
  .stamp { width: min(100%, 82px); padding: 5px; }
  .stamp strong { max-width: 62px; font-size: 8px; }
  .stamp small { font-size: 5px; }
  .route-total { margin-top: 6px; padding-top: 7px; }
  .route-total strong { font-size: 18px; }
}

@media (max-width: 520px) {
  .workspace { grid-template-rows: minmax(220px, 43%) minmax(0, 57%); padding-inline: 7px; }
  h1 { max-width: 220px; font-size: clamp(31px, 10vw, 39px); }
  .intro-copy { width: 175px; margin-top: 7px; font-size: 8px; }
  .dispatch { padding: 11px; }
  .route-stop { grid-template-columns: minmax(0, 1fr) auto; }
  .toggle-copy { display: none; }
  .passport-heading h3 { font-size: 16px; }
  .departure-label { max-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
