:root {
  --bay: #062024;
  --lagoon: #0b3534;
  --foam: #d8efe6;
  --folio: #f6f1e6;
  --folio-2: #efe6d4;
  --ink: #142426;
  --soft: #3f5854;
  --mute: #7a908b;
  --sun: #e8943a;
  --flare: #e15a3a;
  --sea: #1a6b63;
  --line: rgba(20, 36, 38, .12);
  --glass: rgba(246, 241, 230, .9);
  --shadow: 0 22px 50px rgba(2, 10, 12, .38);
  --display: "LXGW WenKai", "LXGW WenKai GB", "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", "Sarasa Gothic SC", "Consolas", ui-monospace, monospace;
}
* { box-sizing: border-box }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bay);
  color: var(--foam);
  font-family: var(--sans);
  line-height: 1.55;
}
body { min-width: 320px; min-height: 100dvh }
a { color: inherit }
button, textarea, input { font: inherit }
[hidden] { display: none !important }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
:focus-visible { outline: 2px solid var(--sun); outline-offset: 3px }

.app {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
}

.stage {
  position: fixed;
  inset: 0;
  background: #9bb8b0;
}
.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.map-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  color: var(--mute);
  background:
    radial-gradient(800px 320px at 70% 20%, rgba(232, 148, 58, .18), transparent 55%),
    linear-gradient(180deg, #123a38, #0b2828);
}
.map-fallback strong {
  display: block;
  color: var(--foam);
  font: 400 28px/1.2 var(--display);
  margin-bottom: 8px;
}
.horizon {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 140px;
  z-index: 2;
  background: linear-gradient(180deg, rgba(6, 32, 36, .55), transparent 80%);
}
.map-controls {
  position: absolute;
  right: 16px;
  top: 72px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-controls button {
  width: 42px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(6, 32, 36, .18);
  font: 500 20px/1 var(--mono);
  cursor: pointer;
}
.map-controls .reset { font-size: 12px; letter-spacing: .08em }
.route-legend, .map-badge {
  position: absolute;
  z-index: 5;
  background: var(--glass);
  color: var(--soft);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(6, 32, 36, .14);
}
.route-legend {
  right: 16px;
  bottom: 20px;
  display: flex;
  gap: 10px;
}
.map-badge { left: 16px; bottom: 20px }
.legend-line {
  width: 14px;
  height: 3px;
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
  border-radius: 2px;
}
.legend-line.drive { background: #d8572a }
.legend-line.walk { background: #2f6b58 }
.legend-line.xfer {
  background: transparent;
  border-top: 2px dashed #8b1e1e;
  height: 0;
  vertical-align: 3px;
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(0, max-content) 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  pointer-events: none;
}
.top > * { pointer-events: auto }
.brand, .top-trip {
  background: var(--glass);
  box-shadow: 0 8px 20px rgba(6, 32, 36, .14);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--lagoon);
  padding: 8px 12px;
  border-radius: 999px;
}
.brand b {
  font: 400 22px/1 var(--display);
  letter-spacing: .18em;
}
.brand span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  opacity: .62;
}
.top-trip {
  min-width: 0;
  max-width: min(440px, 46vw);
  padding: 7px 14px;
  border-radius: 16px;
}
.top-kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--sea);
  text-transform: uppercase;
}
.top-title {
  margin: 0;
  font: 400 18px/1.2 var(--display);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-meta {
  margin: 2px 0 0;
  color: var(--soft);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-actions { display: flex; gap: 8px; justify-self: end }

.btn {
  border: 0;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--sun);
  color: #2a1606;
  cursor: pointer;
  font-weight: 600;
}
.btn.ghost, .btn.secondary {
  background: var(--glass);
  color: var(--ink);
}
.btn:disabled { opacity: .45; cursor: not-allowed }
.text-btn, .ghost {
  border: 0;
  background: transparent;
  color: var(--sea);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
}
.icon-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 36, 38, .06);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.folio, .composer {
  position: fixed;
  top: 76px;
  left: 18px;
  z-index: 7;
  width: min(400px, calc(100vw - 36px));
  max-height: calc(100dvh - 108px);
  background: var(--glass);
  color: var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.folio { padding: 0 }
.pass {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: 16px 16px 12px;
}
.pass-end small {
  display: block;
  color: var(--mute);
  font-size: 10px;
  letter-spacing: .16em;
}
.pass-end strong {
  display: block;
  font: 500 20px/1.15 var(--mono);
  margin-top: 4px;
}
.pass-end span { color: var(--soft); font-size: 13px }
.pass-end:last-child { text-align: right }
.pass-mid {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--sun);
  min-width: 54px;
}
.pass-mid em {
  font: 400 11px var(--display);
  letter-spacing: .12em;
  font-style: normal;
}
.pass-mid i {
  display: block;
  width: 36px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sun), transparent);
}
.pass-note {
  margin: 0 16px 10px;
  color: var(--flare);
  font-size: 13px;
  font-weight: 600;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
}
.tabs button {
  border: 0;
  background: rgba(20, 36, 38, .05);
  color: var(--ink);
  padding: 7px 10px;
  min-height: 34px;
  border-radius: 999px;
  cursor: pointer;
  font: 500 13px var(--display);
}
.tabs button[aria-selected="true"] {
  background: var(--lagoon);
  color: var(--foam);
}
.mode-pill {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  font: 600 10px/1.5 var(--sans);
  border-radius: 999px;
  background: rgba(232, 148, 58, .16);
  color: #b86a12;
  font-style: normal;
  vertical-align: 1px;
}
.tabs button[aria-selected="true"] .mode-pill {
  background: rgba(246, 241, 230, .16);
  color: var(--foam);
}
.mode-pill.mode-walk { background: rgba(26, 107, 99, .12); color: var(--sea) }
.mode-pill.mode-bike { background: rgba(29, 106, 154, .12); color: #1d6a9a }
.mode-pill.mode-transit { background: rgba(107, 76, 154, .12); color: #6b4c9a }
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 14px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat { padding: 6px 8px 6px 0 }
.stat:nth-child(2n) { padding-left: 10px; border-left: 1px solid var(--line) }
.stat small { display: block; color: var(--mute); font-size: 11px; letter-spacing: .08em }
.stat b { display: block; font: 500 15px var(--mono); margin-top: 3px; font-variant-numeric: tabular-nums }
.stat-deadline b { color: var(--flare) }
.folio-scroll {
  overflow: auto;
  padding: 4px 16px 18px;
  min-height: 0;
}
.timeline { list-style: none; margin: 10px 0 0; padding: 0 }
.timeline li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  padding: 7px 0 7px 10px;
  position: relative;
  font-size: 13px;
}
.timeline li:before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sun);
}
.timeline time { font-family: var(--mono); color: var(--sea); font-size: 12px; font-variant-numeric: tabular-nums }
.warn { color: var(--flare); font-weight: 600 }
.status { margin: 10px 0 0; color: var(--mute); font-size: 13px }
.legs-title {
  margin: 16px 0 0;
  font: 500 14px var(--display);
  letter-spacing: .08em;
  color: var(--sea);
}
.legs, .legs-sub { list-style: none; margin: 8px 0 0; padding: 0 }
.legs-head {
  margin: 14px 0 0;
  font: 500 13px var(--display);
  color: var(--sea);
}
.leg {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.leg-idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--lagoon);
  color: var(--foam);
  display: grid;
  place-items: center;
  font: 600 11px var(--mono);
  margin-top: 2px;
}
.leg.xfer .leg-idx { background: var(--flare); border-radius: 5px }
.leg.wait .leg-idx { background: var(--mute) }
.leg strong { display: block; font: 400 14px/1.35 var(--display) }
.leg-meta { display: block; color: var(--mute); font-size: 12px; margin-top: 2px }
.leg a, .place a {
  display: inline-block;
  color: var(--sea);
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  text-decoration: none;
}
.leg a:hover, .place a:hover { color: var(--flare) }
.places { display: grid; gap: 8px; margin-top: 12px }
.place {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 252, 245, .55);
}
.place strong { display: block; font: 400 15px/1.3 var(--display) }
.place span { display: block; color: var(--mute); font-size: 12px; margin-top: 3px }

