/* ============ Apple HIG dark theme ============ */
:root {
  /* Backgrounds (iOS grouped layers) */
  --bg: #000000;
  --bg-grouped: #1c1c1e;
  --bg-elevated: #2c2c2e;
  --bg-tertiary: #3a3a3c;

  /* Text (iOS opacity-tiered) */
  --text: #ffffff;
  --text-2: rgba(235, 235, 245, 0.60);
  --text-3: rgba(235, 235, 245, 0.30);

  /* Separators */
  --sep: rgba(84, 84, 88, 0.65);
  --sep-opaque: #38383a;

  /* System colors (iOS 17+) */
  --blue: #0a84ff;
  --blue-dim: rgba(10, 132, 255, 0.15);
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --yellow: #ffd60a;
  --purple: #bf5af2;
  --pink: #ff375f;
  --teal: #64d2ff;
  --indigo: #5e5ce6;

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;

  /* Blur */
  --blur: saturate(180%) blur(20px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overscroll-behavior: none;
  font-size: 17px;
  line-height: 1.42;
  letter-spacing: -0.022em;
}
body { display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; -webkit-appearance: none; appearance: none; }
input, textarea, select { font-family: inherit; -webkit-appearance: none; }

/* ============ HOME PAGE ============ */
.home-body {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.home-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.home-hero {
  text-align: center;
  padding: 16px 8px 0;
}
.home-logo {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 24px rgba(10, 132, 255, 0.4));
}
.home-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.037em;
  line-height: 1.1;
  color: var(--text);
}
.home-subtitle {
  color: var(--text-2);
  font-size: 15px;
  margin-top: 8px;
  line-height: 1.4;
  font-weight: 400;
}

/* ============ iOS-style FORM ============ */
.home-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  padding-left: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* iOS grouped input */
.field input {
  background: var(--bg-grouped);
  border: none;
  color: var(--text);
  font-size: 17px;
  font-weight: 400;
  padding: 14px 16px;
  border-radius: var(--r-md);
  outline: none;
  min-height: 50px;
  transition: background 0.15s;
}
.field input::placeholder { color: var(--text-3); font-weight: 400; }
.field input:focus { background: var(--bg-elevated); }

/* iOS segmented / chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--bg-grouped);
  border: none;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip:active { transform: scale(0.94); }
.chip.active {
  background: var(--blue);
  color: #fff;
}

/* Chunky iOS primary button */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 16px;
  border-radius: var(--r-md);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 52px;
  margin-top: 12px;
  letter-spacing: -0.01em;
}
.btn-primary:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Recent plans — iOS grouped list */
.home-recent { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.home-recent h2 {
  font-size: 22px;
  font-weight: 700;
  padding-left: 4px;
  letter-spacing: -0.026em;
}
.recent-list {
  background: var(--bg-grouped);
  border-radius: var(--r-md);
  overflow: hidden;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 0.5px solid var(--sep);
  transition: background 0.1s;
}
.recent-item:first-child { border-top: none; }
.recent-item:active { background: var(--bg-elevated); }
.recent-item-body { flex: 1; min-width: 0; }
.recent-item-title { font-size: 17px; font-weight: 500; letter-spacing: -0.015em; }
.recent-item-meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.recent-item-arrow { color: var(--text-3); font-size: 22px; font-weight: 300; line-height: 1; }

.home-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
  padding-top: 20px;
}
.home-footer a { color: var(--blue); font-weight: 500; }

/* ============ PLAN PAGE ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 0.5px solid var(--sep);
  padding-top: env(safe-area-inset-top, 0);
}
.header-top { padding: 14px 16px 10px; }
.header-top h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.026em;
  min-height: 26px;
}
.header-top p {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 3px;
  min-height: 16px;
  font-weight: 400;
}

/* iOS segmented control for tabs */
.tabs {
  display: flex;
  padding: 6px 12px 10px;
  gap: 4px;
  background: rgba(118, 118, 128, 0.16);
  margin: 0 12px 8px;
  border-radius: 9px;
  padding: 3px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  letter-spacing: -0.01em;
}
.tab .tab-icon { display: none; }
.tab.active {
  background: rgba(99, 99, 102, 0.9);
  color: var(--text);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.content {
  flex: 1;
  padding: 8px 16px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0));
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: iosSlide 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes iosSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-grouped) 0%, var(--bg-elevated) 50%, var(--bg-grouped) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.skeleton-card { height: 120px; }
@keyframes shimmer {
  0% { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}

/* Section headers (iOS style) */
.section-title {
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  letter-spacing: -0.026em;
  padding: 8px 4px 0;
}
.section-title.accent { color: var(--blue); }
.section-title.danger { color: var(--red); }

/* iOS grouped card / row */
.card {
  background: var(--bg-grouped);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.card-accent {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.16), rgba(10, 132, 255, 0.04));
  border: 0.5px solid rgba(10, 132, 255, 0.35);
}
.card-danger {
  background: linear-gradient(135deg, rgba(255, 69, 58, 0.12), rgba(255, 69, 58, 0.03));
  border: 0.5px solid rgba(255, 69, 58, 0.3);
}

