/* ==========================================================================
   WanderBook iPhone PWA — Tactile Editorial Travel OS Design System
   Zero purple · Zero gradient text · Safe-Area Native Ergonomics · 16px Inputs
   ========================================================================== */

:root {
  --bg-outer: hsl(208, 22%, 91%);
  --bg-app: hsl(38, 28%, 96.5%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-subtle: hsl(36, 22%, 92.5%);
  --bg-elevated: hsl(38, 36%, 98.5%);
  --bg-header: hsla(38, 28%, 96.5%, 0.86);
  --bg-tabbar: hsla(0, 0%, 100%, 0.88);

  --text-primary: hsl(206, 32%, 13%);
  --text-secondary: hsl(206, 16%, 36%);
  --text-muted: hsl(206, 12%, 52%);

  /* Accents — Strictly zero purple */
  --accent: hsl(13, 68%, 44%);
  --accent-hover: hsl(13, 72%, 37%);
  --accent-soft: hsl(14, 65%, 94.5%);
  --accent-border: hsl(14, 48%, 80%);

  --spruce: hsl(158, 46%, 28%);
  --spruce-soft: hsl(156, 42%, 93%);
  --spruce-border: hsl(156, 35%, 77%);

  --fjord: hsl(202, 68%, 33%);
  --fjord-soft: hsl(202, 55%, 93.5%);
  --fjord-border: hsl(202, 42%, 78%);

  --amber: hsl(35, 82%, 37%);
  --amber-soft: hsl(37, 84%, 93.5%);
  --amber-border: hsl(36, 62%, 78%);

  --danger: hsl(4, 66%, 44%);
  --danger-soft: hsl(4, 72%, 95%);

  --border-subtle: hsl(35, 18%, 86.5%);
  --border-strong: hsl(35, 16%, 75%);
  --shadow-card: 0 2px 10px rgba(15, 28, 38, 0.045), 0 1px 2px rgba(15, 28, 38, 0.03);
  --shadow-sheet: 0 -10px 40px rgba(10, 20, 30, 0.22);

  --radius-sm: 10px;
  --radius-md: 15px;
  --radius-lg: 22px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Plus Jakarta Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg-outer: hsl(208, 30%, 5%);
  --bg-app: hsl(208, 25%, 8.8%);
  --bg-card: hsl(208, 22%, 13%);
  --bg-subtle: hsl(208, 19%, 17.5%);
  --bg-elevated: hsl(208, 21%, 15.2%);
  --bg-header: hsla(208, 25%, 8.8%, 0.86);
  --bg-tabbar: hsla(208, 22%, 12%, 0.9);

  --text-primary: hsl(38, 25%, 94.5%);
  --text-secondary: hsl(206, 14%, 73%);
  --text-muted: hsl(206, 11%, 54%);

  --accent: hsl(15, 78%, 59%);
  --accent-hover: hsl(15, 82%, 65%);
  --accent-soft: hsla(15, 72%, 52%, 0.15);
  --accent-border: hsla(15, 72%, 58%, 0.35);

  --spruce: hsl(156, 52%, 53%);
  --spruce-soft: hsla(156, 48%, 45%, 0.15);
  --spruce-border: hsla(156, 48%, 52%, 0.34);

  --fjord: hsl(200, 76%, 61%);
  --fjord-soft: hsla(200, 70%, 48%, 0.15);
  --fjord-border: hsla(200, 70%, 58%, 0.34);

  --amber: hsl(37, 86%, 61%);
  --amber-soft: hsla(37, 80%, 50%, 0.15);
  --amber-border: hsla(37, 80%, 58%, 0.34);

  --danger: hsl(4, 78%, 65%);
  --danger-soft: hsla(4, 70%, 50%, 0.16);

  --border-subtle: hsl(208, 17%, 20.5%);
  --border-strong: hsl(208, 15%, 29%);
  --shadow-card: 0 3px 14px rgba(0, 0, 0, 0.32);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-outer);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   iPhone App Shell (Full-bleed on Mobile, Framed Preview on Desktop)
   ========================================================================== */
.app-shell {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(78px + var(--safe-bottom));
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.14);
}

@media (max-width: 520px) {
  body {
    background-color: var(--bg-app);
  }
  .app-shell {
    max-width: 100%;
    box-shadow: none;
  }
}

/* ==========================================================================
   Sticky Native Top Header (Dynamic Island Safe-Area Aware)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(0.65rem + var(--safe-top)) 1rem 0.68rem;
  background: var(--bg-header);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.trip-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.42rem 0.85rem 0.42rem 0.65rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  max-width: 245px;
  box-shadow: var(--shadow-card);
  transition: transform 0.14s ease, border-color 0.18s ease;
}

.trip-switcher-btn:active {
  transform: scale(0.97);
}

.trip-switcher-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.status-dot-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.32rem 0.58rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.dot.online {
  background: var(--spruce);
}

.dot.offline {
  background: var(--amber);
}

.icon-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
}

.icon-circle-btn:active {
  transform: scale(0.94);
}

/* ==========================================================================
   Install to Home Screen Guide Banner (Shown in Safari Browser Mode)
   ========================================================================== */
