:root {
  --bg: #0d0d14;
  --bg-card: #14141f;
  --bg-input: #1a1a2e;
  --border: #2a2a3d;
  --accent: #7c6ff7;
  --accent-light: #a89df9;
  --accent-glow: rgba(124, 111, 247, 0.25);
  --danger: #f05a5a;
  --danger-glow: rgba(240, 90, 90, 0.2);
  --success: #4ecdc4;
  --warning: #f7b731;
  --text: #e8e8f0;
  --text-muted: #7878a0;
  --text-sub: #5a5a7a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav Bar ── */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-bar .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-bar .nav-back {
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-bar .nav-title {
  font-size: 16px;
  font-weight: 600;
}
.nav-bar .nav-action {
  color: var(--accent-light);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Mission Card ── */
.mission-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.mission-card.active::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
}
.mission-card.triggered::before {
  background: var(--danger);
}
.mission-card.closed::before {
  background: var(--text-sub);
}
.mission-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}
.mission-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ── Countdown ── */
.countdown {
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.countdown.urgent {
  background: var(--danger-glow);
  border-color: var(--danger);
}
.countdown-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}
.countdown.urgent .countdown-value { color: var(--danger); }
.countdown-label { font-size: 12px; color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-active  { background: rgba(124,111,247,0.15); color: var(--accent-light); }
.badge-draft   { background: rgba(120,120,160,0.12); color: var(--text-muted); }
.badge-triggered { background: rgba(240,90,90,0.15); color: var(--danger); }
.badge-closed  { background: rgba(90,90,122,0.12); color: var(--text-sub); }
.badge-paused  { background: rgba(247,183,49,0.12); color: var(--warning); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #6c5ff5, #8c7ff7);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-danger {
  background: rgba(240,90,90,0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-success {
  background: linear-gradient(135deg, #38b2a0, #4ecdc4);
  color: #fff;
  box-shadow: 0 4px 16px rgba(78,205,196,0.25);
}
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 12px; border-radius: 8px; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 50%;
  transform: translateX(50%) translateX(220px);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ff5, #8c7ff7);
  box-shadow: 0 6px 24px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  border: none;
  z-index: 200;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover { transform: translateX(50%) translateX(220px) scale(1.08); }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 14px;
  gap: 4px;
  font-size: 10px;
  color: var(--text-sub);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}
.bottom-nav-item.active { color: var(--accent-light); }
.bottom-nav-item svg { width: 22px; height: 22px; }

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  display: block;
}
.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-sub); }
.form-textarea {
  resize: none;
  min-height: 120px;
  line-height: 1.6;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237878a0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form-hint {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 6px;
}

/* ── Radio Tabs ── */
.radio-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.radio-tab input { display: none; }
.radio-tab label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.radio-tab input:checked + label {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-light);
}

/* ── Guardian / Capsule Item ── */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
}
.list-item:last-child { border-bottom: none; }
.list-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b8a4ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.list-avatar.capsule-icon {
  background: linear-gradient(135deg, #38b2a0, #4ecdc4);
  font-size: 20px;
}
.list-info { flex: 1; min-width: 0; }
.list-name { font-size: 15px; font-weight: 600; color: var(--text); }
.list-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-arrow { color: var(--text-sub); font-size: 16px; }

/* ── Relation Tag ── */
.relation-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 4px;
}
.tag-family  { background: rgba(78,205,196,0.12); color: var(--success); }
.tag-friend  { background: rgba(124,111,247,0.12); color: var(--accent-light); }
.tag-lawyer  { background: rgba(247,183,49,0.12); color: var(--warning); }
.tag-other   { background: rgba(120,120,160,0.1); color: var(--text-muted); }

/* ── Section Title ── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  margin-top: 4px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.empty-desc { font-size: 13px; color: var(--text-sub); line-height: 1.6; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 440px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideDown 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Step Wizard ── */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px 20px;
}
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-sub);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  z-index: 1;
  transition: all 0.3s;
}
.step-dot.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.step-dot.done {
  background: var(--success);
  color: #fff;
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 40px;
}
.step-line.done { background: var(--success); }

/* ── Checkin Big Button ── */
.checkin-btn {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ff5, #4ecdc4);
  border: none;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 0 12px var(--accent-glow), 0 12px 40px rgba(108,95,245,0.4);
  transition: all 0.2s;
  margin: 0 auto;
  letter-spacing: 0.5px;
}
.checkin-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 16px var(--accent-glow), 0 16px 48px rgba(108,95,245,0.5);
}
.checkin-btn .icon { font-size: 36px; margin-bottom: 6px; }

/* ── Login Page ── */
.login-hero {
  text-align: center;
  padding: 60px 20px 40px;
}
.login-logo {
  font-size: 48px;
  margin-bottom: 16px;
}
.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-tagline {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}
.phone-row {
  display: flex;
  gap: 8px;
}
.phone-prefix {
  flex-shrink: 0;
  width: 70px;
  text-align: center;
}
.otp-row {
  display: flex;
  gap: 10px;
}
.otp-input { flex: 1; letter-spacing: 6px; font-size: 20px; text-align: center; }
.otp-send-btn {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 13px;
  white-space: nowrap;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Mission Detail Timeline ── */
.timeline { padding-left: 16px; }
.timeline-item {
  position: relative;
  padding-left: 20px;
  padding-bottom: 20px;
  border-left: 2px solid var(--border);
}
.timeline-item:last-child { border-left-color: transparent; }
.timeline-dot {
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.timeline-time { font-size: 11px; color: var(--text-sub); margin-bottom: 4px; }
.timeline-text { font-size: 13px; color: var(--text-muted); }

/* ── Guardian Selector ── */
.guardian-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.guardian-check-item:last-child { border-bottom: none; }
.g-checkbox {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.g-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
