/* ===== Apple Design System Tokens ===== */
:root {
  --apple-bg: #F5F5F7;
  --apple-card: rgba(255, 255, 255, 0.72);
  --apple-card-hover: rgba(255, 255, 255, 0.88);
  --apple-text: #1d1d1f;
  --apple-text-secondary: #6e6e73;
  --apple-text-tertiary: #aeaeb2;
  --apple-accent: #0071e3;
  --apple-accent-hover: #0077ED;
  --apple-accent-soft: rgba(0, 113, 227, 0.08);
  --apple-border: rgba(0, 0, 0, 0.06);
  --apple-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --apple-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --apple-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.10);
  --apple-green: #34c759;
  --apple-green-soft: rgba(52, 199, 89, 0.1);
  --apple-red: #ff3b30;
  --apple-red-soft: rgba(255, 59, 48, 0.08);
  --apple-amber: #ff9f0a;
  --apple-amber-soft: rgba(255, 159, 10, 0.1);
  --apple-radius-sm: 10px;
  --apple-radius: 14px;
  --apple-radius-lg: 20px;
  --apple-radius-pill: 24px;
  --blur: saturate(180%) blur(24px);
  --transition-fast: 0.15s cubic-bezier(0.2, 0, 0, 1);
  --transition: 0.25s cubic-bezier(0.2, 0, 0, 1);
  --transition-slow: 0.35s cubic-bezier(0.2, 0, 0, 1);

  /* Legacy compat */
  --bg-primary: #ffffff;
  --bg-secondary: #F5F5F7;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --border: rgba(0, 0, 0, 0.06);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.1);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.08);
  --amber: #ff9f0a;
  --amber-soft: rgba(255, 159, 10, 0.1);
}

/* ─── 会员等级配色方案 ─── */
/* Free 灰绿色调 */
.tier-free {
  --accent: #5e9e6d;
  --accent-soft: rgba(94, 158, 109, 0.08);
  --apple-accent: #5e9e6d;
  --apple-accent-hover: #4d8a5c;
  --apple-accent-soft: rgba(94, 158, 109, 0.08);
}
/* VIP 琥珀金色调 */
.tier-vip {
  --accent: #d4a017;
  --accent-soft: rgba(212, 160, 23, 0.08);
  --apple-accent: #d4a017;
  --apple-accent-hover: #b8890f;
  --apple-accent-soft: rgba(212, 160, 23, 0.08);
}
/* Pro 蓝色调（默认） */
.tier-pro {
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --apple-accent: #0071e3;
  --apple-accent-hover: #0077ED;
  --apple-accent-soft: rgba(0, 113, 227, 0.08);
}

.dark {
  --apple-bg: #1d1d1f;
  --apple-card: rgba(44, 44, 46, 0.7);
  --apple-card-hover: rgba(44, 44, 46, 0.88);
  --apple-text: #f5f5f7;
  --apple-text-secondary: #a1a1a6;
  --apple-text-tertiary: #636366;
  --apple-accent: #2997ff;
  --apple-accent-hover: #40a6ff;
  --apple-accent-soft: rgba(41, 151, 255, 0.12);
  --apple-border: rgba(255, 255, 255, 0.08);
  --apple-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --apple-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --apple-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);

  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #636366;
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.12);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.12);
  --amber: #ff9f0a;
  --amber-soft: rgba(255, 159, 10, 0.15);
}

/* ─── 会员等级配色方案（暗色模式） ─── */
.dark.tier-free {
  --accent: #7bc48f;
  --accent-soft: rgba(123, 196, 143, 0.12);
  --apple-accent: #7bc48f;
  --apple-accent-hover: #8fd4a0;
  --apple-accent-soft: rgba(123, 196, 143, 0.12);
}
.dark.tier-vip {
  --accent: #e6b422;
  --accent-soft: rgba(230, 180, 34, 0.12);
  --apple-accent: #e6b422;
  --apple-accent-hover: #f0c840;
  --apple-accent-soft: rgba(230, 180, 34, 0.12);
}
.dark.tier-pro {
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.12);
  --apple-accent: #2997ff;
  --apple-accent-hover: #40a6ff;
  --apple-accent-soft: rgba(41, 151, 255, 0.12);
}

/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.022em;
  background: var(--apple-bg);
  color: var(--apple-text);
  min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

/* ===== Glass Card ===== */
.glass, .card {
  background: var(--apple-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--apple-border);
  border-radius: var(--apple-radius);
  box-shadow: var(--apple-shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), background var(--transition);
}
.card:hover { box-shadow: var(--apple-shadow-md); }
.card { padding: 1.25rem; }

