:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #0d9488;
  --accent-hover: #14b8a6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  line-height: 1.4;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
  padding-top: 8px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.15);
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 600;
  width: fit-content;
}

.badge.synced {
  color: var(--accent);
  background: rgba(13, 148, 136, 0.15);
}

.badge.offline {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.15);
}

.badge.error {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

.badge.syncing {
  color: var(--warn);
  background: rgba(245, 158, 11, 0.15);
}

.btn-sync {
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.btn-sync:active { opacity: 0.85; }
.btn-sync:disabled { opacity: 0.5; cursor: default; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.field { flex: 1; min-width: 0; }
.field-miles { flex: 0 0 110px; }

textarea,
input[type="text"],
input[type="date"],
input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input[type="date"],
input[type="number"] {
  min-height: auto;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 8px;
}

.preview {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(13, 148, 136, 0.12);
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.preview.show { display: block; }

.preview strong { color: var(--accent); }

.miles-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-appearance: none;
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.btn-primary:active { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  flex: 0 0 auto;
  min-width: 52px;
}

.btn-secondary:active { opacity: 0.85; }

.btn-secondary.listening {
  background: var(--danger);
  color: #fff;
}

section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 8px 0 10px;
  font-weight: 600;
}

.trip-list { list-style: none; }

.trip {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 14px 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.trip.swiping { transform: translateX(-72px); }

.trip-body { flex: 1; min-width: 0; }

.trip-route {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-word;
}

.trip-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trip-miles {
  color: var(--accent);
  font-weight: 600;
}

.trip-del {
  background: transparent;
  color: var(--danger);
  padding: 8px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
