:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --primary: #0f172a;
  --primary-light: #1e293b;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --text: #1e293b;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --error: #ef4444;
  --success: #10b981;
  --info: #3b82f6;
  --radius: 24px;
  --radius-sm: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 10px 40px rgba(0,0,0,0.08);
  --shadow-hover: 0 1px 3px rgba(0,0,0,0.05), 0 20px 60px rgba(0,0,0,0.12);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* --- Navigation --- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
}
.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-logo svg {
  width: 28px;
  height: 28px;
}
.nav-links {
  display: flex;
  gap: 0.5rem;
}
.nav-links a {
  padding: 0.5rem 1rem;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}
.nav-links a:hover {
  color: var(--primary);
  background: var(--border-light);
}
.nav-links a.active {
  color: var(--primary);
  background: #f1f5f9;
  font-weight: 600;
}

/* --- Header --- */
header {
  text-align: center;
  padding: 5rem 1rem 4rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  color: white;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(245,158,11,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(59,130,246,0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}
header p {
  font-size: 1.05rem;
  opacity: 0.7;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  font-weight: 400;
}

/* --- Main --- */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  position: relative;
}

/* --- Calculator Card --- */
.calculator-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 3rem);
  box-shadow: var(--shadow);
  margin-top: -2rem;
  position: relative;
  z-index: 2;
}

.intro-text {
  color: var(--text-light);
  margin-bottom: 2.5rem;
  font-size: 1rem;
  line-height: 1.8;
}

/* --- Form Sections --- */
.form-section { margin-bottom: 2.5rem; }
.form-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.form-section h2 .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Formula Cards --- */
.formula-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.formula-card {
  position: relative;
  padding: 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  background: white;
}
.formula-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.formula-card.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  box-shadow: 0 0 0 4px rgba(245,158,11,0.1), var(--shadow);
}
.formula-card .card-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
  transition: var(--transition);
}
.formula-card.selected .card-icon {
  background: var(--accent);
  color: white;
}
.formula-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.formula-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.5;
}
.formula-card .check-mark {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition);
}
.formula-card.selected .check-mark {
  opacity: 1;
  transform: scale(1);
}

/* --- Activity Cards --- */
.activity-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.activity-card {
  position: relative;
  padding: 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  background: white;
  text-align: center;
}
.activity-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}
.activity-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  box-shadow: 0 0 0 4px rgba(15,23,42,0.06), var(--shadow);
}
.activity-card .act-label {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.activity-card .act-desc {
  font-size: 0.8rem;
  color: var(--text-light);
}
.activity-card .act-factor {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
}
.activity-card.selected .act-factor {
  background: var(--primary);
  color: white;
}

/* --- Form Grid --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}
.form-group { position: relative; }
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
}
input, select {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  transition: var(--transition);
  background: white;
  color: var(--text);
  font-family: inherit;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(245,158,11,0.12);
}
.error-message {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.4rem;
  display: none;
  font-weight: 500;
}
.form-group.error input,
.form-group.error select {
  border-color: var(--error);
  box-shadow: 0 0 0 4px rgba(239,68,68,0.1);
}
.hidden { display: none !important; }

/* --- Button --- */
button[type="submit"] {
  width: 100%;
  padding: 1.1rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: var(--primary);
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  font-family: inherit;
}
button[type="submit"]::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.2) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}
button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 40px rgba(245,158,11,0.35);
}
button[type="submit"]:hover::after { opacity: 1; }
button[type="submit"]:active { transform: translateY(0); }

/* --- Results --- */
#results {
  display: none;
  animation: fadeIn 0.6s ease-out;
  margin-top: 2.5rem;
}
@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(20px); } 
  to { opacity: 1; transform: translateY(0); } 
}

.result-hero {
  text-align: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 2.5rem 2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
  color: white;
  position: relative;
  overflow: hidden;
}
.result-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(245,158,11,0.2) 0%, transparent 70%);
  border-radius: 50%;
}
.result-hero .hero-label {
  font-size: 0.95rem;
  opacity: 0.7;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}
.result-hero .hero-number {
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #ffffff 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  z-index: 1;
}
.result-hero .hero-unit {
  font-size: 1.2rem;
  font-weight: 600;
  opacity: 0.8;
  margin-top: 0.3rem;
}
.result-hero .hero-formula {
  font-size: 0.9rem;
  opacity: 0.5;
  margin-top: 0.8rem;
  position: relative;
  z-index: 1;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  position: relative;
  z-index: 1;
}
.breakdown-item .bd-label {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-bottom: 0.3rem;
}
.breakdown-item .bd-value {
  font-size: 1.4rem;
  font-weight: 700;
}

/* --- Diet Grid --- */
.diet-section-title {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--primary);
}
.diet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.diet-card {
  padding: 1.8rem 1.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: var(--transition);
  border: 1px solid transparent;
}
.diet-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.diet-card.cut {
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
  border-color: #a7f3d0;
}
.diet-card.maintain {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
  border-color: #bfdbfe;
}
.diet-card.bulk {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  border-color: #fde68a;
}
.diet-card .diet-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.8rem;
  font-size: 1.3rem;
}
.diet-card.cut .diet-icon { background: #d1fae5; }
.diet-card.maintain .diet-icon { background: #dbeafe; }
.diet-card.bulk .diet-icon { background: #fef3c7; }
.diet-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--text);
}
.diet-card .cal {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.3rem;
}
.diet-card.cut .cal { color: #059669; }
.diet-card.maintain .cal { color: #2563eb; }
.diet-card.bulk .cal { color: #d97706; }
.diet-card .cal-unit {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  display: block;
}
.diet-card .reason {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.6;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

/* --- FAQ --- */
.faq-section { margin-top: 4rem; }
.faq-section > h2 {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 2rem;
  color: var(--primary);
}
.faq-item {
  background: var(--card-bg);
  padding: 1.5rem 2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--border-light);
  transition: var(--transition);
}
.faq-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--border);
}
.faq-item h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.faq-item p {
  color: var(--text-light);
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.7;
}
.faq-item ul, .faq-item ol {
  padding-left: 1.2rem;
  color: var(--text-light);
  font-size: 0.95rem;
}
.faq-item li { margin-bottom: 0.4rem; line-height: 1.6; }

.tip-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 1rem 1.2rem;
  border-radius: 12px;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #92400e;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.tip-box .tip-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }

/* --- Footer --- */
footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-light);
  margin-top: 3rem;
}
footer a {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.2s;
}
footer a:hover { color: var(--primary); }

/* --- Page Link Banner --- */
.page-link-banner {
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem 2rem;
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-link-banner p {
  font-size: 0.95rem;
  color: var(--text-light);
  margin: 0;
}
.page-link-banner a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
}
.page-link-banner a:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .formula-cards { grid-template-columns: 1fr; }
  .activity-cards { grid-template-columns: 1fr; }
  .diet-grid { grid-template-columns: 1fr; }
  .breakdown-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links a { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
  .page-link-banner { flex-direction: column; text-align: center; }
  .faq-item { padding: 1.2rem; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}