.composer {
  width: min(440px, calc(100vw - 36px));
  padding: 16px 16px 18px;
}
.composer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.kicker {
  margin: 0 0 4px;
  color: var(--sea);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
}
.composer h2, .empty strong {
  font: 400 26px/1.2 var(--display);
  margin: 0 0 8px;
  color: var(--ink);
}
.lede { margin: 0 0 12px; color: var(--soft); font-size: 13px }
.prompt-box, .source-box {
  background: rgba(255, 252, 245, .7);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.source-box { margin-top: 10px }
.prompt-head, .source-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--mute);
  font-size: 12px;
}
.prompt-text {
  margin: 0;
  padding: 10px;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  font: 12px/1.55 var(--mono);
  color: var(--soft);
}
textarea {
  width: 100%;
  min-height: 220px;
  border: 0;
  resize: vertical;
  padding: 10px;
  background: transparent;
  color: var(--ink);
  line-height: 1.55;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px }
.parse-msg { margin: 10px 0 0; font-size: 13px; color: var(--soft); min-height: 1.4em }
.parse-msg.bad { color: var(--flare) }
.parse-msg.ok { color: var(--sea) }
.share-url {
  margin-top: 8px;
  border: 1px dashed rgba(26, 107, 99, .35);
  padding: 8px 10px;
  border-radius: 10px;
  font: 12px var(--mono);
  color: var(--soft);
  word-break: break-all;
}
.empty {
  padding: 28px 22px;
  text-align: center;
  justify-content: center;
}
.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  right: auto;
  z-index: 9;
  max-width: min(340px, calc(100vw - 36px));
  margin: 0;
  background: var(--glass);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.ok { box-shadow: 0 0 0 1px rgba(26, 107, 99, .25), var(--shadow) }
.toast.bad { color: var(--flare) }
.credit {
  position: fixed;
  left: 18px;
  bottom: 52px;
  z-index: 5;
  margin: 0;
  max-width: min(380px, calc(100vw - 200px));
  color: rgba(246, 241, 230, .72);
  font-size: 11px;
  text-shadow: 0 1px 8px rgba(6, 32, 36, .55);
}
.credit a { color: #fff; text-underline-offset: 2px }

.app.composing .folio { display: none }
.app.shared .composer { display: none !important }

@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
  .brand { grid-column: 1 }
  .top-actions { grid-column: 2; grid-row: 1 }
  .top-trip { grid-column: 1 / -1; max-width: none }
  .folio, .composer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 52dvh;
    border-radius: 22px 22px 0 0;
  }
  .map-controls { top: 118px; right: 10px }
  .route-legend { right: 10px; bottom: calc(52dvh + 12px) }
  .map-badge { left: 10px; bottom: calc(52dvh + 12px) }
  .credit { display: none }
}
@media (max-width: 560px) {
  .brand b { font-size: 22px }
  .top-title { font-size: 18px }
  .pass { grid-template-columns: 1fr 1fr }
  .pass-mid { display: none }
  .pass-end:last-child { text-align: left }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important }
}
