:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --stay-bg: #fffbeb;
  --stay-line: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── top bar ─────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px calc(10px + env(safe-area-inset-top) * 0);
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  color: #fff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .25);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.controls input[type="date"], .controls select {
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 14px;
  color-scheme: dark;
}
.controls select option { color: #0f172a; }

/* ── buttons ─────────────────────────────── */
.btn {
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { filter: brightness(.92); }
.btn.ghost { background: rgba(255, 255, 255, .14); color: #fff; }
.btn.block { width: 100%; margin-top: 10px; padding: 11px; font-size: 15px; }

/* ── login ───────────────────────────────── */
.login-wrap { display: flex; justify-content: center; padding: 56px 16px; }
.login-wrap[hidden] { display: none; }
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  text-align: center;
}
.login-title { font-size: 24px; font-weight: 800; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
}
.login-msg { color: #dc2626; font-size: 13px; min-height: 18px; }
.login-page { padding: 40px 16px; max-width: 360px; margin: 0 auto; }

/* ── map + sheet ─────────────────────────── */
#app[hidden] { display: none; }
#map { height: 52vh; min-height: 300px; z-index: 0; }
#panel {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  margin-top: -18px;
  position: relative;
  z-index: 500;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(15, 23, 42, .10);
}
#trips { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#trips:empty { display: none; }
.trip {
  text-align: left;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 14px;
  cursor: pointer;
}
.trip.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

/* ── player ──────────────────────────────── */
#player {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
#play {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
}
#slider { flex: 1 1 120px; min-width: 0; accent-color: var(--accent); }
.player-meta {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}
#clock {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 70%;
  font-variant-numeric: tabular-nums;
}
#speed {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  font-size: 13px;
  background: #fff;
  flex: none;
  max-width: 100%;
}

/* ── stay notes ──────────────────────────── */
#stay { margin: 10px 2px 0; }
#stay:empty { display: none; }
.stay-label {
  background: var(--stay-bg);
  border: 1px solid #fde68a;
  border-left: 4px solid var(--stay-line);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 8px;
  font-size: 13px;
  color: #92400e;
}

@media (min-width: 760px) {
  #map { height: 62vh; }
  #panel { max-width: 720px; margin-left: auto; margin-right: auto; }
}
