/* 顺路 · 移动端样式
   目标：单手可点、拇指区友好、深色/浅色自动适配 */

:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #10131a;
  --sub: #6b7280;
  --line: #e6e9ef;
  --brand: #1466ff;
  --brand-weak: #e8f0ff;
  --green: #06a561;
  --green-weak: #e5f7ee;
  --orange: #f07b1d;
  --red: #e5484d;
  --shadow: 0 1px 2px rgba(16, 19, 26, .06), 0 8px 24px rgba(16, 19, 26, .06);
  --radius: 16px;
  --tap: 44px;
  --nav-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --card: #171b23;
    --ink: #f3f5f9;
    --sub: #98a2b3;
    --line: #262c37;
    --brand: #4d8dff;
    --brand-weak: #17233a;
    --green: #29c27f;
    --green-weak: #10281e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
        "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

/* 有些组件自带 display，[hidden] 必须强制生效 */
[hidden] { display: none !important; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 12px;
  background: linear-gradient(135deg, #1466ff 0%, #0b47c4 55%, #0a3aa0 100%);
  color: #fff;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 6px 24px rgba(11, 71, 196, .22);
}

.topbar-row { display: flex; align-items: center; gap: 10px; }

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand b { font-size: 20px; letter-spacing: .5px; }
.brand span { font-size: 11px; opacity: .78; white-space: nowrap; }

.citybtn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 13px;
  max-width: 40vw;
  overflow: hidden;
  white-space: nowrap;
}
.citybtn:active { background: rgba(255, 255, 255, .3); }
.citybtn svg { flex: none; opacity: .9; }

.ico-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
}
.ico-btn:active { background: rgba(255, 255, 255, .34); }
.ico-btn.busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar-hint { margin-top: 10px; font-size: 12px; opacity: .82; display: flex; align-items: center; gap: 6px; }

/* ---------------- 主体 ---------------- */

main {
  padding: 14px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  max-width: 720px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.card.flush { padding: 0; overflow: hidden; }

.h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.h2 .tag { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--sub); }

.muted { color: var(--sub); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-weight: 550;
  text-align: center;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.block { width: 100%; }
.btn.primary {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(20, 102, 255, .28);
}
.btn.go { background: var(--green); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(6, 165, 97, .26); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--sub);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip.active { background: var(--brand-weak); border-color: transparent; color: var(--brand); font-weight: 600; }

/* ---------------- 表单 ---------------- */

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 102, 255, .12); }
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  height: 42px;
}
.field .prefix { color: var(--sub); font-size: 13px; flex: none; }
.field .suffix { flex: none; border: 0; background: transparent; color: var(--brand); font-size: 13px; padding: 6px; }

.searchbar { display: flex; gap: 8px; }
.searchbar .btn { flex: none; }

/* ---------------- 站牌 / 线路卡 ---------------- */

.addhint {
  display: block;
  width: 100%;
  margin: 2px 0 14px;
  padding: 13px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-family: inherit;
  text-align: center;
}
.addhint:active { background: var(--brand-weak); }

.board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px;
  margin-bottom: 12px;
}

.board-head { display: flex; align-items: flex-start; gap: 10px; }

