:root {
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f7f5;
  --card: #ffffff;
  --must: #1e3a8a;
  --miss: #ea580c;
  --south: #15803d;
  --gate: #6b7280;
  --r1: #2563eb;
  --r2: #ea580c;
  --r3: #16a34a;
  --r4: #9333ea;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
a { color: #1d4ed8; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "hero" "map" "content";
}
.hero { grid-area: hero; padding: 20px 16px 16px; }
.map-wrap { grid-area: map; position: relative; height: 56vh; min-height: 340px; }
.content { grid-area: content; padding: 0 16px 48px; }
#map { position: absolute; inset: 0; background: #e8eedf; }

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 470px;
    grid-template-areas: "map hero" "map content";
    grid-template-rows: auto 1fr;
  }
  .map-wrap { position: sticky; top: 0; height: 100vh; grid-row: 1 / span 2; }
  .hero { padding: 28px 24px 12px; }
  .content { padding: 0 24px 56px; }
}

/* 头部 */
.eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--ink-3); letter-spacing: .02em; }
h1 { font-size: 28px; font-weight: 800; }
.lead { margin: 10px 0 8px; font-size: 15px; color: var(--ink-2); }
.decisions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.decisions li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.decisions .num {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
}
.decisions b { display: block; font-size: 15px; }
.decisions span:not(.num) { font-size: 13px; color: var(--ink-2); }
.must { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #eef2ff; }
.must-title { margin: 0 0 6px; font-size: 13px; color: var(--must); font-weight: 600; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.chain span { font-size: 14px; font-weight: 600; color: var(--must); white-space: nowrap; }
.chain i { width: 18px; height: 2px; background: #a5b4fc; margin: 0 4px; position: relative; }
.chain i::after { content: ""; position: absolute; right: -1px; top: -3px; border: 4px solid transparent; border-left-color: #a5b4fc; border-right: 0; }

/* 区块 */
.block { margin-top: 22px; }
.block h2 { font-size: 20px; font-weight: 800; }
.hint { margin: 4px 0 10px; font-size: 13px; color: var(--ink-3); }

/* 路线卡片 */
.cards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.card {
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px 11px 9px; position: relative; transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: #cbd5e1; }
.card[aria-selected="true"] { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.card .tag { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: var(--c); border-radius: 6px; padding: 0 6px; }
.card .name { display: block; margin-top: 5px; font-size: 15px; font-weight: 700; line-height: 1.35; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.card .meta span { background: #f3f4f6; border-radius: 6px; padding: 1px 6px; }
.card .rec { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 700; color: var(--c); }

/* 路线详情 */
.detail {
  margin-top: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; border-top: 4px solid var(--c, var(--line));
}
.detail h3 { font-size: 17px; }
.detail .sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.stat { background: #f9fafb; border-radius: 10px; padding: 7px 8px; }
.stat b { display: block; font-size: 16px; }
.stat span { font-size: 12px; color: var(--ink-3); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col h4 { margin: 0 0 4px; font-size: 13px; }
.col ul { margin: 0; padding-left: 18px; font-size: 13px; }
.col.see h4 { color: var(--south); }
.col.miss h4 { color: #b91c1c; }
.cost-detail { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-2); }
.note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); background: #fffbeb; border-radius: 8px; padding: 6px 9px; }

/* 路线顺序图 */
.steps { margin: 14px 0 4px; padding: 0; list-style: none; }
.steps li { position: relative; padding-left: 26px; }
.steps .stop { font-size: 14px; font-weight: 600; min-height: 22px; }
.steps .stop::before {
  content: ""; position: absolute; left: 5px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--c);
}
.steps .stop.k-must::before { border-color: var(--must); }
.steps .stop.k-miss::before { border-color: var(--miss); }
.steps .stop.k-south::before { border-color: var(--south); }
.steps .stop.k-gate::before { border-color: var(--gate); }
.steps .stop small { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.steps .leg { font-size: 12.5px; color: var(--ink-2); padding: 3px 0 5px 26px; }
.steps .leg::before { content: ""; position: absolute; left: 10px; top: -2px; bottom: -2px; width: 3px; background: var(--c); border-radius: 2px; }
.steps .leg.m-cable::before { background: repeating-linear-gradient(var(--c) 0 5px, transparent 5px 9px); }
.steps .leg.m-bus::before, .steps .leg.m-shuttle::before { background: repeating-linear-gradient(var(--c) 0 2px, transparent 2px 6px); }
.steps .leg.m-train::before { background: repeating-linear-gradient(#b91c1c 0 6px, transparent 6px 9px); }
.steps .leg.m-slide::before { background: repeating-linear-gradient(var(--c) 0 3px, transparent 3px 5px); }
.steps .leg .mode { display: inline-block; font-weight: 700; color: var(--ink); margin-right: 4px; }

/* 变体 */
.variants { margin-top: 14px; }
.variants h3 { font-size: 15px; margin-bottom: 6px; }
.variant-list { display: grid; gap: 8px; }
.variant {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--card); border: 1px dashed #cbd5e1; border-radius: 12px; padding: 9px 11px;
}
.variant[aria-selected="true"] { border-style: solid; border-color: var(--ink); }
.variant b { font-size: 14px; }
.variant p { margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }

/* 帮我选 */
.quiz { display: grid; gap: 10px; }
.q { border: 0; margin: 0; padding: 0; }
.q legend { font-size: 14px; font-weight: 700; margin-bottom: 5px; padding: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts label { position: relative; }
.opts input { position: absolute; opacity: 0; pointer-events: none; }
.opts span {
  display: inline-block; cursor: pointer; font-size: 13.5px;
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px;
}
.opts input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.opts input:focus-visible + span { outline: 2px solid #93c5fd; outline-offset: 2px; }
.quiz-result:empty { display: none; }
.quiz-result {
  margin-top: 12px; background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  border: 2px solid var(--c, var(--ink));
}
.quiz-result h3 { font-size: 16px; }
.quiz-result ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.quiz-result button {
  margin-top: 10px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--c, var(--ink)); color: #fff; border: 0; border-radius: 10px; padding: 7px 14px;
}

/* 实用信息 */
.info-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.info-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.info-card h3 { font-size: 14px; }
.info-card p { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); }
.info-card .big { font-size: 22px; font-weight: 800; color: var(--ink); margin: 2px 0 0; }
.info-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.info-card.warn { background: #fffbeb; border-color: #fde68a; }
.prices { width: 100%; margin-top: 10px; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: 13.5px; }
.prices caption { text-align: left; font-size: 12.5px; color: var(--ink-3); padding: 0 0 6px; }
.prices th, .prices td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prices th { width: 38%; font-weight: 600; white-space: nowrap; }
.prices tr:last-child th, .prices tr:last-child td { border-bottom: 0; }

/* 来源 */
.sources ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.sources li { margin: 3px 0; }
.disclaimer { font-size: 13.5px; background: #fef2f2; border-radius: 10px; padding: 8px 11px; margin: 8px 0 0; }
.map-credit { font-size: 12px; color: var(--ink-3); margin-top: 10px; }

/* 地图上的元素 */
.legend-toggle {
  position: absolute; left: 10px; bottom: 26px; z-index: 500;
  font: inherit; font-size: 13px; font-weight: 700; background: #fff; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 4px 10px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.legend {
  position: absolute; left: 10px; bottom: 60px; z-index: 500; width: min(270px, calc(100% - 20px));
  max-height: calc(100% - 80px); overflow: auto;
  background: rgba(255,255,255,.97); border-radius: 12px; padding: 10px 12px; box-shadow: 0 2px 12px rgba(0,0,0,.18);
  font-size: 12.5px;
}
.legend-h { margin: 0 0 4px; font-weight: 700; }
.legend ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 3px; }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend-note { margin: 0; color: var(--ink-3); font-size: 11.5px; line-height: 1.5; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dot-must { background: var(--must); }
.dot-miss { background: var(--miss); }
.dot-south { background: var(--south); }
.dot-gate { background: var(--gate); }
.dot-approx { background: transparent; box-shadow: none; border: 2px dashed var(--ink-2); }
.ln { width: 28px; height: 0; border-top: 4px solid var(--ink-2); }
.ln-cable { border-top-style: dashed; }
.ln-bus { border-top: 4px dotted var(--ink-2); }
.ln-train { border-top: 4px dashed #b91c1c; }
.ln-slide { border-top: 4px dotted var(--ink); border-top-width: 3px; }

.poi-icon { background: none; border: 0; }
.poi { position: relative; }
.poi .pin {
  width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); background: var(--k);
}
.poi.approx .pin { outline: 2px dashed var(--k); outline-offset: 3px; }
.poi .lbl {
  position: absolute; left: 20px; top: -3px; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: #111827;
  background: rgba(255,255,255,.92); border-radius: 6px; padding: 0 5px; box-shadow: 0 1px 3px rgba(0,0,0,.18);
  pointer-events: none;
}
.poi .lbl.left { left: auto; right: 20px; }
.poi.dim { opacity: .45; }
.poi.nolbl .lbl { display: none; }
.leaflet-popup-content { margin: 10px 13px; font-size: 13px; line-height: 1.55; }
.pop h4 { margin: 0 0 3px; font-size: 14.5px; }
.pop .k { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; border-radius: 5px; padding: 0 5px; margin-bottom: 4px; }
.pop p { margin: 0 0 4px; }
.pop .src { font-size: 11.5px; color: var(--ink-3); margin: 4px 0 0; }

@media (max-width: 480px) {
  .stat b { font-size: 14px; }
  .map-wrap { height: 60vh; }
}
@media (max-width: 380px) {
  .cards { gap: 6px; }
  .card .name { font-size: 14px; }
  .cols { grid-template-columns: 1fr; }
}