/* Day section */
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.day-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.023em;
}
.day-cost {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-elevated);
  padding: 4px 10px;
  border-radius: 999px;
}
.day-district {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.day-note {
  font-size: 15px;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 14px;
  letter-spacing: -0.014em;
}

.place-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-elevated);
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-top: 8px;
}
.place-item-icon { font-size: 24px; flex-shrink: 0; line-height: 1; }
.place-item-body { flex: 1; min-width: 0; }
.place-item-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.015em;
}
.place-item-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.place-item-tip {
  font-size: 12px;
  color: var(--blue);
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--blue-dim);
  border-radius: 8px;
  line-height: 1.4;
  font-weight: 500;
}
.place-item-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

/* Place card (Places tab) — hero photo iOS style */
.place-card {
  display: block;
  background: var(--bg-grouped);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 16px;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.place-card:active { transform: scale(0.98); }
.place-card-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}
.place-card-photo.grad-1 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.place-card-photo.grad-2 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.place-card-photo.grad-3 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.place-card-photo.grad-4 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.place-card-photo.grad-5 { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.place-card-photo.grad-6 { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }
.place-card-photo.grad-7 { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.place-card-photo.grad-8 { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); }
.place-card-photo-icon {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.5));
  transition: opacity 0.3s;
}
.place-card-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.place-card-photo img.loaded { opacity: 1; }
.place-card-photo img.loaded ~ .place-card-photo-icon { opacity: 0; }
.place-card-photo-play {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s;
  padding-left: 3px;
}
.place-card-photo-play:active { transform: scale(0.9); }
.place-card-video { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.place-card-video iframe { width: 100%; height: 100%; border: 0; display: block; }

.place-card-content { padding: 16px; }
.place-card-name {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.023em;
  line-height: 1.2;
}
.place-card-addr {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
  font-weight: 500;
}
.place-card-desc {
  font-size: 15px;
  color: var(--text);
  line-height: 1.45;
  margin-top: 10px;
  letter-spacing: -0.014em;
}
.place-card-tip {
  font-size: 13px;
  color: var(--blue);
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--blue-dim);
  border-radius: var(--r-sm);
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-weight: 500;
  line-height: 1.4;
}
.place-card-meta {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
  font-weight: 500;
}
.place-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.place-action {
  flex: 1;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  transition: all 0.1s;
  letter-spacing: -0.01em;
}
.place-action:active { transform: scale(0.96); opacity: 0.7; }
.place-action.primary {
  background: var(--blue);
  color: #fff;
}

/* Section lists */
.section-list { list-style: none; padding: 0; }
.section-list li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 15px;
  color: var(--text);
  line-height: 1.45;
  letter-spacing: -0.014em;
}
.section-list li::before {
  content: "•";
  flex-shrink: 0;
  font-weight: 700;
}
.section-list.accent li::before { color: var(--blue); }
.section-list.danger li::before { color: var(--red); }

/* Summary */
.summary-card {
  background: var(--bg-grouped);
  border-radius: var(--r-xl);
  padding: 18px;
  margin-bottom: 16px;
}
.summary-card p {
  font-size: 16px;
  color: var(--text);
  line-height: 1.45;
  letter-spacing: -0.017em;
}

/* Budget — iOS grouped list */
.budget-row {
  background: var(--bg-grouped);
  padding: 14px 16px;
  margin: 0;
  border-top: 0.5px solid var(--sep);
}
.budget-row:first-child { border-top: none; border-radius: var(--r-md) var(--r-md) 0 0; }
.budget-row:last-child { border-radius: 0 0 var(--r-md) var(--r-md); }
.budget-row.total {
  background: var(--blue-dim);
  border-top: 0.5px solid rgba(10, 132, 255, 0.4);
  margin-top: 8px;
  border-radius: var(--r-md);
}
.budget-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.budget-row-name {
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.017em;
}
.budget-row-amount {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-2);
}
.budget-row.total .budget-row-name {
  color: var(--blue);
  font-size: 17px;
  font-weight: 700;
}
.budget-row.total .budget-row-amount {
  color: var(--blue);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.023em;
}
.budget-row-note {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

/* Practical — grouped list */
.practical-card {
  background: var(--bg-grouped);
  padding: 16px;
  margin: 0;
  border-top: 0.5px solid var(--sep);
}
.practical-card:first-child { border-top: none; border-radius: var(--r-md) var(--r-md) 0 0; }
.practical-card:last-child { border-radius: 0 0 var(--r-md) var(--r-md); }
.practical-title {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.practical-title-icon { font-size: 22px; }
.practical-content {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.45;
  margin-top: 8px;
  letter-spacing: -0.014em;
}

/* Error banner — iOS toast */
.error-banner {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  left: 16px;
  right: 16px;
  background: rgba(255, 69, 58, 0.22);
  border: 0.5px solid rgba(255, 69, 58, 0.5);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-size: 15px;
  text-align: center;
  z-index: 100;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: slideUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-weight: 500;
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Pending / loader */
.pending-hero {
  padding: 40px 16px;
  text-align: center;
}
.loader-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--blue);
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
