/* =====================================================================
   app-shell.css — yoyes new mobile-first shell
   Stage 0: design tokens + shell layout + bottom nav + components +
            auth modals + toast
   Single file for the first cut; can be split later if it grows.
   ===================================================================== */

/* ----- 1. Design tokens ----- */
:root {
  /* Surfaces */
  --bg: #050507;
  --bg-elev-0: #0d0d10;
  --bg-elev-1: #15151a;
  --bg-elev-2: #1f1f25;
  --bg-elev-3: #2a2a31;
  --border: #2d2d33;
  --border-soft: rgba(255, 255, 255, 0.08);

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #b6b6c1;
  --text-muted: #7c7c87;

  /* Brand accents */
  --pink: #ff4d8a;
  --pink-strong: #ff2e93;
  --magenta: #c026d3;
  --cyan: #22d3ee;
  --purple: #8b5cf6;
  --yellow: #ffd60a;
  --green: #34d399;
  --orange: #ff9f45;
  --red: #ef4444;

  /* Gradients (used by CTA / cards / icons) */
  --grad-primary: linear-gradient(90deg, #5cffd1 0%, #ff4d8a 50%, #b45cff 100%);
  --grad-magenta: linear-gradient(135deg, #ff52b1 0%, #b45cff 100%);
  --grad-warm: linear-gradient(135deg, #ffb347 0%, #ff5e8b 50%, #b45cff 100%);
  --grad-pink-yellow: linear-gradient(90deg, #ff4d8a 0%, #ffd60a 100%);
  --grad-install: linear-gradient(90deg, #ffd60a 0%, #34d399 100%);

  /* Radii */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-1: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 10px 28px rgba(0, 0, 0, 0.55);

  /* Layout */
  --nav-h: 64px;
  --shell-max: 480px;

  /* Safe-area */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ----- 2. Resets / globals ----- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body {
  /* PC: app shell centered, sides go dark with subtle vertical gradient */
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(180, 92, 255, 0.10), transparent 60%),
    radial-gradient(800px 600px at 50% 110%, rgba(255, 77, 138, 0.08), transparent 70%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img, video { display: block; max-width: 100%; }

/* Hide all old chrome inside the new shell (defensive) */
.app-shell nav.navbar,
.app-shell .mobile-menu,
.app-shell footer.site-footer { display: none !important; }

/* ----- 3. App shell ----- */
.app-shell {
  position: relative;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-elev-0);
  display: flex;
  flex-direction: column;
}

/* PC adaptation — keep the mobile layout order and per-page CSS intact,
   just widen the centered column from 480 → 720 so desktop visitors
   don't see a narrow phone-frame floating in the middle of a 1920 px
   viewport. Bottom nav widens in lockstep so it stays aligned with the
   shell chrome instead of becoming a smaller pill below it.
   Modals / promos that read --shell-max directly stay 480-wide on
   purpose (they look better as tight overlays). */
@media (min-width: 768px) {
  .app-shell {
    max-width: 720px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }
  .bottom-nav {
    max-width: 720px;
  }
}

/* Touch phones (Huawei Edge “desktop site”) still get the 480px phone column
   even when the browser reports a 768px+ layout width. */
@media (min-width: 768px) and (hover: none) and (pointer: coarse) {
  .app-shell,
  .bottom-nav {
    max-width: var(--shell-max);
    box-shadow: none;
  }
}

/* Main scroll area – sits between optional header and bottom nav */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  min-height: 0;
}

/* Variant: full-screen immersive (Feed pages). Nav still floats on top. */
.app-shell.is-fullscreen {
  max-width: none;
  background: #000;
}
.app-shell.is-fullscreen .app-main {
  padding-bottom: 0;
}

/* ----- 4. Generic page padding helpers ----- */
.page-pad { padding: 16px 16px 24px; }
.page-pad-x { padding-left: 16px; padding-right: 16px; }
.page-title { font-size: 1.5rem; font-weight: 800; margin: 4px 0 12px; }

/* ----- 5. Bottom navigation ----- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--shell-max);
  background: rgba(13, 13, 16, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-soft);
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}

.bottom-nav__list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
  margin: 0;
  padding: 0;
  height: var(--nav-h);
}

.bottom-nav__item {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.bottom-nav__item + .bottom-nav__item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.bottom-nav__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

.bottom-nav__link:hover { color: #fff; }

.bottom-nav__icon {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav__icon--filled {
  fill: currentColor;
  stroke: none;
}

.bottom-nav__link.is-active {
  color: var(--pink);
}

/* ----- 6. Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--bg-elev-2);
  color: var(--text-primary);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--block { width: 100%; }
.btn--lg { padding: 14px 22px; font-size: 1rem; }
.btn--sm { padding: 6px 14px; font-size: 0.82rem; }

.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--dark { background: #111114; color: #fff; }
.btn--yellow { background: var(--yellow); color: #1a1408; }
.btn--danger { background: var(--red); color: #fff; }
.btn--primary {
  background: var(--grad-primary);
  color: #0a0a0d;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.btn--magenta { background: var(--grad-magenta); color: #fff; font-weight: 700; }
.btn--warm { background: var(--grad-warm); color: #fff; font-weight: 700; }

/* ----- 6.5 Tier badge (一致复用，关联 /price 卡片视觉) ----- */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  vertical-align: middle;
}
.tier-badge .tier-badge__icon { font-size: 0.9em; line-height: 1; }
.tier-badge--basic {
  color: rgba(220, 220, 230, 0.95);
  background: rgba(168, 168, 180, 0.12);
  border-color: rgba(168, 168, 180, 0.32);
}
.tier-badge--premium {
  color: var(--yellow);
  background: rgba(255, 214, 10, 0.10);
  border-color: rgba(255, 214, 10, 0.40);
}
.tier-badge--deluxe {
  color: #ffb347;
  background: rgba(255, 138, 0, 0.10);
  border-color: rgba(255, 138, 0, 0.45);
}
.tier-badge--ultimate {
  color: #6edcff;
  background: rgba(110, 220, 255, 0.10);
  border-color: rgba(110, 220, 255, 0.45);
}

/* ----- 7. Cards ----- */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  overflow: hidden;
}

.card--soft { background: var(--bg-elev-2); border-color: transparent; }

/* ----- 8. Inputs ----- */
.input,
.textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--r-2);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .textarea:focus { border-color: var(--pink); background: var(--bg-elev-3); }
.textarea { resize: vertical; min-height: 80px; }

/* ----- 9. Top bars / sub tabs ----- */
.subtabs {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--bg-elev-0) 0%, var(--bg-elev-0) 88%, transparent 100%);
}

