:root {
  --brand: #0f4c81;
  --brand-light: #1a6fb8;
  --accent: #f0a500;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c1f26;
  --text-dim: #6b7280;
  --border: #e5e7eb;
  --success: #1e9e5a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- loading / auth ---------- */

.spinner {
  margin: auto;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  gap: 20px;
}

.auth-hero {
  text-align: center;
  margin-bottom: 8px;
}
.auth-hero .emoji { font-size: 44px; }
.auth-hero h1 {
  font-size: 26px;
  margin: 8px 0 4px;
  color: var(--brand);
}
.auth-hero p {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.field input, .field select {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--brand-light);
  outline-offset: -1px;
}

.btn {
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-light); }
.btn-secondary { background: var(--surface); color: var(--brand); border: 1px solid var(--border); }
.btn-text { background: none; color: var(--brand); font-weight: 600; padding: 8px; }
.btn:disabled { opacity: 0.55; }

.error-msg {
  background: #fdecea;
  color: #b3261e;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.success-msg {
  background: #e7f6ec;
  color: var(--success);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- onboarding ---------- */

.onboard-header {
  padding: 24px 20px 12px;
}
.onboard-header h1 { font-size: 22px; margin: 0 0 4px; color: var(--brand); }
.onboard-header p { color: var(--text-dim); font-size: 14px; margin: 0; }

.onboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 100px;
}

.resort-pick {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.resort-pick label { display: flex; align-items: center; gap: 10px; font-size: 14px; flex: 1; }

.favorite-row-name { flex: 1; font-size: 14px; font-weight: 600; }
.reorder-btns { display: flex; gap: 4px; margin-right: 8px; }
.reorder-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  width: 28px; height: 28px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
}
.reorder-btn:disabled { opacity: 0.3; cursor: default; }
.reorder-remove {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
}

.onboard-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- main app shell ---------- */

.main-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: var(--safe-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mode-toggle {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 3px;
}
.mode-toggle-btn {
  border: none;
  background: none;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.mode-toggle-btn.active {
  background: #fff;
  color: var(--brand);
}
.topbar .icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

/* On phones the four nowrap mode buttons plus the profile button are wider
   than the screen, which makes mobile browsers stretch the whole page past
   the viewport (looks zoomed-out, profile button off the right edge). Keep
   the header inside the viewport: tighter buttons, and if it's still too
   narrow (very small phones), the pill scrolls sideways instead. */
@media (max-width: 480px) {
  .topbar { padding: 12px 10px; gap: 8px; }
  .mode-toggle { min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
  .mode-toggle::-webkit-scrollbar { display: none; }
  .mode-toggle-btn { padding: 7px 8px; font-size: 12px; flex: 0 0 auto; }
  .topbar .icon-btn { flex-shrink: 0; width: 32px; height: 32px; }
}

.tab-content { flex: 1; padding: 12px 14px 24px; }

/* ---------- home / progress ---------- */

.progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.progress-tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}
.progress-tile-clickable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.progress-tile-clickable:active { background: var(--bg); }
.progress-tile .label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.progress-tile .pct-row { display: flex; align-items: baseline; gap: 6px; }
.progress-tile .pct-big { font-size: 24px; font-weight: 700; color: var(--brand); }
.progress-tile .count-small { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.bar-track { height: 6px; border-radius: 3px; background: var(--border); margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

.progress-tile-hero {
  grid-column: 1 / -1;
  background: var(--brand);
  border-color: var(--brand);
}
.progress-tile-hero .label { color: rgba(255,255,255,0.75); }
.progress-tile-hero .pct-big { color: #fff; font-size: 32px; }
.progress-tile-hero .count-small { color: rgba(255,255,255,0.75); }
.progress-tile-hero .bar-track { background: rgba(255,255,255,0.25); }
.progress-tile-hero .bar-fill { background: var(--accent); }


.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 18px 0 8px; }
.destination-header {
  font-size: 16px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--brand);
  padding: 4px 0;
  border-radius: 8px;
}

/* ---------- explore ---------- */

.filter-section { margin-bottom: 16px; }
.filter-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.filter-group-title { font-size: 13px; font-weight: 700; color: var(--text); }
.filter-hint { font-size: 11px; font-weight: 400; color: var(--text-dim); text-transform: none; }
.select-all-btn {
  border: none;
  background: none;
  color: var(--brand);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 2px 0;
}
.filter-chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
}
.filter-chip-row::-webkit-scrollbar { display: none; }
.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
  white-space: nowrap;
}
.filter-chip.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f1f3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.item-row:last-child { border-bottom: none; }
.item-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--brand);
  flex-shrink: 0;
}
.item-row .item-name { font-size: 14px; flex: 1; }
.item-row.checked { background: rgba(30, 158, 90, 0.08); margin: 0 -14px; padding: 9px 14px; border-radius: 8px; }
.item-row.checked .item-name { font-weight: 700; color: var(--success); }
.item-chevron { color: var(--text-dim); font-size: 16px; flex-shrink: 0; }

.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 16px;
  margin-top: 8px;
}
.detail-eyebrow { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.detail-title { font-size: 20px; margin: 0 0 10px; color: var(--text); }
.detail-blurb { font-size: 14px; line-height: 1.5; margin: 12px 0 0; color: var(--text); }

.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.achievement-card-header { display: flex; align-items: center; gap: 8px; }
.achievement-medal { font-size: 22px; line-height: 1; }
.achievement-title { font-weight: 700; font-size: 14px; color: var(--text); }
.achievement-desc { font-size: 13px; color: var(--text-dim); margin: 4px 0 0; }
.achievement-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

.achievement-card-compact { padding: 8px 10px; }
.achievement-card-compact .achievement-medal { font-size: 16px; }
.achievement-card-compact .achievement-title { font-size: 13px; }
.achievement-card-compact .achievement-desc { font-size: 12px; margin-top: 2px; }
.achievement-card-compact .achievement-meta { font-size: 11px; margin-top: 4px; }

.achievement-item-list { margin-bottom: 8px; }
.achievement-item-row {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
}
.detail-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
}
.detail-checkbox-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--brand);
  flex-shrink: 0;
}

.rating-widget {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-dim);
}
.rating-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rating-row:last-child { margin-bottom: 0; }
.rating-label { min-width: 90px; font-size: 13px; color: var(--text-dim); }
.rating-meta { font-size: 13px; color: var(--text-dim); }
.stars { font-size: 20px; letter-spacing: 2px; }
.stars .star { color: var(--border); }
.stars .star.filled { color: #f5a623; }
.stars.interactive .star { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.flat-list { padding-top: 4px; }

.badge {
  font-size: 11px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--text-dim);
}
.badge-pct {
  background: rgba(30, 158, 90, 0.12);
  color: var(--success);
  font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 40px 20px;
}

/* ---------- profile ---------- */

.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 14px;
}
.profile-card .email { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.profile-card .meta { font-size: 12px; color: var(--text-dim); }

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.settings-row:last-child { border-bottom: none; }