/* ===== Inputs & Selects ===== */
.input, .select, textarea.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--apple-border);
  border-radius: var(--apple-radius-sm);
  background: var(--apple-card);
  color: var(--apple-text);
  font-size: 14px;
  font-family: inherit;
  letter-spacing: -0.022em;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .select:focus {
  border-color: var(--apple-accent);
  box-shadow: 0 0 0 3px var(--apple-accent-soft);
}
.input::placeholder { color: var(--apple-text-tertiary); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.textarea { min-height: 80px; resize: vertical; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--apple-radius-pill);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  outline: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--apple-accent-soft); }

.btn-primary {
  background: var(--apple-accent);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 113, 227, 0.2);
}
.btn-primary:hover { background: var(--apple-accent-hover); box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3); }

.btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--apple-text);
}
.btn-secondary:hover { background: rgba(0, 0, 0, 0.08); }
.dark .btn-secondary { background: rgba(255, 255, 255, 0.08); }
.dark .btn-secondary:hover { background: rgba(255, 255, 255, 0.14); }

.btn-ghost {
  background: transparent;
  color: var(--apple-text-secondary);
  padding: 8px 16px;
}
.btn-ghost:hover { background: rgba(0, 0, 0, 0.04); color: var(--apple-text); }
.dark .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--apple-radius-pill); }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: var(--apple-radius-pill); }

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.06) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--apple-radius-sm);
}
.dark .skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Keyframe Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ===== Modal Overlay ===== */
#page-modal {
  animation: fadeIn 0.25s ease-out;
}
#page-modal > .bg-black\/40,
#page-modal > [class*="bg-black"] {
  animation: fadeIn 0.25s ease-out;
}
#page-modal > .card,
#page-modal > [class*="relative card"] {
  animation: fadeInUp 0.35s cubic-bezier(0.2, 0, 0, 1);
}

/* ===== Toast ===== */
#toast {
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

/* ===== Style Category Tabs ===== */
.style-cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--apple-radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--apple-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}
.style-cat-tab:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--apple-text);
}
.style-cat-tab.active {
  background: var(--apple-accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}
.dark .style-cat-tab:hover { background: rgba(255, 255, 255, 0.08); }

/* ===== Style Card (Button-style) ===== */
.style-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: var(--apple-radius-sm);
  border: 1.5px solid var(--apple-border);
  background: rgba(0, 0, 0, 0.02);
  color: var(--apple-text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  white-space: nowrap;
}
.dark .style-btn { background: rgba(255, 255, 255, 0.04); }
.style-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--apple-accent);
  box-shadow: var(--apple-shadow-md);
  transform: translateY(-1px);
}
.dark .style-btn:hover { background: rgba(255, 255, 255, 0.08); }
.style-btn:active { transform: scale(0.97); }
.style-btn.selected {
  border-color: var(--apple-accent);
  background: var(--apple-accent);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.35);
}
.dark .style-btn.selected {
  background: var(--apple-accent);
  color: #ffffff;
}

/* ===== Nav Indicator ===== */
.nav-indicator {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 50%;
  border-radius: 0 2px 2px 0;
  background: var(--apple-accent);
  opacity: 0;
  transition: opacity var(--transition);
}
.nav-item.active .nav-indicator { opacity: 1; }
.nav-item {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--apple-radius-sm);
  transition: background var(--transition-fast);
  cursor: pointer;
}
.nav-item:hover { background: rgba(0, 0, 0, 0.04); }
.dark .nav-item:hover { background: rgba(255, 255, 255, 0.06); }

/* ===== Page Content Transitions ===== */
.profile-content {
  animation: fadeIn 0.3s ease-out;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Utility ===== */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Mode Tab ===== */
.mode-tab {
  padding: 8px 18px;
  border-radius: var(--apple-radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(0, 0, 0, 0.03);
  color: var(--apple-text-secondary);
  border: none;
  font-family: inherit;
  letter-spacing: -0.01em;
}
.mode-tab:hover { background: rgba(0, 0, 0, 0.06); }
.mode-tab.active { background: var(--apple-accent); color: #ffffff; }
.dark .mode-tab { background: rgba(255, 255, 255, 0.06); }
.dark .mode-tab:hover { background: rgba(255, 255, 255, 0.1); }

/* ===== Range Slider ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--apple-border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--apple-accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 113, 227, 0.3);
  transition: transform 0.15s ease-out;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(0.95); }