:root {
  --ink: #171717;
  --muted: #737373;
  --green: #16875b;
  --orange: #d97825;
  --blue: #3d6fc7;
  --purple: #8a5bb5;
  --line: #dedede;
  --paper: #fff;
  --wash: #f5f5f5;
  --danger: #b42318;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: #f2f2f2;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px 18px; background: #f2f2f2; }
.auth-card { width: min(320px, 100%); padding: 24px; border: 1px solid #dedede; border-radius: 18px; background: #fff; box-shadow: 0 12px 40px #0000000d; }
.auth-card form { display: grid; gap: 12px; }
.auth-card input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cfcfcf; border-radius: 10px; background: #fff; color: #171717; font: inherit; }
.auth-card input:focus { border-color: #525252; outline: 3px solid #73737330; }
.auth-card button { min-height: 46px; border: 0; border-radius: 10px; background: #2b2b2b; color: #fff; font-weight: 800; cursor: pointer; }
.auth-card button:hover { background: #3d3d3d; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #737373; outline-offset: 3px; }

.shell { width: min(1120px, 100%); margin: 0 auto; padding: 10px 18px 14px; }
.hero {
  position: relative;
  overflow: hidden;
  padding: 8px 13px;
  border: 1px solid #2b2b2b;
  border-radius: 16px;
  background: #2b2b2b;
  box-shadow: 0 5px 16px #00000012;
  color: #fff;
}
.topbar, .map-heading, .summary-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  display: grid;
  flex: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: #fff;
  color: #111;
}
.brand-mark svg { width: 23px; height: 23px; }
.eyebrow { margin: 0 0 2px; color: #bdbdbd; font-size: 8px; font-weight: 700; letter-spacing: .16em; }
h1 { margin: 0; font-size: 22px; line-height: 1.1; letter-spacing: -.04em; }
.refresh {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-width: 72px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid #ffffff40;
  border-radius: 10px;
  background: #ffffff0d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.refresh:hover { background: #ffffff1f; }
.refresh:active { transform: scale(.97); }
.refresh:disabled { cursor: wait; opacity: .7; }
.refresh-icon { width: 15px; height: 15px; }
.refresh.is-loading .refresh-icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mode-switch {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
  padding: 2px;
  border: 1px solid #ffffff1f;
  border-radius: 11px;
  background: #ffffff0a;
}
.mode-switch button {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d4d4d4;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.mode-switch button.active { background: #fff; color: #111; box-shadow: 0 2px 8px #00000030; }
.mode-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
.mode-switch button.active .mode-dot { background: #111; opacity: 1; }

.origin-picker { margin-top: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 13px; background: #fafafa; box-shadow: none; }
.origin-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 5px; color: #333; font-size: 10px; font-weight: 800; }
.origin-heading small { color: #8a8a8a; font-size: 9px; font-weight: 600; }
.origin-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.origin-options button { display: flex; min-width: 0; min-height: 46px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 6px 10px; border: 1px solid #d4d4d4; border-radius: 10px; background: #fff; color: #525252; text-align: left; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.origin-options button:hover { border-color: #737373; }
.origin-options button:active { transform: scale(.985); }
.origin-options button.active { border-color: #3d3d3d; background: #3d3d3d; color: #fff; box-shadow: none; }
.origin-options button:disabled { cursor: wait; opacity: .65; }
.origin-options span { width: 100%; overflow: hidden; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.origin-options small { width: 100%; overflow: hidden; color: #8a8a8a; font-size: 9px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.origin-options button.active small { color: #bfbfbf; }

.updated { display: flex; min-width: 0; align-items: center; gap: 6px; color: #d4d4d4; font-size: 10px; white-space: nowrap; }
.updated.stale { color: #f0c9a8; }
.updated.is-querying { color: #fff; }
.updated .status-dot { background: #fff; box-shadow: 0 0 0 3px #ffffff14; }
.status-dot { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: #171717; box-shadow: 0 0 0 3px #17171712; }
.is-querying .status-dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cards.four-lines { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards:has(.card:only-child) { grid-template-columns: minmax(0, 1fr); }
.card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: 0 4px 14px #00000008;
}
.card.line-0 { --card-color: var(--green); --card-soft: #fafafa; }
.card.line-1 { --card-color: var(--orange); --card-soft: #fafafa; }
.card.line-2 { --card-color: var(--blue); --card-soft: #fafafa; }
.card.line-3 { --card-color: var(--purple); --card-soft: #fafafa; }
.line-badge {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: #fafafa;
}
.line-name { color: var(--card-color); font-size: 25px; font-weight: 900; line-height: 1; letter-spacing: -.06em; white-space: nowrap; }
.line-label { width: 100%; color: #666; font-size: 9px; font-weight: 700; line-height: 1.35; text-align: center; overflow-wrap: anywhere; }
.arrivals { display: flex; min-width: 0; flex-direction: column; padding: 13px 13px 12px; }
.terminal { margin: 0 0 10px; color: var(--muted); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.terminal strong { margin-left: 3px; color: #333; font-weight: 700; }
.arrival-row { display: flex; min-height: 44px; align-items: center; gap: 12px; }
.arrival-primary { display: flex; min-width: 76px; flex: none; align-items: baseline; gap: 5px; }
.minutes { color: var(--card-color); font-size: 40px; font-weight: 900; line-height: 1; letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.minutes-label { color: #525252; font-size: 11px; font-weight: 700; white-space: nowrap; }
.no-data { color: #333; font-size: 16px; font-weight: 850; line-height: 1.2; }
.warning { color: var(--danger) !important; }
.live-meta { min-width: 0; flex: 1; }
.bus-detail { margin: 0; color: #666; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.detail-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.chip { display: inline-flex; min-height: 24px; align-items: center; padding: 4px 6px; border-radius: 6px; background: #f0f0f0; color: #525252; font-size: 10px; font-weight: 700; }
.service-time { margin-top: 7px; color: #737373; font-size: 8px; line-height: 1.45; text-align: center; }
.chip.capacity-0 { background: #ededed; color: #171717; }
.chip.capacity-1 { background: #dedede; color: #404040; }
.chip.capacity-2 { background: #c9c9c9; color: #111; }
.stop-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #ebebeb; }
.stop-info span { min-width: 0; padding: 8px 9px; border: 1px solid #e5e5e5; border-radius: 9px; background: #fafafa; color: #8a8a8a; font-size: 9px; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }
.stop-info strong { display: block; margin-top: 3px; color: #333; font-size: 11px; font-weight: 750; }
.more { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px -13px -12px; padding: 9px 13px; border-top: 1px solid #e8e8e8; background: #f7f7f7; color: #737373; font-size: 10px; line-height: 1.4; }
.more > span { flex: none; }
.more > div { display: flex; min-width: 0; flex-wrap: wrap; justify-content: flex-end; gap: 4px 7px; }
.more strong { color: #333; font-size: 10px; font-weight: 800; white-space: nowrap; }
.more i { align-self: center; color: #a3a3a3; font-style: normal; }
.card.error { border-color: #e5b4ae; }
.skeleton { display: block; min-height: 220px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.skeleton-side { display: none; }
.skeleton-body { width: 100%; }
.skeleton-line { height: 9px; margin-bottom: 9px; border-radius: 999px; background: linear-gradient(90deg, #ededed, #fafafa, #ededed); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-line.short { width: 32%; }
.skeleton-line.title { width: 68%; height: 24px; }
.skeleton-line.detail { width: 88%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.arrival-summary { margin-top: 8px; padding: 12px 15px; border: 1px solid #d4d4d4; border-radius: 15px; background: #fafafa; }
.arrival-summary.unavailable { border-color: #d6d6d6; background: #f5f5f5; }
.summary-heading { color: #525252; font-size: 10px; font-weight: 750; }
#summary-route { padding: 3px 7px; border-radius: 999px; background: #fff; color: #333; text-align: right; }
.summary-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-top: 8px; }
.summary-plan { min-width: 0; padding: 10px 11px; border: 1px solid #dedede; border-radius: 11px; background: #ffffffb3; }
.summary-plan.recommended { border-color: #171717; background: #fff; box-shadow: 0 3px 12px #0000000d; }
.summary-plan.unavailable { border-style: dashed; background: #ffffff70; }
.summary-plan-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #333; font-size: 11px; font-weight: 850; }
.recommended-badge { flex: none; padding: 2px 5px; border-radius: 999px; background: #171717; color: #fff; font-size: 8px; }
.summary-main { display: flex; align-items: center; gap: 9px; margin-top: 5px; }
.summary-time { color: #111; font-size: 30px; font-weight: 900; line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.unavailable .summary-time { color: #737373; font-size: 20px; letter-spacing: -.02em; }
.summary-main p { margin: 0; font-size: 10px; font-weight: 800; }
.summary-minutes { display: block; margin-top: 2px; color: #666; font-size: 10px; font-weight: 700; }
.summary-reason { margin: 7px 0 0; color: #525252; font-size: 10px; line-height: 1.45; }
.summary-legs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.summary-legs span { padding: 4px 6px; border: 1px solid #dedede; border-radius: 7px; background: #ffffffb3; color: #333; font-size: 9px; font-weight: 800; }
.summary-legs small { margin-left: 4px; color: #737373; font-size: 8px; font-weight: 600; }
.map-panel { min-width: 0; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 4px 14px #00000008; }
.map-heading { margin-bottom: 6px; }
.map-heading h2 { flex: none; margin: 0; font-size: 16px; letter-spacing: -.02em; }
.route-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.route-legend > span { display: inline-flex; min-height: 25px; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid #e0e0e0; border-radius: 7px; background: #fafafa; color: #404040; font-size: 9px; font-weight: 800; }
.route-legend small { display: none; }
.legend-line { display: inline-block; width: 14px; height: 3px; border-radius: 99px; background: var(--legend-color); }
.legend-line.color-0 { --legend-color: var(--green); }
.legend-line.color-1 { --legend-color: var(--orange); }
.legend-line.color-2 { --legend-color: var(--blue); }
.legend-line.color-3 { --legend-color: var(--purple); }
.legend-bus { display: inline-block; width: 20px; height: 13px; margin-left: 3px; background: var(--legend-color); clip-path: polygon(0 0, 100% 50%, 0 100%, 18% 50%); filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }
.legend-bus.bus-color-0 { --legend-color: #e83e8c; }
.legend-bus.bus-color-1 { --legend-color: #00bcd4; }
.legend-bus.bus-color-2 { --legend-color: #fdd835; }
.legend-bus.bus-color-3 { --legend-color: #263238; }
.bus-map-label.bus-color-0 { --legend-color: #e83e8c; }
.bus-map-label.bus-color-1 { --legend-color: #00bcd4; }
.bus-map-label.bus-color-2 { --legend-color: #fdd835; }
.bus-map-label.bus-color-3 { --legend-color: #263238; }
.map { height: 560px; overflow: hidden; border: 1px solid #d4d4d4; border-radius: 11px; background: #e5e5e5; }
.map .leaflet-container { width: 100%; height: 100%; font: inherit; }
.map-loading { display: flex; height: 100%; align-items: center; justify-content: center; gap: 8px; background: #f5f5f5; color: #525252; font-size: 12px; }
.map-footer { margin-top: 5px; color: #8a8a8a; font-size: 9px; line-height: 1.35; }
.map-footer:empty, .map-footer:has(#map-message:empty) { display: none; }
#map-message { color: #8a4b16; }
.map-popup { min-width: 120px; color: var(--ink); font-size: 11px; }
.map-popup strong { font-size: 12px; }
.map-popup p { margin: 3px 0; }
.map-popup span { color: var(--muted); font-size: 10px; }

.idle-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; background: #171717b8; backdrop-filter: blur(5px); }
.idle-card { width: min(360px, 100%); padding: 28px 24px 24px; border: 1px solid #d4d4d4; border-radius: 18px; background: #fff; box-shadow: 0 18px 60px #00000040; text-align: center; }
.idle-card .status-dot { width: 9px; height: 9px; }
.idle-card h2 { margin: 14px 0 8px; font-size: 22px; }
.idle-card p { margin: 0; color: #666; font-size: 13px; line-height: 1.65; }
.idle-card button { width: 100%; min-height: 44px; margin-top: 20px; border: 0; border-radius: 11px; background: #2b2b2b; color: #fff; font-weight: 800; cursor: pointer; }
.idle-card button:hover { background: #3d3d3d; }
body.is-idle { overflow: hidden; }
body.is-idle * { animation-play-state: paused !important; }

.notice { margin-top: 8px; padding: 9px 12px; border: 1px solid #e0c9b8; border-radius: 10px; background: #faf7f4; color: #8a4b16; font-size: 11px; line-height: 1.45; }
.notice.error { border-color: #e5b4ae; background: #fdf5f4; color: #a43d32; }

.leaflet-div-icon { border: 0; background: transparent; }
.bus-map-icon { background: transparent; }
.bus-map-label { position: relative; display: flex; width: 54px; height: 32px; align-items: center; justify-content: center; color: #fff; transform: rotate(var(--map-angle, 0deg)) scale(var(--bus-map-scale, 1)); transform-origin: center; }
.bus-map-label::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  clip-path: polygon(0 0, 100% 50%, 0 100%, 18% 50%);
  filter: drop-shadow(0 3px 4px #00000040);
}
.bus-map-label::after {
  content: "";
  position: absolute;
  inset: 15%;
  background: var(--legend-color);
  clip-path: polygon(0 0, 100% 50%, 0 100%, 18% 50%);
}
.bus-map-number {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  transform: rotate(calc(0deg - var(--map-angle, 0deg)));
}
.bus-map-label.bus-color-0 .bus-map-number { color: #4a0d25; }
.bus-map-label.bus-color-1 .bus-map-number { color: #00343a; }
.bus-map-label.bus-color-2 .bus-map-number { color: #3d3200; }
.bus-map-label.bus-color-3 .bus-map-number { color: #f5f5f5; }
.map-zoom-compact .bus-map-number { display: none; }

@media (max-width: 760px) {
  .shell { padding: 8px 10px 12px; }
  .hero { padding: 9px 11px; border-radius: 14px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  h1 { font-size: 21px; }
  .refresh { min-width: 66px; min-height: 34px; padding: 7px 9px; }
  .cards { grid-template-columns: 1fr; gap: 8px; }
  .card { grid-template-columns: 76px minmax(0, 1fr); border-radius: 14px; }
  .line-badge { padding: 12px 9px; }
  .line-name { font-size: 23px; }
  .arrivals { padding: 12px 12px 11px; }
  .arrival-row { min-height: 38px; }
  .minutes { font-size: 35px; }
  .more { margin: 11px -12px -11px; padding: 9px 12px; }
  .arrival-summary { padding: 11px 12px; }
  .summary-time { font-size: 33px; }
  .map { height: 460px; }
}

@media (max-width: 680px) {
  .map { height: 430px; }
  .map-heading h2 { font-size: 15px; }
}

@media (max-width: 420px) {
  .topbar { gap: 6px; }
  .brand { gap: 0; }
  .brand-mark, .eyebrow { display: none; }
  .topbar-actions { gap: 6px; }
  .updated { font-size: 8px; }
  .updated .status-dot { display: none; }
  h1 { font-size: 19px; }
  .refresh { min-width: 60px; }
  .refresh-label { display: none; }
  .card { grid-template-columns: 66px minmax(0, 1fr); }
  .line-badge { padding: 11px 7px; }
  .line-name { font-size: 20px; }
  .line-label { font-size: 8px; }
  .arrivals { padding: 11px 11px 10px; }
  .terminal { margin-bottom: 8px; }
  .arrival-row { min-height: 36px; gap: 9px; }
  .arrival-primary { min-width: 68px; }
  .minutes { font-size: 34px; }
  .minutes-label { font-size: 10px; }
  .stop-info { gap: 6px; margin-top: 10px; padding-top: 10px; }
  .stop-info span { padding: 7px; }
  .stop-info strong { font-size: 10px; }
  .more { margin: 10px -11px -10px; padding: 8px 11px; }
  .summary-main { gap: 9px; }
  .summary-time { font-size: 30px; }
  .summary-main p { font-size: 11px; }
  .map-panel { padding: 9px; }
  .map { height: 410px; }
}

@media (max-width: 360px) {
  .card { grid-template-columns: 60px minmax(0, 1fr); }
  .line-badge { padding: 10px 6px; }
  .line-name { font-size: 18px; }
  .origin-options { grid-template-columns: 1fr; }
  .origin-heading small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