.subtabs__item {
  position: relative;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 6px 4px;
  transition: color 0.15s ease;
}
.subtabs__item.is-active { color: var(--text-primary); }
.subtabs__item.is-active::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--text-primary);
}

.top-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 40;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ----- 10. App promo bar (Install Our App + reward badge inside) ----- */
.app-promo {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--yellow);
  color: #1a1408;
  border-radius: var(--r-pill);
  padding: 5px 6px 5px 6px;
  text-decoration: none;
  font-weight: 800;
}
.app-promo.is-visible {
  display: flex;
}
.app-promo__main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
/* Brand "Y" tile — mirrors the black-square X icon in the reference */
.app-promo__brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0d0d10;
  color: var(--pink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  line-height: 1;
}
.app-promo__reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0d0d10;
  color: var(--green);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

/* ----- 11. Modals (shared) ----- */
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.app-modal.is-open { display: flex; }
.app-modal__box {
  width: 100%;
  max-width: 320px;
  background: rgba(38, 38, 45, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-2);
  text-align: center;
}
.app-modal__title {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.app-modal__title--yellow { color: var(--yellow); }
.app-modal__body {
  color: var(--text-secondary);
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.app-modal__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.app-modal__actions .btn {
  flex: 1;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 700;
}

/* ----- 12. Auth modal (legacy DOM ids preserved for auth.js) ----- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 10120; /* above outfit sheet / result / progress modals */
  align-items: center;
  justify-content: center;
}
.modal[style*="display: block"],
.modal[style*="display:block"] { display: flex !important; }

.modal .modal-content {
  position: relative;
  width: calc(100% - 32px);
  max-width: 400px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 22px;
  color: var(--text-primary);
  max-height: 92vh;
  overflow-y: auto;
}
.modal .close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 26px;
  cursor: pointer;
  color: var(--text-muted);
}
.modal h2 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.25rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.modal .modal-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 18px;
  font-size: 0.86rem;
}

