:root {
  --brand: #ea4157;
  --brand-dark: #c3334a;
  --bg: #0f1115;
  --bg-card: #1a1d23;
  --text: #f5f5f7;
  --muted: #9aa0a6;
  --ok: #34c759;
  --warn: #ff9500;
  --danger: #ff3b30;
  --info: #5ac8fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang HK', 'PingFang TC', 'Microsoft JhengHei', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) 16px env(safe-area-inset-bottom, 16px);
}

header {
  padding: 16px 0;
  text-align: center;
  border-bottom: 1px solid #2a2d35;
  margin-bottom: 16px;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
}

header .subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 16px;
}

.user-bar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #333;
}

.user-bar .info { flex: 1; min-width: 0; }
.user-bar .info .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-bar .info .email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-bar .signout { background: none; border: 1px solid #444; color: var(--muted); padding: 6px 10px; font-size: 12px; border-radius: 8px; cursor: pointer; }

.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin: 32px 0;
}

.login-card p { color: var(--muted); margin-bottom: 16px; font-size: 14px; }

.btn-google {
  background: white;
  color: #1a1a1a;
  border: none;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.btn-google img { width: 20px; height: 20px; }

.status-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.status-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.status-card .value { font-size: 32px; font-weight: 700; color: var(--brand); }
.status-card .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.stats-row .stat { background: var(--bg-card); border-radius: 12px; padding: 12px; text-align: center; }
.stats-row .stat .v { font-size: 22px; font-weight: 700; }
.stats-row .stat .k { font-size: 10px; color: var(--muted); margin-top: 4px; }

.trip-btn {
  width: 100%;
  padding: 24px;
  font-size: 22px;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  margin-bottom: 16px;
  background: var(--brand);
  color: white;
  transition: background 0.2s, transform 0.1s;
}
.trip-btn:active { transform: scale(0.97); }
.trip-btn.active { background: var(--danger); }
.trip-btn:disabled { background: #444; color: #888; cursor: not-allowed; }

.settings {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.settings h3 { font-size: 13px; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }
.settings .row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.settings .row label { font-size: 14px; }
.settings select, .settings input { background: #2a2d35; color: var(--text); border: 1px solid #333; border-radius: 8px; padding: 6px 10px; font-size: 14px; }

.log-panel {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  max-height: 180px;
  overflow-y: auto;
}
.log-panel .line { margin-bottom: 2px; }
.log-panel .line.trigger { color: var(--ok); font-weight: 600; }
.log-panel .line.reject { color: var(--danger); }
.log-panel .line.warn { color: var(--warn); }
.log-panel .line.info { color: var(--info); }

.nav-row { display: flex; gap: 8px; margin-bottom: 16px; }
.nav-row a {
  flex: 1;
  display: block;
  padding: 12px;
  text-align: center;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  font-size: 13px;
}

footer {
  margin-top: auto;
  padding: 16px 0;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}

/* Modal: category picker */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px 20px;
  max-width: 400px;
  width: 100%;
}
.modal-content h2 { font-size: 20px; margin-bottom: 16px; text-align: center; }
.modal-content .gps { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 20px; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-btn {
  background: #2a2d35;
  color: var(--text);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 18px 12px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.cat-btn:active { background: var(--brand); transform: scale(0.97); }
.cat-btn .emoji { font-size: 28px; }
.modal .cancel {
  margin-top: 14px;
  width: 100%;
  background: transparent;
  border: 1px solid #444;
  color: var(--muted);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
}

/* Veto toast */
.veto-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--warn);
  border-radius: 12px;
  padding: 12px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.veto-toast.show { display: flex; }
.veto-toast .txt { font-size: 13px; }
.veto-toast .btn-veto {
  background: var(--warn);
  color: #000;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

/* History page */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-item .emoji { font-size: 24px; }
.history-item .meta { flex: 1; min-width: 0; }
.history-item .meta .cat { font-size: 14px; font-weight: 600; }
.history-item .meta .ts { font-size: 11px; color: var(--muted); }
.history-item .meta .loc { font-size: 11px; color: var(--info); margin-top: 2px; }
.history-item .meta .loc a { color: var(--info); text-decoration: none; }