.lineno {
  flex: none;
  min-width: 48px;
  height: 30px;
  padding: 0 9px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.lineno.metro { background: #7b3fe4; }

.dir { font-size: 12px; color: var(--sub); margin-top: 2px; }

.eta {
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.eta b { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.eta b.soon { color: var(--green); }
.eta b.word { font-size: 17px; letter-spacing: 0; }
.eta b.none { color: var(--sub); font-size: 16px; font-weight: 600; }
.eta span { display: block; font-size: 11px; color: var(--sub); margin-top: 3px; }

.buses { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.bus-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--sub);
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--bg);
}
.bus-row b { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand-weak);
  color: var(--brand);
}
.badge.green { background: var(--green-weak); color: var(--green); }
.badge.gray { background: var(--bg); color: var(--sub); }
.badge.orange { background: #fff2e4; color: var(--orange); }
@media (prefers-color-scheme: dark) { .badge.orange { background: #2a1f12; } }
.badge.red { background: #ffe9ea; color: var(--red); }
@media (prefers-color-scheme: dark) { .badge.red { background: #2c1315; } }

/* ---------------- 列表 ---------------- */

.list { display: flex; flex-direction: column; }
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
}
.item:last-child { border-bottom: 0; }
.item:active { opacity: .6; }
.item .sub { font-size: 12px; color: var(--sub); }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.7;
}
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .55; }

.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--bg), var(--line)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------------- 路线 ---------------- */

.plan {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 10px;
  overflow: hidden;
}
.plan-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 8px; }
.plan-head .d { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.plan-head .m { font-size: 12px; color: var(--sub); }
.plan-body { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.seg { display: flex; gap: 9px; font-size: 13px; line-height: 1.45; }
.seg .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--brand); }
.seg.walk .dot { background: var(--sub); }
.seg .txt { min-width: 0; }
.plan-foot { display: flex; gap: 8px; padding: 0 14px 12px; }
.plan-foot .btn { flex: 1; }

.swap {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  display: grid; place-items: center;
  color: var(--sub);
}

.tips { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.tip-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 0;
  text-align: left;
  width: 100%;
  font-size: 13px;
}
.tip-row:active { opacity: .65; }
.tip-row .sub { font-size: 11px; color: var(--sub); }

/* ---------------- 乘车码 ---------------- */

.code-hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 22px 18px;
  color: #fff;
  background: linear-gradient(140deg, #1677ff 0%, #0d5ae0 45%, #0a2f8f 100%);
  box-shadow: 0 12px 30px rgba(13, 90, 224, .32);
  margin-bottom: 12px;
}
.code-hero:after {
  content: "";
  position: absolute;
  width: 220px; height: 220px;
  right: -70px; top: -90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.code-hero .k { font-size: 13px; opacity: .85; }
.code-hero .t { font-size: 24px; font-weight: 700; margin: 4px 0 14px; letter-spacing: .5px; }
.code-hero .btn { background: #fff; color: #0d5ae0; border: 0; font-weight: 650; }
.code-hero .btn.line { background: rgba(255, 255, 255, .22); color: #fff; border: 1px solid rgba(255, 255, 255, .45); }
.code-hero .btn + .btn { margin-top: 8px; }

.steps { counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.step { position: relative; padding-left: 30px; font-size: 13px; line-height: 1.55; }
.step:before {
  counter-increment: s;
  content: counter(s);
  position: absolute;
  left: 0; top: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand-weak);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------------- 底部导航 ---------------- */

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-item {
  flex: 1;
  border: 0;
  background: none;
  color: var(--sub);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  padding: 0;
}
.nav-item.active { color: var(--brand); font-weight: 600; }
.nav-item.active svg { transform: translateY(-1px); }

/* ---------------- 弹层 / 提示 ---------------- */

.mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, .45);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.mask.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 82dvh;
  overflow-y: auto;
  transform: translateY(102%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .22);
}
.sheet.show { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 0 12px; position: sticky; top: 0; background: var(--card); }
.sheet-head b { font-size: 16px; }
.sheet-head .x { margin-left: auto; border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; color: var(--sub); display: grid; place-items: center; }
.sheet-grab { width: 36px; height: 4px; border-radius: 999px; background: var(--line); margin: 2px auto 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: 82vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(16, 19, 26, .92);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.hint {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--sub);
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
}
.hint.warn { background: #fff4e5; color: #8a4b00; }
@media (prefers-color-scheme: dark) { .hint.warn { background: #2a1f12; color: #e8b06a; } }

.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 7px 0; }
.kv + .kv { border-top: 1px dashed var(--line); }
.kv .k { color: var(--sub); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sub); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.wait { background: var(--orange); }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

@media (min-width: 640px) {
  :root { --radius: 18px; }
  main { padding-top: 18px; }
}
