/* === Design Tokens === */
:root {
  --bg: #0a0f1a;
  --surface: #111827;
  --surface-alt: #1a2332;
  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(148, 163, 184, 0.18);
  --border-active: rgba(125, 211, 252, 0.3);
  --text: #f1f5f9;
  --text-mid: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #7dd3fc;
  --accent-dim: rgba(125, 211, 252, 0.1);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.1);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.1);
  --rose: #fb7185;
  --rose-dim: rgba(251, 113, 133, 0.1);
  --r: 14px;
  --r-sm: 10px;
  --r-xs: 7px;
  --nav-h: 58px;
  --top-h: 48px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.04);
  font-size: 15px;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--border-active); }
textarea { resize: vertical; min-height: 72px; }

/* === App Shell === */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* === Top Bar === */
.topbar {
  flex-shrink: 0;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.trip-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.12s;
}
.trip-switcher:active { background: rgba(148, 163, 184, 0.1); }
.trip-switcher svg { color: var(--text-muted); flex-shrink: 0; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.planning { background: var(--accent); }
.status-dot.booked { background: var(--green); }
.status-dot.in-progress { background: var(--amber); }
.status-dot.completed { background: var(--text-faint); }

/* === Tab Panels === */
.panels {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 16px;
  padding-bottom: 24px;
  display: none;
  flex-direction: column;
  gap: 20px;
}
.panel.active { display: flex; }
.panel::-webkit-scrollbar { display: none; }
.panel { scrollbar-width: none; }

/* === Bottom Nav === */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.12s;
  position: relative;
  min-height: 44px;
}
.tab-btn.active { color: var(--accent); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}
.tab-btn svg { width: 22px; height: 22px; margin-bottom: 1px; }

/* === Hero Card === */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 20px;
  text-align: center;
}
.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 10px;
}
.hero-card[data-status="booked"] .hero-eyebrow { color: var(--green); }
.hero-card[data-status="in-progress"] .hero-eyebrow { color: var(--amber); }
.hero-card[data-status="completed"] .hero-eyebrow { color: var(--text-faint); }
.hero-title { font-size: 22px; font-weight: 800; line-height: 1.15; margin-bottom: 4px; }
.hero-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }
.hero-footer { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.countdown-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--accent-dim);
  border: 1px solid rgba(125, 211, 252, 0.15);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.hero-dates { color: var(--text-muted); font-size: 13px; font-weight: 500; }

/* === Stats === */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 10px;
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* === Section Headers === */
h3 { font-size: 16px; font-weight: 700; }
.section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-row h3 { margin: 0; }
.count-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.link-btn {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.link-btn:active { opacity: 0.7; }

/* === Card Stack === */
.card-stack { display: flex; flex-direction: column; gap: 10px; }

/* === Detail List === */
.detail-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 13px 14px;
  background: var(--surface);
}
.detail-item + .detail-item { border-top: 1px solid var(--border); }
.detail-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.detail-value {
  font-size: 14px;
  text-align: right;
  color: var(--text-mid);
  word-break: break-word;
}

/* === Filter Chips === */
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.12s;
}
.filter-chip:active { transform: scale(0.96); }
.filter-chip.active {
  color: var(--accent);
  border-color: var(--border-active);
  background: var(--accent-dim);
}

/* === Decision Cards === */
.decision-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.decision-question { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 10px; }
.decision-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.cat { background: rgba(148, 163, 184, 0.08); color: var(--text-muted); }
.badge.priority-high { background: var(--amber-dim); color: var(--amber); }
.badge.priority-medium { background: var(--accent-dim); color: var(--accent); }
.badge.priority-low { background: var(--green-dim); color: var(--green); }

.option-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.option-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: rgba(148, 163, 184, 0.02);
}
.option-item.chosen {
  border-color: rgba(52, 211, 153, 0.25);
  background: var(--green-dim);
}
.option-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.option-detail { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

/* === Timeline === */
.timeline-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  border-left: 3px solid var(--accent);
}
.day-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.day-date { font-weight: 700; font-size: 15px; }
.day-location { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.day-items { display: flex; flex-direction: column; gap: 6px; }
.day-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  background: rgba(148, 163, 184, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.06);
  font-size: 14px;
}
.day-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  min-width: 52px;
}
.day-activity { flex: 1; }
.day-booking {
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.day-booking.booked { color: var(--green); }
.day-booking.pending { color: var(--text-faint); }

/* === Alerts === */
.alert-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.45;
}
.alert-card.high { border-left: 3px solid var(--rose); }
.alert-card.medium { border-left: 3px solid var(--amber); }
.alert-card.low { border-left: 3px solid var(--text-faint); }
.alert-severity {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.alert-card.high .alert-severity { color: var(--rose); }
.alert-card.medium .alert-severity { color: var(--amber); }
.alert-card.low .alert-severity { color: var(--text-faint); }

/* === Preferences === */
.pref-group { margin-bottom: 14px; }
.pref-group:last-child { margin-bottom: 0; }
.pref-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 7px;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* === Research Log === */
.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
}
.log-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.log-topic { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.log-findings { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* === Forms === */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.add-form.hidden { display: none; }
.form-inline { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn-primary, .btn-sm {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 12px 20px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 15px;
  min-height: 44px;
  transition: opacity 0.12s;
}
.btn-primary:active, .btn-sm:active { opacity: 0.8; }
.btn-sm { padding: 12px 18px; font-size: 14px; }
.full-w { width: 100%; }

/* === Empty State === */
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.12);
  border-radius: var(--r-sm);
}

/* === Welcome (no trips) === */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  flex: 1;
}
.welcome h2 { font-size: 24px; margin-bottom: 8px; }
.welcome p { color: var(--text-muted); margin-bottom: 24px; }

/* === Bottom Sheet === */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 51;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85dvh;
  max-height: 85vh;
  overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet::-webkit-scrollbar { display: none; }
.sheet { scrollbar-width: none; }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  margin: 6px auto 18px;
}
.sheet-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.sheet-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.sheet-divider { height: 1px; background: var(--border); margin: 18px 0; }

.sheet-trip {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(148, 163, 184, 0.02);
  width: 100%;
  text-align: left;
  min-height: 44px;
  transition: background 0.12s;
}
.sheet-trip:active { background: rgba(148, 163, 184, 0.06); }
.sheet-trip.active { border-color: var(--border-active); background: var(--accent-dim); }
.sheet-trip-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.sheet-trip-meta { font-size: 13px; color: var(--text-muted); }

.new-trip-form { display: flex; flex-direction: column; gap: 10px; }

/* === Desktop === */
@media (min-width: 768px) {
  body { display: flex; justify-content: center; background: #050810; }
  .app {
    max-width: 520px;
    width: 100%;
    box-shadow: 0 0 120px rgba(125, 211, 252, 0.03), 0 0 1px rgba(148, 163, 184, 0.15);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .sheet { max-width: 520px; left: 50%; transform: translateX(-50%) translateY(100%); }
  .sheet-backdrop.open .sheet { transform: translateX(-50%) translateY(0); }
}
