/* 上海地铁票价对比 — UI 样式
   零外部请求：只用系统字体栈，不引 CDN、不引 webfont。 */

:root {
  --bg:      #f6f6f3;
  --panel:   #ffffff;
  --ink:     #16181d;
  --ink-2:   #454a55;
  --muted:   #6b7080;
  --line:    #e2e2dc;
  --line-2:  #efefe9;
  --accent:  #d0021b;
  --accent-soft: #fdecee;
  --warn:    #8a5300;
  --warn-bg: #fff6e2;
  --warn-line: #f0dcb0;
  --up:      #b3261e;
  --down:    #0f6b46;
  --flat:    #6b7080;
  --radius:  12px;
  --shadow:  0 1px 2px rgba(20, 22, 28, .05), 0 8px 24px -18px rgba(20, 22, 28, .35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #101116;
    --panel:   #181a21;
    --ink:     #eceef3;
    --ink-2:   #c3c7d1;
    --muted:   #949aa8;
    --line:    #2a2d36;
    --line-2:  #22242c;
    --accent:  #ff5a68;
    --accent-soft: #2b1418;
    --warn:    #f0c471;
    --warn-bg: #2a2113;
    --warn-line: #4a3a1c;
    --up:      #ff7a72;
    --down:    #5fd6a3;
    --flat:    #949aa8;
    --shadow:  0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -18px rgba(0, 0, 0, .8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1040px, 100% - 2.5rem); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--panel); color: var(--ink);
  padding: .6rem 1rem; border: 2px solid var(--accent); border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- 页头 */

.topbar {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(90rem 22rem at 12% -14rem, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--panel);
  padding: 2.6rem 0 2rem;
}

.eyebrow {
  margin: 0 0 .5rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
}

.topbar h1 {
  font-size: clamp(1.7rem, 1.1rem + 2.4vw, 2.6rem);
  font-weight: 800;
}

.tagline {
  margin: .7rem 0 0;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 1rem;
}

/* ---------------------------------------------------------------- 顶部提示 */

.alert {
  display: flex; gap: .85rem; align-items: flex-start;
  margin: 1.5rem 0 0;
  padding: .95rem 1.1rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-left: 3px solid color-mix(in srgb, var(--warn) 65%, transparent);
  border-radius: var(--radius);
}
.alert p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.alert strong { color: var(--ink); }

.alert-tag {
  flex: none;
  margin-top: .15rem;
  padding: .1rem .5rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 卡片 */

main { padding: 1.5rem 0 3rem; display: grid; gap: 1.1rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
}

.card-title { font-size: 1.06rem; font-weight: 700; }
.card > .card-title { margin-bottom: .9rem; }

.field-note {
  margin: .55rem 0 0;
  color: var(--muted);
  font-size: .84rem;
}
.field-note strong { color: var(--ink-2); }

/* ---------------------------------------------------------------- 查询表单 */

.od {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: .75rem;
}

@media (max-width: 620px) {
  .od { grid-template-columns: 1fr; }
  .swap { justify-self: start; }
}

.field label {
  display: block;
  margin-bottom: .35rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .03em;
  color: var(--muted);
}

.combo { position: relative; }

.combo input {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.combo input::placeholder { color: var(--muted); opacity: .8; }
.combo input:focus { background: var(--panel); border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.swap {
  margin-top: 1.55rem;
  width: 2.5rem; height: 2.5rem;
  font-size: 1.1rem; line-height: 1;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.swap:hover { color: var(--accent); border-color: var(--accent); }

.options {
  position: absolute; z-index: 10;
  top: calc(100% + .3rem); left: 0; right: 0;
  max-height: 17rem; overflow-y: auto;
  margin: 0; padding: .25rem;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .35);
}

.options li {
  display: flex; align-items: baseline; gap: .5rem;
  padding: .45rem .6rem;
  border-radius: 7px;
  cursor: pointer;
}
.options li[aria-selected="true"], .options li:hover {
  background: var(--accent-soft);
}
.options .opt-name { font-weight: 600; }
.options .opt-lines {
  margin-left: auto;
  font-size: .74rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%;
}
.options .empty { color: var(--muted); cursor: default; }
.options .empty:hover { background: none; }

/* ---------------------------------------------------------------- 按钮 */

.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  margin-top: 1.1rem;
}

.btn {
  font: inherit; font-weight: 700;
  padding: .65rem 1.4rem;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn[disabled] { opacity: .55; cursor: progress; }

.examples { font-size: .84rem; color: var(--muted); }

.chip {
  font: inherit; font-size: .82rem;
  margin: 0 .3rem 0 0;
  padding: .22rem .6rem;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }

.error {
  margin: .9rem 0 0;
  padding: .6rem .85rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 9px;
  font-size: .88rem;
}

/* ---------------------------------------------------------------- 按线路选站 */

.browse summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem;
  cursor: pointer;
  list-style: none;
}
.browse summary::-webkit-details-marker { display: none; }
.browse summary::before {
  content: "▸"; color: var(--muted); font-size: .8rem; margin-right: .2rem;
}
.browse[open] summary::before { content: "▾"; }
.summary-hint { font-size: .8rem; color: var(--muted); }

.browse-body { margin-top: 1rem; }

.line-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }

.line-tab {
  font: inherit; font-size: .82rem; font-weight: 600;
  padding: .25rem .6rem .25rem .5rem;
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.line-tab[aria-selected="true"] { color: var(--ink); border-color: currentColor; background: var(--panel); }

.dot {
  width: .6rem; height: .6rem; flex: none;
  border-radius: 999px;
  background: var(--line);
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: .3rem;
  margin: .7rem 0 0; padding: 0;
  list-style: none;
}

.station-btn {
  width: 100%;
  font: inherit; font-size: .85rem; text-align: left;
  padding: .35rem .5rem;
  color: var(--ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}
.station-btn:hover { color: var(--ink); background: var(--bg); border-color: var(--line); }

/* ---------------------------------------------------------------- 结果 */

.result { display: grid; gap: 1.1rem; }

.od-title {
  font-size: clamp(1.15rem, 1rem + 1vw, 1.5rem);
  font-weight: 800;
}
.od-title .arrow { color: var(--accent); margin: 0 .4rem; }

.stats {
  display: flex; flex-wrap: wrap; gap: .6rem 2.4rem;
  margin: 1rem 0 0; padding: 0;
  list-style: none;
}
.stats li { display: flex; flex-direction: column; }
.stat-k { font-size: .76rem; letter-spacing: .05em; color: var(--muted); }
.stat-v {
  font-size: 1.32rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-v small { font-size: .68em; font-weight: 600; color: var(--muted); margin-left: .15rem; }

.warnings { display: grid; gap: .5rem; margin-top: 1rem; }

.warnings p {
  margin: 0;
  padding: .55rem .8rem;
  font-size: .85rem;
  color: var(--ink-2);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 9px;
}
.warnings strong { color: var(--ink); }

/* ---------------------------------------------------------------- 票价卡 */

.fares {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.1rem;
}

.fare-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.fare-card.is-current { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.fare-card.is-plan::after {
  content: "未确定";
  position: absolute; top: .8rem; right: .9rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 999px;
  padding: 0 .4rem;
}

.fare-label { font-size: .82rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.fare-price {
  display: flex; align-items: baseline; gap: .2rem;
  margin-top: .2rem;
  font-size: 2.5rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fare-price .unit { font-size: .95rem; font-weight: 600; color: var(--muted); }

.fare-delta {
  margin-top: .35rem;
  font-size: .85rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fare-delta.up   { color: var(--up); }
.fare-delta.down { color: var(--down); }
.fare-delta.flat { color: var(--flat); }
.fare-delta .pct { font-weight: 600; color: var(--muted); margin-left: .3rem; }

.fare-rule { margin-top: .6rem; font-size: .78rem; color: var(--muted); }

/* ---------------------------------------------------------------- 路径 */

.legs { margin: 1rem 0 0; padding: 0; list-style: none; display: grid; gap: .1rem; }

.leg {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .8rem;
  padding: .6rem .2rem;
  border-top: 1px solid var(--line-2);
}
.leg:first-child { border-top: none; }

.leg-line {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .82rem; font-weight: 700;
  padding: .18rem .55rem;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.leg-od { font-size: .92rem; }
.leg-od .to-arrow { color: var(--muted); margin: 0 .35rem; }
.leg-alt { display: block; font-size: .76rem; color: var(--muted); }

.leg-meta {
  text-align: right;
  font-size: .82rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .leg { grid-template-columns: 1fr auto; }
  .leg-line { grid-column: 1 / -1; justify-self: start; }
}

/* ---------------------------------------------------------------- 表格 */

.table-scroll { overflow-x: auto; margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

th, td {
  padding: .42rem .7rem;
  text-align: right;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }

thead th {
  position: sticky; top: 0;
  background: var(--panel);
  font-size: .78rem; letter-spacing: .04em; color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.fare-table tbody tr:hover { background: var(--line-2); }
.fare-table tbody tr.hit {
  background: var(--accent-soft);
  outline: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.fare-table tbody tr.hit td { font-weight: 700; }
.fare-table .extra { color: var(--muted); font-size: .82rem; }
.fare-table td.d-up   { color: var(--up); }
.fare-table td.d-down { color: var(--down); }
.fare-table td.d-flat { color: var(--flat); }

.rules-table td:first-child { font-weight: 700; }
.rules-table td.steps { font-size: .84rem; white-space: normal; text-align: right; }

/* ---------------------------------------------------------------- 说明 / 页脚 */

.notes ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .45rem; }
.notes li { color: var(--ink-2); font-size: .88rem; }
.notes strong { color: var(--ink); }

.footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 1.6rem 0 2.4rem;
}
.footer p { margin: 0 0 .45rem; color: var(--muted); font-size: .82rem; max-width: 78ch; }
.footer strong { color: var(--ink-2); }
.footer .build { font-variant-numeric: tabular-nums; }