.modal .social-login { margin-bottom: 14px; }
.modal .social-buttons { display: flex; gap: 10px; }
.modal .social-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--r-2);
  font-weight: 600;
  font-size: 0.92rem;
}
.modal .divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 12px 0 10px;
}
.modal .divider::before,
.modal .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.modal .divider span { padding: 0 12px; }

.modal .form-group { margin-bottom: 12px; }
.modal .form-group input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--r-2);
  padding: 12px 14px;
  font: inherit;
  outline: none;
}
.modal .form-group input:focus { border-color: var(--pink); }

.modal .password-input-group,
.modal .code-input-group { position: relative; }
.modal .toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
}
.modal .send-code-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: transparent;
  border: 1px solid var(--pink);
  color: var(--pink);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
}
.modal .send-code-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.modal .form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.modal .remember-me { display: flex; align-items: center; gap: 6px; }
.modal .btn-primary {
  width: 100%;
  border: none;
  background: var(--grad-primary);
  color: #0a0a0d;
  font-weight: 800;
  border-radius: var(--r-pill);
  padding: 12px;
  font-size: 0.95rem;
}
.modal .auth-footer {
  text-align: center;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.modal .auth-footer a,
.modal .switch-to-login,
.modal .register-link {
  color: var(--pink);
  font-weight: 600;
}
.modal .password-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.modal .strength-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elev-3);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.modal .strength-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--red);
  transition: width 0.2s ease, background 0.2s ease;
}
.modal .strength-bar.strength-weak::after   { width: 33%; background: var(--red); }
.modal .strength-bar.strength-medium::after { width: 66%; background: var(--orange); }
.modal .strength-bar.strength-strong::after { width: 100%; background: var(--green); }

/* ----- 13. Toast container (compatible with common.js showToast) ----- */
.toast-container {
  position: fixed;
  top: calc(16px + var(--safe-top));
  right: 50%;
  transform: translateX(50%);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--r-2);
  color: #fff;
  font-size: 0.88rem;
  background: rgba(20, 20, 24, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toast-success { border-color: var(--green); }
.toast-error   { border-color: var(--red); }
.toast-info    { border-color: var(--border); }
.toast-message { flex: 1; margin-right: 10px; }
.toast-close   { cursor: pointer; opacity: 0.6; font-size: 18px; }
.toast-close:hover { opacity: 1; }

/* ----- Pricing / free-trial (pricing.js) ----- */
html.pricing-anon .js-pricing-chip,
html.pricing-anon .feed-cost-chip,
html.pricing-anon .feed-consent__price { display: none !important; }
/* Soften membership hierarchy signals for guests */
html.pricing-anon .af-tier-note,
html.pricing-anon .cc-tier-note,
html.pricing-anon .ap-tier-note,
html.pricing-anon .up-tier-note,
html.pricing-anon .ae-tier-note,
html.pricing-anon .pe-tier-note,
html.pricing-anon .mk-tier-note,
html.pricing-anon .pa-tier-note,
html.pricing-anon .sv-tier-note,
html.pricing-anon .ve-tier-note,
html.pricing-anon .vd-tier-note { display: none !important; }

.feature-free-hint,
.js-free-trial-hint {
  margin: 0 16px 8px;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, rgba(255,255,255,0.72));
  text-align: center;
  line-height: 1.35;
}
.js-pricing-free-label {
  font-weight: 800;
  letter-spacing: 0.02em;
}
.js-pricing-chip.is-pricing-free::before,
.feed-cost-chip.is-pricing-free::before { content: none !important; }

/* ----- 14. Utility ----- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* ----- 15. Brand wordmark ----- */
.brand-wordmark {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ----- 16. Empty state ----- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { margin: 0 0 16px; }

/* ----- 17. Stage 0 preview only ----- */
.shell-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px;
  gap: 18px;
}
.shell-preview h1 { margin: 0; }
.shell-preview .swatch-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.shell-preview .swatch { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); }
