html, body {
  margin: 0;
  padding: 0;
  background: #0d1117;
  color: #e6edf3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
* { box-sizing: border-box; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 calc(110px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13,17,23,.94);
  backdrop-filter: blur(12px);
  padding: 12px 14px 10px;
  border-bottom: 1px solid #21262d;
}

.searchrow {
  display: flex;
  gap: 8px;
  align-items: center;
}

#q {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #30363d;
  background: #161b22;
  color: #e6edf3;
  outline: none;
  text-transform: uppercase;
}
#q:focus { border-color: #2f81f7; box-shadow: 0 0 0 3px rgba(47,129,247,.15); }
#q::placeholder { text-transform: none; color: #6e7681; font-weight: 400; font-size: 16px; }

#clearBtn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 12px;
  width: 46px;
  height: 46px;
  font-size: 18px;
  cursor: pointer;
  display: none;
}
#clearBtn.show { display: block; }

/* 路線號碼建議 */
#suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  max-height: 34vh;
  overflow-y: auto;
}
.chip {
  padding: 9px 15px;
  border-radius: 10px;
  background: #161b22;
  border: 1px solid #30363d;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  color: #e6edf3;
}
.chip:active { background: #2f81f7; border-color: #2f81f7; }
.chip .co {
  font-size: 10px;
  font-weight: 500;
  opacity: .55;
  margin-left: 6px;
  letter-spacing: 0;
}

body {
  padding-top: 0;
}
#headerWrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13,17,23,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #21262d;
}
#headerWrap .inner { max-width: 560px; margin: 0 auto; padding: 12px 14px 10px; }

main { padding: 12px 14px 0; }

/* 方向 tabs */
#dirs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.dirbtn {
  flex: 1;
  padding: 11px 10px;
  border-radius: 11px;
  background: #161b22;
  border: 1px solid #30363d;
  color: #8b949e;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
}
.dirbtn.active {
  background: rgba(47,129,247,.14);
  border-color: #2f81f7;
  color: #e6edf3;
  box-shadow: inset 0 0 0 1px #2f81f7;
}
.dirbtn small { display: block; font-size: 11px; font-weight: 400; opacity: .7; margin-top: 2px; }

/* 站列表 */
.stoplist { display: flex; flex-direction: column; gap: 1px; }
.stoprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 12px;
  background: #161b22;
  border-radius: 10px;
  margin-bottom: 6px;
}
.stoprow.near { border: 1px solid #2f81f7; }
.stopname {
  font-size: 15px;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}
.stopname .seq {
  font-size: 11px;
  color: #6e7681;
  margin-right: 7px;
}
.etas {
  text-align: right;
  flex-shrink: 0;
  min-width: 72px;
}
.eta-main {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
}
.eta-main.soon { color: #3fb950; }
.eta-main.now { color: #f85149; }
.eta-main.gone { color: #6e7681; font-size: 15px; font-weight: 500; }
.eta-sub {
  font-size: 11.5px;
  color: #8b949e;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.rmk {
  font-size: 10px;
  color: #b8860b;
  margin-top: 2px;
  opacity: .85;
}
.eta-flag {
  font-size: 9.5px;
  color: #8b949e;
  margin-top: 2px;
  padding: 1px 5px;
  border: 1px solid #30363d;
  border-radius: 4px;
  display: inline-block;
}

.norows, .msg {
  text-align: center;
  color: #6e7681;
  padding: 40px 20px;
  font-size: 14px;
  line-height: 1.6;
}
.msg b { color: #e6edf3; }

/* 底部狀態 */
#status {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(22,27,34,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid #21262d;
  padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: #8b949e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
}
#status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #3fb950; display: inline-block; margin-right: 6px;
  vertical-align: middle;
}
#status.stale .dot { background: #d29922; }
#status.err .dot { background: #f85149; }

#refreshBtn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #30363d;
  border-top-color: #2f81f7;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
