/* ── App Container ──────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 720px;
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

@media (min-width: 760px) {
  body { background: var(--bg2); }
  #app { box-shadow: 0 0 0 1px var(--border); }
}

/* ── Page System ────────────────────────────────────────── */
.page {
  position: absolute;
  inset: 0;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  transform: translateX(100%);
  opacity: 0;
  transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
  z-index: 1;
  padding-bottom: calc(132px + env(safe-area-inset-bottom, 20px));
}
.page:focus { outline: none; }
.page.active {
  transform: translateX(0);
  opacity: 1;
  z-index: 2;
}
.page.exit-left {
  transform: translateX(-30%);
  opacity: .4;
}

body.onboarding-active .bottom-nav { display: none; }
body.tour-active { overflow: hidden; }

/* Guided app tour */
.app-tour {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: auto;
}
.tour-scrim {
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 20, .68);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.tour-highlight {
  position: fixed;
  border: 2px solid #F4F46D;
  border-radius: 26px;
  box-shadow: 0 0 0 9999px rgba(6, 12, 20, .62), 0 0 0 8px rgba(244,244,109,.16);
  transition: left .24s var(--ease), top .24s var(--ease), width .24s var(--ease), height .24s var(--ease);
  pointer-events: none;
}
.tour-card {
  position: fixed;
  width: min(340px, calc(100vw - 32px));
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: #FFFFFF;
  color: #111827;
  box-shadow: 0 22px 60px rgba(0,0,0,.28);
  transition: left .24s var(--ease), top .24s var(--ease);
}
.tour-step {
  margin-bottom: var(--sp-2);
  color: #111827;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
}
.tour-card h2 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-md);
  line-height: var(--lh-tight);
}
.tour-card p {
  color: #111827;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.tour-skip,
.tour-next {
  min-height: 40px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.tour-skip { color: var(--hint); background: var(--bg2); }
.tour-next { color: #FFFFFF; background: var(--btn-bg); }

/* Bottom app navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  width: min(520px, calc(100vw - 32px));
  height: 76px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  padding: 8px 12px;
  border-radius: 30px;
  background: #252625;
  color: #787b7a;
  box-shadow: 0 18px 48px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.08);
  transform: translateX(-50%);
}
.bottom-nav-item {
  min-width: 0;
  min-height: 56px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 22px;
  color: inherit;
  transition: color .18s var(--ease), background .18s var(--ease), transform .14s var(--ease);
}
.bottom-nav-item:active { transform: scale(.96); }
.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bottom-nav-item svg path { vector-effect: non-scaling-stroke; }
.bottom-nav-item span {
  font-size: 10px;
  line-height: 1;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
.bottom-nav-item.is-active {
  color: #FFFFFF;
  background: rgba(255,255,255,.06);
}
.bottom-nav-ai.is-active { color: #F4F46D; }

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.page-header h1 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  flex: 1;
}
.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  color: var(--text);
  transition: background var(--duration) var(--ease);
}
.back-btn:active { background: var(--bg2); }
.back-btn svg { width: 20px; height: 20px; }

/* ── Typography ─────────────────────────────────────────── */
.t-xs { font-size: var(--fs-xs); }
.t-sm { font-size: var(--fs-sm); }
.t-base { font-size: var(--fs-base); }
.t-md { font-size: var(--fs-md); }
.t-lg { font-size: var(--fs-lg); }
.t-xl { font-size: var(--fs-xl); }
.t-2xl { font-size: var(--fs-2xl); }
.t-light { font-weight: var(--fw-light); }
.t-medium { font-weight: var(--fw-medium); }
.t-semibold { font-weight: var(--fw-semibold); }
.t-bold { font-weight: var(--fw-bold); }
.t-hint { color: var(--hint); }
.t-center { text-align: center; }

/* ── Spacing Helpers ────────────────────────────────────── */
.pad { padding: var(--sp-5); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

