
:root {
  color-scheme: light dark;

  /* ---- geometry, type, motion: identical in both skins ---- */
  --r-sm: 4px; --r-md: 7px; --bar: 4px;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --fs-kicker: 10.5px; --fs-meta: 10.5px; --fs-body: 15px;
  --lh-body: 1.7; --lh-tight: .98; --track-kicker: 2.4px;
  --ease: cubic-bezier(.22,.61,.36,1); --t-fast: .16s;
}

/* ------------------------------------------------------------- DARK skin */
:root, [data-theme="dark"] {
  --bg: #0b0d10;
  --panel: #141a21;
  --panel-2: #10151b;
  --line: #1e232b;

  --ink: #ede9e4;
  --ink-soft: #bdb6af;
  --ink-dim: #a9a29b;
  --mut: #8c857e;

  --accent: #e63b2e;
  --accent-text: #f2564a;
  --accent-fill: #cc2b1d;
  --accent-ink: #ffffff;

  --m-intl: #8aa0b0;
  --m-flight: #f2564a;
  --m-boat: #3fa8cf;
  --m-train: #2ec48a;
  --m-road: #ffb347;
  --m-start: #ede9e4;
  --m-opt: #ffb347;
  --opt-text: #ffb347;   /* 9.83:1 on --panel */

  --shadow-pop: 0 2px 16px rgba(0,0,0,.5);
  --attrib-bg: rgba(20,26,33,.84);
}

/* ------------------------------------------------------------ LIGHT skin */
[data-theme="light"] {
  --bg: #f7f5f1;
  --panel: #fdfcfa;
  --panel-2: #f1eee9;
  --line: #ddd8d0;

  --ink: #131313;
  --ink-soft: #3c3832;
  --ink-dim: #4a453e;
  --mut: #6e6a64;

  --accent: #cc2b1d;
  --accent-text: #cc2b1d;
  --accent-fill: #cc2b1d;
  --accent-ink: #ffffff;

  --m-intl: #5d6b76;
  --m-flight: #cc2b1d;
  --m-boat: #15607e;
  --m-train: #1c7a53;
  --m-road: #8a5610;
  --m-start: #131313;
  --m-opt: #a86b12;
  --opt-text: #7f4f0d;   /* #a86b12 measured 4.29:1 as 9px text on --panel */

  --shadow-pop: 0 2px 14px rgba(19,19,19,.14);
  --attrib-bg: rgba(253,252,250,.84);
}

/* Dark is the default for everyone, not just visitors whose OS is dark.
   A visitor on a light OS still lands on dark and can opt out with the toggle;
   the choice then persists in localStorage under mm-theme. */

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { display:flex; height:100vh; overflow:hidden; }

#side {
  width: 412px; flex:0 0 412px;
  background: var(--panel);
  border-right: var(--bar) solid var(--accent);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 30px 26px 40px;
}
#map { flex:1; height:100vh; background: var(--panel-2); }

/* ---------------------------------------------------------------- header */
header { margin-bottom: 22px; }
.head-row { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 2.6vw, 36px);
  line-height: var(--lh-tight);
  letter-spacing: -.01em;
  margin: 0 0 8px;
  color: var(--ink);
}
.sub { font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); margin: 0; }

#theme {
  flex:0 0 auto; margin-top:2px;
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
#theme:hover { color: var(--accent-text); border-color: var(--accent); }
#theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------------------- stats */
.stats {
  display:grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--line);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin: 20px 0 18px;
}
.stat { background: var(--panel); padding: 11px 8px; text-align:center; }
.stat .n {
  font-family: var(--font-mono); font-weight:500;
  font-size: 17px; color: var(--ink); line-height:1.2;
}
.stat .l {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  margin-top: 3px; line-height:1.3;
}

