:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1c1f;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --border: #e5e7eb;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101214;
    --card: #1a1d21;
    --text: #f2f3f5;
    --muted: #9aa0a6;
    --accent: #4d8dff;
    --accent-fg: #0b0d10;
    --border: #2a2d31;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  }
}
:root[data-theme="dark"] {
  --bg: #101214;
  --card: #1a1d21;
  --text: #f2f3f5;
  --muted: #9aa0a6;
  --accent: #4d8dff;
  --accent-fg: #0b0d10;
  --border: #2a2d31;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
.wrap { max-width: 600px; margin: 0 auto; padding: 14px 14px 40px; }
h1 { font-size: 20px; margin: 2px 0 2px; text-align: center; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 14px; text-align: center; }
.route-line { font-size: 13px; color: var(--muted); margin-bottom: 12px; display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap; text-align: center; }
.route-line strong { color: var(--text); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.hero { padding: 14px; }
.hero-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-left { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.hero-left .label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.hero-left .countdown { font-size: 42px; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; color: var(--text); }
.hero-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; margin-left: auto; min-width: 0; }
.hero-right .legs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hero-right .line-info { font-size: 13px; color: var(--muted); }
.hero-map-area { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
#map { height: 195px; border-radius: 9px; overflow: hidden; background: var(--border); z-index: 0; }
.map-stop-label { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
.line-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 24px;
  padding: 0 6px; background: var(--accent); color: var(--accent-fg); border-radius: 6px; font-weight: 700; font-size: 13px;
}
.notis-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 2px solid var(--card);
  box-sizing: content-box;
}
.notis-dot.green { background: #22c55e; }
.notis-dot.blue { background: #38bdf8; }
.notis-dot.gray { background: #cbd5e1; }
.walk-badge {
  display:inline-flex; align-items:center; padding: 0 6px; height:24px; border-radius:6px;
  background: var(--border); color: var(--muted); font-size: 12px; font-weight:600;
}
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type="text"], input[type="password"], select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
button {
  cursor: pointer; border: none; border-radius: 8px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg);
}
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.search-results { margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.search-results .opt { padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.search-results .opt:last-child { border-bottom: none; }
.search-results .opt:hover { background: var(--bg); }
.search-results .opt.selected { background: color-mix(in srgb, var(--accent) 15%, var(--card)); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.om-time { font-weight: 700; white-space: nowrap; }
.status-ok { color: var(--good); font-weight: 600; }
.status-warn { color: var(--warn); font-weight: 600; }
.status-bad { color: var(--bad); font-weight: 600; }
.muted { color: var(--muted); }
.old-time { text-decoration: line-through; color: var(--muted); margin-right: 4px; opacity: 0.8; }
.trip-time { white-space: nowrap; }
.trip-times-col { display: flex; flex-direction: column; gap: 1px; }
.hero-right .trip-times-col { align-items: flex-end; text-align: right; }
.time-row-orig { font-size: 11px; color: var(--muted); opacity: 0.85; white-space: nowrap; line-height: 1.2; }
.time-row-orig .old-time { text-decoration: line-through; margin-right: 0; }
.time-row-new { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; line-height: 1.2; }
.top-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.refresh-info { font-size: 12px; color: var(--muted); }
.settings-toggle { background: transparent; color: var(--muted); font-size: 13px; padding: 4px 0; text-decoration: underline; }
.error-box {
  background: color-mix(in srgb, var(--bad) 12%, var(--card)); border: 1px solid var(--bad); color: var(--bad);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}
[hidden] { display: none !important; }
.empty-state { text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }
a { color: var(--accent); }
input.saved-match {
  border-color: var(--good);
  box-shadow: 0 0 0 1px var(--good);
}
input.saved-match:focus {
  outline: 2px solid var(--good);
  outline-offset: 1px;
}
.swap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 5px;
  cursor: pointer;
  line-height: 1;
  margin-left: 2px;
  vertical-align: middle;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.swap-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.swap-btn:active {
  transform: scale(0.95);
}
tr.past-row {
  opacity: 0.55;
}
.checkbox-row { display:flex; align-items:center; gap:8px; font-size:13px; margin-bottom:12px; }
.checkbox-row input[type="checkbox"] { width:16px; height:16px; accent-color: var(--accent); }
.checkbox-row label { margin-bottom:0; font-weight:500; cursor:pointer; }
.data-source { margin-top: 10px; color: var(--muted); font-size: 11px; text-align: right; }
.map-dot-stop { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #2563eb; flex-shrink: 0; }
.map-dot-bus { display: inline-block; width: 12px; height: 10px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.map-bus-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  border: 1.5px solid #fff;
  white-space: nowrap;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
}
.map-bus-badge.is-past {
  opacity: 0.55;
}

/* ── Pull to refresh indicator ────────────────────────────────────────────── */
.ptr-indicator {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -70px);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: transform, opacity;
}
.ptr-indicator.ptr-pulling {
  transition: none;
}
.ptr-indicator.ptr-releasing {
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}
.ptr-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.ptr-icon {
  color: var(--accent);
  transition: transform 0.15s ease;
}
.ptr-indicator.ptr-ready .ptr-icon {
  transform: rotate(180deg);
}
.ptr-indicator.ptr-loading .ptr-icon {
  animation: ptr-spin 0.8s linear infinite;
}
@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

