:root {
  --bg: #070b14;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eefb;
  --muted: #8b98b8;
  --accent: #4f8cff;
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 20px;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

.aurora {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 20% 20%, rgba(79, 140, 255, 0.28), transparent 65%),
    radial-gradient(40% 50% at 85% 10%, rgba(34, 211, 238, 0.16), transparent 65%),
    radial-gradient(50% 60% at 55% 0%, rgba(139, 92, 246, 0.16), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}

.view {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 登录 ---------- */
#login-view { padding-top: max(64px, 12vh); }

.brand { text-align: center; margin-bottom: 28px; }
.logo {
  width: 64px; height: 64px; margin: 0 auto 16px;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 800; color: #06111f;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--cyan), var(--accent) 55%, #8b5cf6);
  box-shadow: 0 18px 40px -14px rgba(79, 140, 255, 0.7);
}
.brand h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: 0.5px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.login-card { padding: 22px 18px 18px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin: 0 0 7px 4px; letter-spacing: 0.4px; }
.field input {
  width: 100%; height: 52px; padding: 0 16px;
  font-size: 17px; color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field input::placeholder { color: #5c6782; }
.field input:focus { border-color: rgba(79, 140, 255, 0.65); box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.12); }

.check {
  display: flex; gap: 9px; align-items: flex-start;
  margin: 4px 2px 18px;
  font-size: 12px; line-height: 1.5; color: var(--muted);
}
.check input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

.btn {
  width: 100%; height: 52px;
  border: 0; border-radius: 14px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.5px;
  color: #fff; cursor: pointer;
  transition: transform .12s, opacity .18s, box-shadow .18s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #3b6fe0);
  box-shadow: 0 14px 30px -12px rgba(79, 140, 255, 0.8);
}
.btn.success { background: linear-gradient(135deg, #2fd39a, #12a97a); box-shadow: 0 14px 30px -12px rgba(52, 211, 153, 0.7); }
.btn.ghost {
  background: var(--panel-strong); border: 1px solid var(--line); color: var(--text);
  font-weight: 600; height: 44px; font-size: 14px;
}

.hint { margin: 14px 2px 0; font-size: 11.5px; line-height: 1.6; color: #6f7c9c; text-align: center; }
.footnote { margin: 26px 0 0; text-align: center; font-size: 11px; color: #5b6784; line-height: 1.6; }

/* ---------- 顶部 ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.hello { font-size: 21px; font-weight: 700; }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); letter-spacing: 0.5px; }
.icon-btn {
  background: var(--panel-strong); border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; padding: 7px 12px; border-radius: 10px; cursor: pointer;
}

/* ---------- 任务卡 ---------- */
.tasks { display: grid; gap: 14px; }

.task {
  position: relative;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.task::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
  opacity: .0;
}
.task.open::before { opacity: 1; }
.task.open { border-color: rgba(79, 140, 255, 0.35); box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.12), 0 20px 50px -30px rgba(79, 140, 255, 0.8); }

.task-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.task-name { font-size: 16px; font-weight: 700; line-height: 1.4; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: #a9b6d4; border: 1px solid var(--line);
}
.pill { font-size: 11px; padding: 4px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.pill.before { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.pill.open { background: rgba(52, 211, 153, 0.14); color: var(--green); }
.pill.after { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.pill.done { background: rgba(52, 211, 153, 0.14); color: var(--green); }

.countdown {
  margin: 16px 0 4px;
  font-size: 34px; font-weight: 800; letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #cfe0ff, #7fb0ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.countdown.small { font-size: 22px; }
.countdown-label { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.task-actions { display: flex; gap: 10px; margin-top: 10px; }
.task-actions .btn { height: 48px; font-size: 15px; }
.task-actions .btn.ghost { flex: 0 0 96px; }

.status-line { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.status-line b { color: var(--text); font-weight: 600; }

/* ---------- 抽屉 ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-mask { position: absolute; inset: 0; background: rgba(3, 6, 14, 0.72); backdrop-filter: blur(4px); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 78vh; display: flex; flex-direction: column;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  background: #0d1424;
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  animation: rise .24s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 16px; }
.sheet-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.rec { display: flex; justify-content: space-between; gap: 12px; padding: 13px 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.rec:last-child { border-bottom: 0; }
.rec-date { font-size: 13.5px; font-weight: 600; }
.rec-site { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.rec-right { text-align: right; flex: none; }
.badge { font-size: 10.5px; padding: 3px 7px; border-radius: 999px; }
.badge.in { background: rgba(52, 211, 153, 0.13); color: var(--green); }
.badge.out { background: rgba(248, 113, 113, 0.13); color: var(--red); }
.badge.unk { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.rec-time { font-size: 11px; color: #6f7c9c; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 42px; transform: translate(-50%, 20px);
  z-index: 90; max-width: 86vw;
  padding: 12px 18px; border-radius: 14px;
  background: rgba(18, 26, 44, 0.96); border: 1px solid var(--line);
  font-size: 13.5px; line-height: 1.5; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.err { border-color: rgba(248, 113, 113, 0.4); }

.loading { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 定位确认 ---------- */
.loc-card { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 16px; padding: 2px 14px; margin-bottom: 12px; }
.loc-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; font-size: 13.5px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.loc-row:last-of-type { border-bottom: 0; }
.loc-row span { color: var(--muted); }
.loc-row b { font-weight: 600; }
.loc-row b.ok { color: var(--green); }
.loc-row b.warn { color: var(--amber); }
.loc-row b.bad { color: var(--red); }
.loc-coord { font-size: 11px; color: #6f7c9c; padding: 0 0 12px; font-variant-numeric: tabular-nums; letter-spacing: 0.3px; }
.loc-steps { padding: 14px 2px; }
.loc-step { font-size: 12.5px; color: var(--muted); line-height: 2.1; }
.loc-fail { color: var(--red); font-size: 14px; font-weight: 600; padding: 18px 0 4px; }
.err-text { color: #f0a35e !important; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions .btn { flex: 1; height: 48px; }
.loc-addr { font-size: 11.5px; line-height: 1.6; color: #93a2c4; padding: 0 0 12px; }

/* ---------- 高德地图 ---------- */
.fix-map {
  height: 150px;
  margin: 0 0 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0e1626;
}

#map-sheet { z-index: 60; }
.map-body { height: 88vh; max-height: 88vh; }
.map-body .sheet-head { margin-bottom: 10px; }

.map-wrap { position: relative; flex: 1 1 auto; min-height: 220px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.map-canvas { width: 100%; height: 100%; background: #0e1626; }
.map-loading {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 6px;
  padding: 20px; text-align: center; font-size: 13px; color: var(--muted);
  background: rgba(10, 16, 28, 0.86);
}
.map-loading[hidden] { display: none; }
.map-fail { color: var(--red); font-weight: 600; margin-bottom: 6px; }
.map-fail-sub { font-size: 12px; color: #8b98b8; line-height: 1.6; }

.map-info { padding: 12px 2px 0; }
.map-addr { font-size: 13px; line-height: 1.6; color: var(--text); min-height: 21px; }
.map-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.map-meta > span { font-size: 11.5px; color: #6f7c9c; font-variant-numeric: tabular-nums; letter-spacing: 0.2px; }
.link-btn {
  background: none; border: 0; padding: 4px 0; color: var(--accent);
  font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.map-edit { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.map-edit[hidden] { display: none; }
.map-edit input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px;
  font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.map-edit input:focus { border-color: rgba(79, 140, 255, 0.6); }
.map-edit .btn { flex: 0 0 72px; height: 42px; }
.map-hint { font-size: 11.5px; line-height: 1.6; color: #7f8db0; margin-top: 8px; min-height: 18px; }
.map-fallback { display: grid; place-items: center; height: 100%; font-size: 12px; color: #6f7c9c; }

/* 地图上的「当前位置」标记（可拖动） */
.amap-pin { position: relative; width: 52px; height: 58px; cursor: grab; touch-action: none; }
.amap-pin:active { cursor: grabbing; }
.amap-pin-head {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(160deg, #7fb0ff, #2f6ef0);
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(47, 110, 240, 0.5);
}
.amap-pin-head::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  background: #fff; opacity: 0.9;
}
.amap-pin-stem {
  position: absolute; left: 50%; top: 30px; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-top: 16px solid #2f6ef0;
  filter: drop-shadow(0 6px 8px rgba(47, 110, 240, 0.4));
}
.amap-pin-pulse {
  position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%);
  width: 22px; height: 8px; border-radius: 50%;
  background: rgba(47, 110, 240, 0.3);
}
/* 高德自带的版权/logo 别挡住按钮 */
.amap-logo, .amap-copyright { opacity: 0.75; }