/* ---------------------------------------------------------------- legend */
.legend {
  display:flex; flex-wrap:wrap; gap: 4px 14px;
  font-size: var(--fs-meta); color: var(--mut);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.legend span { display:inline-flex; align-items:center; gap:5px; }
.legend i { width: 15px; height: 0; border-top: 3px solid; display:inline-block; }
/* Optional shares the gold family with Road in the dark skin, so the swatch
   carries the dash the map draws rather than relying on hue alone. */
.legend i[data-mode="opt"] { border-top-style: dashed; }
.legend i[data-mode="intl"] { border-top-style: dashed; }

/* -------------------------------------------------------------- timeline */
.eyebrow {
  font-size: var(--fs-kicker); text-transform:uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  margin: 18px 0 10px;
}
.timeline { position:relative; }
.leg { position:relative; padding-left: 20px; }
.leg::before {
  content:''; position:absolute; left:4px; top:0; bottom:0;
  width:1px; background: var(--line);
}
.leg:last-child::before { bottom: 50%; }
.dot {
  position:absolute; left:0; top:15px;
  width:9px; height:9px; border-radius:50%;
  background: var(--accent); border:2px solid var(--panel);
}
.leg.opt .dot { background: var(--m-opt); }

.card {
  background: var(--panel); border:1px solid var(--line);
  border-left: var(--bar) solid transparent;
  border-radius: var(--r-md);
  padding: 10px 12px; margin: 6px 0;
  cursor:pointer;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.card:hover { background: var(--panel-2); }
.card.active { border-left-color: var(--accent); background: var(--panel-2); }

.top { display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
.place { font-weight:600; font-size:15px; color: var(--ink); line-height:1.3; }
.days {
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--mut); white-space:nowrap; letter-spacing:-.02em;
}
.badge {
  font-family: var(--font); font-size:9px; font-weight:500;
  text-transform:uppercase; letter-spacing:1.4px;
  color: var(--opt-text); border:1px solid var(--m-opt);
  border-radius: var(--r-sm); padding:1px 4px; margin-left:6px;
  vertical-align: 1px;
}

/* one line: mode chip, movement, cost */
.meta {
  display:flex; align-items:center; flex-wrap:wrap; gap:6px;
  margin-top:6px;
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--ink-soft); letter-spacing:-.01em; line-height:1.5;
}
.pill {
  display:inline-flex; align-items:center; gap:4px;
  background: var(--panel-2);
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 1px 6px 1px 5px;
  font-weight:500; white-space:nowrap;
}
.cost { color: var(--mut); }
.cost::before { content:'· '; }

.note { margin-top:5px; font-size: 13px; line-height:1.55; color: var(--ink-dim); }

/* ---------------------------------------------------------------- footer */
.foot { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 8px; }
.foot details { border-bottom: 1px solid var(--line); }
.foot summary {
  cursor:pointer; list-style:none; padding: 10px 0;
  font-size: var(--fs-kicker); text-transform:uppercase;
  letter-spacing: var(--track-kicker); color: var(--ink-soft);
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
.foot summary::-webkit-details-marker { display:none; }
.foot summary::after {
  content:'+'; font-family: var(--font-mono); font-size:14px;
  color: var(--accent-text); line-height:1;
}
.foot details[open] summary::after { content:'\2212'; }
.foot .body { font-size: 13px; line-height:1.6; color: var(--ink-dim); padding: 0 0 12px; }
.foot .body ul { margin:0; padding-left: 16px; }
.foot .body li { margin-bottom: 4px; }
.foot .warn summary { color: var(--accent-text); }

/* ----------------------------------------------------------------- popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  border-top: 3px solid var(--accent);
  background: var(--panel); color: var(--ink);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 11px 13px; font-family: var(--font); }
.leaflet-popup-close-button { color: var(--mut) !important; }
.pop-h { font-weight:600; font-size:14.5px; color: var(--ink); margin-bottom:3px; line-height:1.3; }
.pop-m {
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--mut); letter-spacing:-.01em;
}
.pop-n { margin-top:5px; font-size:12.5px; color: var(--ink-dim); line-height:1.5; }
.leaflet-container { font-family: var(--font); background: var(--panel-2); }
.leaflet-control-attribution {
  font-size: 9.5px; background: var(--attrib-bg); color: var(--mut);
}
.leaflet-control-attribution a { color: var(--mut); }
.leaflet-bar a {
  background: var(--panel); color: var(--ink); border-bottom-color: var(--line);
}
.leaflet-bar a:hover { background: var(--panel-2); color: var(--accent-text); }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  #app { flex-direction: column; height:auto; overflow:visible; }
  #map { height: 46vh; min-height: 300px; order:-1; flex:none;
         border-bottom: var(--bar) solid var(--accent); }
  #side { width:100%; flex:none; border-right:none; height:auto;
          overflow:visible; padding: 22px 18px 36px; }
  html, body { height:auto; }
}


/* ---------------------------------------------------------------- intake */
/* ---- screen switching -------------------------------------------------
   One class on <html> decides which of the four screens is mounted. Only the
   result view wants a locked 100vh body; the others scroll. */
#intake, #confirm, #waiting, #app { display: none; }
.screen-intake  #intake  { display: flex; }
.screen-confirm #confirm { display: flex; }
.screen-waiting #waiting { display: flex; }
.screen-result  #app     { display: flex; }

html:not(.screen-result), html:not(.screen-result) body { height: auto; overflow: auto; }

#intake, #confirm {
  min-height: 100vh; align-items: center; justify-content: center;
  padding: 48px 24px; background: var(--bg);
}

.intake-inner { width: 100%; max-width: 660px; }

.mark {
  display: block; width: 76px; height: 76px; margin-bottom: 14px; margin-left: -3px;
  /* black ink -> invert on the dark ground, leave alone on paper */
  filter: invert(1);
}
[data-theme="light"] .mark { filter: none; }

.brandline {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  display: flex; align-items: center; gap: 9px; margin-bottom: 20px;
}
.brandline::before {
  content: ''; width: 26px; height: 0;
  border-top: var(--bar) solid var(--accent); display: inline-block;
}

#intake h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(31px, 4.5vw, 50px); line-height: 1.04;
  letter-spacing: -.015em; margin: 0 0 14px; color: var(--ink);
}
.h1-sub { color: var(--accent-text); }
.lede {
  font-size: 17px; line-height: 1.55; color: var(--ink-soft);
  margin: 0 0 32px; max-width: 44ch;
}

