:root {
  --bg: #e8e1d4;
  --paper: #fbf8f3;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #e3dacb;
  --rule: #1c1915;
  --sand: #f4e7d4;
  --sand-ink: #6d3c28;
  --archive: #eef1ea;
  --archive-ink: #3e4a3a;
  --alt: #f7f1e4;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "WenQuanYi Micro Hei", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(255, 252, 247, 0.9), transparent 60%),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
a { color: #1a4d5c; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: white;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.mast::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 1px;
  background: var(--rule);
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 6px;
}
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 40px;
  letter-spacing: 0.14em;
  line-height: 1.15;
}
.party {
  margin-top: 8px;
  font-size: 14px;
  color: #3a342c;
}
.mast-side {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.caveat {
  margin-top: 18px;
  padding: 12px 14px;
  background: #f6ece4;
  border-radius: 12px;
  color: #6a3b2c;
  font-size: 13.5px;
}
.caveat strong { font-weight: 600; }

.toolbar { margin-top: 16px; display: grid; gap: 10px; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-name {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  min-width: 64px;
}
.chips, .modes { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .modes button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #d9d0c2;
  background: transparent;
}
.chip[aria-pressed="true"], .modes button[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.modes button { min-width: 88px; }
.legend-note, .port-note, .mode-hint {
  color: var(--muted);
  font-size: 12.5px;
}
.mode-hint { color: #3f4a46; }

.stage {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 40%) minmax(320px, 60%);
  gap: 18px;
  align-items: start;
}
.stage > main, .card, .map-panel { min-width: 0; }
.map-panel { position: sticky; top: 12px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sail, var(--ink));
  border-radius: 12px;
  padding: 12px 14px 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card.is-focus { box-shadow: inset 0 0 0 1px var(--sail); }
.card-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.check { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--sail); }
.who { background: none; border: 0; padding: 0; text-align: left; }
.line-name {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.02em;
}
.en { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.when { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.when b { display: block; font-weight: 600; }
.ports-line {
  margin: 10px 0 0 26px;
  font-size: 16px;
}
.trip-pill, .region-pill, .dev-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  vertical-align: 1px;
}
.trip-pill.oneway { color: var(--sand-ink); background: var(--sand); border-color: #e4c9aa; }
.region-pill { color: #1d4e46; }
.dev-row { margin: 6px 0 0 26px; }
.dev-pill { background: #f6ece4; color: #6a3b2c; border-color: #e4c9aa; margin: 0 6px 0 0; }
.offset-pill { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; background: #e7eef0; color: #1a4d5c; font-size: 12px; }
.family-label { margin: 8px 0 4px; font-size: 15px; font-family: var(--serif); }
.fit-ok { margin: 4px 0 0 26px; color: var(--muted); font-size: 12.5px; }
.when span { display: block; color: var(--muted); font-size: 12.5px; }
.cand-section { margin-top: 28px; }
.cand-notice {
  margin: 8px 0 12px;
  padding: 12px 14px;
  background: #f6ece4;
  color: #6a3b2c;
  border-radius: 12px;
}
.cand-fold, .cand-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 10px 12px;
  margin: 8px 0;
}
.cand-page { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
#cand-map { height: 52vh; min-height: 240px; border-radius: 12px; border: 1px solid var(--line); margin-top: 8px; }
.cand-app select { min-height: 40px; max-width: 100%; }
.set { margin-top: 8px; }
.route {
  margin: 8px 0 0 26px;
  font-size: 13.5px;
}
.caution { color: var(--sand-ink); }
.cities { margin: 4px 0 0 26px; color: var(--muted); font-size: 12.5px; }
.cities i { font-style: normal; color: #b0a89c; margin: 0 4px; }

.strip {
  display: flex;
  gap: 0;
  overflow-x: auto;
  list-style: none;
  max-width: 100%;
  min-width: 0;
  margin: 10px 0 0 26px;
  padding: 0 0 4px;
  scrollbar-width: thin;
}
.src, .sep, .cave, .route, .party { overflow-wrap: anywhere; }
.stop { display: flex; align-items: center; flex: 0 0 auto; gap: 6px; }
.mk {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  background: var(--sail);
  flex: 0 0 auto;
}
.mk.sea {
  background: white;
  color: var(--sail);
  border: 1.5px dashed var(--sail);
}
.mk.scenic {
  background: white;
  color: var(--sail);
  border: 1.5px solid var(--sail);
  border-radius: 3px;
  transform: rotate(45deg);
}
.mk.scenic span { transform: rotate(-45deg); font-size: 10px; }
.txt { display: flex; flex-direction: column; min-width: 0; }
.txt b { font-weight: 560; font-size: 12.5px; font-weight: 600; }
.txt small { color: var(--muted); font-size: 11px; }
.join {
  width: 14px;
  height: 0;
  border-top: 2px solid var(--sail);
  margin: 0 4px;
}
.join.dashed { border-top-style: dashed; }

.price {
  margin: 10px 0 0 26px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f4ee;
  border: 1px solid var(--line);
}
.price.sea { background: color-mix(in srgb, var(--sail) 8%, white); }
.price.inward { background: var(--sand); border-color: #e4c9aa; }
.price.unverified { background: var(--paper); }
.price.missing { background: transparent; border-style: dashed; }
.k { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.tagline {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid currentColor;
}
.price.inward .tagline { color: var(--sand-ink); }
.price.sea .tagline { color: #1d4e46; }
.price.unverified .tagline { color: #6a4a28; }
.amt {
  margin-top: 6px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.amt.cny { font-size: 15px; color: #3c3832; }
.tag {
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 1.6;
}
.tag.direct { color: #0e5c56; }
.tag.derived { color: #3d4c5e; }
.tag.reference { color: #7a5b2a; }
.cat, .src, .cave, .sep {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.missing-title { font-size: 18px; margin-top: 4px; }

.archive, .alt {
  margin: 8px 0 0 26px;
  padding: 10px 12px;
  border-radius: 10px;
}
.archive {
  background: var(--archive);
  border: 1px dashed #b7c0b0;
  color: var(--archive-ink);
}
.alt {
  background: var(--alt);
  border: 1px dashed #c8b48a;
}
.archive .amt, .alt .amt { font-size: 16px; color: inherit; }

.fine {
  margin: 8px 0 0 26px;
  color: var(--muted);
  font-size: 12.5px;
}
details { margin: 8px 0 0 26px; }
summary { cursor: pointer; color: #1a4d5c; font-size: 13px; }
.evidence {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.evidence h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}
.room {
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 4px 6px 4px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.orig { color: var(--muted); font-size: 12px; }

.compare-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}
.compare-head button {
  border: 0;
  background: none;
  text-decoration: underline;
  color: #1a4d5c;
}
.cols {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.group-label {
  font-family: var(--serif);
  font-size: 16px;
  margin: 8px 0;
}
.empty {
  padding: 28px 8px;
  color: var(--muted);
}

.map-frame { position: relative; }
#map {
  height: calc(100vh - 36px);
  min-height: 680px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #d5e2dc;
}
.map-expand {
  position: absolute;
  z-index: 500;
  right: 10px;
  top: 10px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 243, 0.94);
}
.route-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  width: 100%;
  text-align: left;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.stage > main, .set, .route-block, .ship-block, .route-toggle { min-width: 0; max-width: 100%; }
.route-toggle > span:first-child { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.route-price { text-align: right; flex: 0 0 auto; }
.route-price b { display: block; font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600; }
.route-price small, .route-price em { display: block; font-style: normal; font-weight: 400; color: var(--muted); font-size: 11px; }
.route-price.wait { color: #6a4a28; font-size: 13px; }
.schematic {
  position: absolute;
  z-index: 500;
  left: 10px;
  top: 10px;
  margin: 0;
  padding: 4px 8px;
  background: rgba(251, 248, 243, 0.94);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.06em;
}
#legend {
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}
.candidate { border-style: dashed; background: #f6f3ec; }
.hold, .fine { margin: 8px 0 0 26px; color: var(--sand-ink); font-size: 13px; }
.fine { color: var(--muted); font-size: 12.5px; }
.hold-mark { width: 16px; }
.map-key, .legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  vertical-align: -1px;
  border-radius: 50%;
  background: #1c1915;
}
.swatch.sea { background: white; border: 1.5px dashed #1c1915; }
.swatch.scenic { border-radius: 2px; transform: rotate(45deg); background: white; border: 1.5px solid #1c1915; }
.legend-row label {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 32px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-tooltip.map-label {
  background: rgba(251, 248, 243, 0.95);
  border: 1px solid rgba(28, 25, 21, 0.16);
  color: var(--ink);
  border-radius: 999px;
  box-shadow: none;
  font-size: 11px;
  padding: 2px 7px;
}
.leaflet-tooltip.map-label::before { display: none; }
.pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 650;
  font-weight: 600;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(28, 25, 21, 0.25);
}
.pin.sea {
  background: white !important;
  color: var(--sail);
  border: 1.5px dashed var(--sail);
  font-size: 10px;
}
.pin.scenic {
  background: white !important;
  color: var(--sail);
  border: 1.5px solid var(--sail);
  border-radius: 3px;
  transform: rotate(45deg);
}
.pin.scenic span { transform: rotate(-45deg); }

.leaflet-control-attribution {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.88);
}

.colophon {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  display: grid;
  gap: 4px;
}

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

@media (max-width: 860px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .mast { flex-direction: column; align-items: flex-start; }
  .mast-side { text-align: left; }
  h1 { font-size: 34px; }
  .stage { display: flex; flex-direction: column; }
  .map-panel { order: -1; position: static; width: 100%; }
  #map { height: 58vh; min-height: 240px; }
  .map-panel.is-full {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: #efeae2;
    padding: 10px;
    overflow: auto;
  }
  .map-panel.is-full #map { height: calc(100vh - 96px); }
  .route, .cities, .strip, .price, .archive, .alt, .fine, .hold, .ports-line, .fit-ok, .dev-row, details { margin-left: 0; }
  .card-top { grid-template-columns: auto minmax(0, 1fr); }
  .when { grid-column: 2; text-align: left; }
  .modes { width: 100%; }
  .modes button { flex: 1; min-height: 42px; }
  .chip { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
