/* 灵境 (LingJing) Design System - aligned with HTML-UI reference */
:root {
  /* Core Palette */
  --background: 40 15% 97%;
  --foreground: 270 10% 25%;
  --card: 0 0% 100%;
  --card-foreground: 270 10% 25%;
  --primary: 280 60% 65%;
  --primary-foreground: 0 0% 100%;
  --secondary: 270 15% 90%;
  --secondary-foreground: 270 10% 30%;
  --muted: 270 10% 95%;
  --muted-foreground: 270 10% 35%;
  --accent: 290 50% 75%;
  --accent-foreground: 270 10% 25%;
  --destructive: 0 60% 70%;
  --border: 270 10% 88%;
  --input: 270 10% 88%;
  --ring: 280 60% 65%;
  --radius: 1rem;

  /* Five Elements Energy Colors */
  --energy-metal: 45 80% 60%;
  --energy-wood: 140 50% 55%;
  --energy-water: 200 70% 60%;
  --energy-fire: 15 85% 60%;
  --energy-earth: 35 50% 50%;

  /* Shadows */
  --shadow-soft: 0 4px 24px rgba(139, 92, 246, 0.08);
  --shadow-card: 0 8px 32px rgba(139, 92, 246, 0.12);
  --shadow-glow: 0 0 24px rgba(167, 139, 250, 0.3);

  /* Safe Areas */
  --safe-area-top: env(safe-area-inset-top, 44px);
  --safe-area-bottom: env(safe-area-inset-bottom, 34px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: linear-gradient(135deg, hsl(var(--background)), #fff);
  overflow-x: hidden;
}

/* Glass Effect */
.glass-effect {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.glass-effect-dark {
  background: rgba(139, 92, 246, 0.15);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* Energy Gradient */
.energy-gradient {
  background: linear-gradient(135deg, hsl(var(--primary)), #d49fdf);
}

.energy-gradient-radial {
  background: radial-gradient(circle at top, hsl(var(--primary)) 0%, hsl(var(--accent)) 50%, transparent 100%);
}

/* Text Gradient */
.text-gradient {
  background: linear-gradient(135deg, hsl(var(--primary)), #d49fdf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  padding: 14px 24px;
  width: 100%;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, hsl(var(--primary)), #d49fdf);
  color: white;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover { box-shadow: var(--shadow-card); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

.btn-outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--primary));
}

.btn-ghost {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* Input */
.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid hsl(var(--input));
  border-radius: 10px;
  font-size: 0.875rem;
  background: hsl(var(--background) / 0.5);
  color: hsl(var(--foreground));
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.input-field:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.input-field::placeholder { color: hsl(var(--muted-foreground) / 0.5); }

.input-suffix {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

/* Cards */
.card {
  background: hsl(var(--card));
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 1px solid hsl(var(--border) / 0.5);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--card-foreground));
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
  border-top: 1px solid hsl(var(--border) / 0.5);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-weight: 500;
  transition: all 0.3s;
  min-width: 64px;
  border-radius: 12px;
}

.nav-item.active {
  color: hsl(var(--primary));
  transform: scale(1.05);
}
.nav-item.active .nav-label { font-weight: 600; }
.nav-item:active { transform: scale(0.9); }

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nav-item.active .nav-icon svg { stroke-width: 2.5; }
.nav-item.active .nav-icon { transform: scale(1.1); }

.nav-glow {
  position: absolute;
  inset: -8px;
  border-radius: 9999px;
  opacity: 0.2;
  filter: blur(8px);
  animation: pulse-glow 2s ease-in-out infinite;
}

/* Header */
.energy-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  gap: 12px;
  border-bottom: 1px solid hsl(var(--border) / 0.3);
}

.energy-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  position: relative;
}

.energy-badge-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  opacity: 0.3;
  filter: blur(8px);
}

.energy-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.energy-bar-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.energy-bar-track {
  height: 6px;
  background: hsl(var(--muted));
  border-radius: 3px;
  overflow: hidden;
}

.energy-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Floating background decorations */
.float-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.1;
  animation: float 3s ease-in-out infinite;
  pointer-events: none;
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(167, 139, 250, 0.3); }
  50% { box-shadow: 0 0 32px rgba(167, 139, 250, 0.6); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes card-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes ambient-glow {
  0%, 100% { opacity: 0.1; transform: scale(1); }
  50% { opacity: 0.15; transform: scale(1.05); }
}

.animate-float { animation: float 3s ease-in-out infinite; }
.animate-pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }
.animate-card-float { animation: card-float 3s ease-in-out infinite; }
.animate-ambient { animation: ambient-glow 8s ease-in-out infinite; }

/* Scrollable content */
.page-content {
  padding: 0 20px 100px 20px;
  overflow-y: auto;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.badge-outline {
  border: 1px solid hsl(var(--primary) / 0.3);
  color: hsl(var(--primary));
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: hsl(var(--primary) / 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
}

.section-link {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.section-link:hover { color: hsl(var(--primary)); }

/* Checkbox */
.checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.checkbox-wrapper input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: hsl(var(--primary));
  flex-shrink: 0;
  margin-top: 1px;
}

.checkbox-wrapper a {
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: color 0.2s;
}
.checkbox-wrapper a:hover { color: hsl(var(--primary)); }

/* Toast */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: hsl(var(--foreground));
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.875rem;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Icon button (for header actions) */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: hsl(var(--foreground));
  transition: all 0.2s;
}
.icon-btn:hover { background: hsl(var(--accent) / 0.2); }
.icon-btn:active { transform: scale(0.9); }

/* Safe areas */
.safe-area-top { padding-top: env(safe-area-inset-top); }
.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* Scrollbar */
.scrollbar-none { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-none::-webkit-scrollbar { display: none; }
.smooth-scroll { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

/* Shadow utilities */
.shadow-soft { box-shadow: var(--shadow-soft); }
.shadow-card { box-shadow: var(--shadow-card); }
.shadow-glow { box-shadow: var(--shadow-glow); }

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: hsl(var(--muted-foreground)); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.rounded-full { border-radius: 9999px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }
.transition-all { transition: all 0.3s; }

/* === Theme: Dark Mode === */
[data-theme="dark"] {
  --background: 270 20% 10%;
  --foreground: 270 5% 90%;
  --card: 270 15% 15%;
  --card-foreground: 270 5% 90%;
  --primary: 280 60% 65%;
  --primary-foreground: 0 0% 100%;
  --secondary: 270 15% 20%;
  --secondary-foreground: 270 10% 80%;
  --muted: 270 10% 20%;
  --muted-foreground: 270 8% 60%;
  --accent: 290 50% 75%;
  --accent-foreground: 270 5% 90%;
  --destructive: 0 60% 70%;
  --border: 270 10% 25%;
  --input: 270 10% 25%;
  --ring: 280 60% 65%;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px rgba(167, 139, 250, 0.2);
}

[data-theme="dark"] .app-container {
  background: linear-gradient(135deg, hsl(270 20% 8%), hsl(270 15% 12%));
}

[data-theme="dark"] .glass-effect {
  background: rgba(30, 20, 50, 0.7);
  border-color: rgba(100, 80, 150, 0.3);
}

[data-theme="dark"] .toast {
  background: hsl(270 10% 80%);
  color: hsl(270 20% 10%);
}

/* === Font Size Presets === */
/* === Font Size Presets (zoom scales all elements including px values) === */
html[data-font="small"] { zoom: 0.9; }
html[data-font="standard"] { zoom: 1; }
html[data-font="large"] { zoom: 1.1; }

/* === Reduced Motion === */
.reduced-motion,
.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