.field { margin-bottom: 26px; }
.field > label {
  display: block; font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut); margin-bottom: 9px;
}
textarea {
  width: 100%; min-height: 104px; resize: vertical;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-left: var(--bar) solid var(--accent);
  border-radius: var(--r-md); padding: 13px 15px;
  font-family: var(--font); font-size: 15.5px; line-height: 1.55;
  transition: border-color var(--t-fast) var(--ease);
}
textarea::placeholder { color: var(--mut); }
textarea:focus { outline: none; border-color: var(--accent); border-left-color: var(--accent); }

.examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ex {
  background: none; border: 1px dashed var(--line); border-radius: var(--r-sm);
  color: var(--mut); font-family: var(--font); font-size: 12.5px;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ex:hover { color: var(--accent-text); border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font); font-size: 14px; padding: 9px 14px 9px 11px;
  cursor: pointer; text-align: left;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent-fill); color: var(--accent-ink);
  border-color: var(--accent-fill);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 17px; height: 17px; flex: 0 0 auto; opacity: .75; }
.chip[aria-pressed="true"] .ico { opacity: 1; }
.chip:hover .ico { opacity: 1; }

.go-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 34px; }
#go, #confirm-go {
  background: var(--accent-fill); color: var(--accent-ink);
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  letter-spacing: .01em; padding: 13px 26px; cursor: pointer;
  transition: filter var(--t-fast) var(--ease);
}
#go:hover, #confirm-go:hover { filter: brightness(1.1); }
#go:focus-visible, #confirm-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#go[disabled], #confirm-go[disabled] { opacity: .5; cursor: default; }
.go-note { font-size: 12.5px; color: var(--mut); }