.install-banner {
  margin: 0.75rem 1rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--fjord-soft);
  border: 1px solid var(--fjord-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.install-banner.hidden {
  display: none;
}

.install-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  cursor: pointer;
}

/* ==========================================================================
   Trip Hero Cover Card
   ========================================================================== */
.trip-hero-card {
  margin: 0.85rem 1rem 0.75rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.trip-cover-wrap {
  position: relative;
  height: 132px;
  background: hsl(208, 34%, 15%);
  overflow: hidden;
}

.trip-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.9;
}

.trip-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9, 19, 29, 0.84) 0%, rgba(9, 19, 29, 0.18) 65%);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
}

.trip-cover-Overlay-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.trip-hero-card h1 {
  margin: 0.12rem 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

.trip-meta-bar {
  padding: 0.62rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-card);
}

/* ==========================================================================
   Main View Container & Horizontal Scroll Pills
   ========================================================================== */
.view-main {
  padding: 0.2rem 1rem 1.2rem;
  flex: 1;
}

.pill-scroller {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
  scrollbar-width: none;
}

.pill-scroller::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.44rem 0.85rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--text-primary);
  color: var(--bg-card);
  border-color: var(--text-primary);
}

.pill-btn.accent-outline {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* ==========================================================================
   Section Action Bar & Cards
   ========================================================================== */
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.section-bar-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.btn-sm-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.44rem 0.88rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

[data-theme="dark"] .btn-sm-primary {
  color: hsl(208, 30%, 8%);
}

.btn-sm-primary:active {
  transform: scale(0.96);
}

/* Timeline Stop Card */
.timeline-list {
  display: grid;
  gap: 0.78rem;
}

.stop-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow-card);
}

.stop-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.stop-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.stop-time {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
}

.stop-cat {
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.stop-title {
  margin: 0 0 0.32rem;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.35;
}

.stop-addr {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  word-break: break-word;
}

.stop-note {
  margin: 0 0 0.75rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.52;
}

.map-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.45rem;
}

.map-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none;
  min-height: 40px;
  transition: transform 0.12s ease;
}

.map-btn:active {
  transform: scale(0.97);
}

.map-apple {
  background: var(--text-primary);
  color: var(--bg-card);
}

.map-google {
  background: var(--fjord-soft);
  color: var(--fjord);
  border: 1px solid var(--fjord-border);
}

.btn-ghost-del {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 40px;
}

/* ==========================================================================
   Tab 2: Synced Checklist
   ========================================================================== */
.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow-card);
}

.progress-track {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.45rem;
}

.progress-fill {
  height: 100%;
  background: var(--spruce);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.quick-add-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.input-control,
.select-control,
.textarea-control {
  width: 100%;
  padding: 0.64rem 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  /* CRITICAL: 16px prevents iOS Safari automatic viewport zoom on focus! */
  font-size: 16px;
}

.check-stack {
  display: grid;
  gap: 0.52rem;
}

.check-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.82rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  box-shadow: var(--shadow-card);
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  flex: 1;
  cursor: pointer;
}

.check-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 0.1rem;
  accent-color: var(--spruce);
  flex-shrink: 0;
}

.check-row.done .check-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.by-tag {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--spruce);
}

/* ==========================================================================
   Tab 3: Multi-Currency Splitwise Ledger
   ========================================================================== */
.settlement-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-card);
}

.settlement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.65rem 0;
}

.mini-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.settle-banner {
  padding: 0.62rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--spruce-soft);
  border: 1px solid var(--spruce-border);
  color: var(--spruce);
  font-size: 0.82rem;
  font-weight: 700;
}

.expense-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.78rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
  box-shadow: var(--shadow-card);
}

/* ==========================================================================
   Tab 4: Offline Confirmation & Pass Wallet
   ========================================================================== */
.wallet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow-card);
}

.wallet-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  margin-bottom: 0.45rem;
}

.wallet-code-box {
  margin: 0.5rem 0;
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ==========================================================================
   Bottom Frosted iOS Tab Bar
   ========================================================================== */
.ios-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 45;
  background: var(--bg-tabbar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  padding: 0.38rem 0.35rem calc(0.38rem + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 520px) {
  .ios-tabbar {
    max-width: 100%;
  }
}

.tab-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.25rem 0;
  font-family: inherit;
  font-size: 0.69rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: color 0.15s ease, transform 0.12s ease;
}

.tab-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.9;
}

.tab-item.active {
  color: var(--accent);
}

.tab-item:active {
  transform: scale(0.92);
}

/* ==========================================================================
   Slide-Up Native Bottom Sheet Modal & Toast
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 16, 24, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet-panel {
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 22px 22px 0 0;
  padding: 0.85rem 1.15rem calc(1.4rem + var(--safe-bottom));
  box-shadow: var(--shadow-sheet);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-backdrop.open .sheet-panel {
  transform: translateY(0);
}

.sheet-handle {
  width: 38px;
  height: 4.5px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 0.85rem;
}

.form-field {
  margin-bottom: 0.85rem;
}

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.32rem;
  color: var(--text-secondary);
}

.btn-block {
  width: 100%;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

[data-theme="dark"] .btn-block {
  color: hsl(208, 30%, 8%);
}

.toast {
  position: fixed;
  top: calc(4.2rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 95;
  background: hsl(206, 32%, 14%);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}

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