.inspo {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 38px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: var(--bar) solid var(--accent); border-radius: var(--r-md);
  text-decoration: none; color: var(--ink-soft);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.inspo:hover { background: var(--panel-2); border-color: var(--accent); }
.inspo-k {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--accent-text);
}
.inspo-t { font-size: 14.5px; color: var(--ink); }
.inspo-a { margin-left: auto; color: var(--accent-text); font-size: 17px; line-height: 1; }

.mock-flag {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.6; color: var(--mut);
}
.mock-flag b { color: var(--accent-text); font-weight: 600; }

/* ---------------------------------------------------------------- waiting */
#waiting {
  position: fixed; inset: 0; z-index: 900;
  background: var(--bg);
  align-items: center; justify-content: center; padding: 24px;
}
.wait-inner { width: 100%; max-width: 420px; }
.wait-inner h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 26px;
  margin: 0 0 22px; color: var(--ink); line-height: 1.15;
}
.step {
  display: flex; align-items: center; gap: 11px;
  font-size: 14px; color: var(--mut); padding: 7px 0;
  transition: color var(--t-mid, .4s) var(--ease);
}
.step i {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
  background: var(--line); transition: background var(--t-fast) var(--ease);
}
.step.on { color: var(--ink); }
.step.on i { background: var(--accent); }
.step.done { color: var(--ink-dim); }
.step.done i { background: var(--m-train); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 22px; overflow: hidden; }
.bar span {
  display: block; height: 100%; width: 0%; background: var(--accent);
  transition: width .5s var(--ease);
}

/* ------------------------------------------------------------- result nav */
#backbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
#back {
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
}
#back:hover { color: var(--accent-text); border-color: var(--accent); }

@media (max-width: 620px) {
  #intake { padding: 34px 18px; align-items: flex-start; }
  .chip { font-size: 13.5px; padding: 8px 11px; }
}


/* ------------------------------------------------------- confirm screen */
.confirm-h {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(27px, 3.4vw, 38px); line-height: 1.06;
  letter-spacing: -.012em; margin: 0 0 12px; color: var(--ink);
}
.cgrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px;
}
.cfield label {
  display: block; font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut); margin-bottom: 7px;
}
.cfield input {
  width: 100%; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-left: var(--bar) solid var(--accent);
  border-radius: var(--r-md); padding: 11px 13px;
  font-family: var(--font); font-size: 15px;
  transition: border-color var(--t-fast) var(--ease);
}
.cfield input:focus { outline: none; border-color: var(--accent); }
.cread {
  font-size: 13px; line-height: 1.6; color: var(--mut);
  border-left: 1px solid var(--line); padding-left: 12px; margin: 0 0 4px;
}
.ghost {
  background: none; color: var(--mut);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font); font-size: 14px; padding: 12px 18px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ghost:hover { color: var(--ink); border-color: var(--accent); }

/* --------------------------------------------------------------- errors */
.err {
  margin: 16px 0 0; padding: 11px 14px;
  background: var(--panel); border: 1px solid var(--accent);
  border-left: var(--bar) solid var(--accent); border-radius: var(--r-md);
  font-size: 14px; line-height: 1.5; color: var(--ink);
}
.wait-note { margin: 18px 0 0; font-size: 12.5px; color: var(--mut); }

/* -------------------------------------------------------------- backbar */
#backbar { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
#back, #theme {
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
#back:hover, #theme:hover { color: var(--accent-text); border-color: var(--accent); }
#theme { margin-left: auto; }
#back:focus-visible, #theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 620px) {
  #confirm { padding: 34px 18px; align-items: flex-start; }
  .cgrid { grid-template-columns: 1fr; }
}
